Chromium Code Reviews| 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()) { | |
|
Steve Block
2013/11/14 03:31:18
Early-out?
Timothy Loh
2013/11/14 03:54:01
Done.
| |
| 1061 const AnimationEffect::CompositableValueMap& compositableValuesForAnimat ions = state.animationUpdate()->compositableValuesForAnimations(); | |
| 1062 const AnimationEffect::CompositableValueMap& compositableValuesForTransi tions = state.animationUpdate()->compositableValuesForTransitions(); | |
| 1063 applyAnimatedProperties<HighPriorityProperties>(state, compositableValue sForAnimations); | |
| 1064 applyAnimatedProperties<HighPriorityProperties>(state, compositableValue sForTransitions); | |
| 1065 applyAnimatedProperties<LowPriorityProperties>(state, compositableValues ForAnimations); | |
| 1066 applyAnimatedProperties<LowPriorityProperties>(state, compositableValues ForTransitions); | |
| 1067 } | |
| 1068 } | |
| 1069 | |
| 1056 template <StyleResolver::StyleApplicationPass pass> | 1070 template <StyleResolver::StyleApplicationPass pass> |
| 1057 bool StyleResolver::applyAnimatedProperties(StyleResolverState& state, const Ani mationEffect::CompositableValueMap& compositableValues) | 1071 bool 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; | 1076 bool didApply = false; |
| 1063 | 1077 |
| 1064 for (AnimationEffect::CompositableValueMap::const_iterator iter = compositab leValues.begin(); iter != compositableValues.end(); ++iter) { | 1078 for (AnimationEffect::CompositableValueMap::const_iterator iter = compositab leValues.begin(); iter != compositableValues.end(); ++iter) { |
| 1065 CSSPropertyID property = iter->key; | 1079 CSSPropertyID property = iter->key; |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1252 if (state.parentStyle()->inheritedDataShared(cachedMatchedProperties->pa rentRenderStyle.get()) && !isAtShadowBoundary(element)) { | 1266 if (state.parentStyle()->inheritedDataShared(cachedMatchedProperties->pa rentRenderStyle.get()) && !isAtShadowBoundary(element)) { |
| 1253 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheInheritedHi t); | 1267 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheInheritedHi t); |
| 1254 | 1268 |
| 1255 EInsideLink linkStatus = state.style()->insideLink(); | 1269 EInsideLink linkStatus = state.style()->insideLink(); |
| 1256 // If the cache item parent style has identical inherited properties to the current parent style then the | 1270 // 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. | 1271 // 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( )); | 1272 state.style()->inheritFrom(cachedMatchedProperties->renderStyle.get( )); |
| 1259 | 1273 |
| 1260 // Unfortunately the link status is treated like an inherited proper ty. We need to explicitly restore it. | 1274 // Unfortunately the link status is treated like an inherited proper ty. We need to explicitly restore it. |
| 1261 state.style()->setInsideLink(linkStatus); | 1275 state.style()->setInsideLink(linkStatus); |
| 1276 | |
| 1277 if (RuntimeEnabledFeatures::webAnimationsCSSEnabled() | |
| 1278 && (animatingElement->hasActiveAnimations() | |
| 1279 || (state.style()->transitions() && !state.style()->transiti ons()->isEmpty()) | |
| 1280 || (state.style()->animations() && !state.style()->animation s()->isEmpty()))) | |
| 1281 applyAnimatedProperties(state, animatingElement); | |
| 1262 return; | 1282 return; |
| 1263 } | 1283 } |
| 1264 applyInheritedOnly = true; | 1284 applyInheritedOnly = true; |
| 1265 } | 1285 } |
| 1266 | 1286 |
| 1267 // First apply all variable definitions, as they may be used during applicat ion of later properties. | 1287 // 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); | 1288 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); | 1289 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) ; | 1290 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); | 1291 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 | 1333 |
| 1314 // Cache the UA properties to pass them to RenderTheme in adjustRenderStyle. | 1334 // Cache the UA properties to pass them to RenderTheme in adjustRenderStyle. |
| 1315 state.cacheUserAgentBorderAndBackground(); | 1335 state.cacheUserAgentBorderAndBackground(); |
| 1316 | 1336 |
| 1317 // Now do the author and user normal priority properties and all the !import ant properties. | 1337 // 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); | 1338 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); | 1339 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); | 1340 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); | 1341 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc hResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); |
| 1322 | 1342 |
| 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. | 1343 // Start loading resources referenced by this style. |
| 1350 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle Resources()); | 1344 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle Resources()); |
| 1351 | 1345 |
| 1346 if (!cachedMatchedProperties && cacheHash && MatchedPropertiesCache::isCache able(element, state.style(), state.parentStyle())) { | |
| 1347 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheAdded); | |
| 1348 m_matchedPropertiesCache.add(state.style(), state.parentStyle(), cacheHa sh, matchResult); | |
| 1349 } | |
| 1350 | |
| 1351 applyAnimatedProperties(state, animatingElement); | |
| 1352 | |
| 1352 ASSERT(!state.fontBuilder().fontDirty()); | 1353 ASSERT(!state.fontBuilder().fontDirty()); |
|
Steve Block
2013/11/14 03:31:18
Did you intend to move this assert below the cachi
Timothy Loh
2013/11/14 03:54:01
Yep; in particular below applying animated propert
Steve Block
2013/11/14 04:07:33
OK, makes sense
| |
| 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 } | 1354 } |
| 1361 | 1355 |
| 1362 CSSPropertyValue::CSSPropertyValue(CSSPropertyID id, const StylePropertySet& pro pertySet) | 1356 CSSPropertyValue::CSSPropertyValue(CSSPropertyID id, const StylePropertySet& pro pertySet) |
| 1363 : property(id), value(propertySet.getPropertyCSSValue(id).get()) | 1357 : property(id), value(propertySet.getPropertyCSSValue(id).get()) |
| 1364 { } | 1358 { } |
| 1365 | 1359 |
| 1366 void StyleResolver::enableStats(StatsReportType reportType) | 1360 void StyleResolver::enableStats(StatsReportType reportType) |
| 1367 { | 1361 { |
| 1368 if (m_styleResolverStats) | 1362 if (m_styleResolverStats) |
| 1369 return; | 1363 return; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1421 { | 1415 { |
| 1422 unsigned s = m_viewportDependentMediaQueryResults.size(); | 1416 unsigned s = m_viewportDependentMediaQueryResults.size(); |
| 1423 for (unsigned i = 0; i < s; i++) { | 1417 for (unsigned i = 0; i < s; i++) { |
| 1424 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio n) != m_viewportDependentMediaQueryResults[i]->m_result) | 1418 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio n) != m_viewportDependentMediaQueryResults[i]->m_result) |
| 1425 return true; | 1419 return true; |
| 1426 } | 1420 } |
| 1427 return false; | 1421 return false; |
| 1428 } | 1422 } |
| 1429 | 1423 |
| 1430 } // namespace WebCore | 1424 } // namespace WebCore |
| OLD | NEW |