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

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

Issue 892643002: Split property priority functions out of StyleResolver. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use template class CSSPropertyPriority. Created 5 years, 10 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
« no previous file with comments | « Source/core/css/resolver/StyleResolver.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 675
676 // Create the style 676 // Create the style
677 state.setStyle(RenderStyle::clone(&elementStyle)); 677 state.setStyle(RenderStyle::clone(&elementStyle));
678 678
679 // We don't need to bother with !important. Since there is only ever one 679 // We don't need to bother with !important. Since there is only ever one
680 // decl, there's nothing to override. So just add the first properties. 680 // decl, there's nothing to override. So just add the first properties.
681 // We also don't need to bother with animation properties since the only 681 // We also don't need to bother with animation properties since the only
682 // relevant one is animation-timing-function and we special-case that in 682 // relevant one is animation-timing-function and we special-case that in
683 // CSSAnimations.cpp 683 // CSSAnimations.cpp
684 bool inheritedOnly = false; 684 bool inheritedOnly = false;
685 applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, resu lt.matchedProperties.size() - 1, inheritedOnly); 685 applyMatchedProperties<HighPropertyPriority>(state, result, false, 0, result .matchedProperties.size() - 1, inheritedOnly);
686 686
687 // If our font got dirtied, go ahead and update it now. 687 // If our font got dirtied, go ahead and update it now.
688 updateFont(state); 688 updateFont(state);
689 689
690 // Now do rest of the properties. 690 // Now do rest of the properties.
691 applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, resul t.matchedProperties.size() - 1, inheritedOnly); 691 applyMatchedProperties<LowPropertyPriority>(state, result, false, 0, result. matchedProperties.size() - 1, inheritedOnly);
692 692
693 loadPendingResources(state); 693 loadPendingResources(state);
694 694
695 didAccess(); 695 didAccess();
696 696
697 return state.takeStyle(); 697 return state.takeStyle();
698 } 698 }
699 699
700 // This function is used by the WebAnimations JavaScript API method animate(). 700 // This function is used by the WebAnimations JavaScript API method animate().
701 // FIXME: Remove this when animate() switches away from resolution-dependent par sing. 701 // FIXME: Remove this when animate() switches away from resolution-dependent par sing.
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 PageRuleCollector collector(rootElementStyle, pageIndex); 873 PageRuleCollector collector(rootElementStyle, pageIndex);
874 874
875 collector.matchPageRules(CSSDefaultStyleSheets::instance().defaultPrintStyle ()); 875 collector.matchPageRules(CSSDefaultStyleSheets::instance().defaultPrintStyle ());
876 876
877 if (ScopedStyleResolver* scopedResolver = document().scopedStyleResolver()) 877 if (ScopedStyleResolver* scopedResolver = document().scopedStyleResolver())
878 scopedResolver->matchPageRules(collector); 878 scopedResolver->matchPageRules(collector);
879 879
880 bool inheritedOnly = false; 880 bool inheritedOnly = false;
881 881
882 MatchResult& result = collector.matchedResult(); 882 MatchResult& result = collector.matchedResult();
883 applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, resu lt.matchedProperties.size() - 1, inheritedOnly); 883 applyMatchedProperties<HighPropertyPriority>(state, result, false, 0, result .matchedProperties.size() - 1, inheritedOnly);
884 884
885 // If our font got dirtied, go ahead and update it now. 885 // If our font got dirtied, go ahead and update it now.
886 updateFont(state); 886 updateFont(state);
887 887
888 applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, resul t.matchedProperties.size() - 1, inheritedOnly); 888 applyMatchedProperties<LowPropertyPriority>(state, result, false, 0, result. matchedProperties.size() - 1, inheritedOnly);
889 889
890 loadPendingResources(state); 890 loadPendingResources(state);
891 891
892 didAccess(); 892 didAccess();
893 893
894 // Now return the style. 894 // Now return the style.
895 return state.takeStyle(); 895 return state.takeStyle();
896 } 896 }
897 897
898 void StyleResolver::collectViewportRules() 898 void StyleResolver::collectViewportRules()
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 if (!(animatingElement && animatingElement->hasActiveAnimations()) 992 if (!(animatingElement && animatingElement->hasActiveAnimations())
993 && !state.style()->transitions() && !state.style()->animations()) 993 && !state.style()->transitions() && !state.style()->animations())
994 return false; 994 return false;
995 995
996 state.setAnimationUpdate(CSSAnimations::calculateUpdate(animatingElement, *e lement, *state.style(), state.parentStyle(), this)); 996 state.setAnimationUpdate(CSSAnimations::calculateUpdate(animatingElement, *e lement, *state.style(), state.parentStyle(), this));
997 if (!state.animationUpdate()) 997 if (!state.animationUpdate())
998 return false; 998 return false;
999 999
1000 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& activeInterpolationsForAnimations = state.animationUpdate()->activeInterpolation sForAnimations(); 1000 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& activeInterpolationsForAnimations = state.animationUpdate()->activeInterpolation sForAnimations();
1001 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& activeInterpolationsForTransitions = state.animationUpdate()->activeInterpolatio nsForTransitions(); 1001 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& activeInterpolationsForTransitions = state.animationUpdate()->activeInterpolatio nsForTransitions();
1002 applyAnimatedProperties<HighPriorityProperties>(state, activeInterpolationsF orAnimations); 1002 applyAnimatedProperties<HighPropertyPriority>(state, activeInterpolationsFor Animations);
1003 applyAnimatedProperties<HighPriorityProperties>(state, activeInterpolationsF orTransitions); 1003 applyAnimatedProperties<HighPropertyPriority>(state, activeInterpolationsFor Transitions);
1004 1004
1005 updateFont(state); 1005 updateFont(state);
1006 1006
1007 applyAnimatedProperties<LowPriorityProperties>(state, activeInterpolationsFo rAnimations); 1007 applyAnimatedProperties<LowPropertyPriority>(state, activeInterpolationsForA nimations);
1008 applyAnimatedProperties<LowPriorityProperties>(state, activeInterpolationsFo rTransitions); 1008 applyAnimatedProperties<LowPropertyPriority>(state, activeInterpolationsForT ransitions);
1009 1009
1010 // Start loading resources used by animations. 1010 // Start loading resources used by animations.
1011 loadPendingResources(state); 1011 loadPendingResources(state);
1012 1012
1013 ASSERT(!state.fontBuilder().fontDirty()); 1013 ASSERT(!state.fontBuilder().fontDirty());
1014 1014
1015 return true; 1015 return true;
1016 } 1016 }
1017 1017
1018 const StyleRuleKeyframes* StyleResolver::findKeyframesRule(const Element* elemen t, const AtomicString& animationName) 1018 const StyleRuleKeyframes* StyleResolver::findKeyframesRule(const Element* elemen t, const AtomicString& animationName)
1019 { 1019 {
1020 WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8> resolvers; 1020 WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8> resolvers;
1021 collectScopedResolversForHostedShadowTrees(element, resolvers); 1021 collectScopedResolversForHostedShadowTrees(element, resolvers);
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 <CSSPropertyPriority priority>
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 (!CSSPropertyPriorityData<priority>::propertyHasPriority(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
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 <CSSPropertyPriority priority>
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 = CSSPropertyPriorityData<priority>::first();
1270 unsigned endCSSProperty = lastCSSPropertyId<pass>(); 1224 unsigned endCSSProperty = CSSPropertyPriorityData<priority>::last();
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
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 <CSSPropertyPriority priority>
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<priority>(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 (!CSSPropertyPriorityData<priority>::propertyHasPriority(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 <CSSPropertyPriority priority>
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.
1352 state.setApplyPropertyToRegularStyle(linkMatchType & SelectorChecker ::MatchLink); 1306 state.setApplyPropertyToRegularStyle(linkMatchType & SelectorChecker ::MatchLink);
1353 state.setApplyPropertyToVisitedLinkStyle(linkMatchType & SelectorChe cker::MatchVisited); 1307 state.setApplyPropertyToVisitedLinkStyle(linkMatchType & SelectorChe cker::MatchVisited);
1354 1308
1355 applyProperties<pass>(state, matchedProperties.properties.get(), isI mportant, inheritedOnly, static_cast<PropertyWhitelistType>(matchedProperties.m_ types.whitelistType)); 1309 applyProperties<priority>(state, matchedProperties.properties.get(), isImportant, inheritedOnly, static_cast<PropertyWhitelistType>(matchedPropertie s.m_types.whitelistType));
1356 } 1310 }
1357 state.setApplyPropertyToRegularStyle(true); 1311 state.setApplyPropertyToRegularStyle(true);
1358 state.setApplyPropertyToVisitedLinkStyle(false); 1312 state.setApplyPropertyToVisitedLinkStyle(false);
1359 return; 1313 return;
1360 } 1314 }
1361 for (int i = startIndex; i <= endIndex; ++i) { 1315 for (int i = startIndex; i <= endIndex; ++i) {
1362 const MatchedProperties& matchedProperties = matchResult.matchedProperti es[i]; 1316 const MatchedProperties& matchedProperties = matchResult.matchedProperti es[i];
1363 applyProperties<pass>(state, matchedProperties.properties.get(), isImpor tant, inheritedOnly, static_cast<PropertyWhitelistType>(matchedProperties.m_type s.whitelistType)); 1317 applyProperties<priority>(state, matchedProperties.properties.get(), isI mportant, inheritedOnly, static_cast<PropertyWhitelistType>(matchedProperties.m_ types.whitelistType));
1364 } 1318 }
1365 } 1319 }
1366 1320
1367 static unsigned computeMatchedPropertiesHash(const MatchedProperties* properties , unsigned size) 1321 static unsigned computeMatchedPropertiesHash(const MatchedProperties* properties , unsigned size)
1368 { 1322 {
1369 return StringHasher::hashMemory(properties, sizeof(MatchedProperties) * size ); 1323 return StringHasher::hashMemory(properties, sizeof(MatchedProperties) * size );
1370 } 1324 }
1371 1325
1372 void StyleResolver::invalidateMatchedPropertiesCache() 1326 void StyleResolver::invalidateMatchedPropertiesCache()
1373 { 1327 {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1415 1369
1416 return; 1370 return;
1417 } 1371 }
1418 applyInheritedOnly = true; 1372 applyInheritedOnly = true;
1419 } 1373 }
1420 1374
1421 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply 1375 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply
1422 // high-priority properties first, i.e., those properties that other propert ies depend on. 1376 // high-priority properties first, i.e., those properties that other propert ies depend on.
1423 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important 1377 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important
1424 // and (4) normal important. 1378 // and (4) normal important.
1425 applyMatchedProperties<HighPriorityProperties>(state, matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly); 1379 applyMatchedProperties<HighPropertyPriority>(state, matchResult, false, 0, m atchResult.matchedProperties.size() - 1, applyInheritedOnly);
1426 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherit edOnly); 1380 applyMatchedProperties<HighPropertyPriority>(state, matchResult, true, match Result.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherited Only);
1427 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); 1381 applyMatchedProperties<HighPropertyPriority>(state, matchResult, true, match Result.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
1428 1382
1429 if (UNLIKELY(isSVGForeignObjectElement(element))) { 1383 if (UNLIKELY(isSVGForeignObjectElement(element))) {
1430 // RenderSVGRoot handles zooming for the whole SVG subtree, so foreignOb ject content should not be scaled again. 1384 // RenderSVGRoot handles zooming for the whole SVG subtree, so foreignOb ject content should not be scaled again.
1431 // 1385 //
1432 // FIXME: The following hijacks the zoom property for foreignObject so t hat children of foreignObject get the 1386 // FIXME: The following hijacks the zoom property for foreignObject so t hat children of foreignObject get the
1433 // correct font-size in case of zooming. 'zoom' is part of HighPriorityP roperties, along with other font-related 1387 // correct font-size in case of zooming. 'zoom' has HighPropertyPriority , along with other font-related
1434 // properties used as input to the FontBuilder, so resetting it here may cause the FontBuilder to recompute the 1388 // properties used as input to the FontBuilder, so resetting it here may cause the FontBuilder to recompute the
1435 // font used as inheritable font for foreignObject content. If we want t o support zoom on foreignObject we'll 1389 // font used as inheritable font for foreignObject content. If we want t o support zoom on foreignObject we'll
1436 // need to find another way of handling the SVG zoom model. 1390 // need to find another way of handling the SVG zoom model.
1437 state.setEffectiveZoom(RenderStyle::initialZoom()); 1391 state.setEffectiveZoom(RenderStyle::initialZoom());
1438 } 1392 }
1439 1393
1440 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->effecti veZoom() != state.style()->effectiveZoom()) { 1394 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->effecti veZoom() != state.style()->effectiveZoom()) {
1441 state.fontBuilder().setFontDirty(true); 1395 state.fontBuilder().setFontDirty(true);
1442 applyInheritedOnly = false; 1396 applyInheritedOnly = false;
1443 } 1397 }
1444 1398
1445 // If our font got dirtied, go ahead and update it now. 1399 // If our font got dirtied, go ahead and update it now.
1446 updateFont(state); 1400 updateFont(state);
1447 1401
1448 // Many properties depend on the font. If it changes we just apply all prope rties. 1402 // Many properties depend on the font. If it changes we just apply all prope rties.
1449 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->fontDes cription() != state.style()->fontDescription()) 1403 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->fontDes cription() != state.style()->fontDescription())
1450 applyInheritedOnly = false; 1404 applyInheritedOnly = false;
1451 1405
1452 // Now do the normal priority UA properties. 1406 // Now do the normal priority UA properties.
1453 applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, mat chResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); 1407 applyMatchedProperties<LowPropertyPriority>(state, matchResult, false, match Result.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
1454 1408
1455 // Cache the UA properties to pass them to LayoutTheme in adjustRenderStyle. 1409 // Cache the UA properties to pass them to LayoutTheme in adjustRenderStyle.
1456 state.cacheUserAgentBorderAndBackground(); 1410 state.cacheUserAgentBorderAndBackground();
1457 1411
1458 // Now do the author and user normal priority properties and all the !import ant properties. 1412 // Now do the author and user normal priority properties and all the !import ant properties.
1459 applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, mat chResult.ranges.lastUARule + 1, matchResult.matchedProperties.size() - 1, applyI nheritedOnly); 1413 applyMatchedProperties<LowPropertyPriority>(state, matchResult, false, match Result.ranges.lastUARule + 1, matchResult.matchedProperties.size() - 1, applyInh eritedOnly);
1460 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc hResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherite dOnly); 1414 applyMatchedProperties<LowPropertyPriority>(state, matchResult, true, matchR esult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedO nly);
1461 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc hResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); 1415 applyMatchedProperties<LowPropertyPriority>(state, matchResult, true, matchR esult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
1462 1416
1463 loadPendingResources(state); 1417 loadPendingResources(state);
1464 1418
1465 if (!cachedMatchedProperties && cacheHash && MatchedPropertiesCache::isCache able(element, state.style(), state.parentStyle())) { 1419 if (!cachedMatchedProperties && cacheHash && MatchedPropertiesCache::isCache able(element, state.style(), state.parentStyle())) {
1466 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheAdded); 1420 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheAdded);
1467 m_matchedPropertiesCache.add(state.style(), state.parentStyle(), cacheHa sh, matchResult); 1421 m_matchedPropertiesCache.add(state.style(), state.parentStyle(), cacheHa sh, matchResult);
1468 } 1422 }
1469 1423
1470 ASSERT(!state.fontBuilder().fontDirty()); 1424 ASSERT(!state.fontBuilder().fontDirty());
1471 } 1425 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « Source/core/css/resolver/StyleResolver.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698