⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 100204 in webkit


Ignore:
Timestamp:
Nov 14, 2011, 4:01:15 PM (15 years ago)
Author:
commit-queue@webkit.org
Message:

[EFL] Update ewk_frame_script_execute to return the result for JavaScript
https://bugs.webkit.org/show_bug.cgi?id=65972

Patch by Jongseok Yang <js45.yang@samsung.com> on 2011-11-14
Reviewed by Antonio Gomes.

It executes the javascript and converts the result to a string using toString.
And it returns the memory-allocated pointer for the value.

  • ewk/ewk_frame.cpp:

(ewk_frame_script_execute):

  • ewk/ewk_frame.h:
Location:
trunk/Source/WebKit/efl
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/efl/ChangeLog

    r100097 r100204  
     12011-11-14  Jongseok Yang  <js45.yang@samsung.com>
     2
     3        [EFL] Update ewk_frame_script_execute to return the result for JavaScript
     4        https://bugs.webkit.org/show_bug.cgi?id=65972
     5
     6        Reviewed by Antonio Gomes.
     7
     8        It executes the javascript and converts the result to a string using toString.
     9        And it returns the memory-allocated pointer for the value.
     10
     11        * ewk/ewk_frame.cpp:
     12        (ewk_frame_script_execute):
     13        * ewk/ewk_frame.h:
     14
    1152011-11-13  Raphael Kubo da Costa  <kubo@profusion.mobi>
    216
  • trunk/Source/WebKit/efl/ewk/ewk_frame.cpp

    r99480 r100204  
    417417}
    418418
    419 Eina_Bool ewk_frame_script_execute(Evas_Object* ewkFrame, const char* script)
    420 {
    421     EWK_FRAME_SD_GET_OR_RETURN(ewkFrame, smartData, false);
    422     EINA_SAFETY_ON_FALSE_RETURN_VAL(smartData->frame, false);
    423     EINA_SAFETY_ON_NULL_RETURN_VAL(script, false);
    424     smartData->frame->script()->executeScript(WTF::String::fromUTF8(script), true);
    425     return true;
     419char* ewk_frame_script_execute(Evas_Object* ewkFrame, const char* script)
     420{
     421    EWK_FRAME_SD_GET_OR_RETURN(ewkFrame, smartData, 0);
     422    EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->frame, 0);
     423    EINA_SAFETY_ON_NULL_RETURN_VAL(script, 0);
     424
     425#if USE(JSC)
     426    WTF::String resultString;
     427    JSC::JSValue result = smartData->frame->script()->executeScript(WTF::String::fromUTF8(script), true).jsValue();
     428
     429    if (!smartData->frame) // In case the script removed our frame from the page.
     430        return 0;
     431
     432    if (!result || (!result.isBoolean() && !result.isString() && !result.isNumber()))
     433        return 0;
     434
     435    JSC::JSLock lock(JSC::SilenceAssertionsOnly);
     436    resultString = WebCore::ustringToString(result.toString(smartData->frame->script()->globalObject(WebCore::mainThreadNormalWorld())->globalExec()));
     437    return strdup(resultString.utf8().data());
     438#else
     439    notImplemented();
     440    return 0;
     441#endif
    426442}
    427443
  • trunk/Source/WebKit/efl/ewk/ewk_frame.h

    r98378 r100204  
    320320 * Requests execution of the given script.
    321321 *
     322 * The returned string @b should be freed after use.
     323 *
    322324 * @param o frame object to execute script
    323325 * @param script Java Script to execute
    324326 *
    325  * @return @c EINA_TRUE if request was done, @c EINA_FALSE on errors
    326  */
    327 EAPI Eina_Bool    ewk_frame_script_execute(Evas_Object *o, const char *script);
     327 * @return newly allocated string for result or @c 0 if the result cannot be converted to string or failure
     328 */
     329EAPI char        *ewk_frame_script_execute(Evas_Object *o, const char *script);
    328330
    329331/**
Note: See TracChangeset for help on using the changeset viewer.