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

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

Issue 49093005: Fix memory error during selector matching due to getMatchedCSSRules. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 1 month 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 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 } 1144 }
1145 1145
1146 return false; 1146 return false;
1147 } 1147 }
1148 1148
1149 void StyleResolver::updateFont(StyleResolverState& state) 1149 void StyleResolver::updateFont(StyleResolverState& state)
1150 { 1150 {
1151 state.fontBuilder().createFont(m_fontSelector, state.parentStyle(), state.st yle()); 1151 state.fontBuilder().createFont(m_fontSelector, state.parentStyle(), state.st yle());
1152 } 1152 }
1153 1153
1154 PassRefPtr<CSSRuleList> StyleResolver::styleRulesForElement(Element* e, unsigned rulesToInclude) 1154 PassRefPtr<CSSRuleList> StyleResolver::styleRulesForElement(Element* e, unsigned rulesToInclude, ShouldIncludeStyleSheetInCSSOMWrapper includeDocument)
1155 { 1155 {
1156 return pseudoStyleRulesForElement(e, NOPSEUDO, rulesToInclude); 1156 return pseudoStyleRulesForElement(e, NOPSEUDO, rulesToInclude, includeDocume nt);
1157 } 1157 }
1158 1158
1159 PassRefPtr<CSSRuleList> StyleResolver::pseudoStyleRulesForElement(Element* e, Ps eudoId pseudoId, unsigned rulesToInclude) 1159 PassRefPtr<CSSRuleList> StyleResolver::pseudoStyleRulesForElement(Element* e, Ps eudoId pseudoId, unsigned rulesToInclude, ShouldIncludeStyleSheetInCSSOMWrapper includeDocument)
1160 { 1160 {
1161 if (!e || !e->document().haveStylesheetsLoaded()) 1161 if (!e || !e->document().haveStylesheetsLoaded())
1162 return 0; 1162 return 0;
1163 1163
1164 if (e == document().documentElement()) 1164 if (e == document().documentElement())
1165 resetDirectionAndWritingModeOnDocument(document()); 1165 resetDirectionAndWritingModeOnDocument(document());
1166 StyleResolverState state(document(), e); 1166 StyleResolverState state(document(), e);
1167 1167
1168 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta te.style()); 1168 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta te.style(), includeDocument);
1169 collector.setMode(SelectorChecker::CollectingRules); 1169 collector.setMode(SelectorChecker::CollectingRules);
1170 collector.setPseudoStyleRequest(PseudoStyleRequest(pseudoId)); 1170 collector.setPseudoStyleRequest(PseudoStyleRequest(pseudoId));
1171 1171
1172 if (rulesToInclude & UAAndUserCSSRules) { 1172 if (rulesToInclude & UAAndUserCSSRules) {
1173 // First we match rules from the user agent sheet. 1173 // First we match rules from the user agent sheet.
1174 matchUARules(collector); 1174 matchUARules(collector);
1175 1175
1176 // Now we check user sheet rules. 1176 // Now we check user sheet rules.
1177 if (m_matchAuthorAndUserStyles) 1177 if (m_matchAuthorAndUserStyles)
1178 matchUserRules(collector, rulesToInclude & EmptyCSSRules); 1178 matchUserRules(collector, rulesToInclude & EmptyCSSRules);
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1567 m_matchedPropertiesSearches, m_matchedPropertiesHit, m_matchedProperties SharedInheritedHit, m_matchedPropertiesToCache, m_matchedPropertiesEnteredIntoCa che); 1567 m_matchedPropertiesSearches, m_matchedPropertiesHit, m_matchedProperties SharedInheritedHit, m_matchedPropertiesToCache, m_matchedPropertiesEnteredIntoCa che);
1568 1568
1569 fprintf(stderr, "Total:\n"); 1569 fprintf(stderr, "Total:\n");
1570 printStyleStats(m_totalSearches, m_totalElementsEligibleForSharing, m_totalS tylesShared, m_totalSearchFoundSiblingForSharing, m_totalSearchesMissedSharing, 1570 printStyleStats(m_totalSearches, m_totalElementsEligibleForSharing, m_totalS tylesShared, m_totalSearchFoundSiblingForSharing, m_totalSearchesMissedSharing,
1571 m_totalMatchedPropertiesSearches, m_totalMatchedPropertiesHit, m_totalMa tchedPropertiesSharedInheritedHit, m_totalMatchedPropertiesToCache, m_totalMatch edPropertiesEnteredIntoCache); 1571 m_totalMatchedPropertiesSearches, m_totalMatchedPropertiesHit, m_totalMa tchedPropertiesSharedInheritedHit, m_totalMatchedPropertiesToCache, m_totalMatch edPropertiesEnteredIntoCache);
1572 fprintf(stderr, "----------------------------------------------------------- ---------------------\n"); 1572 fprintf(stderr, "----------------------------------------------------------- ---------------------\n");
1573 } 1573 }
1574 #endif 1574 #endif
1575 1575
1576 } // namespace WebCore 1576 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698