Re: Dcef4 Icefdomedocument getelementsbyclassname and getelementsbyname function
Posted: Wed Jun 28, 2017 8:39 am
Hi phuoc_89,
I'm afraid CEF3 doesn't include those functions in the Document node and CEF4Delphi can only show what CEF3 allows to see.
Here's the CEF3 source code of the cef_domdocument_t struct. This becomes TCefDomDocument and ICefDomDocument in CEF4Delphi.
You can find this in /include/capi/cef_dom_capi.h
I've uploaded a new version of the MiniBrowser demo with a DOM search demo function. (check the DPR file)
It shouldn't be too difficult to create a recursive function that compares element names or class names.
I'm afraid CEF3 doesn't include those functions in the Document node and CEF4Delphi can only show what CEF3 allows to see.
Here's the CEF3 source code of the cef_domdocument_t struct. This becomes TCefDomDocument and ICefDomDocument in CEF4Delphi.
You can find this in /include/capi/cef_dom_capi.h
Code: Select all
///
// 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_ref_counted_t base;
///
// Returns the document type.
///
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 offset within the start node.
///
int(CEF_CALLBACK* get_selection_start_offset)(
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;
It shouldn't be too difficult to create a recursive function that compares element names or class names.