mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-03-29 10:20:11 +01:00
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:
parent
4fe0ddf640
commit
db3a9817ed
cef.gypcef_paths.gypicef_paths2.gypi
include
libcef
browser
renderer
libcef_dll
cpptoc
domdocument_cpptoc.ccdomdocument_cpptoc.hdomevent_cpptoc.ccdomevent_cpptoc.hdomevent_listener_cpptoc.ccdomevent_listener_cpptoc.hdomnode_cpptoc.ccdomnode_cpptoc.hdomvisitor_cpptoc.ccdomvisitor_cpptoc.hframe_cpptoc.cc
ctocpp
domdocument_ctocpp.ccdomdocument_ctocpp.hdomevent_ctocpp.ccdomevent_ctocpp.hdomevent_listener_ctocpp.ccdomevent_listener_ctocpp.hdomnode_ctocpp.ccdomnode_ctocpp.hdomvisitor_ctocpp.ccdomvisitor_ctocpp.hframe_ctocpp.ccframe_ctocpp.h
libcef_dll.ccwrapper
tests
8
cef.gyp
8
cef.gyp
@ -227,6 +227,7 @@
|
||||
'tests/cefclient/client_switches.h',
|
||||
'tests/unittests/command_line_unittest.cc',
|
||||
'tests/unittests/cookie_unittest.cc',
|
||||
'tests/unittests/dom_unittest.cc',
|
||||
'tests/unittests/jsdialog_unittest.cc',
|
||||
'tests/unittests/navigation_unittest.cc',
|
||||
'tests/unittests/process_message_unittest.cc',
|
||||
@ -862,6 +863,12 @@
|
||||
'libcef/renderer/browser_impl.h',
|
||||
'libcef/renderer/content_renderer_client.cc',
|
||||
'libcef/renderer/content_renderer_client.h',
|
||||
'libcef/renderer/dom_document_impl.cc',
|
||||
'libcef/renderer/dom_document_impl.h',
|
||||
'libcef/renderer/dom_event_impl.cc',
|
||||
'libcef/renderer/dom_event_impl.h',
|
||||
'libcef/renderer/dom_node_impl.cc',
|
||||
'libcef/renderer/dom_node_impl.h',
|
||||
'libcef/renderer/frame_impl.cc',
|
||||
'libcef/renderer/frame_impl.h',
|
||||
'libcef/renderer/render_process_observer.cc',
|
||||
@ -1058,6 +1065,7 @@
|
||||
'tests/cefclient/process_helper_mac.cpp',
|
||||
'tests/unittests/client_app_delegates.cc',
|
||||
'tests/unittests/cookie_unittest.cc',
|
||||
'tests/unittests/dom_unittest.cc',
|
||||
'tests/unittests/process_message_unittest.cc',
|
||||
'tests/unittests/scheme_handler_unittest.cc',
|
||||
'tests/unittests/test_handler.cc',
|
||||
|
@ -20,6 +20,7 @@
|
||||
'include/cef_context_menu_handler.h',
|
||||
'include/cef_cookie.h',
|
||||
'include/cef_display_handler.h',
|
||||
'include/cef_dom.h',
|
||||
'include/cef_frame.h',
|
||||
'include/cef_geolocation_handler.h',
|
||||
'include/cef_jsdialog_handler.h',
|
||||
@ -55,6 +56,7 @@
|
||||
'include/capi/cef_context_menu_handler_capi.h',
|
||||
'include/capi/cef_cookie_capi.h',
|
||||
'include/capi/cef_display_handler_capi.h',
|
||||
'include/capi/cef_dom_capi.h',
|
||||
'include/capi/cef_frame_capi.h',
|
||||
'include/capi/cef_geolocation_handler_capi.h',
|
||||
'include/capi/cef_jsdialog_handler_capi.h',
|
||||
@ -106,6 +108,16 @@
|
||||
'libcef_dll/cpptoc/cookie_manager_cpptoc.h',
|
||||
'libcef_dll/ctocpp/cookie_visitor_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/cookie_visitor_ctocpp.h',
|
||||
'libcef_dll/cpptoc/domdocument_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/domdocument_cpptoc.h',
|
||||
'libcef_dll/cpptoc/domevent_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/domevent_cpptoc.h',
|
||||
'libcef_dll/ctocpp/domevent_listener_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/domevent_listener_ctocpp.h',
|
||||
'libcef_dll/cpptoc/domnode_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/domnode_cpptoc.h',
|
||||
'libcef_dll/ctocpp/domvisitor_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/domvisitor_ctocpp.h',
|
||||
'libcef_dll/cpptoc/dictionary_value_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/dictionary_value_cpptoc.h',
|
||||
'libcef_dll/ctocpp/display_handler_ctocpp.cc',
|
||||
@ -208,6 +220,16 @@
|
||||
'libcef_dll/ctocpp/cookie_manager_ctocpp.h',
|
||||
'libcef_dll/cpptoc/cookie_visitor_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/cookie_visitor_cpptoc.h',
|
||||
'libcef_dll/ctocpp/domdocument_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/domdocument_ctocpp.h',
|
||||
'libcef_dll/ctocpp/domevent_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/domevent_ctocpp.h',
|
||||
'libcef_dll/cpptoc/domevent_listener_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/domevent_listener_cpptoc.h',
|
||||
'libcef_dll/ctocpp/domnode_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/domnode_ctocpp.h',
|
||||
'libcef_dll/cpptoc/domvisitor_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/domvisitor_cpptoc.h',
|
||||
'libcef_dll/ctocpp/dictionary_value_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/dictionary_value_ctocpp.h',
|
||||
'libcef_dll/cpptoc/display_handler_cpptoc.cc',
|
||||
|
@ -91,8 +91,11 @@
|
||||
'tests/cefclient/client_handler.h',
|
||||
'tests/cefclient/client_switches.cpp',
|
||||
'tests/cefclient/client_switches.h',
|
||||
'tests/cefclient/dom_test.cpp',
|
||||
'tests/cefclient/dom_test.h',
|
||||
'tests/cefclient/res/binding.html',
|
||||
'tests/cefclient/res/dialogs.html',
|
||||
'tests/cefclient/res/domaccess.html',
|
||||
'tests/cefclient/res/localstorage.html',
|
||||
'tests/cefclient/res/logo.png',
|
||||
'tests/cefclient/res/xmlhttprequest.html',
|
||||
@ -129,6 +132,8 @@
|
||||
'tests/cefclient/client_handler_mac.mm',
|
||||
'tests/cefclient/client_switches.cpp',
|
||||
'tests/cefclient/client_switches.h',
|
||||
'tests/cefclient/dom_test.cpp',
|
||||
'tests/cefclient/dom_test.h',
|
||||
'tests/cefclient/process_helper_mac.cpp',
|
||||
'tests/cefclient/resource_util.h',
|
||||
'tests/cefclient/resource_util_mac.mm',
|
||||
@ -145,6 +150,7 @@
|
||||
'tests/cefclient/mac/Info.plist',
|
||||
'tests/cefclient/res/binding.html',
|
||||
'tests/cefclient/res/dialogs.html',
|
||||
'tests/cefclient/res/domaccess.html',
|
||||
'tests/cefclient/res/localstorage.html',
|
||||
'tests/cefclient/res/logo.png',
|
||||
'tests/cefclient/res/xmlhttprequest.html',
|
||||
@ -156,6 +162,7 @@
|
||||
],
|
||||
'cefclient_bundle_resources_linux': [
|
||||
'tests/cefclient/res/binding.html',
|
||||
'tests/cefclient/res/domaccess.html',
|
||||
'tests/cefclient/res/localstorage.html',
|
||||
'tests/cefclient/res/logo.png',
|
||||
'tests/cefclient/res/xmlhttprequest.html',
|
||||
|
441
include/capi/cef_dom_capi.h
Normal file
441
include/capi/cef_dom_capi.h
Normal 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_
|
@ -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
429
include/cef_dom.h
Normal 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_
|
@ -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_
|
||||
|
@ -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
|
||||
|
@ -225,6 +225,10 @@ CefRefPtr<CefV8Context> CefFrameHostImpl::GetV8Context() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CefFrameHostImpl::VisitDOM(CefRefPtr<CefDOMVisitor> visitor) {
|
||||
NOTREACHED() << "VisitDOM cannot be called from the browser process";
|
||||
}
|
||||
|
||||
void CefFrameHostImpl::Detach() {
|
||||
base::AutoLock lock_scope(state_lock_);
|
||||
browser_ = NULL;
|
||||
|
@ -49,6 +49,7 @@ class CefFrameHostImpl : public CefFrame {
|
||||
virtual CefString GetURL() OVERRIDE;
|
||||
virtual CefRefPtr<CefBrowser> GetBrowser() OVERRIDE;
|
||||
virtual CefRefPtr<CefV8Context> GetV8Context() OVERRIDE;
|
||||
virtual void VisitDOM(CefRefPtr<CefDOMVisitor> visitor) OVERRIDE;
|
||||
|
||||
void SetFocused(bool focused);
|
||||
void SetURL(const CefString& url);
|
||||
|
@ -392,6 +392,24 @@ CefRefPtr<CefFrameImpl> CefBrowserImpl::GetWebFrameImpl(int64 frame_id) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CefBrowserImpl::AddFrameObject(int64 frame_id,
|
||||
CefTrackNode* tracked_object) {
|
||||
CefRefPtr<CefTrackManager> manager;
|
||||
|
||||
if (!frame_objects_.empty()) {
|
||||
FrameObjectMap::const_iterator it = frame_objects_.find(frame_id);
|
||||
if (it != frame_objects_.end())
|
||||
manager = it->second;
|
||||
}
|
||||
|
||||
if (!manager.get()) {
|
||||
manager = new CefTrackManager();
|
||||
frame_objects_.insert(std::make_pair(frame_id, manager));
|
||||
}
|
||||
|
||||
manager->Add(tracked_object);
|
||||
}
|
||||
|
||||
|
||||
// RenderViewObserver methods.
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -417,11 +435,20 @@ void CefBrowserImpl::DidStartProvisionalLoad(WebKit::WebFrame* frame) {
|
||||
void CefBrowserImpl::FrameDetached(WebFrame* frame) {
|
||||
int64 frame_id = frame->identifier();
|
||||
|
||||
// Remove the frame from the map.
|
||||
FrameMap::iterator it = frames_.find(frame_id);
|
||||
DCHECK(it != frames_.end());
|
||||
it->second->Detach();
|
||||
frames_.erase(it);
|
||||
{
|
||||
// Remove the frame from the map.
|
||||
FrameMap::iterator it = frames_.find(frame_id);
|
||||
DCHECK(it != frames_.end());
|
||||
it->second->Detach();
|
||||
frames_.erase(it);
|
||||
}
|
||||
|
||||
if (!frame_objects_.empty()) {
|
||||
// Remove any tracked objects associated with the frame.
|
||||
FrameObjectMap::iterator it = frame_objects_.find(frame_id);
|
||||
if (it != frame_objects_.end())
|
||||
frame_objects_.erase(it);
|
||||
}
|
||||
|
||||
// Notify the browser that the frame has detached.
|
||||
Send(new CefHostMsg_FrameDetached(routing_id(), frame_id));
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "include/cef_browser.h"
|
||||
#include "include/cef_client.h"
|
||||
#include "libcef/common/response_manager.h"
|
||||
#include "libcef/common/tracker.h"
|
||||
#include "libcef/renderer/frame_impl.h"
|
||||
|
||||
#include "content/public/renderer/render_view_observer.h"
|
||||
@ -83,6 +84,9 @@ class CefBrowserImpl : public CefBrowser,
|
||||
CefRefPtr<CefFrameImpl> GetWebFrameImpl(WebKit::WebFrame* frame);
|
||||
CefRefPtr<CefFrameImpl> GetWebFrameImpl(int64 frame_id);
|
||||
|
||||
// Frame objects will be deleted immediately before the frame is closed.
|
||||
void AddFrameObject(int64 frame_id, CefTrackNode* tracked_object);
|
||||
|
||||
int browser_window_id() const { return browser_window_id_; }
|
||||
content::RenderView* render_view() {
|
||||
return content::RenderViewObserver::render_view();
|
||||
@ -115,6 +119,11 @@ class CefBrowserImpl : public CefBrowser,
|
||||
typedef std::map<int64, CefRefPtr<CefFrameImpl> > FrameMap;
|
||||
FrameMap frames_;
|
||||
|
||||
// Map of unique frame ids to CefTrackManager objects that need to be cleaned
|
||||
// up when the frame is deleted.
|
||||
typedef std::map<int64, CefRefPtr<CefTrackManager> > FrameObjectMap;
|
||||
FrameObjectMap frame_objects_;
|
||||
|
||||
// Manages response registrations.
|
||||
CefResponseManager response_manager_;
|
||||
|
||||
|
262
libcef/renderer/dom_document_impl.cc
Normal file
262
libcef/renderer/dom_document_impl.cc
Normal file
@ -0,0 +1,262 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "libcef/renderer/dom_document_impl.h"
|
||||
#include "libcef/renderer/dom_node_impl.h"
|
||||
#include "libcef/renderer/thread_util.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h"
|
||||
|
||||
using WebKit::WebDocument;
|
||||
using WebKit::WebElement;
|
||||
using WebKit::WebFrame;
|
||||
using WebKit::WebNode;
|
||||
using WebKit::WebRange;
|
||||
using WebKit::WebString;
|
||||
using WebKit::WebURL;
|
||||
|
||||
|
||||
CefDOMDocumentImpl::CefDOMDocumentImpl(CefBrowserImpl* browser,
|
||||
WebFrame* frame)
|
||||
: browser_(browser),
|
||||
frame_(frame) {
|
||||
const WebDocument& document = frame_->document();
|
||||
DCHECK(!document.isNull());
|
||||
}
|
||||
|
||||
CefDOMDocumentImpl::~CefDOMDocumentImpl() {
|
||||
CEF_REQUIRE_RT();
|
||||
|
||||
// Verify that the Detach() method has been called.
|
||||
DCHECK(frame_ == NULL);
|
||||
}
|
||||
|
||||
CefDOMDocumentImpl::Type CefDOMDocumentImpl::GetType() {
|
||||
if (!VerifyContext())
|
||||
return DOM_DOCUMENT_TYPE_UNKNOWN;
|
||||
|
||||
const WebDocument& document = frame_->document();
|
||||
if (document.isHTMLDocument())
|
||||
return DOM_DOCUMENT_TYPE_HTML;
|
||||
if (document.isXHTMLDocument())
|
||||
return DOM_DOCUMENT_TYPE_XHTML;
|
||||
if (document.isPluginDocument())
|
||||
return DOM_DOCUMENT_TYPE_PLUGIN;
|
||||
return DOM_DOCUMENT_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMDocumentImpl::GetDocument() {
|
||||
const WebDocument& document = frame_->document();
|
||||
return GetOrCreateNode(document.document());
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMDocumentImpl::GetBody() {
|
||||
const WebDocument& document = frame_->document();
|
||||
return GetOrCreateNode(document.body());
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMDocumentImpl::GetHead() {
|
||||
WebDocument document = frame_->document();
|
||||
return GetOrCreateNode(document.head());
|
||||
}
|
||||
|
||||
CefString CefDOMDocumentImpl::GetTitle() {
|
||||
CefString str;
|
||||
if (!VerifyContext())
|
||||
return str;
|
||||
|
||||
const WebDocument& document = frame_->document();
|
||||
const WebString& title = document.title();
|
||||
if (!title.isNull())
|
||||
str = title;
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMDocumentImpl::GetElementById(const CefString& id) {
|
||||
const WebDocument& document = frame_->document();
|
||||
return GetOrCreateNode(document.getElementById(string16(id)));
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMDocumentImpl::GetFocusedNode() {
|
||||
const WebDocument& document = frame_->document();
|
||||
return GetOrCreateNode(document.focusedNode());
|
||||
}
|
||||
|
||||
bool CefDOMDocumentImpl::HasSelection() {
|
||||
if (!VerifyContext())
|
||||
return false;
|
||||
|
||||
return frame_->hasSelection();
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMDocumentImpl::GetSelectionStartNode() {
|
||||
if (!VerifyContext() || !frame_->hasSelection())
|
||||
return NULL;
|
||||
|
||||
const WebRange& range = frame_->selectionRange();
|
||||
if (range.isNull())
|
||||
return NULL;
|
||||
|
||||
int exceptionCode;
|
||||
return GetOrCreateNode(range.startContainer(exceptionCode));
|
||||
}
|
||||
|
||||
int CefDOMDocumentImpl::GetSelectionStartOffset() {
|
||||
if (!VerifyContext() || !frame_->hasSelection())
|
||||
return 0;
|
||||
|
||||
const WebRange& range = frame_->selectionRange();
|
||||
if (range.isNull())
|
||||
return 0;
|
||||
|
||||
return range.startOffset();
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMDocumentImpl::GetSelectionEndNode() {
|
||||
if (!VerifyContext() || !frame_->hasSelection())
|
||||
return NULL;
|
||||
|
||||
const WebRange& range = frame_->selectionRange();
|
||||
if (range.isNull())
|
||||
return NULL;
|
||||
|
||||
int exceptionCode;
|
||||
return GetOrCreateNode(range.endContainer(exceptionCode));
|
||||
}
|
||||
|
||||
int CefDOMDocumentImpl::GetSelectionEndOffset() {
|
||||
if (!VerifyContext() || !frame_->hasSelection())
|
||||
return 0;
|
||||
|
||||
const WebRange& range = frame_->selectionRange();
|
||||
if (range.isNull())
|
||||
return 0;
|
||||
|
||||
return range.endOffset();
|
||||
}
|
||||
|
||||
CefString CefDOMDocumentImpl::GetSelectionAsMarkup() {
|
||||
CefString str;
|
||||
if (!VerifyContext() || !frame_->hasSelection())
|
||||
return str;
|
||||
|
||||
const WebString& markup = frame_->selectionAsMarkup();
|
||||
if (!markup.isNull())
|
||||
str = markup;
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
CefString CefDOMDocumentImpl::GetSelectionAsText() {
|
||||
CefString str;
|
||||
if (!VerifyContext() || !frame_->hasSelection())
|
||||
return str;
|
||||
|
||||
const WebString& text = frame_->selectionAsText();
|
||||
if (!text.isNull())
|
||||
str = text;
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
CefString CefDOMDocumentImpl::GetBaseURL() {
|
||||
CefString str;
|
||||
if (!VerifyContext())
|
||||
return str;
|
||||
|
||||
const WebDocument& document = frame_->document();
|
||||
const WebURL& url = document.baseURL();
|
||||
if (!url.isNull()) {
|
||||
GURL gurl = url;
|
||||
str = gurl.spec();
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
CefString CefDOMDocumentImpl::GetCompleteURL(const CefString& partialURL) {
|
||||
CefString str;
|
||||
if (!VerifyContext())
|
||||
return str;
|
||||
|
||||
const WebDocument& document = frame_->document();
|
||||
const WebURL& url = document.completeURL(string16(partialURL));
|
||||
if (!url.isNull()) {
|
||||
GURL gurl = url;
|
||||
str = gurl.spec();
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMDocumentImpl::GetOrCreateNode(
|
||||
const WebKit::WebNode& node) {
|
||||
if (!VerifyContext())
|
||||
return NULL;
|
||||
|
||||
// Nodes may potentially be null.
|
||||
if (node.isNull())
|
||||
return NULL;
|
||||
|
||||
if (!node_map_.empty()) {
|
||||
// Locate the existing node, if any.
|
||||
NodeMap::const_iterator it = node_map_.find(node);
|
||||
if (it != node_map_.end())
|
||||
return it->second;
|
||||
}
|
||||
|
||||
// Create the new node object.
|
||||
CefRefPtr<CefDOMNode> nodeImpl(new CefDOMNodeImpl(this, node));
|
||||
node_map_.insert(std::make_pair(node, nodeImpl));
|
||||
return nodeImpl;
|
||||
}
|
||||
|
||||
void CefDOMDocumentImpl::RemoveNode(const WebKit::WebNode& node) {
|
||||
if (!VerifyContext())
|
||||
return;
|
||||
|
||||
if (!node_map_.empty()) {
|
||||
NodeMap::iterator it = node_map_.find(node);
|
||||
if (it != node_map_.end())
|
||||
node_map_.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
void CefDOMDocumentImpl::Detach() {
|
||||
if (!VerifyContext())
|
||||
return;
|
||||
|
||||
// If you hit this assert it means that you are keeping references to node
|
||||
// objects beyond the valid scope.
|
||||
DCHECK(node_map_.empty());
|
||||
|
||||
// If you hit this assert it means that you are keeping references to this
|
||||
// document object beyond the valid scope.
|
||||
DCHECK_EQ(GetRefCt(), 1);
|
||||
|
||||
if (!node_map_.empty()) {
|
||||
NodeMap::const_iterator it = node_map_.begin();
|
||||
for (; it != node_map_.end(); ++it)
|
||||
static_cast<CefDOMNodeImpl*>(it->second)->Detach();
|
||||
node_map_.clear();
|
||||
}
|
||||
|
||||
frame_ = NULL;
|
||||
}
|
||||
|
||||
bool CefDOMDocumentImpl::VerifyContext() {
|
||||
if (!CEF_CURRENTLY_ON_RT() || frame_ == NULL) {
|
||||
NOTREACHED();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
66
libcef/renderer/dom_document_impl.h
Normal file
66
libcef/renderer/dom_document_impl.h
Normal file
@ -0,0 +1,66 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_DOM_DOCUMENT_IMPL_H_
|
||||
#define CEF_LIBCEF_DOM_DOCUMENT_IMPL_H_
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include "include/cef_dom.h"
|
||||
|
||||
namespace WebKit {
|
||||
class WebFrame;
|
||||
class WebNode;
|
||||
};
|
||||
|
||||
class CefBrowserImpl;
|
||||
|
||||
class CefDOMDocumentImpl : public CefDOMDocument {
|
||||
public:
|
||||
CefDOMDocumentImpl(CefBrowserImpl* browser,
|
||||
WebKit::WebFrame* frame);
|
||||
virtual ~CefDOMDocumentImpl();
|
||||
|
||||
// CefDOMDocument methods.
|
||||
virtual Type GetType() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMNode> GetDocument() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMNode> GetBody() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMNode> GetHead() OVERRIDE;
|
||||
virtual CefString GetTitle() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMNode> GetElementById(const CefString& id) OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMNode> GetFocusedNode() OVERRIDE;
|
||||
virtual bool HasSelection() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMNode> GetSelectionStartNode() OVERRIDE;
|
||||
virtual int GetSelectionStartOffset() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMNode> GetSelectionEndNode() OVERRIDE;
|
||||
virtual int GetSelectionEndOffset() OVERRIDE;
|
||||
virtual CefString GetSelectionAsMarkup() OVERRIDE;
|
||||
virtual CefString GetSelectionAsText() OVERRIDE;
|
||||
virtual CefString GetBaseURL() OVERRIDE;
|
||||
virtual CefString GetCompleteURL(const CefString& partialURL) OVERRIDE;
|
||||
|
||||
CefBrowserImpl* GetBrowser() { return browser_; }
|
||||
WebKit::WebFrame* GetFrame() { return frame_; }
|
||||
|
||||
// The document maintains a map of all existing node objects.
|
||||
CefRefPtr<CefDOMNode> GetOrCreateNode(const WebKit::WebNode& node);
|
||||
void RemoveNode(const WebKit::WebNode& node);
|
||||
|
||||
// Must be called before the object is destroyed.
|
||||
void Detach();
|
||||
|
||||
// Verify that the object exists and is being accessed on the UI thread.
|
||||
bool VerifyContext();
|
||||
|
||||
protected:
|
||||
CefBrowserImpl* browser_;
|
||||
WebKit::WebFrame* frame_;
|
||||
|
||||
typedef std::map<WebKit::WebNode, CefDOMNode*> NodeMap;
|
||||
NodeMap node_map_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(CefDOMDocumentImpl);
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_DOM_DOCUMENT_IMPL_H_
|
160
libcef/renderer/dom_event_impl.cc
Normal file
160
libcef/renderer/dom_event_impl.cc
Normal file
@ -0,0 +1,160 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "libcef/renderer/dom_event_impl.h"
|
||||
#include "libcef/renderer/dom_document_impl.h"
|
||||
#include "libcef/renderer/thread_util.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMEvent.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
|
||||
|
||||
using WebKit::WebDOMEvent;
|
||||
using WebKit::WebString;
|
||||
|
||||
|
||||
CefDOMEventImpl::CefDOMEventImpl(CefRefPtr<CefDOMDocumentImpl> document,
|
||||
const WebKit::WebDOMEvent& event)
|
||||
: document_(document),
|
||||
event_(event) {
|
||||
DCHECK(!event_.isNull());
|
||||
}
|
||||
|
||||
CefDOMEventImpl::~CefDOMEventImpl() {
|
||||
CEF_REQUIRE_RT();
|
||||
DCHECK(event_.isNull());
|
||||
}
|
||||
|
||||
CefString CefDOMEventImpl::GetType() {
|
||||
CefString str;
|
||||
if (!VerifyContext())
|
||||
return str;
|
||||
|
||||
const WebString& type = event_.type();
|
||||
if (!type.isNull())
|
||||
str = type;
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
CefDOMEventImpl::Category CefDOMEventImpl::GetCategory() {
|
||||
if (!VerifyContext())
|
||||
return DOM_EVENT_CATEGORY_UNKNOWN;
|
||||
|
||||
int flags = 0;
|
||||
if (event_.isUIEvent())
|
||||
flags |= DOM_EVENT_CATEGORY_UI;
|
||||
if (event_.isMouseEvent())
|
||||
flags |= DOM_EVENT_CATEGORY_MOUSE;
|
||||
if (event_.isMutationEvent())
|
||||
flags |= DOM_EVENT_CATEGORY_MUTATION;
|
||||
if (event_.isKeyboardEvent())
|
||||
flags |= DOM_EVENT_CATEGORY_KEYBOARD;
|
||||
if (event_.isTextEvent())
|
||||
flags |= DOM_EVENT_CATEGORY_TEXT;
|
||||
if (event_.isCompositionEvent())
|
||||
flags |= DOM_EVENT_CATEGORY_COMPOSITION;
|
||||
if (event_.isDragEvent())
|
||||
flags |= DOM_EVENT_CATEGORY_DRAG;
|
||||
if (event_.isClipboardEvent())
|
||||
flags |= DOM_EVENT_CATEGORY_CLIPBOARD;
|
||||
if (event_.isMessageEvent())
|
||||
flags |= DOM_EVENT_CATEGORY_MESSAGE;
|
||||
if (event_.isWheelEvent())
|
||||
flags |= DOM_EVENT_CATEGORY_WHEEL;
|
||||
if (event_.isBeforeTextInsertedEvent())
|
||||
flags |= DOM_EVENT_CATEGORY_BEFORE_TEXT_INSERTED;
|
||||
if (event_.isOverflowEvent())
|
||||
flags |= DOM_EVENT_CATEGORY_OVERFLOW;
|
||||
if (event_.isPageTransitionEvent())
|
||||
flags |= DOM_EVENT_CATEGORY_PAGE_TRANSITION;
|
||||
if (event_.isPopStateEvent())
|
||||
flags |= DOM_EVENT_CATEGORY_POPSTATE;
|
||||
if (event_.isProgressEvent())
|
||||
flags |= DOM_EVENT_CATEGORY_PROGRESS;
|
||||
if (event_.isXMLHttpRequestProgressEvent())
|
||||
flags |= DOM_EVENT_CATEGORY_XMLHTTPREQUEST_PROGRESS;
|
||||
if (event_.isWebKitAnimationEvent())
|
||||
flags |= DOM_EVENT_CATEGORY_WEBKIT_ANIMATION;
|
||||
if (event_.isWebKitTransitionEvent())
|
||||
flags |= DOM_EVENT_CATEGORY_WEBKIT_TRANSITION;
|
||||
if (event_.isBeforeLoadEvent())
|
||||
flags |= DOM_EVENT_CATEGORY_BEFORE_LOAD;
|
||||
|
||||
return static_cast<Category>(flags);
|
||||
}
|
||||
|
||||
CefDOMEventImpl::Phase CefDOMEventImpl::GetPhase() {
|
||||
if (!VerifyContext())
|
||||
return DOM_EVENT_PHASE_UNKNOWN;
|
||||
|
||||
switch (event_.eventPhase()) {
|
||||
case WebDOMEvent::CapturingPhase:
|
||||
return DOM_EVENT_PHASE_CAPTURING;
|
||||
case WebDOMEvent::AtTarget:
|
||||
return DOM_EVENT_PHASE_AT_TARGET;
|
||||
case WebDOMEvent::BubblingPhase:
|
||||
return DOM_EVENT_PHASE_BUBBLING;
|
||||
}
|
||||
|
||||
return DOM_EVENT_PHASE_UNKNOWN;
|
||||
}
|
||||
|
||||
bool CefDOMEventImpl::CanBubble() {
|
||||
if (!VerifyContext())
|
||||
return false;
|
||||
|
||||
return event_.bubbles();
|
||||
}
|
||||
|
||||
bool CefDOMEventImpl::CanCancel() {
|
||||
if (!VerifyContext())
|
||||
return false;
|
||||
|
||||
return event_.cancelable();
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMDocument> CefDOMEventImpl::GetDocument() {
|
||||
if (!VerifyContext())
|
||||
return NULL;
|
||||
|
||||
return document_.get();
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMEventImpl::GetTarget() {
|
||||
if (!VerifyContext())
|
||||
return NULL;
|
||||
|
||||
return document_->GetOrCreateNode(event_.target());
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMEventImpl::GetCurrentTarget() {
|
||||
if (!VerifyContext())
|
||||
return NULL;
|
||||
|
||||
return document_->GetOrCreateNode(event_.currentTarget());
|
||||
}
|
||||
|
||||
void CefDOMEventImpl::Detach() {
|
||||
// If you hit this assert it means that you are keeping references to this
|
||||
// event object beyond the valid scope.
|
||||
DCHECK_EQ(GetRefCt(), 1);
|
||||
|
||||
document_ = NULL;
|
||||
event_.assign(WebDOMEvent());
|
||||
}
|
||||
|
||||
bool CefDOMEventImpl::VerifyContext() {
|
||||
if (!document_.get()) {
|
||||
NOTREACHED();
|
||||
return false;
|
||||
}
|
||||
if (!document_->VerifyContext())
|
||||
return false;
|
||||
if (event_.isNull()) {
|
||||
NOTREACHED();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
43
libcef/renderer/dom_event_impl.h
Normal file
43
libcef/renderer/dom_event_impl.h
Normal file
@ -0,0 +1,43 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_DOM_EVENT_IMPL_H_
|
||||
#define CEF_LIBCEF_DOM_EVENT_IMPL_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_dom.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMEvent.h"
|
||||
|
||||
class CefDOMDocumentImpl;
|
||||
|
||||
class CefDOMEventImpl : public CefDOMEvent {
|
||||
public:
|
||||
CefDOMEventImpl(CefRefPtr<CefDOMDocumentImpl> document,
|
||||
const WebKit::WebDOMEvent& event);
|
||||
virtual ~CefDOMEventImpl();
|
||||
|
||||
// CefDOMEvent methods.
|
||||
virtual CefString GetType() OVERRIDE;
|
||||
virtual Category GetCategory() OVERRIDE;
|
||||
virtual Phase GetPhase() OVERRIDE;
|
||||
virtual bool CanBubble() OVERRIDE;
|
||||
virtual bool CanCancel() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMDocument> GetDocument() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMNode> GetTarget() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMNode> GetCurrentTarget() OVERRIDE;
|
||||
|
||||
// Will be called from CefDOMEventListenerWrapper::handleEvent().
|
||||
void Detach();
|
||||
|
||||
// Verify that the object exists and is being accessed on the UI thread.
|
||||
bool VerifyContext();
|
||||
|
||||
protected:
|
||||
CefRefPtr<CefDOMDocumentImpl> document_;
|
||||
WebKit::WebDOMEvent event_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(CefDOMEventImpl);
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_DOM_EVENT_IMPL_H_
|
459
libcef/renderer/dom_node_impl.cc
Normal file
459
libcef/renderer/dom_node_impl.cc
Normal file
@ -0,0 +1,459 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "libcef/renderer/dom_node_impl.h"
|
||||
#include "libcef/common/tracker.h"
|
||||
#include "libcef/renderer/browser_impl.h"
|
||||
#include "libcef/renderer/dom_document_impl.h"
|
||||
#include "libcef/renderer/dom_event_impl.h"
|
||||
#include "libcef/renderer/thread_util.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/string_util.h"
|
||||
#include "base/utf_string_conversions.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMEvent.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMEventListener.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSelectElement.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
|
||||
|
||||
using WebKit::WebDocument;
|
||||
using WebKit::WebDOMEvent;
|
||||
using WebKit::WebDOMEventListener;
|
||||
using WebKit::WebElement;
|
||||
using WebKit::WebFrame;
|
||||
using WebKit::WebFormControlElement;
|
||||
using WebKit::WebInputElement;
|
||||
using WebKit::WebNode;
|
||||
using WebKit::WebSelectElement;
|
||||
using WebKit::WebString;
|
||||
|
||||
namespace {
|
||||
|
||||
// Wrapper implementation for WebDOMEventListener.
|
||||
class CefDOMEventListenerWrapper : public WebDOMEventListener,
|
||||
public CefTrackNode {
|
||||
public:
|
||||
CefDOMEventListenerWrapper(CefBrowserImpl* browser, WebFrame* frame,
|
||||
CefRefPtr<CefDOMEventListener> listener)
|
||||
: browser_(browser),
|
||||
frame_(frame),
|
||||
listener_(listener) {
|
||||
// Cause this object to be deleted immediately before the frame is closed.
|
||||
browser->AddFrameObject(frame->identifier(), this);
|
||||
}
|
||||
virtual ~CefDOMEventListenerWrapper() {
|
||||
CEF_REQUIRE_RT();
|
||||
}
|
||||
|
||||
virtual void handleEvent(const WebDOMEvent& event) {
|
||||
CefRefPtr<CefDOMDocumentImpl> documentImpl;
|
||||
CefRefPtr<CefDOMEventImpl> eventImpl;
|
||||
|
||||
if (!event.isNull()) {
|
||||
// Create CefDOMDocumentImpl and CefDOMEventImpl objects that are valid
|
||||
// only for the scope of this method.
|
||||
const WebDocument& document = frame_->document();
|
||||
if (!document.isNull()) {
|
||||
documentImpl = new CefDOMDocumentImpl(browser_, frame_);
|
||||
eventImpl = new CefDOMEventImpl(documentImpl, event);
|
||||
}
|
||||
}
|
||||
|
||||
listener_->HandleEvent(eventImpl.get());
|
||||
|
||||
if (eventImpl.get())
|
||||
eventImpl->Detach();
|
||||
if (documentImpl.get())
|
||||
documentImpl->Detach();
|
||||
}
|
||||
|
||||
protected:
|
||||
CefBrowserImpl* browser_;
|
||||
WebFrame* frame_;
|
||||
CefRefPtr<CefDOMEventListener> listener_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
CefDOMNodeImpl::CefDOMNodeImpl(CefRefPtr<CefDOMDocumentImpl> document,
|
||||
const WebKit::WebNode& node)
|
||||
: document_(document),
|
||||
node_(node) {
|
||||
}
|
||||
|
||||
CefDOMNodeImpl::~CefDOMNodeImpl() {
|
||||
CEF_REQUIRE_RT();
|
||||
|
||||
if (document_.get() && !node_.isNull()) {
|
||||
// Remove the node from the document.
|
||||
document_->RemoveNode(node_);
|
||||
}
|
||||
}
|
||||
|
||||
CefDOMNodeImpl::Type CefDOMNodeImpl::GetType() {
|
||||
if (!VerifyContext())
|
||||
return DOM_NODE_TYPE_UNSUPPORTED;
|
||||
|
||||
switch (node_.nodeType()) {
|
||||
case WebNode::ElementNode:
|
||||
return DOM_NODE_TYPE_ELEMENT;
|
||||
case WebNode::AttributeNode:
|
||||
return DOM_NODE_TYPE_ATTRIBUTE;
|
||||
case WebNode::TextNode:
|
||||
return DOM_NODE_TYPE_TEXT;
|
||||
case WebNode::CDataSectionNode:
|
||||
return DOM_NODE_TYPE_CDATA_SECTION;
|
||||
case WebNode::EntityReferenceNode:
|
||||
return DOM_NODE_TYPE_ENTITY_REFERENCE;
|
||||
case WebNode::EntityNode:
|
||||
return DOM_NODE_TYPE_ENTITY;
|
||||
case WebNode::ProcessingInstructionsNode:
|
||||
return DOM_NODE_TYPE_PROCESSING_INSTRUCTIONS;
|
||||
case WebNode::CommentNode:
|
||||
return DOM_NODE_TYPE_COMMENT;
|
||||
case WebNode::DocumentNode:
|
||||
return DOM_NODE_TYPE_DOCUMENT;
|
||||
case WebNode::DocumentTypeNode:
|
||||
return DOM_NODE_TYPE_DOCUMENT_TYPE;
|
||||
case WebNode::DocumentFragmentNode:
|
||||
return DOM_NODE_TYPE_DOCUMENT_FRAGMENT;
|
||||
case WebNode::NotationNode:
|
||||
return DOM_NODE_TYPE_NOTATION;
|
||||
case WebNode::XPathNamespaceNode:
|
||||
return DOM_NODE_TYPE_XPATH_NAMESPACE;
|
||||
default:
|
||||
return DOM_NODE_TYPE_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
bool CefDOMNodeImpl::IsText() {
|
||||
if (!VerifyContext())
|
||||
return false;
|
||||
|
||||
return node_.isTextNode();
|
||||
}
|
||||
|
||||
bool CefDOMNodeImpl::IsElement() {
|
||||
if (!VerifyContext())
|
||||
return false;
|
||||
|
||||
return node_.isElementNode();
|
||||
}
|
||||
|
||||
bool CefDOMNodeImpl::IsFormControlElement() {
|
||||
if (!VerifyContext())
|
||||
return false;
|
||||
|
||||
if (node_.isElementNode()) {
|
||||
const WebElement& element = node_.toConst<WebElement>();
|
||||
return element.isFormControlElement();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
CefString CefDOMNodeImpl::GetFormControlElementType() {
|
||||
CefString str;
|
||||
if (!VerifyContext())
|
||||
return str;
|
||||
|
||||
if (node_.isElementNode()) {
|
||||
const WebElement& element = node_.toConst<WebElement>();
|
||||
if (element.isFormControlElement()) {
|
||||
// Retrieve the type from the form control element.
|
||||
const WebFormControlElement& formElement =
|
||||
node_.toConst<WebFormControlElement>();
|
||||
|
||||
const string16& form_control_type = formElement.formControlType();
|
||||
str = form_control_type;
|
||||
}
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
bool CefDOMNodeImpl::IsSame(CefRefPtr<CefDOMNode> that) {
|
||||
if (!VerifyContext())
|
||||
return false;
|
||||
|
||||
CefDOMNodeImpl* impl = static_cast<CefDOMNodeImpl*>(that.get());
|
||||
if (!impl || !impl->VerifyContext())
|
||||
return false;
|
||||
|
||||
return node_.equals(impl->node_);
|
||||
}
|
||||
|
||||
CefString CefDOMNodeImpl::GetName() {
|
||||
CefString str;
|
||||
if (!VerifyContext())
|
||||
return str;
|
||||
|
||||
const WebString& name = node_.nodeName();
|
||||
if (!name.isNull())
|
||||
str = name;
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
CefString CefDOMNodeImpl::GetValue() {
|
||||
CefString str;
|
||||
if (!VerifyContext())
|
||||
return str;
|
||||
|
||||
if (node_.isElementNode()) {
|
||||
const WebElement& element = node_.toConst<WebElement>();
|
||||
if (element.isFormControlElement()) {
|
||||
// Retrieve the value from the form control element.
|
||||
const WebFormControlElement& formElement =
|
||||
node_.toConst<WebFormControlElement>();
|
||||
|
||||
string16 value;
|
||||
const string16& form_control_type = formElement.formControlType();
|
||||
if (form_control_type == ASCIIToUTF16("text")) {
|
||||
const WebInputElement& input_element =
|
||||
formElement.toConst<WebInputElement>();
|
||||
value = input_element.value();
|
||||
} else if (form_control_type == ASCIIToUTF16("select-one")) {
|
||||
const WebSelectElement& select_element =
|
||||
formElement.toConst<WebSelectElement>();
|
||||
value = select_element.value();
|
||||
}
|
||||
|
||||
TrimWhitespace(value, TRIM_LEADING, &value);
|
||||
str = value;
|
||||
}
|
||||
}
|
||||
|
||||
if (str.empty()) {
|
||||
const WebString& value = node_.nodeValue();
|
||||
if (!value.isNull())
|
||||
str = value;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
bool CefDOMNodeImpl::SetValue(const CefString& value) {
|
||||
if (!VerifyContext())
|
||||
return false;
|
||||
|
||||
if (node_.isElementNode())
|
||||
return false;
|
||||
|
||||
return node_.setNodeValue(string16(value));
|
||||
}
|
||||
|
||||
CefString CefDOMNodeImpl::GetAsMarkup() {
|
||||
CefString str;
|
||||
if (!VerifyContext())
|
||||
return str;
|
||||
|
||||
const WebString& markup = node_.createMarkup();
|
||||
if (!markup.isNull())
|
||||
str = markup;
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMDocument> CefDOMNodeImpl::GetDocument() {
|
||||
if (!VerifyContext())
|
||||
return NULL;
|
||||
|
||||
return document_.get();
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMNodeImpl::GetParent() {
|
||||
if (!VerifyContext())
|
||||
return NULL;
|
||||
|
||||
return document_->GetOrCreateNode(node_.parentNode());
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMNodeImpl::GetPreviousSibling() {
|
||||
if (!VerifyContext())
|
||||
return NULL;
|
||||
|
||||
return document_->GetOrCreateNode(node_.previousSibling());
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMNodeImpl::GetNextSibling() {
|
||||
if (!VerifyContext())
|
||||
return NULL;
|
||||
|
||||
return document_->GetOrCreateNode(node_.nextSibling());
|
||||
}
|
||||
|
||||
bool CefDOMNodeImpl::HasChildren() {
|
||||
if (!VerifyContext())
|
||||
return false;
|
||||
|
||||
return node_.hasChildNodes();
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMNodeImpl::GetFirstChild() {
|
||||
if (!VerifyContext())
|
||||
return NULL;
|
||||
|
||||
return document_->GetOrCreateNode(node_.firstChild());
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMNodeImpl::GetLastChild() {
|
||||
if (!VerifyContext())
|
||||
return NULL;
|
||||
|
||||
return document_->GetOrCreateNode(node_.lastChild());
|
||||
}
|
||||
|
||||
void CefDOMNodeImpl::AddEventListener(const CefString& eventType,
|
||||
CefRefPtr<CefDOMEventListener> listener,
|
||||
bool useCapture) {
|
||||
if (!VerifyContext())
|
||||
return;
|
||||
|
||||
node_.addEventListener(string16(eventType),
|
||||
new CefDOMEventListenerWrapper(document_->GetBrowser(),
|
||||
document_->GetFrame(), listener),
|
||||
useCapture);
|
||||
}
|
||||
|
||||
CefString CefDOMNodeImpl::GetElementTagName() {
|
||||
CefString str;
|
||||
if (!VerifyContext())
|
||||
return str;
|
||||
|
||||
if (!node_.isElementNode()) {
|
||||
NOTREACHED();
|
||||
return str;
|
||||
}
|
||||
|
||||
const WebElement& element = node_.toConst<WebKit::WebElement>();
|
||||
const WebString& tagname = element.tagName();
|
||||
if (!tagname.isNull())
|
||||
str = tagname;
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
bool CefDOMNodeImpl::HasElementAttributes() {
|
||||
if (!VerifyContext())
|
||||
return false;
|
||||
|
||||
if (!node_.isElementNode()) {
|
||||
NOTREACHED();
|
||||
return false;
|
||||
}
|
||||
|
||||
const WebElement& element = node_.toConst<WebKit::WebElement>();
|
||||
return (element.attributeCount() > 0);
|
||||
}
|
||||
|
||||
bool CefDOMNodeImpl::HasElementAttribute(const CefString& attrName) {
|
||||
if (!VerifyContext())
|
||||
return false;
|
||||
|
||||
if (!node_.isElementNode()) {
|
||||
NOTREACHED();
|
||||
return false;
|
||||
}
|
||||
|
||||
const WebElement& element = node_.toConst<WebKit::WebElement>();
|
||||
return element.hasAttribute(string16(attrName));
|
||||
}
|
||||
|
||||
CefString CefDOMNodeImpl::GetElementAttribute(const CefString& attrName) {
|
||||
CefString str;
|
||||
if (!VerifyContext())
|
||||
return str;
|
||||
|
||||
if (!node_.isElementNode()) {
|
||||
NOTREACHED();
|
||||
return str;
|
||||
}
|
||||
|
||||
const WebElement& element = node_.toConst<WebKit::WebElement>();
|
||||
const WebString& attr = element.getAttribute(string16(attrName));
|
||||
if (!attr.isNull())
|
||||
str = attr;
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
void CefDOMNodeImpl::GetElementAttributes(AttributeMap& attrMap) {
|
||||
if (!VerifyContext())
|
||||
return;
|
||||
|
||||
if (!node_.isElementNode()) {
|
||||
NOTREACHED();
|
||||
return;
|
||||
}
|
||||
|
||||
const WebElement& element = node_.toConst<WebKit::WebElement>();
|
||||
unsigned int len = element.attributeCount();
|
||||
if (len == 0)
|
||||
return;
|
||||
|
||||
for (unsigned int i = 0; i < len; ++i) {
|
||||
string16 name = element.attributeLocalName(i);
|
||||
string16 value = element.attributeValue(i);
|
||||
attrMap.insert(std::make_pair(name, value));
|
||||
}
|
||||
}
|
||||
|
||||
bool CefDOMNodeImpl::SetElementAttribute(const CefString& attrName,
|
||||
const CefString& value) {
|
||||
if (!VerifyContext())
|
||||
return false;
|
||||
|
||||
if (!node_.isElementNode()) {
|
||||
NOTREACHED();
|
||||
return false;
|
||||
}
|
||||
|
||||
WebElement element = node_.to<WebKit::WebElement>();
|
||||
return element.setAttribute(string16(attrName), string16(value));
|
||||
}
|
||||
|
||||
CefString CefDOMNodeImpl::GetElementInnerText() {
|
||||
CefString str;
|
||||
if (!VerifyContext())
|
||||
return str;
|
||||
|
||||
if (!node_.isElementNode()) {
|
||||
NOTREACHED();
|
||||
return str;
|
||||
}
|
||||
|
||||
WebElement element = node_.to<WebKit::WebElement>();
|
||||
const WebString& text = element.innerText();
|
||||
if (!text.isNull())
|
||||
str = text;
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
void CefDOMNodeImpl::Detach() {
|
||||
document_ = NULL;
|
||||
node_.assign(WebNode());
|
||||
}
|
||||
|
||||
bool CefDOMNodeImpl::VerifyContext() {
|
||||
if (!document_.get()) {
|
||||
NOTREACHED();
|
||||
return false;
|
||||
}
|
||||
if (!document_->VerifyContext())
|
||||
return false;
|
||||
if (node_.isNull()) {
|
||||
NOTREACHED();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
63
libcef/renderer/dom_node_impl.h
Normal file
63
libcef/renderer/dom_node_impl.h
Normal file
@ -0,0 +1,63 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_DOM_NODE_IMPL_H_
|
||||
#define CEF_LIBCEF_DOM_NODE_IMPL_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_dom.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h"
|
||||
|
||||
class CefDOMDocumentImpl;
|
||||
|
||||
class CefDOMNodeImpl : public CefDOMNode {
|
||||
public:
|
||||
CefDOMNodeImpl(CefRefPtr<CefDOMDocumentImpl> document,
|
||||
const WebKit::WebNode& node);
|
||||
virtual ~CefDOMNodeImpl();
|
||||
|
||||
// CefDOMNode methods.
|
||||
virtual Type GetType() OVERRIDE;
|
||||
virtual bool IsText() OVERRIDE;
|
||||
virtual bool IsElement() OVERRIDE;
|
||||
virtual bool IsFormControlElement() OVERRIDE;
|
||||
virtual CefString GetFormControlElementType() OVERRIDE;
|
||||
virtual bool IsSame(CefRefPtr<CefDOMNode> that) OVERRIDE;
|
||||
virtual CefString GetName() OVERRIDE;
|
||||
virtual CefString GetValue() OVERRIDE;
|
||||
virtual bool SetValue(const CefString& value) OVERRIDE;
|
||||
virtual CefString GetAsMarkup() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMDocument> GetDocument() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMNode> GetParent() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMNode> GetPreviousSibling() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMNode> GetNextSibling() OVERRIDE;
|
||||
virtual bool HasChildren() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMNode> GetFirstChild() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMNode> GetLastChild() OVERRIDE;
|
||||
virtual void AddEventListener(const CefString& eventType,
|
||||
CefRefPtr<CefDOMEventListener> listener,
|
||||
bool useCapture) OVERRIDE;
|
||||
virtual CefString GetElementTagName() OVERRIDE;
|
||||
virtual bool HasElementAttributes() OVERRIDE;
|
||||
virtual bool HasElementAttribute(const CefString& attrName) OVERRIDE;
|
||||
virtual CefString GetElementAttribute(const CefString& attrName) OVERRIDE;
|
||||
virtual void GetElementAttributes(AttributeMap& attrMap) OVERRIDE;
|
||||
virtual bool SetElementAttribute(const CefString& attrName,
|
||||
const CefString& value) OVERRIDE;
|
||||
virtual CefString GetElementInnerText() OVERRIDE;
|
||||
|
||||
// Will be called from CefDOMDocumentImpl::Detach().
|
||||
void Detach();
|
||||
|
||||
// Verify that the object exists and is being accessed on the UI thread.
|
||||
bool VerifyContext();
|
||||
|
||||
protected:
|
||||
CefRefPtr<CefDOMDocumentImpl> document_;
|
||||
WebKit::WebNode node_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(CefDOMNodeImpl);
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_DOM_NODE_IMPL_H_
|
@ -8,6 +8,7 @@
|
||||
#include "libcef/common/http_header_utils.h"
|
||||
#include "libcef/common/request_impl.h"
|
||||
#include "libcef/renderer/browser_impl.h"
|
||||
#include "libcef/renderer/dom_document_impl.h"
|
||||
#include "libcef/renderer/thread_util.h"
|
||||
#include "libcef/renderer/v8_impl.h"
|
||||
#include "libcef/renderer/webkit_glue.h"
|
||||
@ -240,6 +241,25 @@ CefRefPtr<CefV8Context> CefFrameImpl::GetV8Context() {
|
||||
}
|
||||
}
|
||||
|
||||
void CefFrameImpl::VisitDOM(CefRefPtr<CefDOMVisitor> visitor) {
|
||||
CEF_REQUIRE_RT_RETURN_VOID();
|
||||
|
||||
if (!frame_)
|
||||
return;
|
||||
|
||||
// Create a CefDOMDocumentImpl object that is valid only for the scope of this
|
||||
// method.
|
||||
CefRefPtr<CefDOMDocumentImpl> documentImpl;
|
||||
const WebKit::WebDocument& document = frame_->document();
|
||||
if (!document.isNull())
|
||||
documentImpl = new CefDOMDocumentImpl(browser_, frame_);
|
||||
|
||||
visitor->Visit(documentImpl.get());
|
||||
|
||||
if (documentImpl.get())
|
||||
documentImpl->Detach();
|
||||
}
|
||||
|
||||
void CefFrameImpl::Detach() {
|
||||
browser_ = NULL;
|
||||
frame_ = NULL;
|
||||
|
@ -52,6 +52,7 @@ class CefFrameImpl : public CefFrame {
|
||||
virtual CefString GetURL() OVERRIDE;
|
||||
virtual CefRefPtr<CefBrowser> GetBrowser() OVERRIDE;
|
||||
virtual CefRefPtr<CefV8Context> GetV8Context() OVERRIDE;
|
||||
virtual void VisitDOM(CefRefPtr<CefDOMVisitor> visitor) OVERRIDE;
|
||||
|
||||
void Detach();
|
||||
|
||||
|
303
libcef_dll/cpptoc/domdocument_cpptoc.cc
Normal file
303
libcef_dll/cpptoc/domdocument_cpptoc.cc
Normal file
@ -0,0 +1,303 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/domdocument_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/domnode_cpptoc.h"
|
||||
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
enum cef_dom_document_type_t CEF_CALLBACK domdocument_get_type(
|
||||
struct _cef_domdocument_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return DOM_DOCUMENT_TYPE_UNKNOWN;
|
||||
|
||||
// Execute
|
||||
cef_dom_document_type_t _retval = CefDOMDocumentCppToC::Get(self)->GetType();
|
||||
|
||||
// Return type: simple
|
||||
return _retval;
|
||||
}
|
||||
|
||||
struct _cef_domnode_t* CEF_CALLBACK domdocument_get_document(
|
||||
struct _cef_domdocument_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefDOMNode> _retval = CefDOMDocumentCppToC::Get(self)->GetDocument(
|
||||
);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMNodeCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
struct _cef_domnode_t* CEF_CALLBACK domdocument_get_body(
|
||||
struct _cef_domdocument_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefDOMNode> _retval = CefDOMDocumentCppToC::Get(self)->GetBody();
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMNodeCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
struct _cef_domnode_t* CEF_CALLBACK domdocument_get_head(
|
||||
struct _cef_domdocument_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefDOMNode> _retval = CefDOMDocumentCppToC::Get(self)->GetHead();
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMNodeCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
cef_string_userfree_t CEF_CALLBACK domdocument_get_title(
|
||||
struct _cef_domdocument_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefString _retval = CefDOMDocumentCppToC::Get(self)->GetTitle();
|
||||
|
||||
// Return type: string
|
||||
return _retval.DetachToUserFree();
|
||||
}
|
||||
|
||||
struct _cef_domnode_t* CEF_CALLBACK domdocument_get_element_by_id(
|
||||
struct _cef_domdocument_t* self, const cef_string_t* id) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
// Verify param: id; type: string_byref_const
|
||||
DCHECK(id);
|
||||
if (!id)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefDOMNode> _retval = CefDOMDocumentCppToC::Get(
|
||||
self)->GetElementById(
|
||||
CefString(id));
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMNodeCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
struct _cef_domnode_t* CEF_CALLBACK domdocument_get_focused_node(
|
||||
struct _cef_domdocument_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefDOMNode> _retval = CefDOMDocumentCppToC::Get(
|
||||
self)->GetFocusedNode();
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMNodeCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK domdocument_has_selection(struct _cef_domdocument_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefDOMDocumentCppToC::Get(self)->HasSelection();
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
struct _cef_domnode_t* CEF_CALLBACK domdocument_get_selection_start_node(
|
||||
struct _cef_domdocument_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefDOMNode> _retval = CefDOMDocumentCppToC::Get(
|
||||
self)->GetSelectionStartNode();
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMNodeCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK domdocument_get_selection_start_offset(
|
||||
struct _cef_domdocument_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
int _retval = CefDOMDocumentCppToC::Get(self)->GetSelectionStartOffset();
|
||||
|
||||
// Return type: simple
|
||||
return _retval;
|
||||
}
|
||||
|
||||
struct _cef_domnode_t* CEF_CALLBACK domdocument_get_selection_end_node(
|
||||
struct _cef_domdocument_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefDOMNode> _retval = CefDOMDocumentCppToC::Get(
|
||||
self)->GetSelectionEndNode();
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMNodeCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK domdocument_get_selection_end_offset(
|
||||
struct _cef_domdocument_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
int _retval = CefDOMDocumentCppToC::Get(self)->GetSelectionEndOffset();
|
||||
|
||||
// Return type: simple
|
||||
return _retval;
|
||||
}
|
||||
|
||||
cef_string_userfree_t CEF_CALLBACK domdocument_get_selection_as_markup(
|
||||
struct _cef_domdocument_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefString _retval = CefDOMDocumentCppToC::Get(self)->GetSelectionAsMarkup();
|
||||
|
||||
// Return type: string
|
||||
return _retval.DetachToUserFree();
|
||||
}
|
||||
|
||||
cef_string_userfree_t CEF_CALLBACK domdocument_get_selection_as_text(
|
||||
struct _cef_domdocument_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefString _retval = CefDOMDocumentCppToC::Get(self)->GetSelectionAsText();
|
||||
|
||||
// Return type: string
|
||||
return _retval.DetachToUserFree();
|
||||
}
|
||||
|
||||
cef_string_userfree_t CEF_CALLBACK domdocument_get_base_url(
|
||||
struct _cef_domdocument_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefString _retval = CefDOMDocumentCppToC::Get(self)->GetBaseURL();
|
||||
|
||||
// Return type: string
|
||||
return _retval.DetachToUserFree();
|
||||
}
|
||||
|
||||
cef_string_userfree_t CEF_CALLBACK domdocument_get_complete_url(
|
||||
struct _cef_domdocument_t* self, const cef_string_t* partialURL) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
// Verify param: partialURL; type: string_byref_const
|
||||
DCHECK(partialURL);
|
||||
if (!partialURL)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefString _retval = CefDOMDocumentCppToC::Get(self)->GetCompleteURL(
|
||||
CefString(partialURL));
|
||||
|
||||
// Return type: string
|
||||
return _retval.DetachToUserFree();
|
||||
}
|
||||
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefDOMDocumentCppToC::CefDOMDocumentCppToC(CefDOMDocument* cls)
|
||||
: CefCppToC<CefDOMDocumentCppToC, CefDOMDocument, cef_domdocument_t>(cls) {
|
||||
struct_.struct_.get_type = domdocument_get_type;
|
||||
struct_.struct_.get_document = domdocument_get_document;
|
||||
struct_.struct_.get_body = domdocument_get_body;
|
||||
struct_.struct_.get_head = domdocument_get_head;
|
||||
struct_.struct_.get_title = domdocument_get_title;
|
||||
struct_.struct_.get_element_by_id = domdocument_get_element_by_id;
|
||||
struct_.struct_.get_focused_node = domdocument_get_focused_node;
|
||||
struct_.struct_.has_selection = domdocument_has_selection;
|
||||
struct_.struct_.get_selection_start_node =
|
||||
domdocument_get_selection_start_node;
|
||||
struct_.struct_.get_selection_start_offset =
|
||||
domdocument_get_selection_start_offset;
|
||||
struct_.struct_.get_selection_end_node = domdocument_get_selection_end_node;
|
||||
struct_.struct_.get_selection_end_offset =
|
||||
domdocument_get_selection_end_offset;
|
||||
struct_.struct_.get_selection_as_markup = domdocument_get_selection_as_markup;
|
||||
struct_.struct_.get_selection_as_text = domdocument_get_selection_as_text;
|
||||
struct_.struct_.get_base_url = domdocument_get_base_url;
|
||||
struct_.struct_.get_complete_url = domdocument_get_complete_url;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCppToC<CefDOMDocumentCppToC, CefDOMDocument,
|
||||
cef_domdocument_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
37
libcef_dll/cpptoc/domdocument_cpptoc.h
Normal file
37
libcef_dll/cpptoc/domdocument_cpptoc.h
Normal file
@ -0,0 +1,37 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CPPTOC_DOMDOCUMENT_CPPTOC_H_
|
||||
#define CEF_LIBCEF_DLL_CPPTOC_DOMDOCUMENT_CPPTOC_H_
|
||||
#pragma once
|
||||
|
||||
#ifndef BUILDING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
|
||||
#else // BUILDING_CEF_SHARED
|
||||
|
||||
#include "include/cef_dom.h"
|
||||
#include "include/capi/cef_dom_capi.h"
|
||||
#include "libcef_dll/cpptoc/cpptoc.h"
|
||||
|
||||
// Wrap a C++ class with a C structure.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefDOMDocumentCppToC
|
||||
: public CefCppToC<CefDOMDocumentCppToC, CefDOMDocument,
|
||||
cef_domdocument_t> {
|
||||
public:
|
||||
explicit CefDOMDocumentCppToC(CefDOMDocument* cls);
|
||||
virtual ~CefDOMDocumentCppToC() {}
|
||||
};
|
||||
|
||||
#endif // BUILDING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CPPTOC_DOMDOCUMENT_CPPTOC_H_
|
||||
|
159
libcef_dll/cpptoc/domevent_cpptoc.cc
Normal file
159
libcef_dll/cpptoc/domevent_cpptoc.cc
Normal file
@ -0,0 +1,159 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/domdocument_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/domevent_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/domnode_cpptoc.h"
|
||||
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
cef_string_userfree_t CEF_CALLBACK domevent_get_type(
|
||||
struct _cef_domevent_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefString _retval = CefDOMEventCppToC::Get(self)->GetType();
|
||||
|
||||
// Return type: string
|
||||
return _retval.DetachToUserFree();
|
||||
}
|
||||
|
||||
enum cef_dom_event_category_t CEF_CALLBACK domevent_get_category(
|
||||
struct _cef_domevent_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return DOM_EVENT_CATEGORY_UNKNOWN;
|
||||
|
||||
// Execute
|
||||
cef_dom_event_category_t _retval = CefDOMEventCppToC::Get(self)->GetCategory(
|
||||
);
|
||||
|
||||
// Return type: simple
|
||||
return _retval;
|
||||
}
|
||||
|
||||
enum cef_dom_event_phase_t CEF_CALLBACK domevent_get_phase(
|
||||
struct _cef_domevent_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return DOM_EVENT_PHASE_UNKNOWN;
|
||||
|
||||
// Execute
|
||||
cef_dom_event_phase_t _retval = CefDOMEventCppToC::Get(self)->GetPhase();
|
||||
|
||||
// Return type: simple
|
||||
return _retval;
|
||||
}
|
||||
|
||||
int CEF_CALLBACK domevent_can_bubble(struct _cef_domevent_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefDOMEventCppToC::Get(self)->CanBubble();
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
int CEF_CALLBACK domevent_can_cancel(struct _cef_domevent_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefDOMEventCppToC::Get(self)->CanCancel();
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
cef_domdocument_t* CEF_CALLBACK domevent_get_document(
|
||||
struct _cef_domevent_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefDOMDocument> _retval = CefDOMEventCppToC::Get(self)->GetDocument(
|
||||
);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMDocumentCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
cef_domnode_t* CEF_CALLBACK domevent_get_target(struct _cef_domevent_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefDOMNode> _retval = CefDOMEventCppToC::Get(self)->GetTarget();
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMNodeCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
cef_domnode_t* CEF_CALLBACK domevent_get_current_target(
|
||||
struct _cef_domevent_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefDOMNode> _retval = CefDOMEventCppToC::Get(
|
||||
self)->GetCurrentTarget();
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMNodeCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefDOMEventCppToC::CefDOMEventCppToC(CefDOMEvent* cls)
|
||||
: CefCppToC<CefDOMEventCppToC, CefDOMEvent, cef_domevent_t>(cls) {
|
||||
struct_.struct_.get_type = domevent_get_type;
|
||||
struct_.struct_.get_category = domevent_get_category;
|
||||
struct_.struct_.get_phase = domevent_get_phase;
|
||||
struct_.struct_.can_bubble = domevent_can_bubble;
|
||||
struct_.struct_.can_cancel = domevent_can_cancel;
|
||||
struct_.struct_.get_document = domevent_get_document;
|
||||
struct_.struct_.get_target = domevent_get_target;
|
||||
struct_.struct_.get_current_target = domevent_get_current_target;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCppToC<CefDOMEventCppToC, CefDOMEvent,
|
||||
cef_domevent_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
36
libcef_dll/cpptoc/domevent_cpptoc.h
Normal file
36
libcef_dll/cpptoc/domevent_cpptoc.h
Normal file
@ -0,0 +1,36 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CPPTOC_DOMEVENT_CPPTOC_H_
|
||||
#define CEF_LIBCEF_DLL_CPPTOC_DOMEVENT_CPPTOC_H_
|
||||
#pragma once
|
||||
|
||||
#ifndef BUILDING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
|
||||
#else // BUILDING_CEF_SHARED
|
||||
|
||||
#include "include/cef_dom.h"
|
||||
#include "include/capi/cef_dom_capi.h"
|
||||
#include "libcef_dll/cpptoc/cpptoc.h"
|
||||
|
||||
// Wrap a C++ class with a C structure.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefDOMEventCppToC
|
||||
: public CefCppToC<CefDOMEventCppToC, CefDOMEvent, cef_domevent_t> {
|
||||
public:
|
||||
explicit CefDOMEventCppToC(CefDOMEvent* cls);
|
||||
virtual ~CefDOMEventCppToC() {}
|
||||
};
|
||||
|
||||
#endif // BUILDING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CPPTOC_DOMEVENT_CPPTOC_H_
|
||||
|
49
libcef_dll/cpptoc/domevent_listener_cpptoc.cc
Normal file
49
libcef_dll/cpptoc/domevent_listener_cpptoc.cc
Normal file
@ -0,0 +1,49 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/domevent_listener_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/domevent_ctocpp.h"
|
||||
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
void CEF_CALLBACK domevent_listener_handle_event(
|
||||
struct _cef_domevent_listener_t* self, cef_domevent_t* event) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
// Verify param: event; type: refptr_diff
|
||||
DCHECK(event);
|
||||
if (!event)
|
||||
return;
|
||||
|
||||
// Execute
|
||||
CefDOMEventListenerCppToC::Get(self)->HandleEvent(
|
||||
CefDOMEventCToCpp::Wrap(event));
|
||||
}
|
||||
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefDOMEventListenerCppToC::CefDOMEventListenerCppToC(CefDOMEventListener* cls)
|
||||
: CefCppToC<CefDOMEventListenerCppToC, CefDOMEventListener,
|
||||
cef_domevent_listener_t>(cls) {
|
||||
struct_.struct_.handle_event = domevent_listener_handle_event;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCppToC<CefDOMEventListenerCppToC, CefDOMEventListener,
|
||||
cef_domevent_listener_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
37
libcef_dll/cpptoc/domevent_listener_cpptoc.h
Normal file
37
libcef_dll/cpptoc/domevent_listener_cpptoc.h
Normal file
@ -0,0 +1,37 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CPPTOC_DOMEVENT_LISTENER_CPPTOC_H_
|
||||
#define CEF_LIBCEF_DLL_CPPTOC_DOMEVENT_LISTENER_CPPTOC_H_
|
||||
#pragma once
|
||||
|
||||
#ifndef USING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
|
||||
#else // USING_CEF_SHARED
|
||||
|
||||
#include "include/cef_dom.h"
|
||||
#include "include/capi/cef_dom_capi.h"
|
||||
#include "libcef_dll/cpptoc/cpptoc.h"
|
||||
|
||||
// Wrap a C++ class with a C structure.
|
||||
// This class may be instantiated and accessed wrapper-side only.
|
||||
class CefDOMEventListenerCppToC
|
||||
: public CefCppToC<CefDOMEventListenerCppToC, CefDOMEventListener,
|
||||
cef_domevent_listener_t> {
|
||||
public:
|
||||
explicit CefDOMEventListenerCppToC(CefDOMEventListener* cls);
|
||||
virtual ~CefDOMEventListenerCppToC() {}
|
||||
};
|
||||
|
||||
#endif // USING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CPPTOC_DOMEVENT_LISTENER_CPPTOC_H_
|
||||
|
479
libcef_dll/cpptoc/domnode_cpptoc.cc
Normal file
479
libcef_dll/cpptoc/domnode_cpptoc.cc
Normal file
@ -0,0 +1,479 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/domdocument_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/domnode_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/domevent_listener_ctocpp.h"
|
||||
#include "libcef_dll/transfer_util.h"
|
||||
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
enum cef_dom_node_type_t CEF_CALLBACK domnode_get_type(
|
||||
struct _cef_domnode_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return DOM_NODE_TYPE_UNSUPPORTED;
|
||||
|
||||
// Execute
|
||||
cef_dom_node_type_t _retval = CefDOMNodeCppToC::Get(self)->GetType();
|
||||
|
||||
// Return type: simple
|
||||
return _retval;
|
||||
}
|
||||
|
||||
int CEF_CALLBACK domnode_is_text(struct _cef_domnode_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefDOMNodeCppToC::Get(self)->IsText();
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
int CEF_CALLBACK domnode_is_element(struct _cef_domnode_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefDOMNodeCppToC::Get(self)->IsElement();
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
int CEF_CALLBACK domnode_is_form_control_element(struct _cef_domnode_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefDOMNodeCppToC::Get(self)->IsFormControlElement();
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
cef_string_userfree_t CEF_CALLBACK domnode_get_form_control_element_type(
|
||||
struct _cef_domnode_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefString _retval = CefDOMNodeCppToC::Get(self)->GetFormControlElementType();
|
||||
|
||||
// Return type: string
|
||||
return _retval.DetachToUserFree();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK domnode_is_same(struct _cef_domnode_t* self,
|
||||
struct _cef_domnode_t* that) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
// Verify param: that; type: refptr_same
|
||||
DCHECK(that);
|
||||
if (!that)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefDOMNodeCppToC::Get(self)->IsSame(
|
||||
CefDOMNodeCppToC::Unwrap(that));
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
cef_string_userfree_t CEF_CALLBACK domnode_get_name(
|
||||
struct _cef_domnode_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefString _retval = CefDOMNodeCppToC::Get(self)->GetName();
|
||||
|
||||
// Return type: string
|
||||
return _retval.DetachToUserFree();
|
||||
}
|
||||
|
||||
cef_string_userfree_t CEF_CALLBACK domnode_get_value(
|
||||
struct _cef_domnode_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefString _retval = CefDOMNodeCppToC::Get(self)->GetValue();
|
||||
|
||||
// Return type: string
|
||||
return _retval.DetachToUserFree();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK domnode_set_value(struct _cef_domnode_t* self,
|
||||
const cef_string_t* value) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
// Verify param: value; type: string_byref_const
|
||||
DCHECK(value);
|
||||
if (!value)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefDOMNodeCppToC::Get(self)->SetValue(
|
||||
CefString(value));
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
cef_string_userfree_t CEF_CALLBACK domnode_get_as_markup(
|
||||
struct _cef_domnode_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefString _retval = CefDOMNodeCppToC::Get(self)->GetAsMarkup();
|
||||
|
||||
// Return type: string
|
||||
return _retval.DetachToUserFree();
|
||||
}
|
||||
|
||||
cef_domdocument_t* CEF_CALLBACK domnode_get_document(
|
||||
struct _cef_domnode_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefDOMDocument> _retval = CefDOMNodeCppToC::Get(self)->GetDocument(
|
||||
);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMDocumentCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
struct _cef_domnode_t* CEF_CALLBACK domnode_get_parent(
|
||||
struct _cef_domnode_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefDOMNode> _retval = CefDOMNodeCppToC::Get(self)->GetParent();
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMNodeCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
struct _cef_domnode_t* CEF_CALLBACK domnode_get_previous_sibling(
|
||||
struct _cef_domnode_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefDOMNode> _retval = CefDOMNodeCppToC::Get(
|
||||
self)->GetPreviousSibling();
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMNodeCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
struct _cef_domnode_t* CEF_CALLBACK domnode_get_next_sibling(
|
||||
struct _cef_domnode_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefDOMNode> _retval = CefDOMNodeCppToC::Get(self)->GetNextSibling();
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMNodeCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK domnode_has_children(struct _cef_domnode_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefDOMNodeCppToC::Get(self)->HasChildren();
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
struct _cef_domnode_t* CEF_CALLBACK domnode_get_first_child(
|
||||
struct _cef_domnode_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefDOMNode> _retval = CefDOMNodeCppToC::Get(self)->GetFirstChild();
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMNodeCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
struct _cef_domnode_t* CEF_CALLBACK domnode_get_last_child(
|
||||
struct _cef_domnode_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefDOMNode> _retval = CefDOMNodeCppToC::Get(self)->GetLastChild();
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMNodeCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK domnode_add_event_listener(struct _cef_domnode_t* self,
|
||||
const cef_string_t* eventType, struct _cef_domevent_listener_t* listener,
|
||||
int useCapture) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
// Verify param: eventType; type: string_byref_const
|
||||
DCHECK(eventType);
|
||||
if (!eventType)
|
||||
return;
|
||||
// Verify param: listener; type: refptr_diff
|
||||
DCHECK(listener);
|
||||
if (!listener)
|
||||
return;
|
||||
|
||||
// Execute
|
||||
CefDOMNodeCppToC::Get(self)->AddEventListener(
|
||||
CefString(eventType),
|
||||
CefDOMEventListenerCToCpp::Wrap(listener),
|
||||
useCapture?true:false);
|
||||
}
|
||||
|
||||
cef_string_userfree_t CEF_CALLBACK domnode_get_element_tag_name(
|
||||
struct _cef_domnode_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefString _retval = CefDOMNodeCppToC::Get(self)->GetElementTagName();
|
||||
|
||||
// Return type: string
|
||||
return _retval.DetachToUserFree();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK domnode_has_element_attributes(struct _cef_domnode_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefDOMNodeCppToC::Get(self)->HasElementAttributes();
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
int CEF_CALLBACK domnode_has_element_attribute(struct _cef_domnode_t* self,
|
||||
const cef_string_t* attrName) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
// Verify param: attrName; type: string_byref_const
|
||||
DCHECK(attrName);
|
||||
if (!attrName)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefDOMNodeCppToC::Get(self)->HasElementAttribute(
|
||||
CefString(attrName));
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
cef_string_userfree_t CEF_CALLBACK domnode_get_element_attribute(
|
||||
struct _cef_domnode_t* self, const cef_string_t* attrName) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
// Verify param: attrName; type: string_byref_const
|
||||
DCHECK(attrName);
|
||||
if (!attrName)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefString _retval = CefDOMNodeCppToC::Get(self)->GetElementAttribute(
|
||||
CefString(attrName));
|
||||
|
||||
// Return type: string
|
||||
return _retval.DetachToUserFree();
|
||||
}
|
||||
|
||||
void CEF_CALLBACK domnode_get_element_attributes(struct _cef_domnode_t* self,
|
||||
cef_string_map_t attrMap) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
// Verify param: attrMap; type: string_map_single_byref
|
||||
DCHECK(attrMap);
|
||||
if (!attrMap)
|
||||
return;
|
||||
|
||||
// Translate param: attrMap; type: string_map_single_byref
|
||||
std::map<CefString, CefString> attrMapMap;
|
||||
transfer_string_map_contents(attrMap, attrMapMap);
|
||||
|
||||
// Execute
|
||||
CefDOMNodeCppToC::Get(self)->GetElementAttributes(
|
||||
attrMapMap);
|
||||
|
||||
// Restore param: attrMap; type: string_map_single_byref
|
||||
cef_string_map_clear(attrMap);
|
||||
transfer_string_map_contents(attrMapMap, attrMap);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK domnode_set_element_attribute(struct _cef_domnode_t* self,
|
||||
const cef_string_t* attrName, const cef_string_t* value) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
// Verify param: attrName; type: string_byref_const
|
||||
DCHECK(attrName);
|
||||
if (!attrName)
|
||||
return 0;
|
||||
// Verify param: value; type: string_byref_const
|
||||
DCHECK(value);
|
||||
if (!value)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefDOMNodeCppToC::Get(self)->SetElementAttribute(
|
||||
CefString(attrName),
|
||||
CefString(value));
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
cef_string_userfree_t CEF_CALLBACK domnode_get_element_inner_text(
|
||||
struct _cef_domnode_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefString _retval = CefDOMNodeCppToC::Get(self)->GetElementInnerText();
|
||||
|
||||
// Return type: string
|
||||
return _retval.DetachToUserFree();
|
||||
}
|
||||
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefDOMNodeCppToC::CefDOMNodeCppToC(CefDOMNode* cls)
|
||||
: CefCppToC<CefDOMNodeCppToC, CefDOMNode, cef_domnode_t>(cls) {
|
||||
struct_.struct_.get_type = domnode_get_type;
|
||||
struct_.struct_.is_text = domnode_is_text;
|
||||
struct_.struct_.is_element = domnode_is_element;
|
||||
struct_.struct_.is_form_control_element = domnode_is_form_control_element;
|
||||
struct_.struct_.get_form_control_element_type =
|
||||
domnode_get_form_control_element_type;
|
||||
struct_.struct_.is_same = domnode_is_same;
|
||||
struct_.struct_.get_name = domnode_get_name;
|
||||
struct_.struct_.get_value = domnode_get_value;
|
||||
struct_.struct_.set_value = domnode_set_value;
|
||||
struct_.struct_.get_as_markup = domnode_get_as_markup;
|
||||
struct_.struct_.get_document = domnode_get_document;
|
||||
struct_.struct_.get_parent = domnode_get_parent;
|
||||
struct_.struct_.get_previous_sibling = domnode_get_previous_sibling;
|
||||
struct_.struct_.get_next_sibling = domnode_get_next_sibling;
|
||||
struct_.struct_.has_children = domnode_has_children;
|
||||
struct_.struct_.get_first_child = domnode_get_first_child;
|
||||
struct_.struct_.get_last_child = domnode_get_last_child;
|
||||
struct_.struct_.add_event_listener = domnode_add_event_listener;
|
||||
struct_.struct_.get_element_tag_name = domnode_get_element_tag_name;
|
||||
struct_.struct_.has_element_attributes = domnode_has_element_attributes;
|
||||
struct_.struct_.has_element_attribute = domnode_has_element_attribute;
|
||||
struct_.struct_.get_element_attribute = domnode_get_element_attribute;
|
||||
struct_.struct_.get_element_attributes = domnode_get_element_attributes;
|
||||
struct_.struct_.set_element_attribute = domnode_set_element_attribute;
|
||||
struct_.struct_.get_element_inner_text = domnode_get_element_inner_text;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCppToC<CefDOMNodeCppToC, CefDOMNode,
|
||||
cef_domnode_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
36
libcef_dll/cpptoc/domnode_cpptoc.h
Normal file
36
libcef_dll/cpptoc/domnode_cpptoc.h
Normal file
@ -0,0 +1,36 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CPPTOC_DOMNODE_CPPTOC_H_
|
||||
#define CEF_LIBCEF_DLL_CPPTOC_DOMNODE_CPPTOC_H_
|
||||
#pragma once
|
||||
|
||||
#ifndef BUILDING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
|
||||
#else // BUILDING_CEF_SHARED
|
||||
|
||||
#include "include/cef_dom.h"
|
||||
#include "include/capi/cef_dom_capi.h"
|
||||
#include "libcef_dll/cpptoc/cpptoc.h"
|
||||
|
||||
// Wrap a C++ class with a C structure.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefDOMNodeCppToC
|
||||
: public CefCppToC<CefDOMNodeCppToC, CefDOMNode, cef_domnode_t> {
|
||||
public:
|
||||
explicit CefDOMNodeCppToC(CefDOMNode* cls);
|
||||
virtual ~CefDOMNodeCppToC() {}
|
||||
};
|
||||
|
||||
#endif // BUILDING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CPPTOC_DOMNODE_CPPTOC_H_
|
||||
|
48
libcef_dll/cpptoc/domvisitor_cpptoc.cc
Normal file
48
libcef_dll/cpptoc/domvisitor_cpptoc.cc
Normal file
@ -0,0 +1,48 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/domvisitor_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/domdocument_ctocpp.h"
|
||||
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
void CEF_CALLBACK domvisitor_visit(struct _cef_domvisitor_t* self,
|
||||
struct _cef_domdocument_t* document) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
// Verify param: document; type: refptr_diff
|
||||
DCHECK(document);
|
||||
if (!document)
|
||||
return;
|
||||
|
||||
// Execute
|
||||
CefDOMVisitorCppToC::Get(self)->Visit(
|
||||
CefDOMDocumentCToCpp::Wrap(document));
|
||||
}
|
||||
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefDOMVisitorCppToC::CefDOMVisitorCppToC(CefDOMVisitor* cls)
|
||||
: CefCppToC<CefDOMVisitorCppToC, CefDOMVisitor, cef_domvisitor_t>(cls) {
|
||||
struct_.struct_.visit = domvisitor_visit;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCppToC<CefDOMVisitorCppToC, CefDOMVisitor,
|
||||
cef_domvisitor_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
36
libcef_dll/cpptoc/domvisitor_cpptoc.h
Normal file
36
libcef_dll/cpptoc/domvisitor_cpptoc.h
Normal file
@ -0,0 +1,36 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CPPTOC_DOMVISITOR_CPPTOC_H_
|
||||
#define CEF_LIBCEF_DLL_CPPTOC_DOMVISITOR_CPPTOC_H_
|
||||
#pragma once
|
||||
|
||||
#ifndef USING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
|
||||
#else // USING_CEF_SHARED
|
||||
|
||||
#include "include/cef_dom.h"
|
||||
#include "include/capi/cef_dom_capi.h"
|
||||
#include "libcef_dll/cpptoc/cpptoc.h"
|
||||
|
||||
// Wrap a C++ class with a C structure.
|
||||
// This class may be instantiated and accessed wrapper-side only.
|
||||
class CefDOMVisitorCppToC
|
||||
: public CefCppToC<CefDOMVisitorCppToC, CefDOMVisitor, cef_domvisitor_t> {
|
||||
public:
|
||||
explicit CefDOMVisitorCppToC(CefDOMVisitor* cls);
|
||||
virtual ~CefDOMVisitorCppToC() {}
|
||||
};
|
||||
|
||||
#endif // USING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CPPTOC_DOMVISITOR_CPPTOC_H_
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "libcef_dll/cpptoc/frame_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/request_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/v8context_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/domvisitor_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/string_visitor_ctocpp.h"
|
||||
|
||||
|
||||
@ -345,6 +346,23 @@ struct _cef_v8context_t* CEF_CALLBACK frame_get_v8context(
|
||||
return CefV8ContextCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK frame_visit_dom(struct _cef_frame_t* self,
|
||||
cef_domvisitor_t* visitor) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
// Verify param: visitor; type: refptr_diff
|
||||
DCHECK(visitor);
|
||||
if (!visitor)
|
||||
return;
|
||||
|
||||
// Execute
|
||||
CefFrameCppToC::Get(self)->VisitDOM(
|
||||
CefDOMVisitorCToCpp::Wrap(visitor));
|
||||
}
|
||||
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
@ -373,6 +391,7 @@ CefFrameCppToC::CefFrameCppToC(CefFrame* cls)
|
||||
struct_.struct_.get_url = frame_get_url;
|
||||
struct_.struct_.get_browser = frame_get_browser;
|
||||
struct_.struct_.get_v8context = frame_get_v8context;
|
||||
struct_.struct_.visit_dom = frame_visit_dom;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
255
libcef_dll/ctocpp/domdocument_ctocpp.cc
Normal file
255
libcef_dll/ctocpp/domdocument_ctocpp.cc
Normal file
@ -0,0 +1,255 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#include "libcef_dll/ctocpp/domdocument_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/domnode_ctocpp.h"
|
||||
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
CefDOMDocument::Type CefDOMDocumentCToCpp::GetType() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_type))
|
||||
return DOM_DOCUMENT_TYPE_UNKNOWN;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_dom_document_type_t _retval = struct_->get_type(struct_);
|
||||
|
||||
// Return type: simple
|
||||
return _retval;
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMDocumentCToCpp::GetDocument() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_document))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_domnode_t* _retval = struct_->get_document(struct_);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMNodeCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMDocumentCToCpp::GetBody() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_body))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_domnode_t* _retval = struct_->get_body(struct_);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMNodeCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMDocumentCToCpp::GetHead() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_head))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_domnode_t* _retval = struct_->get_head(struct_);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMNodeCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
CefString CefDOMDocumentCToCpp::GetTitle() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_title))
|
||||
return CefString();
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_string_userfree_t _retval = struct_->get_title(struct_);
|
||||
|
||||
// Return type: string
|
||||
CefString _retvalStr;
|
||||
_retvalStr.AttachToUserFree(_retval);
|
||||
return _retvalStr;
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMDocumentCToCpp::GetElementById(
|
||||
const CefString& id) {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_element_by_id))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: id; type: string_byref_const
|
||||
DCHECK(!id.empty());
|
||||
if (id.empty())
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
cef_domnode_t* _retval = struct_->get_element_by_id(struct_,
|
||||
id.GetStruct());
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMNodeCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMDocumentCToCpp::GetFocusedNode() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_focused_node))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_domnode_t* _retval = struct_->get_focused_node(struct_);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMNodeCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
bool CefDOMDocumentCToCpp::HasSelection() {
|
||||
if (CEF_MEMBER_MISSING(struct_, has_selection))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->has_selection(struct_);
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMDocumentCToCpp::GetSelectionStartNode() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_selection_start_node))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_domnode_t* _retval = struct_->get_selection_start_node(struct_);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMNodeCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
int CefDOMDocumentCToCpp::GetSelectionStartOffset() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_selection_start_offset))
|
||||
return 0;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->get_selection_start_offset(struct_);
|
||||
|
||||
// Return type: simple
|
||||
return _retval;
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMDocumentCToCpp::GetSelectionEndNode() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_selection_end_node))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_domnode_t* _retval = struct_->get_selection_end_node(struct_);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMNodeCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
int CefDOMDocumentCToCpp::GetSelectionEndOffset() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_selection_end_offset))
|
||||
return 0;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->get_selection_end_offset(struct_);
|
||||
|
||||
// Return type: simple
|
||||
return _retval;
|
||||
}
|
||||
|
||||
CefString CefDOMDocumentCToCpp::GetSelectionAsMarkup() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_selection_as_markup))
|
||||
return CefString();
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_string_userfree_t _retval = struct_->get_selection_as_markup(struct_);
|
||||
|
||||
// Return type: string
|
||||
CefString _retvalStr;
|
||||
_retvalStr.AttachToUserFree(_retval);
|
||||
return _retvalStr;
|
||||
}
|
||||
|
||||
CefString CefDOMDocumentCToCpp::GetSelectionAsText() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_selection_as_text))
|
||||
return CefString();
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_string_userfree_t _retval = struct_->get_selection_as_text(struct_);
|
||||
|
||||
// Return type: string
|
||||
CefString _retvalStr;
|
||||
_retvalStr.AttachToUserFree(_retval);
|
||||
return _retvalStr;
|
||||
}
|
||||
|
||||
CefString CefDOMDocumentCToCpp::GetBaseURL() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_base_url))
|
||||
return CefString();
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_string_userfree_t _retval = struct_->get_base_url(struct_);
|
||||
|
||||
// Return type: string
|
||||
CefString _retvalStr;
|
||||
_retvalStr.AttachToUserFree(_retval);
|
||||
return _retvalStr;
|
||||
}
|
||||
|
||||
CefString CefDOMDocumentCToCpp::GetCompleteURL(const CefString& partialURL) {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_complete_url))
|
||||
return CefString();
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: partialURL; type: string_byref_const
|
||||
DCHECK(!partialURL.empty());
|
||||
if (partialURL.empty())
|
||||
return CefString();
|
||||
|
||||
// Execute
|
||||
cef_string_userfree_t _retval = struct_->get_complete_url(struct_,
|
||||
partialURL.GetStruct());
|
||||
|
||||
// Return type: string
|
||||
CefString _retvalStr;
|
||||
_retvalStr.AttachToUserFree(_retval);
|
||||
return _retvalStr;
|
||||
}
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCToCpp<CefDOMDocumentCToCpp, CefDOMDocument,
|
||||
cef_domdocument_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
57
libcef_dll/ctocpp/domdocument_ctocpp.h
Normal file
57
libcef_dll/ctocpp/domdocument_ctocpp.h
Normal file
@ -0,0 +1,57 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CTOCPP_DOMDOCUMENT_CTOCPP_H_
|
||||
#define CEF_LIBCEF_DLL_CTOCPP_DOMDOCUMENT_CTOCPP_H_
|
||||
#pragma once
|
||||
|
||||
#ifndef USING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
|
||||
#else // USING_CEF_SHARED
|
||||
|
||||
#include "include/cef_dom.h"
|
||||
#include "include/capi/cef_dom_capi.h"
|
||||
#include "libcef_dll/ctocpp/ctocpp.h"
|
||||
|
||||
// Wrap a C structure with a C++ class.
|
||||
// This class may be instantiated and accessed wrapper-side only.
|
||||
class CefDOMDocumentCToCpp
|
||||
: public CefCToCpp<CefDOMDocumentCToCpp, CefDOMDocument,
|
||||
cef_domdocument_t> {
|
||||
public:
|
||||
explicit CefDOMDocumentCToCpp(cef_domdocument_t* str)
|
||||
: CefCToCpp<CefDOMDocumentCToCpp, CefDOMDocument, cef_domdocument_t>(
|
||||
str) {}
|
||||
virtual ~CefDOMDocumentCToCpp() {}
|
||||
|
||||
// CefDOMDocument methods
|
||||
virtual Type GetType() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMNode> GetDocument() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMNode> GetBody() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMNode> GetHead() OVERRIDE;
|
||||
virtual CefString GetTitle() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMNode> GetElementById(const CefString& id) OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMNode> GetFocusedNode() OVERRIDE;
|
||||
virtual bool HasSelection() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMNode> GetSelectionStartNode() OVERRIDE;
|
||||
virtual int GetSelectionStartOffset() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMNode> GetSelectionEndNode() OVERRIDE;
|
||||
virtual int GetSelectionEndOffset() OVERRIDE;
|
||||
virtual CefString GetSelectionAsMarkup() OVERRIDE;
|
||||
virtual CefString GetSelectionAsText() OVERRIDE;
|
||||
virtual CefString GetBaseURL() OVERRIDE;
|
||||
virtual CefString GetCompleteURL(const CefString& partialURL) OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // USING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CTOCPP_DOMDOCUMENT_CTOCPP_H_
|
||||
|
131
libcef_dll/ctocpp/domevent_ctocpp.cc
Normal file
131
libcef_dll/ctocpp/domevent_ctocpp.cc
Normal file
@ -0,0 +1,131 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#include "libcef_dll/ctocpp/domdocument_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/domevent_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/domnode_ctocpp.h"
|
||||
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
CefString CefDOMEventCToCpp::GetType() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_type))
|
||||
return CefString();
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_string_userfree_t _retval = struct_->get_type(struct_);
|
||||
|
||||
// Return type: string
|
||||
CefString _retvalStr;
|
||||
_retvalStr.AttachToUserFree(_retval);
|
||||
return _retvalStr;
|
||||
}
|
||||
|
||||
CefDOMEvent::Category CefDOMEventCToCpp::GetCategory() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_category))
|
||||
return DOM_EVENT_CATEGORY_UNKNOWN;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_dom_event_category_t _retval = struct_->get_category(struct_);
|
||||
|
||||
// Return type: simple
|
||||
return _retval;
|
||||
}
|
||||
|
||||
CefDOMEvent::Phase CefDOMEventCToCpp::GetPhase() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_phase))
|
||||
return DOM_EVENT_PHASE_UNKNOWN;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_dom_event_phase_t _retval = struct_->get_phase(struct_);
|
||||
|
||||
// Return type: simple
|
||||
return _retval;
|
||||
}
|
||||
|
||||
bool CefDOMEventCToCpp::CanBubble() {
|
||||
if (CEF_MEMBER_MISSING(struct_, can_bubble))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->can_bubble(struct_);
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
bool CefDOMEventCToCpp::CanCancel() {
|
||||
if (CEF_MEMBER_MISSING(struct_, can_cancel))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->can_cancel(struct_);
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMDocument> CefDOMEventCToCpp::GetDocument() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_document))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_domdocument_t* _retval = struct_->get_document(struct_);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMDocumentCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMEventCToCpp::GetTarget() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_target))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_domnode_t* _retval = struct_->get_target(struct_);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMNodeCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMEventCToCpp::GetCurrentTarget() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_current_target))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_domnode_t* _retval = struct_->get_current_target(struct_);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMNodeCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCToCpp<CefDOMEventCToCpp, CefDOMEvent,
|
||||
cef_domevent_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
47
libcef_dll/ctocpp/domevent_ctocpp.h
Normal file
47
libcef_dll/ctocpp/domevent_ctocpp.h
Normal file
@ -0,0 +1,47 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CTOCPP_DOMEVENT_CTOCPP_H_
|
||||
#define CEF_LIBCEF_DLL_CTOCPP_DOMEVENT_CTOCPP_H_
|
||||
#pragma once
|
||||
|
||||
#ifndef USING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
|
||||
#else // USING_CEF_SHARED
|
||||
|
||||
#include "include/cef_dom.h"
|
||||
#include "include/capi/cef_dom_capi.h"
|
||||
#include "libcef_dll/ctocpp/ctocpp.h"
|
||||
|
||||
// Wrap a C structure with a C++ class.
|
||||
// This class may be instantiated and accessed wrapper-side only.
|
||||
class CefDOMEventCToCpp
|
||||
: public CefCToCpp<CefDOMEventCToCpp, CefDOMEvent, cef_domevent_t> {
|
||||
public:
|
||||
explicit CefDOMEventCToCpp(cef_domevent_t* str)
|
||||
: CefCToCpp<CefDOMEventCToCpp, CefDOMEvent, cef_domevent_t>(str) {}
|
||||
virtual ~CefDOMEventCToCpp() {}
|
||||
|
||||
// CefDOMEvent methods
|
||||
virtual CefString GetType() OVERRIDE;
|
||||
virtual Category GetCategory() OVERRIDE;
|
||||
virtual Phase GetPhase() OVERRIDE;
|
||||
virtual bool CanBubble() OVERRIDE;
|
||||
virtual bool CanCancel() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMDocument> GetDocument() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMNode> GetTarget() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMNode> GetCurrentTarget() OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // USING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CTOCPP_DOMEVENT_CTOCPP_H_
|
||||
|
40
libcef_dll/ctocpp/domevent_listener_ctocpp.cc
Normal file
40
libcef_dll/ctocpp/domevent_listener_ctocpp.cc
Normal file
@ -0,0 +1,40 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/domevent_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/domevent_listener_ctocpp.h"
|
||||
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
void CefDOMEventListenerCToCpp::HandleEvent(CefRefPtr<CefDOMEvent> event) {
|
||||
if (CEF_MEMBER_MISSING(struct_, handle_event))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: event; type: refptr_diff
|
||||
DCHECK(event.get());
|
||||
if (!event.get())
|
||||
return;
|
||||
|
||||
// Execute
|
||||
struct_->handle_event(struct_,
|
||||
CefDOMEventCppToC::Wrap(event));
|
||||
}
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCToCpp<CefDOMEventListenerCToCpp, CefDOMEventListener,
|
||||
cef_domevent_listener_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
42
libcef_dll/ctocpp/domevent_listener_ctocpp.h
Normal file
42
libcef_dll/ctocpp/domevent_listener_ctocpp.h
Normal file
@ -0,0 +1,42 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CTOCPP_DOMEVENT_LISTENER_CTOCPP_H_
|
||||
#define CEF_LIBCEF_DLL_CTOCPP_DOMEVENT_LISTENER_CTOCPP_H_
|
||||
#pragma once
|
||||
|
||||
#ifndef BUILDING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
|
||||
#else // BUILDING_CEF_SHARED
|
||||
|
||||
#include "include/cef_dom.h"
|
||||
#include "include/capi/cef_dom_capi.h"
|
||||
#include "libcef_dll/ctocpp/ctocpp.h"
|
||||
|
||||
// Wrap a C structure with a C++ class.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefDOMEventListenerCToCpp
|
||||
: public CefCToCpp<CefDOMEventListenerCToCpp, CefDOMEventListener,
|
||||
cef_domevent_listener_t> {
|
||||
public:
|
||||
explicit CefDOMEventListenerCToCpp(cef_domevent_listener_t* str)
|
||||
: CefCToCpp<CefDOMEventListenerCToCpp, CefDOMEventListener,
|
||||
cef_domevent_listener_t>(str) {}
|
||||
virtual ~CefDOMEventListenerCToCpp() {}
|
||||
|
||||
// CefDOMEventListener methods
|
||||
virtual void HandleEvent(CefRefPtr<CefDOMEvent> event) OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // BUILDING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CTOCPP_DOMEVENT_LISTENER_CTOCPP_H_
|
||||
|
423
libcef_dll/ctocpp/domnode_ctocpp.cc
Normal file
423
libcef_dll/ctocpp/domnode_ctocpp.cc
Normal file
@ -0,0 +1,423 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/domevent_listener_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/domdocument_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/domnode_ctocpp.h"
|
||||
#include "libcef_dll/transfer_util.h"
|
||||
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
CefDOMNode::Type CefDOMNodeCToCpp::GetType() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_type))
|
||||
return DOM_NODE_TYPE_UNSUPPORTED;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_dom_node_type_t _retval = struct_->get_type(struct_);
|
||||
|
||||
// Return type: simple
|
||||
return _retval;
|
||||
}
|
||||
|
||||
bool CefDOMNodeCToCpp::IsText() {
|
||||
if (CEF_MEMBER_MISSING(struct_, is_text))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->is_text(struct_);
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
bool CefDOMNodeCToCpp::IsElement() {
|
||||
if (CEF_MEMBER_MISSING(struct_, is_element))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->is_element(struct_);
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
bool CefDOMNodeCToCpp::IsFormControlElement() {
|
||||
if (CEF_MEMBER_MISSING(struct_, is_form_control_element))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->is_form_control_element(struct_);
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
CefString CefDOMNodeCToCpp::GetFormControlElementType() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_form_control_element_type))
|
||||
return CefString();
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_string_userfree_t _retval = struct_->get_form_control_element_type(
|
||||
struct_);
|
||||
|
||||
// Return type: string
|
||||
CefString _retvalStr;
|
||||
_retvalStr.AttachToUserFree(_retval);
|
||||
return _retvalStr;
|
||||
}
|
||||
|
||||
bool CefDOMNodeCToCpp::IsSame(CefRefPtr<CefDOMNode> that) {
|
||||
if (CEF_MEMBER_MISSING(struct_, is_same))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: that; type: refptr_same
|
||||
DCHECK(that.get());
|
||||
if (!that.get())
|
||||
return false;
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->is_same(struct_,
|
||||
CefDOMNodeCToCpp::Unwrap(that));
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
CefString CefDOMNodeCToCpp::GetName() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_name))
|
||||
return CefString();
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_string_userfree_t _retval = struct_->get_name(struct_);
|
||||
|
||||
// Return type: string
|
||||
CefString _retvalStr;
|
||||
_retvalStr.AttachToUserFree(_retval);
|
||||
return _retvalStr;
|
||||
}
|
||||
|
||||
CefString CefDOMNodeCToCpp::GetValue() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_value))
|
||||
return CefString();
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_string_userfree_t _retval = struct_->get_value(struct_);
|
||||
|
||||
// Return type: string
|
||||
CefString _retvalStr;
|
||||
_retvalStr.AttachToUserFree(_retval);
|
||||
return _retvalStr;
|
||||
}
|
||||
|
||||
bool CefDOMNodeCToCpp::SetValue(const CefString& value) {
|
||||
if (CEF_MEMBER_MISSING(struct_, set_value))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: value; type: string_byref_const
|
||||
DCHECK(!value.empty());
|
||||
if (value.empty())
|
||||
return false;
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->set_value(struct_,
|
||||
value.GetStruct());
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
CefString CefDOMNodeCToCpp::GetAsMarkup() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_as_markup))
|
||||
return CefString();
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_string_userfree_t _retval = struct_->get_as_markup(struct_);
|
||||
|
||||
// Return type: string
|
||||
CefString _retvalStr;
|
||||
_retvalStr.AttachToUserFree(_retval);
|
||||
return _retvalStr;
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMDocument> CefDOMNodeCToCpp::GetDocument() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_document))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_domdocument_t* _retval = struct_->get_document(struct_);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMDocumentCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMNodeCToCpp::GetParent() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_parent))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_domnode_t* _retval = struct_->get_parent(struct_);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMNodeCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMNodeCToCpp::GetPreviousSibling() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_previous_sibling))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_domnode_t* _retval = struct_->get_previous_sibling(struct_);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMNodeCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMNodeCToCpp::GetNextSibling() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_next_sibling))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_domnode_t* _retval = struct_->get_next_sibling(struct_);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMNodeCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
bool CefDOMNodeCToCpp::HasChildren() {
|
||||
if (CEF_MEMBER_MISSING(struct_, has_children))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->has_children(struct_);
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMNodeCToCpp::GetFirstChild() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_first_child))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_domnode_t* _retval = struct_->get_first_child(struct_);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMNodeCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMNodeCToCpp::GetLastChild() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_last_child))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_domnode_t* _retval = struct_->get_last_child(struct_);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDOMNodeCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
void CefDOMNodeCToCpp::AddEventListener(const CefString& eventType,
|
||||
CefRefPtr<CefDOMEventListener> listener, bool useCapture) {
|
||||
if (CEF_MEMBER_MISSING(struct_, add_event_listener))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: eventType; type: string_byref_const
|
||||
DCHECK(!eventType.empty());
|
||||
if (eventType.empty())
|
||||
return;
|
||||
// Verify param: listener; type: refptr_diff
|
||||
DCHECK(listener.get());
|
||||
if (!listener.get())
|
||||
return;
|
||||
|
||||
// Execute
|
||||
struct_->add_event_listener(struct_,
|
||||
eventType.GetStruct(),
|
||||
CefDOMEventListenerCppToC::Wrap(listener),
|
||||
useCapture);
|
||||
}
|
||||
|
||||
CefString CefDOMNodeCToCpp::GetElementTagName() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_element_tag_name))
|
||||
return CefString();
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_string_userfree_t _retval = struct_->get_element_tag_name(struct_);
|
||||
|
||||
// Return type: string
|
||||
CefString _retvalStr;
|
||||
_retvalStr.AttachToUserFree(_retval);
|
||||
return _retvalStr;
|
||||
}
|
||||
|
||||
bool CefDOMNodeCToCpp::HasElementAttributes() {
|
||||
if (CEF_MEMBER_MISSING(struct_, has_element_attributes))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->has_element_attributes(struct_);
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
bool CefDOMNodeCToCpp::HasElementAttribute(const CefString& attrName) {
|
||||
if (CEF_MEMBER_MISSING(struct_, has_element_attribute))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: attrName; type: string_byref_const
|
||||
DCHECK(!attrName.empty());
|
||||
if (attrName.empty())
|
||||
return false;
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->has_element_attribute(struct_,
|
||||
attrName.GetStruct());
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
CefString CefDOMNodeCToCpp::GetElementAttribute(const CefString& attrName) {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_element_attribute))
|
||||
return CefString();
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: attrName; type: string_byref_const
|
||||
DCHECK(!attrName.empty());
|
||||
if (attrName.empty())
|
||||
return CefString();
|
||||
|
||||
// Execute
|
||||
cef_string_userfree_t _retval = struct_->get_element_attribute(struct_,
|
||||
attrName.GetStruct());
|
||||
|
||||
// Return type: string
|
||||
CefString _retvalStr;
|
||||
_retvalStr.AttachToUserFree(_retval);
|
||||
return _retvalStr;
|
||||
}
|
||||
|
||||
void CefDOMNodeCToCpp::GetElementAttributes(AttributeMap& attrMap) {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_element_attributes))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Translate param: attrMap; type: string_map_single_byref
|
||||
cef_string_map_t attrMapMap = cef_string_map_alloc();
|
||||
DCHECK(attrMapMap);
|
||||
if (attrMapMap)
|
||||
transfer_string_map_contents(attrMap, attrMapMap);
|
||||
|
||||
// Execute
|
||||
struct_->get_element_attributes(struct_,
|
||||
attrMapMap);
|
||||
|
||||
// Restore param:attrMap; type: string_map_single_byref
|
||||
if (attrMapMap) {
|
||||
attrMap.clear();
|
||||
transfer_string_map_contents(attrMapMap, attrMap);
|
||||
cef_string_map_free(attrMapMap);
|
||||
}
|
||||
}
|
||||
|
||||
bool CefDOMNodeCToCpp::SetElementAttribute(const CefString& attrName,
|
||||
const CefString& value) {
|
||||
if (CEF_MEMBER_MISSING(struct_, set_element_attribute))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: attrName; type: string_byref_const
|
||||
DCHECK(!attrName.empty());
|
||||
if (attrName.empty())
|
||||
return false;
|
||||
// Verify param: value; type: string_byref_const
|
||||
DCHECK(!value.empty());
|
||||
if (value.empty())
|
||||
return false;
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->set_element_attribute(struct_,
|
||||
attrName.GetStruct(),
|
||||
value.GetStruct());
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
CefString CefDOMNodeCToCpp::GetElementInnerText() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_element_inner_text))
|
||||
return CefString();
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_string_userfree_t _retval = struct_->get_element_inner_text(struct_);
|
||||
|
||||
// Return type: string
|
||||
CefString _retvalStr;
|
||||
_retvalStr.AttachToUserFree(_retval);
|
||||
return _retvalStr;
|
||||
}
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCToCpp<CefDOMNodeCToCpp, CefDOMNode,
|
||||
cef_domnode_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
66
libcef_dll/ctocpp/domnode_ctocpp.h
Normal file
66
libcef_dll/ctocpp/domnode_ctocpp.h
Normal file
@ -0,0 +1,66 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CTOCPP_DOMNODE_CTOCPP_H_
|
||||
#define CEF_LIBCEF_DLL_CTOCPP_DOMNODE_CTOCPP_H_
|
||||
#pragma once
|
||||
|
||||
#ifndef USING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
|
||||
#else // USING_CEF_SHARED
|
||||
|
||||
#include "include/cef_dom.h"
|
||||
#include "include/capi/cef_dom_capi.h"
|
||||
#include "libcef_dll/ctocpp/ctocpp.h"
|
||||
|
||||
// Wrap a C structure with a C++ class.
|
||||
// This class may be instantiated and accessed wrapper-side only.
|
||||
class CefDOMNodeCToCpp
|
||||
: public CefCToCpp<CefDOMNodeCToCpp, CefDOMNode, cef_domnode_t> {
|
||||
public:
|
||||
explicit CefDOMNodeCToCpp(cef_domnode_t* str)
|
||||
: CefCToCpp<CefDOMNodeCToCpp, CefDOMNode, cef_domnode_t>(str) {}
|
||||
virtual ~CefDOMNodeCToCpp() {}
|
||||
|
||||
// CefDOMNode methods
|
||||
virtual Type GetType() OVERRIDE;
|
||||
virtual bool IsText() OVERRIDE;
|
||||
virtual bool IsElement() OVERRIDE;
|
||||
virtual bool IsFormControlElement() OVERRIDE;
|
||||
virtual CefString GetFormControlElementType() OVERRIDE;
|
||||
virtual bool IsSame(CefRefPtr<CefDOMNode> that) OVERRIDE;
|
||||
virtual CefString GetName() OVERRIDE;
|
||||
virtual CefString GetValue() OVERRIDE;
|
||||
virtual bool SetValue(const CefString& value) OVERRIDE;
|
||||
virtual CefString GetAsMarkup() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMDocument> GetDocument() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMNode> GetParent() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMNode> GetPreviousSibling() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMNode> GetNextSibling() OVERRIDE;
|
||||
virtual bool HasChildren() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMNode> GetFirstChild() OVERRIDE;
|
||||
virtual CefRefPtr<CefDOMNode> GetLastChild() OVERRIDE;
|
||||
virtual void AddEventListener(const CefString& eventType,
|
||||
CefRefPtr<CefDOMEventListener> listener, bool useCapture) OVERRIDE;
|
||||
virtual CefString GetElementTagName() OVERRIDE;
|
||||
virtual bool HasElementAttributes() OVERRIDE;
|
||||
virtual bool HasElementAttribute(const CefString& attrName) OVERRIDE;
|
||||
virtual CefString GetElementAttribute(const CefString& attrName) OVERRIDE;
|
||||
virtual void GetElementAttributes(AttributeMap& attrMap) OVERRIDE;
|
||||
virtual bool SetElementAttribute(const CefString& attrName,
|
||||
const CefString& value) OVERRIDE;
|
||||
virtual CefString GetElementInnerText() OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // USING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CTOCPP_DOMNODE_CTOCPP_H_
|
||||
|
40
libcef_dll/ctocpp/domvisitor_ctocpp.cc
Normal file
40
libcef_dll/ctocpp/domvisitor_ctocpp.cc
Normal file
@ -0,0 +1,40 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/domdocument_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/domvisitor_ctocpp.h"
|
||||
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
void CefDOMVisitorCToCpp::Visit(CefRefPtr<CefDOMDocument> document) {
|
||||
if (CEF_MEMBER_MISSING(struct_, visit))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: document; type: refptr_diff
|
||||
DCHECK(document.get());
|
||||
if (!document.get())
|
||||
return;
|
||||
|
||||
// Execute
|
||||
struct_->visit(struct_,
|
||||
CefDOMDocumentCppToC::Wrap(document));
|
||||
}
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCToCpp<CefDOMVisitorCToCpp, CefDOMVisitor,
|
||||
cef_domvisitor_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
40
libcef_dll/ctocpp/domvisitor_ctocpp.h
Normal file
40
libcef_dll/ctocpp/domvisitor_ctocpp.h
Normal file
@ -0,0 +1,40 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CTOCPP_DOMVISITOR_CTOCPP_H_
|
||||
#define CEF_LIBCEF_DLL_CTOCPP_DOMVISITOR_CTOCPP_H_
|
||||
#pragma once
|
||||
|
||||
#ifndef BUILDING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
|
||||
#else // BUILDING_CEF_SHARED
|
||||
|
||||
#include "include/cef_dom.h"
|
||||
#include "include/capi/cef_dom_capi.h"
|
||||
#include "libcef_dll/ctocpp/ctocpp.h"
|
||||
|
||||
// Wrap a C structure with a C++ class.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefDOMVisitorCToCpp
|
||||
: public CefCToCpp<CefDOMVisitorCToCpp, CefDOMVisitor, cef_domvisitor_t> {
|
||||
public:
|
||||
explicit CefDOMVisitorCToCpp(cef_domvisitor_t* str)
|
||||
: CefCToCpp<CefDOMVisitorCToCpp, CefDOMVisitor, cef_domvisitor_t>(str) {}
|
||||
virtual ~CefDOMVisitorCToCpp() {}
|
||||
|
||||
// CefDOMVisitor methods
|
||||
virtual void Visit(CefRefPtr<CefDOMDocument> document) OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // BUILDING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CTOCPP_DOMVISITOR_CTOCPP_H_
|
||||
|
@ -10,6 +10,7 @@
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/domvisitor_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/string_visitor_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/browser_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/frame_ctocpp.h"
|
||||
@ -326,6 +327,22 @@ CefRefPtr<CefV8Context> CefFrameCToCpp::GetV8Context() {
|
||||
return CefV8ContextCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
void CefFrameCToCpp::VisitDOM(CefRefPtr<CefDOMVisitor> visitor) {
|
||||
if (CEF_MEMBER_MISSING(struct_, visit_dom))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: visitor; type: refptr_diff
|
||||
DCHECK(visitor.get());
|
||||
if (!visitor.get())
|
||||
return;
|
||||
|
||||
// Execute
|
||||
struct_->visit_dom(struct_,
|
||||
CefDOMVisitorCppToC::Wrap(visitor));
|
||||
}
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCToCpp<CefFrameCToCpp, CefFrame, cef_frame_t>::DebugObjCt =
|
||||
|
@ -61,6 +61,7 @@ class CefFrameCToCpp
|
||||
virtual CefString GetURL() OVERRIDE;
|
||||
virtual CefRefPtr<CefBrowser> GetBrowser() OVERRIDE;
|
||||
virtual CefRefPtr<CefV8Context> GetV8Context() OVERRIDE;
|
||||
virtual void VisitDOM(CefRefPtr<CefDOMVisitor> visitor) OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // USING_CEF_SHARED
|
||||
|
@ -31,6 +31,9 @@
|
||||
#include "libcef_dll/cpptoc/callback_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/context_menu_params_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/cookie_manager_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/domdocument_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/domevent_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/domnode_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/dictionary_value_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/frame_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/geolocation_callback_cpptoc.h"
|
||||
@ -54,6 +57,8 @@
|
||||
#include "libcef_dll/ctocpp/app_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/context_menu_handler_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/cookie_visitor_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/domevent_listener_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/domvisitor_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/display_handler_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/geolocation_handler_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/jsdialog_handler_ctocpp.h"
|
||||
@ -150,6 +155,11 @@ CEF_EXPORT void cef_shutdown() {
|
||||
DCHECK_EQ(CefContextMenuParamsCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefCookieManagerCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefCookieVisitorCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefDOMDocumentCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefDOMEventCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefDOMEventListenerCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefDOMNodeCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefDOMVisitorCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefDictionaryValueCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefDisplayHandlerCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefFrameCppToC::DebugObjCt, 0);
|
||||
|
@ -28,6 +28,8 @@
|
||||
#include "libcef_dll/cpptoc/app_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/context_menu_handler_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/cookie_visitor_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/domevent_listener_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/domvisitor_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/display_handler_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/geolocation_handler_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/jsdialog_handler_cpptoc.h"
|
||||
@ -53,6 +55,9 @@
|
||||
#include "libcef_dll/ctocpp/callback_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/context_menu_params_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/cookie_manager_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/domdocument_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/domevent_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/domnode_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/dictionary_value_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/frame_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/geolocation_callback_ctocpp.h"
|
||||
@ -142,6 +147,11 @@ CEF_GLOBAL void CefShutdown() {
|
||||
DCHECK_EQ(CefContextMenuParamsCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefCookieManagerCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefCookieVisitorCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefDOMDocumentCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefDOMEventCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefDOMEventListenerCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefDOMNodeCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefDOMVisitorCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefDictionaryValueCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefDisplayHandlerCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefFrameCToCpp::DebugObjCt, 0);
|
||||
|
@ -34,6 +34,7 @@ IDS_LOGO BINARY "res\\logo.png"
|
||||
IDS_LOGOBALL BINARY "res\\logoball.png"
|
||||
IDS_LOCALSTORAGE BINARY "res\\localstorage.html"
|
||||
IDS_XMLHTTPREQUEST BINARY "res\\xmlhttprequest.html"
|
||||
IDS_DOMACCESS BINARY "res\\domaccess.html"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@ -70,6 +71,7 @@ BEGIN
|
||||
MENUITEM "JavaScript Binding", ID_TESTS_BINDING
|
||||
MENUITEM "JavaScript Dialogs", ID_TESTS_DIALOGS
|
||||
MENUITEM "Plugin Info", ID_TESTS_PLUGIN_INFO
|
||||
MENUITEM "DOM Access", ID_TESTS_DOM_ACCESS
|
||||
MENUITEM "Local Storage", ID_TESTS_LOCALSTORAGE
|
||||
MENUITEM "XMLHttpRequest", ID_TESTS_XMLHTTPREQUEST
|
||||
MENUITEM "Accelerated 2D Canvas", ID_TESTS_ACCELERATED2DCANVAS
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "include/cef_runnable.h"
|
||||
#include "cefclient/binding_test.h"
|
||||
#include "cefclient/client_handler.h"
|
||||
#include "cefclient/dom_test.h"
|
||||
#include "cefclient/scheme_test.h"
|
||||
#include "cefclient/string_util.h"
|
||||
|
||||
@ -93,6 +94,14 @@ gboolean PluginInfoActivated(GtkWidget* widget) {
|
||||
return FALSE; // Don't stop this message.
|
||||
}
|
||||
|
||||
// Callback for Debug > DOM Access... menu item.
|
||||
gboolean DOMAccessActivated(GtkWidget* widget) {
|
||||
if (g_handler.get() && g_handler->GetBrowserId())
|
||||
dom_test::RunTest(g_handler->GetBrowser());
|
||||
|
||||
return FALSE; // Don't stop this message.
|
||||
}
|
||||
|
||||
// Callback for Debug > Popup Window... menu item.
|
||||
gboolean PopupWindowActivated(GtkWidget* widget) {
|
||||
if (g_handler.get() && g_handler->GetBrowserId())
|
||||
@ -212,6 +221,8 @@ GtkWidget* CreateMenuBar() {
|
||||
G_CALLBACK(BindingActivated));
|
||||
AddMenuEntry(debug_menu, "Plugin Info",
|
||||
G_CALLBACK(PluginInfoActivated));
|
||||
AddMenuEntry(debug_menu, "DOM Access",
|
||||
G_CALLBACK(DOMAccessActivated));
|
||||
AddMenuEntry(debug_menu, "Popup Window",
|
||||
G_CALLBACK(PopupWindowActivated));
|
||||
AddMenuEntry(debug_menu, "Accelerated 2D Canvas",
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "include/cef_runnable.h"
|
||||
#include "cefclient/binding_test.h"
|
||||
#include "cefclient/client_handler.h"
|
||||
#include "cefclient/dom_test.h"
|
||||
#include "cefclient/resource_util.h"
|
||||
#include "cefclient/scheme_test.h"
|
||||
#include "cefclient/string_util.h"
|
||||
@ -195,6 +196,7 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) {
|
||||
- (IBAction)testBinding:(id)sender;
|
||||
- (IBAction)testDialogs:(id)sender;
|
||||
- (IBAction)testPluginInfo:(id)sender;
|
||||
- (IBAction)testDOMAccess:(id)sender;
|
||||
- (IBAction)testPopupWindow:(id)sender;
|
||||
- (IBAction)testAccelerated2DCanvas:(id)sender;
|
||||
- (IBAction)testAcceleratedLayers:(id)sender;
|
||||
@ -243,6 +245,9 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) {
|
||||
[testMenu addItemWithTitle:@"Plugin Info"
|
||||
action:@selector(testPluginInfo:)
|
||||
keyEquivalent:@""];
|
||||
[testMenu addItemWithTitle:@"DOM Access"
|
||||
action:@selector(testDOMAccess:)
|
||||
keyEquivalent:@""];
|
||||
[testMenu addItemWithTitle:@"Local Storage"
|
||||
action:@selector(testLocalStorage:)
|
||||
keyEquivalent:@""];
|
||||
@ -400,6 +405,11 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) {
|
||||
RunPluginInfoTest(g_handler->GetBrowser());
|
||||
}
|
||||
|
||||
- (IBAction)testDOMAccess:(id)sender {
|
||||
if (g_handler.get() && g_handler->GetBrowserId())
|
||||
dom_test::RunTest(g_handler->GetBrowser());
|
||||
}
|
||||
|
||||
- (IBAction)testPopupWindow:(id)sender {
|
||||
if (g_handler.get() && g_handler->GetBrowserId())
|
||||
RunPopupTest(g_handler->GetBrowser());
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "include/cef_runnable.h"
|
||||
#include "cefclient/binding_test.h"
|
||||
#include "cefclient/client_handler.h"
|
||||
#include "cefclient/dom_test.h"
|
||||
#include "cefclient/resource.h"
|
||||
#include "cefclient/scheme_test.h"
|
||||
#include "cefclient/string_util.h"
|
||||
@ -385,6 +386,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||
if (browser.get())
|
||||
RunPluginInfoTest(browser);
|
||||
return 0;
|
||||
case ID_TESTS_DOM_ACCESS: // Test DOM access
|
||||
if (browser.get())
|
||||
dom_test::RunTest(browser);
|
||||
return 0;
|
||||
case ID_TESTS_LOCALSTORAGE: // Test localStorage
|
||||
if (browser.get())
|
||||
RunLocalStorageTest(browser);
|
||||
|
@ -3,10 +3,12 @@
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "cefclient/client_app.h"
|
||||
#include "cefclient/dom_test.h"
|
||||
#include "cefclient/scheme_test.h"
|
||||
|
||||
// static
|
||||
void ClientApp::CreateRenderDelegates(RenderDelegateSet& delegates) {
|
||||
dom_test::CreateRenderDelegates(delegates);
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "include/wrapper/cef_stream_resource_handler.h"
|
||||
#include "cefclient/binding_test.h"
|
||||
#include "cefclient/cefclient.h"
|
||||
#include "cefclient/dom_test.h"
|
||||
#include "cefclient/resource_util.h"
|
||||
#include "cefclient/string_util.h"
|
||||
|
||||
@ -114,6 +115,10 @@ void ClientHandler::OnLoadEnd(CefRefPtr<CefBrowser> browser,
|
||||
if (m_BrowserId == browser->GetIdentifier() && frame->IsMain()) {
|
||||
// We've just finished loading a page
|
||||
SetLoading(false);
|
||||
|
||||
// Continue the DOM test.
|
||||
if (frame->GetURL() == dom_test::kTestUrl)
|
||||
dom_test::OnLoadEnd(browser);
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,6 +158,12 @@ CefRefPtr<CefResourceHandler> ClientHandler::GetResourceHandler(
|
||||
GetBinaryResourceReader("dialogs.html");
|
||||
ASSERT(stream.get());
|
||||
return new CefStreamResourceHandler("text/html", stream);
|
||||
} else if (url == dom_test::kTestUrl) {
|
||||
// Show the domaccess contents
|
||||
CefRefPtr<CefStreamReader> stream =
|
||||
GetBinaryResourceReader("domaccess.html");
|
||||
ASSERT(stream.get());
|
||||
return new CefStreamResourceHandler("text/html", stream);
|
||||
} else if (url == "http://tests/localstorage") {
|
||||
// Show the localstorage contents
|
||||
CefRefPtr<CefStreamReader> stream =
|
||||
@ -247,7 +258,7 @@ void ClientHandler::OnBeforeContextMenu(
|
||||
// Add a separator if the menu already has items.
|
||||
if (model->GetCount() > 0)
|
||||
model->AddSeparator();
|
||||
|
||||
|
||||
// Add a "Show DevTools" item to all context menus.
|
||||
model->AddItem(CLIENT_ID_SHOW_DEVTOOLS, "&Show DevTools");
|
||||
|
||||
|
139
tests/cefclient/dom_test.cpp
Normal file
139
tests/cefclient/dom_test.cpp
Normal file
@ -0,0 +1,139 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "cefclient/dom_test.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "include/cef_dom.h"
|
||||
#include "cefclient/util.h"
|
||||
|
||||
namespace dom_test {
|
||||
|
||||
const char kTestUrl[] = "http://tests/domaccess";
|
||||
|
||||
namespace {
|
||||
|
||||
const char* kMessageName = "DOMTest.Message";
|
||||
|
||||
class ClientDOMEventListener : public CefDOMEventListener {
|
||||
public:
|
||||
ClientDOMEventListener() {
|
||||
}
|
||||
|
||||
virtual void HandleEvent(CefRefPtr<CefDOMEvent> event) OVERRIDE {
|
||||
CefRefPtr<CefDOMDocument> document = event->GetDocument();
|
||||
ASSERT(document.get());
|
||||
|
||||
std::stringstream ss;
|
||||
|
||||
CefRefPtr<CefDOMNode> button = event->GetTarget();
|
||||
ASSERT(button.get());
|
||||
std::string buttonValue = button->GetElementAttribute("value");
|
||||
ss << "You clicked the " << buttonValue.c_str() << " button. ";
|
||||
|
||||
if (document->HasSelection()) {
|
||||
std::string startName, endName;
|
||||
|
||||
// Determine the start name by first trying to locate the "id" attribute
|
||||
// and then defaulting to the tag name.
|
||||
{
|
||||
CefRefPtr<CefDOMNode> node = document->GetSelectionStartNode();
|
||||
if (!node->IsElement())
|
||||
node = node->GetParent();
|
||||
if (node->IsElement() && node->HasElementAttribute("id"))
|
||||
startName = node->GetElementAttribute("id");
|
||||
else
|
||||
startName = node->GetName();
|
||||
}
|
||||
|
||||
// Determine the end name by first trying to locate the "id" attribute
|
||||
// and then defaulting to the tag name.
|
||||
{
|
||||
CefRefPtr<CefDOMNode> node = document->GetSelectionEndNode();
|
||||
if (!node->IsElement())
|
||||
node = node->GetParent();
|
||||
if (node->IsElement() && node->HasElementAttribute("id"))
|
||||
endName = node->GetElementAttribute("id");
|
||||
else
|
||||
endName = node->GetName();
|
||||
}
|
||||
|
||||
ss << "The selection is from " <<
|
||||
startName.c_str() << ":" << document->GetSelectionStartOffset() <<
|
||||
" to " <<
|
||||
endName.c_str() << ":" << document->GetSelectionEndOffset();
|
||||
} else {
|
||||
ss << "Nothing is selected.";
|
||||
}
|
||||
|
||||
// Update the description.
|
||||
CefRefPtr<CefDOMNode> desc = document->GetElementById("description");
|
||||
ASSERT(desc.get());
|
||||
CefRefPtr<CefDOMNode> text = desc->GetFirstChild();
|
||||
ASSERT(text.get());
|
||||
ASSERT(text->IsText());
|
||||
text->SetValue(ss.str());
|
||||
}
|
||||
|
||||
IMPLEMENT_REFCOUNTING(ClientDOMEventListener);
|
||||
};
|
||||
|
||||
class ClientDOMVisitor : public CefDOMVisitor {
|
||||
public:
|
||||
ClientDOMVisitor() {
|
||||
}
|
||||
|
||||
virtual void Visit(CefRefPtr<CefDOMDocument> document) OVERRIDE {
|
||||
// Register a click listener for the button.
|
||||
CefRefPtr<CefDOMNode> button = document->GetElementById("button");
|
||||
ASSERT(button.get());
|
||||
button->AddEventListener("click", new ClientDOMEventListener(), false);
|
||||
}
|
||||
|
||||
IMPLEMENT_REFCOUNTING(ClientDOMVisitor);
|
||||
};
|
||||
|
||||
class DOMRenderDelegate : public ClientApp::RenderDelegate {
|
||||
public:
|
||||
DOMRenderDelegate() {
|
||||
}
|
||||
|
||||
virtual bool OnProcessMessageRecieved(
|
||||
CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefProcessId source_process,
|
||||
CefRefPtr<CefProcessMessage> message) OVERRIDE {
|
||||
if (message->GetName() == kMessageName) {
|
||||
// Visit the DOM to attach the event listener.
|
||||
browser->GetMainFrame()->VisitDOM(new ClientDOMVisitor);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
IMPLEMENT_REFCOUNTING(DOMRenderDelegate);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
void CreateRenderDelegates(ClientApp::RenderDelegateSet& delegates) {
|
||||
delegates.insert(new DOMRenderDelegate);
|
||||
}
|
||||
|
||||
void RunTest(CefRefPtr<CefBrowser> browser) {
|
||||
// Load the test URL.
|
||||
browser->GetMainFrame()->LoadURL(kTestUrl);
|
||||
}
|
||||
|
||||
void OnLoadEnd(CefRefPtr<CefBrowser> browser) {
|
||||
// Send a message to the render process to continue the test setup.
|
||||
browser->SendProcessMessage(PID_RENDERER,
|
||||
CefProcessMessage::Create(kMessageName));
|
||||
}
|
||||
|
||||
} // namespace dom_test
|
28
tests/cefclient/dom_test.h
Normal file
28
tests/cefclient/dom_test.h
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_TESTS_CEFCLIENT_DOM_TEST_H_
|
||||
#define CEF_TESTS_CEFCLIENT_DOM_TEST_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_base.h"
|
||||
#include "cefclient/client_app.h"
|
||||
|
||||
namespace dom_test {
|
||||
|
||||
// The DOM test URL.
|
||||
extern const char kTestUrl[];
|
||||
|
||||
// Create the render delegate.
|
||||
void CreateRenderDelegates(ClientApp::RenderDelegateSet& delegates);
|
||||
|
||||
// Run the test.
|
||||
void RunTest(CefRefPtr<CefBrowser> browser);
|
||||
|
||||
// Continue the test after the page has loaded.
|
||||
void OnLoadEnd(CefRefPtr<CefBrowser> browser);
|
||||
|
||||
} // namespace dom_test
|
||||
|
||||
#endif // CEF_TESTS_CEFCLIENT_DOM_TEST_H_
|
13
tests/cefclient/res/domaccess.html
Normal file
13
tests/cefclient/res/domaccess.html
Normal file
@ -0,0 +1,13 @@
|
||||
<html>
|
||||
<body>
|
||||
<p id="instructions">Select some portion of the below page content and click the "Describe Selection" button. The selected region will then be described below.</p>
|
||||
<p id="p1">This is p1</p>
|
||||
<p id="p2">This is p2</p>
|
||||
<p id="p3">This is p3</p>
|
||||
<p id="p4">This is p4</p>
|
||||
<form>
|
||||
<input type="button" id="button" value="Describe Selection">
|
||||
<p id="description">The description will appear here.</p>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
@ -40,6 +40,7 @@
|
||||
#define ID_TESTS_BINDING 32773
|
||||
#define ID_TESTS_DIALOGS 32774
|
||||
#define ID_TESTS_PLUGIN_INFO 32775
|
||||
#define ID_TESTS_DOM_ACCESS 32776
|
||||
#define IDC_STATIC -1
|
||||
#define IDS_BINDING 1000
|
||||
#define IDS_DIALOGS 1001
|
||||
@ -47,6 +48,7 @@
|
||||
#define IDS_LOGOBALL 1003
|
||||
#define IDS_LOCALSTORAGE 1004
|
||||
#define IDS_XMLHTTPREQUEST 1005
|
||||
#define IDS_DOMACCESS 1006
|
||||
|
||||
// Avoid files associated with MacOS
|
||||
#define _X86_
|
||||
|
@ -47,6 +47,7 @@ CefRefPtr<CefStreamReader> GetBinaryResourceReader(const char* resource_name) {
|
||||
} resource_map[] = {
|
||||
{"binding.html", IDS_BINDING},
|
||||
{"dialogs.html", IDS_DIALOGS},
|
||||
{"domaccess.html", IDS_DOMACCESS},
|
||||
{"localstorage.html", IDS_LOCALSTORAGE},
|
||||
{"xmlhttprequest.html", IDS_XMLHTTPREQUEST},
|
||||
};
|
||||
|
@ -12,8 +12,12 @@ void ClientApp::CreateRenderDelegates(RenderDelegateSet& delegates) {
|
||||
CreateProcessMessageRendererTests(delegates);
|
||||
|
||||
// Bring in the V8 tests.
|
||||
extern void CreateV8RendererTests(ClientApp::RenderDelegateSet& delegates);
|
||||
extern void CreateV8RendererTests(RenderDelegateSet& delegates);
|
||||
CreateV8RendererTests(delegates);
|
||||
|
||||
// Bring in the DOM tests.
|
||||
extern void CreateDOMRendererTests(RenderDelegateSet& delegates);
|
||||
CreateDOMRendererTests(delegates);
|
||||
}
|
||||
|
||||
// static
|
||||
|
332
tests/unittests/dom_unittest.cc
Normal file
332
tests/unittests/dom_unittest.cc
Normal file
@ -0,0 +1,332 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "include/cef_dom.h"
|
||||
#include "tests/cefclient/client_app.h"
|
||||
#include "tests/unittests/test_handler.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace {
|
||||
|
||||
const char* kTestUrl = "http://tests/DOMTest.Test";
|
||||
const char* kTestMessage = "DOMTest.Message";
|
||||
|
||||
enum DOMTestType {
|
||||
DOM_TEST_STRUCTURE,
|
||||
DOM_TEST_MODIFY,
|
||||
};
|
||||
|
||||
class TestDOMVisitor : public CefDOMVisitor {
|
||||
public:
|
||||
explicit TestDOMVisitor(CefRefPtr<CefBrowser> browser, DOMTestType test_type)
|
||||
: browser_(browser),
|
||||
test_type_(test_type) {
|
||||
}
|
||||
|
||||
void TestHeadNodeStructure(CefRefPtr<CefDOMNode> headNode) {
|
||||
EXPECT_TRUE(headNode.get());
|
||||
EXPECT_TRUE(headNode->IsElement());
|
||||
EXPECT_FALSE(headNode->IsText());
|
||||
EXPECT_EQ(headNode->GetName(), "HEAD");
|
||||
EXPECT_EQ(headNode->GetElementTagName(), "HEAD");
|
||||
|
||||
EXPECT_TRUE(headNode->HasChildren());
|
||||
EXPECT_FALSE(headNode->HasElementAttributes());
|
||||
|
||||
CefRefPtr<CefDOMNode> titleNode = headNode->GetFirstChild();
|
||||
EXPECT_TRUE(titleNode.get());
|
||||
EXPECT_TRUE(titleNode->IsElement());
|
||||
EXPECT_FALSE(titleNode->IsText());
|
||||
EXPECT_EQ(titleNode->GetName(), "TITLE");
|
||||
EXPECT_EQ(titleNode->GetElementTagName(), "TITLE");
|
||||
EXPECT_TRUE(titleNode->GetParent()->IsSame(headNode));
|
||||
|
||||
EXPECT_FALSE(titleNode->GetNextSibling().get());
|
||||
EXPECT_FALSE(titleNode->GetPreviousSibling().get());
|
||||
EXPECT_TRUE(titleNode->HasChildren());
|
||||
EXPECT_FALSE(titleNode->HasElementAttributes());
|
||||
|
||||
CefRefPtr<CefDOMNode> textNode = titleNode->GetFirstChild();
|
||||
EXPECT_TRUE(textNode.get());
|
||||
EXPECT_FALSE(textNode->IsElement());
|
||||
EXPECT_TRUE(textNode->IsText());
|
||||
EXPECT_EQ(textNode->GetValue(), "The Title");
|
||||
EXPECT_TRUE(textNode->GetParent()->IsSame(titleNode));
|
||||
|
||||
EXPECT_FALSE(textNode->GetNextSibling().get());
|
||||
EXPECT_FALSE(textNode->GetPreviousSibling().get());
|
||||
EXPECT_FALSE(textNode->HasChildren());
|
||||
}
|
||||
|
||||
void TestBodyNodeStructure(CefRefPtr<CefDOMNode> bodyNode) {
|
||||
EXPECT_TRUE(bodyNode.get());
|
||||
EXPECT_TRUE(bodyNode->IsElement());
|
||||
EXPECT_FALSE(bodyNode->IsText());
|
||||
EXPECT_EQ(bodyNode->GetName(), "BODY");
|
||||
EXPECT_EQ(bodyNode->GetElementTagName(), "BODY");
|
||||
|
||||
EXPECT_TRUE(bodyNode->HasChildren());
|
||||
EXPECT_FALSE(bodyNode->HasElementAttributes());
|
||||
|
||||
CefRefPtr<CefDOMNode> h1Node = bodyNode->GetFirstChild();
|
||||
EXPECT_TRUE(h1Node.get());
|
||||
EXPECT_TRUE(h1Node->IsElement());
|
||||
EXPECT_FALSE(h1Node->IsText());
|
||||
EXPECT_EQ(h1Node->GetName(), "H1");
|
||||
EXPECT_EQ(h1Node->GetElementTagName(), "H1");
|
||||
|
||||
EXPECT_FALSE(h1Node->GetNextSibling().get());
|
||||
EXPECT_FALSE(h1Node->GetPreviousSibling().get());
|
||||
EXPECT_TRUE(h1Node->HasChildren());
|
||||
EXPECT_FALSE(h1Node->HasElementAttributes());
|
||||
|
||||
CefRefPtr<CefDOMNode> textNode = h1Node->GetFirstChild();
|
||||
EXPECT_TRUE(textNode.get());
|
||||
EXPECT_FALSE(textNode->IsElement());
|
||||
EXPECT_TRUE(textNode->IsText());
|
||||
EXPECT_EQ(textNode->GetValue(), "Hello From");
|
||||
|
||||
EXPECT_FALSE(textNode->GetPreviousSibling().get());
|
||||
EXPECT_FALSE(textNode->HasChildren());
|
||||
|
||||
CefRefPtr<CefDOMNode> brNode = textNode->GetNextSibling();
|
||||
EXPECT_TRUE(brNode.get());
|
||||
EXPECT_TRUE(brNode->IsElement());
|
||||
EXPECT_FALSE(brNode->IsText());
|
||||
EXPECT_EQ(brNode->GetName(), "BR");
|
||||
EXPECT_EQ(brNode->GetElementTagName(), "BR");
|
||||
|
||||
EXPECT_FALSE(brNode->HasChildren());
|
||||
|
||||
EXPECT_TRUE(brNode->HasElementAttributes());
|
||||
EXPECT_TRUE(brNode->HasElementAttribute("class"));
|
||||
EXPECT_EQ(brNode->GetElementAttribute("class"), "some_class");
|
||||
EXPECT_TRUE(brNode->HasElementAttribute("id"));
|
||||
EXPECT_EQ(brNode->GetElementAttribute("id"), "some_id");
|
||||
EXPECT_FALSE(brNode->HasElementAttribute("no_existing"));
|
||||
|
||||
CefDOMNode::AttributeMap map;
|
||||
brNode->GetElementAttributes(map);
|
||||
ASSERT_EQ(map.size(), (size_t)2);
|
||||
EXPECT_EQ(map["class"], "some_class");
|
||||
EXPECT_EQ(map["id"], "some_id");
|
||||
|
||||
// Can also retrieve by ID.
|
||||
brNode = bodyNode->GetDocument()->GetElementById("some_id");
|
||||
EXPECT_TRUE(brNode.get());
|
||||
EXPECT_TRUE(brNode->IsElement());
|
||||
EXPECT_FALSE(brNode->IsText());
|
||||
EXPECT_EQ(brNode->GetName(), "BR");
|
||||
EXPECT_EQ(brNode->GetElementTagName(), "BR");
|
||||
|
||||
textNode = brNode->GetNextSibling();
|
||||
EXPECT_TRUE(textNode.get());
|
||||
EXPECT_FALSE(textNode->IsElement());
|
||||
EXPECT_TRUE(textNode->IsText());
|
||||
EXPECT_EQ(textNode->GetValue(), "Main Frame");
|
||||
|
||||
EXPECT_FALSE(textNode->GetNextSibling().get());
|
||||
EXPECT_FALSE(textNode->HasChildren());
|
||||
}
|
||||
|
||||
// Test document structure by iterating through the DOM tree.
|
||||
void TestStructure(CefRefPtr<CefDOMDocument> document) {
|
||||
EXPECT_EQ(document->GetTitle(), "The Title");
|
||||
EXPECT_EQ(document->GetBaseURL(), kTestUrl);
|
||||
EXPECT_EQ(document->GetCompleteURL("foo.html"), "http://tests/foo.html");
|
||||
|
||||
// Navigate the complete document structure.
|
||||
CefRefPtr<CefDOMNode> docNode = document->GetDocument();
|
||||
EXPECT_TRUE(docNode.get());
|
||||
EXPECT_FALSE(docNode->IsElement());
|
||||
EXPECT_FALSE(docNode->IsText());
|
||||
|
||||
CefRefPtr<CefDOMNode> htmlNode = docNode->GetFirstChild();
|
||||
EXPECT_TRUE(htmlNode.get());
|
||||
EXPECT_TRUE(htmlNode->IsElement());
|
||||
EXPECT_FALSE(htmlNode->IsText());
|
||||
EXPECT_EQ(htmlNode->GetName(), "HTML");
|
||||
EXPECT_EQ(htmlNode->GetElementTagName(), "HTML");
|
||||
|
||||
EXPECT_TRUE(htmlNode->HasChildren());
|
||||
EXPECT_FALSE(htmlNode->HasElementAttributes());
|
||||
|
||||
CefRefPtr<CefDOMNode> headNode = htmlNode->GetFirstChild();
|
||||
TestHeadNodeStructure(headNode);
|
||||
|
||||
CefRefPtr<CefDOMNode> bodyNode = headNode->GetNextSibling();
|
||||
TestBodyNodeStructure(bodyNode);
|
||||
|
||||
// Retrieve the head node directly.
|
||||
headNode = document->GetHead();
|
||||
TestHeadNodeStructure(headNode);
|
||||
|
||||
// Retrieve the body node directly.
|
||||
bodyNode = document->GetBody();
|
||||
TestBodyNodeStructure(bodyNode);
|
||||
}
|
||||
|
||||
// Test document modification by changing the H1 tag.
|
||||
void TestModify(CefRefPtr<CefDOMDocument> document) {
|
||||
CefRefPtr<CefDOMNode> bodyNode = document->GetBody();
|
||||
CefRefPtr<CefDOMNode> h1Node = bodyNode->GetFirstChild();
|
||||
|
||||
ASSERT_EQ(h1Node->GetAsMarkup(),
|
||||
"<h1>Hello From<br class=\"some_class\" id=\"some_id\">"
|
||||
"Main Frame</h1>");
|
||||
|
||||
CefRefPtr<CefDOMNode> textNode = h1Node->GetFirstChild();
|
||||
ASSERT_EQ(textNode->GetValue(), "Hello From");
|
||||
ASSERT_TRUE(textNode->SetValue("A Different Message From"));
|
||||
ASSERT_EQ(textNode->GetValue(), "A Different Message From");
|
||||
|
||||
CefRefPtr<CefDOMNode> brNode = textNode->GetNextSibling();
|
||||
EXPECT_EQ(brNode->GetElementAttribute("class"), "some_class");
|
||||
EXPECT_TRUE(brNode->SetElementAttribute("class", "a_different_class"));
|
||||
EXPECT_EQ(brNode->GetElementAttribute("class"), "a_different_class");
|
||||
|
||||
ASSERT_EQ(h1Node->GetAsMarkup(),
|
||||
"<h1>A Different Message From<br class=\"a_different_class\" "
|
||||
"id=\"some_id\">Main Frame</h1>");
|
||||
|
||||
ASSERT_FALSE(h1Node->SetValue("Something Different"));
|
||||
}
|
||||
|
||||
virtual void Visit(CefRefPtr<CefDOMDocument> document) OVERRIDE {
|
||||
if (test_type_ == DOM_TEST_STRUCTURE)
|
||||
TestStructure(document);
|
||||
else if (test_type_ == DOM_TEST_MODIFY)
|
||||
TestModify(document);
|
||||
|
||||
DestroyTest();
|
||||
}
|
||||
|
||||
protected:
|
||||
// Return from the test.
|
||||
void DestroyTest() {
|
||||
// Check if the test has failed.
|
||||
bool result = !TestFailed();
|
||||
|
||||
// Return the result to the browser process.
|
||||
CefRefPtr<CefProcessMessage> return_msg =
|
||||
CefProcessMessage::Create(kTestMessage);
|
||||
EXPECT_TRUE(return_msg->GetArgumentList()->SetBool(0, result));
|
||||
EXPECT_TRUE(browser_->SendProcessMessage(PID_BROWSER, return_msg));
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowser> browser_;
|
||||
DOMTestType test_type_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(TestDOMVisitor);
|
||||
};
|
||||
|
||||
// Used in the render process.
|
||||
class DOMRendererTest : public ClientApp::RenderDelegate {
|
||||
public:
|
||||
DOMRendererTest() {
|
||||
}
|
||||
|
||||
virtual bool OnProcessMessageRecieved(
|
||||
CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefProcessId source_process,
|
||||
CefRefPtr<CefProcessMessage> message) OVERRIDE {
|
||||
if (message->GetName() == kTestMessage) {
|
||||
EXPECT_EQ(message->GetArgumentList()->GetSize(), (size_t)1);
|
||||
int test_type = message->GetArgumentList()->GetInt(0);
|
||||
|
||||
browser->GetMainFrame()->VisitDOM(
|
||||
new TestDOMVisitor(browser, static_cast<DOMTestType>(test_type)));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
IMPLEMENT_REFCOUNTING(DOMRendererTest);
|
||||
};
|
||||
|
||||
// Used in the browser process.
|
||||
class TestDOMHandler : public TestHandler {
|
||||
public:
|
||||
explicit TestDOMHandler(DOMTestType test)
|
||||
: test_type_(test) {
|
||||
}
|
||||
|
||||
virtual void RunTest() OVERRIDE {
|
||||
std::stringstream mainHtml;
|
||||
mainHtml <<
|
||||
"<html>"
|
||||
"<head><title>The Title</title></head>"
|
||||
"<body>"
|
||||
"<h1>Hello From<br class=\"some_class\"/ id=\"some_id\"/>"
|
||||
"Main Frame</h1>"
|
||||
"</body>"
|
||||
"</html>";
|
||||
|
||||
AddResource(kTestUrl, mainHtml.str(), "text/html");
|
||||
CreateBrowser(kTestUrl);
|
||||
}
|
||||
|
||||
virtual void OnLoadEnd(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
int httpStatusCode) OVERRIDE {
|
||||
if (frame->IsMain()) {
|
||||
// Start the test in the render process.
|
||||
CefRefPtr<CefProcessMessage> message(
|
||||
CefProcessMessage::Create(kTestMessage));
|
||||
message->GetArgumentList()->SetInt(0, test_type_);
|
||||
EXPECT_TRUE(browser->SendProcessMessage(PID_RENDERER, message));
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool OnProcessMessageRecieved(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefProcessId source_process,
|
||||
CefRefPtr<CefProcessMessage> message) OVERRIDE {
|
||||
EXPECT_STREQ(message->GetName().ToString().c_str(), kTestMessage);
|
||||
|
||||
got_message_.yes();
|
||||
|
||||
if (message->GetArgumentList()->GetBool(0))
|
||||
got_success_.yes();
|
||||
|
||||
// Test is complete.
|
||||
DestroyTest();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DOMTestType test_type_;
|
||||
TrackCallback got_message_;
|
||||
TrackCallback got_success_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
// Test DOM structure reading.
|
||||
TEST(DOMTest, Read) {
|
||||
CefRefPtr<TestDOMHandler> handler =
|
||||
new TestDOMHandler(DOM_TEST_STRUCTURE);
|
||||
handler->ExecuteTest();
|
||||
|
||||
EXPECT_TRUE(handler->got_message_);
|
||||
EXPECT_TRUE(handler->got_success_);
|
||||
}
|
||||
|
||||
// Test DOM modifications.
|
||||
TEST(DOMTest, Modify) {
|
||||
CefRefPtr<TestDOMHandler> handler =
|
||||
new TestDOMHandler(DOM_TEST_MODIFY);
|
||||
handler->ExecuteTest();
|
||||
|
||||
EXPECT_TRUE(handler->got_message_);
|
||||
EXPECT_TRUE(handler->got_success_);
|
||||
}
|
||||
|
||||
// Entry point for creating DOM renderer test objects.
|
||||
// Called from client_app_delegates.cc.
|
||||
void CreateDOMRendererTests(ClientApp::RenderDelegateSet& delegates) {
|
||||
delegates.insert(new DOMRendererTest);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user