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

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

Issue 796713002: Turn StyleSharing to 11. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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.cpp » ('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 abdb826e085140b8af92ced551d671979d6d0ce5..67f52705bbae67b23aa140ac6d1418c6432d2107 100644
--- a/sky/engine/core/css/resolver/SharedStyleFinder.cpp
+++ b/sky/engine/core/css/resolver/SharedStyleFinder.cpp
@@ -102,60 +102,37 @@ bool SharedStyleFinder::sharingCandidateCanShareHostStyles(Element& candidate) c
return elementShadow->hasSameStyles(candidateShadow);
}
-bool SharedStyleFinder::sharingCandidateDistributedToSameInsertionPoint(Element& candidate) const
-{
- Vector<RawPtr<InsertionPoint>, 8> insertionPoints, candidateInsertionPoints;
- collectDestinationInsertionPoints(element(), insertionPoints);
- collectDestinationInsertionPoints(candidate, candidateInsertionPoints);
- if (insertionPoints.size() != candidateInsertionPoints.size())
- return false;
- for (size_t i = 0; i < insertionPoints.size(); ++i) {
- if (insertionPoints[i] != candidateInsertionPoints[i])
- return false;
- }
- return true;
-}
-
bool SharedStyleFinder::canShareStyleWithElement(Element& candidate) const
{
+ ASSERT(candidate.supportsStyleSharing());
+
if (element() == candidate)
return false;
- Element* parent = candidate.parentOrShadowHostElement();
+ if (candidate.tagQName() != element().tagQName())
+ return false;
+ if (candidate.needsStyleRecalc())
+ return false;
RenderStyle* style = candidate.renderStyle();
if (!style)
return false;
if (!style->isSharable())
return false;
+ ContainerNode* parent = NodeRenderingTraversal::parent(&candidate);
if (!parent)
return false;
- if (element().parentOrShadowHostElement()->renderStyle() != parent->renderStyle())
+ RenderStyle* parentStyle = parent->renderStyle();
+ if (!parentStyle)
return false;
- if (candidate.tagQName() != element().tagQName())
- return false;
- if (candidate.inlineStyle())
ojan 2014/12/11 19:35:54 Why don't we need this check? Where do we check th
esprehn 2014/12/11 23:09:58 supportsStyleSharing() contains this check, and we
- return false;
- if (candidate.needsStyleRecalc())
+ if (m_renderingParent->renderStyle()->inheritedNotEqual(parentStyle))
return false;
if (!sharingCandidateHasIdenticalStyleAffectingAttributes(candidate))
return false;
- if (candidate.hasID() && m_features.hasSelectorForId(candidate.idForStyleResolution()))
ojan 2014/12/11 19:35:54 Getting rid of this means we do less work on pages
esprehn 2014/12/11 23:09:59 This is also inside supportsStyleSharing().
- return false;
if (!sharingCandidateCanShareHostStyles(candidate))
return false;
- if (!sharingCandidateDistributedToSameInsertionPoint(candidate))
+ if (!candidate.treeScope().hasSameStyles(element().treeScope()))
return false;
if (candidate.isUnresolvedCustomElement() != element().isUnresolvedCustomElement())
return false;
-
- if (element().parentOrShadowHostElement() != parent) {
- if (!parent->isStyledElement())
- return false;
- if (parent->inlineStyle())
- return false;
- if (parent->hasID() && m_features.hasSelectorForId(parent->idForStyleResolution()))
- return false;
- }
-
return true;
}
@@ -200,6 +177,7 @@ RenderStyle* SharedStyleFinder::findSharedStyle()
// Cache whether context.element() is affected by any known class selectors.
m_elementAffectedByClassRules = element().hasClass() && classNamesAffectedByRules(element());
+ m_renderingParent = NodeRenderingTraversal::parent(&element());
Element* shareElement = findElementForStyleSharing();
« no previous file with comments | « sky/engine/core/css/resolver/SharedStyleFinder.h ('k') | sky/engine/core/css/resolver/StyleResolver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698