Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(418)

Unified Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 1544443004: Alternate computation of axObjectCacheOwner to improve perf (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comment Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/Document.cpp
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp
index 6415861c3039a7819733b35cd4f432f506ce3672..56afe214d957c65ababa6f2a5a42eb885f51b9e1 100644
--- a/third_party/WebKit/Source/core/dom/Document.cpp
+++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -2312,22 +2312,25 @@ Document& Document::axObjectCacheOwner() const
// of the AXObjectCache (http://crbug.com/510410), but the proper fix
// will be for each Document to have its own AXObjectCache
// (http://crbug.com/532249).
-
+ Document* top = const_cast<Document*>(this);
LocalFrame* frame = this->frame();
if (!frame)
- return *const_cast<Document*>(this);
+ return *top;
- frame = frame->localFrameRoot();
- if (!frame || !frame->document())
- return *const_cast<Document*>(this);
+ // This loop is more efficient than calling localFrameRoot.
+ while (frame && frame->owner() && frame->owner()->isLocal()) {
+ HTMLFrameOwnerElement* owner = toHTMLFrameOwnerElement(frame->owner());
+ top = &owner->document();
+ frame = top->frame();
+ }
- Document* owner = frame->document();
- if (frame->pagePopupOwner()) {
- ASSERT(!owner->m_axObjectCache);
- return frame->pagePopupOwner()->document().axObjectCacheOwner();
+ if (top->frame() && top->frame()->pagePopupOwner()) {
+ ASSERT(!top->m_axObjectCache);
+ return top->frame()->pagePopupOwner()->document().axObjectCacheOwner();
}
- return *owner;
+ ASSERT(top);
+ return *top;
}
void Document::clearAXObjectCache()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698