Permalink
Browse files

Split WebElementWrapper into abstract/webkit parts

  • Loading branch information...
The-Compiler committed Aug 8, 2016
1 parent 743d2dc commit dfbadaf7c24f3245e387f33f1347c2e53d74b820
@@ -40,7 +40,7 @@
from qutebrowser.commands import userscripts, cmdexc, cmdutils, runners
from qutebrowser.config import config, configexc
from qutebrowser.browser import urlmarks, browsertab, inspector, navigate
-from qutebrowser.browser.webkit import webelem, downloads, mhtml
+from qutebrowser.browser.webkit import webkitelem, downloads, mhtml
from qutebrowser.keyinput import modeman
from qutebrowser.utils import (message, usertypes, log, qtutils, urlutils,
objreg, utils, typing, javascript)
@@ -1422,8 +1422,8 @@ def open_editor(self):
tab = self._current_widget()
page = tab._widget.page() # pylint: disable=protected-access
try:
- elem = webelem.focus_elem(page.currentFrame())
- except webelem.IsNullError:
+ elem = webkitelem.focus_elem(page.currentFrame())
+ except webkitelem.IsNullError:
raise cmdexc.CommandError("No element focused!")
if not elem.is_editable(strict=True):
raise cmdexc.CommandError("Focused element is not editable!")
@@ -1444,7 +1444,7 @@ def on_editing_finished(self, elem, text):
"""
try:
elem.set_text(text, use_js=True)
- except webelem.IsNullError:
+ except webkitelem.IsNullError:
raise cmdexc.CommandError("Element vanished while editing!")
@cmdutils.register(instance='command-dispatcher',
@@ -1456,8 +1456,8 @@ def paste_primary(self):
tab = self._current_widget()
page = tab._widget.page() # pylint: disable=protected-access
try:
- elem = webelem.focus_elem(page.currentFrame())
- except webelem.IsNullError:
+ elem = webkitelem.focus_elem(page.currentFrame())
+ except webkitelem.IsNullError:
raise cmdexc.CommandError("No element focused!")
if not elem.is_editable(strict=True):
raise cmdexc.CommandError("Focused element is not editable!")
@@ -28,12 +28,11 @@
from PyQt5.QtCore import (pyqtSignal, pyqtSlot, QObject, QEvent, Qt, QUrl,
QTimer)
from PyQt5.QtGui import QMouseEvent
-from PyQt5.QtWebKit import QWebElement
from PyQt5.QtWebKitWidgets import QWebPage
from qutebrowser.config import config
from qutebrowser.keyinput import modeman, modeparsers
-from qutebrowser.browser.webkit import webelem
+from qutebrowser.browser import webelem
from qutebrowser.commands import userscripts, cmdexc, cmdutils, runners
from qutebrowser.utils import usertypes, log, qtutils, message, objreg, utils
@@ -374,7 +373,7 @@ def _cleanup(self):
for elem in self._context.all_elems:
try:
elem.label.remove_from_document()
- except webelem.IsNullError:
+ except webelem.Error:
pass
text = self._get_text()
message_bridge = objreg.get('message-bridge', scope='window',
@@ -516,7 +515,7 @@ def _number_to_hint_str(self, number, chars, digits=0):
def _is_hidden(self, elem):
"""Check if the element is hidden via display=none."""
- display = elem.style_property('display', QWebElement.InlineStyle)
+ display = elem.style_property('display', strategy='inline')
return display == 'none'
def _show_elem(self, elem):
@@ -767,7 +766,7 @@ def handle_partial_key(self, keystr):
else:
# element doesn't match anymore -> hide it
self._hide_elem(elem.label)
- except webelem.IsNullError:
+ except webelem.Error:
pass
def _filter_number_hints(self):
@@ -782,7 +781,7 @@ def _filter_number_hints(self):
try:
if not self._is_hidden(e.label):
elems.append(e)
- except webelem.IsNullError:
+ except webelem.Error:
pass
if not elems:
# Whoops, filtered all hints
@@ -813,7 +812,7 @@ def _filter_non_number_hints(self):
try:
if not self._is_hidden(elem.label):
visible[string] = elem
- except webelem.IsNullError:
+ except webelem.Error:
pass
if not visible:
# Whoops, filtered all hints
@@ -844,7 +843,7 @@ def filter_hints(self, filterstr):
else:
# element doesn't match anymore -> hide it
self._hide_elem(elem.label)
- except webelem.IsNullError:
+ except webelem.Error:
pass
if config.get('hints', 'mode') == 'number':
@@ -961,7 +960,7 @@ def on_contents_size_changed(self):
e.label.remove_from_document()
continue
self._set_style_position(e.elem, e.label)
- except webelem.IsNullError:
+ except webelem.Error:
pass
@pyqtSlot(usertypes.KeyMode)
@@ -21,7 +21,7 @@
import posixpath
-from qutebrowser.browser.webkit import webelem
+from qutebrowser.browser import webelem
from qutebrowser.config import config
from qutebrowser.utils import (usertypes, objreg, urlutils, log, message,
qtutils)
Oops, something went wrong.

0 comments on commit dfbadaf

Please sign in to comment.