Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) | 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) |
| 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. |
| 6 * All rights reserved. | 6 * All rights reserved. |
| 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
| 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
| 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 10 * (http://www.torchmobile.com/) | 10 * (http://www.torchmobile.com/) |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 | 191 |
| 192 if (!elementShadow && !candidateShadow) | 192 if (!elementShadow && !candidateShadow) |
| 193 return true; | 193 return true; |
| 194 | 194 |
| 195 if (static_cast<bool>(elementShadow) != static_cast<bool>(candidateShadow)) | 195 if (static_cast<bool>(elementShadow) != static_cast<bool>(candidateShadow)) |
| 196 return false; | 196 return false; |
| 197 | 197 |
| 198 return elementShadow->hasSameStyles(*candidateShadow); | 198 return elementShadow->hasSameStyles(*candidateShadow); |
| 199 } | 199 } |
| 200 | 200 |
| 201 bool SharedStyleFinder::sharingCandidateAssignedToSameSlot( | |
| 202 Element& candidate) const { | |
| 203 HTMLSlotElement* slot1 = element().assignedSlot(); | |
| 204 HTMLSlotElement* slot2 = candidate.assignedSlot(); | |
| 205 return slot1 && slot2 && slot1 == slot2; | |
|
rune
2017/01/11 11:34:27
The most common case is that slot1 and slot2 are b
| |
| 206 } | |
| 207 | |
| 201 bool SharedStyleFinder::sharingCandidateDistributedToSameInsertionPoint( | 208 bool SharedStyleFinder::sharingCandidateDistributedToSameInsertionPoint( |
| 202 Element& candidate) const { | 209 Element& candidate) const { |
| 203 HeapVector<Member<InsertionPoint>, 8> insertionPoints, | 210 HeapVector<Member<InsertionPoint>, 8> insertionPoints, |
| 204 candidateInsertionPoints; | 211 candidateInsertionPoints; |
| 205 collectDestinationInsertionPoints(element(), insertionPoints); | 212 collectDestinationInsertionPoints(element(), insertionPoints); |
| 206 collectDestinationInsertionPoints(candidate, candidateInsertionPoints); | 213 collectDestinationInsertionPoints(candidate, candidateInsertionPoints); |
| 207 if (insertionPoints.size() != candidateInsertionPoints.size()) | 214 if (insertionPoints.size() != candidateInsertionPoints.size()) |
| 208 return false; | 215 return false; |
| 209 for (size_t i = 0; i < insertionPoints.size(); ++i) { | 216 for (size_t i = 0; i < insertionPoints.size(); ++i) { |
| 210 if (insertionPoints[i] != candidateInsertionPoints[i]) | 217 if (insertionPoints[i] != candidateInsertionPoints[i]) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 if (!sharingCandidateHasIdenticalStyleAffectingAttributes(candidate)) | 251 if (!sharingCandidateHasIdenticalStyleAffectingAttributes(candidate)) |
| 245 return false; | 252 return false; |
| 246 if (candidate.additionalPresentationAttributeStyle() != | 253 if (candidate.additionalPresentationAttributeStyle() != |
| 247 element().additionalPresentationAttributeStyle()) | 254 element().additionalPresentationAttributeStyle()) |
| 248 return false; | 255 return false; |
| 249 if (candidate.hasID() && | 256 if (candidate.hasID() && |
| 250 m_features.hasSelectorForId(candidate.idForStyleResolution())) | 257 m_features.hasSelectorForId(candidate.idForStyleResolution())) |
| 251 return false; | 258 return false; |
| 252 if (!sharingCandidateCanShareHostStyles(candidate)) | 259 if (!sharingCandidateCanShareHostStyles(candidate)) |
| 253 return false; | 260 return false; |
| 261 // For Shadow DOM V1 | |
| 262 if (!sharingCandidateAssignedToSameSlot(candidate)) | |
| 263 return false; | |
| 264 // For Shadow DOM V0 | |
| 254 if (!sharingCandidateDistributedToSameInsertionPoint(candidate)) | 265 if (!sharingCandidateDistributedToSameInsertionPoint(candidate)) |
| 255 return false; | 266 return false; |
| 256 if (candidate.isInTopLayer() != element().isInTopLayer()) | 267 if (candidate.isInTopLayer() != element().isInTopLayer()) |
| 257 return false; | 268 return false; |
| 258 | 269 |
| 259 bool isControl = candidate.isFormControlElement(); | 270 bool isControl = candidate.isFormControlElement(); |
| 260 ASSERT(isControl == element().isFormControlElement()); | 271 ASSERT(isControl == element().isFormControlElement()); |
| 261 if (isControl && !canShareStyleWithControl(candidate)) | 272 if (isControl && !canShareStyleWithControl(candidate)) |
| 262 return false; | 273 return false; |
| 263 | 274 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 384 if (!element().parentElementOrShadowRoot()->childrenSupportStyleSharing()) { | 395 if (!element().parentElementOrShadowRoot()->childrenSupportStyleSharing()) { |
| 385 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), | 396 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), |
| 386 sharedStyleRejectedByParent, 1); | 397 sharedStyleRejectedByParent, 1); |
| 387 return nullptr; | 398 return nullptr; |
| 388 } | 399 } |
| 389 | 400 |
| 390 return shareElement->mutableComputedStyle(); | 401 return shareElement->mutableComputedStyle(); |
| 391 } | 402 } |
| 392 | 403 |
| 393 } // namespace blink | 404 } // namespace blink |
| OLD | NEW |