| 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 * Copyright (C) 2004-2007, 2009, 2014 Apple Inc. All rights reserved. | 4 * Copyright (C) 2004-2007, 2009, 2014 Apple Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 Document& document, | 185 Document& document, |
| 186 ConstructionType type = CreateHTMLElement) | 186 ConstructionType type = CreateHTMLElement) |
| 187 : Element(tagName, &document, type) { | 187 : Element(tagName, &document, type) { |
| 188 DCHECK(!tagName.localName().isNull()); | 188 DCHECK(!tagName.localName().isNull()); |
| 189 } | 189 } |
| 190 | 190 |
| 191 inline bool Node::hasTagName(const HTMLQualifiedName& name) const { | 191 inline bool Node::hasTagName(const HTMLQualifiedName& name) const { |
| 192 return isHTMLElement() && toHTMLElement(*this).hasTagName(name); | 192 return isHTMLElement() && toHTMLElement(*this).hasTagName(name); |
| 193 } | 193 } |
| 194 | 194 |
| 195 // Functor used to match HTMLElements with a specific HTML tag when using the El
ementTraversal API. | 195 // Functor used to match HTMLElements with a specific HTML tag when using the |
| 196 // ElementTraversal API. |
| 196 class HasHTMLTagName { | 197 class HasHTMLTagName { |
| 197 STACK_ALLOCATED(); | 198 STACK_ALLOCATED(); |
| 198 | 199 |
| 199 public: | 200 public: |
| 200 explicit HasHTMLTagName(const HTMLQualifiedName& tagName) | 201 explicit HasHTMLTagName(const HTMLQualifiedName& tagName) |
| 201 : m_tagName(tagName) {} | 202 : m_tagName(tagName) {} |
| 202 bool operator()(const HTMLElement& element) const { | 203 bool operator()(const HTMLElement& element) const { |
| 203 return element.hasTagName(m_tagName); | 204 return element.hasTagName(m_tagName); |
| 204 } | 205 } |
| 205 | 206 |
| 206 private: | 207 private: |
| 207 const HTMLQualifiedName& m_tagName; | 208 const HTMLQualifiedName& m_tagName; |
| 208 }; | 209 }; |
| 209 | 210 |
| 210 // This requires isHTML*Element(const Element&) and isHTML*Element(const HTMLEle
ment&). | 211 // This requires isHTML*Element(const Element&) and isHTML*Element(const |
| 211 // When the input element is an HTMLElement, we don't need to check the namespac
e URI, just the local name. | 212 // HTMLElement&). When the input element is an HTMLElement, we don't need to |
| 213 // check the namespace URI, just the local name. |
| 212 #define DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(thisType) \ | 214 #define DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(thisType) \ |
| 213 inline bool is##thisType(const thisType* element); \ | 215 inline bool is##thisType(const thisType* element); \ |
| 214 inline bool is##thisType(const thisType& element); \ | 216 inline bool is##thisType(const thisType& element); \ |
| 215 inline bool is##thisType(const HTMLElement* element) { \ | 217 inline bool is##thisType(const HTMLElement* element) { \ |
| 216 return element && is##thisType(*element); \ | 218 return element && is##thisType(*element); \ |
| 217 } \ | 219 } \ |
| 218 inline bool is##thisType(const Node& node) { \ | 220 inline bool is##thisType(const Node& node) { \ |
| 219 return node.isHTMLElement() ? is##thisType(toHTMLElement(node)) : false; \ | 221 return node.isHTMLElement() ? is##thisType(toHTMLElement(node)) : false; \ |
| 220 } \ | 222 } \ |
| 221 inline bool is##thisType(const Node* node) { \ | 223 inline bool is##thisType(const Node* node) { \ |
| 222 return node && is##thisType(*node); \ | 224 return node && is##thisType(*node); \ |
| 223 } \ | 225 } \ |
| 224 inline bool is##thisType(const Element* element) { \ | 226 inline bool is##thisType(const Element* element) { \ |
| 225 return element && is##thisType(*element); \ | 227 return element && is##thisType(*element); \ |
| 226 } \ | 228 } \ |
| 227 template <> \ | 229 template <> \ |
| 228 inline bool isElementOfType<const thisType>(const HTMLElement& element) { \ | 230 inline bool isElementOfType<const thisType>(const HTMLElement& element) { \ |
| 229 return is##thisType(element); \ | 231 return is##thisType(element); \ |
| 230 } \ | 232 } \ |
| 231 DEFINE_ELEMENT_TYPE_CASTS_WITH_FUNCTION(thisType) | 233 DEFINE_ELEMENT_TYPE_CASTS_WITH_FUNCTION(thisType) |
| 232 | 234 |
| 233 } // namespace blink | 235 } // namespace blink |
| 234 | 236 |
| 235 #include "core/HTMLElementTypeHelpers.h" | 237 #include "core/HTMLElementTypeHelpers.h" |
| 236 | 238 |
| 237 #endif // HTMLElement_h | 239 #endif // HTMLElement_h |
| OLD | NEW |