From 0028bd94cc81f34b857ef4ae0b6a78aad69782c4 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 23 Jun 2014 08:02:10 +0200 Subject: [PATCH] Go to insertmode in google docs --- doc/BUGS | 2 -- qutebrowser/widgets/webview.py | 19 ++++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/doc/BUGS b/doc/BUGS index d9365ff8d..2e758abcf 100644 --- a/doc/BUGS +++ b/doc/BUGS @@ -10,8 +10,6 @@ Bugs - Handle it correctly when a new statusbar question is asked while another is still active. (see notes) -- iggy: qutebrowser gets out of insert mode a lot on Google Drive/Docs - - Ugly font rendering on Windows on http://support.sigasi.com/Knowledgebase/List - On doodle, when modifying something on http://doodle.com/create and clicking diff --git a/qutebrowser/widgets/webview.py b/qutebrowser/widgets/webview.py index 7230dc199..67d5bff14 100644 --- a/qutebrowser/widgets/webview.py +++ b/qutebrowser/widgets/webview.py @@ -185,7 +185,9 @@ class WebView(QWebView): Args: hitresult: A QWebHitTestResult """ - # FIXME is this algorithm accurate? + # Beginnings of div-classes which are actually some kind of editor. + DIV_CLASSES = ['CodeMirror', # Javascript editor over a textarea + 'kix-'] # Google Docs editor elem = hitresult.element() tag = elem.tagName().lower() if hitresult.isContentEditable() and webelem.is_writable(elem): @@ -208,12 +210,15 @@ class WebView(QWebView): log.mouse.debug(" clicked.".format(objtype)) return config.get('input', 'insert-mode-on-plugins') elif tag == 'div': - # CodeMirror is some java-script editor which hides the underlying - # textarea, but is editable. - if any([c.startswith('CodeMirror') for c in elem.classes()]): - return True - else: - return False + log.webview.debug("div with classes {} clicked!".format( + elem.classes())) + for klass in elem.classes(): + if any([klass.startswith(e) for e in DIV_CLASSES]): + return True + elif tag == 'span': + log.webview.debug("span with classes {} clicked!".format( + elem.classes())) + return False def _mousepress_backforward(self, e): """Handle back/forward mouse button presses.