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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 #include "core/css/CSSCalculationValue.h" | 42 #include "core/css/CSSCalculationValue.h" |
| 43 #include "core/css/CSSDefaultStyleSheets.h" | 43 #include "core/css/CSSDefaultStyleSheets.h" |
| 44 #include "core/css/CSSFontSelector.h" | 44 #include "core/css/CSSFontSelector.h" |
| 45 #include "core/css/CSSKeyframeRule.h" | 45 #include "core/css/CSSKeyframeRule.h" |
| 46 #include "core/css/CSSKeyframesRule.h" | 46 #include "core/css/CSSKeyframesRule.h" |
| 47 #include "core/css/CSSReflectValue.h" | 47 #include "core/css/CSSReflectValue.h" |
| 48 #include "core/css/CSSRuleList.h" | 48 #include "core/css/CSSRuleList.h" |
| 49 #include "core/css/CSSSelector.h" | 49 #include "core/css/CSSSelector.h" |
| 50 #include "core/css/CSSStyleRule.h" | 50 #include "core/css/CSSStyleRule.h" |
| 51 #include "core/css/CSSValueList.h" | 51 #include "core/css/CSSValueList.h" |
| 52 #include "core/css/CSSValuePool.h" | |
| 52 #include "core/css/ElementRuleCollector.h" | 53 #include "core/css/ElementRuleCollector.h" |
| 53 #include "core/css/FontFace.h" | 54 #include "core/css/FontFace.h" |
| 54 #include "core/css/MediaQueryEvaluator.h" | 55 #include "core/css/MediaQueryEvaluator.h" |
| 55 #include "core/css/PageRuleCollector.h" | 56 #include "core/css/PageRuleCollector.h" |
| 56 #include "core/css/StylePropertySet.h" | 57 #include "core/css/StylePropertySet.h" |
| 57 #include "core/css/StyleRuleImport.h" | 58 #include "core/css/StyleRuleImport.h" |
| 58 #include "core/css/StyleSheetContents.h" | 59 #include "core/css/StyleSheetContents.h" |
| 59 #include "core/css/parser/BisonCSSParser.h" | 60 #include "core/css/parser/BisonCSSParser.h" |
| 60 #include "core/css/resolver/AnimatedStyleBuilder.h" | 61 #include "core/css/resolver/AnimatedStyleBuilder.h" |
| 61 #include "core/css/resolver/MatchResult.h" | 62 #include "core/css/resolver/MatchResult.h" |
| (...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1223 // Properties that we currently support outside of spec. | 1224 // Properties that we currently support outside of spec. |
| 1224 case CSSPropertyWebkitLineBoxContain: | 1225 case CSSPropertyWebkitLineBoxContain: |
| 1225 case CSSPropertyVisibility: | 1226 case CSSPropertyVisibility: |
| 1226 return true; | 1227 return true; |
| 1227 | 1228 |
| 1228 default: | 1229 default: |
| 1229 return false; | 1230 return false; |
| 1230 } | 1231 } |
| 1231 } | 1232 } |
| 1232 | 1233 |
| 1234 // This method returns the first CSSPropertyId of properties which generate | |
| 1235 // animations. All animation properties are obtained by using | |
| 1236 // firstCSSPropertyId<AnimationProperties> and | |
| 1237 // lastCSSPropertyId<AnimationProperties>. | |
| 1238 // c.f. //src/third_party/WebKit/Source/core/css/CSSPropertyNames.in. | |
| 1239 template<> CSSPropertyID StyleResolver::firstCSSPropertyId<StyleResolver::Animat ionProperties>() | |
|
dglazkov
2014/06/17 15:13:14
Food for thought (won't block your work on this):
tasak
2014/06/18 05:16:31
I see. I added FIXME. After finishing "all", I wou
| |
| 1240 { | |
| 1241 COMPILE_ASSERT(firstCSSProperty == CSSPropertyDisplay, CSS_first_animation_p roperty_should_be_first_property); | |
| 1242 return CSSPropertyDisplay; | |
| 1243 } | |
| 1244 | |
| 1245 // This method returns the first CSSPropertyId of properties which generate | |
| 1246 // animations. | |
| 1247 template<> CSSPropertyID StyleResolver::lastCSSPropertyId<StyleResolver::Animati onProperties>() | |
| 1248 { | |
| 1249 return CSSPropertyTransitionTimingFunction; | |
|
dglazkov
2014/06/17 15:13:14
That handy COMPILE_ASSERT in the firstCSSPropertyI
tasak
2014/06/18 05:16:31
Done.
| |
| 1250 } | |
| 1251 | |
| 1252 // This method returns the first CSSPropertyId of high priority properties. | |
| 1253 // Other properties can depend on high priority properties. For example, | |
| 1254 // border-color property with currentColor value depends on color property. | |
| 1255 // All high priority properties are obtained by using | |
| 1256 // firstCSSPropertyId<HighPriorityProperties> and | |
| 1257 // lastCSSPropertyId<HighPriorityProperties>. | |
| 1258 template<> CSSPropertyID StyleResolver::firstCSSPropertyId<StyleResolver::HighPr iorityProperties>() | |
| 1259 { | |
| 1260 COMPILE_ASSERT(CSSPropertyTransitionTimingFunction + 1 == CSSPropertyColor, CSS_color_is_first_high_priority_property); | |
| 1261 return CSSPropertyColor; | |
| 1262 } | |
| 1263 | |
| 1264 // This method returns the last CSSPropertyId of high priority properties. | |
| 1265 template<> CSSPropertyID StyleResolver::lastCSSPropertyId<StyleResolver::HighPri orityProperties>() | |
| 1266 { | |
| 1267 COMPILE_ASSERT(CSSPropertyLineHeight == CSSPropertyColor + 17, CSS_line_heig ht_is_end_of_high_prioity_property_range); | |
| 1268 COMPILE_ASSERT(CSSPropertyZoom == CSSPropertyLineHeight - 1, CSS_zoom_is_bef ore_line_height); | |
| 1269 return CSSPropertyLineHeight; | |
| 1270 } | |
| 1271 | |
| 1272 // This method returns the first CSSPropertyId of remaining properties, | |
| 1273 // i.e. low priority properties. No properties depend on low priority | |
| 1274 // properties. So we don't need to resolve such properties quickly. | |
| 1275 // All low priority properties are obtained by using | |
| 1276 // firstCSSPropertyId<LowPriorityProperties> and | |
| 1277 // lastCSSPropertyId<LowPriorityProperties>. | |
| 1278 template<> CSSPropertyID StyleResolver::firstCSSPropertyId<StyleResolver::LowPri orityProperties>() | |
| 1279 { | |
| 1280 COMPILE_ASSERT(CSSPropertyBackground == CSSPropertyLineHeight + 1, CSS_backg round_is_first_low_priority_property); | |
| 1281 return CSSPropertyBackground; | |
| 1282 } | |
| 1283 | |
| 1284 // This method returns the last CSSPropertyId of low priority properties. | |
| 1285 template<> CSSPropertyID StyleResolver::lastCSSPropertyId<StyleResolver::LowPrio rityProperties>() | |
| 1286 { | |
| 1287 return static_cast<CSSPropertyID>(lastCSSProperty); | |
| 1288 } | |
| 1289 | |
| 1233 template <StyleResolver::StyleApplicationPass pass> | 1290 template <StyleResolver::StyleApplicationPass pass> |
| 1234 bool StyleResolver::isPropertyForPass(CSSPropertyID property) | 1291 bool StyleResolver::isPropertyForPass(CSSPropertyID property) |
| 1235 { | 1292 { |
| 1236 const CSSPropertyID firstAnimationProperty = CSSPropertyDisplay; | 1293 return firstCSSPropertyId<pass>() <= property && property <= lastCSSProperty Id<pass>(); |
| 1237 const CSSPropertyID lastAnimationProperty = CSSPropertyTransitionTimingFunct ion; | 1294 } |
| 1238 COMPILE_ASSERT(firstCSSProperty == firstAnimationProperty, CSS_first_animati on_property_should_be_first_property); | 1295 |
| 1239 const CSSPropertyID firstHighPriorityProperty = CSSPropertyColor; | 1296 // This method expands all shorthand property to longhand properties |
| 1240 const CSSPropertyID lastHighPriorityProperty = CSSPropertyLineHeight; | 1297 // considering StyleApplicationPass, and apply each expanded longhand property. |
| 1241 COMPILE_ASSERT(lastAnimationProperty + 1 == firstHighPriorityProperty, CSS_c olor_is_first_high_priority_property); | 1298 // For example, if StyleApplicationPass is AnimationProperties, all shorthand |
| 1242 COMPILE_ASSERT(CSSPropertyLineHeight == firstHighPriorityProperty + 17, CSS_ line_height_is_end_of_high_prioity_property_range); | 1299 // is expaneded to display, -webkit-animation, -webkit-animation-delay, ..., |
| 1243 COMPILE_ASSERT(CSSPropertyZoom == lastHighPriorityProperty - 1, CSS_zoom_is_ before_line_height); | 1300 // transition-timing-function. So each property's value will be applied |
| 1244 switch (pass) { | 1301 // according to all's value (initial, inherit or unset). |
| 1245 case AnimationProperties: | 1302 template <StyleResolver::StyleApplicationPass pass> |
| 1246 return property >= firstAnimationProperty && property <= lastAnimationPr operty; | 1303 void StyleResolver::applyAllProperty(StyleResolverState& state, CSSValue* allVal ue) |
| 1247 case HighPriorityProperties: | 1304 { |
| 1248 return property >= firstHighPriorityProperty && property <= lastHighPrio rityProperty; | 1305 bool isUnsetValue = !allValue->isInitialValue() && !allValue->isInheritedVal ue(); |
| 1249 case LowPriorityProperties: | 1306 unsigned startCSSProperty = firstCSSPropertyId<pass>(); |
| 1250 return property > lastHighPriorityProperty; | 1307 unsigned endCSSProperty = lastCSSPropertyId<pass>(); |
| 1308 | |
| 1309 for (unsigned i = startCSSProperty; i <= endCSSProperty; ++i) { | |
| 1310 CSSPropertyID propertyId = static_cast<CSSPropertyID>(i); | |
| 1311 | |
| 1312 // StyleBuilder does not allow any expanded shorthands. | |
| 1313 if (isExpandedShorthandForAll(propertyId)) | |
| 1314 continue; | |
| 1315 | |
| 1316 // all shorthand spec says: | |
| 1317 // The all property is a shorthand that resets all CSS properties | |
| 1318 // except direction and unicode-bidi. | |
| 1319 // c.f. http://dev.w3.org/csswg/css-cascade/#all-shorthand | |
| 1320 // We skip applyProperty when a given property is unicode-bidi or | |
| 1321 // direction. | |
| 1322 if (!CSSProperty::isAffectedByAllProperty(propertyId)) | |
| 1323 continue; | |
| 1324 | |
| 1325 CSSValue* value; | |
| 1326 if (!isUnsetValue) { | |
| 1327 value = allValue; | |
| 1328 } else { | |
| 1329 if (CSSProperty::isInheritedProperty(propertyId)) | |
| 1330 value = cssValuePool().createInheritedValue().get(); | |
| 1331 else | |
| 1332 value = cssValuePool().createExplicitInitialValue().get(); | |
| 1333 } | |
| 1334 StyleBuilder::applyProperty(propertyId, state, value); | |
| 1251 } | 1335 } |
| 1252 ASSERT_NOT_REACHED(); | |
| 1253 return false; | |
| 1254 } | 1336 } |
| 1255 | 1337 |
| 1256 template <StyleResolver::StyleApplicationPass pass> | 1338 template <StyleResolver::StyleApplicationPass pass> |
| 1257 void StyleResolver::applyProperties(StyleResolverState& state, const StyleProper tySet* properties, StyleRule* rule, bool isImportant, bool inheritedOnly, Proper tyWhitelistType propertyWhitelistType) | 1339 void StyleResolver::applyProperties(StyleResolverState& state, const StyleProper tySet* properties, StyleRule* rule, bool isImportant, bool inheritedOnly, Proper tyWhitelistType propertyWhitelistType) |
| 1258 { | 1340 { |
| 1259 state.setCurrentRule(rule); | 1341 state.setCurrentRule(rule); |
| 1260 | 1342 |
| 1261 unsigned propertyCount = properties->propertyCount(); | 1343 unsigned propertyCount = properties->propertyCount(); |
| 1262 for (unsigned i = 0; i < propertyCount; ++i) { | 1344 for (unsigned i = 0; i < propertyCount; ++i) { |
| 1263 StylePropertySet::PropertyReference current = properties->propertyAt(i); | 1345 StylePropertySet::PropertyReference current = properties->propertyAt(i); |
| 1264 if (isImportant != current.isImportant()) | 1346 if (isImportant != current.isImportant()) |
| 1265 continue; | 1347 continue; |
| 1348 | |
| 1349 CSSPropertyID property = current.id(); | |
| 1350 if (property == CSSPropertyAll) { | |
| 1351 applyAllProperty<pass>(state, current.value()); | |
| 1352 continue; | |
| 1353 } | |
| 1354 | |
| 1266 if (inheritedOnly && !current.isInherited()) { | 1355 if (inheritedOnly && !current.isInherited()) { |
| 1267 // If the property value is explicitly inherited, we need to apply f urther non-inherited properties | 1356 // If the property value is explicitly inherited, we need to apply f urther non-inherited properties |
| 1268 // as they might override the value inherited here. For this reason we don't allow declarations with | 1357 // as they might override the value inherited here. For this reason we don't allow declarations with |
| 1269 // explicitly inherited properties to be cached. | 1358 // explicitly inherited properties to be cached. |
| 1270 ASSERT(!current.value()->isInheritedValue()); | 1359 ASSERT(!current.value()->isInheritedValue()); |
| 1271 continue; | 1360 continue; |
| 1272 } | 1361 } |
| 1273 CSSPropertyID property = current.id(); | |
| 1274 | 1362 |
| 1275 if (propertyWhitelistType == PropertyWhitelistCue && !isValidCueStylePro perty(property)) | 1363 if (propertyWhitelistType == PropertyWhitelistCue && !isValidCueStylePro perty(property)) |
| 1276 continue; | 1364 continue; |
| 1277 if (propertyWhitelistType == PropertyWhitelistFirstLetter && !isValidFir stLetterStyleProperty(property)) | 1365 if (propertyWhitelistType == PropertyWhitelistFirstLetter && !isValidFir stLetterStyleProperty(property)) |
| 1278 continue; | 1366 continue; |
| 1279 if (!isPropertyForPass<pass>(property)) | 1367 if (!isPropertyForPass<pass>(property)) |
| 1280 continue; | 1368 continue; |
| 1281 if (pass == HighPriorityProperties && property == CSSPropertyLineHeight) | 1369 if (pass == HighPriorityProperties && property == CSSPropertyLineHeight) |
| 1282 state.setLineHeightValue(current.value()); | 1370 state.setLineHeightValue(current.value()); |
| 1283 else | 1371 else |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1506 visitor->trace(m_viewportStyleResolver); | 1594 visitor->trace(m_viewportStyleResolver); |
| 1507 visitor->trace(m_features); | 1595 visitor->trace(m_features); |
| 1508 visitor->trace(m_siblingRuleSet); | 1596 visitor->trace(m_siblingRuleSet); |
| 1509 visitor->trace(m_uncommonAttributeRuleSet); | 1597 visitor->trace(m_uncommonAttributeRuleSet); |
| 1510 visitor->trace(m_watchedSelectorsRules); | 1598 visitor->trace(m_watchedSelectorsRules); |
| 1511 visitor->trace(m_treeBoundaryCrossingRules); | 1599 visitor->trace(m_treeBoundaryCrossingRules); |
| 1512 visitor->trace(m_pendingStyleSheets); | 1600 visitor->trace(m_pendingStyleSheets); |
| 1513 } | 1601 } |
| 1514 | 1602 |
| 1515 } // namespace WebCore | 1603 } // namespace WebCore |
| OLD | NEW |