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

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

Issue 24350009: Reverse style resolution to avoid N^2 walk when building the render tree (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixing loops in Regions Created 7 years, 2 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
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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 } 176 }
177 177
178 // When we're set to lazyAttach we'll have a SubtreeStyleChange and we'll ne ed 178 // When we're set to lazyAttach we'll have a SubtreeStyleChange and we'll ne ed
179 // to promote the change to a Force for all our descendants so they get a 179 // to promote the change to a Force for all our descendants so they get a
180 // recalc and will attach. 180 // recalc and will attach.
181 if (styleChangeType() >= SubtreeStyleChange) 181 if (styleChangeType() >= SubtreeStyleChange)
182 change = Force; 182 change = Force;
183 183
184 // FIXME: This doesn't handle :hover + div properly like Element::recalcStyl e does. 184 // FIXME: This doesn't handle :hover + div properly like Element::recalcStyl e does.
185 bool forceReattachOfAnyWhitespaceSibling = false; 185 bool forceReattachOfAnyWhitespaceSibling = false;
186 for (Node* child = firstChild(); child; child = child->nextSibling()) { 186 for (Node* child = lastChild(); child; child = child->previousSibling()) {
187 bool didReattach = false; 187 bool didReattach = false;
188 188
189 if (child->renderer()) 189 if (child->isTextNode())
190 forceReattachOfAnyWhitespaceSibling = false; 190 didReattach = toText(child)->recalcTextStyle(change);
191 else if (child->isElementNode() && shouldRecalcStyle(change, child))
192 didReattach = toElement(child)->recalcStyle(change);
191 193
192 if (child->isTextNode()) { 194 if (didReattach)
193 if (forceReattachOfAnyWhitespaceSibling && toText(child)->containsOn lyWhitespace()) 195 child->reattachWhitespaceSiblings();
esprehn 2013/09/30 22:52:03 You're missing the nasty whitespace stuff in here.
194 child->reattach();
195 else
196 didReattach = toText(child)->recalcTextStyle(change);
197 } else if (child->isElementNode() && shouldRecalcStyle(change, child)) {
198 didReattach = toElement(child)->recalcStyle(change);
199 }
200
201 forceReattachOfAnyWhitespaceSibling = didReattach || forceReattachOfAnyW hitespaceSibling;
202 } 196 }
203 197
204 styleResolver->popParentShadowRoot(*this); 198 styleResolver->popParentShadowRoot(*this);
205 clearNeedsStyleRecalc(); 199 clearNeedsStyleRecalc();
206 clearChildNeedsStyleRecalc(); 200 clearChildNeedsStyleRecalc();
207 } 201 }
208 202
209 bool ShadowRoot::isActive() const 203 bool ShadowRoot::isActive() const
210 { 204 {
211 for (ShadowRoot* shadowRoot = youngerShadowRoot(); shadowRoot; shadowRoot = shadowRoot->youngerShadowRoot()) 205 for (ShadowRoot* shadowRoot = youngerShadowRoot(); shadowRoot; shadowRoot = shadowRoot->youngerShadowRoot())
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 411
418 StyleSheetList* ShadowRoot::styleSheets() 412 StyleSheetList* ShadowRoot::styleSheets()
419 { 413 {
420 if (!ensureShadowRootRareData()->styleSheets()) 414 if (!ensureShadowRootRareData()->styleSheets())
421 m_shadowRootRareData->setStyleSheets(StyleSheetList::create(this)); 415 m_shadowRootRareData->setStyleSheets(StyleSheetList::create(this));
422 416
423 return m_shadowRootRareData->styleSheets(); 417 return m_shadowRootRareData->styleSheets();
424 } 418 }
425 419
426 } 420 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698