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

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

Issue 1162583002: Use begin/end istead of first/last for rule ranges. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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
« 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 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 648
649 // Create the style 649 // Create the style
650 state.setStyle(ComputedStyle::clone(elementStyle)); 650 state.setStyle(ComputedStyle::clone(elementStyle));
651 651
652 // We don't need to bother with !important. Since there is only ever one 652 // We don't need to bother with !important. Since there is only ever one
653 // decl, there's nothing to override. So just add the first properties. 653 // decl, there's nothing to override. So just add the first properties.
654 // We also don't need to bother with animation properties since the only 654 // We also don't need to bother with animation properties since the only
655 // relevant one is animation-timing-function and we special-case that in 655 // relevant one is animation-timing-function and we special-case that in
656 // CSSAnimations.cpp 656 // CSSAnimations.cpp
657 bool inheritedOnly = false; 657 bool inheritedOnly = false;
658 applyMatchedProperties<HighPropertyPriority>(state, result, false, result.fi rstRule(), result.lastRule(), inheritedOnly); 658 applyMatchedProperties<HighPropertyPriority>(state, result, false, result.be gin(), result.end(), inheritedOnly);
659 659
660 // If our font got dirtied, go ahead and update it now. 660 // If our font got dirtied, go ahead and update it now.
661 updateFont(state); 661 updateFont(state);
662 662
663 // Now do rest of the properties. 663 // Now do rest of the properties.
664 applyMatchedProperties<LowPropertyPriority>(state, result, false, result.fir stRule(), result.lastRule(), inheritedOnly); 664 applyMatchedProperties<LowPropertyPriority>(state, result, false, result.beg in(), result.end(), inheritedOnly);
665 665
666 loadPendingResources(state); 666 loadPendingResources(state);
667 667
668 didAccess(); 668 didAccess();
669 669
670 return state.takeStyle(); 670 return state.takeStyle();
671 } 671 }
672 672
673 // This function is used by the WebAnimations JavaScript API method animate(). 673 // This function is used by the WebAnimations JavaScript API method animate().
674 // FIXME: Remove this when animate() switches away from resolution-dependent par sing. 674 // FIXME: Remove this when animate() switches away from resolution-dependent par sing.
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 PageRuleCollector collector(rootElementStyle, pageIndex); 843 PageRuleCollector collector(rootElementStyle, pageIndex);
844 844
845 collector.matchPageRules(CSSDefaultStyleSheets::instance().defaultPrintStyle ()); 845 collector.matchPageRules(CSSDefaultStyleSheets::instance().defaultPrintStyle ());
846 846
847 if (ScopedStyleResolver* scopedResolver = document().scopedStyleResolver()) 847 if (ScopedStyleResolver* scopedResolver = document().scopedStyleResolver())
848 scopedResolver->matchPageRules(collector); 848 scopedResolver->matchPageRules(collector);
849 849
850 bool inheritedOnly = false; 850 bool inheritedOnly = false;
851 851
852 const MatchResult& result = collector.matchedResult(); 852 const MatchResult& result = collector.matchedResult();
853 applyMatchedProperties<HighPropertyPriority>(state, result, false, result.fi rstRule(), result.lastRule(), inheritedOnly); 853 applyMatchedProperties<HighPropertyPriority>(state, result, false, result.be gin(), result.end(), inheritedOnly);
854 854
855 // If our font got dirtied, go ahead and update it now. 855 // If our font got dirtied, go ahead and update it now.
856 updateFont(state); 856 updateFont(state);
857 857
858 applyMatchedProperties<LowPropertyPriority>(state, result, false, result.fir stRule(), result.lastRule(), inheritedOnly); 858 applyMatchedProperties<LowPropertyPriority>(state, result, false, result.beg in(), result.end(), inheritedOnly);
859 859
860 loadPendingResources(state); 860 loadPendingResources(state);
861 861
862 didAccess(); 862 didAccess();
863 863
864 // Now return the style. 864 // Now return the style.
865 return state.takeStyle(); 865 return state.takeStyle();
866 } 866 }
867 867
868 PassRefPtr<ComputedStyle> StyleResolver::initialStyleForElement() 868 PassRefPtr<ComputedStyle> StyleResolver::initialStyleForElement()
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 } 1246 }
1247 1247
1248 if (!CSSPropertyPriorityData<priority>::propertyHasPriority(property)) 1248 if (!CSSPropertyPriorityData<priority>::propertyHasPriority(property))
1249 continue; 1249 continue;
1250 1250
1251 StyleBuilder::applyProperty(current.id(), state, current.value()); 1251 StyleBuilder::applyProperty(current.id(), state, current.value());
1252 } 1252 }
1253 } 1253 }
1254 1254
1255 template <CSSPropertyPriority priority> 1255 template <CSSPropertyPriority priority>
1256 void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc hResult& matchResult, bool isImportant, int startIndex, int endIndex, bool inher itedOnly) 1256 void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc hResult& matchResult, bool isImportant, unsigned startIndex, unsigned endIndex, bool inheritedOnly)
1257 { 1257 {
1258 if (startIndex == -1) 1258 if (startIndex == endIndex)
1259 return; 1259 return;
1260 1260
1261 ASSERT(startIndex >= 0 && endIndex < static_cast<int>(matchResult.matchedPro perties.size())); 1261 ASSERT_WITH_SECURITY_IMPLICATION(endIndex <= matchResult.matchedProperties.s ize());
1262 1262
1263 if (state.style()->insideLink() != NotInsideLink) { 1263 if (state.style()->insideLink() != NotInsideLink) {
1264 for (int i = startIndex; i <= endIndex; ++i) { 1264 for (unsigned i = startIndex; i < endIndex; ++i) {
1265 const MatchedProperties& matchedProperties = matchResult.matchedProp erties[i]; 1265 const MatchedProperties& matchedProperties = matchResult.matchedProp erties[i];
1266 unsigned linkMatchType = matchedProperties.m_types.linkMatchType; 1266 unsigned linkMatchType = matchedProperties.m_types.linkMatchType;
1267 // FIXME: It would be nicer to pass these as arguments but that requ ires changes in many places. 1267 // FIXME: It would be nicer to pass these as arguments but that requ ires changes in many places.
1268 state.setApplyPropertyToRegularStyle(linkMatchType & CSSSelector::Ma tchLink); 1268 state.setApplyPropertyToRegularStyle(linkMatchType & CSSSelector::Ma tchLink);
1269 state.setApplyPropertyToVisitedLinkStyle(linkMatchType & CSSSelector ::MatchVisited); 1269 state.setApplyPropertyToVisitedLinkStyle(linkMatchType & CSSSelector ::MatchVisited);
1270 1270
1271 applyProperties<priority>(state, matchedProperties.properties.get(), isImportant, inheritedOnly, static_cast<PropertyWhitelistType>(matchedPropertie s.m_types.whitelistType)); 1271 applyProperties<priority>(state, matchedProperties.properties.get(), isImportant, inheritedOnly, static_cast<PropertyWhitelistType>(matchedPropertie s.m_types.whitelistType));
1272 } 1272 }
1273 state.setApplyPropertyToRegularStyle(true); 1273 state.setApplyPropertyToRegularStyle(true);
1274 state.setApplyPropertyToVisitedLinkStyle(false); 1274 state.setApplyPropertyToVisitedLinkStyle(false);
1275 return; 1275 return;
1276 } 1276 }
1277 for (int i = startIndex; i <= endIndex; ++i) { 1277 for (unsigned i = startIndex; i < endIndex; ++i) {
1278 const MatchedProperties& matchedProperties = matchResult.matchedProperti es[i]; 1278 const MatchedProperties& matchedProperties = matchResult.matchedProperti es[i];
1279 applyProperties<priority>(state, matchedProperties.properties.get(), isI mportant, inheritedOnly, static_cast<PropertyWhitelistType>(matchedProperties.m_ types.whitelistType)); 1279 applyProperties<priority>(state, matchedProperties.properties.get(), isI mportant, inheritedOnly, static_cast<PropertyWhitelistType>(matchedProperties.m_ types.whitelistType));
1280 } 1280 }
1281 } 1281 }
1282 1282
1283 static unsigned computeMatchedPropertiesHash(const MatchedProperties* properties , unsigned size) 1283 static unsigned computeMatchedPropertiesHash(const MatchedProperties* properties , unsigned size)
1284 { 1284 {
1285 return StringHasher::hashMemory(properties, sizeof(MatchedProperties) * size ); 1285 return StringHasher::hashMemory(properties, sizeof(MatchedProperties) * size );
1286 } 1286 }
1287 1287
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 1329
1330 return; 1330 return;
1331 } 1331 }
1332 applyInheritedOnly = true; 1332 applyInheritedOnly = true;
1333 } 1333 }
1334 1334
1335 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply 1335 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply
1336 // high-priority properties first, i.e., those properties that other propert ies depend on. 1336 // high-priority properties first, i.e., those properties that other propert ies depend on.
1337 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important 1337 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important
1338 // and (4) normal important. 1338 // and (4) normal important.
1339 applyMatchedProperties<HighPropertyPriority>(state, matchResult, false, matc hResult.firstRule(), matchResult.lastRule(), applyInheritedOnly); 1339 applyMatchedProperties<HighPropertyPriority>(state, matchResult, false, matc hResult.begin(), matchResult.end(), applyInheritedOnly);
1340 applyMatchedProperties<HighPropertyPriority>(state, matchResult, true, match Result.firstAuthorRule(), matchResult.lastAuthorRule(), applyInheritedOnly); 1340 applyMatchedProperties<HighPropertyPriority>(state, matchResult, true, match Result.beginAuthor(), matchResult.endAuthor(), applyInheritedOnly);
1341 applyMatchedProperties<HighPropertyPriority>(state, matchResult, true, match Result.firstUARule(), matchResult.lastUARule(), applyInheritedOnly); 1341 applyMatchedProperties<HighPropertyPriority>(state, matchResult, true, match Result.beginUA(), matchResult.endUA(), applyInheritedOnly);
1342 1342
1343 if (UNLIKELY(isSVGForeignObjectElement(element))) { 1343 if (UNLIKELY(isSVGForeignObjectElement(element))) {
1344 // LayoutSVGRoot handles zooming for the whole SVG subtree, so foreignOb ject content should not be scaled again. 1344 // LayoutSVGRoot handles zooming for the whole SVG subtree, so foreignOb ject content should not be scaled again.
1345 // 1345 //
1346 // FIXME: The following hijacks the zoom property for foreignObject so t hat children of foreignObject get the 1346 // FIXME: The following hijacks the zoom property for foreignObject so t hat children of foreignObject get the
1347 // correct font-size in case of zooming. 'zoom' has HighPropertyPriority , along with other font-related 1347 // correct font-size in case of zooming. 'zoom' has HighPropertyPriority , along with other font-related
1348 // properties used as input to the FontBuilder, so resetting it here may cause the FontBuilder to recompute the 1348 // properties used as input to the FontBuilder, so resetting it here may cause the FontBuilder to recompute the
1349 // font used as inheritable font for foreignObject content. If we want t o support zoom on foreignObject we'll 1349 // font used as inheritable font for foreignObject content. If we want t o support zoom on foreignObject we'll
1350 // need to find another way of handling the SVG zoom model. 1350 // need to find another way of handling the SVG zoom model.
1351 state.setEffectiveZoom(ComputedStyle::initialZoom()); 1351 state.setEffectiveZoom(ComputedStyle::initialZoom());
1352 } 1352 }
1353 1353
1354 if (cachedMatchedProperties && cachedMatchedProperties->computedStyle->effec tiveZoom() != state.style()->effectiveZoom()) { 1354 if (cachedMatchedProperties && cachedMatchedProperties->computedStyle->effec tiveZoom() != state.style()->effectiveZoom()) {
1355 state.fontBuilder().didChangeEffectiveZoom(); 1355 state.fontBuilder().didChangeEffectiveZoom();
1356 applyInheritedOnly = false; 1356 applyInheritedOnly = false;
1357 } 1357 }
1358 1358
1359 // If our font got dirtied, go ahead and update it now. 1359 // If our font got dirtied, go ahead and update it now.
1360 updateFont(state); 1360 updateFont(state);
1361 1361
1362 // Many properties depend on the font. If it changes we just apply all prope rties. 1362 // Many properties depend on the font. If it changes we just apply all prope rties.
1363 if (cachedMatchedProperties && cachedMatchedProperties->computedStyle->fontD escription() != state.style()->fontDescription()) 1363 if (cachedMatchedProperties && cachedMatchedProperties->computedStyle->fontD escription() != state.style()->fontDescription())
1364 applyInheritedOnly = false; 1364 applyInheritedOnly = false;
1365 1365
1366 // Now do the normal priority UA properties. 1366 // Now do the normal priority UA properties.
1367 applyMatchedProperties<LowPropertyPriority>(state, matchResult, false, match Result.firstUARule(), matchResult.lastUARule(), applyInheritedOnly); 1367 applyMatchedProperties<LowPropertyPriority>(state, matchResult, false, match Result.beginUA(), matchResult.endUA(), applyInheritedOnly);
1368 1368
1369 // Cache the UA properties to pass them to LayoutTheme in adjustComputedStyl e. 1369 // Cache the UA properties to pass them to LayoutTheme in adjustComputedStyl e.
1370 state.cacheUserAgentBorderAndBackground(); 1370 state.cacheUserAgentBorderAndBackground();
1371 1371
1372 // Now do the author and user normal priority properties and all the !import ant properties. 1372 // Now do the author and user normal priority properties and all the !import ant properties.
1373 applyMatchedProperties<LowPropertyPriority>(state, matchResult, false, match Result.firstAuthorRule(), matchResult.lastAuthorRule(), applyInheritedOnly); 1373 applyMatchedProperties<LowPropertyPriority>(state, matchResult, false, match Result.beginAuthor(), matchResult.endAuthor(), applyInheritedOnly);
1374 applyMatchedProperties<LowPropertyPriority>(state, matchResult, true, matchR esult.firstAuthorRule(), matchResult.lastAuthorRule(), applyInheritedOnly); 1374 applyMatchedProperties<LowPropertyPriority>(state, matchResult, true, matchR esult.beginAuthor(), matchResult.endAuthor(), applyInheritedOnly);
1375 applyMatchedProperties<LowPropertyPriority>(state, matchResult, true, matchR esult.firstUARule(), matchResult.lastUARule(), applyInheritedOnly); 1375 applyMatchedProperties<LowPropertyPriority>(state, matchResult, true, matchR esult.beginUA(), matchResult.endUA(), applyInheritedOnly);
1376 1376
1377 loadPendingResources(state); 1377 loadPendingResources(state);
1378 1378
1379 if (!cachedMatchedProperties && cacheHash && MatchedPropertiesCache::isCache able(element, *state.style(), *state.parentStyle())) { 1379 if (!cachedMatchedProperties && cacheHash && MatchedPropertiesCache::isCache able(element, *state.style(), *state.parentStyle())) {
1380 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheAdded); 1380 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheAdded);
1381 m_matchedPropertiesCache.add(*state.style(), *state.parentStyle(), cache Hash, matchResult); 1381 m_matchedPropertiesCache.add(*state.style(), *state.parentStyle(), cache Hash, matchResult);
1382 } 1382 }
1383 1383
1384 ASSERT(!state.fontBuilder().fontDirty()); 1384 ASSERT(!state.fontBuilder().fontDirty());
1385 } 1385 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1483 visitor->trace(m_watchedSelectorsRules); 1483 visitor->trace(m_watchedSelectorsRules);
1484 visitor->trace(m_treeBoundaryCrossingRules); 1484 visitor->trace(m_treeBoundaryCrossingRules);
1485 visitor->trace(m_styleResourceLoader); 1485 visitor->trace(m_styleResourceLoader);
1486 visitor->trace(m_styleSharingLists); 1486 visitor->trace(m_styleSharingLists);
1487 visitor->trace(m_pendingStyleSheets); 1487 visitor->trace(m_pendingStyleSheets);
1488 visitor->trace(m_document); 1488 visitor->trace(m_document);
1489 #endif 1489 #endif
1490 } 1490 }
1491 1491
1492 } // namespace blink 1492 } // 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