Changeset 93637 in webkit


Ignore:
Timestamp:
Aug 23, 2011 2:01:52 PM (13 years ago)
Author:
demarchi@webkit.org
Message:

Source/WebKit: Patch by Jonas M. Gastal <jgastal@profusion.mobi> on 2011-08-23
Reviewed by Antonio Gomes.

[EFL] Exporting JavaScript objects for EFL port
https://bugs.webkit.org/show_bug.cgi?id=43446

This patch allows to export objects to JavaScript API,
just like qt does, but it uses the netscape api
to do the convertion to javascript object.

  • CMakeLists.txt:

Adding necessary files for the patch.

Source/WebKit/efl: [EFL] Exporting JavaScript objects for EFL port
https://bugs.webkit.org/show_bug.cgi?id=43446

Patch by Jonas M. Gastal <jgastal@profusion.mobi> on 2011-08-23
Reviewed by Antonio Gomes.

This patch allows to export objects to JavaScript API,
just like qt does, but it uses the netscape api
to do the convertion to javascript object.

  • CMakeLists.txt:
  • WebCoreSupport/FrameLoaderClientEfl.cpp:

(WebCore::FrameLoaderClientEfl::dispatchDidClearWindowObjectInWorld):

  • ewk/EWebKit.h:
  • ewk/ewk_js.cpp: Added.

(ewk_js_variant_to_npvariant):
(ewk_js_npvariant_to_variant):
(ewk_js_property_has):
(ewk_js_property_get):
(ewk_js_property_set):
(ewk_js_property_remove):
(ewk_js_properties_enumerate):
(ewk_js_method_has):
(ewk_js_method_invoke):
(ewk_js_class_new):
(ewk_js_class_free):
(ewk_js_object_new):
(ewk_js_object_free):
(ewk_js_object_properties_get):
(ewk_js_object_name_get):
(ewk_js_variant_free):

  • ewk/ewk_js.h: Added.
  • ewk/ewk_main.cpp:

(ewk_init):

  • ewk/ewk_private.h:
  • ewk/ewk_view.cpp:

(ewk_view_js_window_object_clear):
(ewk_view_js_object_add):

  • ewk/ewk_view.h:
Location:
trunk/Source/WebKit
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/CMakeLists.txt

    r83792 r93637  
    66    "${WEBCORE_DIR}/bindings"
    77    "${WEBCORE_DIR}/bridge"
     8    "${WEBCORE_DIR}/bridge/c"
    89    "${WEBCORE_DIR}/bridge/jsc"
    910    "${WEBCORE_DIR}/css"
  • trunk/Source/WebKit/ChangeLog

    r92492 r93637  
     12011-08-23  Jonas M. Gastal <jgastal@profusion.mobi>
     2
     3        Reviewed by Antonio Gomes.
     4
     5        [EFL] Exporting JavaScript objects for EFL port
     6        https://bugs.webkit.org/show_bug.cgi?id=43446
     7
     8        This patch allows to export objects to JavaScript API,
     9        just like qt does, but it uses the netscape api
     10        to do the convertion to javascript object.
     11
     12        * CMakeLists.txt:
     13        Adding necessary files for the patch.
     14
    1152011-08-05  Anders Carlsson  <andersca@apple.com>
    216
  • trunk/Source/WebKit/efl/CMakeListsEfl.txt

    r91973 r93637  
    8181    efl/ewk/ewk_view_tiled.c
    8282    efl/ewk/ewk_window_features.cpp
     83    efl/ewk/ewk_js.cpp
    8384)
    8485
  • trunk/Source/WebKit/efl/ChangeLog

    r93617 r93637  
     12011-08-23  Jonas M. Gastal <jgastal@profusion.mobi>
     2
     3        [EFL] Exporting JavaScript objects for EFL port
     4        https://bugs.webkit.org/show_bug.cgi?id=43446
     5
     6        Reviewed by Antonio Gomes.
     7
     8        This patch allows to export objects to JavaScript API,
     9        just like qt does, but it uses the netscape api
     10        to do the convertion to javascript object.
     11
     12        * CMakeLists.txt:
     13        * WebCoreSupport/FrameLoaderClientEfl.cpp:
     14        (WebCore::FrameLoaderClientEfl::dispatchDidClearWindowObjectInWorld):
     15        * ewk/EWebKit.h:
     16        * ewk/ewk_js.cpp: Added.
     17        (ewk_js_variant_to_npvariant):
     18        (ewk_js_npvariant_to_variant):
     19        (ewk_js_property_has):
     20        (ewk_js_property_get):
     21        (ewk_js_property_set):
     22        (ewk_js_property_remove):
     23        (ewk_js_properties_enumerate):
     24        (ewk_js_method_has):
     25        (ewk_js_method_invoke):
     26        (ewk_js_class_new):
     27        (ewk_js_class_free):
     28        (ewk_js_object_new):
     29        (ewk_js_object_free):
     30        (ewk_js_object_properties_get):
     31        (ewk_js_object_name_get):
     32        (ewk_js_variant_free):
     33        * ewk/ewk_js.h: Added.
     34        * ewk/ewk_main.cpp:
     35        (ewk_init):
     36        * ewk/ewk_private.h:
     37        * ewk/ewk_view.cpp:
     38        (ewk_view_js_window_object_clear):
     39        (ewk_view_js_object_add):
     40        * ewk/ewk_view.h:
     41
    1422011-08-23  Raphael Kubo da Costa  <kubo@profusion.mobi>
    243
  • trunk/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp

    r93611 r93637  
    441441
    442442    evas_object_smart_callback_call(m_view, "window,object,cleared", &event);
     443
     444#if ENABLE(NETSCAPE_PLUGIN_API)
     445    ewk_view_js_window_object_clear(m_view, m_frame);
     446#endif
    443447}
    444448
  • trunk/Source/WebKit/efl/ewk/EWebKit.h

    r91255 r93637  
    3535#include "ewk_frame.h"
    3636#include "ewk_history.h"
     37#include "ewk_js.h"
    3738#include "ewk_main.h"
    3839#include "ewk_network.h"
  • trunk/Source/WebKit/efl/ewk/ewk_private.h

    r93617 r93637  
    3131#include "EWebKit.h"
    3232#include "Frame.h"
     33#include "NP_jsobject.h"
    3334#include "Page.h"
    3435#include "Settings.h"
    3536#include "Widget.h"
     37#include "ewk_js.h"
    3638#include "ewk_logging.h"
    3739#include "ewk_util.h"
     
    4749// If defined, ewk will do type checking to ensure objects are of correct type
    4850#define EWK_TYPE_CHECK 1
     51
     52#if ENABLE(NETSCAPE_PLUGIN_API)
     53#define EWK_JS_OBJECT_MAGIC 0x696969
     54
     55typedef struct _Ewk_JS_Class Ewk_JS_Class;
     56struct _Ewk_JS_Object {
     57    JavaScriptObject base;
     58    const char *name;
     59    const Ewk_JS_Class *cls;
     60    Eina_Hash *properties;
     61    Evas_Object *view; // ewk_view: check if this object has already been added to another ewk_view
     62    Ewk_JS_Object_Type type;
     63    EINA_MAGIC;
     64};
     65#endif // ENABLE(NETSCAPE_PLUGIN_API)
    4966
    5067// forward declarations
     
    122139void ewk_view_editor_client_selection_changed(Evas_Object *o);
    123140
     141#if ENABLE(NETSCAPE_PLUGIN_API)
     142void ewk_view_js_window_object_clear(Evas_Object *o, Evas_Object *frame);
     143#endif
     144
    124145int ewk_util_dpi_get(void);
    125146void ewk_util_javascript_gc_collect();
  • trunk/Source/WebKit/efl/ewk/ewk_view.cpp

    r93401 r93637  
    2424
    2525#include "BackForwardListImpl.h"
     26#include "Bridge.h"
    2627#include "Chrome.h"
    2728#include "ChromeClientEfl.h"
     
    4142#include "InspectorClientEfl.h"
    4243#include "IntSize.h"
     44#include "JSDOMBinding.h"
     45#include "JSDOMWindow.h"
     46#include "JSLock.h"
    4347#include "PlatformMouseEvent.h"
    4448#include "PopupMenuClient.h"
    4549#include "ProgressTracker.h"
    4650#include "RenderTheme.h"
     51#include "c_instance.h"
    4752#include "ewk_private.h"
    4853
     
    33913396/**
    33923397 * @internal
     3398 * Reports the JS window object was cleared.
     3399 *
     3400 * @param o view.
     3401 * @param frame the frame.
     3402 */
     3403void ewk_view_js_window_object_clear(Evas_Object *o, Evas_Object *frame)
     3404{
     3405    evas_object_smart_callback_call(o, "js,windowobject,clear", frame);
     3406}
     3407
     3408/**
     3409 * @internal
    33933410 * Reports the viewport has changed.
    33943411 *
     
    35393556    return sd->api->navigation_policy_decision(sd, request);
    35403557}
     3558
     3559Eina_Bool ewk_view_js_object_add(Evas_Object *o, Ewk_JS_Object *obj, const char *obj_name)
     3560{
     3561#if ENABLE(NETSCAPE_PLUGIN_API)
     3562    if (obj->view) // object has already been added to another ewk_view
     3563        return EINA_FALSE;
     3564    obj->name = eina_stringshare_add(obj_name);
     3565    EWK_VIEW_SD_GET_OR_RETURN(o, sd, EINA_FALSE);
     3566    EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, EINA_FALSE);
     3567
     3568    JSC::JSLock lock(JSC::SilenceAssertionsOnly);
     3569    WebCore::JSDOMWindow *window = toJSDOMWindow(priv->main_frame, WebCore::mainThreadNormalWorld());
     3570    JSC::Bindings::RootObject *root;
     3571    root = priv->main_frame->script()->bindingRootObject();
     3572
     3573    if (!window) {
     3574        ERR("Warning: couldn't get window object");
     3575        return EINA_FALSE;
     3576    }
     3577
     3578    JSC::ExecState* exec = window->globalExec();
     3579
     3580    obj->view = o;
     3581    JSC::JSObject *runtimeObject = (JSC::JSObject*)JSC::Bindings::CInstance::create((NPObject*)obj, root)->createRuntimeObject(exec);
     3582    JSC::Identifier id = JSC::Identifier(exec, obj_name);
     3583
     3584    JSC::PutPropertySlot slot;
     3585    window->put(exec, id, runtimeObject, slot);
     3586    return EINA_TRUE;
     3587#else
     3588    return EINA_FALSE;
     3589#endif // ENABLE(NETSCAPE_PLUGIN_API)
     3590}
     3591
    35413592
    35423593/**
  • trunk/Source/WebKit/efl/ewk/ewk_view.h

    r93488 r93637  
    4141 *  - "inputmethod,changed", Eina_Bool: reports that input method was changed and
    4242 *    it gives a boolean value whether it's enabled or not as an argument.
     43 *  - "js,windowobject,clear", void: Report that the JS window object has been cleared.
    4344 *  - "link,hover,in", const char *link[2]: reports mouse is over a link.
    4445 *    It gives the url in link[0] and link's title in link[1] as an argument.
     
    8687#include "ewk_frame.h"
    8788#include "ewk_history.h"
     89#include "ewk_js.h"
    8890#include "ewk_window_features.h"
    8991
     
    21762178 */
    21772179EAPI Ewk_View_Mode ewk_view_mode_get(Evas_Object *o);
     2180
     2181/**
     2182 * Creates a JS object named @a obj_name as property of the window object. This should be called on a callback connectedto the
     2183 * js,windowobject,clear signal.
     2184 *
     2185 * @param o view.
     2186 * @param obj object that will be added(see: @a ewk_js_object_new).
     2187 * @param obj_name name of the object.
     2188 *
     2189 * @return @c EINA_TRUE if object was added, @c EINA_FALSE if not.
     2190 */
     2191EAPI Eina_Bool ewk_view_js_object_add(Evas_Object *o, Ewk_JS_Object *obj, const char *obj_name);
    21782192#ifdef __cplusplus
    21792193}
Note: See TracChangeset for help on using the changeset viewer.