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

Side by Side Diff: Source/core/html/HTMLElement.h

Issue 1306413003: Make classes and structures in core/html fast-allocated. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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
« no previous file with comments | « Source/core/html/HTMLDimension.h ('k') | Source/core/html/HTMLFrameOwnerElement.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 * 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 ASSERT(!tagName.localName().isNull()); 152 ASSERT(!tagName.localName().isNull());
153 } 153 }
154 154
155 inline bool Node::hasTagName(const HTMLQualifiedName& name) const 155 inline bool Node::hasTagName(const HTMLQualifiedName& name) const
156 { 156 {
157 return isHTMLElement() && toHTMLElement(*this).hasTagName(name); 157 return isHTMLElement() && toHTMLElement(*this).hasTagName(name);
158 } 158 }
159 159
160 // Functor used to match HTMLElements with a specific HTML tag when using the El ementTraversal API. 160 // Functor used to match HTMLElements with a specific HTML tag when using the El ementTraversal API.
161 class HasHTMLTagName { 161 class HasHTMLTagName {
162 STACK_ALLOCATED();
162 public: 163 public:
163 explicit HasHTMLTagName(const HTMLQualifiedName& tagName): m_tagName(tagName ) { } 164 explicit HasHTMLTagName(const HTMLQualifiedName& tagName): m_tagName(tagName ) { }
164 bool operator() (const HTMLElement& element) const { return element.hasTagNa me(m_tagName); } 165 bool operator() (const HTMLElement& element) const { return element.hasTagNa me(m_tagName); }
165 private: 166 private:
166 const HTMLQualifiedName& m_tagName; 167 const HTMLQualifiedName& m_tagName;
167 }; 168 };
168 169
169 // This requires isHTML*Element(const Element&) and isHTML*Element(const HTMLEle ment&). 170 // This requires isHTML*Element(const Element&) and isHTML*Element(const HTMLEle ment&).
170 // When the input element is an HTMLElement, we don't need to check the namespac e URI, just the local name. 171 // When the input element is an HTMLElement, we don't need to check the namespac e URI, just the local name.
171 #define DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(thisType) \ 172 #define DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(thisType) \
172 inline bool is##thisType(const thisType* element); \ 173 inline bool is##thisType(const thisType* element); \
173 inline bool is##thisType(const thisType& element); \ 174 inline bool is##thisType(const thisType& element); \
174 inline bool is##thisType(const HTMLElement* element) { return element && is# #thisType(*element); } \ 175 inline bool is##thisType(const HTMLElement* element) { return element && is# #thisType(*element); } \
175 inline bool is##thisType(const Node& node) { return node.isHTMLElement() ? i s##thisType(toHTMLElement(node)) : false; } \ 176 inline bool is##thisType(const Node& node) { return node.isHTMLElement() ? i s##thisType(toHTMLElement(node)) : false; } \
176 inline bool is##thisType(const Node* node) { return node && is##thisType(*no de); } \ 177 inline bool is##thisType(const Node* node) { return node && is##thisType(*no de); } \
177 inline bool is##thisType(const Element* element) { return element && is##thi sType(*element); } \ 178 inline bool is##thisType(const Element* element) { return element && is##thi sType(*element); } \
178 template<typename T> inline bool is##thisType(const PassRefPtr<T>& node) { r eturn is##thisType(node.get()); } \ 179 template<typename T> inline bool is##thisType(const PassRefPtr<T>& node) { r eturn is##thisType(node.get()); } \
179 template<typename T> inline bool is##thisType(const RefPtr<T>& node) { retur n is##thisType(node.get()); } \ 180 template<typename T> inline bool is##thisType(const RefPtr<T>& node) { retur n is##thisType(node.get()); } \
180 template <> inline bool isElementOfType<const thisType>(const HTMLElement& e lement) { return is##thisType(element); } \ 181 template <> inline bool isElementOfType<const thisType>(const HTMLElement& e lement) { return is##thisType(element); } \
181 DEFINE_ELEMENT_TYPE_CASTS_WITH_FUNCTION(thisType) 182 DEFINE_ELEMENT_TYPE_CASTS_WITH_FUNCTION(thisType)
182 183
183 } // namespace blink 184 } // namespace blink
184 185
185 #include "core/HTMLElementTypeHelpers.h" 186 #include "core/HTMLElementTypeHelpers.h"
186 187
187 #endif // HTMLElement_h 188 #endif // HTMLElement_h
OLDNEW
« no previous file with comments | « Source/core/html/HTMLDimension.h ('k') | Source/core/html/HTMLFrameOwnerElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698