From e5e49ed858b70683150ce4a64704aec1587a56ab Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 23 Jun 2014 14:48:18 +0200 Subject: [PATCH] Split _is_object_editable from is_editable. --- qutebrowser/utils/webelem.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/qutebrowser/utils/webelem.py b/qutebrowser/utils/webelem.py index 6f20f960a..7400e2500 100644 --- a/qutebrowser/utils/webelem.py +++ b/qutebrowser/utils/webelem.py @@ -179,6 +179,23 @@ def get_child_frames(startframe): return results +def _is_object_editable(elem): + """Check if an object-element is editable.""" + if not elem.hasAttribute('type'): + log.webview.debug(" without type clicked...") + return False + objtype = elem.attribute('type') + if objtype.startswith('application/') or elem.hasAttribute('classid'): + # Let's hope flash/java stuff has an application/* mimetype OR + # at least a classid attribute. Oh, and let's hope images/... + # DON'T have a classid attribute. HTML sucks. + log.webview.debug(" clicked.".format(objtype)) + return config.get('input', 'insert-mode-on-plugins') + else: + # Image/Audio/... + return False + + def is_editable(elem): """Check whether we should switch to insert mode for this element. @@ -205,18 +222,7 @@ def is_editable(elem): # Flash/Java/... return config.get('input', 'insert-mode-on-plugins') elif tag == 'object': - # Could be Flash/Java/..., could be image/audio/... - if not elem.hasAttribute('type'): - log.webview.debug(" without type clicked...") - return False - objtype = elem.attribute('type') - if (objtype.startswith('application/') or - elem.hasAttribute('classid')): - # Let's hope flash/java stuff has an application/* mimetype OR - # at least a classid attribute. Oh, and let's hope images/... - # DON'T have a classid attribute. HTML sucks. - log.webview.debug(" clicked.".format(objtype)) - return config.get('input', 'insert-mode-on-plugins') + return _is_object_editable(elem) elif tag == 'div': log.webview.debug("div with classes {} clicked!".format( elem.classes()))