2012-04-27 23:19:06 +02:00
|
|
|
// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are
|
|
|
|
// met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above
|
|
|
|
// copyright notice, this list of conditions and the following disclaimer
|
|
|
|
// in the documentation and/or other materials provided with the
|
|
|
|
// distribution.
|
|
|
|
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
|
|
|
// Framework nor the names of its contributors may be used to endorse
|
|
|
|
// or promote products derived from this software without specific prior
|
|
|
|
// written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
//
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// The contents of this file must follow a specific format in order to
|
|
|
|
// support the CEF translator tool. See the translator.README.txt file in the
|
|
|
|
// tools directory for more information.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef CEF_INCLUDE_CEF_DOM_H_
|
|
|
|
#define CEF_INCLUDE_CEF_DOM_H_
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <map>
|
2017-05-17 11:29:28 +02:00
|
|
|
#include "include/cef_base.h"
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
class CefDOMDocument;
|
|
|
|
class CefDOMNode;
|
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Interface to implement for visiting the DOM. The methods of this class will
|
|
|
|
/// be called on the render process main thread.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef(source=client)--*/
|
2017-02-09 23:07:43 +01:00
|
|
|
class CefDOMVisitor : public virtual CefBaseRefCounted {
|
2012-04-27 23:19:06 +02:00
|
|
|
public:
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// 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.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual void Visit(CefRefPtr<CefDOMDocument> document) = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Class used to represent a DOM document. The methods of this class should
|
|
|
|
/// only be called on the render process main thread thread.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef(source=library)--*/
|
2017-02-09 23:07:43 +01:00
|
|
|
class CefDOMDocument : public virtual CefBaseRefCounted {
|
2012-04-27 23:19:06 +02:00
|
|
|
public:
|
|
|
|
typedef cef_dom_document_type_t Type;
|
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the document type.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef(default_retval=DOM_DOCUMENT_TYPE_UNKNOWN)--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual Type GetType() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the root document node.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefRefPtr<CefDOMNode> GetDocument() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the BODY node of an HTML document.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefRefPtr<CefDOMNode> GetBody() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the HEAD node of an HTML document.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefRefPtr<CefDOMNode> GetHead() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the title of an HTML document.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefString GetTitle() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the document element with the specified ID value.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefRefPtr<CefDOMNode> GetElementById(const CefString& id) = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the node that currently has keyboard focus.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefRefPtr<CefDOMNode> GetFocusedNode() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns true if a portion of the document is selected.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual bool HasSelection() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the selection offset within the start node.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual int GetSelectionStartOffset() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the selection offset within the end node.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual int GetSelectionEndOffset() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the contents of this selection as markup.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefString GetSelectionAsMarkup() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the contents of this selection as text.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefString GetSelectionAsText() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the base URL for the document.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefString GetBaseURL() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns a complete URL based on the document base URL and the specified
|
|
|
|
/// partial URL.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefString GetCompleteURL(const CefString& partialURL) = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Class used to represent a DOM node. The methods of this class should only be
|
|
|
|
/// called on the render process main thread.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef(source=library)--*/
|
2017-02-09 23:07:43 +01:00
|
|
|
class CefDOMNode : public virtual CefBaseRefCounted {
|
2012-04-27 23:19:06 +02:00
|
|
|
public:
|
|
|
|
typedef std::map<CefString, CefString> AttributeMap;
|
|
|
|
typedef cef_dom_node_type_t Type;
|
2023-10-19 20:08:48 +02:00
|
|
|
typedef cef_dom_form_control_type_t FormControlType;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the type for this node.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef(default_retval=DOM_NODE_TYPE_UNSUPPORTED)--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual Type GetType() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns true if this is a text node.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual bool IsText() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns true if this is an element node.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual bool IsElement() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
2012-06-11 17:52:49 +02:00
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns true if this is an editable node.
|
2012-06-11 17:52:49 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual bool IsEditable() = 0;
|
2012-06-11 17:52:49 +02:00
|
|
|
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns true if this is a form control element node.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
2023-10-19 20:08:48 +02:00
|
|
|
/*--cef(default_retval=DOM_NODE_TYPE_UNSUPPORTED)--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual bool IsFormControlElement() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the type of this form control element node.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
2023-10-19 20:08:48 +02:00
|
|
|
/*--cef(default_retval=DOM_FORM_CONTROL_TYPE_UNSUPPORTED)--*/
|
|
|
|
virtual FormControlType GetFormControlElementType() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns true if this object is pointing to the same handle as |that|
|
|
|
|
/// object.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual bool IsSame(CefRefPtr<CefDOMNode> that) = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the name of this node.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefString GetName() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the value of this node.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefString GetValue() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Set the value of this node. Returns true on success.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual bool SetValue(const CefString& value) = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the contents of this node as markup.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefString GetAsMarkup() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the document associated with this node.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefRefPtr<CefDOMDocument> GetDocument() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the parent node.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefRefPtr<CefDOMNode> GetParent() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the previous sibling node.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefRefPtr<CefDOMNode> GetPreviousSibling() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the next sibling node.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefRefPtr<CefDOMNode> GetNextSibling() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns true if this node has child nodes.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual bool HasChildren() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Return the first child node.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefRefPtr<CefDOMNode> GetFirstChild() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the last child node.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefRefPtr<CefDOMNode> GetLastChild() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
// The following methods are valid only for element nodes.
|
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the tag name of this element.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefString GetElementTagName() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns true if this element has attributes.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual bool HasElementAttributes() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns true if this element has an attribute named |attrName|.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual bool HasElementAttribute(const CefString& attrName) = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the element attribute named |attrName|.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefString GetElementAttribute(const CefString& attrName) = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns a map of all element attributes.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual void GetElementAttributes(AttributeMap& attrMap) = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Set the value for the element attribute named |attrName|. Returns true on
|
|
|
|
/// success.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
|
|
|
virtual bool SetElementAttribute(const CefString& attrName,
|
2017-05-17 11:29:28 +02:00
|
|
|
const CefString& value) = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the inner text of the element.
|
2012-04-27 23:19:06 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefString GetElementInnerText() = 0;
|
2016-09-09 20:02:57 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the bounds of the element in device pixels. Use
|
|
|
|
/// "window.devicePixelRatio" to convert to/from CSS pixels.
|
2016-09-09 20:02:57 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefRect GetElementBounds() = 0;
|
2012-04-27 23:19:06 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_INCLUDE_CEF_DOM_H_
|