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

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

Issue 30453002: Should not allow style sharing if grandparents matches different rule chain (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@build_hack
Patch Set: same as patchset 2, rebased. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/fast/css/style-sharing-grand-parent-invalidate-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/resolver/SharedStyleFinder.cpp
diff --git a/Source/core/css/resolver/SharedStyleFinder.cpp b/Source/core/css/resolver/SharedStyleFinder.cpp
index 3d6bd946ede52f6d8b674ec735b5c636ba0ee670..cabed4465bce686b0a26e5aed455c541ae1b393b 100644
--- a/Source/core/css/resolver/SharedStyleFinder.cpp
+++ b/Source/core/css/resolver/SharedStyleFinder.cpp
@@ -157,6 +157,19 @@ bool SharedStyleFinder::sharingCandidateHasIdenticalStyleAffectingAttributes(Ele
return true;
}
+static bool ancestorChainAllShareStyle(Element* parentA, Element* parentB)
+{
+ while (parentA != parentB) {
+ ASSERT(parentA && parentB);
+ if (parentA->renderStyle() != parentB->renderStyle())
+ return false;
+
+ parentA = parentA->parentElement();
+ parentB = parentB->parentElement();
esprehn 2013/10/19 09:10:09 I don't think this is safe. If parentA has a null
+ }
+ return true;
+}
+
bool SharedStyleFinder::canShareStyleWithElement(Element& candidate) const
{
if (element() == candidate)
@@ -167,7 +180,7 @@ bool SharedStyleFinder::canShareStyleWithElement(Element& candidate) const
return false;
if (!parent)
return false;
- if (element().parentElement()->renderStyle() != parent->renderStyle())
+ if (!ancestorChainAllShareStyle(element().parentElement(), parent))
return false;
if (style->unique())
return false;
« no previous file with comments | « LayoutTests/fast/css/style-sharing-grand-parent-invalidate-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698