示例#1
0
bool Dictionary::getOwnPropertiesAsStringHashMap(WTF::HashMap<String, String>& hashMap) const
{
    if (!isObject())
        return false;

    v8::Handle<v8::Object> options = m_options->ToObject();
    if (options.IsEmpty())
        return false;

    v8::Local<v8::Array> properties = options->GetOwnPropertyNames();
    if (properties.IsEmpty())
        return true;
    for (uint32_t i = 0; i < properties->Length(); ++i) {
        v8::Local<v8::String> key = properties->Get(i)->ToString();
        if (!options->Has(key))
            continue;

        v8::Local<v8::Value> value = options->Get(key);
        String stringKey = v8ValueToWebCoreString(key);
        String stringValue = v8ValueToWebCoreString(value);
        if (!stringKey.isEmpty())
            hashMap.set(stringKey, stringValue);
    }

    return true;
}
示例#2
0
void DumpRenderTreeSupportEfl::evaluateScriptInIsolatedWorld(const Evas_Object* ewkFrame, int worldID, JSObjectRef globalObject, const String& script)
{
    WebCore::Frame* coreFrame = EWKPrivate::coreFrame(ewkFrame);
    if (!coreFrame)
        return;

    // Comment from mac: Start off with some guess at a frame and a global object, we'll try to do better...!
    WebCore::JSDOMWindow* anyWorldGlobalObject = coreFrame->script()->globalObject(WebCore::mainThreadNormalWorld());

    // Comment from mac: The global object is probably a shell object? - if so, we know how to use this!
    JSC::JSObject* globalObjectObj = toJS(globalObject);
    if (!strcmp(globalObjectObj->classInfo()->className, "JSDOMWindowShell"))
        anyWorldGlobalObject = static_cast<WebCore::JSDOMWindowShell*>(globalObjectObj)->window();

    // Comment from mac: Get the frame from the global object we've settled on.
    WebCore::Frame* globalFrame = anyWorldGlobalObject->impl()->frame();
    if (!globalFrame)
        return;

    WebCore::ScriptController* proxy = globalFrame->script();
    if (!proxy)
        return;

    static WTF::HashMap<int, WTF::RefPtr<WebCore::DOMWrapperWorld > > worldMap;

    WTF::RefPtr<WebCore::DOMWrapperWorld> scriptWorld;
    if (!worldID)
        scriptWorld = WebCore::ScriptController::createWorld();
    else {
        WTF::HashMap<int, RefPtr<WebCore::DOMWrapperWorld > >::const_iterator it = worldMap.find(worldID);
        if (it != worldMap.end())
            scriptWorld = (*it).second;
        else {
            scriptWorld = WebCore::ScriptController::createWorld();
            worldMap.set(worldID, scriptWorld);
        }
    }

    // The code below is only valid for JSC, V8 specific code is to be added
    // when V8 will be supported in EFL port. See Qt implemenation.
    proxy->executeScriptInWorld(scriptWorld.get(), script, true);
}
示例#3
0
bool Dictionary::getOwnPropertiesAsStringHashMap(WTF::HashMap<String, String>& map) const
{
    if (!m_dictionary.isValid())
        return false;

    JSObject* object =  m_dictionary.initializerObject();
    ExecState* exec = m_dictionary.execState();

    PropertyNameArray propertyNames(exec);
    JSObject::getOwnPropertyNames(object, exec, propertyNames, ExcludeDontEnumProperties);
    for (PropertyNameArray::const_iterator it = propertyNames.begin(); it != propertyNames.end(); it++) {
        String stringKey = ustringToString(it->ustring());
        if (stringKey.isEmpty())
            continue;
        JSValue value = object->get(exec, *it);
        if (exec->hadException())
            continue;
        String stringValue = ustringToString(value.toString(exec)->value(exec));
        if (!exec->hadException())
            map.set(stringKey, stringValue);
    }

    return true;
}