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