Commit 5ad5e62d authored by Joanmarie Diggs's avatar Joanmarie Diggs

Web: When dumping cache due to children-changed preserve context by default

We now dump all of our cache when children-changed events are emitted.
This ensures we are not working with a stale tree (which can cause us
to get stuck and/or skip over content). Unfortunately, clearing the
context has exposed bugs in browsers. It should be safe to preserve
the context by default so we do not have to search for the current
location after a children-changed event that hasn't destroyed the
current location's accessible object.
parent abd79ae9
......@@ -1697,11 +1697,7 @@ class Script(default.Script):
isLiveRegion = self.utilities.isLiveRegion(event.source)
document = self.utilities.getDocumentForObject(event.source)
if document and not isLiveRegion:
msg = "WEB: Clearing all cached info for %s" % document
debug.println(debug.LEVEL_INFO, msg, True)
self.structuralNavigation.clearCache(document)
self.utilities.clearCaretContext(document)
self.utilities.clearCachedObjects()
self.utilities.dumpCache(document)
else:
msg = "WEB: Could not get document for event source"
debug.println(debug.LEVEL_INFO, msg, True)
......@@ -1799,11 +1795,7 @@ class Script(default.Script):
document = self.utilities.getDocumentForObject(event.source)
if document:
msg = "WEB: Clearing all cached info for %s" % document
debug.println(debug.LEVEL_INFO, msg, True)
self.structuralNavigation.clearCache(document)
self.utilities.clearCaretContext(document)
self.utilities.clearCachedObjects()
self.utilities.dumpCache(document)
if self.utilities.handleEventForRemovedChild(event):
msg = "WEB: Event handled for removed child."
......
......@@ -127,6 +127,24 @@ class Utilities(script_utilities.Utilities):
for key in toRemove:
self._caretContexts.pop(key, None)
def dumpCache(self, documentFrame, preserveContext=True):
if not documentFrame or self.isZombie(documentFrame):
documentFrame = self.documentFrame()
context = self._caretContexts.get(hash(documentFrame.parent))
msg = "WEB: Clearing all cached info for %s" % documentFrame
debug.println(debug.LEVEL_INFO, msg, True)
self._script.structuralNavigation.clearCache(documentFrame)
self.clearCaretContext(documentFrame)
self.clearCachedObjects()
if preserveContext and context:
msg = "WEB: Preserving context of %s, %i" % (context[0], context[1])
debug.println(debug.LEVEL_INFO, msg, True)
self._caretContexts[documentFrame.parent] = context
def clearCachedObjects(self):
debug.println(debug.LEVEL_INFO, "WEB: cleaning up cached objects", True)
self._objectAttributes = {}
......
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