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()) { |
799 setChildNeedsStyleRecalc(); | 800 if (!childNeedsStyleRecalc()) { |
800 markAncestorsWithChildNeedsStyleRecalc(); | 801 setChildNeedsStyleRecalc(); |
| 802 markAncestorsWithChildNeedsStyleRecalc(); |
| 803 } |
| 804 if (!childNeedsReattachLayoutTree()) { |
| 805 setChildNeedsReattachLayoutTree(); |
| 806 markAncestorsWithChildNeedsReattachLayoutTree(); |
| 807 } |
801 } | 808 } |
802 } | 809 } |
803 | 810 |
804 void ContainerNode::cloneChildNodes(ContainerNode* clone) { | 811 void ContainerNode::cloneChildNodes(ContainerNode* clone) { |
805 DummyExceptionStateForTesting exceptionState; | 812 DummyExceptionStateForTesting exceptionState; |
806 for (Node* n = firstChild(); n && !exceptionState.hadException(); | 813 for (Node* n = firstChild(); n && !exceptionState.hadException(); |
807 n = n->nextSibling()) | 814 n = n->nextSibling()) |
808 clone->appendChild(n->cloneNode(true), exceptionState); | 815 clone->appendChild(n->cloneNode(true), exceptionState); |
809 } | 816 } |
810 | 817 |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1298 if (element->shouldCallRecalcStyle(change)) | 1305 if (element->shouldCallRecalcStyle(change)) |
1299 element->recalcStyle(change, lastTextNode); | 1306 element->recalcStyle(change, lastTextNode); |
1300 else if (element->supportsStyleSharing()) | 1307 else if (element->supportsStyleSharing()) |
1301 styleResolver.addToStyleSharingList(*element); | 1308 styleResolver.addToStyleSharingList(*element); |
1302 if (element->layoutObject()) | 1309 if (element->layoutObject()) |
1303 lastTextNode = nullptr; | 1310 lastTextNode = nullptr; |
1304 } | 1311 } |
1305 } | 1312 } |
1306 } | 1313 } |
1307 | 1314 |
| 1315 void ContainerNode::rebuildChildrenLayoutTrees() { |
| 1316 DCHECK(!needsReattachLayoutTree()); |
| 1317 |
| 1318 for (Node* child = lastChild(); child; child = child->previousSibling()) { |
| 1319 if (child->needsReattachLayoutTree() || |
| 1320 child->childNeedsReattachLayoutTree()) { |
| 1321 if (child->isTextNode()) |
| 1322 toText(child)->rebuildTextLayoutTree(); |
| 1323 else if (child->isElementNode()) |
| 1324 toElement(child)->rebuildLayoutTree(); |
| 1325 } |
| 1326 } |
| 1327 // This is done in ContainerNode::attachLayoutTree but will never be cleared |
| 1328 // if we don't enter ContainerNode::attachLayoutTree so we do it here. |
| 1329 clearChildNeedsStyleRecalc(); |
| 1330 clearChildNeedsReattachLayoutTree(); |
| 1331 } |
| 1332 |
1308 void ContainerNode::checkForSiblingStyleChanges(SiblingCheckType changeType, | 1333 void ContainerNode::checkForSiblingStyleChanges(SiblingCheckType changeType, |
1309 Element* changedElement, | 1334 Element* changedElement, |
1310 Node* nodeBeforeChange, | 1335 Node* nodeBeforeChange, |
1311 Node* nodeAfterChange) { | 1336 Node* nodeAfterChange) { |
1312 if (!inActiveDocument() || document().hasPendingForcedStyleRecalc() || | 1337 if (!inActiveDocument() || document().hasPendingForcedStyleRecalc() || |
1313 getStyleChangeType() >= SubtreeStyleChange) | 1338 getStyleChangeType() >= SubtreeStyleChange) |
1314 return; | 1339 return; |
1315 | 1340 |
1316 if (!hasRestyleFlag(ChildrenAffectedByStructuralRules)) | 1341 if (!hasRestyleFlag(ChildrenAffectedByStructuralRules)) |
1317 return; | 1342 return; |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1477 return true; | 1502 return true; |
1478 | 1503 |
1479 if (node->isElementNode() && toElement(node)->shadow()) | 1504 if (node->isElementNode() && toElement(node)->shadow()) |
1480 return true; | 1505 return true; |
1481 | 1506 |
1482 return false; | 1507 return false; |
1483 } | 1508 } |
1484 #endif | 1509 #endif |
1485 | 1510 |
1486 } // namespace blink | 1511 } // namespace blink |
OLD | NEW |