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, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Appl
e 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 |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 bool isJavaScriptURLAttribute(const Attribute&) const; | 666 bool isJavaScriptURLAttribute(const Attribute&) const; |
667 | 667 |
668 RefPtr<ElementData> m_elementData; | 668 RefPtr<ElementData> m_elementData; |
669 }; | 669 }; |
670 | 670 |
671 DEFINE_NODE_TYPE_CASTS(Element, isElementNode()); | 671 DEFINE_NODE_TYPE_CASTS(Element, isElementNode()); |
672 template <typename T> bool isElementOfType(const Element&); | 672 template <typename T> bool isElementOfType(const Element&); |
673 template <typename T> inline bool isElementOfType(const Node& node) { return nod
e.isElementNode() && isElementOfType<const T>(toElement(node)); } | 673 template <typename T> inline bool isElementOfType(const Node& node) { return nod
e.isElementNode() && isElementOfType<const T>(toElement(node)); } |
674 template <> inline bool isElementOfType<const Element>(const Element&) { return
true; } | 674 template <> inline bool isElementOfType<const Element>(const Element&) { return
true; } |
675 | 675 |
| 676 // Type casting. |
| 677 template<typename T> inline T& toElement(Node& node) |
| 678 { |
| 679 ASSERT_WITH_SECURITY_IMPLICATION(isElementOfType<const T>(node)); |
| 680 return static_cast<T&>(node); |
| 681 } |
| 682 template<typename T> inline T* toElement(Node* node) |
| 683 { |
| 684 ASSERT_WITH_SECURITY_IMPLICATION(!node || isElementOfType<const T>(*node)); |
| 685 return static_cast<T*>(node); |
| 686 } |
| 687 template<typename T> inline const T& toElement(const Node& node) |
| 688 { |
| 689 ASSERT_WITH_SECURITY_IMPLICATION(isElementOfType<const T>(node)); |
| 690 return static_cast<const T&>(node); |
| 691 } |
| 692 template<typename T> inline const T* toElement(const Node* node) |
| 693 { |
| 694 ASSERT_WITH_SECURITY_IMPLICATION(!node || isElementOfType<const T>(*node)); |
| 695 return static_cast<const T*>(node); |
| 696 } |
| 697 template<typename T, typename U> inline T* toElement(const RefPtr<U>& node) { re
turn toElement<T>(node.get()); } |
| 698 |
676 inline bool isDisabledFormControl(const Node* node) | 699 inline bool isDisabledFormControl(const Node* node) |
677 { | 700 { |
678 return node->isElementNode() && toElement(node)->isDisabledFormControl(); | 701 return node->isElementNode() && toElement(node)->isDisabledFormControl(); |
679 } | 702 } |
680 | 703 |
681 inline bool Node::hasTagName(const QualifiedName& name) const | 704 inline bool Node::hasTagName(const QualifiedName& name) const |
682 { | 705 { |
683 return isElementNode() && toElement(this)->hasTagName(name); | 706 return isElementNode() && toElement(this)->hasTagName(name); |
684 } | 707 } |
685 | 708 |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 } | 882 } |
860 | 883 |
861 inline bool isShadowHost(const Element* element) | 884 inline bool isShadowHost(const Element* element) |
862 { | 885 { |
863 return element && element->shadow(); | 886 return element && element->shadow(); |
864 } | 887 } |
865 | 888 |
866 } // namespace | 889 } // namespace |
867 | 890 |
868 #endif | 891 #endif |
OLD | NEW |