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

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

Issue 166033005: Port Node's previousElementSibling() / nextElementSibling() to ElementTraversal (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 10 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
« no previous file with comments | « no previous file | Source/core/dom/Element.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 14 matching lines...) Expand all
25 * Boston, MA 02110-1301, USA. 25 * Boston, MA 02110-1301, USA.
26 */ 26 */
27 27
28 #include "config.h" 28 #include "config.h"
29 #include "core/css/SelectorChecker.h" 29 #include "core/css/SelectorChecker.h"
30 30
31 #include "HTMLNames.h" 31 #include "HTMLNames.h"
32 #include "core/css/CSSSelectorList.h" 32 #include "core/css/CSSSelectorList.h"
33 #include "core/css/SiblingTraversalStrategies.h" 33 #include "core/css/SiblingTraversalStrategies.h"
34 #include "core/dom/Document.h" 34 #include "core/dom/Document.h"
35 #include "core/dom/ElementTraversal.h"
35 #include "core/dom/FullscreenElementStack.h" 36 #include "core/dom/FullscreenElementStack.h"
36 #include "core/dom/NodeRenderStyle.h" 37 #include "core/dom/NodeRenderStyle.h"
37 #include "core/dom/Text.h" 38 #include "core/dom/Text.h"
38 #include "core/dom/shadow/InsertionPoint.h" 39 #include "core/dom/shadow/InsertionPoint.h"
39 #include "core/dom/shadow/ShadowRoot.h" 40 #include "core/dom/shadow/ShadowRoot.h"
40 #include "core/editing/FrameSelection.h" 41 #include "core/editing/FrameSelection.h"
41 #include "core/html/HTMLDocument.h" 42 #include "core/html/HTMLDocument.h"
42 #include "core/html/HTMLFrameElementBase.h" 43 #include "core/html/HTMLFrameElementBase.h"
43 #include "core/html/HTMLInputElement.h" 44 #include "core/html/HTMLInputElement.h"
44 #include "core/html/HTMLOptionElement.h" 45 #include "core/html/HTMLOptionElement.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 259
259 nextContext.isSubSelector = false; 260 nextContext.isSubSelector = false;
260 nextContext.elementStyle = 0; 261 nextContext.elementStyle = 0;
261 return match(nextContext, siblingTraversalStrategy, result); 262 return match(nextContext, siblingTraversalStrategy, result);
262 } 263 }
263 case CSSSelector::DirectAdjacent: 264 case CSSSelector::DirectAdjacent:
264 if (m_mode == ResolvingStyle) { 265 if (m_mode == ResolvingStyle) {
265 if (Element* parent = parentElement(context)) 266 if (Element* parent = parentElement(context))
266 parent->setChildrenAffectedByDirectAdjacentRules(); 267 parent->setChildrenAffectedByDirectAdjacentRules();
267 } 268 }
268 nextContext.element = context.element->previousElementSibling(); 269 nextContext.element = ElementTraversal::previousSibling(*context.element );
269 if (!nextContext.element) 270 if (!nextContext.element)
270 return SelectorFailsAllSiblings; 271 return SelectorFailsAllSiblings;
271 nextContext.isSubSelector = false; 272 nextContext.isSubSelector = false;
272 nextContext.elementStyle = 0; 273 nextContext.elementStyle = 0;
273 return match(nextContext, siblingTraversalStrategy, result); 274 return match(nextContext, siblingTraversalStrategy, result);
274 275
275 case CSSSelector::IndirectAdjacent: 276 case CSSSelector::IndirectAdjacent:
276 if (m_mode == ResolvingStyle) { 277 if (m_mode == ResolvingStyle) {
277 if (Element* parent = parentElement(context)) 278 if (Element* parent = parentElement(context))
278 parent->setChildrenAffectedByForwardPositionalRules(); 279 parent->setChildrenAffectedByForwardPositionalRules();
279 } 280 }
280 nextContext.element = context.element->previousElementSibling(); 281 nextContext.element = ElementTraversal::previousSibling(*context.element );
281 nextContext.isSubSelector = false; 282 nextContext.isSubSelector = false;
282 nextContext.elementStyle = 0; 283 nextContext.elementStyle = 0;
283 for (; nextContext.element; nextContext.element = nextContext.element->p reviousElementSibling()) { 284 for (; nextContext.element; nextContext.element = ElementTraversal::prev iousSibling(*nextContext.element)) {
284 Match match = this->match(nextContext, siblingTraversalStrategy, res ult); 285 Match match = this->match(nextContext, siblingTraversalStrategy, res ult);
285 if (match == SelectorMatches || match == SelectorFailsAllSiblings || match == SelectorFailsCompletely) 286 if (match == SelectorMatches || match == SelectorFailsAllSiblings || match == SelectorFailsCompletely)
286 return match; 287 return match;
287 }; 288 };
288 return SelectorFailsAllSiblings; 289 return SelectorFailsAllSiblings;
289 290
290 case CSSSelector::ShadowPseudo: 291 case CSSSelector::ShadowPseudo:
291 case CSSSelector::ChildTree: 292 case CSSSelector::ChildTree:
292 { 293 {
293 // If we're in the same tree-scope as the scoping element, then foll owing a shadow descendant combinator would escape that and thus the scope. 294 // If we're in the same tree-scope as the scoping element, then foll owing a shadow descendant combinator would escape that and thus the scope.
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 return element.focused() && isFrameFocused(element); 1074 return element.focused() && isFrameFocused(element);
1074 } 1075 }
1075 1076
1076 template 1077 template
1077 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co nst DOMSiblingTraversalStrategy&, MatchResult*) const; 1078 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co nst DOMSiblingTraversalStrategy&, MatchResult*) const;
1078 1079
1079 template 1080 template
1080 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co nst ShadowDOMSiblingTraversalStrategy&, MatchResult*) const; 1081 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co nst ShadowDOMSiblingTraversalStrategy&, MatchResult*) const;
1081 1082
1082 } 1083 }
OLDNEW
« no previous file with comments | « no previous file | Source/core/dom/Element.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698