| OLD | NEW |
| 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, 2008, 2009, 2010, 2011, 2012, 2013 Appl
e Inc. All rights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Appl
e Inc. All rights reserved. |
| 6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
| 7 * Copyright (C) 2014 Samsung Electronics. All rights reserved. | 7 * Copyright (C) 2014 Samsung Electronics. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 22 * Boston, MA 02110-1301, USA. | 22 * Boston, MA 02110-1301, USA. |
| 23 * | 23 * |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef ElementTraversal_h | 26 #ifndef ElementTraversal_h |
| 27 #define ElementTraversal_h | 27 #define ElementTraversal_h |
| 28 | 28 |
| 29 #include "core/dom/Element.h" | 29 #include "core/dom/Element.h" |
| 30 #include "core/dom/NodeTraversal.h" | 30 #include "core/dom/NodeTraversal.h" |
| 31 #include "wtf/Allocator.h" |
| 31 | 32 |
| 32 namespace blink { | 33 namespace blink { |
| 33 | 34 |
| 34 class HasTagName { | 35 class HasTagName { |
| 36 STACK_ALLOCATED(); |
| 35 public: | 37 public: |
| 36 explicit HasTagName(const QualifiedName& tagName) : m_tagName(tagName) { } | 38 explicit HasTagName(const QualifiedName& tagName) : m_tagName(tagName) { } |
| 37 bool operator() (const Element& element) const { return element.hasTagName(m
_tagName); } | 39 bool operator() (const Element& element) const { return element.hasTagName(m
_tagName); } |
| 38 private: | 40 private: |
| 39 const QualifiedName m_tagName; | 41 const QualifiedName m_tagName; |
| 40 }; | 42 }; |
| 41 | 43 |
| 42 template <class ElementType> | 44 template <class ElementType> |
| 43 class Traversal { | 45 class Traversal { |
| 46 STATIC_ONLY(Traversal); |
| 44 public: | 47 public: |
| 45 using TraversalNodeType = ElementType; | 48 using TraversalNodeType = ElementType; |
| 46 // First or last ElementType child of the node. | 49 // First or last ElementType child of the node. |
| 47 static ElementType* firstChild(const ContainerNode& current) { return firstC
hildTemplate(current); } | 50 static ElementType* firstChild(const ContainerNode& current) { return firstC
hildTemplate(current); } |
| 48 static ElementType* firstChild(const Node& current) { return firstChildTempl
ate(current); } | 51 static ElementType* firstChild(const Node& current) { return firstChildTempl
ate(current); } |
| 49 template <class MatchFunc> | 52 template <class MatchFunc> |
| 50 static ElementType* firstChild(const ContainerNode&, MatchFunc); | 53 static ElementType* firstChild(const ContainerNode&, MatchFunc); |
| 51 static ElementType* lastChild(const ContainerNode& current) { return lastChi
ldTemplate(current); } | 54 static ElementType* lastChild(const ContainerNode& current) { return lastChi
ldTemplate(current); } |
| 52 static ElementType* lastChild(const Node& current) { return lastChildTemplat
e(current); } | 55 static ElementType* lastChild(const Node& current) { return lastChildTemplat
e(current); } |
| 53 template <class MatchFunc> | 56 template <class MatchFunc> |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 { | 434 { |
| 432 ElementType* element = Traversal<ElementType>::nextSibling(current); | 435 ElementType* element = Traversal<ElementType>::nextSibling(current); |
| 433 while (element && !isMatch(*element)) | 436 while (element && !isMatch(*element)) |
| 434 element = Traversal<ElementType>::nextSibling(*element); | 437 element = Traversal<ElementType>::nextSibling(*element); |
| 435 return element; | 438 return element; |
| 436 } | 439 } |
| 437 | 440 |
| 438 } // namespace blink | 441 } // namespace blink |
| 439 | 442 |
| 440 #endif | 443 #endif |
| OLD | NEW |