| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) | 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) |
| 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
All rights reserved. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
All rights reserved. |
| 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
| 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
| 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
| 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. | 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
| 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 #include "config.h" | 29 #include "config.h" |
| 30 #include "core/css/resolver/StyleResolver.h" | 30 #include "core/css/resolver/StyleResolver.h" |
| 31 | 31 |
| 32 #include "CSSPropertyNames.h" | 32 #include "CSSPropertyNames.h" |
| 33 #include "HTMLNames.h" | 33 #include "HTMLNames.h" |
| 34 #include "RuntimeEnabledFeatures.h" | 34 #include "RuntimeEnabledFeatures.h" |
| 35 #include "StylePropertyShorthand.h" | 35 #include "StylePropertyShorthand.h" |
| 36 #include "core/animation/AnimatableValue.h" | 36 #include "core/animation/AnimatableValue.h" |
| 37 #include "core/animation/Animation.h" | 37 #include "core/animation/Animation.h" |
| 38 #include "core/animation/DocumentTimeline.h" |
| 38 #include "core/css/CSSCalculationValue.h" | 39 #include "core/css/CSSCalculationValue.h" |
| 39 #include "core/css/CSSDefaultStyleSheets.h" | 40 #include "core/css/CSSDefaultStyleSheets.h" |
| 40 #include "core/css/CSSFontSelector.h" | 41 #include "core/css/CSSFontSelector.h" |
| 41 #include "core/css/CSSKeyframeRule.h" | 42 #include "core/css/CSSKeyframeRule.h" |
| 42 #include "core/css/CSSKeyframesRule.h" | 43 #include "core/css/CSSKeyframesRule.h" |
| 43 #include "core/css/CSSParser.h" | 44 #include "core/css/CSSParser.h" |
| 44 #include "core/css/CSSReflectValue.h" | 45 #include "core/css/CSSReflectValue.h" |
| 45 #include "core/css/CSSRuleList.h" | 46 #include "core/css/CSSRuleList.h" |
| 46 #include "core/css/CSSSelector.h" | 47 #include "core/css/CSSSelector.h" |
| 47 #include "core/css/CSSStyleRule.h" | 48 #include "core/css/CSSStyleRule.h" |
| (...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 matchAuthorRules(state.element(), collector, rulesToInclude & EmptyCSSRu
les); | 974 matchAuthorRules(state.element(), collector, rulesToInclude & EmptyCSSRu
les); |
| 974 } | 975 } |
| 975 | 976 |
| 976 return collector.matchedRuleList(); | 977 return collector.matchedRuleList(); |
| 977 } | 978 } |
| 978 | 979 |
| 979 // -----------------------------------------------------------------------------
-------- | 980 // -----------------------------------------------------------------------------
-------- |
| 980 // this is mostly boring stuff on how to apply a certain rule to the renderstyle
... | 981 // this is mostly boring stuff on how to apply a certain rule to the renderstyle
... |
| 981 | 982 |
| 982 template <StyleResolver::StyleApplicationPass pass> | 983 template <StyleResolver::StyleApplicationPass pass> |
| 983 void StyleResolver::applyAnimatedProperties(StyleResolverState& state, const Ele
ment* target) | 984 void StyleResolver::applyAnimatedProperties(StyleResolverState& state, const Ele
ment* target, const DocumentTimeline* timeline) |
| 984 { | 985 { |
| 985 ASSERT(pass != VariableDefinitions); | 986 ASSERT(pass != VariableDefinitions); |
| 986 ASSERT(pass != AnimationProperties); | 987 ASSERT(pass != AnimationProperties); |
| 987 if (!target->hasActiveAnimations()) | 988 AnimationStack* animationStack = timeline->animationStack(target); |
| 989 if (!animationStack) |
| 988 return; | 990 return; |
| 991 const Vector<Animation*>& animations = animationStack->activeAnimations(targ
et); |
| 989 | 992 |
| 990 Vector<Animation*>* animations = target->activeAnimations(); | 993 for (size_t i = 0; i < animations.size(); ++i) { |
| 991 | 994 RefPtr<Animation> animation = animations.at(i); |
| 992 for (size_t i = 0; i < animations->size(); ++i) { | |
| 993 RefPtr<Animation> animation = animations->at(i); | |
| 994 const AnimationEffect::CompositableValueMap* compositableValues = animat
ion->compositableValues(); | 995 const AnimationEffect::CompositableValueMap* compositableValues = animat
ion->compositableValues(); |
| 995 for (AnimationEffect::CompositableValueMap::const_iterator iter = compos
itableValues->begin(); iter != compositableValues->end(); ++iter) { | 996 for (AnimationEffect::CompositableValueMap::const_iterator iter = compos
itableValues->begin(); iter != compositableValues->end(); ++iter) { |
| 996 CSSPropertyID property = iter->key; | 997 CSSPropertyID property = iter->key; |
| 997 if (!isPropertyForPass<pass>(property)) | 998 if (!isPropertyForPass<pass>(property)) |
| 998 continue; | 999 continue; |
| 999 RefPtr<CSSValue> value = iter->value->compositeOnto(AnimatableValue:
:neutralValue())->toCSSValue(); | 1000 RefPtr<CSSValue> value = iter->value->compositeOnto(AnimatableValue:
:neutralValue())->toCSSValue(); |
| 1000 if (pass == HighPriorityProperties && property == CSSPropertyLineHei
ght) | 1001 if (pass == HighPriorityProperties && property == CSSPropertyLineHei
ght) |
| 1001 state.setLineHeightValue(value.get()); | 1002 state.setLineHeightValue(value.get()); |
| 1002 else | 1003 else |
| 1003 applyProperty(state, property, value.get()); | 1004 applyProperty(state, property, value.get()); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1227 // FIXME: animations should be triggered here | 1228 // FIXME: animations should be triggered here |
| 1228 | 1229 |
| 1229 // Now we have all of the matched rules in the appropriate order. Walk the r
ules and apply | 1230 // Now we have all of the matched rules in the appropriate order. Walk the r
ules and apply |
| 1230 // high-priority properties first, i.e., those properties that other propert
ies depend on. | 1231 // high-priority properties first, i.e., those properties that other propert
ies depend on. |
| 1231 // The order is (1) high-priority not important, (2) high-priority important
, (3) normal not important | 1232 // The order is (1) high-priority not important, (2) high-priority important
, (3) normal not important |
| 1232 // and (4) normal important. | 1233 // and (4) normal important. |
| 1233 state.setLineHeightValue(0); | 1234 state.setLineHeightValue(0); |
| 1234 applyMatchedProperties<HighPriorityProperties>(state, matchResult, false, 0,
matchResult.matchedProperties.size() - 1, applyInheritedOnly); | 1235 applyMatchedProperties<HighPriorityProperties>(state, matchResult, false, 0,
matchResult.matchedProperties.size() - 1, applyInheritedOnly); |
| 1235 // Animation contributions are processed here because CSS Animations are ove
rridable by user !important rules. | 1236 // Animation contributions are processed here because CSS Animations are ove
rridable by user !important rules. |
| 1236 if (RuntimeEnabledFeatures::webAnimationsEnabled()) | 1237 if (RuntimeEnabledFeatures::webAnimationsEnabled()) |
| 1237 applyAnimatedProperties<HighPriorityProperties>(state, element); | 1238 applyAnimatedProperties<HighPriorityProperties>(state, element, element-
>document()->timeline()); |
| 1238 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat
chResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherit
edOnly); | 1239 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat
chResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherit
edOnly); |
| 1239 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat
chResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOn
ly); | 1240 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat
chResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOn
ly); |
| 1240 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat
chResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); | 1241 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat
chResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); |
| 1241 | 1242 |
| 1242 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->effecti
veZoom() != state.style()->effectiveZoom()) { | 1243 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->effecti
veZoom() != state.style()->effectiveZoom()) { |
| 1243 state.fontBuilder().setFontDirty(true); | 1244 state.fontBuilder().setFontDirty(true); |
| 1244 applyInheritedOnly = false; | 1245 applyInheritedOnly = false; |
| 1245 } | 1246 } |
| 1246 | 1247 |
| 1247 // If our font got dirtied, go ahead and update it now. | 1248 // If our font got dirtied, go ahead and update it now. |
| 1248 updateFont(state); | 1249 updateFont(state); |
| 1249 | 1250 |
| 1250 // Line-height is set when we are sure we decided on the font-size. | 1251 // Line-height is set when we are sure we decided on the font-size. |
| 1251 if (state.lineHeightValue()) | 1252 if (state.lineHeightValue()) |
| 1252 applyProperty(state, CSSPropertyLineHeight, state.lineHeightValue()); | 1253 applyProperty(state, CSSPropertyLineHeight, state.lineHeightValue()); |
| 1253 | 1254 |
| 1254 // Many properties depend on the font. If it changes we just apply all prope
rties. | 1255 // Many properties depend on the font. If it changes we just apply all prope
rties. |
| 1255 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->fontDes
cription() != state.style()->fontDescription()) | 1256 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->fontDes
cription() != state.style()->fontDescription()) |
| 1256 applyInheritedOnly = false; | 1257 applyInheritedOnly = false; |
| 1257 | 1258 |
| 1258 // Now do the normal priority UA properties. | 1259 // Now do the normal priority UA properties. |
| 1259 applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, mat
chResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); | 1260 applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, mat
chResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); |
| 1260 | 1261 |
| 1261 // Cache the UA properties to pass them to RenderTheme in adjustRenderStyle. | 1262 // Cache the UA properties to pass them to RenderTheme in adjustRenderStyle. |
| 1262 state.cacheUserAgentBorderAndBackground(); | 1263 state.cacheUserAgentBorderAndBackground(); |
| 1263 | 1264 |
| 1264 // Now do the author and user normal priority properties and all the !import
ant properties. | 1265 // Now do the author and user normal priority properties and all the !import
ant properties. |
| 1265 applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, mat
chResult.ranges.lastUARule + 1, matchResult.matchedProperties.size() - 1, applyI
nheritedOnly); | 1266 applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, mat
chResult.ranges.lastUARule + 1, matchResult.matchedProperties.size() - 1, applyI
nheritedOnly); |
| 1266 if (RuntimeEnabledFeatures::webAnimationsEnabled()) | 1267 if (RuntimeEnabledFeatures::webAnimationsEnabled()) |
| 1267 applyAnimatedProperties<LowPriorityProperties>(state, element); | 1268 applyAnimatedProperties<LowPriorityProperties>(state, element, element->
document()->timeline()); |
| 1268 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
hResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherite
dOnly); | 1269 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
hResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherite
dOnly); |
| 1269 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
hResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnl
y); | 1270 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
hResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnl
y); |
| 1270 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
hResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); | 1271 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
hResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); |
| 1271 | 1272 |
| 1272 // Start loading resources referenced by this style. | 1273 // Start loading resources referenced by this style. |
| 1273 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); | 1274 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); |
| 1274 | 1275 |
| 1275 ASSERT(!state.fontBuilder().fontDirty()); | 1276 ASSERT(!state.fontBuilder().fontDirty()); |
| 1276 | 1277 |
| 1277 if (cachedMatchedProperties || !cacheHash) | 1278 if (cachedMatchedProperties || !cacheHash) |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1443 fprintf(stderr, "This recalc style:\n"); | 1444 fprintf(stderr, "This recalc style:\n"); |
| 1444 printStyleStats(m_searches, m_elementsEligibleForSharing, m_stylesShared, m_
searchFoundSiblingForSharing, m_searchesMissedSharing); | 1445 printStyleStats(m_searches, m_elementsEligibleForSharing, m_stylesShared, m_
searchFoundSiblingForSharing, m_searchesMissedSharing); |
| 1445 | 1446 |
| 1446 fprintf(stderr, "Total:\n"); | 1447 fprintf(stderr, "Total:\n"); |
| 1447 printStyleStats(m_totalSearches, m_totalElementsEligibleForSharing, m_totalS
tylesShared, m_totalSearchFoundSiblingForSharing, m_totalSearchesMissedSharing); | 1448 printStyleStats(m_totalSearches, m_totalElementsEligibleForSharing, m_totalS
tylesShared, m_totalSearchFoundSiblingForSharing, m_totalSearchesMissedSharing); |
| 1448 fprintf(stderr, "-----------------------------------------------------------
---------------------\n"); | 1449 fprintf(stderr, "-----------------------------------------------------------
---------------------\n"); |
| 1449 } | 1450 } |
| 1450 #endif | 1451 #endif |
| 1451 | 1452 |
| 1452 } // namespace WebCore | 1453 } // namespace WebCore |
| OLD | NEW |