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 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 // Properties that we currently support outside of spec. | 1203 // Properties that we currently support outside of spec. |
1204 case CSSPropertyWebkitLineBoxContain: | 1204 case CSSPropertyWebkitLineBoxContain: |
1205 case CSSPropertyVisibility: | 1205 case CSSPropertyVisibility: |
1206 return true; | 1206 return true; |
1207 | 1207 |
1208 default: | 1208 default: |
1209 return false; | 1209 return false; |
1210 } | 1210 } |
1211 } | 1211 } |
1212 | 1212 |
1213 static bool shouldIgnoreTextTrackAuthorStyle(Document& document) | 1213 static bool shouldIgnoreTextTrackAuthorStyle(const Document& document) |
1214 { | 1214 { |
1215 Settings* settings = document.settings(); | 1215 Settings* settings = document.settings(); |
1216 if (!settings) | 1216 if (!settings) |
1217 return false; | 1217 return false; |
1218 // Ignore author specified settings for text tracks when any of the user set
tings are present. | 1218 // Ignore author specified settings for text tracks when any of the user set
tings are present. |
1219 if (!settings->textTrackBackgroundColor().isEmpty() | 1219 if (!settings->textTrackBackgroundColor().isEmpty() |
1220 || !settings->textTrackFontFamily().isEmpty() | 1220 || !settings->textTrackFontFamily().isEmpty() |
1221 || !settings->textTrackFontStyle().isEmpty() | 1221 || !settings->textTrackFontStyle().isEmpty() |
1222 || !settings->textTrackFontVariant().isEmpty() | 1222 || !settings->textTrackFontVariant().isEmpty() |
1223 || !settings->textTrackTextColor().isEmpty() | 1223 || !settings->textTrackTextColor().isEmpty() |
1224 || !settings->textTrackTextShadow().isEmpty() | 1224 || !settings->textTrackTextShadow().isEmpty() |
1225 || !settings->textTrackTextSize().isEmpty()) | 1225 || !settings->textTrackTextSize().isEmpty()) |
1226 return true; | 1226 return true; |
1227 return false; | 1227 return false; |
1228 } | 1228 } |
1229 | 1229 |
| 1230 static inline bool isPropertyInWhitelist(PropertyWhitelistType propertyWhitelist
Type, CSSPropertyID property, const Document& document) |
| 1231 { |
| 1232 if (propertyWhitelistType == PropertyWhitelistNone) |
| 1233 return true; // Early bail for the by far most common case. |
| 1234 |
| 1235 if (propertyWhitelistType == PropertyWhitelistFirstLetter) |
| 1236 return isValidFirstLetterStyleProperty(property); |
| 1237 |
| 1238 if (propertyWhitelistType == PropertyWhitelistCue) |
| 1239 return isValidCueStyleProperty(property) && !shouldIgnoreTextTrackAuthor
Style(document); |
| 1240 |
| 1241 ASSERT_NOT_REACHED(); |
| 1242 return true; |
| 1243 } |
| 1244 |
1230 // This method expands the 'all' shorthand property to longhand properties | 1245 // This method expands the 'all' shorthand property to longhand properties |
1231 // and applies the expanded longhand properties. | 1246 // and applies the expanded longhand properties. |
1232 template <CSSPropertyPriority priority> | 1247 template <CSSPropertyPriority priority> |
1233 void StyleResolver::applyAllProperty(StyleResolverState& state, CSSValue* allVal
ue, bool inheritedOnly) | 1248 void StyleResolver::applyAllProperty(StyleResolverState& state, CSSValue* allVal
ue, bool inheritedOnly, PropertyWhitelistType propertyWhitelistType) |
1234 { | 1249 { |
1235 unsigned startCSSProperty = CSSPropertyPriorityData<priority>::first(); | 1250 unsigned startCSSProperty = CSSPropertyPriorityData<priority>::first(); |
1236 unsigned endCSSProperty = CSSPropertyPriorityData<priority>::last(); | 1251 unsigned endCSSProperty = CSSPropertyPriorityData<priority>::last(); |
1237 | 1252 |
1238 for (unsigned i = startCSSProperty; i <= endCSSProperty; ++i) { | 1253 for (unsigned i = startCSSProperty; i <= endCSSProperty; ++i) { |
1239 CSSPropertyID propertyId = static_cast<CSSPropertyID>(i); | 1254 CSSPropertyID propertyId = static_cast<CSSPropertyID>(i); |
1240 | 1255 |
1241 // StyleBuilder does not allow any expanded shorthands. | 1256 // StyleBuilder does not allow any expanded shorthands. |
1242 if (isShorthandProperty(propertyId)) | 1257 if (isShorthandProperty(propertyId)) |
1243 continue; | 1258 continue; |
1244 | 1259 |
1245 // all shorthand spec says: | 1260 // all shorthand spec says: |
1246 // The all property is a shorthand that resets all CSS properties | 1261 // The all property is a shorthand that resets all CSS properties |
1247 // except direction and unicode-bidi. | 1262 // except direction and unicode-bidi. |
1248 // c.f. http://dev.w3.org/csswg/css-cascade/#all-shorthand | 1263 // c.f. http://dev.w3.org/csswg/css-cascade/#all-shorthand |
1249 // We skip applyProperty when a given property is unicode-bidi or | 1264 // We skip applyProperty when a given property is unicode-bidi or |
1250 // direction. | 1265 // direction. |
1251 if (!CSSProperty::isAffectedByAllProperty(propertyId)) | 1266 if (!CSSProperty::isAffectedByAllProperty(propertyId)) |
1252 continue; | 1267 continue; |
1253 | 1268 |
| 1269 if (!isPropertyInWhitelist(propertyWhitelistType, propertyId, document()
)) |
| 1270 continue; |
| 1271 |
1254 // When hitting matched properties' cache, only inherited properties wil
l be | 1272 // When hitting matched properties' cache, only inherited properties wil
l be |
1255 // applied. | 1273 // applied. |
1256 if (inheritedOnly && !CSSPropertyMetadata::isInheritedProperty(propertyI
d)) | 1274 if (inheritedOnly && !CSSPropertyMetadata::isInheritedProperty(propertyI
d)) |
1257 continue; | 1275 continue; |
1258 | 1276 |
1259 StyleBuilder::applyProperty(propertyId, state, allValue); | 1277 StyleBuilder::applyProperty(propertyId, state, allValue); |
1260 } | 1278 } |
1261 } | 1279 } |
1262 | 1280 |
1263 template <CSSPropertyPriority priority> | 1281 template <CSSPropertyPriority priority> |
1264 void StyleResolver::applyProperties(StyleResolverState& state, const StyleProper
tySet* properties, bool isImportant, bool inheritedOnly, PropertyWhitelistType p
ropertyWhitelistType) | 1282 void StyleResolver::applyProperties(StyleResolverState& state, const StyleProper
tySet* properties, bool isImportant, bool inheritedOnly, PropertyWhitelistType p
ropertyWhitelistType) |
1265 { | 1283 { |
1266 unsigned propertyCount = properties->propertyCount(); | 1284 unsigned propertyCount = properties->propertyCount(); |
1267 for (unsigned i = 0; i < propertyCount; ++i) { | 1285 for (unsigned i = 0; i < propertyCount; ++i) { |
1268 StylePropertySet::PropertyReference current = properties->propertyAt(i); | 1286 StylePropertySet::PropertyReference current = properties->propertyAt(i); |
1269 if (isImportant != current.isImportant()) | 1287 if (isImportant != current.isImportant()) |
1270 continue; | 1288 continue; |
1271 | 1289 |
1272 CSSPropertyID property = current.id(); | 1290 CSSPropertyID property = current.id(); |
1273 if (property == CSSPropertyAll) { | 1291 if (property == CSSPropertyAll) { |
1274 applyAllProperty<priority>(state, current.value(), inheritedOnly); | 1292 applyAllProperty<priority>(state, current.value(), inheritedOnly, pr
opertyWhitelistType); |
1275 continue; | 1293 continue; |
1276 } | 1294 } |
1277 | 1295 |
1278 if (propertyWhitelistType == PropertyWhitelistCue && (!isValidCueStylePr
operty(property) || shouldIgnoreTextTrackAuthorStyle(document()))) | 1296 if (!isPropertyInWhitelist(propertyWhitelistType, property, document())) |
1279 continue; | |
1280 | |
1281 if (propertyWhitelistType == PropertyWhitelistFirstLetter && !isValidFir
stLetterStyleProperty(property)) | |
1282 continue; | 1297 continue; |
1283 | 1298 |
1284 if (inheritedOnly && !current.isInherited()) { | 1299 if (inheritedOnly && !current.isInherited()) { |
1285 // If the property value is explicitly inherited, we need to apply f
urther non-inherited properties | 1300 // If the property value is explicitly inherited, we need to apply f
urther non-inherited properties |
1286 // as they might override the value inherited here. For this reason
we don't allow declarations with | 1301 // as they might override the value inherited here. For this reason
we don't allow declarations with |
1287 // explicitly inherited properties to be cached. | 1302 // explicitly inherited properties to be cached. |
1288 ASSERT(!current.value()->isInheritedValue()); | 1303 ASSERT(!current.value()->isInheritedValue()); |
1289 continue; | 1304 continue; |
1290 } | 1305 } |
1291 | 1306 |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1508 visitor->trace(m_watchedSelectorsRules); | 1523 visitor->trace(m_watchedSelectorsRules); |
1509 visitor->trace(m_treeBoundaryCrossingScopes); | 1524 visitor->trace(m_treeBoundaryCrossingScopes); |
1510 visitor->trace(m_styleResourceLoader); | 1525 visitor->trace(m_styleResourceLoader); |
1511 visitor->trace(m_styleSharingLists); | 1526 visitor->trace(m_styleSharingLists); |
1512 visitor->trace(m_pendingStyleSheets); | 1527 visitor->trace(m_pendingStyleSheets); |
1513 visitor->trace(m_document); | 1528 visitor->trace(m_document); |
1514 #endif | 1529 #endif |
1515 } | 1530 } |
1516 | 1531 |
1517 } // namespace blink | 1532 } // namespace blink |
OLD | NEW |