| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 { | 142 { |
| 143 ASSERT(!tagName.localName().isNull()); | 143 ASSERT(!tagName.localName().isNull()); |
| 144 ScriptWrappable::init(this); | 144 ScriptWrappable::init(this); |
| 145 } | 145 } |
| 146 | 146 |
| 147 inline bool Node::hasTagName(const HTMLQualifiedName& name) const | 147 inline bool Node::hasTagName(const HTMLQualifiedName& name) const |
| 148 { | 148 { |
| 149 return isHTMLElement() && toHTMLElement(*this).hasTagName(name); | 149 return isHTMLElement() && toHTMLElement(*this).hasTagName(name); |
| 150 } | 150 } |
| 151 | 151 |
| 152 // Functor used to match HTMLElements with a specific HTML tag when using the El
ementTraversal API. |
| 153 class HasHTMLTagName { |
| 154 public: |
| 155 explicit HasHTMLTagName(const HTMLQualifiedName& tagName): m_tagName(tagName
) { } |
| 156 bool operator() (const HTMLElement& element) const { return element.hasTagNa
me(m_tagName); } |
| 157 private: |
| 158 const HTMLQualifiedName& m_tagName; |
| 159 }; |
| 160 |
| 152 // This requires isHTML*Element(const Element&) and isHTML*Element(const HTMLEle
ment&). | 161 // This requires isHTML*Element(const Element&) and isHTML*Element(const HTMLEle
ment&). |
| 153 // When the input element is an HTMLElement, we don't need to check the namespac
e URI, just the local name. | 162 // When the input element is an HTMLElement, we don't need to check the namespac
e URI, just the local name. |
| 154 #define DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(thisType) \ | 163 #define DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(thisType) \ |
| 155 inline bool is##thisType(const thisType* element); \ | 164 inline bool is##thisType(const thisType* element); \ |
| 156 inline bool is##thisType(const thisType& element); \ | 165 inline bool is##thisType(const thisType& element); \ |
| 157 inline bool is##thisType(const HTMLElement* element) { return element && is#
#thisType(*element); } \ | 166 inline bool is##thisType(const HTMLElement* element) { return element && is#
#thisType(*element); } \ |
| 158 inline bool is##thisType(const Node& node) { return node.isHTMLElement() ? i
s##thisType(toHTMLElement(node)) : false; } \ | 167 inline bool is##thisType(const Node& node) { return node.isHTMLElement() ? i
s##thisType(toHTMLElement(node)) : false; } \ |
| 159 inline bool is##thisType(const Node* node) { return node && is##thisType(*no
de); } \ | 168 inline bool is##thisType(const Node* node) { return node && is##thisType(*no
de); } \ |
| 160 inline bool is##thisType(const Element* element) { return element && is##thi
sType(*element); } \ | 169 inline bool is##thisType(const Element* element) { return element && is##thi
sType(*element); } \ |
| 161 template<typename T> inline bool is##thisType(const PassRefPtr<T>& node) { r
eturn is##thisType(node.get()); } \ | 170 template<typename T> inline bool is##thisType(const PassRefPtr<T>& node) { r
eturn is##thisType(node.get()); } \ |
| 162 template<typename T> inline bool is##thisType(const RefPtr<T>& node) { retur
n is##thisType(node.get()); } \ | 171 template<typename T> inline bool is##thisType(const RefPtr<T>& node) { retur
n is##thisType(node.get()); } \ |
| 163 template <> inline bool isElementOfType<const thisType>(const HTMLElement& e
lement) { return is##thisType(element); } \ | 172 template <> inline bool isElementOfType<const thisType>(const HTMLElement& e
lement) { return is##thisType(element); } \ |
| 164 DEFINE_ELEMENT_TYPE_CASTS_WITH_FUNCTION(thisType) | 173 DEFINE_ELEMENT_TYPE_CASTS_WITH_FUNCTION(thisType) |
| 165 | 174 |
| 166 } // namespace blink | 175 } // namespace blink |
| 167 | 176 |
| 168 #include "core/HTMLElementTypeHelpers.h" | 177 #include "core/HTMLElementTypeHelpers.h" |
| 169 | 178 |
| 170 #endif // HTMLElement_h | 179 #endif // HTMLElement_h |
| OLD | NEW |