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

Side by Side Diff: Source/core/dom/ContainerNode.h

Issue 425383002: Move highestAncestorOrSelf() from Node to NodeTraversal (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/core/dom/Node.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) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2013 Apple Inc. All r ights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2013 Apple Inc. All r ights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 return toContainerNode(this)->firstChild(); 288 return toContainerNode(this)->firstChild();
289 } 289 }
290 290
291 inline Node* Node::lastChild() const 291 inline Node* Node::lastChild() const
292 { 292 {
293 if (!isContainerNode()) 293 if (!isContainerNode())
294 return 0; 294 return 0;
295 return toContainerNode(this)->lastChild(); 295 return toContainerNode(this)->lastChild();
296 } 296 }
297 297
298 inline Node& Node::highestAncestorOrSelf() const
299 {
300 Node* node = const_cast<Node*>(this);
301 Node* highest = node;
302 for (; node; node = node->parentNode())
303 highest = node;
304 return *highest;
305 }
306
307 inline ContainerNode* Node::parentElementOrShadowRoot() const 298 inline ContainerNode* Node::parentElementOrShadowRoot() const
308 { 299 {
309 ContainerNode* parent = parentNode(); 300 ContainerNode* parent = parentNode();
310 return parent && (parent->isElementNode() || parent->isShadowRoot()) ? paren t : 0; 301 return parent && (parent->isElementNode() || parent->isShadowRoot()) ? paren t : 0;
311 } 302 }
312 303
313 inline ContainerNode* Node::parentElementOrDocumentFragment() const 304 inline ContainerNode* Node::parentElementOrDocumentFragment() const
314 { 305 {
315 ContainerNode* parent = parentNode(); 306 ContainerNode* parent = parentNode();
316 return parent && (parent->isElementNode() || parent->isDocumentFragment()) ? parent : 0; 307 return parent && (parent->isElementNode() || parent->isDocumentFragment()) ? parent : 0;
317 } 308 }
318 309
319 inline bool Node::isTreeScope() const 310 inline bool Node::isTreeScope() const
320 { 311 {
321 return &treeScope().rootNode() == this; 312 return &treeScope().rootNode() == this;
322 } 313 }
323 314
324 inline void getChildNodes(Node& node, NodeVector& nodes) 315 inline void getChildNodes(Node& node, NodeVector& nodes)
325 { 316 {
326 ASSERT(!nodes.size()); 317 ASSERT(!nodes.size());
327 for (Node* child = node.firstChild(); child; child = child->nextSibling()) 318 for (Node* child = node.firstChild(); child; child = child->nextSibling())
328 nodes.append(child); 319 nodes.append(child);
329 } 320 }
330 321
331 } // namespace blink 322 } // namespace blink
332 323
333 #endif // ContainerNode_h 324 #endif // ContainerNode_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/dom/Node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698