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

Side by Side Diff: third_party/WebKit/Source/core/css/SelectorChecker.cpp

Issue 2789363002: Styling slot fallback content with ::slotted()
Patch Set: clean up Created 3 years, 8 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 return context.element->parentElement(); 116 return context.element->parentElement();
117 } 117 }
118 118
119 // If context has scope, return slot that matches the scope, otherwise return 119 // If context has scope, return slot that matches the scope, otherwise return
120 // the assigned slot for scope-less matching of ::slotted pseudo element. 120 // the assigned slot for scope-less matching of ::slotted pseudo element.
121 static const HTMLSlotElement* FindSlotElementInScope( 121 static const HTMLSlotElement* FindSlotElementInScope(
122 const SelectorChecker::SelectorCheckingContext& context) { 122 const SelectorChecker::SelectorCheckingContext& context) {
123 if (!context.scope) 123 if (!context.scope)
124 return context.element->AssignedSlot(); 124 return context.element->AssignedSlot();
125 125
126 for (const HTMLSlotElement* slot = context.element->AssignedSlot(); slot; 126 const HTMLSlotElement* slot = context.element->AssignedSlot();
127 slot = slot->AssignedSlot()) { 127 if (!slot) {
hayato 2017/04/13 05:50:40 Looks the dupe of code. It would be better to extr
128 Element* parent = context.element->parentElement();
129 if (!parent || !isHTMLSlotElement(parent) ||
130 !toHTMLSlotElement(parent)->AssignedNodes().IsEmpty())
131 return nullptr;
132 slot = toHTMLSlotElement(parent);
133 }
134
135 // Find the slot element that matches the scope.
136 for (; slot; slot = slot->AssignedSlot()) {
128 if (slot->GetTreeScope() == context.scope->GetTreeScope()) 137 if (slot->GetTreeScope() == context.scope->GetTreeScope())
129 return slot; 138 return slot;
130 } 139 }
131 return nullptr; 140 return nullptr;
132 } 141 }
133 142
134 static bool ScopeContainsLastMatchedElement( 143 static bool ScopeContainsLastMatchedElement(
135 const SelectorChecker::SelectorCheckingContext& context) { 144 const SelectorChecker::SelectorCheckingContext& context) {
136 // If this context isn't scoped, skip checking. 145 // If this context isn't scoped, skip checking.
137 if (!context.scope) 146 if (!context.scope)
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1335 bool SelectorChecker::MatchesFocusPseudoClass(const Element& element) { 1344 bool SelectorChecker::MatchesFocusPseudoClass(const Element& element) {
1336 bool force_pseudo_state = false; 1345 bool force_pseudo_state = false;
1337 probe::forcePseudoState(const_cast<Element*>(&element), 1346 probe::forcePseudoState(const_cast<Element*>(&element),
1338 CSSSelector::kPseudoFocus, &force_pseudo_state); 1347 CSSSelector::kPseudoFocus, &force_pseudo_state);
1339 if (force_pseudo_state) 1348 if (force_pseudo_state)
1340 return true; 1349 return true;
1341 return element.IsFocused() && IsFrameFocused(element); 1350 return element.IsFocused() && IsFrameFocused(element);
1342 } 1351 }
1343 1352
1344 } // namespace blink 1353 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698