OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 BLINK_EXPORT void reset(); | 68 BLINK_EXPORT void reset(); |
69 BLINK_EXPORT void assign(const WebNode&); | 69 BLINK_EXPORT void assign(const WebNode&); |
70 | 70 |
71 BLINK_EXPORT bool equals(const WebNode&) const; | 71 BLINK_EXPORT bool equals(const WebNode&) const; |
72 // Required for using WebNodes in std maps. Note the order used is | 72 // Required for using WebNodes in std maps. Note the order used is |
73 // arbitrary and should not be expected to have any specific meaning. | 73 // arbitrary and should not be expected to have any specific meaning. |
74 BLINK_EXPORT bool lessThan(const WebNode&) const; | 74 BLINK_EXPORT bool lessThan(const WebNode&) const; |
75 | 75 |
76 bool isNull() const { return m_private.isNull(); } | 76 bool isNull() const { return m_private.isNull(); } |
77 | 77 |
78 enum NodeType { | |
79 ElementNode = 1, | |
80 AttributeNode = 2, | |
81 TextNode = 3, | |
82 CDataSectionNode = 4, | |
83 // EntityReferenceNodes are impossible to create in Blink. | |
84 // EntityNodes are impossible to create in Blink. | |
85 ProcessingInstructionsNode = 7, | |
86 CommentNode = 8, | |
87 DocumentNode = 9, | |
88 DocumentTypeNode = 10, | |
89 DocumentFragmentNode = 11, | |
90 // NotationNodes are impossible to create in Blink. | |
91 // XPathNamespaceNodes are impossible to create in Blink. | |
92 ShadowRootNode = 14 | |
93 }; | |
94 | |
95 BLINK_EXPORT NodeType nodeType() const; | |
96 BLINK_EXPORT WebNode parentNode() const; | 78 BLINK_EXPORT WebNode parentNode() const; |
97 BLINK_EXPORT WebString nodeValue() const; | 79 BLINK_EXPORT WebString nodeValue() const; |
98 BLINK_EXPORT WebDocument document() const; | 80 BLINK_EXPORT WebDocument document() const; |
99 BLINK_EXPORT WebNode firstChild() const; | 81 BLINK_EXPORT WebNode firstChild() const; |
100 BLINK_EXPORT WebNode lastChild() const; | 82 BLINK_EXPORT WebNode lastChild() const; |
101 BLINK_EXPORT WebNode previousSibling() const; | 83 BLINK_EXPORT WebNode previousSibling() const; |
102 BLINK_EXPORT WebNode nextSibling() const; | 84 BLINK_EXPORT WebNode nextSibling() const; |
103 BLINK_EXPORT bool hasChildNodes() const; | 85 BLINK_EXPORT bool hasChildNodes() const; |
104 BLINK_EXPORT WebNodeList childNodes(); | 86 BLINK_EXPORT WebNodeList childNodes(); |
105 BLINK_EXPORT bool isLink() const; | 87 BLINK_EXPORT bool isLink() const; |
| 88 BLINK_EXPORT bool isDocumentNode() const; |
106 BLINK_EXPORT bool isCommentNode() const; | 89 BLINK_EXPORT bool isCommentNode() const; |
107 BLINK_EXPORT bool isTextNode() const; | 90 BLINK_EXPORT bool isTextNode() const; |
108 BLINK_EXPORT bool isFocusable() const; | 91 BLINK_EXPORT bool isFocusable() const; |
109 BLINK_EXPORT bool isContentEditable() const; | 92 BLINK_EXPORT bool isContentEditable() const; |
110 BLINK_EXPORT bool isElementNode() const; | 93 BLINK_EXPORT bool isElementNode() const; |
111 BLINK_EXPORT void dispatchEvent(const WebDOMEvent&); | 94 BLINK_EXPORT void dispatchEvent(const WebDOMEvent&); |
112 BLINK_EXPORT void simulateClick(); | 95 BLINK_EXPORT void simulateClick(); |
113 // The argument should be lower-cased. | 96 // The argument should be lower-cased. |
114 BLINK_EXPORT WebElementCollection getElementsByHTMLTagName(const WebString&)
const; | 97 BLINK_EXPORT WebElementCollection getElementsByHTMLTagName(const WebString&)
const; |
115 | 98 |
116 | 99 |
117 BLINK_EXPORT WebElement querySelector(const WebString& selector, WebExceptio
nCode&) const; | 100 BLINK_EXPORT WebElement querySelector(const WebString& selector, WebExceptio
nCode&) const; |
118 BLINK_EXPORT void querySelectorAll(const WebString& selector, WebVector<WebE
lement>& results, WebExceptionCode&) const; | 101 BLINK_EXPORT void querySelectorAll(const WebString& selector, WebVector<WebE
lement>& results, WebExceptionCode&) const; |
119 | 102 |
120 // Same as querySelector and querySelectorAll, but ASSERT if an exception | 103 // Same as querySelector and querySelectorAll, but ASSERT if an exception |
121 // code would be generated. | 104 // code would be generated. |
122 BLINK_EXPORT WebElement querySelector(const WebString& selector) const; | 105 BLINK_EXPORT WebElement querySelector(const WebString& selector) const; |
123 BLINK_EXPORT void querySelectorAll(const WebString& selector, WebVector<WebE
lement>& results) const; | 106 BLINK_EXPORT void querySelectorAll(const WebString& selector, WebVector<WebE
lement>& results) const; |
124 | 107 |
125 BLINK_EXPORT bool focused() const; | 108 BLINK_EXPORT bool focused() const; |
126 | 109 |
127 BLINK_EXPORT WebPluginContainer* pluginContainer() const; | 110 BLINK_EXPORT WebPluginContainer* pluginContainer() const; |
128 | 111 |
129 BLINK_EXPORT bool isInsideFocusableElementOrARIAWidget() const; | 112 BLINK_EXPORT bool isInsideFocusableElementOrARIAWidget() const; |
130 BLINK_EXPORT WebAXObject accessibilityObject(); | 113 BLINK_EXPORT WebAXObject accessibilityObject(); |
131 | 114 |
132 template<typename T> T to() | 115 template<typename T> T to(); |
133 { | 116 template<typename T> const T toConst() const; |
134 T res; | |
135 res.WebNode::assign(*this); | |
136 return res; | |
137 } | |
138 | |
139 template<typename T> const T toConst() const | |
140 { | |
141 T res; | |
142 res.WebNode::assign(*this); | |
143 return res; | |
144 } | |
145 | 117 |
146 #if BLINK_IMPLEMENTATION | 118 #if BLINK_IMPLEMENTATION |
147 WebNode(const PassRefPtrWillBeRawPtr<Node>&); | 119 WebNode(const PassRefPtrWillBeRawPtr<Node>&); |
148 WebNode& operator=(const PassRefPtrWillBeRawPtr<Node>&); | 120 WebNode& operator=(const PassRefPtrWillBeRawPtr<Node>&); |
149 operator PassRefPtrWillBeRawPtr<Node>() const; | 121 operator PassRefPtrWillBeRawPtr<Node>() const; |
150 #endif | |
151 | 122 |
152 #if BLINK_IMPLEMENTATION | |
153 template<typename T> T* unwrap() | 123 template<typename T> T* unwrap() |
154 { | 124 { |
155 return static_cast<T*>(m_private.get()); | 125 return static_cast<T*>(m_private.get()); |
156 } | 126 } |
157 | 127 |
158 template<typename T> const T* constUnwrap() const | 128 template<typename T> const T* constUnwrap() const |
159 { | 129 { |
160 return static_cast<const T*>(m_private.get()); | 130 return static_cast<const T*>(m_private.get()); |
161 } | 131 } |
162 #endif | 132 #endif |
163 | 133 |
164 protected: | 134 protected: |
165 WebPrivatePtr<Node> m_private; | 135 WebPrivatePtr<Node> m_private; |
166 }; | 136 }; |
167 | 137 |
| 138 #define DECLARE_WEB_NODE_TYPE_CASTS(type) \ |
| 139 template<> \ |
| 140 BLINK_EXPORT type WebNode::to<type>(); \ |
| 141 template<> \ |
| 142 BLINK_EXPORT const type WebNode::toConst<type>() const; |
| 143 |
| 144 #if BLINK_IMPLEMENTATION |
| 145 #define DEFINE_WEB_NODE_TYPE_CASTS(type, predicate) \ |
| 146 template<> \ |
| 147 type WebNode::to<type>() { \ |
| 148 ASSERT_WITH_SECURITY_IMPLICATION(isNull() || (predicate)); \ |
| 149 type result; \ |
| 150 result.WebNode::assign(*this); \ |
| 151 return result; \ |
| 152 } \ |
| 153 template<> \ |
| 154 const type WebNode::toConst<type>() const { \ |
| 155 ASSERT_WITH_SECURITY_IMPLICATION(isNull() || (predicate)); \ |
| 156 type result; \ |
| 157 result.WebNode::assign(*this); \ |
| 158 return result; \ |
| 159 } |
| 160 #endif |
| 161 |
168 inline bool operator==(const WebNode& a, const WebNode& b) | 162 inline bool operator==(const WebNode& a, const WebNode& b) |
169 { | 163 { |
170 return a.equals(b); | 164 return a.equals(b); |
171 } | 165 } |
172 | 166 |
173 inline bool operator!=(const WebNode& a, const WebNode& b) | 167 inline bool operator!=(const WebNode& a, const WebNode& b) |
174 { | 168 { |
175 return !(a == b); | 169 return !(a == b); |
176 } | 170 } |
177 | 171 |
178 inline bool operator<(const WebNode& a, const WebNode& b) | 172 inline bool operator<(const WebNode& a, const WebNode& b) |
179 { | 173 { |
180 return a.lessThan(b); | 174 return a.lessThan(b); |
181 } | 175 } |
182 | 176 |
183 } // namespace blink | 177 } // namespace blink |
184 | 178 |
185 #endif | 179 #endif |
OLD | NEW |