static void zoomAndPanAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { SVGViewElement* imp = V8SVGViewElement::toNative(info.Holder()); int v = toUInt32(value); imp->setZoomAndPan(v); return; }
static void setItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(ExceptionState::ExecutionContext, "setItem", "TestInterface2", info.Holder(), info.GetIsolate()); if (UNLIKELY(info.Length() < 2)) { setMinimumArityTypeError(exceptionState, 2, info.Length()); exceptionState.throwIfNeeded(); return; } TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); unsigned index; TestInterfaceEmpty* value; { index = toUInt32(info.GetIsolate(), info[0], NormalConversion, exceptionState); if (exceptionState.throwIfNeeded()) return; value = V8TestInterfaceEmpty::toImplWithTypeCheck(info.GetIsolate(), info[1]); if (!value) { exceptionState.throwTypeError("parameter 2 is not of type 'TestInterfaceEmpty'."); exceptionState.throwIfNeeded(); return; } } TestInterfaceEmpty* result = impl->setItem(index, value, exceptionState); if (exceptionState.hadException()) { exceptionState.throwIfNeeded(); return; } v8SetReturnValue(info, result); }
void V8PannerNode::panningModelAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { PannerNode* imp = V8PannerNode::toNative(info.Holder()); #if ENABLE(LEGACY_WEB_AUDIO) if (value->IsNumber()) { bool ok = false; uint32_t model = toUInt32(value, ok); ASSERT(ok); if (!imp->setPanningModel(model)) throwError(v8TypeError, "Illegal panningModel", info.GetIsolate()); return; } #endif if (value->IsString()) { String model = toWebCoreString(value); if (model == "equalpower" || model == "HRTF" || model == "soundfield") { imp->setPanningModel(model); return; } } throwError(v8TypeError, "Illegal panningModel", info.GetIsolate()); }
void V8PannerNode::distanceModelAttrSetterCustom(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { PannerNode* imp = V8PannerNode::toNative(info.Holder()); #if ENABLE(LEGACY_WEB_AUDIO) if (value->IsNumber()) { bool ok = false; uint32_t model = toUInt32(value, ok); ASSERT(ok); if (!imp->setDistanceModel(model)) throwError(v8TypeError, "Illegal distanceModel", info.GetIsolate()); return; } #endif if (value->IsString()) { String model = toWebCoreString(value); if (model == "linear" || model == "inverse" || model == "exponential") { imp->setDistanceModel(model); return; } } throwError(v8TypeError, "Illegal distanceModel", info.GetIsolate()); }
void V8BiquadFilterNode::typeAttributeSetterCustom(v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info) { ExceptionState exceptionState(ExceptionState::SetterContext, "type", "BiquadFilterNode", info.Holder(), info.GetIsolate()); BiquadFilterNode* impl = V8BiquadFilterNode::toNative(info.Holder()); if (value->IsNumber()) { uint32_t type = toUInt32(value, exceptionState); if (exceptionState.throwIfNeeded()) return; if (!impl->setType(type)) { exceptionState.throwTypeError("Illegal BiquadFilterNode type"); exceptionState.throwIfNeeded(); } return; } if (value->IsString()) { String type = toCoreString(value.As<v8::String>()); if (type == "lowpass" || type == "highpass" || type == "bandpass" || type == "lowshelf" || type == "highshelf" || type == "peaking" || type == "notch" || type == "allpass") { impl->setType(type); return; } } exceptionState.throwTypeError("Illegal BiquadFilterNode type"); exceptionState.throwIfNeeded(); }
void V8OscillatorNode::typeAttributeSetterCustom(v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info) { ExceptionState exceptionState(ExceptionState::SetterContext, "type", "OscillatorNode", info.Holder(), info.GetIsolate()); v8::Handle<v8::Object> holder = info.Holder(); OscillatorNode* imp = V8OscillatorNode::toNative(holder); if (value->IsNumber()) { uint32_t type = toUInt32(value, exceptionState); if (exceptionState.throwIfNeeded()) return; if (!imp->setType(type)) { exceptionState.throwTypeError("Illegal OscillatorNode type"); exceptionState.throwIfNeeded(); } return; } if (value->IsString()) { String type = toCoreString(value.As<v8::String>()); if (type == "sine" || type == "square" || type == "sawtooth" || type == "triangle") { imp->setType(type); return; } } exceptionState.throwTypeError("Illegal OscillatorNode type"); exceptionState.throwIfNeeded(); }
void V8OscillatorNode::typeAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { v8::Handle<v8::Object> holder = info.Holder(); OscillatorNode* imp = V8OscillatorNode::toNative(holder); #if ENABLE(LEGACY_WEB_AUDIO) if (value->IsNumber()) { bool ok = false; uint32_t type = toUInt32(value, ok); if (!ok || !imp->setType(type)) throwError(v8TypeError, "Illegal OscillatorNode type", info.GetIsolate()); return; } #endif if (value->IsString()) { String type = toWebCoreString(value); if (type == "sine" || type == "square" || type == "sawtooth" || type == "triangle") { imp->setType(type); return; } } throwError(v8TypeError, "Illegal OscillatorNode type", info.GetIsolate()); }
static std::unique_ptr<CryptoAlgorithmParameters> createRsaKeyGenParams(ExecState* exec, JSValue value) { if (!value.isObject()) { throwTypeError(exec); return nullptr; } auto result = std::make_unique<CryptoAlgorithmRsaKeyGenParams>(); JSValue modulusLengthValue = getProperty(exec, value.getObject(), "modulusLength"); if (exec->hadException()) return nullptr; // FIXME: Why no EnforceRange? Filed as <https://www.w3.org/Bugs/Public/show_bug.cgi?id=23779>. result->modulusLength = toUInt32(exec, modulusLengthValue, NormalConversion); if (exec->hadException()) return nullptr; JSValue publicExponentValue = getProperty(exec, value.getObject(), "publicExponent"); if (exec->hadException()) return nullptr; RefPtr<Uint8Array> publicExponentArray = toUint8Array(publicExponentValue); if (!publicExponentArray) { throwTypeError(exec, "Expected a Uint8Array in publicExponent"); return nullptr; } result->publicExponent.append(publicExponentArray->data(), publicExponentArray->byteLength()); return WTF::move(result); }
void V8PannerNode::distanceModelAttributeSetterCustom(v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info) { ExceptionState exceptionState(ExceptionState::SetterContext, "distanceModel", "PannerNode", info.Holder(), info.GetIsolate()); PannerNode* impl = V8PannerNode::toNative(info.Holder()); if (value->IsNumber()) { uint32_t model = toUInt32(value, exceptionState); if (exceptionState.throwIfNeeded()) return; if (!impl->setDistanceModel(model)) { exceptionState.throwTypeError("Illegal distanceModel"); exceptionState.throwIfNeeded(); } return; } if (value->IsString()) { String model = toCoreString(value.As<v8::String>()); if (model == "linear" || model == "inverse" || model == "exponential") { impl->setDistanceModel(model); return; } } exceptionState.throwTypeError("Illegal distanceModel"); exceptionState.throwIfNeeded(); }
static void heightAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { HTMLVideoElement* imp = V8HTMLVideoElement::toNative(info.Holder()); unsigned v = toUInt32(value); imp->setUnsignedIntegralAttribute(WebCore::HTMLNames::heightAttr, v); return; }
EncodedJSValue JSC_HOST_CALL jsSVGFilterElementPrototypeFunctionSetFilterRes(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); JSSVGFilterElement* castedThis = jsDynamicCast<JSSVGFilterElement*>(thisValue); if (!castedThis) return throwVMTypeError(exec); ASSERT_GC_OBJECT_INHERITS(castedThis, JSSVGFilterElement::info()); SVGFilterElement& impl = castedThis->impl(); unsigned filterResX(toUInt32(exec, exec->argument(0), NormalConversion)); if (exec->hadException()) return JSValue::encode(jsUndefined()); unsigned filterResY(toUInt32(exec, exec->argument(1), NormalConversion)); if (exec->hadException()) return JSValue::encode(jsUndefined()); impl.setFilterRes(filterResX, filterResY); return JSValue::encode(jsUndefined()); }
static void sortableAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { INC_STATS("DOM.HTMLDataGridColElement.sortable._set"); HTMLDataGridColElement* imp = V8HTMLDataGridColElement::toNative(info.Holder()); int v = toUInt32(value); imp->setSortable(v); return; }
static void typeAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { INC_STATS("DOM.BiquadFilterNode.type._set"); BiquadFilterNode* imp = V8BiquadFilterNode::toNative(info.Holder()); int v = toUInt32(value); imp->setType(v); return; }
static void lengthAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { INC_STATS("DOM.HTMLSelectElement.length._set"); HTMLSelectElement* imp = V8HTMLSelectElement::toNative(info.Holder()); unsigned v = toUInt32(value); ExceptionCode ec = 0; imp->setLength(v, ec); if (UNLIKELY(ec)) V8Proxy::setDOMException(ec); return; }
EncodedJSValue JSC_HOST_CALL jsDOMNamedFlowCollectionPrototypeFunctionItem(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); JSDOMNamedFlowCollection* castedThis = jsDynamicCast<JSDOMNamedFlowCollection*>(thisValue); if (!castedThis) return throwVMTypeError(exec); ASSERT_GC_OBJECT_INHERITS(castedThis, JSDOMNamedFlowCollection::info()); DOMNamedFlowCollection& impl = castedThis->impl(); if (exec->argumentCount() < 1) return throwVMError(exec, createNotEnoughArgumentsError(exec)); unsigned index(toUInt32(exec, exec->argument(0), NormalConversion)); if (exec->hadException()) return JSValue::encode(jsUndefined()); JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl.item(index))); return JSValue::encode(result); }
static void meetOrSliceAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { SVGPropertyTearOff<SVGPreserveAspectRatio>* wrapper = V8SVGPreserveAspectRatio::toNative(info.Holder()); if (wrapper->isReadOnly()) { setDOMException(NO_MODIFICATION_ALLOWED_ERR, info.GetIsolate()); return; } SVGPreserveAspectRatio& impInstance = wrapper->propertyReference(); SVGPreserveAspectRatio* imp = &impInstance; int v = toUInt32(value); ExceptionCode ec = 0; imp->setMeetOrSlice(v, ec); if (UNLIKELY(ec)) setDOMException(ec, info.GetIsolate()); if (!ec) wrapper->commitChange(); return; }
EncodedJSValue JSC_HOST_CALL jsKeyboardEventPrototypeFunctionInitKeyboardEvent(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); JSKeyboardEvent* castedThis = jsDynamicCast<JSKeyboardEvent*>(thisValue); if (!castedThis) return throwVMTypeError(exec); ASSERT_GC_OBJECT_INHERITS(castedThis, JSKeyboardEvent::info()); KeyboardEvent& impl = castedThis->impl(); const String& type(exec->argument(0).isEmpty() ? String() : exec->argument(0).toString(exec)->value(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); bool canBubble(exec->argument(1).toBoolean(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); bool cancelable(exec->argument(2).toBoolean(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); DOMWindow* view(toDOMWindow(exec->argument(3))); if (exec->hadException()) return JSValue::encode(jsUndefined()); const String& keyIdentifier(exec->argument(4).isEmpty() ? String() : exec->argument(4).toString(exec)->value(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); unsigned location(toUInt32(exec, exec->argument(5), NormalConversion)); if (exec->hadException()) return JSValue::encode(jsUndefined()); bool ctrlKey(exec->argument(6).toBoolean(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); bool altKey(exec->argument(7).toBoolean(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); bool shiftKey(exec->argument(8).toBoolean(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); bool metaKey(exec->argument(9).toBoolean(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); bool altGraphKey(exec->argument(10).toBoolean(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); impl.initKeyboardEvent(type, canBubble, cancelable, view, keyIdentifier, location, ctrlKey, altKey, shiftKey, metaKey, altGraphKey); return JSValue::encode(jsUndefined()); }
EncodedJSValue JSC_HOST_CALL jsSVGStringListPrototypeFunctionRemoveItem(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); JSSVGStringList* castedThis = jsDynamicCast<JSSVGStringList*>(thisValue); if (!castedThis) return throwVMTypeError(exec); ASSERT_GC_OBJECT_INHERITS(castedThis, JSSVGStringList::info()); SVGStaticListPropertyTearOff<SVGStringList> & impl = castedThis->impl(); if (exec->argumentCount() < 1) return throwVMError(exec, createNotEnoughArgumentsError(exec)); ExceptionCode ec = 0; unsigned index(toUInt32(exec, exec->argument(0), NormalConversion)); if (exec->hadException()) return JSValue::encode(jsUndefined()); JSC::JSValue result = jsStringWithCache(exec, impl.removeItem(index, ec)); setDOMException(exec, ec); return JSValue::encode(result); }
static void itemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionContext, "TestInterface2", "item"); TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); if (UNLIKELY(info.Length() < 1)) { exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length())); return; } unsigned index; index = toUInt32(info.GetIsolate(), info[0], NormalConversion, exceptionState); if (exceptionState.hadException()) return; TestInterfaceEmpty* result = impl->item(index, exceptionState); if (exceptionState.hadException()) { return; } v8SetReturnValue(info, result); }
static void itemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(ExceptionState::ExecutionContext, "item", "TestInterface2", info.Holder(), info.GetIsolate()); if (UNLIKELY(info.Length() < 1)) { setMinimumArityTypeError(exceptionState, 1, info.Length()); exceptionState.throwIfNeeded(); return; } TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); unsigned index; { index = toUInt32(info.GetIsolate(), info[0], NormalConversion, exceptionState); if (exceptionState.throwIfNeeded()) return; } TestInterfaceEmpty* result = impl->item(index, exceptionState); if (exceptionState.hadException()) { exceptionState.throwIfNeeded(); return; } v8SetReturnValue(info, result); }
void V8BiquadFilterNode::typeAttributeSetterCustom(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info) { BiquadFilterNode* imp = V8BiquadFilterNode::toNative(info.Holder()); if (value->IsNumber()) { bool ok = false; uint32_t type = toUInt32(value, ok); ASSERT(ok); if (!imp->setType(type)) throwTypeError("Illegal BiquadFilterNode type", info.GetIsolate()); return; } if (value->IsString()) { String type = toWebCoreString(value); if (type == "lowpass" || type == "highpass" || type == "bandpass" || type == "lowshelf" || type == "highshelf" || type == "peaking" || type == "notch" || type == "allpass") { imp->setType(type); return; } } throwTypeError("Illegal BiquadFilterNode type", info.GetIsolate()); }
uint32_t toUInt32(v8::Handle<v8::Value> value) { NonThrowableExceptionState exceptionState; return toUInt32(value, NormalConversion, exceptionState); }
static inline uint32_t toIntegral(v8::Isolate* isolate, v8::Local<v8::Value> value, IntegerConversionConfiguration configuration, ExceptionState& exceptionState) { return toUInt32(isolate, value, configuration, exceptionState); }
static inline uint32_t toIntegral(v8::Handle<v8::Value> value, IntegerConversionConfiguration configuration, ExceptionState& exceptionState) { return toUInt32(value, configuration, exceptionState); }