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

Unified Diff: Source/core/css/resolver/StyleResolver.cpp

Issue 24106007: Replace style sharing cousin list search with LRU (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updating with esprehn's changes Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/resolver/StyleResolver.h ('k') | Source/core/dom/Document.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/resolver/StyleResolver.cpp
diff --git a/Source/core/css/resolver/StyleResolver.cpp b/Source/core/css/resolver/StyleResolver.cpp
index 0119889f3c3ee12d64e40c84c0fa137036cc9228..cefc546cb48593a42fe93f8aa995a561749047f2 100644
--- a/Source/core/css/resolver/StyleResolver.cpp
+++ b/Source/core/css/resolver/StyleResolver.cpp
@@ -241,6 +241,60 @@ void StyleResolver::collectFeatures()
m_uncommonAttributeRuleSet = makeRuleSet(m_features.uncommonAttributeRules);
}
+bool StyleResolver::supportsStyleSharing(Element* element)
+{
+ if (!element || !element->isStyledElement() || !element->parentElement())
+ return false;
+
+ // If the element has inline style it is probably unique.
+ if (element->inlineStyle())
+ return false;
+ if (element->isSVGElement() && toSVGElement(element)->animatedSMILStyleProperties())
+ return false;
+ // Ids stop style sharing if they show up in the stylesheets.
+ if (element->hasID() && m_features.idsInRules.contains(element->idForStyleResolution().impl()))
+ return false;
+ // Active and hovered elements always make a chain towards the document node
+ // and no siblings or cousins will have the same state.
+ if (element->hovered())
+ return false;
+ if (element->active())
+ return false;
+ // There is always only one focused element.
+ if (element->focused())
+ return false;
+ if (element->parentElement()->hasFlagsSetDuringStylingOfChildren())
+ return false;
+ if (element->hasScopedHTMLStyleChild())
+ return false;
+ if (element == m_document.cssTarget())
+ return false;
+ if (element->isHTMLElement() && toHTMLElement(element)->hasDirectionAuto())
+ return false;
+ if (element->hasActiveAnimations())
+ return false;
+ // When a dialog is first shown, its style is mutated to center it in the
+ // viewport. So the styles can't be shared since the viewport position and
+ // size may be different each time a dialog is opened.
+ if (element->hasTagName(dialogTag))
+ return false;
+ if (isShadowHost(element) && element->shadow()->containsActiveStyles())
+ return false;
+ return true;
+}
+
+void StyleResolver::addToStyleSharingList(Element* element)
+{
+ if (m_styleSharingList.size() >= styleSharingListSize)
+ m_styleSharingList.remove(--m_styleSharingList.end());
+ m_styleSharingList.prepend(element);
+}
+
+void StyleResolver::clearStyleSharingList()
+{
+ m_styleSharingList.clear();
+}
+
void StyleResolver::pushParentElement(Element* parent)
{
ASSERT(parent);
« no previous file with comments | « Source/core/css/resolver/StyleResolver.h ('k') | Source/core/dom/Document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698