Open links in current tab

Fix for #676

It removes the target of the link, as to prevent the website to overrule
the user. I guess the following things should be done:
 - add setting to enable/disable this behaviour
 - and/or add "hint all current"

Only the first one would be easiest. The second one requires us to keep track
of the original target. I should open a pull request for discussion.
This commit is contained in:
Kevin Velghe 2016-03-28 13:15:22 +02:00
parent bec8bd0285
commit 76935291c0
2 changed files with 8 additions and 0 deletions

View File

@ -463,6 +463,7 @@ class HintManager(QObject):
QMouseEvent(QEvent.MouseButtonRelease, pos, Qt.LeftButton,
Qt.NoButton, modifiers),
]
elem.remove_target()
for evt in events:
self.mouse_event.emit(evt)
if elem.is_text_input() and elem.is_editable():

View File

@ -285,6 +285,13 @@ class WebElementWrapper(collections.abc.MutableMapping):
tag = self._elem.tagName().lower()
return self.get('role', None) in roles or tag in ('input', 'textarea')
def remove_target(self):
"""Remove target from link"""
if self._elem.tagName().lower() == 'a':
self._elem.removeAttribute('target')
elif self.parent().tagName().lower() == 'a':
self.parent().removeAttribute('target')
def debug_text(self):
"""Get a text based on an element suitable for debug output."""
self._check_vanished()