cef/libcef_dll/cpptoc/domnode_cpptoc.cc

345 lines
8.9 KiB
C++

// Copyright (c) 2011 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.
//
// ---------------------------------------------------------------------------
//
// A portion of this file was generated by the CEF translator tool. When
// making changes by hand only do so within the body of existing 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)
{
DCHECK(self);
if(!self)
return DOM_NODE_TYPE_UNSUPPORTED;
return CefDOMNodeCppToC::Get(self)->GetType();
}
int CEF_CALLBACK domnode_is_text(struct _cef_domnode_t* self)
{
DCHECK(self);
if(!self)
return 0;
return CefDOMNodeCppToC::Get(self)->IsText();
}
int CEF_CALLBACK domnode_is_element(struct _cef_domnode_t* self)
{
DCHECK(self);
if(!self)
return 0;
return CefDOMNodeCppToC::Get(self)->IsElement();
}
int CEF_CALLBACK domnode_is_form_control_element(struct _cef_domnode_t* self)
{
DCHECK(self);
if (!self)
return 0;
return CefDOMNodeCppToC::Get(self)->IsFormControlElement();
}
cef_string_userfree_t CEF_CALLBACK domnode_get_form_control_element_type(
struct _cef_domnode_t* self)
{
DCHECK(self);
if (!self)
return NULL;
CefString str = CefDOMNodeCppToC::Get(self)->GetFormControlElementType();
return str.DetachToUserFree();
}
int CEF_CALLBACK domnode_is_same(struct _cef_domnode_t* self,
struct _cef_domnode_t* that)
{
DCHECK(self);
DCHECK(that);
if (!self || !that)
return 0;
return CefDOMNodeCppToC::Get(self)->IsSame(CefDOMNodeCppToC::Unwrap(that));
}
cef_string_userfree_t CEF_CALLBACK domnode_get_name(struct _cef_domnode_t* self)
{
DCHECK(self);
if(!self)
return NULL;
CefString str = CefDOMNodeCppToC::Get(self)->GetName();
return str.DetachToUserFree();
}
cef_string_userfree_t CEF_CALLBACK domnode_get_value(
struct _cef_domnode_t* self)
{
DCHECK(self);
if(!self)
return NULL;
CefString str = CefDOMNodeCppToC::Get(self)->GetValue();
return str.DetachToUserFree();
}
int CEF_CALLBACK domnode_set_value(struct _cef_domnode_t* self,
const cef_string_t* value)
{
DCHECK(self);
DCHECK(value);
if(!self || !value)
return 0;
return CefDOMNodeCppToC::Get(self)->SetValue(CefString(value));
}
cef_string_userfree_t CEF_CALLBACK domnode_get_as_markup(
struct _cef_domnode_t* self)
{
DCHECK(self);
if(!self)
return NULL;
CefString str = CefDOMNodeCppToC::Get(self)->GetAsMarkup();
return str.DetachToUserFree();
}
cef_domdocument_t* CEF_CALLBACK domnode_get_document(
struct _cef_domnode_t* self)
{
DCHECK(self);
if(!self)
return NULL;
CefRefPtr<CefDOMDocument> documentPtr =
CefDOMNodeCppToC::Get(self)->GetDocument();
if(documentPtr.get())
return CefDOMDocumentCppToC::Wrap(documentPtr);
return NULL;
}
struct _cef_domnode_t* CEF_CALLBACK domnode_get_parent(
struct _cef_domnode_t* self)
{
DCHECK(self);
if(!self)
return NULL;
CefRefPtr<CefDOMNode> nodePtr = CefDOMNodeCppToC::Get(self)->GetParent();
if(nodePtr.get())
return CefDOMNodeCppToC::Wrap(nodePtr);
return NULL;
}
struct _cef_domnode_t* CEF_CALLBACK domnode_get_previous_sibling(
struct _cef_domnode_t* self)
{
DCHECK(self);
if(!self)
return NULL;
CefRefPtr<CefDOMNode> nodePtr =
CefDOMNodeCppToC::Get(self)->GetPreviousSibling();
if(nodePtr.get())
return CefDOMNodeCppToC::Wrap(nodePtr);
return NULL;
}
struct _cef_domnode_t* CEF_CALLBACK domnode_get_next_sibling(
struct _cef_domnode_t* self)
{
DCHECK(self);
if(!self)
return NULL;
CefRefPtr<CefDOMNode> nodePtr = CefDOMNodeCppToC::Get(self)->GetNextSibling();
if(nodePtr.get())
return CefDOMNodeCppToC::Wrap(nodePtr);
return NULL;
}
int CEF_CALLBACK domnode_has_children(struct _cef_domnode_t* self)
{
DCHECK(self);
if(!self)
return 0;
return CefDOMNodeCppToC::Get(self)->HasChildren();
}
struct _cef_domnode_t* CEF_CALLBACK domnode_get_first_child(
struct _cef_domnode_t* self)
{
DCHECK(self);
if(!self)
return NULL;
CefRefPtr<CefDOMNode> nodePtr = CefDOMNodeCppToC::Get(self)->GetFirstChild();
if(nodePtr.get())
return CefDOMNodeCppToC::Wrap(nodePtr);
return NULL;
}
struct _cef_domnode_t* CEF_CALLBACK domnode_get_last_child(
struct _cef_domnode_t* self)
{
DCHECK(self);
if(!self)
return NULL;
CefRefPtr<CefDOMNode> nodePtr = CefDOMNodeCppToC::Get(self)->GetLastChild();
if(nodePtr.get())
return CefDOMNodeCppToC::Wrap(nodePtr);
return NULL;
}
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)
{
DCHECK(self);
DCHECK(eventType);
DCHECK(listener);
if(!self || !eventType || !listener)
return;
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)
{
DCHECK(self);
if(!self)
return NULL;
CefString str = CefDOMNodeCppToC::Get(self)->GetElementTagName();
return str.DetachToUserFree();
}
int CEF_CALLBACK domnode_has_element_attributes(struct _cef_domnode_t* self)
{
DCHECK(self);
if(!self)
return 0;
return CefDOMNodeCppToC::Get(self)->HasElementAttributes();
}
int CEF_CALLBACK domnode_has_element_attribute(struct _cef_domnode_t* self,
const cef_string_t* attrName)
{
DCHECK(self);
DCHECK(attrName);
if(!self || !attrName)
return 0;
return CefDOMNodeCppToC::Get(self)->HasElementAttribute(CefString(attrName));
}
cef_string_userfree_t CEF_CALLBACK domnode_get_element_attribute(
struct _cef_domnode_t* self, const cef_string_t* attrName)
{
DCHECK(self);
DCHECK(attrName);
if(!self || !attrName)
return NULL;
CefString str =
CefDOMNodeCppToC::Get(self)->GetElementAttribute(CefString(attrName));
return str.DetachToUserFree();
}
void CEF_CALLBACK domnode_get_element_attributes(struct _cef_domnode_t* self,
cef_string_map_t attrMap)
{
DCHECK(self);
if(!self)
return;
CefDOMNode::AttributeMap map;
CefDOMNodeCppToC::Get(self)->GetElementAttributes(map);
transfer_string_map_contents(map, attrMap);
}
int CEF_CALLBACK domnode_set_element_attribute(struct _cef_domnode_t* self,
const cef_string_t* attrName, const cef_string_t* value)
{
DCHECK(self);
DCHECK(attrName);
DCHECK(value);
if(!self || !attrName || !value)
return 0;
return CefDOMNodeCppToC::Get(self)->SetElementAttribute(CefString(attrName),
CefString(value));
}
cef_string_userfree_t CEF_CALLBACK domnode_get_element_inner_text(
struct _cef_domnode_t* self)
{
DCHECK(self);
if(!self)
return NULL;
CefString str = CefDOMNodeCppToC::Get(self)->GetElementInnerText();
return str.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