| 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 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1266 } | 1266 } |
| 1267 | 1267 |
| 1268 void ContainerNode::setRestyleFlag(DynamicRestyleFlags mask) { | 1268 void ContainerNode::setRestyleFlag(DynamicRestyleFlags mask) { |
| 1269 DCHECK(isElementNode() || isShadowRoot()); | 1269 DCHECK(isElementNode() || isShadowRoot()); |
| 1270 ensureRareData().setRestyleFlag(mask); | 1270 ensureRareData().setRestyleFlag(mask); |
| 1271 } | 1271 } |
| 1272 | 1272 |
| 1273 void ContainerNode::recalcDescendantStyles(StyleRecalcChange change) { | 1273 void ContainerNode::recalcDescendantStyles(StyleRecalcChange change) { |
| 1274 DCHECK(document().inStyleRecalc()); | 1274 DCHECK(document().inStyleRecalc()); |
| 1275 DCHECK(change >= UpdatePseudoElements || childNeedsStyleRecalc()); | 1275 DCHECK(change >= UpdatePseudoElements || childNeedsStyleRecalc()); |
| 1276 DCHECK(!needsStyleRecalc()); | |
| 1277 | 1276 |
| 1278 // This loop is deliberately backwards because we use insertBefore in the | 1277 // This loop is deliberately backwards because we use insertBefore in the |
| 1279 // layout tree, and want to avoid a potentially n^2 loop to find the insertion | 1278 // layout tree, and want to avoid a potentially n^2 loop to find the insertion |
| 1280 // point while resolving style. Having us start from the last child and work | 1279 // point while resolving style. Having us start from the last child and work |
| 1281 // our way back means in the common case, we'll find the insertion point in | 1280 // our way back means in the common case, we'll find the insertion point in |
| 1282 // O(1) time. See crbug.com/288225 | 1281 // O(1) time. See crbug.com/288225 |
| 1283 StyleResolver& styleResolver = document().ensureStyleResolver(); | 1282 StyleResolver& styleResolver = document().ensureStyleResolver(); |
| 1284 Text* lastTextNode = nullptr; | 1283 Text* lastTextNode = nullptr; |
| 1285 for (Node* child = lastChild(); child; child = child->previousSibling()) { | 1284 for (Node* child = lastChild(); child; child = child->previousSibling()) { |
| 1286 if (child->isTextNode()) { | 1285 if (child->isTextNode()) { |
| 1287 toText(child)->recalcTextStyle(change, lastTextNode); | 1286 toText(child)->recalcTextStyle(change, lastTextNode); |
| 1288 lastTextNode = toText(child); | 1287 lastTextNode = toText(child); |
| 1289 } else if (child->isElementNode()) { | 1288 } else if (child->isElementNode()) { |
| 1290 Element* element = toElement(child); | 1289 Element* element = toElement(child); |
| 1291 if (element->shouldCallRecalcStyle(change)) | 1290 if (element->shouldCallRecalcStyle(change)) |
| 1292 element->recalcStyle(change, lastTextNode); | 1291 element->recalcStyle(change, lastTextNode); |
| 1293 else if (element->supportsStyleSharing()) | 1292 else if (element->supportsStyleSharing()) |
| 1294 styleResolver.addToStyleSharingList(*element); | 1293 styleResolver.addToStyleSharingList(*element); |
| 1295 if (element->layoutObject()) | 1294 if (element->layoutObject()) |
| 1296 lastTextNode = nullptr; | 1295 lastTextNode = nullptr; |
| 1297 } | 1296 } |
| 1298 } | 1297 } |
| 1299 } | 1298 } |
| 1300 | 1299 |
| 1300 void ContainerNode::rebuildChildrenLayoutTrees() { |
| 1301 DCHECK(!needsReattachLayoutTree()); |
| 1302 |
| 1303 for (Node* child = lastChild(); child; child = child->previousSibling()) { |
| 1304 if (child->needsReattachLayoutTree() || |
| 1305 child->childNeedsReattachLayoutTree()) { |
| 1306 if (child->isTextNode()) |
| 1307 toText(child)->rebuildTextLayoutTree(); |
| 1308 else if (child->isElementNode()) |
| 1309 toElement(child)->rebuildLayoutTree(); |
| 1310 } |
| 1311 } |
| 1312 // This is done in ContainerNode::attachLayoutTree but will never be cleared |
| 1313 // if we don't enter ContainerNode::attachLayoutTree so we do it here. |
| 1314 clearChildNeedsStyleRecalc(); |
| 1315 clearChildNeedsReattachLayoutTree(); |
| 1316 } |
| 1317 |
| 1301 void ContainerNode::checkForSiblingStyleChanges(SiblingCheckType changeType, | 1318 void ContainerNode::checkForSiblingStyleChanges(SiblingCheckType changeType, |
| 1302 Element* changedElement, | 1319 Element* changedElement, |
| 1303 Node* nodeBeforeChange, | 1320 Node* nodeBeforeChange, |
| 1304 Node* nodeAfterChange) { | 1321 Node* nodeAfterChange) { |
| 1305 if (!inActiveDocument() || document().hasPendingForcedStyleRecalc() || | 1322 if (!inActiveDocument() || document().hasPendingForcedStyleRecalc() || |
| 1306 getStyleChangeType() >= SubtreeStyleChange) | 1323 getStyleChangeType() >= SubtreeStyleChange) |
| 1307 return; | 1324 return; |
| 1308 | 1325 |
| 1309 if (!hasRestyleFlag(ChildrenAffectedByStructuralRules)) | 1326 if (!hasRestyleFlag(ChildrenAffectedByStructuralRules)) |
| 1310 return; | 1327 return; |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1470 return true; | 1487 return true; |
| 1471 | 1488 |
| 1472 if (node->isElementNode() && toElement(node)->shadow()) | 1489 if (node->isElementNode() && toElement(node)->shadow()) |
| 1473 return true; | 1490 return true; |
| 1474 | 1491 |
| 1475 return false; | 1492 return false; |
| 1476 } | 1493 } |
| 1477 #endif | 1494 #endif |
| 1478 | 1495 |
| 1479 } // namespace blink | 1496 } // namespace blink |
| OLD | NEW |