Changeset 116763 in webkit


Ignore:
Timestamp:
May 11, 2012 6:49:17 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Web Intents code only supports V8
https://bugs.webkit.org/show_bug.cgi?id=85954

Patch by Christophe Dumez <Christophe Dumez> on 2012-05-11
Reviewed by Adam Barth.

.:

Add ENABLE_WEB_INTENTS flag to CMake.

  • Source/cmake/WebKitFeatures.cmake:
  • Source/cmakeconfig.h.cmake:

Source/WebCore:

Add necessary abstraction for js Dictionary and ScriptValue so that
the Web Intents code in WebCore compiles with JSC, not just V8.

This required changes in the JSC bindings generator to pass
callback arguments of type SerializedScriptValue as raw pointers
instead of RefPtr. This matches the change made to the V8 bindings
generator in r104531.

  • CMakeLists.txt:
  • Modules/intents/Intent.cpp:
  • Modules/intents/Intent.h:
  • bindings/js/Dictionary.cpp:

(WebCore::Dictionary::Dictionary):
(WebCore):
(WebCore::Dictionary::getOwnPropertiesAsStringHashMap):

  • bindings/js/Dictionary.h:

(Dictionary):

  • bindings/js/JSBindingsAllInOne.cpp:
  • bindings/js/JSDictionary.cpp:

(WebCore::JSDictionary::convertValue):
(WebCore):

  • bindings/js/JSDictionary.h:

(WebCore):
(WebCore::JSDictionary::initializerObject):

  • bindings/js/ScriptValue.cpp:

(WebCore::ScriptValue::serialize):
(WebCore):

  • bindings/js/ScriptValue.h:

(ScriptValue):

  • bindings/scripts/CodeGeneratorJS.pm:

(AddIncludesForType):
(GenerateCallbackHeader):
(GenerateCallbackImplementation):
(GetNativeTypeForCallbacks):

Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r116758 r116763  
     12012-05-11  Christophe Dumez  <christophe.dumez@intel.com>
     2
     3        Web Intents code only supports V8
     4        https://bugs.webkit.org/show_bug.cgi?id=85954
     5
     6        Reviewed by Adam Barth.
     7
     8        Add ENABLE_WEB_INTENTS flag to CMake.
     9
     10        * Source/cmake/WebKitFeatures.cmake:
     11        * Source/cmakeconfig.h.cmake:
     12
    1132012-05-11  Xiaobo Wang  <xbwang@torchmobile.com.cn>
    214
  • trunk/Source/JavaScriptCore/API/JSValueRef.h

    r56189 r116763  
    6464@result         A value of type JSType that identifies value's type.
    6565*/
    66 JS_EXPORT JSType JSValueGetType(JSContextRef ctx, JSValueRef value);
     66JS_EXPORT JSType JSValueGetType(JSContextRef ctx, JSValueRef);
    6767
    6868/*!
  • trunk/Source/WebCore/CMakeLists.txt

    r116690 r116763  
    44    "${WEBCORE_DIR}/Modules/geolocation"
    55    "${WEBCORE_DIR}/Modules/indexeddb"
     6    "${WEBCORE_DIR}/Modules/intents"
    67    "${WEBCORE_DIR}/Modules/webaudio"
    78    "${WEBCORE_DIR}/Modules/webdatabase"
     
    25082509ENDIF ()
    25092510
     2511IF (ENABLE_WEB_INTENTS)
     2512    LIST(APPEND WebCore_IDL_FILES
     2513        Modules/intents/DOMWindowIntents.idl
     2514        Modules/intents/Intent.idl
     2515        Modules/intents/IntentResultCallback.idl
     2516        Modules/intents/NavigatorIntents.idl
     2517    )
     2518    LIST(APPEND WebCore_SOURCES
     2519       Modules/intents/Intent.cpp
     2520       Modules/intents/IntentRequest.cpp
     2521       Modules/intents/NavigatorIntents.cpp
     2522    )
     2523ENDIF ()
     2524
    25102525# Modules that the bindings generator scripts may use
    25112526SET(SCRIPTS_RESOLVE_SUPPLEMENTAL
  • trunk/Source/WebCore/ChangeLog

    r116762 r116763  
     12012-05-11  Christophe Dumez  <christophe.dumez@intel.com>
     2
     3        Web Intents code only supports V8
     4        https://bugs.webkit.org/show_bug.cgi?id=85954
     5
     6        Reviewed by Adam Barth.
     7
     8        Add necessary abstraction for js Dictionary and ScriptValue so that
     9        the Web Intents code in WebCore compiles with JSC, not just V8.
     10
     11        This required changes in the JSC bindings generator to pass
     12        callback arguments of type SerializedScriptValue as raw pointers
     13        instead of RefPtr. This matches the change made to the V8 bindings
     14        generator in r104531.
     15
     16        * CMakeLists.txt:
     17        * Modules/intents/Intent.cpp:
     18        * Modules/intents/Intent.h:
     19        * bindings/js/Dictionary.cpp:
     20        (WebCore::Dictionary::Dictionary):
     21        (WebCore):
     22        (WebCore::Dictionary::getOwnPropertiesAsStringHashMap):
     23        * bindings/js/Dictionary.h:
     24        (Dictionary):
     25        * bindings/js/JSBindingsAllInOne.cpp:
     26        * bindings/js/JSDictionary.cpp:
     27        (WebCore::JSDictionary::convertValue):
     28        (WebCore):
     29        * bindings/js/JSDictionary.h:
     30        (WebCore):
     31        (WebCore::JSDictionary::initializerObject):
     32        * bindings/js/ScriptValue.cpp:
     33        (WebCore::ScriptValue::serialize):
     34        (WebCore):
     35        * bindings/js/ScriptValue.h:
     36        (ScriptValue):
     37        * bindings/scripts/CodeGeneratorJS.pm:
     38        (AddIncludesForType):
     39        (GenerateCallbackHeader):
     40        (GenerateCallbackImplementation):
     41        (GetNativeTypeForCallbacks):
     42
    1432012-05-11  Alexander Pavlov  <apavlov@chromium.org>
    244
  • trunk/Source/WebCore/Modules/intents/Intent.cpp

    r115264 r116763  
    3434#include "ExceptionCode.h"
    3535#include "MessagePort.h"
    36 #include "ScriptState.h"
    3736#include "SerializedScriptValue.h"
    3837
  • trunk/Source/WebCore/Modules/intents/Intent.h

    r115264 r116763  
    3636#include "MessagePort.h"
    3737#include "MessagePortChannel.h"
     38#include "ScriptState.h"
    3839#include <wtf/Forward.h>
    3940#include <wtf/PassRefPtr.h>
     
    4445namespace WebCore {
    4546
    46 class ScriptState;
    4747class SerializedScriptValue;
    4848
  • trunk/Source/WebCore/bindings/js/Dictionary.cpp

    r114855 r116763  
    3636namespace WebCore {
    3737
     38Dictionary::Dictionary()
     39    : m_dictionary(0, 0)
     40{
     41}
     42
    3843Dictionary::Dictionary(JSC::ExecState* exec, JSC::JSValue value)
    3944    : m_dictionary(exec, value.isObject() ? value.getObject() : 0)
     
    5055#endif
    5156
     57bool Dictionary::getOwnPropertiesAsStringHashMap(WTF::HashMap<String, String>& map) const
     58{
     59    if (!m_dictionary.isValid())
     60        return false;
     61
     62    JSObject* object =  m_dictionary.initializerObject();
     63    ExecState* exec = m_dictionary.execState();
     64
     65    PropertyNameArray propertyNames(exec);
     66    JSObject::getOwnPropertyNames(object, exec, propertyNames, ExcludeDontEnumProperties);
     67    for (PropertyNameArray::const_iterator it = propertyNames.begin(); it != propertyNames.end(); it++) {
     68        String stringKey = ustringToString(it->ustring());
     69        if (stringKey.isEmpty())
     70            continue;
     71        JSValue value = object->get(exec, *it);
     72        if (exec->hadException())
     73            continue;
     74        String stringValue = ustringToString(value.toString(exec)->value(exec));
     75        if (!exec->hadException())
     76            map.set(stringKey, stringValue);
     77    }
     78
     79    return true;
     80}
     81
    5282};
    5383
  • trunk/Source/WebCore/bindings/js/Dictionary.h

    r114855 r116763  
    3232#include "NotImplemented.h"
    3333#include "ScriptValue.h"
     34#include <wtf/HashMap.h>
    3435#include <wtf/text/CString.h>
    3536#include <wtf/text/WTFString.h>
     
    4445class Dictionary {
    4546public:
     47    Dictionary();
    4648    Dictionary(JSC::ExecState*, JSC::JSValue);
    4749
     
    5961    bool isObject() const { return m_dictionary.isValid(); }
    6062    bool isUndefinedOrNull() const { return !m_dictionary.isValid(); }
     63    bool getOwnPropertiesAsStringHashMap(WTF::HashMap<String, String>&) const;
    6164    bool getWithUndefinedOrNullCheck(const String&, String&) const { notImplemented(); return false; }
    6265
  • trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp

    r107454 r116763  
    2929#include "DOMObjectHashTableMap.cpp"
    3030#include "DOMWrapperWorld.cpp"
     31#include "Dictionary.cpp"
    3132#include "GCController.cpp"
    3233#include "JSArrayBufferCustom.cpp"
  • trunk/Source/WebCore/bindings/js/JSDictionary.cpp

    r114001 r116763  
    2727#include "JSDictionary.h"
    2828
     29#include "Dictionary.h"
    2930#include "JSDOMWindow.h"
    3031#include "JSEventTarget.h"
     
    9091{
    9192    result = value.toNumber(exec);
     93}
     94
     95void JSDictionary::convertValue(JSC::ExecState* exec, JSC::JSValue value, Dictionary& result)
     96{
     97    result = Dictionary(exec, value);
    9298}
    9399
  • trunk/Source/WebCore/bindings/js/JSDictionary.h

    r114855 r116763  
    3333namespace WebCore {
    3434
     35class Dictionary;
    3536class DOMWindow;
    3637class EventTarget;
     
    6061
    6162    JSC::ExecState* execState() const { return m_exec; }
     63    JSC::JSObject* initializerObject() const { return m_initializerObject; }
    6264    bool isValid() const { return m_exec && m_initializerObject; }
    6365
     
    8789    static void convertValue(JSC::ExecState*, JSC::JSValue, unsigned long long& result);
    8890    static void convertValue(JSC::ExecState*, JSC::JSValue, double& result);
     91    static void convertValue(JSC::ExecState*, JSC::JSValue, Dictionary& result);
    8992    static void convertValue(JSC::ExecState*, JSC::JSValue, String& result);
    9093    static void convertValue(JSC::ExecState*, JSC::JSValue, ScriptValue& result);
  • trunk/Source/WebCore/bindings/js/ScriptValue.cpp

    r115061 r116763  
    107107}
    108108
     109PassRefPtr<SerializedScriptValue> ScriptValue::serialize(ScriptState* scriptState, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, bool& didThrow)
     110{
     111    JSValueRef exception = 0;
     112    RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::create(toRef(scriptState), toRef(scriptState, jsValue()), messagePorts, arrayBuffers, &exception);
     113    didThrow = exception ? true : false;
     114    return serializedValue.release();
     115}
     116
    109117ScriptValue ScriptValue::deserialize(ScriptState* scriptState, SerializedScriptValue* value, SerializationErrorMode throwExceptions)
    110118{
  • trunk/Source/WebCore/bindings/js/ScriptValue.h

    r115158 r116763  
    6464
    6565    PassRefPtr<SerializedScriptValue> serialize(ScriptState*, SerializationErrorMode = Throwing);
     66    PassRefPtr<SerializedScriptValue> serialize(ScriptState*, MessagePortArray*, ArrayBufferArray*, bool&);
    6667    static ScriptValue deserialize(ScriptState*, SerializedScriptValue*, SerializationErrorMode = Throwing);
    6768
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r116487 r116763  
    263263    } elsif ($type eq "unsigned long[]") {
    264264        $includesRef->{"<wtf/Vector.h>"} = 1;
     265    } elsif ($type eq "SerializedScriptValue") {
     266        $includesRef->{"SerializedScriptValue.h"} = 1;
    265267    } elsif ($isCallback) {
    266268        $includesRef->{"JS${type}.h"} = 1;
     
    26052607            }
    26062608
    2607             push(@headerContent, "    virtual " . GetNativeType($function->signature->type) . " " . $function->signature->name . "(");
     2609            push(@headerContent, "    virtual " . GetNativeTypeForCallbacks($function->signature->type) . " " . $function->signature->name . "(");
    26082610
    26092611            my @args = ();
    26102612            foreach my $param (@params) {
    2611                 push(@args, GetNativeType($param->type) . " " . $param->name);
     2613                push(@args, GetNativeTypeForCallbacks($param->type) . " " . $param->name);
    26122614            }
    26132615            push(@headerContent, join(", ", @args));
     
    26842686
    26852687            AddIncludesForTypeInImpl($function->signature->type);
    2686             push(@implContent, "\n" . GetNativeType($function->signature->type) . " ${className}::" . $function->signature->name . "(");
     2688            push(@implContent, "\n" . GetNativeTypeForCallbacks($function->signature->type) . " ${className}::" . $function->signature->name . "(");
    26872689
    26882690            my @args = ();
     
    26922694                my $paramName = $param->name;
    26932695                AddIncludesForTypeInImpl($param->type, 1);
    2694                 push(@args, GetNativeType($param->type) . " " . $paramName);
     2696                push(@args, GetNativeTypeForCallbacks($param->type) . " " . $paramName);
    26952697                if ($thisType and $thisType eq $param->type) {
    26962698                    push(@argsCheck, <<END);
     
    27182720                } elsif ($param->type eq "boolean") {
    27192721                    push(@implContent, "    args.append(jsBoolean(${paramName}));\n");
     2722                } elsif ($param->type eq "SerializedScriptValue") {
     2723                    push(@implContent, "    args.append($paramName ? $paramName->deserialize(exec, m_data->globalObject(), 0) : jsNull());\n");
    27202724                } else {
    27212725                    push(@implContent, "    args.append(toJS(exec, m_data->globalObject(), ${paramName}));\n");
     
    28332837}
    28342838
     2839sub GetNativeTypeForCallbacks
     2840{
     2841    my $type = shift;
     2842    return "SerializedScriptValue*" if $type eq "SerializedScriptValue";
     2843
     2844    return GetNativeType($type);
     2845}
     2846
    28352847sub GetSVGPropertyTypes
    28362848{
  • trunk/Source/cmake/WebKitFeatures.cmake

    r116571 r116763  
    9090    WEBKIT_OPTION_DEFINE(ENABLE_WEBGL "Toggle 3D canvas (WebGL) support" OFF)
    9191    WEBKIT_OPTION_DEFINE(ENABLE_WEB_AUDIO "Toggle Web Audio support" OFF)
     92    WEBKIT_OPTION_DEFINE(ENABLE_WEB_INTENTS "Toggle Web Intents support" OFF)
    9293    WEBKIT_OPTION_DEFINE(ENABLE_WEB_SOCKETS "Toggle Web Sockets support" ON)
    9394    WEBKIT_OPTION_DEFINE(ENABLE_WEB_TIMING "Toggle Web Timing support" OFF)
  • trunk/Source/cmakeconfig.h.cmake

    r116536 r116763  
    7171#cmakedefine01 ENABLE_WEBGL
    7272#cmakedefine01 ENABLE_WEB_AUDIO
     73#cmakedefine01 ENABLE_WEB_INTENTS
    7374#cmakedefine01 ENABLE_WEB_SOCKETS
    7475#cmakedefine01 ENABLE_WEB_TIMING
Note: See TracChangeset for help on using the changeset viewer.