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

Unified Diff: sky/engine/core/css/resolver/SharedStyleFinder.cpp

Issue 796583002: Use the HashSet of attribute names in SharedStyleFinder. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Use C++11 loops. Created 6 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/engine/core/css/resolver/SharedStyleFinder.h ('k') | sky/engine/core/css/resolver/StyleResolver.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/core/css/resolver/SharedStyleFinder.cpp
diff --git a/sky/engine/core/css/resolver/SharedStyleFinder.cpp b/sky/engine/core/css/resolver/SharedStyleFinder.cpp
index 5f4ee61d7d4d403c57b3be2c146f403b1f3447cb..abdb826e085140b8af92ced551d671979d6d0ce5 100644
--- a/sky/engine/core/css/resolver/SharedStyleFinder.cpp
+++ b/sky/engine/core/css/resolver/SharedStyleFinder.cpp
@@ -48,8 +48,9 @@
namespace blink {
-bool SharedStyleFinder::classNamesAffectedByRules(const SpaceSplitString& classNames) const
+bool SharedStyleFinder::classNamesAffectedByRules(const Element& element) const
{
+ const SpaceSplitString& classNames = element.classNames();
unsigned count = classNames.size();
for (unsigned i = 0; i < count; ++i) {
if (m_features.hasSelectorForClass(classNames[i]))
@@ -58,6 +59,15 @@ bool SharedStyleFinder::classNamesAffectedByRules(const SpaceSplitString& classN
return false;
}
+bool SharedStyleFinder::attributesAffectedByRules(const Element& element) const
+{
+ for (auto& attribute : element.attributesWithoutUpdate()) {
+ if (m_features.hasSelectorForAttribute(attribute.localName()))
+ return true;
+ }
+ return false;
+}
+
bool SharedStyleFinder::sharingCandidateHasIdenticalStyleAffectingAttributes(Element& candidate) const
{
if (element().sharesSameElementData(candidate))
@@ -66,7 +76,7 @@ bool SharedStyleFinder::sharingCandidateHasIdenticalStyleAffectingAttributes(Ele
return false;
if (!m_elementAffectedByClassRules) {
- if (candidate.hasClass() && classNamesAffectedByRules(candidate.classNames()))
+ if (candidate.hasClass() && classNamesAffectedByRules(candidate))
return false;
} else if (candidate.hasClass()) {
if (element().classNames() != candidate.classNames())
@@ -176,14 +186,6 @@ inline Element* SharedStyleFinder::findElementForStyleSharing() const
return 0;
}
-bool SharedStyleFinder::matchesRuleSet(RuleSet* ruleSet)
-{
- if (!ruleSet)
- return false;
- ElementRuleCollector collector(m_context);
- return collector.hasAnyMatchingRules(ruleSet);
-}
-
RenderStyle* SharedStyleFinder::findSharedStyle()
{
INCREMENT_STYLE_STATS_COUNTER(m_styleResolver, sharedStyleLookups);
@@ -191,8 +193,13 @@ RenderStyle* SharedStyleFinder::findSharedStyle()
if (!element().supportsStyleSharing())
return 0;
+ if (attributesAffectedByRules(element())) {
+ INCREMENT_STYLE_STATS_COUNTER(m_styleResolver, sharedStyleRejectedByAttributeRules);
+ return 0;
+ }
+
// Cache whether context.element() is affected by any known class selectors.
- m_elementAffectedByClassRules = element().hasClass() && classNamesAffectedByRules(element().classNames());
+ m_elementAffectedByClassRules = element().hasClass() && classNamesAffectedByRules(element());
Element* shareElement = findElementForStyleSharing();
@@ -204,7 +211,7 @@ RenderStyle* SharedStyleFinder::findSharedStyle()
INCREMENT_STYLE_STATS_COUNTER(m_styleResolver, sharedStyleFound);
- if (matchesRuleSet(m_attributeRuleSet)) {
+ if (attributesAffectedByRules(*shareElement)) {
INCREMENT_STYLE_STATS_COUNTER(m_styleResolver, sharedStyleRejectedByAttributeRules);
return 0;
}
« no previous file with comments | « sky/engine/core/css/resolver/SharedStyleFinder.h ('k') | sky/engine/core/css/resolver/StyleResolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698