| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/dom/SiblingRuleHelper.h" | 6 #include "core/dom/SiblingRuleHelper.h" |
| 7 | 7 |
| 8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "core/dom/Element.h" | 9 #include "core/dom/Element.h" |
| 10 #include "core/dom/StyleEngine.h" | 10 #include "core/dom/StyleEngine.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 } | 21 } |
| 22 | 22 |
| 23 void SiblingRuleHelper::setChildrenAffectedByDirectAdjacentRules() | 23 void SiblingRuleHelper::setChildrenAffectedByDirectAdjacentRules() |
| 24 { | 24 { |
| 25 if (m_node->isElementNode()) | 25 if (m_node->isElementNode()) |
| 26 toElement(m_node)->setChildrenAffectedByDirectAdjacentRules(); | 26 toElement(m_node)->setChildrenAffectedByDirectAdjacentRules(); |
| 27 else | 27 else |
| 28 toShadowRoot(m_node)->setChildrenAffectedByDirectAdjacentRules(); | 28 toShadowRoot(m_node)->setChildrenAffectedByDirectAdjacentRules(); |
| 29 } | 29 } |
| 30 | 30 |
| 31 void SiblingRuleHelper::setChildrenAffectedByIndirectAdjacentRules() |
| 32 { |
| 33 if (m_node->isElementNode()) |
| 34 toElement(m_node)->setChildrenAffectedByIndirectAdjacentRules(); |
| 35 else |
| 36 toShadowRoot(m_node)->setChildrenAffectedByIndirectAdjacentRules(); |
| 37 } |
| 38 |
| 31 void SiblingRuleHelper::setChildrenAffectedByForwardPositionalRules() | 39 void SiblingRuleHelper::setChildrenAffectedByForwardPositionalRules() |
| 32 { | 40 { |
| 33 if (m_node->isElementNode()) | 41 if (m_node->isElementNode()) |
| 34 toElement(m_node)->setChildrenAffectedByForwardPositionalRules(); | 42 toElement(m_node)->setChildrenAffectedByForwardPositionalRules(); |
| 35 else | 43 else |
| 36 toShadowRoot(m_node)->setChildrenAffectedByForwardPositionalRules(); | 44 toShadowRoot(m_node)->setChildrenAffectedByForwardPositionalRules(); |
| 37 } | 45 } |
| 38 | 46 |
| 39 void SiblingRuleHelper::setChildrenAffectedByBackwardPositionalRules() | 47 void SiblingRuleHelper::setChildrenAffectedByBackwardPositionalRules() |
| 40 { | 48 { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 bool SiblingRuleHelper::childrenAffectedByLastChildRules() const | 81 bool SiblingRuleHelper::childrenAffectedByLastChildRules() const |
| 74 { | 82 { |
| 75 return m_node->isElementNode() ? toElement(m_node)->childrenAffectedByLastCh
ildRules() : toShadowRoot(m_node)->childrenAffectedByLastChildRules(); | 83 return m_node->isElementNode() ? toElement(m_node)->childrenAffectedByLastCh
ildRules() : toShadowRoot(m_node)->childrenAffectedByLastChildRules(); |
| 76 } | 84 } |
| 77 | 85 |
| 78 bool SiblingRuleHelper::childrenAffectedByDirectAdjacentRules() const | 86 bool SiblingRuleHelper::childrenAffectedByDirectAdjacentRules() const |
| 79 { | 87 { |
| 80 return m_node->isElementNode() ? toElement(m_node)->childrenAffectedByDirect
AdjacentRules() : toShadowRoot(m_node)->childrenAffectedByDirectAdjacentRules(); | 88 return m_node->isElementNode() ? toElement(m_node)->childrenAffectedByDirect
AdjacentRules() : toShadowRoot(m_node)->childrenAffectedByDirectAdjacentRules(); |
| 81 } | 89 } |
| 82 | 90 |
| 91 bool SiblingRuleHelper::childrenAffectedByIndirectAdjacentRules() const |
| 92 { |
| 93 return m_node->isElementNode() ? toElement(m_node)->childrenAffectedByIndire
ctAdjacentRules() : toShadowRoot(m_node)->childrenAffectedByIndirectAdjacentRule
s(); |
| 94 } |
| 95 |
| 83 bool SiblingRuleHelper::childrenAffectedByForwardPositionalRules() const | 96 bool SiblingRuleHelper::childrenAffectedByForwardPositionalRules() const |
| 84 { | 97 { |
| 85 return m_node->isElementNode() ? toElement(m_node)->childrenAffectedByForwar
dPositionalRules() : toShadowRoot(m_node)->childrenAffectedByForwardPositionalRu
les(); | 98 return m_node->isElementNode() ? toElement(m_node)->childrenAffectedByForwar
dPositionalRules() : toShadowRoot(m_node)->childrenAffectedByForwardPositionalRu
les(); |
| 86 } | 99 } |
| 87 | 100 |
| 88 bool SiblingRuleHelper::childrenAffectedByBackwardPositionalRules() const | 101 bool SiblingRuleHelper::childrenAffectedByBackwardPositionalRules() const |
| 89 { | 102 { |
| 90 return m_node->isElementNode() ? toElement(m_node)->childrenAffectedByBackwa
rdPositionalRules() : toShadowRoot(m_node)->childrenAffectedByBackwardPositional
Rules(); | 103 return m_node->isElementNode() ? toElement(m_node)->childrenAffectedByBackwa
rdPositionalRules() : toShadowRoot(m_node)->childrenAffectedByBackwardPositional
Rules(); |
| 91 } | 104 } |
| 92 | 105 |
| 93 void SiblingRuleHelper::checkForChildrenAdjacentRuleChanges() | 106 void SiblingRuleHelper::checkForChildrenAdjacentRuleChanges() |
| 94 { | 107 { |
| 95 bool hasDirectAdjacentRules = childrenAffectedByDirectAdjacentRules(); | 108 bool hasDirectAdjacentRules = childrenAffectedByDirectAdjacentRules(); |
| 96 bool hasIndirectAdjacentRules = childrenAffectedByForwardPositionalRules(); | 109 bool hasIndirectAdjacentRules = childrenAffectedByIndirectAdjacentRules(); |
| 97 | 110 |
| 98 if (!hasDirectAdjacentRules && !hasIndirectAdjacentRules) | 111 if (!hasDirectAdjacentRules && !hasIndirectAdjacentRules) |
| 99 return; | 112 return; |
| 100 | 113 |
| 101 unsigned forceCheckOfNextElementCount = 0; | 114 unsigned forceCheckOfNextElementCount = 0; |
| 102 bool forceCheckOfAnyElementSibling = false; | 115 bool forceCheckOfAnyElementSibling = false; |
| 103 Document& document = m_node->document(); | 116 Document& document = m_node->document(); |
| 104 | 117 |
| 105 for (Node* child = m_node->firstChild(); child; child = child->nextSibling()
) { | 118 for (Node* child = m_node->firstChild(); child; child = child->nextSibling()
) { |
| 106 if (!child->isElementNode()) | 119 if (!child->isElementNode()) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 121 } | 134 } |
| 122 } | 135 } |
| 123 | 136 |
| 124 bool SiblingRuleHelper::childrenSupportStyleSharing() | 137 bool SiblingRuleHelper::childrenSupportStyleSharing() |
| 125 { | 138 { |
| 126 return m_node->isElementNode() ? toElement(m_node)->childrenSupportStyleShar
ing() : toShadowRoot(m_node)->childrenSupportStyleSharing(); | 139 return m_node->isElementNode() ? toElement(m_node)->childrenSupportStyleShar
ing() : toShadowRoot(m_node)->childrenSupportStyleSharing(); |
| 127 } | 140 } |
| 128 | 141 |
| 129 } // namespace WebCore | 142 } // namespace WebCore |
| 130 | 143 |
| OLD | NEW |