Add CefDOMNode::IsSame() method.
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@228 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
2669a3b6c3
commit
4bc8e47fad
|
@ -2105,6 +2105,11 @@ public:
|
|||
/*--cef()--*/
|
||||
virtual bool IsElement() =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;
|
||||
|
|
|
@ -1857,6 +1857,11 @@ typedef struct _cef_domnode_t
|
|||
// Returns true (1) if this is an element node.
|
||||
int (CEF_CALLBACK *is_element)(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);
|
||||
|
|
|
@ -154,6 +154,18 @@ bool CefDOMNodeImpl::IsElement()
|
|||
return node_.isElementNode();
|
||||
}
|
||||
|
||||
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;
|
||||
|
|
|
@ -20,6 +20,7 @@ public:
|
|||
virtual Type GetType();
|
||||
virtual bool IsText();
|
||||
virtual bool IsElement();
|
||||
virtual bool IsSame(CefRefPtr<CefDOMNode> that);
|
||||
virtual CefString GetName();
|
||||
virtual CefString GetValue();
|
||||
virtual bool SetValue(const CefString& value);
|
||||
|
|
|
@ -46,6 +46,17 @@ int CEF_CALLBACK domnode_is_element(struct _cef_domnode_t* self)
|
|||
return CefDOMNodeCppToC::Get(self)->IsElement();
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -281,6 +292,7 @@ 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_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;
|
||||
|
|
|
@ -32,8 +32,7 @@ enum cef_retval_t CEF_CALLBACK handler_handle_before_created(
|
|||
DCHECK(self);
|
||||
DCHECK(windowInfo);
|
||||
DCHECK(handler && *handler);
|
||||
DCHECK(url);
|
||||
if(!self || !windowInfo || !handler || !*handler || !url)
|
||||
if(!self || !windowInfo || !handler || !*handler)
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefWindowInfo wndInfo;
|
||||
|
|
|
@ -206,11 +206,11 @@ int CEF_CALLBACK v8value_is_same(struct _cef_v8value_t* self,
|
|||
struct _cef_v8value_t* that)
|
||||
{
|
||||
DCHECK(self);
|
||||
if(!self)
|
||||
DCHECK(that);
|
||||
if(!self || !that)
|
||||
return 0;
|
||||
|
||||
CefRefPtr<CefV8Value> thatPtr = CefV8ValueCppToC::Unwrap(that);
|
||||
return CefV8ValueCppToC::Get(self)->IsSame(thatPtr);
|
||||
return CefV8ValueCppToC::Get(self)->IsSame(CefV8ValueCppToC::Unwrap(that));
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_get_bool_value(struct _cef_v8value_t* self)
|
||||
|
|
|
@ -42,6 +42,15 @@ bool CefDOMNodeCToCpp::IsElement()
|
|||
return struct_->is_element(struct_) ? true : false;
|
||||
}
|
||||
|
||||
bool CefDOMNodeCToCpp::IsSame(CefRefPtr<CefDOMNode> that)
|
||||
{
|
||||
if (CEF_MEMBER_MISSING(struct_, is_same))
|
||||
return false;
|
||||
|
||||
return struct_->is_same(struct_, CefDOMNodeCToCpp::Unwrap(that)) ?
|
||||
true : false;
|
||||
}
|
||||
|
||||
CefString CefDOMNodeCToCpp::GetName()
|
||||
{
|
||||
CefString str;
|
||||
|
|
|
@ -34,6 +34,7 @@ public:
|
|||
virtual Type GetType();
|
||||
virtual bool IsText();
|
||||
virtual bool IsElement();
|
||||
virtual bool IsSame(CefRefPtr<CefDOMNode> that);
|
||||
virtual CefString GetName();
|
||||
virtual CefString GetValue();
|
||||
virtual bool SetValue(const CefString& value);
|
||||
|
|
|
@ -33,6 +33,7 @@ public:
|
|||
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());
|
||||
|
@ -44,6 +45,7 @@ public:
|
|||
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());
|
||||
|
|
Loading…
Reference in New Issue