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 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 if (state.element()->isStyledElement()) { | 587 if (state.element()->isStyledElement()) { |
588 if (state.element()->inlineStyle()) { | 588 if (state.element()->inlineStyle()) { |
589 // Inline style is immutable as long as there is no CSSOM wrapper. | 589 // Inline style is immutable as long as there is no CSSOM wrapper. |
590 bool isInlineStyleCacheable = !state.element()->inlineStyle()->isMut
able(); | 590 bool isInlineStyleCacheable = !state.element()->inlineStyle()->isMut
able(); |
591 collector.addElementStyleProperties(state.element()->inlineStyle(),
isInlineStyleCacheable); | 591 collector.addElementStyleProperties(state.element()->inlineStyle(),
isInlineStyleCacheable); |
592 } | 592 } |
593 | 593 |
594 // Now check SMIL animation override style. | 594 // Now check SMIL animation override style. |
595 if (includeSMILProperties && state.element()->isSVGElement()) | 595 if (includeSMILProperties && state.element()->isSVGElement()) |
596 collector.addElementStyleProperties(toSVGElement(state.element())->a
nimatedSMILStyleProperties(), false /* isCacheable */); | 596 collector.addElementStyleProperties(toSVGElement(state.element())->a
nimatedSMILStyleProperties(), false /* isCacheable */); |
597 | |
598 if (state.element()->hasActiveAnimations()) | |
599 collector.matchedResult().isCacheable = false; | |
600 } | 597 } |
601 } | 598 } |
602 | 599 |
603 PassRefPtr<RenderStyle> StyleResolver::styleForDocument(Document& document, CSSF
ontSelector* fontSelector) | 600 PassRefPtr<RenderStyle> StyleResolver::styleForDocument(Document& document, CSSF
ontSelector* fontSelector) |
604 { | 601 { |
605 const Frame* frame = document.frame(); | 602 const Frame* frame = document.frame(); |
606 | 603 |
607 // HTML5 states that seamless iframes should replace default CSS values | 604 // HTML5 states that seamless iframes should replace default CSS values |
608 // with values inherited from the containing iframe element. However, | 605 // with values inherited from the containing iframe element. However, |
609 // some values (such as the case of designMode = "on") still need to | 606 // some values (such as the case of designMode = "on") still need to |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 | 1043 |
1047 if (rulesToInclude & AuthorCSSRules) { | 1044 if (rulesToInclude & AuthorCSSRules) { |
1048 collector.setSameOriginOnly(!(rulesToInclude & CrossOriginCSSRules)); | 1045 collector.setSameOriginOnly(!(rulesToInclude & CrossOriginCSSRules)); |
1049 matchAuthorRules(element, collector, rulesToInclude & EmptyCSSRules); | 1046 matchAuthorRules(element, collector, rulesToInclude & EmptyCSSRules); |
1050 } | 1047 } |
1051 } | 1048 } |
1052 | 1049 |
1053 // -----------------------------------------------------------------------------
-------- | 1050 // -----------------------------------------------------------------------------
-------- |
1054 // this is mostly boring stuff on how to apply a certain rule to the renderstyle
... | 1051 // this is mostly boring stuff on how to apply a certain rule to the renderstyle
... |
1055 | 1052 |
| 1053 void StyleResolver::applyAnimatedProperties(StyleResolverState& state, Element*
animatingElement) |
| 1054 { |
| 1055 // animatingElement may be null, for example if we're calculating the |
| 1056 // style for a potential pseudo element that has yet to be created. |
| 1057 if (!RuntimeEnabledFeatures::webAnimationsCSSEnabled() || !animatingElement) |
| 1058 return; |
| 1059 state.setAnimationUpdate(CSSAnimations::calculateUpdate(animatingElement, *s
tate.style(), this)); |
| 1060 if (!state.animationUpdate()) |
| 1061 return; |
| 1062 const AnimationEffect::CompositableValueMap& compositableValuesForAnimations
= state.animationUpdate()->compositableValuesForAnimations(); |
| 1063 const AnimationEffect::CompositableValueMap& compositableValuesForTransition
s = state.animationUpdate()->compositableValuesForTransitions(); |
| 1064 applyAnimatedProperties<HighPriorityProperties>(state, compositableValuesFor
Animations); |
| 1065 applyAnimatedProperties<HighPriorityProperties>(state, compositableValuesFor
Transitions); |
| 1066 applyAnimatedProperties<LowPriorityProperties>(state, compositableValuesForA
nimations); |
| 1067 applyAnimatedProperties<LowPriorityProperties>(state, compositableValuesForT
ransitions); |
| 1068 } |
| 1069 |
1056 template <StyleResolver::StyleApplicationPass pass> | 1070 template <StyleResolver::StyleApplicationPass pass> |
1057 bool StyleResolver::applyAnimatedProperties(StyleResolverState& state, const Ani
mationEffect::CompositableValueMap& compositableValues) | 1071 void StyleResolver::applyAnimatedProperties(StyleResolverState& state, const Ani
mationEffect::CompositableValueMap& compositableValues) |
1058 { | 1072 { |
1059 ASSERT(RuntimeEnabledFeatures::webAnimationsCSSEnabled()); | 1073 ASSERT(RuntimeEnabledFeatures::webAnimationsCSSEnabled()); |
1060 ASSERT(pass != VariableDefinitions); | 1074 ASSERT(pass != VariableDefinitions); |
1061 ASSERT(pass != AnimationProperties); | 1075 ASSERT(pass != AnimationProperties); |
1062 bool didApply = false; | |
1063 | 1076 |
1064 for (AnimationEffect::CompositableValueMap::const_iterator iter = compositab
leValues.begin(); iter != compositableValues.end(); ++iter) { | 1077 for (AnimationEffect::CompositableValueMap::const_iterator iter = compositab
leValues.begin(); iter != compositableValues.end(); ++iter) { |
1065 CSSPropertyID property = iter->key; | 1078 CSSPropertyID property = iter->key; |
1066 if (!isPropertyForPass<pass>(property)) | 1079 if (!isPropertyForPass<pass>(property)) |
1067 continue; | 1080 continue; |
1068 ASSERT_WITH_MESSAGE(!iter->value->dependsOnUnderlyingValue(), "Web Anima
tions not yet implemented: An interface for compositing onto the underlying valu
e."); | 1081 ASSERT_WITH_MESSAGE(!iter->value->dependsOnUnderlyingValue(), "Web Anima
tions not yet implemented: An interface for compositing onto the underlying valu
e."); |
1069 RefPtr<AnimatableValue> animatableValue = iter->value->compositeOnto(0); | 1082 RefPtr<AnimatableValue> animatableValue = iter->value->compositeOnto(0); |
1070 AnimatedStyleBuilder::applyProperty(property, state, animatableValue.get
()); | 1083 AnimatedStyleBuilder::applyProperty(property, state, animatableValue.get
()); |
1071 didApply = true; | |
1072 } | 1084 } |
1073 return didApply; | |
1074 } | 1085 } |
1075 | 1086 |
1076 // http://dev.w3.org/csswg/css3-regions/#the-at-region-style-rule | 1087 // http://dev.w3.org/csswg/css3-regions/#the-at-region-style-rule |
1077 // FIXME: add incremental support for other region styling properties. | 1088 // FIXME: add incremental support for other region styling properties. |
1078 static inline bool isValidRegionStyleProperty(CSSPropertyID id) | 1089 static inline bool isValidRegionStyleProperty(CSSPropertyID id) |
1079 { | 1090 { |
1080 switch (id) { | 1091 switch (id) { |
1081 case CSSPropertyBackgroundColor: | 1092 case CSSPropertyBackgroundColor: |
1082 case CSSPropertyColor: | 1093 case CSSPropertyColor: |
1083 return true; | 1094 return true; |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 if (state.parentStyle()->inheritedDataShared(cachedMatchedProperties->pa
rentRenderStyle.get()) && !isAtShadowBoundary(element)) { | 1263 if (state.parentStyle()->inheritedDataShared(cachedMatchedProperties->pa
rentRenderStyle.get()) && !isAtShadowBoundary(element)) { |
1253 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheInheritedHi
t); | 1264 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheInheritedHi
t); |
1254 | 1265 |
1255 EInsideLink linkStatus = state.style()->insideLink(); | 1266 EInsideLink linkStatus = state.style()->insideLink(); |
1256 // If the cache item parent style has identical inherited properties
to the current parent style then the | 1267 // If the cache item parent style has identical inherited properties
to the current parent style then the |
1257 // resulting style will be identical too. We copy the inherited prop
erties over from the cache and are done. | 1268 // resulting style will be identical too. We copy the inherited prop
erties over from the cache and are done. |
1258 state.style()->inheritFrom(cachedMatchedProperties->renderStyle.get(
)); | 1269 state.style()->inheritFrom(cachedMatchedProperties->renderStyle.get(
)); |
1259 | 1270 |
1260 // Unfortunately the link status is treated like an inherited proper
ty. We need to explicitly restore it. | 1271 // Unfortunately the link status is treated like an inherited proper
ty. We need to explicitly restore it. |
1261 state.style()->setInsideLink(linkStatus); | 1272 state.style()->setInsideLink(linkStatus); |
| 1273 |
| 1274 if (RuntimeEnabledFeatures::webAnimationsCSSEnabled() |
| 1275 && (animatingElement->hasActiveAnimations() |
| 1276 || (state.style()->transitions() && !state.style()->transiti
ons()->isEmpty()) |
| 1277 || (state.style()->animations() && !state.style()->animation
s()->isEmpty()))) |
| 1278 applyAnimatedProperties(state, animatingElement); |
1262 return; | 1279 return; |
1263 } | 1280 } |
1264 applyInheritedOnly = true; | 1281 applyInheritedOnly = true; |
1265 } | 1282 } |
1266 | 1283 |
1267 // First apply all variable definitions, as they may be used during applicat
ion of later properties. | 1284 // First apply all variable definitions, as they may be used during applicat
ion of later properties. |
1268 applyMatchedProperties<VariableDefinitions>(state, matchResult, false, 0, ma
tchResult.matchedProperties.size() - 1, applyInheritedOnly); | 1285 applyMatchedProperties<VariableDefinitions>(state, matchResult, false, 0, ma
tchResult.matchedProperties.size() - 1, applyInheritedOnly); |
1269 applyMatchedProperties<VariableDefinitions>(state, matchResult, true, matchR
esult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedO
nly); | 1286 applyMatchedProperties<VariableDefinitions>(state, matchResult, true, matchR
esult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedO
nly); |
1270 applyMatchedProperties<VariableDefinitions>(state, matchResult, true, matchR
esult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly)
; | 1287 applyMatchedProperties<VariableDefinitions>(state, matchResult, true, matchR
esult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly)
; |
1271 applyMatchedProperties<VariableDefinitions>(state, matchResult, true, matchR
esult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); | 1288 applyMatchedProperties<VariableDefinitions>(state, matchResult, true, matchR
esult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1313 | 1330 |
1314 // Cache the UA properties to pass them to RenderTheme in adjustRenderStyle. | 1331 // Cache the UA properties to pass them to RenderTheme in adjustRenderStyle. |
1315 state.cacheUserAgentBorderAndBackground(); | 1332 state.cacheUserAgentBorderAndBackground(); |
1316 | 1333 |
1317 // Now do the author and user normal priority properties and all the !import
ant properties. | 1334 // Now do the author and user normal priority properties and all the !import
ant properties. |
1318 applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, mat
chResult.ranges.lastUARule + 1, matchResult.matchedProperties.size() - 1, applyI
nheritedOnly); | 1335 applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, mat
chResult.ranges.lastUARule + 1, matchResult.matchedProperties.size() - 1, applyI
nheritedOnly); |
1319 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
hResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherite
dOnly); | 1336 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
hResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherite
dOnly); |
1320 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
hResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnl
y); | 1337 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
hResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnl
y); |
1321 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
hResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); | 1338 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
hResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); |
1322 | 1339 |
1323 // animatingElement may be null, for example if we're calculating the | |
1324 // style for a potential pseudo element that has yet to be created. | |
1325 if (RuntimeEnabledFeatures::webAnimationsEnabled() && animatingElement) { | |
1326 state.setAnimationUpdate(CSSAnimations::calculateUpdate(animatingElement
, *state.style(), this)); | |
1327 if (state.animationUpdate()) { | |
1328 ASSERT(!applyInheritedOnly); | |
1329 const AnimationEffect::CompositableValueMap& compositableValuesForAn
imations = state.animationUpdate()->compositableValuesForAnimations(); | |
1330 const AnimationEffect::CompositableValueMap& compositableValuesForTr
ansitions = state.animationUpdate()->compositableValuesForTransitions(); | |
1331 // Apply animated properties, then reapply any rules marked importan
t. | |
1332 if (applyAnimatedProperties<HighPriorityProperties>(state, composita
bleValuesForAnimations)) { | |
1333 bool important = true; | |
1334 applyMatchedProperties<HighPriorityProperties>(state, matchResul
t, important, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorR
ule, applyInheritedOnly); | |
1335 applyMatchedProperties<HighPriorityProperties>(state, matchResul
t, important, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule,
applyInheritedOnly); | |
1336 applyMatchedProperties<HighPriorityProperties>(state, matchResul
t, important, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, app
lyInheritedOnly); | |
1337 } | |
1338 applyAnimatedProperties<HighPriorityProperties>(state, compositableV
aluesForTransitions); | |
1339 if (applyAnimatedProperties<LowPriorityProperties>(state, compositab
leValuesForAnimations)) { | |
1340 bool important = true; | |
1341 applyMatchedProperties<LowPriorityProperties>(state, matchResult
, important, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRu
le, applyInheritedOnly); | |
1342 applyMatchedProperties<LowPriorityProperties>(state, matchResult
, important, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule,
applyInheritedOnly); | |
1343 applyMatchedProperties<LowPriorityProperties>(state, matchResult
, important, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, appl
yInheritedOnly); | |
1344 } | |
1345 applyAnimatedProperties<LowPriorityProperties>(state, compositableVa
luesForTransitions); | |
1346 } | |
1347 } | |
1348 | |
1349 // Start loading resources referenced by this style. | 1340 // Start loading resources referenced by this style. |
1350 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); | 1341 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); |
1351 | 1342 |
| 1343 if (!cachedMatchedProperties && cacheHash && MatchedPropertiesCache::isCache
able(element, state.style(), state.parentStyle())) { |
| 1344 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheAdded); |
| 1345 m_matchedPropertiesCache.add(state.style(), state.parentStyle(), cacheHa
sh, matchResult); |
| 1346 } |
| 1347 |
| 1348 applyAnimatedProperties(state, animatingElement); |
| 1349 |
1352 ASSERT(!state.fontBuilder().fontDirty()); | 1350 ASSERT(!state.fontBuilder().fontDirty()); |
1353 | |
1354 if (cachedMatchedProperties || !cacheHash) | |
1355 return; | |
1356 if (!MatchedPropertiesCache::isCacheable(element, state.style(), state.paren
tStyle())) | |
1357 return; | |
1358 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheAdded); | |
1359 m_matchedPropertiesCache.add(state.style(), state.parentStyle(), cacheHash,
matchResult); | |
1360 } | 1351 } |
1361 | 1352 |
1362 CSSPropertyValue::CSSPropertyValue(CSSPropertyID id, const StylePropertySet& pro
pertySet) | 1353 CSSPropertyValue::CSSPropertyValue(CSSPropertyID id, const StylePropertySet& pro
pertySet) |
1363 : property(id), value(propertySet.getPropertyCSSValue(id).get()) | 1354 : property(id), value(propertySet.getPropertyCSSValue(id).get()) |
1364 { } | 1355 { } |
1365 | 1356 |
1366 void StyleResolver::enableStats(StatsReportType reportType) | 1357 void StyleResolver::enableStats(StatsReportType reportType) |
1367 { | 1358 { |
1368 if (m_styleResolverStats) | 1359 if (m_styleResolverStats) |
1369 return; | 1360 return; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1421 { | 1412 { |
1422 unsigned s = m_viewportDependentMediaQueryResults.size(); | 1413 unsigned s = m_viewportDependentMediaQueryResults.size(); |
1423 for (unsigned i = 0; i < s; i++) { | 1414 for (unsigned i = 0; i < s; i++) { |
1424 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio
n) != m_viewportDependentMediaQueryResults[i]->m_result) | 1415 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio
n) != m_viewportDependentMediaQueryResults[i]->m_result) |
1425 return true; | 1416 return true; |
1426 } | 1417 } |
1427 return false; | 1418 return false; |
1428 } | 1419 } |
1429 | 1420 |
1430 } // namespace WebCore | 1421 } // namespace WebCore |
OLD | NEW |