From 65f407e9260233ead7c5b512f6e5f626956559d5 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 1 Mar 2017 17:54:27 +0100 Subject: [PATCH] Remove webelem.style_property() It's not used anymore, and not possible to support with QtWebEngine without a massive performance hit when serializing elements. --- qutebrowser/browser/webelem.py | 4 ---- qutebrowser/browser/webengine/webengineelem.py | 4 ---- qutebrowser/browser/webkit/webkitelem.py | 10 ---------- scripts/dev/run_vulture.py | 1 - tests/unit/browser/webkit/test_webkitelem.py | 8 ++------ 5 files changed, 2 insertions(+), 25 deletions(-) diff --git a/qutebrowser/browser/webelem.py b/qutebrowser/browser/webelem.py index 4c3fb3491..5dd263da3 100644 --- a/qutebrowser/browser/webelem.py +++ b/qutebrowser/browser/webelem.py @@ -120,10 +120,6 @@ class AbstractWebElement(collections.abc.MutableMapping): """Get the geometry for this element.""" raise NotImplementedError - def style_property(self, name, *, strategy): - """Get the element style resolved with the given strategy.""" - raise NotImplementedError - def classes(self): """Get a list of classes assigned to this element.""" raise NotImplementedError diff --git a/qutebrowser/browser/webengine/webengineelem.py b/qutebrowser/browser/webengine/webengineelem.py index 8b1f633b8..0ebcd72b1 100644 --- a/qutebrowser/browser/webengine/webengineelem.py +++ b/qutebrowser/browser/webengine/webengineelem.py @@ -79,10 +79,6 @@ class WebEngineElement(webelem.AbstractWebElement): log.stub() return QRect() - def style_property(self, name, *, strategy): - log.stub() - return '' - def classes(self): """Get a list of classes assigned to this element.""" return self._js_dict['class_name'].split() diff --git a/qutebrowser/browser/webkit/webkitelem.py b/qutebrowser/browser/webkit/webkitelem.py index fdd2e25d4..7db70bced 100644 --- a/qutebrowser/browser/webkit/webkitelem.py +++ b/qutebrowser/browser/webkit/webkitelem.py @@ -96,16 +96,6 @@ class WebKitElement(webelem.AbstractWebElement): self._check_vanished() return self._elem.geometry() - def style_property(self, name, *, strategy): - self._check_vanished() - strategies = { - # FIXME:qtwebengine which ones do we actually need? - 'inline': QWebElement.InlineStyle, - 'computed': QWebElement.ComputedStyle, - } - qt_strategy = strategies[strategy] - return self._elem.styleProperty(name, qt_strategy) - def classes(self): self._check_vanished() return self._elem.classes() diff --git a/scripts/dev/run_vulture.py b/scripts/dev/run_vulture.py index ade05ac94..43974e658 100755 --- a/scripts/dev/run_vulture.py +++ b/scripts/dev/run_vulture.py @@ -65,7 +65,6 @@ def whitelist_generator(): yield 'qutebrowser.utils.debug.qflags_key' yield 'qutebrowser.utils.qtutils.QtOSError.qt_errno' yield 'scripts.utils.bg_colors' - yield 'qutebrowser.browser.webelem.AbstractWebElement.style_property' yield 'qutebrowser.config.configtypes.Float' # Qt attributes diff --git a/tests/unit/browser/webkit/test_webkitelem.py b/tests/unit/browser/webkit/test_webkitelem.py index 3c3832aff..c4384fa61 100644 --- a/tests/unit/browser/webkit/test_webkitelem.py +++ b/tests/unit/browser/webkit/test_webkitelem.py @@ -262,7 +262,6 @@ class TestWebKitElement: len, lambda e: e.has_frame(), lambda e: e.geometry(), - lambda e: e.style_property('visibility', strategy='computed'), lambda e: e.value(), lambda e: e.set_value('foo'), lambda e: e.insert_text('foo'), @@ -276,8 +275,8 @@ class TestWebKitElement: lambda e: e.rect_on_view(), lambda e: e._is_visible(None), ], ids=['str', 'getitem', 'setitem', 'delitem', 'contains', 'iter', 'len', - 'frame', 'geometry', 'style_property', 'value', 'set_value', - 'insert_text', 'is_writable', 'is_content_editable', 'is_editable', + 'frame', 'geometry', 'value', 'set_value', 'insert_text', + 'is_writable', 'is_content_editable', 'is_editable', 'is_text_input', 'remove_blank_target', 'outer_xml', 'tag_name', 'rect_on_view', 'is_visible']) def test_vanished(self, elem, code): @@ -413,9 +412,6 @@ class TestWebKitElement: elem._elem.tagName.return_value = 'SPAN' assert elem.tag_name() == 'span' - def test_style_property(self, elem): - assert elem.style_property('foo', strategy='computed') == 'bar' - def test_value(self, elem): elem._elem.evaluateJavaScript.return_value = 'js' assert elem.value() == 'js'