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 Peter Kelly (pmk@post.com) | 4 * (C) 2001 Peter Kelly (pmk@post.com) |
5 * (C) 2001 Dirk Mueller (mueller@kde.org) | 5 * (C) 2001 Dirk Mueller (mueller@kde.org) |
6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Appl
e Inc. All rights reserved. | 6 * Copyright (C) 2003-2011, 2013, 2014 Apple Inc. All rights reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
11 * version 2 of the License, or (at your option) any later version. | 11 * version 2 of the License, or (at your option) any later version. |
12 * | 12 * |
13 * This library is distributed in the hope that it will be useful, | 13 * This library is distributed in the hope that it will be useful, |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 * Library General Public License for more details. | 16 * Library General Public License for more details. |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 | 225 |
226 PassRefPtrWillBeRawPtr<Attr> attrIfExists(const QualifiedName&); | 226 PassRefPtrWillBeRawPtr<Attr> attrIfExists(const QualifiedName&); |
227 PassRefPtrWillBeRawPtr<Attr> ensureAttr(const QualifiedName&); | 227 PassRefPtrWillBeRawPtr<Attr> ensureAttr(const QualifiedName&); |
228 | 228 |
229 WillBeHeapVector<RefPtrWillBeMember<Attr> >* attrNodeList(); | 229 WillBeHeapVector<RefPtrWillBeMember<Attr> >* attrNodeList(); |
230 | 230 |
231 CSSStyleDeclaration* style(); | 231 CSSStyleDeclaration* style(); |
232 | 232 |
233 const QualifiedName& tagQName() const { return m_tagName; } | 233 const QualifiedName& tagQName() const { return m_tagName; } |
234 String tagName() const { return nodeName(); } | 234 String tagName() const { return nodeName(); } |
| 235 |
235 bool hasTagName(const QualifiedName& tagName) const { return m_tagName.match
es(tagName); } | 236 bool hasTagName(const QualifiedName& tagName) const { return m_tagName.match
es(tagName); } |
| 237 bool hasTagName(const HTMLQualifiedName& tagName) const { return ContainerNo
de::hasTagName(tagName); } |
| 238 bool hasTagName(const SVGQualifiedName& tagName) const { return ContainerNod
e::hasTagName(tagName); } |
236 | 239 |
237 // Should be called only by Document::createElementNS to fix up m_tagName im
mediately after construction. | 240 // Should be called only by Document::createElementNS to fix up m_tagName im
mediately after construction. |
238 void setTagNameForCreateElementNS(const QualifiedName&); | 241 void setTagNameForCreateElementNS(const QualifiedName&); |
239 | 242 |
240 // A fast function for checking the local name against another atomic string
. | 243 // A fast function for checking the local name against another atomic string
. |
241 bool hasLocalName(const AtomicString& other) const { return m_tagName.localN
ame() == other; } | 244 bool hasLocalName(const AtomicString& other) const { return m_tagName.localN
ame() == other; } |
242 bool hasLocalName(const QualifiedName& other) const { return m_tagName.local
Name() == other.localName(); } | |
243 | 245 |
244 virtual const AtomicString& localName() const OVERRIDE FINAL { return m_tagN
ame.localName(); } | 246 virtual const AtomicString& localName() const OVERRIDE FINAL { return m_tagN
ame.localName(); } |
245 const AtomicString& prefix() const { return m_tagName.prefix(); } | 247 const AtomicString& prefix() const { return m_tagName.prefix(); } |
246 virtual const AtomicString& namespaceURI() const OVERRIDE FINAL { return m_t
agName.namespaceURI(); } | 248 virtual const AtomicString& namespaceURI() const OVERRIDE FINAL { return m_t
agName.namespaceURI(); } |
247 | 249 |
248 const AtomicString& locateNamespacePrefix(const AtomicString& namespaceURI)
const; | 250 const AtomicString& locateNamespacePrefix(const AtomicString& namespaceURI)
const; |
249 | 251 |
250 virtual KURL baseURI() const OVERRIDE FINAL; | 252 virtual KURL baseURI() const OVERRIDE FINAL; |
251 | 253 |
252 virtual String nodeName() const OVERRIDE; | 254 virtual String nodeName() const OVERRIDE; |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 void detachAllAttrNodesFromElement(); | 648 void detachAllAttrNodesFromElement(); |
647 void detachAttrNodeFromElementWithValue(Attr*, const AtomicString& value); | 649 void detachAttrNodeFromElementWithValue(Attr*, const AtomicString& value); |
648 void detachAttrNodeAtIndex(Attr*, size_t index); | 650 void detachAttrNodeAtIndex(Attr*, size_t index); |
649 | 651 |
650 bool isJavaScriptURLAttribute(const Attribute&) const; | 652 bool isJavaScriptURLAttribute(const Attribute&) const; |
651 | 653 |
652 RefPtrWillBeMember<ElementData> m_elementData; | 654 RefPtrWillBeMember<ElementData> m_elementData; |
653 }; | 655 }; |
654 | 656 |
655 DEFINE_NODE_TYPE_CASTS(Element, isElementNode()); | 657 DEFINE_NODE_TYPE_CASTS(Element, isElementNode()); |
656 template <typename T> bool isElementOfType(const Element&); | 658 template <typename T> bool isElementOfType(const Node&); |
657 template <typename T> inline bool isElementOfType(const Node& node) { return nod
e.isElementNode() && isElementOfType<const T>(toElement(node)); } | 659 template <> inline bool isElementOfType<const Element>(const Node& node) { retur
n node.isElementNode(); } |
| 660 template <typename T> inline bool isElementOfType(const Element& element) { retu
rn isElementOfType<T>(static_cast<const Node&>(element)); } |
658 template <> inline bool isElementOfType<const Element>(const Element&) { return
true; } | 661 template <> inline bool isElementOfType<const Element>(const Element&) { return
true; } |
659 | 662 |
660 // Type casting. | 663 // Type casting. |
661 template<typename T> inline T& toElement(Node& node) | 664 template<typename T> inline T& toElement(Node& node) |
662 { | 665 { |
663 ASSERT_WITH_SECURITY_IMPLICATION(isElementOfType<const T>(node)); | 666 ASSERT_WITH_SECURITY_IMPLICATION(isElementOfType<const T>(node)); |
664 return static_cast<T&>(node); | 667 return static_cast<T&>(node); |
665 } | 668 } |
666 template<typename T> inline T* toElement(Node* node) | 669 template<typename T> inline T* toElement(Node* node) |
667 { | 670 { |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 } | 854 } |
852 | 855 |
853 inline bool isShadowHost(const Element* element) | 856 inline bool isShadowHost(const Element* element) |
854 { | 857 { |
855 return element && element->shadow(); | 858 return element && element->shadow(); |
856 } | 859 } |
857 | 860 |
858 // These macros do the same as their NODE equivalents but additionally provide a
template specialization | 861 // These macros do the same as their NODE equivalents but additionally provide a
template specialization |
859 // for isElementOfType<>() so that the Traversal<> API works for these Element t
ypes. | 862 // for isElementOfType<>() so that the Traversal<> API works for these Element t
ypes. |
860 #define DEFINE_ELEMENT_TYPE_CASTS(thisType, predicate) \ | 863 #define DEFINE_ELEMENT_TYPE_CASTS(thisType, predicate) \ |
861 template <> inline bool isElementOfType<const thisType>(const Element& eleme
nt) { return element.predicate; } \ | 864 template <> inline bool isElementOfType<const thisType>(const Node& node) {
return node.predicate; } \ |
862 DEFINE_NODE_TYPE_CASTS(thisType, predicate) | 865 DEFINE_NODE_TYPE_CASTS(thisType, predicate) |
863 | 866 |
864 #define DEFINE_ELEMENT_TYPE_CASTS_WITH_FUNCTION(thisType) \ | 867 #define DEFINE_ELEMENT_TYPE_CASTS_WITH_FUNCTION(thisType) \ |
865 template <> inline bool isElementOfType<const thisType>(const Element& eleme
nt) { return is##thisType(element); } \ | 868 template <> inline bool isElementOfType<const thisType>(const Node& node) {
return is##thisType(node); } \ |
866 DEFINE_NODE_TYPE_CASTS_WITH_FUNCTION(thisType) | 869 DEFINE_NODE_TYPE_CASTS_WITH_FUNCTION(thisType) |
867 | 870 |
868 #define DECLARE_ELEMENT_FACTORY_WITH_TAGNAME(T) \ | 871 #define DECLARE_ELEMENT_FACTORY_WITH_TAGNAME(T) \ |
869 static PassRefPtrWillBeRawPtr<T> create(const QualifiedName&, Document&) | 872 static PassRefPtrWillBeRawPtr<T> create(const QualifiedName&, Document&) |
870 #define DEFINE_ELEMENT_FACTORY_WITH_TAGNAME(T) \ | 873 #define DEFINE_ELEMENT_FACTORY_WITH_TAGNAME(T) \ |
871 PassRefPtrWillBeRawPtr<T> T::create(const QualifiedName& tagName, Document&
document) \ | 874 PassRefPtrWillBeRawPtr<T> T::create(const QualifiedName& tagName, Document&
document) \ |
872 { \ | 875 { \ |
873 return adoptRefWillBeNoop(new T(tagName, document)); \ | 876 return adoptRefWillBeNoop(new T(tagName, document)); \ |
874 } | 877 } |
875 | 878 |
876 } // namespace | 879 } // namespace |
877 | 880 |
878 #endif | 881 #endif |
OLD | NEW |