Ejemplo n.º 1
2
v8::Handle<v8::Value> V8DataView::setUint8Callback(const v8::Arguments& args)
{
    if (args.Length() < 2)
        return throwNotEnoughArgumentsError(args.GetIsolate());

    DataView* imp = V8DataView::toNative(args.Holder());
    ExceptionCode ec = 0;
    V8TRYCATCH(unsigned, byteOffset, toUInt32(args[0]));
    V8TRYCATCH(int, value, toInt32(args[1]));
    imp->setUint8(byteOffset, static_cast<uint8_t>(value), ec);
    if (UNLIKELY(ec))
        return setDOMException(ec, args.GetIsolate());
    return v8Undefined();
}
static v8::Handle<v8::Value> histogramEnumerationCallback(const v8::Arguments& args)
{
    if (args.Length() < 3)
        return throwNotEnoughArgumentsError(args.GetIsolate());
    PagePopupController* imp = V8PagePopupController::toNative(args.Holder());
    V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, name, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined));
    V8TRYCATCH(int, sample, toInt32(MAYBE_MISSING_PARAMETER(args, 1, DefaultIsUndefined)));
    V8TRYCATCH(int, boundaryValue, toInt32(MAYBE_MISSING_PARAMETER(args, 2, DefaultIsUndefined)));
    imp->histogramEnumeration(name, sample, boundaryValue);
    return v8Undefined();
}
Ejemplo n.º 3
0
v8::Handle<v8::Value> toV8(EventTarget* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
    if (!impl)
        return v8NullWithCheck(isolate);

    AtomicString desiredInterface = impl->interfaceName();
    DOM_EVENT_TARGET_INTERFACES_FOR_EACH(TRY_TO_WRAP_WITH_INTERFACE)

    ASSERT_NOT_REACHED();
    return v8Undefined();
}
static v8::Handle<v8::Value> saveCallback(const v8::Arguments& args)
{
    if (args.Length() < 3)
        return throwNotEnoughArgumentsError(args.GetIsolate());
    InspectorFrontendHost* imp = V8InspectorFrontendHost::toNative(args.Holder());
    V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, url, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined));
    V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, content, MAYBE_MISSING_PARAMETER(args, 1, DefaultIsUndefined));
    V8TRYCATCH(bool, forceSaveAs, MAYBE_MISSING_PARAMETER(args, 2, DefaultIsUndefined)->BooleanValue());
    imp->save(url, content, forceSaveAs);
    return v8Undefined();
}
Ejemplo n.º 5
0
// A JS object of type EventTarget is limited to a small number of possible classes.
v8::Handle<v8::Value> V8DOMWrapper::convertEventTargetToV8Object(EventTarget* target, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
    if (!target)
        return v8NullWithCheck(isolate);

    AtomicString desiredInterface = target->interfaceName();
    DOM_EVENT_TARGET_INTERFACES_FOR_EACH(TRY_TO_WRAP_WITH_INTERFACE)

    ASSERT_NOT_REACHED();
    return v8Undefined();
}
static v8::Handle<v8::Value> getFrequencyResponseCallback(const v8::Arguments& args)
{
    if (args.Length() < 3)
        return throwNotEnoughArgumentsError(args.GetIsolate());
    BiquadFilterNode* imp = V8BiquadFilterNode::toNative(args.Holder());
    V8TRYCATCH(Float32Array*, frequencyHz, V8Float32Array::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)) ? V8Float32Array::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))) : 0);
    V8TRYCATCH(Float32Array*, magResponse, V8Float32Array::HasInstance(MAYBE_MISSING_PARAMETER(args, 1, DefaultIsUndefined)) ? V8Float32Array::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 1, DefaultIsUndefined))) : 0);
    V8TRYCATCH(Float32Array*, phaseResponse, V8Float32Array::HasInstance(MAYBE_MISSING_PARAMETER(args, 2, DefaultIsUndefined)) ? V8Float32Array::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 2, DefaultIsUndefined))) : 0);
    imp->getFrequencyResponse(frequencyHz, magResponse, phaseResponse);
    return v8Undefined();
}
Ejemplo n.º 7
0
static v8::Handle<v8::Value> removeEventListenerCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.TestEventTarget.removeEventListener()");
    RefPtr<EventListener> listener = V8DOMWrapper::getEventListener(args[1], false, ListenerFindOnly);
    if (listener) {
        V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<WithNullCheck>, stringResource, args[0]);
        V8TestEventTarget::toNative(args.Holder())->removeEventListener(stringResource, listener.get(), args[2]->BooleanValue());
        removeHiddenDependency(args.Holder(), args[1], V8TestEventTarget::eventListenerCacheIndex);
    }
    return v8Undefined();
}
Ejemplo n.º 8
0
v8::Handle<v8::Value> V8Console::profileEndCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.Console.profileEnd");
    Console* imp = V8Console::toNative(args.Holder());
    RefPtr<ScriptCallStack> callStack(createScriptCallStack(1));
    if (!callStack)
        return v8::Undefined();
    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<WithUndefinedOrNullCheck>, title, args[0]);
    imp->profileEnd(title, ScriptState::current(), callStack);
    return v8Undefined();
}
static v8::Handle<v8::Value> start2Callback(const v8::Arguments& args)
{
    FeatureObserver::observe(activeDOMWindow(BindingState::instance()), FeatureObserver::WebAudioStart);
    if (args.Length() < 2)
        return throwNotEnoughArgumentsError(args.GetIsolate());
    AudioBufferSourceNode* imp = V8AudioBufferSourceNode::toNative(args.Holder());
    V8TRYCATCH(double, when, static_cast<double>(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)->NumberValue()));
    V8TRYCATCH(double, grainOffset, static_cast<double>(MAYBE_MISSING_PARAMETER(args, 1, DefaultIsUndefined)->NumberValue()));
    imp->startGrain(when, grainOffset);
    return v8Undefined();
}
static v8::Handle<v8::Value> setVelocityCallback(const v8::Arguments& args)
{
    if (args.Length() < 3)
        return throwNotEnoughArgumentsError(args.GetIsolate());
    PannerNode* imp = V8PannerNode::toNative(args.Holder());
    V8TRYCATCH(float, x, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)->NumberValue()));
    V8TRYCATCH(float, y, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 1, DefaultIsUndefined)->NumberValue()));
    V8TRYCATCH(float, z, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 2, DefaultIsUndefined)->NumberValue()));
    imp->setVelocity(x, y, z);
    return v8Undefined();
}
Ejemplo n.º 11
0
v8::Handle<v8::Value> V8HTMLOptionsCollection::indexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.HTMLOptionsCollection.IndexedPropertyGetter");
    HTMLOptionsCollection* collection = V8HTMLOptionsCollection::toNative(info.Holder());

    RefPtr<Node> result = collection->item(index);
    if (!result)
        return v8Undefined();

    return toV8(result.release(), info.Holder()->CreationContext(), info.GetIsolate());
}
Ejemplo n.º 12
0
static v8::Handle<v8::Value> getNthValueOnKeyPath(v8::Handle<v8::Value>& rootValue, const Vector<String>& keyPathElements, size_t index, v8::Isolate* isolate)
{
    v8::Handle<v8::Value> currentValue(rootValue);
    ASSERT(index <= keyPathElements.size());
    for (size_t i = 0; i < index; ++i) {
        v8::Handle<v8::Value> parentValue(currentValue);
        if (!get(parentValue, keyPathElements[i], currentValue, isolate))
            return v8Undefined();
    }

    return currentValue;
}
static v8::Handle<v8::Value> clearCallback(const v8::Arguments& args)
{
    RefPtr<SVGStaticListPropertyTearOff<SVGStringList> > imp = V8SVGStringList::toNative(args.Holder());
    ExceptionCode ec = 0;
    {
    imp->clear(ec);
    if (UNLIKELY(ec))
        goto fail;
    return v8Undefined();
    }
    fail:
    return setDOMException(ec, args.GetIsolate());
}
static v8::Handle<v8::Value> acceptTransferListMethod(const v8::Arguments& args)
{
    if (args.Length() < 1)
        return throwNotEnoughArgumentsError(args.GetIsolate());
    TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterface::toNative(args.Holder());
    MessagePortArray messagePortArrayTransferList;
    ArrayBufferArray arrayBufferArrayTransferList;
    if (args.Length() > 1) {
        if (!extractTransferables(args[1], messagePortArrayTransferList, arrayBufferArrayTransferList, args.GetIsolate()))
            return throwTypeError("Could not extract transferables", args.GetIsolate());
    }
    bool dataDidThrow = false;
    RefPtr<SerializedScriptValue> data = SerializedScriptValue::create(args[0], &messagePortArrayTransferList, &arrayBufferArrayTransferList, dataDidThrow, args.GetIsolate());
    if (dataDidThrow)
        return v8Undefined();
    if (args.Length() <= 1) {
        imp->acceptTransferList(data);
        return v8Undefined();
    }
    imp->acceptTransferList(data, messagePortArrayTransferList);
    return v8Undefined();
}
static v8::Handle<v8::Value> removeRecursivelyCallback(const v8::Arguments& args)
{
    DirectoryEntrySync* imp = V8DirectoryEntrySync::toNative(args.Holder());
    ExceptionCode ec = 0;
    {
    imp->removeRecursively(ec);
    if (UNLIKELY(ec))
        goto fail;
    return v8Undefined();
    }
    fail:
    return setDOMException(ec, args.GetIsolate());
}
Ejemplo n.º 16
0
static v8::Handle<v8::Value> getNamedItems(HTMLAllCollection* collection, AtomicString name, v8::Isolate* isolate)
{
    Vector<RefPtr<Node> > namedItems;
    collection->namedItems(name, namedItems);

    if (!namedItems.size())
        return v8Undefined();

    if (namedItems.size() == 1)
        return toV8(namedItems.at(0).release(), isolate);

    return toV8(V8NamedNodesCollection::create(namedItems), isolate);
}
static v8::Handle<v8::Value> getNamedItems(HTMLFormControlsCollection* collection, const AtomicString& name, const CallbackInfo& callbackInfo)
{
    Vector<RefPtr<Node> > namedItems;
    collection->namedItems(name, namedItems);

    if (!namedItems.size())
        return v8Undefined();

    if (namedItems.size() == 1)
        return toV8(namedItems.at(0).release(), callbackInfo.Holder(), callbackInfo.GetIsolate());

    return toV8(collection->ownerNode()->radioNodeList(name).get(), callbackInfo.Holder(), callbackInfo.GetIsolate());
}
static v8::Handle<v8::Value> getNamedItems(HTMLFormControlsCollection* collection, const AtomicString& name, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
    Vector<RefPtr<Node> > namedItems;
    collection->namedItems(name, namedItems);

    if (!namedItems.size())
        return v8Undefined();

    if (namedItems.size() == 1)
        return toV8(namedItems.at(0).release(), creationContext, isolate);

    return toV8(collection->ownerNode()->radioNodeList(name).get(), creationContext, isolate);
}
static v8::Handle<v8::Value> webkitEnterFullScreenCallback(const v8::Arguments& args)
{
    HTMLVideoElement* imp = V8HTMLVideoElement::toNative(args.Holder());
    ExceptionCode ec = 0;
    {
    imp->webkitEnterFullScreen(ec);
    if (UNLIKELY(ec))
        goto fail;
    return v8Undefined();
    }
    fail:
    return setDOMException(ec, args.GetIsolate());
}
Ejemplo n.º 20
0
static v8::Handle<v8::Value> getNamedItems(HTMLFormControlsCollection* collection, const AtomicString& name, const HolderContainer& holder)
{
    Vector<RefPtr<Node> > namedItems;
    collection->namedItems(name, namedItems);

    if (!namedItems.size())
        return v8Undefined();

    if (namedItems.size() == 1)
        return toV8Fast(namedItems.at(0).release(), holder, collection);

    return toV8Fast(collection->ownerNode()->radioNodeList(name).get(), holder, collection);
}
static v8::Handle<v8::Value> endOfStreamCallback(const v8::Arguments& args)
{
    MediaSource* imp = V8MediaSource::toNative(args.Holder());
    ExceptionCode ec = 0;
    {
    V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, error, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsNullString));
    imp->endOfStream(error, ec);
    if (UNLIKELY(ec))
        goto fail;
    return v8Undefined();
    }
    fail:
    return setDOMException(ec, args.GetIsolate());
}
static v8::Handle<v8::Value> initMutationEventCallback(const v8::Arguments& args)
{
    MutationEvent* imp = V8MutationEvent::toNative(args.Holder());
    V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, type, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined));
    V8TRYCATCH(bool, canBubble, MAYBE_MISSING_PARAMETER(args, 1, DefaultIsUndefined)->BooleanValue());
    V8TRYCATCH(bool, cancelable, MAYBE_MISSING_PARAMETER(args, 2, DefaultIsUndefined)->BooleanValue());
    V8TRYCATCH(Node*, relatedNode, V8Node::HasInstance(MAYBE_MISSING_PARAMETER(args, 3, DefaultIsUndefined)) ? V8Node::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 3, DefaultIsUndefined))) : 0);
    V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, prevValue, MAYBE_MISSING_PARAMETER(args, 4, DefaultIsUndefined));
    V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, newValue, MAYBE_MISSING_PARAMETER(args, 5, DefaultIsUndefined));
    V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, attrName, MAYBE_MISSING_PARAMETER(args, 6, DefaultIsUndefined));
    V8TRYCATCH(int, attrChange, toUInt32(MAYBE_MISSING_PARAMETER(args, 7, DefaultIsUndefined)));
    imp->initMutationEvent(type, canBubble, cancelable, relatedNode, prevValue, newValue, attrName, attrChange);
    return v8Undefined();
}
Ejemplo n.º 23
0
v8::Handle<v8::Value> V8HTMLCollection::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty())
        return v8Undefined();
    if (info.Holder()->HasRealNamedCallbackProperty(name))
        return v8Undefined();

    HTMLCollection* imp = V8HTMLCollection::toNative(info.Holder());
#if ENABLE(MICRODATA)
    if (imp->type() == ItemProperties) {
        if (!static_cast<HTMLPropertiesCollection*>(imp)->hasNamedItem(toWebCoreAtomicString(name)))
            return v8Undefined();
        RefPtr<PropertyNodeList> item = static_cast<HTMLPropertiesCollection*>(imp)->propertyNodeList(toWebCoreAtomicString(name));
        if (!item)
            return v8Undefined();
        return toV8(item.release(), info.Holder(), info.GetIsolate());
    }
#endif
    Node* item = imp->namedItem(toWebCoreAtomicString(name));
    if (!item)
        return v8Undefined();
    return toV8(item, info.Holder(), info.GetIsolate());
}
static v8::Handle<v8::Value> removeRuleCallback(const v8::Arguments& args)
{
    CSSStyleSheet* imp = V8CSSStyleSheet::toNative(args.Holder());
    ExceptionCode ec = 0;
    {
    V8TRYCATCH(unsigned, index, toUInt32(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)));
    imp->removeRule(index, ec);
    if (UNLIKELY(ec))
        goto fail;
    return v8Undefined();
    }
    fail:
    return setDOMException(ec, args.GetIsolate());
}
static v8::Handle<v8::Value> deleteCellCallback(const v8::Arguments& args)
{
    HTMLTableRowElement* imp = V8HTMLTableRowElement::toNative(args.Holder());
    ExceptionCode ec = 0;
    {
    V8TRYCATCH(int, index, toInt32(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)));
    imp->deleteCell(index, ec);
    if (UNLIKELY(ec))
        goto fail;
    return v8Undefined();
    }
    fail:
    return setDOMException(ec, args.GetIsolate());
}
static v8::Local<v8::Value> getNamedItems(HTMLAllCollection* collection, AtomicString name, const CallbackInfo& info)
{
    WillBeHeapVector<RefPtrWillBeMember<Element>> namedItems;
    collection->namedItems(name, namedItems);

    if (!namedItems.size())
        return v8Undefined();

    if (namedItems.size() == 1)
        return toV8(namedItems.at(0).release(), info.Holder(), info.GetIsolate());

    // FIXME: HTML5 specification says this should be a HTMLCollection.
    // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html#htmlallcollection
    return toV8(StaticElementList::adopt(namedItems), info.Holder(), info.GetIsolate());
}
static v8::Handle<v8::Value> setStringValueCallback(const v8::Arguments& args)
{
    CSSPrimitiveValue* imp = V8CSSPrimitiveValue::toNative(args.Holder());
    ExceptionCode ec = 0;
    {
    V8TRYCATCH(int, stringType, toUInt32(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)));
    V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, stringValue, MAYBE_MISSING_PARAMETER(args, 1, DefaultIsUndefined));
    imp->setStringValue(stringType, stringValue, ec);
    if (UNLIKELY(ec))
        goto fail;
    return v8Undefined();
    }
    fail:
    return setDOMException(ec, args.GetIsolate());
}
static v8::Handle<v8::Value> parentNodeCallback(const v8::Arguments& args)
{
    TreeWalker* imp = V8TreeWalker::toNative(args.Holder());
    ScriptState* currentState = ScriptState::current();
    if (!currentState)
        return v8Undefined();
    ScriptState& state = *currentState;
    RefPtr<Node> result = imp->parentNode(&state);
    if (state.hadException()) {
        v8::Local<v8::Value> exception = state.exception();
        state.clearException();
        return throwError(exception, args.GetIsolate());
    }
    return toV8(result.release(), args.Holder(), args.GetIsolate());
}
Ejemplo n.º 29
0
static v8::Handle<v8::Value> getNamedItems(HTMLAllCollection* collection, AtomicString name, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
    Vector<RefPtr<Node> > namedItems;
    collection->namedItems(name, namedItems);

    if (!namedItems.size())
        return v8Undefined();

    if (namedItems.size() == 1)
        return toV8(namedItems.at(0).release(), creationContext, isolate);

    // FIXME: HTML5 specification says this should be a HTMLCollection.
    // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html#htmlallcollection
    return toV8(V8NamedNodesCollection::create(namedItems), creationContext, isolate);
}
Ejemplo n.º 30
0
v8::Handle<v8::Value> V8DeviceMotionEvent::initDeviceMotionEventCallback(const v8::Arguments& args)
{
    DeviceMotionEvent* imp = V8DeviceMotionEvent::toNative(args.Holder());
    V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, type, args[0]);
    bool bubbles = args[1]->BooleanValue();
    bool cancelable = args[2]->BooleanValue();
    RefPtr<DeviceMotionData::Acceleration> acceleration = readAccelerationArgument(args[3]);
    RefPtr<DeviceMotionData::Acceleration> accelerationIncludingGravity = readAccelerationArgument(args[4]);
    RefPtr<DeviceMotionData::RotationRate> rotationRate = readRotationRateArgument(args[5]);
    bool intervalProvided = !isUndefinedOrNull(args[6]);
    double interval = args[6]->NumberValue();
    RefPtr<DeviceMotionData> deviceMotionData = DeviceMotionData::create(acceleration, accelerationIncludingGravity, rotationRate, intervalProvided, interval);
    imp->initDeviceMotionEvent(type, bubbles, cancelable, deviceMotionData.get());
    return v8Undefined();
}