Press enter to follow links instead of using js
This codepath may trigger a crash which was fixed by
0e75f3272d
.
However, this commit does not make it more likely to happen, and this
patch was backported into arch (at least).
In the future, we may be able to use <enter> on qtwebkit with js,
without triggering this crash
This commit is contained in:
parent
c33a887b2d
commit
de127497a2
@ -335,6 +335,11 @@ class WebEngineCaret(browsertab.AbstractCaret):
|
|||||||
"""
|
"""
|
||||||
if js_elem is None:
|
if js_elem is None:
|
||||||
return
|
return
|
||||||
|
if js_elem == "focused":
|
||||||
|
# we had a focused element, not a selected one. Just send <enter>
|
||||||
|
self._tab.key_press(Qt.Key_Enter)
|
||||||
|
return
|
||||||
|
|
||||||
assert isinstance(js_elem, dict), js_elem
|
assert isinstance(js_elem, dict), js_elem
|
||||||
elem = webengineelem.WebEngineElement(js_elem, tab=self._tab)
|
elem = webengineelem.WebEngineElement(js_elem, tab=self._tab)
|
||||||
if tab:
|
if tab:
|
||||||
@ -364,7 +369,8 @@ class WebEngineCaret(browsertab.AbstractCaret):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
# click an existing blue selection
|
# click an existing blue selection
|
||||||
js_code = javascript.assemble('webelem', 'find_selected_focused_link')
|
js_code = javascript.assemble('webelem',
|
||||||
|
'find_selected_focused_link')
|
||||||
self._tab.run_js_async(js_code, lambda jsret:
|
self._tab.run_js_async(js_code, lambda jsret:
|
||||||
self._follow_selected_cb(jsret, tab))
|
self._follow_selected_cb(jsret, tab))
|
||||||
|
|
||||||
|
@ -388,6 +388,11 @@ class WebKitCaret(browsertab.AbstractCaret):
|
|||||||
else:
|
else:
|
||||||
selection = self._widget.selectedHtml()
|
selection = self._widget.selectedHtml()
|
||||||
if not selection:
|
if not selection:
|
||||||
|
# Getting here may mean we crashed, but we can't do anything
|
||||||
|
# about that:
|
||||||
|
# https://github.com/annulen/webkit/commit/0e75f3272d149bc64899c161f150eb341a2417af
|
||||||
|
# TODO find a way to check if something is focused
|
||||||
|
self._tab.key_press(Qt.Key_Enter)
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
selected_element = xml.etree.ElementTree.fromstring(
|
selected_element = xml.etree.ElementTree.fromstring(
|
||||||
|
@ -329,8 +329,9 @@ window._qutebrowser.webelem = (function() {
|
|||||||
return serialize_elem(elem);
|
return serialize_elem(elem);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Function for returning a selection to python (so we can click it)
|
// Function for returning a selection or focus to python (so we can click
|
||||||
// If there is no selection, get the currently focused element.
|
// it). If nothing is selected but there is something focused, returns
|
||||||
|
// "focused"
|
||||||
funcs.find_selected_focused_link = () => {
|
funcs.find_selected_focused_link = () => {
|
||||||
const elem = window.getSelection().baseNode;
|
const elem = window.getSelection().baseNode;
|
||||||
if (elem) {
|
if (elem) {
|
||||||
@ -348,8 +349,7 @@ window._qutebrowser.webelem = (function() {
|
|||||||
if (serialized_frame_elem) {
|
if (serialized_frame_elem) {
|
||||||
return serialized_frame_elem;
|
return serialized_frame_elem;
|
||||||
}
|
}
|
||||||
// No selected element, return focused element
|
return funcs.find_focused() && "focused";
|
||||||
return funcs.find_focused();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
funcs.set_value = (id, value) => {
|
funcs.set_value = (id, value) => {
|
||||||
|
@ -321,28 +321,34 @@ Feature: Caret mode
|
|||||||
- data/caret.html
|
- data/caret.html
|
||||||
- data/hello.txt (active)
|
- data/hello.txt (active)
|
||||||
|
|
||||||
@qtwebkit_skip: getting focused element not possible without js
|
|
||||||
Scenario: :follow-selected with link tabbing (without JS)
|
Scenario: :follow-selected with link tabbing (without JS)
|
||||||
When I set content.javascript.enabled to false
|
When I set content.javascript.enabled to false
|
||||||
|
And I run :leave-mode
|
||||||
|
And I run :jseval document.activeElement.blur();
|
||||||
And I run :fake-key <tab>
|
And I run :fake-key <tab>
|
||||||
And I run :follow-selected
|
And I run :follow-selected
|
||||||
Then data/hello.txt should be loaded
|
Then data/hello.txt should be loaded
|
||||||
|
|
||||||
Scenario: :follow-selected with link tabbing (with JS)
|
Scenario: :follow-selected with link tabbing (with JS)
|
||||||
When I set content.javascript.enabled to true
|
When I set content.javascript.enabled to true
|
||||||
|
And I run :leave-mode
|
||||||
|
And I run :jseval document.activeElement.blur();
|
||||||
And I run :fake-key <tab>
|
And I run :fake-key <tab>
|
||||||
And I run :follow-selected
|
And I run :follow-selected
|
||||||
Then data/hello.txt should be loaded
|
Then data/hello.txt should be loaded
|
||||||
|
|
||||||
@qtwebkit_skip: getting focused element not possible without js
|
|
||||||
Scenario: :follow-selected with link tabbing in a tab (without JS)
|
Scenario: :follow-selected with link tabbing in a tab (without JS)
|
||||||
When I set content.javascript.enabled to false
|
When I set content.javascript.enabled to false
|
||||||
|
And I run :leave-mode
|
||||||
|
And I run :jseval document.activeElement.blur();
|
||||||
And I run :fake-key <tab>
|
And I run :fake-key <tab>
|
||||||
And I run :follow-selected --tab
|
And I run :follow-selected --tab
|
||||||
Then data/hello.txt should be loaded
|
Then data/hello.txt should be loaded
|
||||||
|
|
||||||
Scenario: :follow-selected with link tabbing in a tab (with JS)
|
Scenario: :follow-selected with link tabbing in a tab (with JS)
|
||||||
When I set content.javascript.enabled to true
|
When I set content.javascript.enabled to true
|
||||||
|
And I run :leave-mode
|
||||||
|
And I run :jseval document.activeElement.blur();
|
||||||
And I run :fake-key <tab>
|
And I run :fake-key <tab>
|
||||||
And I run :follow-selected --tab
|
And I run :follow-selected --tab
|
||||||
Then data/hello.txt should be loaded
|
Then data/hello.txt should be loaded
|
||||||
|
Loading…
Reference in New Issue
Block a user