Commit 069a8cee authored by Joanmarie Diggs's avatar Joanmarie Diggs

Web: Skip useless empty elements when seeking first context in document

There shouldn't be useless empty elements at the top of a document. But
authors, along with Thunderbird.... Therefore when seeking the first
context in the document (e.g. when pressing Ctrl+Home), start with the
first child that isn't a useless empty element.
parent b1b4c8d7
......@@ -4826,6 +4826,13 @@ class Utilities(script_utilities.Utilities):
debug.println(debug.LEVEL_INFO, msg, True)
return obj, offset
if self.isDocument(obj):
while self.isUselessEmptyElement(child):
msg = "WEB: Child %s of %s at offset %i cannot be context." % (child, obj, offset)
debug.println(debug.LEVEL_INFO, msg, True)
offset += 1
child = self.getChildAtOffset(obj, offset)
if self.isListItemMarker(child):
msg = "WEB: First caret context for %s, %i is %s, %i (skip list item marker child)" % \
(obj, offset, obj, offset + 1)
......@@ -4841,7 +4848,7 @@ class Utilities(script_utilities.Utilities):
return nextObj, nextOffset
if not self._canHaveCaretContext(child):
msg = "WEB: Child cannot be context. Returning %s, %i unchanged." % (obj, offset)
msg = "WEB: Child cannot be context. Returning %s, %i." % (obj, offset)
debug.println(debug.LEVEL_INFO, msg, True)
return obj, offset
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment