- Add CefFocusHandler::OnFocusedNodeChanged() notification (issue #379).

- Add CefDOMNode::IsFormControlElement() and CefDOMNode::GetFormControlElementType() methods (issue #379).
- Add space bar handling example to cefclient.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@318 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2011-10-14 12:40:40 +00:00
parent 06b7e9ab53
commit 9c6dcab73a
16 changed files with 267 additions and 12 deletions

View File

@@ -40,6 +40,9 @@ public:
// instance to the other side.
static StructName* Wrap(CefRefPtr<BaseName> c)
{
if (!c.get())
return NULL;
// Wrap our object with the CefCppToC class.
ClassName* wrapper = new ClassName(c);
// Add a reference to our wrapper object that will be released once our
@@ -53,6 +56,8 @@ public:
// our wrapper structure back from the other side.
static CefRefPtr<BaseName> Unwrap(StructName* s)
{
DCHECK(s);
// Cast our structure to the wrapper structure type.
Struct* wrapperStruct = reinterpret_cast<Struct*>(s);
// Add the underlying object instance to a smart pointer.

View File

@@ -46,6 +46,26 @@ int CEF_CALLBACK domnode_is_element(struct _cef_domnode_t* self)
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)
{
@@ -292,6 +312,9 @@ CefDOMNodeCppToC::CefDOMNodeCppToC(CefDOMNode* 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;

View File

@@ -12,6 +12,8 @@
#include "libcef_dll/cpptoc/focus_handler_cpptoc.h"
#include "libcef_dll/ctocpp/browser_ctocpp.h"
#include "libcef_dll/ctocpp/domnode_ctocpp.h"
#include "libcef_dll/ctocpp/frame_ctocpp.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
@@ -40,6 +42,21 @@ int CEF_CALLBACK focus_handler_on_set_focus(struct _cef_focus_handler_t* self,
CefBrowserCToCpp::Wrap(browser), source);
}
void CEF_CALLBACK focus_handler_on_focused_node_changed(
struct _cef_focus_handler_t* self, cef_browser_t* browser,
cef_frame_t* frame, struct _cef_domnode_t* node)
{
DCHECK(self);
DCHECK(browser);
DCHECK(frame);
if (!self || !browser || !frame)
return;
return CefFocusHandlerCppToC::Get(self)->OnFocusedNodeChanged(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame),
CefDOMNodeCToCpp::Wrap(node));
}
// CONSTRUCTOR - Do not edit by hand.
@@ -49,6 +66,8 @@ CefFocusHandlerCppToC::CefFocusHandlerCppToC(CefFocusHandler* cls)
{
struct_.struct_.on_take_focus = focus_handler_on_take_focus;
struct_.struct_.on_set_focus = focus_handler_on_set_focus;
struct_.struct_.on_focused_node_changed =
focus_handler_on_focused_node_changed;
}
#ifndef NDEBUG

View File

@@ -21,6 +21,9 @@ public:
// received from the other side.
static CefRefPtr<BaseName> Wrap(StructName* s)
{
if (!s)
return NULL;
// Wrap their structure with the CefCToCpp object.
ClassName* wrapper = new ClassName(s);
// Put the wrapper object in a smart pointer.
@@ -36,6 +39,8 @@ public:
// instance for return back to the other side.
static StructName* Unwrap(CefRefPtr<BaseName> c)
{
DCHECK(c.get());
// Cast the object to our wrapper class type.
ClassName* wrapper = static_cast<ClassName*>(c.get());
// Add a reference to the CefCppToC wrapper object on the other side that

View File

@@ -42,6 +42,26 @@ bool CefDOMNodeCToCpp::IsElement()
return struct_->is_element(struct_) ? true : false;
}
bool CefDOMNodeCToCpp::IsFormControlElement()
{
if (CEF_MEMBER_MISSING(struct_, is_form_control_element))
return false;
return struct_->is_form_control_element(struct_) ? true : false;
}
CefString CefDOMNodeCToCpp::GetFormControlElementType()
{
CefString str;
if (CEF_MEMBER_MISSING(struct_, get_form_control_element_type))
return str;
cef_string_userfree_t strPtr =
struct_->get_form_control_element_type(struct_);
str.AttachToUserFree(strPtr);
return str;
}
bool CefDOMNodeCToCpp::IsSame(CefRefPtr<CefDOMNode> that)
{
if (CEF_MEMBER_MISSING(struct_, is_same))

View File

@@ -34,6 +34,8 @@ public:
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;

View File

@@ -11,6 +11,8 @@
//
#include "libcef_dll/cpptoc/browser_cpptoc.h"
#include "libcef_dll/cpptoc/domnode_cpptoc.h"
#include "libcef_dll/cpptoc/frame_cpptoc.h"
#include "libcef_dll/ctocpp/focus_handler_ctocpp.h"
@@ -35,6 +37,17 @@ bool CefFocusHandlerCToCpp::OnSetFocus(CefRefPtr<CefBrowser> browser,
source) ? true : false;
}
void CefFocusHandlerCToCpp::OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, CefRefPtr<CefDOMNode> node)
{
if (CEF_MEMBER_MISSING(struct_, on_focused_node_changed))
return;
struct_->on_focused_node_changed(struct_,
CefBrowserCppToC::Wrap(browser), CefFrameCppToC::Wrap(frame),
CefDOMNodeCppToC::Wrap(node));
}
#ifndef NDEBUG
template<> long CefCToCpp<CefFocusHandlerCToCpp, CefFocusHandler,

View File

@@ -36,6 +36,8 @@ public:
virtual void OnTakeFocus(CefRefPtr<CefBrowser> browser, bool next) OVERRIDE;
virtual bool OnSetFocus(CefRefPtr<CefBrowser> browser,
FocusSource source) OVERRIDE;
virtual void OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, CefRefPtr<CefDOMNode> node) OVERRIDE;
};
#endif // BUILDING_CEF_SHARED