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

Side by Side Diff: Source/core/dom/ContainerNode.h

Issue 768533004: Make getComputedStyle optimization work for adjacent combinators. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Redistribution might change computed style. Created 6 years 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, 2009, 2010, 2011, 2013 Apple Inc. All r ights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2013 Apple Inc. All r ights 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 148
149 bool childrenAffectedByBackwardPositionalRules() const { return hasRestyleFl ag(ChildrenAffectedByBackwardPositionalRules); } 149 bool childrenAffectedByBackwardPositionalRules() const { return hasRestyleFl ag(ChildrenAffectedByBackwardPositionalRules); }
150 void setChildrenAffectedByBackwardPositionalRules() { setRestyleFlag(Childre nAffectedByBackwardPositionalRules); } 150 void setChildrenAffectedByBackwardPositionalRules() { setRestyleFlag(Childre nAffectedByBackwardPositionalRules); }
151 151
152 bool affectedByFirstChildRules() const { return hasRestyleFlag(AffectedByFir stChildRules); } 152 bool affectedByFirstChildRules() const { return hasRestyleFlag(AffectedByFir stChildRules); }
153 void setAffectedByFirstChildRules() { setRestyleFlag(AffectedByFirstChildRul es); } 153 void setAffectedByFirstChildRules() { setRestyleFlag(AffectedByFirstChildRul es); }
154 154
155 bool affectedByLastChildRules() const { return hasRestyleFlag(AffectedByLast ChildRules); } 155 bool affectedByLastChildRules() const { return hasRestyleFlag(AffectedByLast ChildRules); }
156 void setAffectedByLastChildRules() { setRestyleFlag(AffectedByLastChildRules ); } 156 void setAffectedByLastChildRules() { setRestyleFlag(AffectedByLastChildRules ); }
157 157
158 bool needsAdjacentStyleRecalc() const;
159
158 // FIXME: These methods should all be renamed to something better than "chec k", 160 // FIXME: These methods should all be renamed to something better than "chec k",
159 // since it's not clear that they alter the style bits of siblings and child ren. 161 // since it's not clear that they alter the style bits of siblings and child ren.
160 void checkForChildrenAdjacentRuleChanges(); 162 void checkForChildrenAdjacentRuleChanges();
161 enum SiblingCheckType { FinishedParsingChildren, SiblingElementInserted, Sib lingElementRemoved }; 163 enum SiblingCheckType { FinishedParsingChildren, SiblingElementInserted, Sib lingElementRemoved };
162 void checkForSiblingStyleChanges(SiblingCheckType, Node* nodeBeforeChange, N ode* nodeAfterChange); 164 void checkForSiblingStyleChanges(SiblingCheckType, Node* nodeBeforeChange, N ode* nodeAfterChange);
163 void recalcChildStyle(StyleRecalcChange); 165 void recalcChildStyle(StyleRecalcChange);
164 166
165 bool childrenSupportStyleSharing() const { return !hasRestyleFlags(); } 167 bool childrenSupportStyleSharing() const { return !hasRestyleFlags(); }
166 168
167 // ------------------------------------------------------------------------- ---- 169 // ------------------------------------------------------------------------- ----
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 308
307 inline void ContainerNode::detachChildren(const AttachContext& context) 309 inline void ContainerNode::detachChildren(const AttachContext& context)
308 { 310 {
309 AttachContext childrenContext(context); 311 AttachContext childrenContext(context);
310 childrenContext.resolvedStyle = nullptr; 312 childrenContext.resolvedStyle = nullptr;
311 313
312 for (Node* child = firstChild(); child; child = child->nextSibling()) 314 for (Node* child = firstChild(); child; child = child->nextSibling())
313 child->detach(childrenContext); 315 child->detach(childrenContext);
314 } 316 }
315 317
318 inline bool ContainerNode::needsAdjacentStyleRecalc() const
319 {
320 if (!childrenAffectedByDirectAdjacentRules() && !childrenAffectedByIndirectA djacentRules())
321 return false;
322 return childNeedsStyleRecalc() || childNeedsStyleInvalidation();
323 }
324
316 inline unsigned Node::countChildren() const 325 inline unsigned Node::countChildren() const
317 { 326 {
318 if (!isContainerNode()) 327 if (!isContainerNode())
319 return 0; 328 return 0;
320 return toContainerNode(this)->countChildren(); 329 return toContainerNode(this)->countChildren();
321 } 330 }
322 331
323 inline Node* Node::firstChild() const 332 inline Node* Node::firstChild() const
324 { 333 {
325 if (!isContainerNode()) 334 if (!isContainerNode())
(...skipping 28 matching lines...) Expand all
354 inline void getChildNodes(ContainerNode& node, NodeVector& nodes) 363 inline void getChildNodes(ContainerNode& node, NodeVector& nodes)
355 { 364 {
356 ASSERT(!nodes.size()); 365 ASSERT(!nodes.size());
357 for (Node* child = node.firstChild(); child; child = child->nextSibling()) 366 for (Node* child = node.firstChild(); child; child = child->nextSibling())
358 nodes.append(child); 367 nodes.append(child);
359 } 368 }
360 369
361 } // namespace blink 370 } // namespace blink
362 371
363 #endif // ContainerNode_h 372 #endif // ContainerNode_h
OLDNEW
« no previous file with comments | « LayoutTests/fast/css/getComputedStyle/computed-style-recalc-expected.txt ('k') | Source/core/dom/Document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698