Merge branch 'paretje-webengine-current'
This commit is contained in:
commit
1dd308b50b
@ -159,8 +159,8 @@ Contributors, sorted by the number of commits in descending order:
|
|||||||
* Joel Torstensson
|
* Joel Torstensson
|
||||||
* Patric Schmitz
|
* Patric Schmitz
|
||||||
* Tarcisio Fedrizzi
|
* Tarcisio Fedrizzi
|
||||||
* Claude
|
|
||||||
* Kevin Velghe
|
* Kevin Velghe
|
||||||
|
* Claude
|
||||||
* Corentin Julé
|
* Corentin Julé
|
||||||
* meles5
|
* meles5
|
||||||
* Philipp Hansch
|
* Philipp Hansch
|
||||||
|
@ -162,11 +162,6 @@ class AbstractWebElement(collections.abc.MutableMapping):
|
|||||||
"""Insert the given text into the element."""
|
"""Insert the given text into the element."""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def parent(self):
|
|
||||||
"""Get the parent element of this element."""
|
|
||||||
# FIXME:qtwebengine get rid of this?
|
|
||||||
raise NotImplementedError
|
|
||||||
|
|
||||||
def rect_on_view(self, *, elem_geometry=None, no_js=False):
|
def rect_on_view(self, *, elem_geometry=None, no_js=False):
|
||||||
"""Get the geometry of the element relative to the webview.
|
"""Get the geometry of the element relative to the webview.
|
||||||
|
|
||||||
@ -294,16 +289,7 @@ class AbstractWebElement(collections.abc.MutableMapping):
|
|||||||
|
|
||||||
def remove_blank_target(self):
|
def remove_blank_target(self):
|
||||||
"""Remove target from link."""
|
"""Remove target from link."""
|
||||||
elem = self
|
raise NotImplementedError
|
||||||
for _ in range(5):
|
|
||||||
if elem is None:
|
|
||||||
break
|
|
||||||
tag = elem.tag_name()
|
|
||||||
if tag == 'a' or tag == 'area':
|
|
||||||
if elem.get('target', None) == '_blank':
|
|
||||||
elem['target'] = '_top'
|
|
||||||
break
|
|
||||||
elem = elem.parent()
|
|
||||||
|
|
||||||
def resolve_url(self, baseurl):
|
def resolve_url(self, baseurl):
|
||||||
"""Resolve the URL in the element's src/href attribute.
|
"""Resolve the URL in the element's src/href attribute.
|
||||||
|
@ -117,12 +117,6 @@ class WebEngineElement(webelem.AbstractWebElement):
|
|||||||
js_code = javascript.assemble('webelem', 'insert_text', self._id, text)
|
js_code = javascript.assemble('webelem', 'insert_text', self._id, text)
|
||||||
self._tab.run_js_async(js_code)
|
self._tab.run_js_async(js_code)
|
||||||
|
|
||||||
def parent(self):
|
|
||||||
"""Get the parent element of this element."""
|
|
||||||
# FIXME:qtwebengine get rid of this?
|
|
||||||
log.stub()
|
|
||||||
return None
|
|
||||||
|
|
||||||
def rect_on_view(self, *, elem_geometry=None, no_js=False):
|
def rect_on_view(self, *, elem_geometry=None, no_js=False):
|
||||||
"""Get the geometry of the element relative to the webview.
|
"""Get the geometry of the element relative to the webview.
|
||||||
|
|
||||||
@ -163,3 +157,8 @@ class WebEngineElement(webelem.AbstractWebElement):
|
|||||||
log.webelem.debug("Couldn't find rectangle for {!r} ({})".format(
|
log.webelem.debug("Couldn't find rectangle for {!r} ({})".format(
|
||||||
self, rects))
|
self, rects))
|
||||||
return QRect()
|
return QRect()
|
||||||
|
|
||||||
|
def remove_blank_target(self):
|
||||||
|
js_code = javascript.assemble('webelem', 'remove_blank_target',
|
||||||
|
self._id)
|
||||||
|
self._tab.run_js_async(js_code)
|
||||||
|
@ -145,7 +145,8 @@ class WebKitElement(webelem.AbstractWebElement):
|
|||||||
this.dispatchEvent(event);
|
this.dispatchEvent(event);
|
||||||
""".format(javascript.string_escape(text)))
|
""".format(javascript.string_escape(text)))
|
||||||
|
|
||||||
def parent(self):
|
def _parent(self):
|
||||||
|
"""Get the parent element of this element."""
|
||||||
self._check_vanished()
|
self._check_vanished()
|
||||||
elem = self._elem.parent()
|
elem = self._elem.parent()
|
||||||
if elem is None or elem.isNull():
|
if elem is None or elem.isNull():
|
||||||
@ -283,6 +284,18 @@ class WebKitElement(webelem.AbstractWebElement):
|
|||||||
visible_in_frame = visible_on_screen
|
visible_in_frame = visible_on_screen
|
||||||
return all([visible_on_screen, visible_in_frame])
|
return all([visible_on_screen, visible_in_frame])
|
||||||
|
|
||||||
|
def remove_blank_target(self):
|
||||||
|
elem = self
|
||||||
|
for _ in range(5):
|
||||||
|
if elem is None:
|
||||||
|
break
|
||||||
|
tag = elem.tag_name()
|
||||||
|
if tag == 'a' or tag == 'area':
|
||||||
|
if elem.get('target', None) == '_blank':
|
||||||
|
elem['target'] = '_top'
|
||||||
|
break
|
||||||
|
elem = elem._parent() # pylint: disable=protected-access
|
||||||
|
|
||||||
|
|
||||||
def get_child_frames(startframe):
|
def get_child_frames(startframe):
|
||||||
"""Get all children recursively of a given QWebFrame.
|
"""Get all children recursively of a given QWebFrame.
|
||||||
|
@ -159,5 +159,19 @@ window._qutebrowser.webelem = (function() {
|
|||||||
elements[id].setAttribute(name, value);
|
elements[id].setAttribute(name, value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
funcs.remove_blank_target = function(id) {
|
||||||
|
var elem = elements[id];
|
||||||
|
while (elem !== null) {
|
||||||
|
var tag = elem.tagName.toLowerCase();
|
||||||
|
if (tag === "a" || tag === "area") {
|
||||||
|
if (elem.getAttribute("target") === "_blank") {
|
||||||
|
elem.setAttribute("target", "_top");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
elem = elem.parentElement;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return funcs;
|
return funcs;
|
||||||
})();
|
})();
|
||||||
|
Loading…
Reference in New Issue
Block a user