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 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. |
6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
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 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 { | 877 { |
878 return !node || node->isDocumentNode() || node->isShadowRoot(); | 878 return !node || node->isDocumentNode() || node->isShadowRoot(); |
879 } | 879 } |
880 | 880 |
881 inline bool isTreeScopeRoot(const Node& node) | 881 inline bool isTreeScopeRoot(const Node& node) |
882 { | 882 { |
883 return node.isDocumentNode() || node.isShadowRoot(); | 883 return node.isDocumentNode() || node.isShadowRoot(); |
884 } | 884 } |
885 | 885 |
886 // Allow equality comparisons of Nodes by reference or pointer, interchangeably. | 886 // Allow equality comparisons of Nodes by reference or pointer, interchangeably. |
887 inline bool operator==(const Node& a, const Node& b) { return &a == &b; } | 887 DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES_REFCOUNTED(Node) |
888 inline bool operator==(const Node& a, const Node* b) { return &a == b; } | |
889 inline bool operator==(const Node* a, const Node& b) { return a == &b; } | |
890 inline bool operator!=(const Node& a, const Node& b) { return !(a == b); } | |
891 inline bool operator!=(const Node& a, const Node* b) { return !(a == b); } | |
892 inline bool operator!=(const Node* a, const Node& b) { return !(a == b); } | |
893 inline bool operator==(const PassRefPtr<Node>& a, const Node& b) { return a.get(
) == &b; } | |
894 inline bool operator==(const Node& a, const PassRefPtr<Node>& b) { return &a ==
b.get(); } | |
895 inline bool operator!=(const PassRefPtr<Node>& a, const Node& b) { return !(a ==
b); } | |
896 inline bool operator!=(const Node& a, const PassRefPtr<Node>& b) { return !(a ==
b); } | |
897 | 888 |
898 | 889 |
899 #define DEFINE_NODE_TYPE_CASTS(thisType, predicate) \ | 890 #define DEFINE_NODE_TYPE_CASTS(thisType, predicate) \ |
900 template<typename T> inline thisType* to##thisType(const RefPtr<T>& node) {
return to##thisType(node.get()); } \ | 891 template<typename T> inline thisType* to##thisType(const RefPtr<T>& node) {
return to##thisType(node.get()); } \ |
901 DEFINE_TYPE_CASTS(thisType, Node, node, node->predicate, node.predicate) | 892 DEFINE_TYPE_CASTS(thisType, Node, node, node->predicate, node.predicate) |
902 | 893 |
903 // This requires isClassName(const Node&). | 894 // This requires isClassName(const Node&). |
904 #define DEFINE_NODE_TYPE_CASTS_WITH_FUNCTION(thisType) \ | 895 #define DEFINE_NODE_TYPE_CASTS_WITH_FUNCTION(thisType) \ |
905 template<typename T> inline thisType* to##thisType(const RefPtr<T>& node) {
return to##thisType(node.get()); } \ | 896 template<typename T> inline thisType* to##thisType(const RefPtr<T>& node) {
return to##thisType(node.get()); } \ |
906 DEFINE_TYPE_CASTS(thisType, Node, node, is##thisType(*node), is##thisType(no
de)) | 897 DEFINE_TYPE_CASTS(thisType, Node, node, is##thisType(*node), is##thisType(no
de)) |
907 | 898 |
908 #define DEFINE_NODE_FACTORY(T) \ | 899 #define DEFINE_NODE_FACTORY(T) \ |
909 inline static PassRefPtrWillBeRawPtr<T> create(Document& document) \ | 900 inline static PassRefPtrWillBeRawPtr<T> create(Document& document) \ |
910 { \ | 901 { \ |
911 return adoptRefWillBeRefCountedGarbageCollected(new T(document)); \ | 902 return adoptRefWillBeRefCountedGarbageCollected(new T(document)); \ |
912 } | 903 } |
913 | 904 |
914 } // namespace WebCore | 905 } // namespace WebCore |
915 | 906 |
916 #ifndef NDEBUG | 907 #ifndef NDEBUG |
917 // Outside the WebCore namespace for ease of invocation from gdb. | 908 // Outside the WebCore namespace for ease of invocation from gdb. |
918 void showNode(const WebCore::Node*); | 909 void showNode(const WebCore::Node*); |
919 void showTree(const WebCore::Node*); | 910 void showTree(const WebCore::Node*); |
920 void showNodePath(const WebCore::Node*); | 911 void showNodePath(const WebCore::Node*); |
921 #endif | 912 #endif |
922 | 913 |
923 #endif | 914 #endif |
OLD | NEW |