Clean up handling of focus element

Also fixes #1359.
This commit is contained in:
Florian Bruhin 2016-08-08 14:05:30 +02:00
parent 27330bd4d1
commit 0b16a36120
4 changed files with 4 additions and 5 deletions

View File

@ -36,7 +36,7 @@ from qutebrowser.utils import log, usertypes, utils, qtutils
Group = usertypes.enum('Group', ['all', 'links', 'images', 'url', 'prevnext',
'focus', 'inputs'])
'inputs'])
SELECTORS = {
@ -47,7 +47,6 @@ SELECTORS = {
Group.images: 'img',
Group.url: '[src], [href]',
Group.prevnext: 'a, area, button, link, [role=button]',
Group.focus: '*:focus',
Group.inputs: ('input[type=text], input[type=email], input[type=url], '
'input[type=tel], input[type=number], '
'input[type=password], input[type=search], '

View File

@ -353,5 +353,5 @@ def focus_elem(frame):
Args:
frame: The QWebFrame to search in.
"""
elem = frame.findFirstElement(webelem.SELECTORS[webelem.Group.focus])
elem = frame.findFirstElement('*:focus')
return WebKitElement(elem)

View File

@ -325,7 +325,7 @@ class WebView(QWebView):
return
frame = self.page().currentFrame()
try:
elem = webkitelem.WebKitElement(frame.findFirstElement(':focus'))
elem = webkitelem.focus_elem(frame)
except webkitelem.IsNullError:
log.webview.debug("Focused element is null!")
return

View File

@ -188,7 +188,7 @@ class SelectionAndFilterTests:
webelem.Group.url]),
]
GROUPS = [e for e in webelem.Group if e != webelem.Group.focus]
GROUPS = list(webelem.Group)
COMBINATIONS = list(itertools.product(TESTS, GROUPS))