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 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1309 } else if (child->IsElementNode()) { | 1309 } else if (child->IsElementNode()) { |
1310 Element* element = ToElement(child); | 1310 Element* element = ToElement(child); |
1311 if (element->ShouldCallRecalcStyle(change)) | 1311 if (element->ShouldCallRecalcStyle(change)) |
1312 element->RecalcStyle(change); | 1312 element->RecalcStyle(change); |
1313 else if (element->SupportsStyleSharing()) | 1313 else if (element->SupportsStyleSharing()) |
1314 style_resolver.AddToStyleSharingList(*element); | 1314 style_resolver.AddToStyleSharingList(*element); |
1315 } | 1315 } |
1316 } | 1316 } |
1317 } | 1317 } |
1318 | 1318 |
| 1319 void ContainerNode::RebuildLayoutTreeForChild(Node* child, |
| 1320 Text*& next_text_sibling) { |
| 1321 bool rebuild_child = |
| 1322 child->NeedsReattachLayoutTree() || child->ChildNeedsReattachLayoutTree(); |
| 1323 |
| 1324 if (child->IsTextNode()) { |
| 1325 Text* text_node = ToText(child); |
| 1326 if (rebuild_child) |
| 1327 text_node->RebuildTextLayoutTree(next_text_sibling); |
| 1328 next_text_sibling = text_node; |
| 1329 return; |
| 1330 } |
| 1331 |
| 1332 if (!child->IsElementNode()) |
| 1333 return; |
| 1334 |
| 1335 Element* element = ToElement(child); |
| 1336 if (rebuild_child) |
| 1337 element->RebuildLayoutTree(next_text_sibling); |
| 1338 if (element->GetLayoutObject()) |
| 1339 next_text_sibling = nullptr; |
| 1340 } |
| 1341 |
1319 void ContainerNode::RebuildChildrenLayoutTrees(Text*& next_text_sibling) { | 1342 void ContainerNode::RebuildChildrenLayoutTrees(Text*& next_text_sibling) { |
1320 DCHECK(!NeedsReattachLayoutTree()); | 1343 DCHECK(!NeedsReattachLayoutTree()); |
1321 | 1344 |
| 1345 if (IsActiveSlotOrActiveInsertionPoint()) { |
| 1346 if (isHTMLSlotElement(this)) |
| 1347 toHTMLSlotElement(this)->RebuildDistributedChildrenLayoutTrees(); |
| 1348 else |
| 1349 ToInsertionPoint(this)->RebuildDistributedChildrenLayoutTrees(); |
| 1350 } |
| 1351 |
1322 // This loop is deliberately backwards because we use insertBefore in the | 1352 // This loop is deliberately backwards because we use insertBefore in the |
1323 // layout tree, and want to avoid a potentially n^2 loop to find the insertion | 1353 // layout tree, and want to avoid a potentially n^2 loop to find the insertion |
1324 // point while building the layout tree. Having us start from the last child | 1354 // point while building the layout tree. Having us start from the last child |
1325 // and work our way back means in the common case, we'll find the insertion | 1355 // and work our way back means in the common case, we'll find the insertion |
1326 // point in O(1) time. See crbug.com/288225 | 1356 // point in O(1) time. See crbug.com/288225 |
1327 for (Node* child = lastChild(); child; child = child->previousSibling()) { | 1357 for (Node* child = lastChild(); child; child = child->previousSibling()) |
1328 bool rebuild_child = child->NeedsReattachLayoutTree() || | 1358 RebuildLayoutTreeForChild(child, next_text_sibling); |
1329 child->ChildNeedsReattachLayoutTree(); | 1359 |
1330 if (child->IsTextNode()) { | 1360 // This is done in ContainerNode::AttachLayoutTree but will never be cleared |
1331 Text* text_node = ToText(child); | 1361 // if we don't enter ContainerNode::AttachLayoutTree so we do it here. |
1332 if (rebuild_child) | |
1333 text_node->RebuildTextLayoutTree(next_text_sibling); | |
1334 next_text_sibling = text_node; | |
1335 } else if (child->IsElementNode()) { | |
1336 Element* element = ToElement(child); | |
1337 if (rebuild_child) | |
1338 element->RebuildLayoutTree(next_text_sibling); | |
1339 if (element->GetLayoutObject()) | |
1340 next_text_sibling = nullptr; | |
1341 } | |
1342 } | |
1343 // This is done in ContainerNode::attachLayoutTree but will never be cleared | |
1344 // if we don't enter ContainerNode::attachLayoutTree so we do it here. | |
1345 ClearChildNeedsStyleRecalc(); | 1362 ClearChildNeedsStyleRecalc(); |
1346 ClearChildNeedsReattachLayoutTree(); | 1363 ClearChildNeedsReattachLayoutTree(); |
1347 } | 1364 } |
1348 | 1365 |
1349 void ContainerNode::CheckForSiblingStyleChanges(SiblingCheckType change_type, | 1366 void ContainerNode::CheckForSiblingStyleChanges(SiblingCheckType change_type, |
1350 Element* changed_element, | 1367 Element* changed_element, |
1351 Node* node_before_change, | 1368 Node* node_before_change, |
1352 Node* node_after_change) { | 1369 Node* node_after_change) { |
1353 if (!InActiveDocument() || GetDocument().HasPendingForcedStyleRecalc() || | 1370 if (!InActiveDocument() || GetDocument().HasPendingForcedStyleRecalc() || |
1354 GetStyleChangeType() >= kSubtreeStyleChange) | 1371 GetStyleChangeType() >= kSubtreeStyleChange) |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1520 return true; | 1537 return true; |
1521 | 1538 |
1522 if (node->IsElementNode() && ToElement(node)->Shadow()) | 1539 if (node->IsElementNode() && ToElement(node)->Shadow()) |
1523 return true; | 1540 return true; |
1524 | 1541 |
1525 return false; | 1542 return false; |
1526 } | 1543 } |
1527 #endif | 1544 #endif |
1528 | 1545 |
1529 } // namespace blink | 1546 } // namespace blink |
OLD | NEW |