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

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

Issue 1496533003: Implement a simple version of SelectorQuery. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert change to SelectorFilter.h Created 5 years 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. All rights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 { 208 {
209 if (NthIndexCache* nthIndexCache = element.document().nthIndexCache()) 209 if (NthIndexCache* nthIndexCache = element.document().nthIndexCache())
210 return nthIndexCache->nthLastChildIndexOfType(element, type); 210 return nthIndexCache->nthLastChildIndexOfType(element, type);
211 211
212 int index = 1; 212 int index = 1;
213 for (const Element* sibling = ElementTraversal::nextSibling(element, HasTagN ame(type)); sibling; sibling = ElementTraversal::nextSibling(*sibling, HasTagNam e(type))) 213 for (const Element* sibling = ElementTraversal::nextSibling(element, HasTagN ame(type)); sibling; sibling = ElementTraversal::nextSibling(*sibling, HasTagNam e(type)))
214 ++index; 214 ++index;
215 return index; 215 return index;
216 } 216 }
217 217
218 bool SelectorChecker::match(const SelectorCheckingContext& context, MatchResult& result) const
219 {
220 ASSERT(context.selector);
221 return matchSelector(context, result) == SelectorMatches;
222 }
223
224 bool SelectorChecker::match(const SelectorCheckingContext& context) const
225 {
226 MatchResult ignoreResult;
227 return match(context, ignoreResult);
228 }
229
230 // Recursive check of selectors and combinators 218 // Recursive check of selectors and combinators
231 // It can return 4 different values: 219 // It can return 4 different values:
232 // * SelectorMatches - the selector matches the element e 220 // * SelectorMatches - the selector matches the element e
233 // * SelectorFailsLocally - the selector fails for the element e 221 // * SelectorFailsLocally - the selector fails for the element e
234 // * SelectorFailsAllSiblings - the selector fails for e and any sibling of e 222 // * SelectorFailsAllSiblings - the selector fails for e and any sibling of e
235 // * SelectorFailsCompletely - the selector fails for e and any sibling or ance stor of e 223 // * SelectorFailsCompletely - the selector fails for e and any sibling or ance stor of e
236 SelectorChecker::Match SelectorChecker::matchSelector(const SelectorCheckingCont ext& context, MatchResult& result) const 224 SelectorChecker::Match SelectorChecker::matchSelector(const SelectorCheckingCont ext& context, MatchResult& result) const
237 { 225 {
238 MatchResult subResult; 226 MatchResult subResult;
239 if (!checkOne(context, subResult)) 227 if (!checkOne(context, subResult))
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 } 1179 }
1192 1180
1193 bool SelectorChecker::matchesFocusPseudoClass(const Element& element) 1181 bool SelectorChecker::matchesFocusPseudoClass(const Element& element)
1194 { 1182 {
1195 if (InspectorInstrumentation::forcePseudoState(const_cast<Element*>(&element ), CSSSelector::PseudoFocus)) 1183 if (InspectorInstrumentation::forcePseudoState(const_cast<Element*>(&element ), CSSSelector::PseudoFocus))
1196 return true; 1184 return true;
1197 return element.focused() && isFrameFocused(element); 1185 return element.focused() && isFrameFocused(element);
1198 } 1186 }
1199 1187
1200 } 1188 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/SelectorChecker.h ('k') | third_party/WebKit/Source/core/dom/SelectorQuery.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698