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