OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Neither the name of Google Inc. nor the names of its | 10 * * Neither the name of Google Inc. nor the names of its |
11 * contributors may be used to endorse or promote products derived from | 11 * contributors may be used to endorse or promote products derived from |
12 * this software without specific prior written permission. | 12 * this software without specific prior written permission. |
13 * | 13 * |
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
15 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 15 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
16 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 16 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
17 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 17 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
18 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 18 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
19 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 19 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
20 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 20 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 */ | 25 */ |
26 | 26 |
27 #include "core/dom/shadow/ElementShadow.h" | 27 #include "core/dom/shadow/ElementShadow.h" |
28 | 28 |
29 #include "core/css/StyleSheetList.h" | 29 #include "core/css/StyleSheetList.h" |
| 30 #include "core/css/resolver/ScopedStyleResolver.h" |
30 #include "core/dom/StyleChangeReason.h" | 31 #include "core/dom/StyleChangeReason.h" |
31 #include "core/dom/shadow/ElementShadowV0.h" | 32 #include "core/dom/shadow/ElementShadowV0.h" |
32 #include "core/frame/Deprecation.h" | 33 #include "core/frame/Deprecation.h" |
33 #include "core/inspector/InspectorInstrumentation.h" | 34 #include "core/inspector/InspectorInstrumentation.h" |
34 #include "platform/EventDispatchForbiddenScope.h" | 35 #include "platform/EventDispatchForbiddenScope.h" |
35 #include "platform/ScriptForbiddenScope.h" | 36 #include "platform/ScriptForbiddenScope.h" |
36 | 37 |
37 namespace blink { | 38 namespace blink { |
38 | 39 |
39 ElementShadow* ElementShadow::create() { | 40 ElementShadow* ElementShadow::create() { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 v0().clearDistribution(); | 133 v0().clearDistribution(); |
133 } | 134 } |
134 | 135 |
135 bool ElementShadow::hasSameStyles(const ElementShadow& other) const { | 136 bool ElementShadow::hasSameStyles(const ElementShadow& other) const { |
136 ShadowRoot* root = &youngestShadowRoot(); | 137 ShadowRoot* root = &youngestShadowRoot(); |
137 ShadowRoot* otherRoot = &other.youngestShadowRoot(); | 138 ShadowRoot* otherRoot = &other.youngestShadowRoot(); |
138 while (root || otherRoot) { | 139 while (root || otherRoot) { |
139 if (!root || !otherRoot) | 140 if (!root || !otherRoot) |
140 return false; | 141 return false; |
141 | 142 |
142 StyleSheetList& list = root->styleSheets(); | 143 if (!ScopedStyleResolver::haveSameStyles( |
143 StyleSheetList& otherList = otherRoot->styleSheets(); | 144 root->scopedStyleResolver(), otherRoot->scopedStyleResolver())) { |
| 145 return false; |
| 146 } |
144 | 147 |
145 if (list.length() != otherList.length()) | |
146 return false; | |
147 | |
148 for (size_t i = 0; i < list.length(); i++) { | |
149 if (toCSSStyleSheet(list.item(i))->contents() != | |
150 toCSSStyleSheet(otherList.item(i))->contents()) | |
151 return false; | |
152 } | |
153 root = root->olderShadowRoot(); | 148 root = root->olderShadowRoot(); |
154 otherRoot = otherRoot->olderShadowRoot(); | 149 otherRoot = otherRoot->olderShadowRoot(); |
155 } | 150 } |
156 | 151 |
157 return true; | 152 return true; |
158 } | 153 } |
159 | 154 |
160 void ElementShadow::distribute() { | 155 void ElementShadow::distribute() { |
161 if (isV1()) | 156 if (isV1()) |
162 youngestShadowRoot().distributeV1(); | 157 youngestShadowRoot().distributeV1(); |
163 else | 158 else |
164 v0().distribute(); | 159 v0().distribute(); |
165 } | 160 } |
166 | 161 |
167 DEFINE_TRACE(ElementShadow) { | 162 DEFINE_TRACE(ElementShadow) { |
168 visitor->trace(m_elementShadowV0); | 163 visitor->trace(m_elementShadowV0); |
169 visitor->trace(m_shadowRoot); | 164 visitor->trace(m_shadowRoot); |
170 } | 165 } |
171 | 166 |
172 DEFINE_TRACE_WRAPPERS(ElementShadow) { | 167 DEFINE_TRACE_WRAPPERS(ElementShadow) { |
173 visitor->traceWrappers(m_elementShadowV0); | 168 visitor->traceWrappers(m_elementShadowV0); |
174 visitor->traceWrappers(m_shadowRoot); | 169 visitor->traceWrappers(m_shadowRoot); |
175 } | 170 } |
176 | 171 |
177 } // namespace blink | 172 } // namespace blink |
OLD | NEW |