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

Side by Side Diff: third_party/WebKit/Source/core/css/SelectorChecker.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 unified diff | Download patch
OLDNEW
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // (a) context.element has the same treescope as context.scope, need to walk 107 // (a) context.element has the same treescope as context.scope, need to walk
108 // up to its shadow host. 108 // up to its shadow host.
109 // (b) Otherwise, should not walk up from a shadow root to a shadow host. 109 // (b) Otherwise, should not walk up from a shadow root to a shadow host.
110 if (context.scope && 110 if (context.scope &&
111 (context.scope == context.element->containingShadowRoot() || 111 (context.scope == context.element->containingShadowRoot() ||
112 context.scope->treeScope() == context.element->treeScope())) 112 context.scope->treeScope() == context.element->treeScope()))
113 return context.element->parentOrShadowHostElement(); 113 return context.element->parentOrShadowHostElement();
114 return context.element->parentElement(); 114 return context.element->parentElement();
115 } 115 }
116 116
117 // If context has scope, return slot that matches the scope, otherwise return
118 // the assigned slot for scope-less matching of ::slotted pseudo element.
117 static const HTMLSlotElement* findSlotElementInScope( 119 static const HTMLSlotElement* findSlotElementInScope(
118 const SelectorChecker::SelectorCheckingContext& context) { 120 const SelectorChecker::SelectorCheckingContext& context) {
119 if (!context.scope) 121 if (!context.scope)
120 return nullptr; 122 return context.element->assignedSlot();
rune 2017/01/11 11:34:27 Not sure I understand this one. This is fixing a k
kochi 2017/01/13 10:46:45 ElemenetRuleCollector::hasAnyMatchingRules() does
121 123
122 const HTMLSlotElement* slot = context.element->assignedSlot(); 124 for (const HTMLSlotElement* slot = context.element->assignedSlot(); slot;
123 while (slot) { 125 slot = slot->assignedSlot()) {
124 if (slot->treeScope() == context.scope->treeScope()) 126 if (slot->treeScope() == context.scope->treeScope())
125 return slot; 127 return slot;
126 slot = slot->assignedSlot();
127 } 128 }
128 return nullptr; 129 return nullptr;
129 } 130 }
130 131
131 static bool scopeContainsLastMatchedElement( 132 static bool scopeContainsLastMatchedElement(
132 const SelectorChecker::SelectorCheckingContext& context) { 133 const SelectorChecker::SelectorCheckingContext& context) {
133 // If this context isn't scoped, skip checking. 134 // If this context isn't scoped, skip checking.
134 if (!context.scope) 135 if (!context.scope)
135 return true; 136 return true;
136 137
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 } 1314 }
1314 1315
1315 bool SelectorChecker::matchesFocusPseudoClass(const Element& element) { 1316 bool SelectorChecker::matchesFocusPseudoClass(const Element& element) {
1316 if (InspectorInstrumentation::forcePseudoState(const_cast<Element*>(&element), 1317 if (InspectorInstrumentation::forcePseudoState(const_cast<Element*>(&element),
1317 CSSSelector::PseudoFocus)) 1318 CSSSelector::PseudoFocus))
1318 return true; 1319 return true;
1319 return element.isFocused() && isFrameFocused(element); 1320 return element.isFocused() && isFrameFocused(element);
1320 } 1321 }
1321 1322
1322 } // namespace blink 1323 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698