Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: Source/core/css/resolver/StyleResolver.cpp

Issue 216803002: Implement all shorthand property. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed ASSERT_NOT_REACH in linux_blink_dbg Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "core/css/CSSDefaultStyleSheets.h" 44 #include "core/css/CSSDefaultStyleSheets.h"
45 #include "core/css/CSSFontSelector.h" 45 #include "core/css/CSSFontSelector.h"
46 #include "core/css/CSSKeyframeRule.h" 46 #include "core/css/CSSKeyframeRule.h"
47 #include "core/css/CSSKeyframesRule.h" 47 #include "core/css/CSSKeyframesRule.h"
48 #include "core/css/parser/BisonCSSParser.h" 48 #include "core/css/parser/BisonCSSParser.h"
49 #include "core/css/CSSReflectValue.h" 49 #include "core/css/CSSReflectValue.h"
50 #include "core/css/CSSRuleList.h" 50 #include "core/css/CSSRuleList.h"
51 #include "core/css/CSSSelector.h" 51 #include "core/css/CSSSelector.h"
52 #include "core/css/CSSStyleRule.h" 52 #include "core/css/CSSStyleRule.h"
53 #include "core/css/CSSValueList.h" 53 #include "core/css/CSSValueList.h"
54 #include "core/css/CSSValuePool.h"
54 #include "core/css/ElementRuleCollector.h" 55 #include "core/css/ElementRuleCollector.h"
55 #include "core/css/FontFace.h" 56 #include "core/css/FontFace.h"
56 #include "core/css/MediaQueryEvaluator.h" 57 #include "core/css/MediaQueryEvaluator.h"
57 #include "core/css/PageRuleCollector.h" 58 #include "core/css/PageRuleCollector.h"
58 #include "core/css/StylePropertySet.h" 59 #include "core/css/StylePropertySet.h"
59 #include "core/css/StyleRuleImport.h" 60 #include "core/css/StyleRuleImport.h"
60 #include "core/css/StyleSheetContents.h" 61 #include "core/css/StyleSheetContents.h"
61 #include "core/css/resolver/AnimatedStyleBuilder.h" 62 #include "core/css/resolver/AnimatedStyleBuilder.h"
62 #include "core/css/resolver/MatchResult.h" 63 #include "core/css/resolver/MatchResult.h"
63 #include "core/css/resolver/MediaQueryResult.h" 64 #include "core/css/resolver/MediaQueryResult.h"
(...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 // Properties that we currently support outside of spec. 1223 // Properties that we currently support outside of spec.
1223 case CSSPropertyWebkitLineBoxContain: 1224 case CSSPropertyWebkitLineBoxContain:
1224 case CSSPropertyVisibility: 1225 case CSSPropertyVisibility:
1225 return true; 1226 return true;
1226 1227
1227 default: 1228 default:
1228 return false; 1229 return false;
1229 } 1230 }
1230 } 1231 }
1231 1232
1233 static const CSSPropertyID firstAnimationProperty = CSSPropertyDisplay;
1234 static const CSSPropertyID lastAnimationProperty = CSSPropertyTransitionTimingFu nction;
1235 COMPILE_ASSERT(firstCSSProperty == firstAnimationProperty, CSS_first_animation_p roperty_should_be_first_property);
1236 static const CSSPropertyID firstHighPriorityProperty = CSSPropertyColor;
1237 static const CSSPropertyID lastHighPriorityProperty = CSSPropertyLineHeight;
1238 COMPILE_ASSERT(lastAnimationProperty + 1 == firstHighPriorityProperty, CSS_color _is_first_high_priority_property);
1239 COMPILE_ASSERT(CSSPropertyLineHeight == firstHighPriorityProperty + 17, CSS_line _height_is_end_of_high_prioity_property_range);
1240 COMPILE_ASSERT(CSSPropertyZoom == lastHighPriorityProperty - 1, CSS_zoom_is_befo re_line_height);
1241
1232 template <StyleResolver::StyleApplicationPass pass> 1242 template <StyleResolver::StyleApplicationPass pass>
1233 bool StyleResolver::isPropertyForPass(CSSPropertyID property) 1243 bool StyleResolver::isPropertyForPass(CSSPropertyID property)
1234 { 1244 {
1235 const CSSPropertyID firstAnimationProperty = CSSPropertyDisplay;
1236 const CSSPropertyID lastAnimationProperty = CSSPropertyTransitionTimingFunct ion;
1237 COMPILE_ASSERT(firstCSSProperty == firstAnimationProperty, CSS_first_animati on_property_should_be_first_property);
1238 const CSSPropertyID firstHighPriorityProperty = CSSPropertyColor;
1239 const CSSPropertyID lastHighPriorityProperty = CSSPropertyLineHeight;
1240 COMPILE_ASSERT(lastAnimationProperty + 1 == firstHighPriorityProperty, CSS_c olor_is_first_high_priority_property);
1241 COMPILE_ASSERT(CSSPropertyLineHeight == firstHighPriorityProperty + 17, CSS_ line_height_is_end_of_high_prioity_property_range);
1242 COMPILE_ASSERT(CSSPropertyZoom == lastHighPriorityProperty - 1, CSS_zoom_is_ before_line_height);
1243 switch (pass) { 1245 switch (pass) {
1244 case AnimationProperties: 1246 case AnimationProperties:
1245 return property >= firstAnimationProperty && property <= lastAnimationPr operty; 1247 return property >= firstAnimationProperty && property <= lastAnimationPr operty;
1246 case HighPriorityProperties: 1248 case HighPriorityProperties:
1247 return property >= firstHighPriorityProperty && property <= lastHighPrio rityProperty; 1249 return property >= firstHighPriorityProperty && property <= lastHighPrio rityProperty;
1248 case LowPriorityProperties: 1250 case LowPriorityProperties:
1249 return property > lastHighPriorityProperty; 1251 return property > lastHighPriorityProperty;
1250 } 1252 }
1251 ASSERT_NOT_REACHED(); 1253 ASSERT_NOT_REACHED();
1252 return false; 1254 return false;
1253 } 1255 }
1254 1256
1255 template <StyleResolver::StyleApplicationPass pass> 1257 template <StyleResolver::StyleApplicationPass pass>
1258 void StyleResolver::applyAllProperty(StyleResolverState& state, CSSValue* allVal ue)
1259 {
1260 bool isUnsetValue = !allValue->isInitialValue() && !allValue->isInheritedVal ue();
1261 unsigned startCSSProperty;
1262 unsigned endCSSProperty;
1263 switch (pass) {
1264 case AnimationProperties:
esprehn 2014/05/30 00:59:22 Can we put this in a method so you could do: star
tasak 2014/06/04 09:37:41 I see. Done. I also modified COMPILE_ASSERT. So t
1265 startCSSProperty = firstAnimationProperty;
1266 endCSSProperty = lastAnimationProperty;
1267 break;
1268 case HighPriorityProperties:
1269 startCSSProperty = firstHighPriorityProperty;
1270 endCSSProperty = lastHighPriorityProperty;
1271 break;
1272 case LowPriorityProperties:
1273 startCSSProperty = lastHighPriorityProperty + 1;
1274 endCSSProperty = lastCSSProperty;
1275 break;
1276 default:
1277 ASSERT_NOT_REACHED();
1278 }
1279
1280 for (unsigned i = startCSSProperty; i <= endCSSProperty; ++i) {
esprehn 2014/05/30 00:59:22 Can we just do CSSPropertyID and ++ on it?
tasak 2014/06/04 09:37:41 Since CSSPropertyID is enum, we cannot ++.
1281 CSSPropertyID propertyId = static_cast<CSSPropertyID>(i);
1282
1283 if (isExpandedShorthandForAll(propertyId))
1284 continue;
1285 if (propertyId == CSSPropertyAll || propertyId == CSSPropertyUnicodeBidi || propertyId == CSSPropertyDirection)
esprehn 2014/05/30 00:59:22 This list is somewhere else too I think in the sam
tasak 2014/06/04 09:37:41 Yeah. I have the same condition in several places.
1286 continue;
1287
1288 CSSValue* value;
1289 if (!isUnsetValue) {
1290 value = allValue;
1291 } else {
1292 if (CSSProperty::isInheritedProperty(propertyId))
1293 value = cssValuePool().createInheritedValue().get();
1294 else
1295 value = cssValuePool().createExplicitInitialValue().get();
1296 }
1297 StyleBuilder::applyProperty(propertyId, state, value);
1298 }
1299 }
1300
1301 template <StyleResolver::StyleApplicationPass pass>
1256 void StyleResolver::applyProperties(StyleResolverState& state, const StyleProper tySet* properties, StyleRule* rule, bool isImportant, bool inheritedOnly, Proper tyWhitelistType propertyWhitelistType) 1302 void StyleResolver::applyProperties(StyleResolverState& state, const StyleProper tySet* properties, StyleRule* rule, bool isImportant, bool inheritedOnly, Proper tyWhitelistType propertyWhitelistType)
1257 { 1303 {
1258 state.setCurrentRule(rule); 1304 state.setCurrentRule(rule);
1259 1305
1260 unsigned propertyCount = properties->propertyCount(); 1306 unsigned propertyCount = properties->propertyCount();
1261 for (unsigned i = 0; i < propertyCount; ++i) { 1307 for (unsigned i = 0; i < propertyCount; ++i) {
1262 StylePropertySet::PropertyReference current = properties->propertyAt(i); 1308 StylePropertySet::PropertyReference current = properties->propertyAt(i);
1263 if (isImportant != current.isImportant()) 1309 if (isImportant != current.isImportant())
1264 continue; 1310 continue;
1311
1312 CSSPropertyID property = current.id();
1313 if (property == CSSPropertyAll) {
1314 applyAllProperty<pass>(state, current.value());
1315 continue;
1316 }
1317
1265 if (inheritedOnly && !current.isInherited()) { 1318 if (inheritedOnly && !current.isInherited()) {
1266 // If the property value is explicitly inherited, we need to apply f urther non-inherited properties 1319 // If the property value is explicitly inherited, we need to apply f urther non-inherited properties
1267 // as they might override the value inherited here. For this reason we don't allow declarations with 1320 // as they might override the value inherited here. For this reason we don't allow declarations with
1268 // explicitly inherited properties to be cached. 1321 // explicitly inherited properties to be cached.
1269 ASSERT(!current.value()->isInheritedValue()); 1322 ASSERT(!current.value()->isInheritedValue());
1270 continue; 1323 continue;
1271 } 1324 }
1272 CSSPropertyID property = current.id();
1273 1325
1274 if (propertyWhitelistType == PropertyWhitelistCue && !isValidCueStylePro perty(property)) 1326 if (propertyWhitelistType == PropertyWhitelistCue && !isValidCueStylePro perty(property))
1275 continue; 1327 continue;
1276 if (propertyWhitelistType == PropertyWhitelistFirstLetter && !isValidFir stLetterStyleProperty(property)) 1328 if (propertyWhitelistType == PropertyWhitelistFirstLetter && !isValidFir stLetterStyleProperty(property))
1277 continue; 1329 continue;
1278 if (!isPropertyForPass<pass>(property)) 1330 if (!isPropertyForPass<pass>(property))
1279 continue; 1331 continue;
1280 if (pass == HighPriorityProperties && property == CSSPropertyLineHeight) 1332 if (pass == HighPriorityProperties && property == CSSPropertyLineHeight)
1281 state.setLineHeightValue(current.value()); 1333 state.setLineHeightValue(current.value());
1282 else 1334 else
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1495 visitor->trace(m_features); 1547 visitor->trace(m_features);
1496 visitor->trace(m_siblingRuleSet); 1548 visitor->trace(m_siblingRuleSet);
1497 visitor->trace(m_uncommonAttributeRuleSet); 1549 visitor->trace(m_uncommonAttributeRuleSet);
1498 visitor->trace(m_watchedSelectorsRules); 1550 visitor->trace(m_watchedSelectorsRules);
1499 visitor->trace(m_treeBoundaryCrossingRules); 1551 visitor->trace(m_treeBoundaryCrossingRules);
1500 visitor->trace(m_pendingStyleSheets); 1552 visitor->trace(m_pendingStyleSheets);
1501 CSSFontSelectorClient::trace(visitor); 1553 CSSFontSelectorClient::trace(visitor);
1502 } 1554 }
1503 1555
1504 } // namespace WebCore 1556 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698