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

Side by Side Diff: Source/core/dom/ContainerNodeAlgorithms.cpp

Issue 15871005: Avoid N^2 walk placing renderers when building the render tree (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Adding a mitigation for the perf regression to Element::recalcStyle. Created 7 years, 5 months 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 unified diff | Download patch
« no previous file with comments | « Source/core/dom/ContainerNodeAlgorithms.h ('k') | Source/core/dom/Document.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * Copyright (C) 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2012 Google Inc. All rights reserved.
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 17 matching lines...) Expand all
28 28
29 #include "core/dom/Element.h" 29 #include "core/dom/Element.h"
30 #include "core/dom/shadow/ElementShadow.h" 30 #include "core/dom/shadow/ElementShadow.h"
31 #include "core/html/HTMLFrameOwnerElement.h" 31 #include "core/html/HTMLFrameOwnerElement.h"
32 32
33 namespace WebCore { 33 namespace WebCore {
34 34
35 void ChildNodeInsertionNotifier::notifyDescendantInsertedIntoDocument(ContainerN ode* node) 35 void ChildNodeInsertionNotifier::notifyDescendantInsertedIntoDocument(ContainerN ode* node)
36 { 36 {
37 ChildNodesLazySnapshot snapshot(node); 37 ChildNodesLazySnapshot snapshot(node);
38 while (RefPtr<Node> child = snapshot.nextNode()) { 38 while (RefPtr<Node> child = snapshot.previousNode()) {
39 // If we have been removed from the document during this loop, then 39 // If we have been removed from the document during this loop, then
40 // we don't want to tell the rest of our children that they've been 40 // we don't want to tell the rest of our children that they've been
41 // inserted into the document because they haven't. 41 // inserted into the document because they haven't.
42 if (node->inDocument() && child->parentNode() == node) 42 if (node->inDocument() && child->parentNode() == node)
43 notifyNodeInsertedIntoDocument(child.get()); 43 notifyNodeInsertedIntoDocument(child.get());
44 } 44 }
45 45
46 if (!node->isElementNode()) 46 if (!node->isElementNode())
47 return; 47 return;
48 48
(...skipping 13 matching lines...) Expand all
62 notifyNodeInsertedIntoTree(toContainerNode(child)); 62 notifyNodeInsertedIntoTree(toContainerNode(child));
63 } 63 }
64 64
65 for (ShadowRoot* root = node->youngestShadowRoot(); root; root = root->older ShadowRoot()) 65 for (ShadowRoot* root = node->youngestShadowRoot(); root; root = root->older ShadowRoot())
66 notifyNodeInsertedIntoTree(root); 66 notifyNodeInsertedIntoTree(root);
67 } 67 }
68 68
69 void ChildNodeRemovalNotifier::notifyDescendantRemovedFromDocument(ContainerNode * node) 69 void ChildNodeRemovalNotifier::notifyDescendantRemovedFromDocument(ContainerNode * node)
70 { 70 {
71 ChildNodesLazySnapshot snapshot(node); 71 ChildNodesLazySnapshot snapshot(node);
72 while (RefPtr<Node> child = snapshot.nextNode()) { 72 while (RefPtr<Node> child = snapshot.previousNode()) {
73 // If we have been added to the document during this loop, then we 73 // If we have been added to the document during this loop, then we
74 // don't want to tell the rest of our children that they've been 74 // don't want to tell the rest of our children that they've been
75 // removed from the document because they haven't. 75 // removed from the document because they haven't.
76 if (!node->inDocument() && child->parentNode() == node) 76 if (!node->inDocument() && child->parentNode() == node)
77 notifyNodeRemovedFromDocument(child.get()); 77 notifyNodeRemovedFromDocument(child.get());
78 } 78 }
79 79
80 if (!node->isElementNode()) 80 if (!node->isElementNode())
81 return; 81 return;
82 82
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // If we overcount it's safe, but not optimal because it means we'll travers e 140 // If we overcount it's safe, but not optimal because it means we'll travers e
141 // through the document in ChildFrameDisconnector looking for frames that ha ve 141 // through the document in ChildFrameDisconnector looking for frames that ha ve
142 // already been disconnected. 142 // already been disconnected.
143 ASSERT(node->connectedSubframeCount() == count); 143 ASSERT(node->connectedSubframeCount() == count);
144 144
145 return count; 145 return count;
146 } 146 }
147 #endif 147 #endif
148 148
149 } 149 }
OLDNEW
« no previous file with comments | « Source/core/dom/ContainerNodeAlgorithms.h ('k') | Source/core/dom/Document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698