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 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1291 } else if (child->isElementNode()) { | 1291 } else if (child->isElementNode()) { |
1292 Element* element = toElement(child); | 1292 Element* element = toElement(child); |
1293 if (element->shouldCallRecalcStyle(change)) | 1293 if (element->shouldCallRecalcStyle(change)) |
1294 element->recalcStyle(change); | 1294 element->recalcStyle(change); |
1295 else if (element->supportsStyleSharing()) | 1295 else if (element->supportsStyleSharing()) |
1296 styleResolver.addToStyleSharingList(*element); | 1296 styleResolver.addToStyleSharingList(*element); |
1297 } | 1297 } |
1298 } | 1298 } |
1299 } | 1299 } |
1300 | 1300 |
1301 void ContainerNode::rebuildChildrenLayoutTrees() { | 1301 void ContainerNode::rebuildChildrenLayoutTrees(Text*& nextTextSibling) { |
1302 DCHECK(!needsReattachLayoutTree()); | 1302 DCHECK(!needsReattachLayoutTree()); |
1303 | 1303 |
1304 // This loop is deliberately backwards because we use insertBefore in the | 1304 // This loop is deliberately backwards because we use insertBefore in the |
1305 // layout tree, and want to avoid a potentially n^2 loop to find the insertion | 1305 // layout tree, and want to avoid a potentially n^2 loop to find the insertion |
1306 // point while building the layout tree. Having us start from the last child | 1306 // point while building the layout tree. Having us start from the last child |
1307 // and work our way back means in the common case, we'll find the insertion | 1307 // and work our way back means in the common case, we'll find the insertion |
1308 // point in O(1) time. See crbug.com/288225 | 1308 // point in O(1) time. See crbug.com/288225 |
1309 Text* lastTextNode = nullptr; | |
1310 for (Node* child = lastChild(); child; child = child->previousSibling()) { | 1309 for (Node* child = lastChild(); child; child = child->previousSibling()) { |
1311 bool rebuildChild = child->needsReattachLayoutTree() || | 1310 bool rebuildChild = child->needsReattachLayoutTree() || |
1312 child->childNeedsReattachLayoutTree(); | 1311 child->childNeedsReattachLayoutTree(); |
1313 if (child->isTextNode()) { | 1312 if (child->isTextNode()) { |
1314 Text* textNode = toText(child); | 1313 Text* textNode = toText(child); |
1315 if (rebuildChild) | 1314 if (rebuildChild) |
1316 textNode->rebuildTextLayoutTree(lastTextNode); | 1315 textNode->rebuildTextLayoutTree(nextTextSibling); |
1317 lastTextNode = textNode; | 1316 nextTextSibling = textNode; |
1318 } else if (child->isElementNode()) { | 1317 } else if (child->isElementNode()) { |
1319 Element* element = toElement(child); | 1318 Element* element = toElement(child); |
1320 if (rebuildChild) | 1319 if (rebuildChild) |
1321 element->rebuildLayoutTree(lastTextNode); | 1320 element->rebuildLayoutTree(nextTextSibling); |
1322 if (element->layoutObject()) | 1321 if (element->layoutObject()) |
1323 lastTextNode = nullptr; | 1322 nextTextSibling = nullptr; |
1324 } | 1323 } |
1325 } | 1324 } |
1326 // This is done in ContainerNode::attachLayoutTree but will never be cleared | 1325 // This is done in ContainerNode::attachLayoutTree but will never be cleared |
1327 // if we don't enter ContainerNode::attachLayoutTree so we do it here. | 1326 // if we don't enter ContainerNode::attachLayoutTree so we do it here. |
1328 clearChildNeedsStyleRecalc(); | 1327 clearChildNeedsStyleRecalc(); |
1329 clearChildNeedsReattachLayoutTree(); | 1328 clearChildNeedsReattachLayoutTree(); |
1330 } | 1329 } |
1331 | 1330 |
1331 Text* ContainerNode::findNextTextSibling() const { | |
esprehn
2017/03/28 20:56:51
This needs a better name, it's doing something ver
rune
2017/03/29 10:39:47
PS2 adds a new method on ShadowRoot instead.
| |
1332 for (Node* sibling = firstChild(); sibling; | |
esprehn
2017/03/28 20:56:51
This is confusing, the function says sibling, but
rune
2017/03/29 10:39:47
Acknowledged.
| |
1333 sibling = sibling->nextSibling()) { | |
1334 if (sibling->isTextNode()) | |
1335 return toText(sibling); | |
1336 LayoutObject* layoutObject = sibling->layoutObject(); | |
1337 if (layoutObject && !layoutObject->isFloatingOrOutOfFlowPositioned()) | |
esprehn
2017/03/28 20:56:51
Why is it safe to call this here? Wouldn't the sty
rune
2017/03/29 10:39:47
This code should be executed during rebuildLayoutT
| |
1338 return nullptr; | |
1339 } | |
1340 return nullptr; | |
1341 } | |
1342 | |
1332 void ContainerNode::checkForSiblingStyleChanges(SiblingCheckType changeType, | 1343 void ContainerNode::checkForSiblingStyleChanges(SiblingCheckType changeType, |
1333 Element* changedElement, | 1344 Element* changedElement, |
1334 Node* nodeBeforeChange, | 1345 Node* nodeBeforeChange, |
1335 Node* nodeAfterChange) { | 1346 Node* nodeAfterChange) { |
1336 if (!inActiveDocument() || document().hasPendingForcedStyleRecalc() || | 1347 if (!inActiveDocument() || document().hasPendingForcedStyleRecalc() || |
1337 getStyleChangeType() >= SubtreeStyleChange) | 1348 getStyleChangeType() >= SubtreeStyleChange) |
1338 return; | 1349 return; |
1339 | 1350 |
1340 if (!hasRestyleFlag(ChildrenAffectedByStructuralRules)) | 1351 if (!hasRestyleFlag(ChildrenAffectedByStructuralRules)) |
1341 return; | 1352 return; |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1501 return true; | 1512 return true; |
1502 | 1513 |
1503 if (node->isElementNode() && toElement(node)->shadow()) | 1514 if (node->isElementNode() && toElement(node)->shadow()) |
1504 return true; | 1515 return true; |
1505 | 1516 |
1506 return false; | 1517 return false; |
1507 } | 1518 } |
1508 #endif | 1519 #endif |
1509 | 1520 |
1510 } // namespace blink | 1521 } // namespace blink |
OLD | NEW |