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

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

Issue 2613213002: Support Style Sharing for Shadow DOM V1 (Closed)
Patch Set: improve check Created 3 years, 11 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
Index: third_party/WebKit/Source/core/css/resolver/SharedStyleFinder.cpp
diff --git a/third_party/WebKit/Source/core/css/resolver/SharedStyleFinder.cpp b/third_party/WebKit/Source/core/css/resolver/SharedStyleFinder.cpp
index 842676fb717292ef5d9e3a5e5a3593b4f4c2d903..7cf33826a864486c11d433f0b03da1c9ea904fa3 100644
--- a/third_party/WebKit/Source/core/css/resolver/SharedStyleFinder.cpp
+++ b/third_party/WebKit/Source/core/css/resolver/SharedStyleFinder.cpp
@@ -198,6 +198,13 @@ bool SharedStyleFinder::sharingCandidateCanShareHostStyles(
return elementShadow->hasSameStyles(*candidateShadow);
}
+bool SharedStyleFinder::sharingCandidateAssignedToSameSlot(
+ Element& candidate) const {
+ HTMLSlotElement* slot1 = element().assignedSlot();
+ HTMLSlotElement* slot2 = candidate.assignedSlot();
+ return slot1 && slot2 && slot1 == slot2;
rune 2017/01/11 11:34:27 The most common case is that slot1 and slot2 are b
+}
+
bool SharedStyleFinder::sharingCandidateDistributedToSameInsertionPoint(
Element& candidate) const {
HeapVector<Member<InsertionPoint>, 8> insertionPoints,
@@ -251,6 +258,10 @@ bool SharedStyleFinder::canShareStyleWithElement(Element& candidate) const {
return false;
if (!sharingCandidateCanShareHostStyles(candidate))
return false;
+ // For Shadow DOM V1
+ if (!sharingCandidateAssignedToSameSlot(candidate))
+ return false;
+ // For Shadow DOM V0
if (!sharingCandidateDistributedToSameInsertionPoint(candidate))
return false;
if (candidate.isInTopLayer() != element().isInTopLayer())

Powered by Google App Engine
This is Rietveld 408576698