-
esprehn@chromium.org authored
https://bugs.webkit.org/show_bug.cgi?id=101821 Reviewed by Ojan Vafai. Source/WebCore: Make removeChild 9-14% faster by not walking the descendants looking for frames when there's known to be no frames. This is a more generalized version of the fix in Bug 101619 that only avoided this walk when the whole document had no frames. This patch extends it to skip traversing subtrees that have no frames by tracking the number of frames in subtrees and then only walking those subtrees that are known to contain frames in removeChild. Test: fast/frames/parser-append-subframe-count.html * dom/ContainerNode.cpp: (WebCore::willRemoveChildren): (WebCore::parserAppendChild): (WebCore::parserRemoveChild): (WebCore::parserInsertBefore): The parser may move nodes without doing frame disconnection so we must maintain the connected subframe count manually during these mutations. * 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): LayoutTests: Add a test that when frames are moved around by the parser and not actually detached we keep the subframe counters of ancestors consistent. * fast/frames/parser-append-subframe-count-expected.txt: Added. * fast/frames/parser-append-subframe-count.html: Added. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@140090 268f45cc-cd09-0410-ab3c-d52691b4dbfc
64fc1e8b