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

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

Issue 21049007: DevTools: Drop CSS Selector Profiler (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove forgotten test Created 7 years, 4 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/ElementRuleCollector.cpp ('k') | Source/core/inspector/InspectorCSSAgent.h » ('j') | 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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 if (state.element()->hasActiveAnimations()) 435 if (state.element()->hasActiveAnimations())
436 collector.matchedResult().isCacheable = false; 436 collector.matchedResult().isCacheable = false;
437 } 437 }
438 } 438 }
439 439
440 bool StyleResolver::styleSharingCandidateMatchesRuleSet(const ElementResolveCont ext& context, RenderStyle* style, RuleSet* ruleSet) 440 bool StyleResolver::styleSharingCandidateMatchesRuleSet(const ElementResolveCont ext& context, RenderStyle* style, RuleSet* ruleSet)
441 { 441 {
442 if (!ruleSet) 442 if (!ruleSet)
443 return false; 443 return false;
444 444
445 ElementRuleCollector collector(context, m_selectorFilter, style, m_inspector CSSOMWrappers); 445 ElementRuleCollector collector(context, m_selectorFilter, style);
446 return collector.hasAnyMatchingRules(ruleSet); 446 return collector.hasAnyMatchingRules(ruleSet);
447 } 447 }
448 448
449 PassRefPtr<RenderStyle> StyleResolver::styleForDocument(const Document* document , CSSFontSelector* fontSelector) 449 PassRefPtr<RenderStyle> StyleResolver::styleForDocument(const Document* document , CSSFontSelector* fontSelector)
450 { 450 {
451 const Frame* frame = document->frame(); 451 const Frame* frame = document->frame();
452 452
453 // HTML5 states that seamless iframes should replace default CSS values 453 // HTML5 states that seamless iframes should replace default CSS values
454 // with values inherited from the containing iframe element. However, 454 // with values inherited from the containing iframe element. However,
455 // some values (such as the case of designMode = "on") still need to 455 // some values (such as the case of designMode = "on") still need to
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 } 590 }
591 591
592 bool needsCollection = false; 592 bool needsCollection = false;
593 CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement(element, needsColl ection); 593 CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement(element, needsColl ection);
594 if (needsCollection) { 594 if (needsCollection) {
595 collectFeatures(); 595 collectFeatures();
596 m_inspectorCSSOMWrappers.reset(); 596 m_inspectorCSSOMWrappers.reset();
597 } 597 }
598 598
599 { 599 {
600 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, state.style(), m_inspectorCSSOMWrappers); 600 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, state.style());
601 collector.setRegionForStyling(regionForStyling); 601 collector.setRegionForStyling(regionForStyling);
602 602
603 if (matchingBehavior == MatchOnlyUserAgentRules) 603 if (matchingBehavior == MatchOnlyUserAgentRules)
604 matchUARules(collector); 604 matchUARules(collector);
605 else 605 else
606 matchAllRules(state, collector, m_matchAuthorAndUserStyles, matching Behavior != MatchAllRulesExcludingSMIL); 606 matchAllRules(state, collector, m_matchAuthorAndUserStyles, matching Behavior != MatchAllRulesExcludingSMIL);
607 607
608 applyMatchedProperties(state, collector.matchedResult()); 608 applyMatchedProperties(state, collector.matchedResult());
609 } 609 }
610 { 610 {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 state.setParentStyle(RenderStyle::clone(state.style())); 779 state.setParentStyle(RenderStyle::clone(state.style()));
780 } 780 }
781 781
782 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta te.useSVGZoomRules()); 782 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta te.useSVGZoomRules());
783 783
784 // Since we don't use pseudo-elements in any of our quirk/print 784 // Since we don't use pseudo-elements in any of our quirk/print
785 // user agent rules, don't waste time walking those rules. 785 // user agent rules, don't waste time walking those rules.
786 786
787 { 787 {
788 // Check UA, user and author rules. 788 // Check UA, user and author rules.
789 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta te.style(), m_inspectorCSSOMWrappers); 789 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta te.style());
790 collector.setPseudoStyleRequest(pseudoStyleRequest); 790 collector.setPseudoStyleRequest(pseudoStyleRequest);
791 791
792 matchUARules(collector); 792 matchUARules(collector);
793 if (m_matchAuthorAndUserStyles) { 793 if (m_matchAuthorAndUserStyles) {
794 matchUserRules(collector, false); 794 matchUserRules(collector, false);
795 matchAuthorRules(state.element(), collector, false); 795 matchAuthorRules(state.element(), collector, false);
796 } 796 }
797 797
798 if (collector.matchedResult().matchedProperties.isEmpty()) 798 if (collector.matchedResult().matchedProperties.isEmpty())
799 return 0; 799 return 0;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 942
943 PassRefPtr<CSSRuleList> StyleResolver::pseudoStyleRulesForElement(Element* e, Ps eudoId pseudoId, unsigned rulesToInclude) 943 PassRefPtr<CSSRuleList> StyleResolver::pseudoStyleRulesForElement(Element* e, Ps eudoId pseudoId, unsigned rulesToInclude)
944 { 944 {
945 if (!e || !e->document()->haveStylesheetsLoaded()) 945 if (!e || !e->document()->haveStylesheetsLoaded())
946 return 0; 946 return 0;
947 947
948 if (e == document()->documentElement()) 948 if (e == document()->documentElement())
949 resetDirectionAndWritingModeOnDocument(document()); 949 resetDirectionAndWritingModeOnDocument(document());
950 StyleResolverState state(document(), e); 950 StyleResolverState state(document(), e);
951 951
952 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta te.style(), m_inspectorCSSOMWrappers); 952 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta te.style());
953 collector.setMode(SelectorChecker::CollectingRules); 953 collector.setMode(SelectorChecker::CollectingRules);
954 collector.setPseudoStyleRequest(PseudoStyleRequest(pseudoId)); 954 collector.setPseudoStyleRequest(PseudoStyleRequest(pseudoId));
955 955
956 if (rulesToInclude & UAAndUserCSSRules) { 956 if (rulesToInclude & UAAndUserCSSRules) {
957 // First we match rules from the user agent sheet. 957 // First we match rules from the user agent sheet.
958 matchUARules(collector); 958 matchUARules(collector);
959 959
960 // Now we check user sheet rules. 960 // Now we check user sheet rules.
961 if (m_matchAuthorAndUserStyles) 961 if (m_matchAuthorAndUserStyles)
962 matchUserRules(collector, rulesToInclude & EmptyCSSRules); 962 matchUserRules(collector, rulesToInclude & EmptyCSSRules);
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 return property > lastHighPriorityProperty; 1115 return property > lastHighPriorityProperty;
1116 } 1116 }
1117 ASSERT_NOT_REACHED(); 1117 ASSERT_NOT_REACHED();
1118 return false; 1118 return false;
1119 } 1119 }
1120 1120
1121 template <StyleResolver::StyleApplicationPass pass> 1121 template <StyleResolver::StyleApplicationPass pass>
1122 void StyleResolver::applyProperties(StyleResolverState& state, const StyleProper tySet* properties, StyleRule* rule, bool isImportant, bool inheritedOnly, Proper tyWhitelistType propertyWhitelistType) 1122 void StyleResolver::applyProperties(StyleResolverState& state, const StyleProper tySet* properties, StyleRule* rule, bool isImportant, bool inheritedOnly, Proper tyWhitelistType propertyWhitelistType)
1123 { 1123 {
1124 ASSERT((propertyWhitelistType != PropertyWhitelistRegion) || state.regionFor Styling()); 1124 ASSERT((propertyWhitelistType != PropertyWhitelistRegion) || state.regionFor Styling());
1125 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willProces sRule(document(), rule, this);
1126 1125
1127 unsigned propertyCount = properties->propertyCount(); 1126 unsigned propertyCount = properties->propertyCount();
1128 for (unsigned i = 0; i < propertyCount; ++i) { 1127 for (unsigned i = 0; i < propertyCount; ++i) {
1129 StylePropertySet::PropertyReference current = properties->propertyAt(i); 1128 StylePropertySet::PropertyReference current = properties->propertyAt(i);
1130 if (isImportant != current.isImportant()) 1129 if (isImportant != current.isImportant())
1131 continue; 1130 continue;
1132 if (inheritedOnly && !current.isInherited()) { 1131 if (inheritedOnly && !current.isInherited()) {
1133 // If the property value is explicitly inherited, we need to apply f urther non-inherited properties 1132 // If the property value is explicitly inherited, we need to apply f urther non-inherited properties
1134 // as they might override the value inherited here. For this reason we don't allow declarations with 1133 // as they might override the value inherited here. For this reason we don't allow declarations with
1135 // explicitly inherited properties to be cached. 1134 // explicitly inherited properties to be cached.
1136 ASSERT(!current.value()->isInheritedValue()); 1135 ASSERT(!current.value()->isInheritedValue());
1137 continue; 1136 continue;
1138 } 1137 }
1139 CSSPropertyID property = current.id(); 1138 CSSPropertyID property = current.id();
1140 1139
1141 if (propertyWhitelistType == PropertyWhitelistRegion && !isValidRegionSt yleProperty(property)) 1140 if (propertyWhitelistType == PropertyWhitelistRegion && !isValidRegionSt yleProperty(property))
1142 continue; 1141 continue;
1143 if (propertyWhitelistType == PropertyWhitelistCue && !isValidCueStylePro perty(property)) 1142 if (propertyWhitelistType == PropertyWhitelistCue && !isValidCueStylePro perty(property))
1144 continue; 1143 continue;
1145 if (!isPropertyForPass<pass>(property)) 1144 if (!isPropertyForPass<pass>(property))
1146 continue; 1145 continue;
1147 if (pass == HighPriorityProperties && property == CSSPropertyLineHeight) 1146 if (pass == HighPriorityProperties && property == CSSPropertyLineHeight)
1148 state.setLineHeightValue(current.value()); 1147 state.setLineHeightValue(current.value());
1149 else 1148 else
1150 applyProperty(state, current.id(), current.value()); 1149 applyProperty(state, current.id(), current.value());
1151 } 1150 }
1152 InspectorInstrumentation::didProcessRule(cookie);
1153 } 1151 }
1154 1152
1155 template <StyleResolver::StyleApplicationPass pass> 1153 template <StyleResolver::StyleApplicationPass pass>
1156 void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc hResult& matchResult, bool isImportant, int startIndex, int endIndex, bool inher itedOnly) 1154 void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc hResult& matchResult, bool isImportant, int startIndex, int endIndex, bool inher itedOnly)
1157 { 1155 {
1158 if (startIndex == -1) 1156 if (startIndex == -1)
1159 return; 1157 return;
1160 1158
1161 if (state.style()->insideLink() != NotInsideLink) { 1159 if (state.style()->insideLink() != NotInsideLink) {
1162 for (int i = startIndex; i <= endIndex; ++i) { 1160 for (int i = startIndex; i <= endIndex; ++i) {
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1460 m_matchedPropertiesSearches, m_matchedPropertiesHit, m_matchedProperties SharedInheritedHit, m_matchedPropertiesToCache, m_matchedPropertiesEnteredIntoCa che); 1458 m_matchedPropertiesSearches, m_matchedPropertiesHit, m_matchedProperties SharedInheritedHit, m_matchedPropertiesToCache, m_matchedPropertiesEnteredIntoCa che);
1461 1459
1462 fprintf(stderr, "Total:\n"); 1460 fprintf(stderr, "Total:\n");
1463 printStyleStats(m_totalSearches, m_totalElementsEligibleForSharing, m_totalS tylesShared, m_totalSearchFoundSiblingForSharing, m_totalSearchesMissedSharing, 1461 printStyleStats(m_totalSearches, m_totalElementsEligibleForSharing, m_totalS tylesShared, m_totalSearchFoundSiblingForSharing, m_totalSearchesMissedSharing,
1464 m_totalMatchedPropertiesSearches, m_totalMatchedPropertiesHit, m_totalMa tchedPropertiesSharedInheritedHit, m_totalMatchedPropertiesToCache, m_totalMatch edPropertiesEnteredIntoCache); 1462 m_totalMatchedPropertiesSearches, m_totalMatchedPropertiesHit, m_totalMa tchedPropertiesSharedInheritedHit, m_totalMatchedPropertiesToCache, m_totalMatch edPropertiesEnteredIntoCache);
1465 fprintf(stderr, "----------------------------------------------------------- ---------------------\n"); 1463 fprintf(stderr, "----------------------------------------------------------- ---------------------\n");
1466 } 1464 }
1467 #endif 1465 #endif
1468 1466
1469 } // namespace WebCore 1467 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/ElementRuleCollector.cpp ('k') | Source/core/inspector/InspectorCSSAgent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698