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

Unified Diff: Source/core/dom/Element.h

Issue 406843002: Optimize hasTagName when called on an HTMLElement / SVGElement (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/build/scripts/templates/MakeQualifiedNames.h.tmpl ('k') | Source/core/dom/ElementTraversal.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Element.h
diff --git a/Source/core/dom/Element.h b/Source/core/dom/Element.h
index 2df5a9adc5a0a427bfd85722678a415a1baa9253..b14bf198f1c767f57658c7557a3d40a8815dd04b 100644
--- a/Source/core/dom/Element.h
+++ b/Source/core/dom/Element.h
@@ -3,7 +3,7 @@
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2001 Peter Kelly (pmk@post.com)
* (C) 2001 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2003-2011, 2013, 2014 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -232,14 +232,16 @@ public:
const QualifiedName& tagQName() const { return m_tagName; }
String tagName() const { return nodeName(); }
+
bool hasTagName(const QualifiedName& tagName) const { return m_tagName.matches(tagName); }
+ bool hasTagName(const HTMLQualifiedName& tagName) const { return ContainerNode::hasTagName(tagName); }
+ bool hasTagName(const SVGQualifiedName& tagName) const { return ContainerNode::hasTagName(tagName); }
// Should be called only by Document::createElementNS to fix up m_tagName immediately after construction.
void setTagNameForCreateElementNS(const QualifiedName&);
// A fast function for checking the local name against another atomic string.
bool hasLocalName(const AtomicString& other) const { return m_tagName.localName() == other; }
- bool hasLocalName(const QualifiedName& other) const { return m_tagName.localName() == other.localName(); }
virtual const AtomicString& localName() const OVERRIDE FINAL { return m_tagName.localName(); }
const AtomicString& prefix() const { return m_tagName.prefix(); }
@@ -653,8 +655,9 @@ private:
};
DEFINE_NODE_TYPE_CASTS(Element, isElementNode());
-template <typename T> bool isElementOfType(const Element&);
-template <typename T> inline bool isElementOfType(const Node& node) { return node.isElementNode() && isElementOfType<const T>(toElement(node)); }
+template <typename T> bool isElementOfType(const Node&);
+template <> inline bool isElementOfType<const Element>(const Node& node) { return node.isElementNode(); }
+template <typename T> inline bool isElementOfType(const Element& element) { return isElementOfType<T>(static_cast<const Node&>(element)); }
template <> inline bool isElementOfType<const Element>(const Element&) { return true; }
// Type casting.
@@ -858,11 +861,11 @@ inline bool isShadowHost(const Element* element)
// These macros do the same as their NODE equivalents but additionally provide a template specialization
// for isElementOfType<>() so that the Traversal<> API works for these Element types.
#define DEFINE_ELEMENT_TYPE_CASTS(thisType, predicate) \
- template <> inline bool isElementOfType<const thisType>(const Element& element) { return element.predicate; } \
+ template <> inline bool isElementOfType<const thisType>(const Node& node) { return node.predicate; } \
DEFINE_NODE_TYPE_CASTS(thisType, predicate)
#define DEFINE_ELEMENT_TYPE_CASTS_WITH_FUNCTION(thisType) \
- template <> inline bool isElementOfType<const thisType>(const Element& element) { return is##thisType(element); } \
+ template <> inline bool isElementOfType<const thisType>(const Node& node) { return is##thisType(node); } \
DEFINE_NODE_TYPE_CASTS_WITH_FUNCTION(thisType)
#define DECLARE_ELEMENT_FACTORY_WITH_TAGNAME(T) \
« no previous file with comments | « Source/build/scripts/templates/MakeQualifiedNames.h.tmpl ('k') | Source/core/dom/ElementTraversal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698