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

Side by Side Diff: Source/core/dom/shadow/ShadowRoot.cpp

Issue 18276003: Avoid N^2 walk placing renderers when building the render tree (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Removing extra parens (whoops) 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/Text.cpp ('k') | no next file » | 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Neither the name of Google Inc. nor the names of its 10 * * Neither the name of Google Inc. nor the names of its
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 return; 158 return;
159 } 159 }
160 160
161 // When we're set to lazyAttach we'll have a SubtreeStyleChange and we'll ne ed 161 // When we're set to lazyAttach we'll have a SubtreeStyleChange and we'll ne ed
162 // to promote the change to a Force for all our descendants so they get a 162 // to promote the change to a Force for all our descendants so they get a
163 // recalc and will attach. 163 // recalc and will attach.
164 if (styleChangeType() == SubtreeStyleChange) 164 if (styleChangeType() == SubtreeStyleChange)
165 change = Force; 165 change = Force;
166 166
167 // FIXME: This doesn't handle :hover + div properly like Element::recalcStyl e does. 167 // FIXME: This doesn't handle :hover + div properly like Element::recalcStyl e does.
168 bool forceReattachOfAnyWhitespaceSibling = false; 168 for (Node* child = lastChild(); child; child = child->previousSibling()) {
169 for (Node* child = firstChild(); child; child = child->nextSibling()) {
170 bool didReattach = false; 169 bool didReattach = false;
171 170
172 if (child->renderer()) 171 if (child->isTextNode())
173 forceReattachOfAnyWhitespaceSibling = false; 172 didReattach = toText(child)->recalcTextStyle(change);
173 else if (child->isElementNode() && shouldRecalcStyle(change, child))
174 didReattach = toElement(child)->recalcStyle(change);
174 175
175 if (child->isTextNode()) { 176 if (didReattach)
176 if (forceReattachOfAnyWhitespaceSibling && toText(child)->containsOn lyWhitespace()) 177 child->reattachWhitespaceSiblings();
177 child->reattach();
178 else
179 didReattach = toText(child)->recalcTextStyle(change);
180 } else if (child->isElementNode() && shouldRecalcStyle(change, child)) {
181 didReattach = toElement(child)->recalcStyle(change);
182 }
183
184 forceReattachOfAnyWhitespaceSibling = didReattach || forceReattachOfAnyW hitespaceSibling;
185 } 178 }
186 179
187 styleResolver->popParentShadowRoot(this); 180 styleResolver->popParentShadowRoot(this);
188 clearNeedsStyleRecalc(); 181 clearNeedsStyleRecalc();
189 clearChildNeedsStyleRecalc(); 182 clearChildNeedsStyleRecalc();
190 } 183 }
191 184
192 bool ShadowRoot::isActive() const 185 bool ShadowRoot::isActive() const
193 { 186 {
194 for (ShadowRoot* shadowRoot = youngerShadowRoot(); shadowRoot; shadowRoot = shadowRoot->youngerShadowRoot()) 187 for (ShadowRoot* shadowRoot = youngerShadowRoot(); shadowRoot; shadowRoot = shadowRoot->youngerShadowRoot())
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 { 299 {
307 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM); 300 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
308 DocumentFragment::reportMemoryUsage(memoryObjectInfo); 301 DocumentFragment::reportMemoryUsage(memoryObjectInfo);
309 TreeScope::reportMemoryUsage(memoryObjectInfo); 302 TreeScope::reportMemoryUsage(memoryObjectInfo);
310 info.addMember(m_prev, "prev"); 303 info.addMember(m_prev, "prev");
311 info.addMember(m_next, "next"); 304 info.addMember(m_next, "next");
312 info.addMember(m_scopeDistribution, "scopeDistribution"); 305 info.addMember(m_scopeDistribution, "scopeDistribution");
313 } 306 }
314 307
315 } 308 }
OLDNEW
« no previous file with comments | « Source/core/dom/Text.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698