[webkit-efl] DOM exposure in eflwebkit
rony macabo
ronymacabo at gmail.com
Wed Aug 28 10:38:22 PDT 2013
Hi everybody,
i'm using eflwebkit (Source/WebKit), and i really need to access to dom
elements, to be aware when the focus goes to an input text, for example.
so i have started writing some set of functions to expose DOM.
in file ewk_view.cpp i have added this,
******************************************
struct _Ewk_Dom_Document
{
WebCore::Document* doc;
};
struct _Ewk_Dom_Node_List
{
WebCore::NodeList* nodelist;
};
struct _Ewk_Dom_Node
{
WebCore::Node* node;
};
static Ewk_Dom_Document current_doc = {0};
static Ewk_Dom_Node_List current_node_list = {0};
static Ewk_Dom_Node current_node = {0};
Ewk_Dom_Document* ewk_view_get_dom_document(Evas_Object* ewkView)
{
EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
current_doc.doc = priv->mainFrame->document();
return ¤t_doc;
}
Ewk_Dom_Node_List*
ewk_dom_document_get_elements_by_tag_name(Ewk_Dom_Document* m_doc, const
char* tagname)
{
WebCore::Document* element = m_doc->doc;
WTF::String wtf_name = WTF::String::fromUTF8(tagname);
PassRefPtr<WebCore::NodeList> g_res =
WTF::getPtr(element->getElementsByTagName(wtf_name));
current_node_list.nodelist = g_res.get();
return ¤t_node_list;
}
unsigned int ewk_dom_node_list_get_length(Ewk_Dom_Node_List* m_nodelist)
{
WebCore::NodeList* element = m_nodelist->nodelist;
return (unsigned int)element->length();
}
Ewk_Dom_Node* ewk_dom_get_node(Ewk_Dom_Node_List* m_nodelist, unsigned int
index)
{
WebCore::NodeList* element = m_nodelist->nodelist;
current_node.node = element->item(index);
return ¤t_node;
}
Eina_Bool ewk_dom_node_check_type(Ewk_Dom_Node* node, const char* type)
{
char* result;
g_object_get(G_OBJECT(n), "type", &result, NULL);
if( g_str_equal(type, result) )
return EINA_TRUE;
else
return EINA_FALSE;
}
******************************************
in file ewk_view.h i have added this
******************************************
typedef struct _Ewk_Dom_Document Ewk_Dom_Document;
typedef struct _Ewk_Dom_Node_List Ewk_Dom_Node_List;
typedef struct _Ewk_Dom_Node Ewk_Dom_Node;
EAPI Ewk_Dom_Document* ewk_view_get_dom_document(Evas_Object* ewkView);
EAPI Ewk_Dom_Node_List*
ewk_dom_document_get_elements_by_tag_name(Ewk_Dom_Document* m_doc, const
char* tagname);
EAPI unsigned int ewk_dom_node_list_get_length(Ewk_Dom_Node_List*
m_nodelist);
EAPI Eina_Bool ewk_dom_node_check_type(Ewk_Dom_Node* node, const char*
type);
Ewk_Dom_Node* ewk_dom_get_node(Ewk_Dom_Node_List* m_nodelist, unsigned int
index);
******************************************
when compiling eflwebkit i got this error
Source/WebKit/efl/ewk/ewk_view.cpp: In function 'unsigned int
> ewk_dom_node_list_get_length(Ewk_Dom_Node_List*)':
Source/WebKit/efl/ewk/ewk_view.cpp:4903:33: error: invalid use of
> incomplete type 'class WebCore::NodeList'
>
The problem come from this line
element->length()
after i have checked, i saw that WebCore::NodeList is an abstract class,
but i do not found which class implements it?
I wonder if I should create this class because it seems odd to me, I
thought webkit already had a base class for dom objects,
and i have just need to bring out the fields that interested me.
Please, have you any idea? i 'm wrong somewhere?
Thanks in advance,
Kind regards,
Rony.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-efl/attachments/20130828/beb4eacd/attachment.html>
More information about the webkit-efl
mailing list