| 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
reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights
reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1198 { | 1198 { |
| 1199 return rareData()->hasRestyleFlags(); | 1199 return rareData()->hasRestyleFlags(); |
| 1200 } | 1200 } |
| 1201 | 1201 |
| 1202 void ContainerNode::setRestyleFlag(DynamicRestyleFlags mask) | 1202 void ContainerNode::setRestyleFlag(DynamicRestyleFlags mask) |
| 1203 { | 1203 { |
| 1204 ASSERT(isElementNode() || isShadowRoot()); | 1204 ASSERT(isElementNode() || isShadowRoot()); |
| 1205 ensureRareData().setRestyleFlag(mask); | 1205 ensureRareData().setRestyleFlag(mask); |
| 1206 } | 1206 } |
| 1207 | 1207 |
| 1208 void ContainerNode::recalcChildStyle(StyleRecalcChange change) |
| 1209 { |
| 1210 ASSERT(document().inStyleRecalc()); |
| 1211 ASSERT(change >= UpdatePseudoElements || childNeedsStyleRecalc()); |
| 1212 ASSERT(!needsStyleRecalc()); |
| 1213 |
| 1214 if (change < Force && hasRareData() && childNeedsStyleRecalc()) |
| 1215 checkForChildrenAdjacentRuleChanges(); |
| 1216 |
| 1217 // This loop is deliberately backwards because we use insertBefore in the re
ndering tree, and want to avoid |
| 1218 // a potentially n^2 loop to find the insertion point while resolving style.
Having us start from the last |
| 1219 // child and work our way back means in the common case, we'll find the inse
rtion point in O(1) time. |
| 1220 // See crbug.com/288225 |
| 1221 StyleResolver& styleResolver = document().ensureStyleResolver(); |
| 1222 Text* lastTextNode = 0; |
| 1223 for (Node* child = lastChild(); child; child = child->previousSibling()) { |
| 1224 if (child->isTextNode()) { |
| 1225 toText(child)->recalcTextStyle(change, lastTextNode); |
| 1226 lastTextNode = toText(child); |
| 1227 } else if (child->isElementNode()) { |
| 1228 Element* element = toElement(child); |
| 1229 if (element->shouldCallRecalcStyle(change)) |
| 1230 element->recalcStyle(change, lastTextNode); |
| 1231 else if (element->supportsStyleSharing()) |
| 1232 styleResolver.addToStyleSharingList(*element); |
| 1233 if (element->renderer()) |
| 1234 lastTextNode = 0; |
| 1235 } |
| 1236 } |
| 1237 } |
| 1238 |
| 1208 void ContainerNode::checkForChildrenAdjacentRuleChanges() | 1239 void ContainerNode::checkForChildrenAdjacentRuleChanges() |
| 1209 { | 1240 { |
| 1210 bool hasDirectAdjacentRules = childrenAffectedByDirectAdjacentRules(); | 1241 bool hasDirectAdjacentRules = childrenAffectedByDirectAdjacentRules(); |
| 1211 bool hasIndirectAdjacentRules = childrenAffectedByIndirectAdjacentRules(); | 1242 bool hasIndirectAdjacentRules = childrenAffectedByIndirectAdjacentRules(); |
| 1212 | 1243 |
| 1213 if (!hasDirectAdjacentRules && !hasIndirectAdjacentRules) | 1244 if (!hasDirectAdjacentRules && !hasIndirectAdjacentRules) |
| 1214 return; | 1245 return; |
| 1215 | 1246 |
| 1216 unsigned forceCheckOfNextElementCount = 0; | 1247 unsigned forceCheckOfNextElementCount = 0; |
| 1217 bool forceCheckOfAnyElementSibling = false; | 1248 bool forceCheckOfAnyElementSibling = false; |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1410 return true; | 1441 return true; |
| 1411 | 1442 |
| 1412 if (node->isElementNode() && toElement(node)->shadow()) | 1443 if (node->isElementNode() && toElement(node)->shadow()) |
| 1413 return true; | 1444 return true; |
| 1414 | 1445 |
| 1415 return false; | 1446 return false; |
| 1416 } | 1447 } |
| 1417 #endif | 1448 #endif |
| 1418 | 1449 |
| 1419 } // namespace blink | 1450 } // namespace blink |
| OLD | NEW |