Add direct DOM access (issue #511).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@610 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2012-04-27 21:19:06 +00:00
parent 4fe0ddf640
commit db3a9817ed
58 changed files with 5089 additions and 7 deletions

441
include/capi/cef_dom_capi.h Normal file
View File

@@ -0,0 +1,441 @@
// 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.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#ifndef CEF_INCLUDE_CAPI_CEF_DOM_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_DOM_CAPI_H_
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "include/capi/cef_base_capi.h"
///
// Structure to implement for visiting the DOM. The functions of this structure
// will be called on the render process main thread.
///
typedef struct _cef_domvisitor_t {
///
// Base structure.
///
cef_base_t base;
///
// Method executed for visiting the DOM. The document object passed to this
// function represents a snapshot of the DOM at the time this function is
// executed. DOM objects are only valid for the scope of this function. Do not
// keep references to or attempt to access any DOM objects outside the scope
// of this function.
///
void (CEF_CALLBACK *visit)(struct _cef_domvisitor_t* self,
struct _cef_domdocument_t* document);
} cef_domvisitor_t;
///
// Structure used to represent a DOM document. The functions of this structure
// should only be called on the render process main thread thread.
///
typedef struct _cef_domdocument_t {
///
// Base structure.
///
cef_base_t base;
///
// Returns the document type.
///
enum cef_dom_document_type_t (CEF_CALLBACK *get_type)(
struct _cef_domdocument_t* self);
///
// Returns the root document node.
///
struct _cef_domnode_t* (CEF_CALLBACK *get_document)(
struct _cef_domdocument_t* self);
///
// Returns the BODY node of an HTML document.
///
struct _cef_domnode_t* (CEF_CALLBACK *get_body)(
struct _cef_domdocument_t* self);
///
// Returns the HEAD node of an HTML document.
///
struct _cef_domnode_t* (CEF_CALLBACK *get_head)(
struct _cef_domdocument_t* self);
///
// Returns the title of an HTML document.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_title)(
struct _cef_domdocument_t* self);
///
// Returns the document element with the specified ID value.
///
struct _cef_domnode_t* (CEF_CALLBACK *get_element_by_id)(
struct _cef_domdocument_t* self, const cef_string_t* id);
///
// Returns the node that currently has keyboard focus.
///
struct _cef_domnode_t* (CEF_CALLBACK *get_focused_node)(
struct _cef_domdocument_t* self);
///
// Returns true (1) if a portion of the document is selected.
///
int (CEF_CALLBACK *has_selection)(struct _cef_domdocument_t* self);
///
// Returns the selection start node.
///
struct _cef_domnode_t* (CEF_CALLBACK *get_selection_start_node)(
struct _cef_domdocument_t* self);
///
// Returns the selection offset within the start node.
///
int (CEF_CALLBACK *get_selection_start_offset)(
struct _cef_domdocument_t* self);
///
// Returns the selection end node.
///
struct _cef_domnode_t* (CEF_CALLBACK *get_selection_end_node)(
struct _cef_domdocument_t* self);
///
// Returns the selection offset within the end node.
///
int (CEF_CALLBACK *get_selection_end_offset)(struct _cef_domdocument_t* self);
///
// Returns the contents of this selection as markup.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_selection_as_markup)(
struct _cef_domdocument_t* self);
///
// Returns the contents of this selection as text.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_selection_as_text)(
struct _cef_domdocument_t* self);
///
// Returns the base URL for the document.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_base_url)(
struct _cef_domdocument_t* self);
///
// Returns a complete URL based on the document base URL and the specified
// partial URL.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_complete_url)(
struct _cef_domdocument_t* self, const cef_string_t* partialURL);
} cef_domdocument_t;
///
// Structure used to represent a DOM node. The functions of this structure
// should only be called on the render process main thread.
///
typedef struct _cef_domnode_t {
///
// Base structure.
///
cef_base_t base;
///
// Returns the type for this node.
///
enum cef_dom_node_type_t (CEF_CALLBACK *get_type)(
struct _cef_domnode_t* self);
///
// Returns true (1) if this is a text node.
///
int (CEF_CALLBACK *is_text)(struct _cef_domnode_t* self);
///
// Returns true (1) if this is an element node.
///
int (CEF_CALLBACK *is_element)(struct _cef_domnode_t* self);
///
// Returns true (1) if this is a form control element node.
///
int (CEF_CALLBACK *is_form_control_element)(struct _cef_domnode_t* self);
///
// Returns the type of this form control element node.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_form_control_element_type)(
struct _cef_domnode_t* self);
///
// Returns true (1) if this object is pointing to the same handle as |that|
// object.
///
int (CEF_CALLBACK *is_same)(struct _cef_domnode_t* self,
struct _cef_domnode_t* that);
///
// Returns the name of this node.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_name)(struct _cef_domnode_t* self);
///
// Returns the value of this node.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_value)(struct _cef_domnode_t* self);
///
// Set the value of this node. Returns true (1) on success.
///
int (CEF_CALLBACK *set_value)(struct _cef_domnode_t* self,
const cef_string_t* value);
///
// Returns the contents of this node as markup.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_as_markup)(
struct _cef_domnode_t* self);
///
// Returns the document associated with this node.
///
struct _cef_domdocument_t* (CEF_CALLBACK *get_document)(
struct _cef_domnode_t* self);
///
// Returns the parent node.
///
struct _cef_domnode_t* (CEF_CALLBACK *get_parent)(
struct _cef_domnode_t* self);
///
// Returns the previous sibling node.
///
struct _cef_domnode_t* (CEF_CALLBACK *get_previous_sibling)(
struct _cef_domnode_t* self);
///
// Returns the next sibling node.
///
struct _cef_domnode_t* (CEF_CALLBACK *get_next_sibling)(
struct _cef_domnode_t* self);
///
// Returns true (1) if this node has child nodes.
///
int (CEF_CALLBACK *has_children)(struct _cef_domnode_t* self);
///
// Return the first child node.
///
struct _cef_domnode_t* (CEF_CALLBACK *get_first_child)(
struct _cef_domnode_t* self);
///
// Returns the last child node.
///
struct _cef_domnode_t* (CEF_CALLBACK *get_last_child)(
struct _cef_domnode_t* self);
///
// Add an event listener to this node for the specified event type. If
// |useCapture| is true (1) then this listener will be considered a capturing
// listener. Capturing listeners will recieve all events of the specified type
// before the events are dispatched to any other event targets beneath the
// current node in the tree. Events which are bubbling upwards through the
// tree will not trigger a capturing listener. Separate calls to this function
// can be used to register the same listener with and without capture. See
// WebCore/dom/EventNames.h for the list of supported event types.
///
void (CEF_CALLBACK *add_event_listener)(struct _cef_domnode_t* self,
const cef_string_t* eventType, struct _cef_domevent_listener_t* listener,
int useCapture);
// The following functions are valid only for element nodes.
///
// Returns the tag name of this element.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_element_tag_name)(
struct _cef_domnode_t* self);
///
// Returns true (1) if this element has attributes.
///
int (CEF_CALLBACK *has_element_attributes)(struct _cef_domnode_t* self);
///
// Returns true (1) if this element has an attribute named |attrName|.
///
int (CEF_CALLBACK *has_element_attribute)(struct _cef_domnode_t* self,
const cef_string_t* attrName);
///
// Returns the element attribute named |attrName|.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_element_attribute)(
struct _cef_domnode_t* self, const cef_string_t* attrName);
///
// Returns a map of all element attributes.
///
void (CEF_CALLBACK *get_element_attributes)(struct _cef_domnode_t* self,
cef_string_map_t attrMap);
///
// Set the value for the element attribute named |attrName|. Returns true (1)
// on success.
///
int (CEF_CALLBACK *set_element_attribute)(struct _cef_domnode_t* self,
const cef_string_t* attrName, const cef_string_t* value);
///
// Returns the inner text of the element.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_element_inner_text)(
struct _cef_domnode_t* self);
} cef_domnode_t;
///
// Structure used to represent a DOM event. The functions of this structure
// should only be called on the render process main thread.
///
typedef struct _cef_domevent_t {
///
// Base structure.
///
cef_base_t base;
///
// Returns the event type.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_type)(struct _cef_domevent_t* self);
///
// Returns the event category.
///
enum cef_dom_event_category_t (CEF_CALLBACK *get_category)(
struct _cef_domevent_t* self);
///
// Returns the event processing phase.
///
enum cef_dom_event_phase_t (CEF_CALLBACK *get_phase)(
struct _cef_domevent_t* self);
///
// Returns true (1) if the event can bubble up the tree.
///
int (CEF_CALLBACK *can_bubble)(struct _cef_domevent_t* self);
///
// Returns true (1) if the event can be canceled.
///
int (CEF_CALLBACK *can_cancel)(struct _cef_domevent_t* self);
///
// Returns the document associated with this event.
///
struct _cef_domdocument_t* (CEF_CALLBACK *get_document)(
struct _cef_domevent_t* self);
///
// Returns the target of the event.
///
struct _cef_domnode_t* (CEF_CALLBACK *get_target)(
struct _cef_domevent_t* self);
///
// Returns the current target of the event.
///
struct _cef_domnode_t* (CEF_CALLBACK *get_current_target)(
struct _cef_domevent_t* self);
} cef_domevent_t;
///
// Structure to implement for handling DOM events. The functions of this
// structure will be called on the render process main thread.
///
typedef struct _cef_domevent_listener_t {
///
// Base structure.
///
cef_base_t base;
///
// Called when an event is received. The event object passed to this function
// contains a snapshot of the DOM at the time this function is executed. DOM
// objects are only valid for the scope of this function. Do not keep
// references to or attempt to access any DOM objects outside the scope of
// this function.
///
void (CEF_CALLBACK *handle_event)(struct _cef_domevent_listener_t* self,
struct _cef_domevent_t* event);
} cef_domevent_listener_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_DOM_CAPI_H_

View File

@@ -195,6 +195,13 @@ typedef struct _cef_frame_t {
///
struct _cef_v8context_t* (CEF_CALLBACK *get_v8context)(
struct _cef_frame_t* self);
///
// Visit the DOM document. This function can only be called from the render
// process.
///
void (CEF_CALLBACK *visit_dom)(struct _cef_frame_t* self,
struct _cef_domvisitor_t* visitor);
} cef_frame_t;

429
include/cef_dom.h Normal file
View File

@@ -0,0 +1,429 @@
// 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 "include/cef_base.h"
#include <map>
class CefDOMDocument;
class CefDOMEventListener;
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 CefBase {
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 CefBase {
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 start node.
///
/*--cef()--*/
virtual CefRefPtr<CefDOMNode> GetSelectionStartNode() =0;
///
// Returns the selection offset within the start node.
///
/*--cef()--*/
virtual int GetSelectionStartOffset() =0;
///
// Returns the selection end node.
///
/*--cef()--*/
virtual CefRefPtr<CefDOMNode> GetSelectionEndNode() =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 CefBase {
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 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;
///
// Add an event listener to this node for the specified event type. If
// |useCapture| is true then this listener will be considered a capturing
// listener. Capturing listeners will recieve all events of the specified
// type before the events are dispatched to any other event targets beneath
// the current node in the tree. Events which are bubbling upwards through
// the tree will not trigger a capturing listener. Separate calls to this
// method can be used to register the same listener with and without capture.
// See WebCore/dom/EventNames.h for the list of supported event types.
///
/*--cef()--*/
virtual void AddEventListener(const CefString& eventType,
CefRefPtr<CefDOMEventListener> listener,
bool useCapture) =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;
};
///
// Class used to represent a DOM event. The methods of this class should only
// be called on the render process main thread.
///
/*--cef(source=library)--*/
class CefDOMEvent : public virtual CefBase {
public:
typedef cef_dom_event_category_t Category;
typedef cef_dom_event_phase_t Phase;
///
// Returns the event type.
///
/*--cef()--*/
virtual CefString GetType() =0;
///
// Returns the event category.
///
/*--cef(default_retval=DOM_EVENT_CATEGORY_UNKNOWN)--*/
virtual Category GetCategory() =0;
///
// Returns the event processing phase.
///
/*--cef(default_retval=DOM_EVENT_PHASE_UNKNOWN)--*/
virtual Phase GetPhase() =0;
///
// Returns true if the event can bubble up the tree.
///
/*--cef()--*/
virtual bool CanBubble() =0;
///
// Returns true if the event can be canceled.
///
/*--cef()--*/
virtual bool CanCancel() =0;
///
// Returns the document associated with this event.
///
/*--cef()--*/
virtual CefRefPtr<CefDOMDocument> GetDocument() =0;
///
// Returns the target of the event.
///
/*--cef()--*/
virtual CefRefPtr<CefDOMNode> GetTarget() =0;
///
// Returns the current target of the event.
///
/*--cef()--*/
virtual CefRefPtr<CefDOMNode> GetCurrentTarget() =0;
};
///
// Interface to implement for handling DOM events. The methods of this class
// will be called on the render process main thread.
///
/*--cef(source=client)--*/
class CefDOMEventListener : public virtual CefBase {
public:
///
// Called when an event is received. The event object passed to this method
// contains 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 HandleEvent(CefRefPtr<CefDOMEvent> event) =0;
};
#endif // CEF_INCLUDE_CEF_DOM_H_

View File

@@ -39,6 +39,7 @@
#pragma once
#include "include/cef_base.h"
#include "include/cef_dom.h"
#include "include/cef_request.h"
#include "include/cef_stream.h"
#include "include/cef_string_visitor.h"
@@ -209,6 +210,13 @@ class CefFrame : public virtual CefBase {
///
/*--cef()--*/
virtual CefRefPtr<CefV8Context> GetV8Context() =0;
///
// Visit the DOM document. This method can only be called from the render
// process.
///
/*--cef()--*/
virtual void VisitDOM(CefRefPtr<CefDOMVisitor> visitor) =0;
};
#endif // CEF_INCLUDE_CEF_FRAME_H_

View File

@@ -1027,6 +1027,73 @@ typedef struct _cef_proxy_info_t {
cef_string_t proxyList;
} cef_proxy_info_t;
///
// DOM document types.
///
enum cef_dom_document_type_t {
DOM_DOCUMENT_TYPE_UNKNOWN = 0,
DOM_DOCUMENT_TYPE_HTML,
DOM_DOCUMENT_TYPE_XHTML,
DOM_DOCUMENT_TYPE_PLUGIN,
};
///
// DOM event category flags.
///
enum cef_dom_event_category_t {
DOM_EVENT_CATEGORY_UNKNOWN = 0x0,
DOM_EVENT_CATEGORY_UI = 0x1,
DOM_EVENT_CATEGORY_MOUSE = 0x2,
DOM_EVENT_CATEGORY_MUTATION = 0x4,
DOM_EVENT_CATEGORY_KEYBOARD = 0x8,
DOM_EVENT_CATEGORY_TEXT = 0x10,
DOM_EVENT_CATEGORY_COMPOSITION = 0x20,
DOM_EVENT_CATEGORY_DRAG = 0x40,
DOM_EVENT_CATEGORY_CLIPBOARD = 0x80,
DOM_EVENT_CATEGORY_MESSAGE = 0x100,
DOM_EVENT_CATEGORY_WHEEL = 0x200,
DOM_EVENT_CATEGORY_BEFORE_TEXT_INSERTED = 0x400,
DOM_EVENT_CATEGORY_OVERFLOW = 0x800,
DOM_EVENT_CATEGORY_PAGE_TRANSITION = 0x1000,
DOM_EVENT_CATEGORY_POPSTATE = 0x2000,
DOM_EVENT_CATEGORY_PROGRESS = 0x4000,
DOM_EVENT_CATEGORY_XMLHTTPREQUEST_PROGRESS = 0x8000,
DOM_EVENT_CATEGORY_WEBKIT_ANIMATION = 0x10000,
DOM_EVENT_CATEGORY_WEBKIT_TRANSITION = 0x20000,
DOM_EVENT_CATEGORY_BEFORE_LOAD = 0x40000,
};
///
// DOM event processing phases.
///
enum cef_dom_event_phase_t {
DOM_EVENT_PHASE_UNKNOWN = 0,
DOM_EVENT_PHASE_CAPTURING,
DOM_EVENT_PHASE_AT_TARGET,
DOM_EVENT_PHASE_BUBBLING,
};
///
// DOM node types.
///
enum cef_dom_node_type_t {
DOM_NODE_TYPE_UNSUPPORTED = 0,
DOM_NODE_TYPE_ELEMENT,
DOM_NODE_TYPE_ATTRIBUTE,
DOM_NODE_TYPE_TEXT,
DOM_NODE_TYPE_CDATA_SECTION,
DOM_NODE_TYPE_ENTITY_REFERENCE,
DOM_NODE_TYPE_ENTITY,
DOM_NODE_TYPE_PROCESSING_INSTRUCTIONS,
DOM_NODE_TYPE_COMMENT,
DOM_NODE_TYPE_DOCUMENT,
DOM_NODE_TYPE_DOCUMENT_TYPE,
DOM_NODE_TYPE_DOCUMENT_FRAGMENT,
DOM_NODE_TYPE_NOTATION,
DOM_NODE_TYPE_XPATH_NAMESPACE,
};
#ifdef __cplusplus
}
#endif