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

Side by Side Diff: third_party/WebKit/Source/core/dom/ContainerNode.cpp

Issue 2235723002: Use invalidation sets for nth invalidations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment ::before/::after Created 4 years, 4 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
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, 2013 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 { 1225 {
1226 if (!inActiveDocument() || document().hasPendingForcedStyleRecalc() || getSt yleChangeType() >= SubtreeStyleChange) 1226 if (!inActiveDocument() || document().hasPendingForcedStyleRecalc() || getSt yleChangeType() >= SubtreeStyleChange)
1227 return; 1227 return;
1228 1228
1229 if (!hasRestyleFlag(ChildrenAffectedByStructuralRules)) 1229 if (!hasRestyleFlag(ChildrenAffectedByStructuralRules))
1230 return; 1230 return;
1231 1231
1232 Element* elementAfterChange = !nodeAfterChange || nodeAfterChange->isElement Node() ? toElement(nodeAfterChange) : ElementTraversal::nextSibling(*nodeAfterCh ange); 1232 Element* elementAfterChange = !nodeAfterChange || nodeAfterChange->isElement Node() ? toElement(nodeAfterChange) : ElementTraversal::nextSibling(*nodeAfterCh ange);
1233 Element* elementBeforeChange = !nodeBeforeChange || nodeBeforeChange->isElem entNode() ? toElement(nodeBeforeChange) : ElementTraversal::previousSibling(*nod eBeforeChange); 1233 Element* elementBeforeChange = !nodeBeforeChange || nodeBeforeChange->isElem entNode() ? toElement(nodeBeforeChange) : ElementTraversal::previousSibling(*nod eBeforeChange);
1234 1234
1235 // TODO(rune@opera.com): move this code into StyleEngine and collect the
1236 // various invalidation sets into a single InvalidationLists object and
1237 // schedule with a single scheduleInvalidationSetsForNode for efficiency.
1238
1235 // Forward positional selectors include :nth-child, :nth-of-type, 1239 // Forward positional selectors include :nth-child, :nth-of-type,
1236 // :first-of-type, and only-of-type. The indirect adjacent selector is the ~ 1240 // :first-of-type, and only-of-type. Backward positional selectors include
1237 // selector. Backward positional selectors include :nth-last-child, 1241 // :nth-last-child, :nth-last-of-type, :last-of-type, and :only-of-type.
1238 // :nth-last-of-type, :last-of-type, and :only-of-type. We have to
1239 // invalidate everything following the insertion point in the forward and
1240 // indirect adjacent case, and everything before the insertion point in the
1241 // backward case. |nodeAfterChange| is nullptr in the parser callback case,
1242 // so we won't do any work for the forward case if we don't have to.
1243 // For performance reasons we just mark the parent node as changed, since we
1244 // don't want to make childrenChanged O(n^2) by crawling all our kids here.
1245 // recalcStyle will then force a walk of the children when it sees that this
1246 // has happened.
1247 if ((childrenAffectedByForwardPositionalRules() && elementAfterChange) 1242 if ((childrenAffectedByForwardPositionalRules() && elementAfterChange)
1248 || (childrenAffectedByBackwardPositionalRules() && elementBeforeChange)) { 1243 || (childrenAffectedByBackwardPositionalRules() && elementBeforeChange)) {
1249 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::cre ate(StyleChangeReason::SiblingSelector)); 1244 document().styleEngine().scheduleNthPseudoInvalidations(*this);
1250 return;
1251 } 1245 }
1252 1246
1253 if (childrenAffectedByFirstChildRules() && !elementBeforeChange && elementAf terChange && elementAfterChange->affectedByFirstChildRules()) { 1247 if (childrenAffectedByFirstChildRules() && !elementBeforeChange && elementAf terChange && elementAfterChange->affectedByFirstChildRules()) {
1254 DCHECK_NE(changeType, FinishedParsingChildren); 1248 DCHECK_NE(changeType, FinishedParsingChildren);
1255 elementAfterChange->pseudoStateChanged(CSSSelector::PseudoFirstChild); 1249 elementAfterChange->pseudoStateChanged(CSSSelector::PseudoFirstChild);
1256 elementAfterChange->pseudoStateChanged(CSSSelector::PseudoOnlyChild); 1250 elementAfterChange->pseudoStateChanged(CSSSelector::PseudoOnlyChild);
1257 } 1251 }
1258 1252
1259 if (childrenAffectedByLastChildRules() && !elementAfterChange && elementBefo reChange && elementBeforeChange->affectedByLastChildRules()) { 1253 if (childrenAffectedByLastChildRules() && !elementAfterChange && elementBefo reChange && elementBeforeChange->affectedByLastChildRules()) {
1260 elementBeforeChange->pseudoStateChanged(CSSSelector::PseudoLastChild); 1254 elementBeforeChange->pseudoStateChanged(CSSSelector::PseudoLastChild);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 return true; 1371 return true;
1378 1372
1379 if (node->isElementNode() && toElement(node)->shadow()) 1373 if (node->isElementNode() && toElement(node)->shadow())
1380 return true; 1374 return true;
1381 1375
1382 return false; 1376 return false;
1383 } 1377 }
1384 #endif 1378 #endif
1385 1379
1386 } // namespace blink 1380 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/invalidation/StyleInvalidator.cpp ('k') | third_party/WebKit/Source/core/dom/StyleEngine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698