| 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 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1022 if (ScopedStyleResolver* scopedResolver = element->treeScope().scopedStyleRe
solver()) | 1022 if (ScopedStyleResolver* scopedResolver = element->treeScope().scopedStyleRe
solver()) |
| 1023 resolvers.append(scopedResolver); | 1023 resolvers.append(scopedResolver); |
| 1024 | 1024 |
| 1025 for (size_t i = 0; i < resolvers.size(); ++i) { | 1025 for (size_t i = 0; i < resolvers.size(); ++i) { |
| 1026 if (const StyleRuleKeyframes* keyframesRule = resolvers[i]->keyframeStyl
esForAnimation(animationName.impl())) | 1026 if (const StyleRuleKeyframes* keyframesRule = resolvers[i]->keyframeStyl
esForAnimation(animationName.impl())) |
| 1027 return keyframesRule; | 1027 return keyframesRule; |
| 1028 } | 1028 } |
| 1029 return nullptr; | 1029 return nullptr; |
| 1030 } | 1030 } |
| 1031 | 1031 |
| 1032 template <StyleResolver::StyleApplicationPass pass> | 1032 template <StyleApplicationPass pass> |
| 1033 void StyleResolver::applyAnimatedProperties(StyleResolverState& state, const Wil
lBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& activeInterpo
lations) | 1033 void StyleResolver::applyAnimatedProperties(StyleResolverState& state, const Wil
lBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& activeInterpo
lations) |
| 1034 { | 1034 { |
| 1035 for (const auto& interpolationEntry : activeInterpolations) { | 1035 for (const auto& interpolationEntry : activeInterpolations) { |
| 1036 CSSPropertyID property = interpolationEntry.key; | 1036 CSSPropertyID property = interpolationEntry.key; |
| 1037 if (!isPropertyForPass<pass>(property)) | 1037 if (!StylePropertyRange::isPropertyForPass<pass>(property)) |
| 1038 continue; | 1038 continue; |
| 1039 const StyleInterpolation* interpolation = toStyleInterpolation(interpola
tionEntry.value.get()); | 1039 const StyleInterpolation* interpolation = toStyleInterpolation(interpola
tionEntry.value.get()); |
| 1040 interpolation->apply(state); | 1040 interpolation->apply(state); |
| 1041 } | 1041 } |
| 1042 } | 1042 } |
| 1043 | 1043 |
| 1044 static inline bool isValidCueStyleProperty(CSSPropertyID id) | 1044 static inline bool isValidCueStyleProperty(CSSPropertyID id) |
| 1045 { | 1045 { |
| 1046 switch (id) { | 1046 switch (id) { |
| 1047 case CSSPropertyBackground: | 1047 case CSSPropertyBackground: |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 // Properties that we currently support outside of spec. | 1207 // Properties that we currently support outside of spec. |
| 1208 case CSSPropertyWebkitLineBoxContain: | 1208 case CSSPropertyWebkitLineBoxContain: |
| 1209 case CSSPropertyVisibility: | 1209 case CSSPropertyVisibility: |
| 1210 return true; | 1210 return true; |
| 1211 | 1211 |
| 1212 default: | 1212 default: |
| 1213 return false; | 1213 return false; |
| 1214 } | 1214 } |
| 1215 } | 1215 } |
| 1216 | 1216 |
| 1217 // FIXME: Consider refactoring to create a new class which owns the following | |
| 1218 // first/last/range properties. | |
| 1219 // This method returns the first CSSPropertyId of high priority properties. | |
| 1220 // Other properties can depend on high priority properties. For example, | |
| 1221 // border-color property with currentColor value depends on color property. | |
| 1222 // All high priority properties are obtained by using | |
| 1223 // firstCSSPropertyId<HighPriorityProperties> and | |
| 1224 // lastCSSPropertyId<HighPriorityProperties>. | |
| 1225 template<> CSSPropertyID StyleResolver::firstCSSPropertyId<StyleResolver::HighPr
iorityProperties>() | |
| 1226 { | |
| 1227 static_assert(CSSPropertyColor == firstCSSProperty, "CSSPropertyColor should
be the first high priority property"); | |
| 1228 return CSSPropertyColor; | |
| 1229 } | |
| 1230 | |
| 1231 // This method returns the last CSSPropertyId of high priority properties. | |
| 1232 template<> CSSPropertyID StyleResolver::lastCSSPropertyId<StyleResolver::HighPri
orityProperties>() | |
| 1233 { | |
| 1234 static_assert(CSSPropertyZoom == CSSPropertyColor + 16, "CSSPropertyZoom sho
uld be the end of the high priority property range"); | |
| 1235 static_assert(CSSPropertyTextRendering == CSSPropertyZoom - 1, "CSSPropertyT
extRendering should be immediately before CSSPropertyZoom"); | |
| 1236 return CSSPropertyZoom; | |
| 1237 } | |
| 1238 | |
| 1239 // This method returns the first CSSPropertyId of remaining properties, | |
| 1240 // i.e. low priority properties. No properties depend on low priority | |
| 1241 // properties. So we don't need to resolve such properties quickly. | |
| 1242 // All low priority properties are obtained by using | |
| 1243 // firstCSSPropertyId<LowPriorityProperties> and | |
| 1244 // lastCSSPropertyId<LowPriorityProperties>. | |
| 1245 template<> CSSPropertyID StyleResolver::firstCSSPropertyId<StyleResolver::LowPri
orityProperties>() | |
| 1246 { | |
| 1247 static_assert(CSSPropertyAlignContent == CSSPropertyZoom + 1, "CSSPropertyAl
ignContent should be the first low priority property"); | |
| 1248 return CSSPropertyAlignContent; | |
| 1249 } | |
| 1250 | |
| 1251 // This method returns the last CSSPropertyId of low priority properties. | |
| 1252 template<> CSSPropertyID StyleResolver::lastCSSPropertyId<StyleResolver::LowPrio
rityProperties>() | |
| 1253 { | |
| 1254 return static_cast<CSSPropertyID>(lastCSSProperty); | |
| 1255 } | |
| 1256 | |
| 1257 template <StyleResolver::StyleApplicationPass pass> | |
| 1258 bool StyleResolver::isPropertyForPass(CSSPropertyID property) | |
| 1259 { | |
| 1260 return firstCSSPropertyId<pass>() <= property && property <= lastCSSProperty
Id<pass>(); | |
| 1261 } | |
| 1262 | |
| 1263 // This method expands the 'all' shorthand property to longhand properties | 1217 // This method expands the 'all' shorthand property to longhand properties |
| 1264 // and applies the expanded longhand properties. | 1218 // and applies the expanded longhand properties. |
| 1265 template <StyleResolver::StyleApplicationPass pass> | 1219 template <StyleApplicationPass pass> |
| 1266 void StyleResolver::applyAllProperty(StyleResolverState& state, CSSValue* allVal
ue, bool inheritedOnly) | 1220 void StyleResolver::applyAllProperty(StyleResolverState& state, CSSValue* allVal
ue, bool inheritedOnly) |
| 1267 { | 1221 { |
| 1268 bool isUnsetValue = !allValue->isInitialValue() && !allValue->isInheritedVal
ue(); | 1222 bool isUnsetValue = !allValue->isInitialValue() && !allValue->isInheritedVal
ue(); |
| 1269 unsigned startCSSProperty = firstCSSPropertyId<pass>(); | 1223 unsigned startCSSProperty = StylePropertyRange::firstCSSPropertyId<pass>(); |
| 1270 unsigned endCSSProperty = lastCSSPropertyId<pass>(); | 1224 unsigned endCSSProperty = StylePropertyRange::lastCSSPropertyId<pass>(); |
| 1271 | 1225 |
| 1272 for (unsigned i = startCSSProperty; i <= endCSSProperty; ++i) { | 1226 for (unsigned i = startCSSProperty; i <= endCSSProperty; ++i) { |
| 1273 CSSPropertyID propertyId = static_cast<CSSPropertyID>(i); | 1227 CSSPropertyID propertyId = static_cast<CSSPropertyID>(i); |
| 1274 | 1228 |
| 1275 // StyleBuilder does not allow any expanded shorthands. | 1229 // StyleBuilder does not allow any expanded shorthands. |
| 1276 if (isShorthandProperty(propertyId)) | 1230 if (isShorthandProperty(propertyId)) |
| 1277 continue; | 1231 continue; |
| 1278 | 1232 |
| 1279 // all shorthand spec says: | 1233 // all shorthand spec says: |
| 1280 // The all property is a shorthand that resets all CSS properties | 1234 // The all property is a shorthand that resets all CSS properties |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1296 } else { | 1250 } else { |
| 1297 if (CSSPropertyMetadata::isInheritedProperty(propertyId)) | 1251 if (CSSPropertyMetadata::isInheritedProperty(propertyId)) |
| 1298 value = cssValuePool().createInheritedValue().get(); | 1252 value = cssValuePool().createInheritedValue().get(); |
| 1299 else | 1253 else |
| 1300 value = cssValuePool().createExplicitInitialValue().get(); | 1254 value = cssValuePool().createExplicitInitialValue().get(); |
| 1301 } | 1255 } |
| 1302 StyleBuilder::applyProperty(propertyId, state, value); | 1256 StyleBuilder::applyProperty(propertyId, state, value); |
| 1303 } | 1257 } |
| 1304 } | 1258 } |
| 1305 | 1259 |
| 1306 template <StyleResolver::StyleApplicationPass pass> | 1260 template <StyleApplicationPass pass> |
| 1307 void StyleResolver::applyProperties(StyleResolverState& state, const StyleProper
tySet* properties, bool isImportant, bool inheritedOnly, PropertyWhitelistType p
ropertyWhitelistType) | 1261 void StyleResolver::applyProperties(StyleResolverState& state, const StyleProper
tySet* properties, bool isImportant, bool inheritedOnly, PropertyWhitelistType p
ropertyWhitelistType) |
| 1308 { | 1262 { |
| 1309 unsigned propertyCount = properties->propertyCount(); | 1263 unsigned propertyCount = properties->propertyCount(); |
| 1310 for (unsigned i = 0; i < propertyCount; ++i) { | 1264 for (unsigned i = 0; i < propertyCount; ++i) { |
| 1311 StylePropertySet::PropertyReference current = properties->propertyAt(i); | 1265 StylePropertySet::PropertyReference current = properties->propertyAt(i); |
| 1312 if (isImportant != current.isImportant()) | 1266 if (isImportant != current.isImportant()) |
| 1313 continue; | 1267 continue; |
| 1314 | 1268 |
| 1315 CSSPropertyID property = current.id(); | 1269 CSSPropertyID property = current.id(); |
| 1316 if (property == CSSPropertyAll) { | 1270 if (property == CSSPropertyAll) { |
| 1317 applyAllProperty<pass>(state, current.value(), inheritedOnly); | 1271 applyAllProperty<pass>(state, current.value(), inheritedOnly); |
| 1318 continue; | 1272 continue; |
| 1319 } | 1273 } |
| 1320 | 1274 |
| 1321 if (propertyWhitelistType == PropertyWhitelistCue && !isValidCueStylePro
perty(property)) | 1275 if (propertyWhitelistType == PropertyWhitelistCue && !isValidCueStylePro
perty(property)) |
| 1322 continue; | 1276 continue; |
| 1323 if (propertyWhitelistType == PropertyWhitelistFirstLetter && !isValidFir
stLetterStyleProperty(property)) | 1277 if (propertyWhitelistType == PropertyWhitelistFirstLetter && !isValidFir
stLetterStyleProperty(property)) |
| 1324 continue; | 1278 continue; |
| 1325 | 1279 |
| 1326 if (inheritedOnly && !current.isInherited()) { | 1280 if (inheritedOnly && !current.isInherited()) { |
| 1327 // If the property value is explicitly inherited, we need to apply f
urther non-inherited properties | 1281 // If the property value is explicitly inherited, we need to apply f
urther non-inherited properties |
| 1328 // as they might override the value inherited here. For this reason
we don't allow declarations with | 1282 // as they might override the value inherited here. For this reason
we don't allow declarations with |
| 1329 // explicitly inherited properties to be cached. | 1283 // explicitly inherited properties to be cached. |
| 1330 ASSERT(!current.value()->isInheritedValue()); | 1284 ASSERT(!current.value()->isInheritedValue()); |
| 1331 continue; | 1285 continue; |
| 1332 } | 1286 } |
| 1333 | 1287 |
| 1334 if (!isPropertyForPass<pass>(property)) | 1288 if (!StylePropertyRange::isPropertyForPass<pass>(property)) |
| 1335 continue; | 1289 continue; |
| 1336 | 1290 |
| 1337 StyleBuilder::applyProperty(current.id(), state, current.value()); | 1291 StyleBuilder::applyProperty(current.id(), state, current.value()); |
| 1338 } | 1292 } |
| 1339 } | 1293 } |
| 1340 | 1294 |
| 1341 template <StyleResolver::StyleApplicationPass pass> | 1295 template <StyleApplicationPass pass> |
| 1342 void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc
hResult& matchResult, bool isImportant, int startIndex, int endIndex, bool inher
itedOnly) | 1296 void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc
hResult& matchResult, bool isImportant, int startIndex, int endIndex, bool inher
itedOnly) |
| 1343 { | 1297 { |
| 1344 if (startIndex == -1) | 1298 if (startIndex == -1) |
| 1345 return; | 1299 return; |
| 1346 | 1300 |
| 1347 if (state.style()->insideLink() != NotInsideLink) { | 1301 if (state.style()->insideLink() != NotInsideLink) { |
| 1348 for (int i = startIndex; i <= endIndex; ++i) { | 1302 for (int i = startIndex; i <= endIndex; ++i) { |
| 1349 const MatchedProperties& matchedProperties = matchResult.matchedProp
erties[i]; | 1303 const MatchedProperties& matchedProperties = matchResult.matchedProp
erties[i]; |
| 1350 unsigned linkMatchType = matchedProperties.m_types.linkMatchType; | 1304 unsigned linkMatchType = matchedProperties.m_types.linkMatchType; |
| 1351 // FIXME: It would be nicer to pass these as arguments but that requ
ires changes in many places. | 1305 // FIXME: It would be nicer to pass these as arguments but that requ
ires changes in many places. |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1573 visitor->trace(m_uncommonAttributeRuleSet); | 1527 visitor->trace(m_uncommonAttributeRuleSet); |
| 1574 visitor->trace(m_watchedSelectorsRules); | 1528 visitor->trace(m_watchedSelectorsRules); |
| 1575 visitor->trace(m_treeBoundaryCrossingRules); | 1529 visitor->trace(m_treeBoundaryCrossingRules); |
| 1576 visitor->trace(m_styleSharingLists); | 1530 visitor->trace(m_styleSharingLists); |
| 1577 visitor->trace(m_pendingStyleSheets); | 1531 visitor->trace(m_pendingStyleSheets); |
| 1578 visitor->trace(m_document); | 1532 visitor->trace(m_document); |
| 1579 #endif | 1533 #endif |
| 1580 } | 1534 } |
| 1581 | 1535 |
| 1582 } // namespace blink | 1536 } // namespace blink |
| OLD | NEW |