Track subframe count to avoid traversing the tree when there's no subframes
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Nov 2012 20:38:34 +0000 (20:38 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Nov 2012 20:38:34 +0000 (20:38 +0000)
commit51f77bec264b5f5981c051bd0d522c545d314f94
treef25d7b73b2b723c7d54a9f4bdc692f7537393bf4
parent404a5b02894d78559100c9aae8390a7b55b16985
Track subframe count to avoid traversing the tree when there's no subframes
https://bugs.webkit.org/show_bug.cgi?id=101821

Patch by Elliott Sprehn <esprehn@chromium.org> on 2012-11-15
Reviewed by Ojan Vafai.

Bug 101619 showed a 9-14% improvement from not walking the children during
removeChild looking for frames when there's known to be no frames. The fix
in that bug only avoids this walk when the whole document has no frames, this
patch extends it to skip traversing subtrees that have no iframes by hooking
the frame assignment to walk up the tree and keep track of the count of frames
in the subtree on contentFrame assignment and then decrement it on disconnect.

No new tests, this is just a perf refactor.

* dom/ContainerNode.cpp:
(WebCore::willRemoveChildren):
* dom/ContainerNodeAlgorithms.cpp:
(WebCore::ChildFrameDisconnector::collectFrameOwners):
* dom/ContainerNodeAlgorithms.h:
(WebCore::ChildFrameDisconnector::ChildFrameDisconnector):
(ChildFrameDisconnector):
(WebCore::ChildFrameDisconnector::collectFrameOwners):
  Renamed from collectDescendant() to better reflect what it really does.
(WebCore::ChildFrameDisconnector::disconnectCollectedFrameOwners):
  Renamed from disconnect() to better reflect what it really does.
(WebCore::ChildFrameDisconnector::disconnect):
  New method that does the collection of frame owners on either the root
  or only it's descendants.
* dom/Node.cpp:
(WebCore::Node::connectedSubframeCount):
(WebCore::Node::incrementConnectedSubframeCount):
(WebCore::Node::decrementConnectedSubframeCount):
* dom/Node.h:
* dom/NodeRareData.h:
(WebCore::NodeRareData::NodeRareData):
(WebCore::NodeRareData::connectedSubframeCount):
(WebCore::NodeRareData::incrementConnectedSubframeCount):
(WebCore::NodeRareData::decrementConnectedSubframeCount):
* html/HTMLFrameOwnerElement.cpp:
(WebCore::HTMLFrameOwnerElement::setContentFrame):
(WebCore::HTMLFrameOwnerElement::disconnectContentFrame):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@134817 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/dom/ContainerNode.cpp
Source/WebCore/dom/ContainerNodeAlgorithms.cpp
Source/WebCore/dom/ContainerNodeAlgorithms.h
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/Node.h
Source/WebCore/dom/NodeRareData.h
Source/WebCore/html/HTMLFrameOwnerElement.cpp