OLD | NEW |
---|---|
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 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
781 | 781 |
782 void ContainerNode::detachLayoutTree(const AttachContext& context) { | 782 void ContainerNode::detachLayoutTree(const AttachContext& context) { |
783 AttachContext childrenContext(context); | 783 AttachContext childrenContext(context); |
784 childrenContext.resolvedStyle = nullptr; | 784 childrenContext.resolvedStyle = nullptr; |
785 childrenContext.clearInvalidation = true; | 785 childrenContext.clearInvalidation = true; |
786 | 786 |
787 for (Node* child = firstChild(); child; child = child->nextSibling()) | 787 for (Node* child = firstChild(); child; child = child->nextSibling()) |
788 child->detachLayoutTree(childrenContext); | 788 child->detachLayoutTree(childrenContext); |
789 | 789 |
790 setChildNeedsStyleRecalc(); | 790 setChildNeedsStyleRecalc(); |
791 setChildNeedsReattachLayoutTree(); | |
791 Node::detachLayoutTree(context); | 792 Node::detachLayoutTree(context); |
792 } | 793 } |
793 | 794 |
794 void ContainerNode::childrenChanged(const ChildrenChange& change) { | 795 void ContainerNode::childrenChanged(const ChildrenChange& change) { |
795 document().incDOMTreeVersion(); | 796 document().incDOMTreeVersion(); |
796 document().notifyChangeChildren(*this); | 797 document().notifyChangeChildren(*this); |
797 invalidateNodeListCachesInAncestors(); | 798 invalidateNodeListCachesInAncestors(); |
798 if (change.isChildInsertion() && !childNeedsStyleRecalc()) { | 799 if (change.isChildInsertion() && !childNeedsStyleRecalc()) { |
799 setChildNeedsStyleRecalc(); | 800 setChildNeedsStyleRecalc(); |
800 markAncestorsWithChildNeedsStyleRecalc(); | 801 markAncestorsWithChildNeedsStyleRecalc(); |
802 setChildNeedsReattachLayoutTree(); | |
esprehn
2017/02/16 05:49:25
You need a separate check for !childNeedsReattach.
nainar
2017/02/16 06:47:54
Done. Add test in this patch or in another one?
| |
803 markAncestorsWithChildNeedsReattachLayoutTree(); | |
801 } | 804 } |
802 } | 805 } |
803 | 806 |
804 void ContainerNode::cloneChildNodes(ContainerNode* clone) { | 807 void ContainerNode::cloneChildNodes(ContainerNode* clone) { |
805 DummyExceptionStateForTesting exceptionState; | 808 DummyExceptionStateForTesting exceptionState; |
806 for (Node* n = firstChild(); n && !exceptionState.hadException(); | 809 for (Node* n = firstChild(); n && !exceptionState.hadException(); |
807 n = n->nextSibling()) | 810 n = n->nextSibling()) |
808 clone->appendChild(n->cloneNode(true), exceptionState); | 811 clone->appendChild(n->cloneNode(true), exceptionState); |
809 } | 812 } |
810 | 813 |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1273 } | 1276 } |
1274 | 1277 |
1275 void ContainerNode::setRestyleFlag(DynamicRestyleFlags mask) { | 1278 void ContainerNode::setRestyleFlag(DynamicRestyleFlags mask) { |
1276 DCHECK(isElementNode() || isShadowRoot()); | 1279 DCHECK(isElementNode() || isShadowRoot()); |
1277 ensureRareData().setRestyleFlag(mask); | 1280 ensureRareData().setRestyleFlag(mask); |
1278 } | 1281 } |
1279 | 1282 |
1280 void ContainerNode::recalcDescendantStyles(StyleRecalcChange change) { | 1283 void ContainerNode::recalcDescendantStyles(StyleRecalcChange change) { |
1281 DCHECK(document().inStyleRecalc()); | 1284 DCHECK(document().inStyleRecalc()); |
1282 DCHECK(change >= UpdatePseudoElements || childNeedsStyleRecalc()); | 1285 DCHECK(change >= UpdatePseudoElements || childNeedsStyleRecalc()); |
1283 DCHECK(!needsStyleRecalc()); | |
esprehn
2017/02/16 05:49:25
add this back? Recomputing the descendant styles w
nainar
2017/02/16 06:47:54
Done. Needed to move the
if (!needsReattachLayou
| |
1284 | 1286 |
1285 // This loop is deliberately backwards because we use insertBefore in the | 1287 // This loop is deliberately backwards because we use insertBefore in the |
1286 // layout tree, and want to avoid a potentially n^2 loop to find the insertion | 1288 // layout tree, and want to avoid a potentially n^2 loop to find the insertion |
1287 // point while resolving style. Having us start from the last child and work | 1289 // point while resolving style. Having us start from the last child and work |
1288 // our way back means in the common case, we'll find the insertion point in | 1290 // our way back means in the common case, we'll find the insertion point in |
1289 // O(1) time. See crbug.com/288225 | 1291 // O(1) time. See crbug.com/288225 |
1290 StyleResolver& styleResolver = document().ensureStyleResolver(); | 1292 StyleResolver& styleResolver = document().ensureStyleResolver(); |
1291 Text* lastTextNode = nullptr; | 1293 Text* lastTextNode = nullptr; |
1292 for (Node* child = lastChild(); child; child = child->previousSibling()) { | 1294 for (Node* child = lastChild(); child; child = child->previousSibling()) { |
1293 if (child->isTextNode()) { | 1295 if (child->isTextNode()) { |
1294 toText(child)->recalcTextStyle(change, lastTextNode); | 1296 toText(child)->recalcTextStyle(change, lastTextNode); |
1295 lastTextNode = toText(child); | 1297 lastTextNode = toText(child); |
1296 } else if (child->isElementNode()) { | 1298 } else if (child->isElementNode()) { |
1297 Element* element = toElement(child); | 1299 Element* element = toElement(child); |
1298 if (element->shouldCallRecalcStyle(change)) | 1300 if (element->shouldCallRecalcStyle(change)) |
1299 element->recalcStyle(change, lastTextNode); | 1301 element->recalcStyle(change, lastTextNode); |
1300 else if (element->supportsStyleSharing()) | 1302 else if (element->supportsStyleSharing()) |
1301 styleResolver.addToStyleSharingList(*element); | 1303 styleResolver.addToStyleSharingList(*element); |
1302 if (element->layoutObject()) | 1304 if (element->layoutObject()) |
1303 lastTextNode = nullptr; | 1305 lastTextNode = nullptr; |
1304 } | 1306 } |
1305 } | 1307 } |
1306 } | 1308 } |
1307 | 1309 |
1310 void ContainerNode::rebuildChildrenLayoutTrees() { | |
1311 DCHECK(!needsReattachLayoutTree()); | |
1312 | |
1313 for (Node* child = lastChild(); child; child = child->previousSibling()) { | |
1314 if (child->needsReattachLayoutTree() || | |
1315 child->childNeedsReattachLayoutTree()) { | |
1316 if (child->isTextNode()) | |
1317 toText(child)->rebuildTextLayoutTree(); | |
1318 else if (child->isElementNode()) | |
1319 toElement(child)->rebuildLayoutTree(); | |
1320 } | |
1321 } | |
1322 clearNeedsStyleRecalc(); | |
1323 // This is done in ContainerNode::attachLayoutTree but will never be cleared | |
1324 // if we don't enter ContainerNode::attachLayoutTree so we do it here. | |
1325 clearChildNeedsStyleRecalc(); | |
1326 clearChildNeedsReattachLayoutTree(); | |
1327 } | |
1328 | |
1308 void ContainerNode::checkForSiblingStyleChanges(SiblingCheckType changeType, | 1329 void ContainerNode::checkForSiblingStyleChanges(SiblingCheckType changeType, |
1309 Element* changedElement, | 1330 Element* changedElement, |
1310 Node* nodeBeforeChange, | 1331 Node* nodeBeforeChange, |
1311 Node* nodeAfterChange) { | 1332 Node* nodeAfterChange) { |
1312 if (!inActiveDocument() || document().hasPendingForcedStyleRecalc() || | 1333 if (!inActiveDocument() || document().hasPendingForcedStyleRecalc() || |
1313 getStyleChangeType() >= SubtreeStyleChange) | 1334 getStyleChangeType() >= SubtreeStyleChange) |
1314 return; | 1335 return; |
1315 | 1336 |
1316 if (!hasRestyleFlag(ChildrenAffectedByStructuralRules)) | 1337 if (!hasRestyleFlag(ChildrenAffectedByStructuralRules)) |
1317 return; | 1338 return; |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1477 return true; | 1498 return true; |
1478 | 1499 |
1479 if (node->isElementNode() && toElement(node)->shadow()) | 1500 if (node->isElementNode() && toElement(node)->shadow()) |
1480 return true; | 1501 return true; |
1481 | 1502 |
1482 return false; | 1503 return false; |
1483 } | 1504 } |
1484 #endif | 1505 #endif |
1485 | 1506 |
1486 } // namespace blink | 1507 } // namespace blink |
OLD | NEW |