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

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

Issue 2473743003: Call Element::rebuildLayoutTree from Document::updateStyle directly (Closed)
Patch Set: Commit the renames Created 4 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, 2008, 2009, 2013 Apple Inc. All rights 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights
6 * reserved. 6 * reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 void ContainerNode::parserTakeAllChildrenFrom(ContainerNode& oldParent) { 84 void ContainerNode::parserTakeAllChildrenFrom(ContainerNode& oldParent) {
85 while (Node* child = oldParent.firstChild()) { 85 while (Node* child = oldParent.firstChild()) {
86 // Explicitly remove since appending can fail, but this loop shouldn't be 86 // Explicitly remove since appending can fail, but this loop shouldn't be
87 // infinite. 87 // infinite.
88 oldParent.parserRemoveChild(*child); 88 oldParent.parserRemoveChild(*child);
89 parserAppendChild(child); 89 parserAppendChild(child);
90 } 90 }
91 } 91 }
92 92
93 ContainerNode::~ContainerNode() { 93 ContainerNode::~ContainerNode() {
94 DCHECK(needsAttach());
nainar 2016/11/29 06:13:39 This is unnecessary - maybe replace this with a ch
rune 2016/12/05 10:05:16 Wouldn't this correspond with needsReattachLayoutT
esprehn 2016/12/05 22:31:33 Leave this ASSERT alone, it's making sure by the t
95 } 94 }
96 95
97 DISABLE_CFI_PERF 96 DISABLE_CFI_PERF
98 bool ContainerNode::isChildTypeAllowed(const Node& child) const { 97 bool ContainerNode::isChildTypeAllowed(const Node& child) const {
99 if (!child.isDocumentFragment()) 98 if (!child.isDocumentFragment())
100 return childTypeAllowed(child.getNodeType()); 99 return childTypeAllowed(child.getNodeType());
101 100
102 for (Node* node = toDocumentFragment(child).firstChild(); node; 101 for (Node* node = toDocumentFragment(child).firstChild(); node;
103 node = node->nextSibling()) { 102 node = node->nextSibling()) {
104 if (!childTypeAllowed(node->getNodeType())) 103 if (!childTypeAllowed(node->getNodeType()))
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 541
543 void ContainerNode::removeBetween(Node* previousChild, 542 void ContainerNode::removeBetween(Node* previousChild,
544 Node* nextChild, 543 Node* nextChild,
545 Node& oldChild) { 544 Node& oldChild) {
546 EventDispatchForbiddenScope assertNoEventDispatch; 545 EventDispatchForbiddenScope assertNoEventDispatch;
547 546
548 DCHECK_EQ(oldChild.parentNode(), this); 547 DCHECK_EQ(oldChild.parentNode(), this);
549 548
550 AttachContext context; 549 AttachContext context;
551 context.clearInvalidation = true; 550 context.clearInvalidation = true;
552 if (!oldChild.needsAttach()) 551 if (oldChild.needsReattachLayoutTree())
nainar 2016/11/29 06:13:39 This statemement is no longer true since we are no
rune 2016/12/05 10:05:16 Shouldn't this be !needsReattachLayoutTree()?
esprehn 2016/12/05 22:31:33 Leave this alone.
553 oldChild.detachLayoutTree(context); 552 oldChild.detachLayoutTree(context);
554 553
555 if (nextChild) 554 if (nextChild)
556 nextChild->setPreviousSibling(previousChild); 555 nextChild->setPreviousSibling(previousChild);
557 if (previousChild) 556 if (previousChild)
558 previousChild->setNextSibling(nextChild); 557 previousChild->setNextSibling(nextChild);
559 if (m_firstChild == &oldChild) 558 if (m_firstChild == &oldChild)
560 setFirstChild(nextChild); 559 setFirstChild(nextChild);
561 if (m_lastChild == &oldChild) 560 if (m_lastChild == &oldChild)
562 setLastChild(previousChild); 561 setLastChild(previousChild);
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 } 751 }
753 } 752 }
754 753
755 DISABLE_CFI_PERF 754 DISABLE_CFI_PERF
756 void ContainerNode::attachLayoutTree(const AttachContext& context) { 755 void ContainerNode::attachLayoutTree(const AttachContext& context) {
757 AttachContext childrenContext(context); 756 AttachContext childrenContext(context);
758 childrenContext.resolvedStyle = nullptr; 757 childrenContext.resolvedStyle = nullptr;
759 758
760 for (Node* child = firstChild(); child; child = child->nextSibling()) { 759 for (Node* child = firstChild(); child; child = child->nextSibling()) {
761 #if DCHECK_IS_ON() 760 #if DCHECK_IS_ON()
762 DCHECK(child->needsAttach() || 761 DCHECK(child->needsReattachLayoutTree() ||
763 childAttachedAllowedWhenAttachingChildren(this)); 762 childAttachedAllowedWhenAttachingChildren(this));
764 #endif 763 #endif
765 if (child->needsAttach()) 764 if (child->needsReattachLayoutTree())
766 child->attachLayoutTree(childrenContext); 765 child->attachLayoutTree(childrenContext);
767 } 766 }
768 767
769 clearChildNeedsStyleRecalc(); 768 clearChildNeedsStyleRecalc();
770 clearChildNeedsReattachLayoutTree(); 769 clearChildNeedsReattachLayoutTree();
771 Node::attachLayoutTree(context); 770 Node::attachLayoutTree(context);
772 } 771 }
773 772
774 void ContainerNode::detachLayoutTree(const AttachContext& context) { 773 void ContainerNode::detachLayoutTree(const AttachContext& context) {
775 AttachContext childrenContext(context); 774 AttachContext childrenContext(context);
776 childrenContext.resolvedStyle = nullptr; 775 childrenContext.resolvedStyle = nullptr;
777 childrenContext.clearInvalidation = true; 776 childrenContext.clearInvalidation = true;
778 777
779 for (Node* child = firstChild(); child; child = child->nextSibling()) 778 for (Node* child = firstChild(); child; child = child->nextSibling())
780 child->detachLayoutTree(childrenContext); 779 child->detachLayoutTree(childrenContext);
781
782 setChildNeedsStyleRecalc();
783 Node::detachLayoutTree(context); 780 Node::detachLayoutTree(context);
784 } 781 }
785 782
786 void ContainerNode::childrenChanged(const ChildrenChange& change) { 783 void ContainerNode::childrenChanged(const ChildrenChange& change) {
787 document().incDOMTreeVersion(); 784 document().incDOMTreeVersion();
788 invalidateNodeListCachesInAncestors(); 785 invalidateNodeListCachesInAncestors();
789 if (change.isChildInsertion() && !childNeedsStyleRecalc()) { 786 if (change.isChildInsertion() && !childNeedsStyleRecalc()) {
790 setChildNeedsStyleRecalc(); 787 setChildNeedsStyleRecalc();
791 markAncestorsWithChildNeedsStyleRecalc(); 788 markAncestorsWithChildNeedsStyleRecalc();
792 } 789 }
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 } else if (child->isElementNode()) { 1284 } else if (child->isElementNode()) {
1288 Element* element = toElement(child); 1285 Element* element = toElement(child);
1289 if (element->shouldCallRecalcStyle(change)) 1286 if (element->shouldCallRecalcStyle(change))
1290 element->recalcStyle(change, lastTextNode); 1287 element->recalcStyle(change, lastTextNode);
1291 else if (element->supportsStyleSharing()) 1288 else if (element->supportsStyleSharing())
1292 styleResolver.addToStyleSharingList(*element); 1289 styleResolver.addToStyleSharingList(*element);
1293 if (element->layoutObject()) 1290 if (element->layoutObject())
1294 lastTextNode = nullptr; 1291 lastTextNode = nullptr;
1295 } 1292 }
1296 } 1293 }
1294 clearChildNeedsStyleRecalc();
1295 }
1296
1297 void ContainerNode::rebuildDescendantLayoutTree() {
1298 DCHECK(!needsStyleRecalc());
1299 DCHECK(!childNeedsStyleRecalc());
1300 DCHECK(!needsReattachLayoutTree());
1301
1302 for (Node* child = firstChild(); child; child = child->nextSibling()) {
1303 if (child->needsReattachLayoutTree() ||
1304 child->childNeedsReattachLayoutTree()) {
1305 if (child->isTextNode())
1306 toText(child)->rebuildTextLayoutTree();
1307 else if (child->isElementNode())
1308 toElement(child)->rebuildLayoutTree();
1309 }
1310 }
1311 clearChildNeedsStyleRecalc();
1312 clearChildNeedsReattachLayoutTree();
1297 } 1313 }
1298 1314
1299 void ContainerNode::checkForSiblingStyleChanges(SiblingCheckType changeType, 1315 void ContainerNode::checkForSiblingStyleChanges(SiblingCheckType changeType,
1300 Element* changedElement, 1316 Element* changedElement,
1301 Node* nodeBeforeChange, 1317 Node* nodeBeforeChange,
1302 Node* nodeAfterChange) { 1318 Node* nodeAfterChange) {
1303 if (!inActiveDocument() || document().hasPendingForcedStyleRecalc() || 1319 if (!inActiveDocument() || document().hasPendingForcedStyleRecalc() ||
1304 getStyleChangeType() >= SubtreeStyleChange) 1320 getStyleChangeType() >= SubtreeStyleChange)
1305 return; 1321 return;
1306 1322
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1468 return true; 1484 return true;
1469 1485
1470 if (node->isElementNode() && toElement(node)->shadow()) 1486 if (node->isElementNode() && toElement(node)->shadow())
1471 return true; 1487 return true;
1472 1488
1473 return false; 1489 return false;
1474 } 1490 }
1475 #endif 1491 #endif
1476 1492
1477 } // namespace blink 1493 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698