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

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

Issue 29633003: Avoid style sharing with mis-matched descendant selectors (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 return ruleSet.release(); 260 return ruleSet.release();
261 } 261 }
262 262
263 void StyleResolver::collectFeatures() 263 void StyleResolver::collectFeatures()
264 { 264 {
265 m_features.clear(); 265 m_features.clear();
266 m_ruleSets.collectFeaturesTo(m_features, document().isViewSource()); 266 m_ruleSets.collectFeaturesTo(m_features, document().isViewSource());
267 m_styleTree.collectFeaturesTo(m_features); 267 m_styleTree.collectFeaturesTo(m_features);
268 268
269 m_siblingRuleSet = makeRuleSet(m_features.siblingRules); 269 m_siblingRuleSet = makeRuleSet(m_features.siblingRules);
270 m_descendantRuleSet = makeRuleSet(m_features.descendantRules);
270 m_uncommonAttributeRuleSet = makeRuleSet(m_features.uncommonAttributeRules); 271 m_uncommonAttributeRuleSet = makeRuleSet(m_features.uncommonAttributeRules);
271 } 272 }
272 273
273 bool StyleResolver::hasRulesForId(const AtomicString& id) const 274 bool StyleResolver::hasRulesForId(const AtomicString& id) const
274 { 275 {
275 return m_features.idsInRules.contains(id.impl()); 276 return m_features.idsInRules.contains(id.impl());
276 } 277 }
277 278
278 void StyleResolver::addToStyleSharingList(Element* element) 279 void StyleResolver::addToStyleSharingList(Element* element)
279 { 280 {
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 } 606 }
606 element->document().setHasNodesWithPlaceholderStyle(); 607 element->document().setHasNodesWithPlaceholderStyle();
607 return s_styleNotYetAvailable; 608 return s_styleNotYetAvailable;
608 } 609 }
609 610
610 if (element == document().documentElement()) 611 if (element == document().documentElement())
611 resetDirectionAndWritingModeOnDocument(document()); 612 resetDirectionAndWritingModeOnDocument(document());
612 StyleResolverState state(document(), element, defaultParent, regionForStylin g); 613 StyleResolverState state(document(), element, defaultParent, regionForStylin g);
613 614
614 if (sharingBehavior == AllowStyleSharing && !state.distributedToInsertionPoi nt() && state.parentStyle()) { 615 if (sharingBehavior == AllowStyleSharing && !state.distributedToInsertionPoi nt() && state.parentStyle()) {
615 SharedStyleFinder styleFinder(m_features, m_siblingRuleSet.get(), m_unco mmonAttributeRuleSet.get(), this); 616 SharedStyleFinder styleFinder(m_features, m_siblingRuleSet.get(), m_unco mmonAttributeRuleSet.get(), m_descendantRuleSet.get(), this);
616 RefPtr<RenderStyle> sharedStyle = styleFinder.locateSharedStyle(state.el ementContext()); 617 RefPtr<RenderStyle> sharedStyle = styleFinder.locateSharedStyle(state.el ementContext());
617 if (sharedStyle) 618 if (sharedStyle)
618 return sharedStyle.release(); 619 return sharedStyle.release();
619 } 620 }
620 621
621 if (state.parentStyle()) { 622 if (state.parentStyle()) {
622 state.setStyle(RenderStyle::create()); 623 state.setStyle(RenderStyle::create());
623 state.style()->inheritFrom(state.parentStyle(), isAtShadowBoundary(eleme nt) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary); 624 state.style()->inheritFrom(state.parentStyle(), isAtShadowBoundary(eleme nt) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary);
624 } else { 625 } else {
625 state.setStyle(defaultStyleForElement()); 626 state.setStyle(defaultStyleForElement());
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after
1597 m_matchedPropertiesSearches, m_matchedPropertiesHit, m_matchedProperties SharedInheritedHit, m_matchedPropertiesToCache, m_matchedPropertiesEnteredIntoCa che); 1598 m_matchedPropertiesSearches, m_matchedPropertiesHit, m_matchedProperties SharedInheritedHit, m_matchedPropertiesToCache, m_matchedPropertiesEnteredIntoCa che);
1598 1599
1599 fprintf(stderr, "Total:\n"); 1600 fprintf(stderr, "Total:\n");
1600 printStyleStats(m_totalSearches, m_totalElementsEligibleForSharing, m_totalS tylesShared, m_totalSearchFoundSiblingForSharing, m_totalSearchesMissedSharing, 1601 printStyleStats(m_totalSearches, m_totalElementsEligibleForSharing, m_totalS tylesShared, m_totalSearchFoundSiblingForSharing, m_totalSearchesMissedSharing,
1601 m_totalMatchedPropertiesSearches, m_totalMatchedPropertiesHit, m_totalMa tchedPropertiesSharedInheritedHit, m_totalMatchedPropertiesToCache, m_totalMatch edPropertiesEnteredIntoCache); 1602 m_totalMatchedPropertiesSearches, m_totalMatchedPropertiesHit, m_totalMa tchedPropertiesSharedInheritedHit, m_totalMatchedPropertiesToCache, m_totalMatch edPropertiesEnteredIntoCache);
1602 fprintf(stderr, "----------------------------------------------------------- ---------------------\n"); 1603 fprintf(stderr, "----------------------------------------------------------- ---------------------\n");
1603 } 1604 }
1604 #endif 1605 #endif
1605 1606
1606 } // namespace WebCore 1607 } // namespace WebCore
OLDNEW
« Source/core/css/resolver/SharedStyleFinder.cpp ('K') | « Source/core/css/resolver/StyleResolver.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698