Improve _is_editable()
This commit is contained in:
parent
ff887c647d
commit
b3418cae5d
@ -111,28 +111,36 @@ class BrowserTab(QWebView):
|
|||||||
self._shutdown_callback()
|
self._shutdown_callback()
|
||||||
|
|
||||||
def _is_editable(self, hitresult):
|
def _is_editable(self, hitresult):
|
||||||
"""Checks if the hitresult needs keyboard focus.
|
"""Check if a hit result needs keyboard focus.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
hitresult: A QWebHitTestResult
|
hitresult: A QWebHitTestResult
|
||||||
"""
|
"""
|
||||||
# FIXME is this algorithm accurate?
|
# FIXME is this algorithm accurate?
|
||||||
if hitresult.isContentEditable():
|
if hitresult.isContentEditable():
|
||||||
|
# text fields and the like
|
||||||
return True
|
return True
|
||||||
if not config.get('general', 'insert_mode_on_plugins'):
|
if not config.get('general', 'insert_mode_on_plugins'):
|
||||||
return False
|
return False
|
||||||
elem = hitresult.element()
|
elem = hitresult.element()
|
||||||
tag = elem.tagName().lower()
|
tag = elem.tagName().lower()
|
||||||
if tag in ['embed', 'applet']:
|
if tag in ['embed', 'applet']:
|
||||||
|
# Flash/Java/...
|
||||||
return True
|
return True
|
||||||
elif tag == 'object':
|
if tag == 'object':
|
||||||
|
# Could be Flash/Java/..., could be image/audio/...
|
||||||
if not elem.hasAttribute("type"):
|
if not elem.hasAttribute("type"):
|
||||||
logging.warn("<object> without type clicked...")
|
logging.debug("<object> without type clicked...")
|
||||||
return False
|
return False
|
||||||
objtype = elem.attribute("type")
|
objtype = elem.attribute("type")
|
||||||
if not objtype.startswith("image/"):
|
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 home images/...
|
||||||
|
# DON"T have a classid attribute. HTML sucks.
|
||||||
logging.debug("<object type=\"{}\"> clicked.".format(objtype))
|
logging.debug("<object type=\"{}\"> clicked.".format(objtype))
|
||||||
return True
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def openurl(self, url):
|
def openurl(self, url):
|
||||||
"""Open an URL in the browser.
|
"""Open an URL in the browser.
|
||||||
|
Loading…
Reference in New Issue
Block a user