OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. | 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. |
4 * Copyright (C) 2012 Google Inc. All rights reserved. | 4 * Copyright (C) 2012 Google Inc. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
11 * 2. Redistributions in binary form must reproduce the above copyright | 11 * 2. Redistributions in binary form must reproduce the above copyright |
12 * notice, this list of conditions and the following disclaimer in the | 12 * notice, this list of conditions and the following disclaimer in the |
13 * documentation and/or other materials provided with the distribution. | 13 * documentation and/or other materials provided with the distribution. |
14 * | 14 * |
15 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y | 15 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y |
16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
18 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y | 18 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y |
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N | 21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N |
22 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 */ | 25 */ |
26 | 26 |
27 #include "core/css/resolver/ScopedStyleResolver.h" | 27 #include "core/css/resolver/ScopedStyleResolver.h" |
28 | 28 |
29 #include "core/HTMLNames.h" | 29 #include "core/HTMLNames.h" |
| 30 #include "core/animation/DocumentTimeline.h" |
30 #include "core/css/CSSFontSelector.h" | 31 #include "core/css/CSSFontSelector.h" |
31 #include "core/css/CSSStyleSheet.h" | 32 #include "core/css/CSSStyleSheet.h" |
32 #include "core/css/FontFace.h" | 33 #include "core/css/FontFace.h" |
33 #include "core/css/PageRuleCollector.h" | 34 #include "core/css/PageRuleCollector.h" |
34 #include "core/css/RuleFeature.h" | 35 #include "core/css/RuleFeature.h" |
35 #include "core/css/StyleRule.h" | 36 #include "core/css/StyleRule.h" |
36 #include "core/css/StyleSheetContents.h" | 37 #include "core/css/StyleSheetContents.h" |
37 #include "core/css/resolver/MatchRequest.h" | 38 #include "core/css/resolver/MatchRequest.h" |
38 #include "core/css/resolver/ViewportStyleResolver.h" | 39 #include "core/css/resolver/ViewportStyleResolver.h" |
39 #include "core/dom/Document.h" | 40 #include "core/dom/Document.h" |
| 41 #include "core/dom/StyleChangeReason.h" |
40 #include "core/dom/StyleEngine.h" | 42 #include "core/dom/StyleEngine.h" |
41 #include "core/dom/shadow/ElementShadow.h" | 43 #include "core/dom/shadow/ElementShadow.h" |
42 #include "core/dom/shadow/ShadowRoot.h" | 44 #include "core/dom/shadow/ShadowRoot.h" |
43 #include "core/html/HTMLStyleElement.h" | 45 #include "core/html/HTMLStyleElement.h" |
44 #include "core/svg/SVGStyleElement.h" | 46 #include "core/svg/SVGStyleElement.h" |
45 | 47 |
46 namespace blink { | 48 namespace blink { |
47 | 49 |
48 ScopedStyleResolver* ScopedStyleResolver::parent() const | 50 ScopedStyleResolver* ScopedStyleResolver::parent() const |
49 { | 51 { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 KeyframesRuleMap::iterator it = m_keyframesRuleMap.find(s.impl()); | 139 KeyframesRuleMap::iterator it = m_keyframesRuleMap.find(s.impl()); |
138 if (it == m_keyframesRuleMap.end()) | 140 if (it == m_keyframesRuleMap.end()) |
139 m_keyframesRuleMap.set(s.impl(), rule); | 141 m_keyframesRuleMap.set(s.impl(), rule); |
140 else if (it->value->isVendorPrefixed()) | 142 else if (it->value->isVendorPrefixed()) |
141 m_keyframesRuleMap.set(s.impl(), rule); | 143 m_keyframesRuleMap.set(s.impl(), rule); |
142 } else { | 144 } else { |
143 m_keyframesRuleMap.set(s.impl(), rule); | 145 m_keyframesRuleMap.set(s.impl(), rule); |
144 } | 146 } |
145 } | 147 } |
146 | 148 |
| 149 static Node& invalidationRootFor(const TreeScope& treeScope) |
| 150 { |
| 151 if (treeScope.rootNode() == treeScope.document()) |
| 152 return treeScope.document(); |
| 153 return toShadowRoot(treeScope.rootNode()).host(); |
| 154 } |
| 155 |
| 156 void ScopedStyleResolver::keyframesRulesAdded(const TreeScope& treeScope) |
| 157 { |
| 158 // Called when @keyframes rules are about to be added/removed from a |
| 159 // TreeScope. @keyframes rules may apply to animations on elements in the |
| 160 // same TreeScope as the stylesheet, or the host element in the parent |
| 161 // TreeScope if the TreeScope is a shadow tree. |
| 162 |
| 163 ScopedStyleResolver* resolver = treeScope.scopedStyleResolver(); |
| 164 ScopedStyleResolver* parentResolver = treeScope.parentTreeScope() ? treeScop
e.parentTreeScope()->scopedStyleResolver() : nullptr; |
| 165 |
| 166 bool hadUnresolvedKeyframes = false; |
| 167 if (resolver && resolver->m_hasUnresolvedKeyframesRule) { |
| 168 resolver->m_hasUnresolvedKeyframesRule = false; |
| 169 hadUnresolvedKeyframes = true; |
| 170 } |
| 171 if (parentResolver && parentResolver->m_hasUnresolvedKeyframesRule) { |
| 172 parentResolver->m_hasUnresolvedKeyframesRule = false; |
| 173 hadUnresolvedKeyframes = true; |
| 174 } |
| 175 |
| 176 if (hadUnresolvedKeyframes) { |
| 177 // If an animation ended up not being started because no @keyframes |
| 178 // rules were found for the animation-name, we need to recalculate style |
| 179 // for the elements in the scope, including its shadow host if |
| 180 // applicable. |
| 181 invalidationRootFor(treeScope).setNeedsStyleRecalc(SubtreeStyleChange, S
tyleChangeReasonForTracing::create(StyleChangeReason::StyleSheetChange)); |
| 182 return; |
| 183 } |
| 184 |
| 185 // If we have animations running, added/removed @keyframes may affect these. |
| 186 treeScope.document().timeline().invalidateKeyframeEffects(treeScope); |
| 187 } |
| 188 |
147 void ScopedStyleResolver::collectMatchingAuthorRules(ElementRuleCollector& colle
ctor, CascadeOrder cascadeOrder) | 189 void ScopedStyleResolver::collectMatchingAuthorRules(ElementRuleCollector& colle
ctor, CascadeOrder cascadeOrder) |
148 { | 190 { |
149 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) { | 191 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) { |
150 ASSERT(m_authorStyleSheets[i]->ownerNode()); | 192 ASSERT(m_authorStyleSheets[i]->ownerNode()); |
151 MatchRequest matchRequest(&m_authorStyleSheets[i]->contents()->ruleSet()
, &m_scope->rootNode(), m_authorStyleSheets[i], i); | 193 MatchRequest matchRequest(&m_authorStyleSheets[i]->contents()->ruleSet()
, &m_scope->rootNode(), m_authorStyleSheets[i], i); |
152 collector.collectMatchingRules(matchRequest, cascadeOrder); | 194 collector.collectMatchingRules(matchRequest, cascadeOrder); |
153 } | 195 } |
154 } | 196 } |
155 | 197 |
156 void ScopedStyleResolver::collectMatchingShadowHostRules(ElementRuleCollector& c
ollector, CascadeOrder cascadeOrder) | 198 void ScopedStyleResolver::collectMatchingShadowHostRules(ElementRuleCollector& c
ollector, CascadeOrder cascadeOrder) |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 m_treeBoundaryCrossingRuleSet->append(RuleSubSet::create(parentStyleSheet, s
heetIndex, ruleSetForScope)); | 273 m_treeBoundaryCrossingRuleSet->append(RuleSubSet::create(parentStyleSheet, s
heetIndex, ruleSetForScope)); |
232 } | 274 } |
233 | 275 |
234 DEFINE_TRACE(ScopedStyleResolver::RuleSubSet) | 276 DEFINE_TRACE(ScopedStyleResolver::RuleSubSet) |
235 { | 277 { |
236 visitor->trace(m_parentStyleSheet); | 278 visitor->trace(m_parentStyleSheet); |
237 visitor->trace(m_ruleSet); | 279 visitor->trace(m_ruleSet); |
238 } | 280 } |
239 | 281 |
240 } // namespace blink | 282 } // namespace blink |
OLD | NEW |