forked from chromiumembedded/cef
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcef_dom.h
332 lines (284 loc) · 8.42 KB
/
cef_dom.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// The contents of this file must follow a specific format in order to
// support the CEF translator tool. See the translator.README.txt file in the
// tools directory for more information.
//
#ifndef CEF_INCLUDE_CEF_DOM_H_
#define CEF_INCLUDE_CEF_DOM_H_
#pragma once
#include <map>
#include "include/cef_base.h"
class CefDOMDocument;
class CefDOMNode;
///
// Interface to implement for visiting the DOM. The methods of this class will
// be called on the render process main thread.
///
/*--cef(source=client)--*/
class CefDOMVisitor : public virtual CefBaseRefCounted {
public:
///
// Method executed for visiting the DOM. The document object passed to this
// method represents a snapshot of the DOM at the time this method is
// executed. DOM objects are only valid for the scope of this method. Do not
// keep references to or attempt to access any DOM objects outside the scope
// of this method.
///
/*--cef()--*/
virtual void Visit(CefRefPtr<CefDOMDocument> document) = 0;
};
///
// Class used to represent a DOM document. The methods of this class should only
// be called on the render process main thread thread.
///
/*--cef(source=library)--*/
class CefDOMDocument : public virtual CefBaseRefCounted {
public:
typedef cef_dom_document_type_t Type;
///
// Returns the document type.
///
/*--cef(default_retval=DOM_DOCUMENT_TYPE_UNKNOWN)--*/
virtual Type GetType() = 0;
///
// Returns the root document node.
///
/*--cef()--*/
virtual CefRefPtr<CefDOMNode> GetDocument() = 0;
///
// Returns the BODY node of an HTML document.
///
/*--cef()--*/
virtual CefRefPtr<CefDOMNode> GetBody() = 0;
///
// Returns the HEAD node of an HTML document.
///
/*--cef()--*/
virtual CefRefPtr<CefDOMNode> GetHead() = 0;
///
// Returns the title of an HTML document.
///
/*--cef()--*/
virtual CefString GetTitle() = 0;
///
// Returns the document element with the specified ID value.
///
/*--cef()--*/
virtual CefRefPtr<CefDOMNode> GetElementById(const CefString& id) = 0;
///
// Returns the node that currently has keyboard focus.
///
/*--cef()--*/
virtual CefRefPtr<CefDOMNode> GetFocusedNode() = 0;
///
// Returns true if a portion of the document is selected.
///
/*--cef()--*/
virtual bool HasSelection() = 0;
///
// Returns the selection offset within the start node.
///
/*--cef()--*/
virtual int GetSelectionStartOffset() = 0;
///
// Returns the selection offset within the end node.
///
/*--cef()--*/
virtual int GetSelectionEndOffset() = 0;
///
// Returns the contents of this selection as markup.
///
/*--cef()--*/
virtual CefString GetSelectionAsMarkup() = 0;
///
// Returns the contents of this selection as text.
///
/*--cef()--*/
virtual CefString GetSelectionAsText() = 0;
///
// Returns the base URL for the document.
///
/*--cef()--*/
virtual CefString GetBaseURL() = 0;
///
// Returns a complete URL based on the document base URL and the specified
// partial URL.
///
/*--cef()--*/
virtual CefString GetCompleteURL(const CefString& partialURL) = 0;
};
///
// Class used to represent a DOM node. The methods of this class should only be
// called on the render process main thread.
///
/*--cef(source=library)--*/
class CefDOMNode : public virtual CefBaseRefCounted {
public:
typedef std::map<CefString, CefString> AttributeMap;
typedef cef_dom_node_type_t Type;
///
// Returns the type for this node.
///
/*--cef(default_retval=DOM_NODE_TYPE_UNSUPPORTED)--*/
virtual Type GetType() = 0;
///
// Returns true if this is a text node.
///
/*--cef()--*/
virtual bool IsText() = 0;
///
// Returns true if this is an element node.
///
/*--cef()--*/
virtual bool IsElement() = 0;
///
// Returns true if this is an editable node.
///
/*--cef()--*/
virtual bool IsEditable() = 0;
///
// Returns true if this is a form control element node.
///
/*--cef()--*/
virtual bool IsFormControlElement() = 0;
///
// Returns the type of this form control element node.
///
/*--cef()--*/
virtual CefString GetFormControlElementType() = 0;
///
// Returns true if this object is pointing to the same handle as |that|
// object.
///
/*--cef()--*/
virtual bool IsSame(CefRefPtr<CefDOMNode> that) = 0;
///
// Returns the name of this node.
///
/*--cef()--*/
virtual CefString GetName() = 0;
///
// Returns the value of this node.
///
/*--cef()--*/
virtual CefString GetValue() = 0;
///
// Set the value of this node. Returns true on success.
///
/*--cef()--*/
virtual bool SetValue(const CefString& value) = 0;
///
// Returns the contents of this node as markup.
///
/*--cef()--*/
virtual CefString GetAsMarkup() = 0;
///
// Returns the document associated with this node.
///
/*--cef()--*/
virtual CefRefPtr<CefDOMDocument> GetDocument() = 0;
///
// Returns the parent node.
///
/*--cef()--*/
virtual CefRefPtr<CefDOMNode> GetParent() = 0;
///
// Returns the previous sibling node.
///
/*--cef()--*/
virtual CefRefPtr<CefDOMNode> GetPreviousSibling() = 0;
///
// Returns the next sibling node.
///
/*--cef()--*/
virtual CefRefPtr<CefDOMNode> GetNextSibling() = 0;
///
// Returns true if this node has child nodes.
///
/*--cef()--*/
virtual bool HasChildren() = 0;
///
// Return the first child node.
///
/*--cef()--*/
virtual CefRefPtr<CefDOMNode> GetFirstChild() = 0;
///
// Returns the last child node.
///
/*--cef()--*/
virtual CefRefPtr<CefDOMNode> GetLastChild() = 0;
// The following methods are valid only for element nodes.
///
// Returns the tag name of this element.
///
/*--cef()--*/
virtual CefString GetElementTagName() = 0;
///
// Returns true if this element has attributes.
///
/*--cef()--*/
virtual bool HasElementAttributes() = 0;
///
// Returns true if this element has an attribute named |attrName|.
///
/*--cef()--*/
virtual bool HasElementAttribute(const CefString& attrName) = 0;
///
// Returns the element attribute named |attrName|.
///
/*--cef()--*/
virtual CefString GetElementAttribute(const CefString& attrName) = 0;
///
// Returns a map of all element attributes.
///
/*--cef()--*/
virtual void GetElementAttributes(AttributeMap& attrMap) = 0;
///
// Set the value for the element attribute named |attrName|. Returns true on
// success.
///
/*--cef()--*/
virtual bool SetElementAttribute(const CefString& attrName,
const CefString& value) = 0;
///
// Returns the inner text of the element.
///
/*--cef()--*/
virtual CefString GetElementInnerText() = 0;
///
// Returns the bounds of the element.
///
/*--cef()--*/
virtual CefRect GetElementBounds() = 0;
};
#endif // CEF_INCLUDE_CEF_DOM_H_