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 |
1332 void ContainerNode::checkForSiblingStyleChanges(SiblingCheckType changeType, | 1331 void ContainerNode::checkForSiblingStyleChanges(SiblingCheckType changeType, |
1333 Element* changedElement, | 1332 Element* changedElement, |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1501 return true; | 1500 return true; |
1502 | 1501 |
1503 if (node->isElementNode() && toElement(node)->shadow()) | 1502 if (node->isElementNode() && toElement(node)->shadow()) |
1504 return true; | 1503 return true; |
1505 | 1504 |
1506 return false; | 1505 return false; |
1507 } | 1506 } |
1508 #endif | 1507 #endif |
1509 | 1508 |
1510 } // namespace blink | 1509 } // namespace blink |
OLD | NEW |