diff options
author | Florian Bruhin <me@the-compiler.org> | 2024-03-27 16:55:18 +0100 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2024-03-27 16:55:18 +0100 |
commit | 7a969a2d54633f334f7ba2002515471eec472c59 (patch) | |
tree | df4d891c619bf81c7595c8024ecea8d296ff1edd /qutebrowser | |
parent | 481542844db79ee58740e8324ecc1090e3738c35 (diff) | |
download | qutebrowser-7a969a2d54633f334f7ba2002515471eec472c59.tar.gz qutebrowser-7a969a2d54633f334f7ba2002515471eec472c59.zip |
Add caret browsing debug logging
Diffstat (limited to 'qutebrowser')
-rw-r--r-- | qutebrowser/browser/webengine/webenginetab.py | 2 | ||||
-rw-r--r-- | qutebrowser/javascript/caret.js | 19 | ||||
-rw-r--r-- | qutebrowser/qutebrowser.py | 3 |
3 files changed, 23 insertions, 1 deletions
diff --git a/qutebrowser/browser/webengine/webenginetab.py b/qutebrowser/browser/webengine/webenginetab.py index 1c712db5e..02d912a50 100644 --- a/qutebrowser/browser/webengine/webenginetab.py +++ b/qutebrowser/browser/webengine/webenginetab.py @@ -292,6 +292,8 @@ class WebEngineCaret(browsertab.AbstractCaret): flags = set() if utils.is_windows: flags.add('windows') + if 'caret' in objects.debug_flags: + flags.add('debug') return list(flags) @pyqtSlot(usertypes.KeyMode) diff --git a/qutebrowser/javascript/caret.js b/qutebrowser/javascript/caret.js index b16a15348..4aeefcdb9 100644 --- a/qutebrowser/javascript/caret.js +++ b/qutebrowser/javascript/caret.js @@ -740,6 +740,12 @@ window._qutebrowser.caret = (function() { CaretBrowsing.isWindows = null; /** + * Whether we should log debug outputs. + * @type {boolean} + */ + CaretBrowsing.isDebug = null; + + /** * The id returned by window.setInterval for our stopAnimation function, so * we can cancel it when we call stopAnimation again. * @type {number?} @@ -1150,6 +1156,8 @@ window._qutebrowser.caret = (function() { action = "extend"; } + CaretBrowsing.debug(`(move) ${action} ${count} ${granularity} ${direction}, selection ${CaretBrowsing.selectionState}`); + for (let i = 0; i < count; i++) { if (CaretBrowsing.selectionState === CaretBrowsing.SelectionState.LINE) { CaretBrowsing.updateLineSelection(direction, granularity); @@ -1180,6 +1188,8 @@ window._qutebrowser.caret = (function() { if (CaretBrowsing.selectionState !== CaretBrowsing.SelectionState.NONE) { action = "extend"; } + CaretBrowsing.debug(`(moveToBlock) ${action} paragraph ${paragraph}, boundary ${boundary}, count ${count}, selection ${CaretBrowsing.selectionState}`); + for (let i = 0; i < count; i++) { window. getSelection(). @@ -1196,6 +1206,7 @@ window._qutebrowser.caret = (function() { }; CaretBrowsing.toggle = function(value) { + CaretBrowsing.debug(`(toggle) enabled ${CaretBrowsing.isEnabled}, force ${CaretBrowsing.forceEnabled}`); if (CaretBrowsing.forceEnabled) { CaretBrowsing.recreateCaretElement(); return; @@ -1231,6 +1242,7 @@ window._qutebrowser.caret = (function() { * is enabled and whether this window / iframe has focus. */ CaretBrowsing.updateIsCaretVisible = function() { + CaretBrowsing.debug(`(updateIsCaretVisible) isEnabled ${CaretBrowsing.isEnabled}, isWindowFocused ${CaretBrowsing.isWindowFocused}, isCaretVisible ${CaretBrowsing.isCaretVisible}, caretElement ${CaretBrowsing.caretElement}`); CaretBrowsing.isCaretVisible = (CaretBrowsing.isEnabled && CaretBrowsing.isWindowFocused); if (CaretBrowsing.isCaretVisible && !CaretBrowsing.caretElement) { @@ -1274,6 +1286,12 @@ window._qutebrowser.caret = (function() { } }; + CaretBrowsing.debug = (text) => { + if (CaretBrowsing.isDebug) { + console.debug(`caret: ${text}`); + } + } + CaretBrowsing.init = function() { CaretBrowsing.isWindowFocused = document.hasFocus(); @@ -1313,6 +1331,7 @@ window._qutebrowser.caret = (function() { funcs.setFlags = (flags) => { CaretBrowsing.isWindows = flags.includes("windows"); + CaretBrowsing.isDebug = flags.includes("debug"); }; funcs.disableCaret = () => { diff --git a/qutebrowser/qutebrowser.py b/qutebrowser/qutebrowser.py index c3a0a60be..e68156759 100644 --- a/qutebrowser/qutebrowser.py +++ b/qutebrowser/qutebrowser.py @@ -171,12 +171,13 @@ def debug_flag_error(flag): avoid-chromium-init: Enable `--version` without initializing Chromium. werror: Turn Python warnings into errors. test-notification-service: Use the testing libnotify service. + caret: Enable debug logging for caret.js. """ valid_flags = ['debug-exit', 'pdb-postmortem', 'no-sql-history', 'no-scroll-filtering', 'log-requests', 'log-cookies', 'log-scroll-pos', 'log-sensitive-keys', 'stack', 'chromium', 'wait-renderer-process', 'avoid-chromium-init', 'werror', - 'test-notification-service', 'log-qt-events'] + 'test-notification-service', 'log-qt-events', 'caret'] if flag in valid_flags: return flag |