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> createSVGPathSegCurvetoQuadraticSmoothRelCallback(const v8::Arguments& args) { SVGPathElement* imp = V8SVGPathElement::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())); return toV8Fast(imp->createSVGPathSegCurvetoQuadraticSmoothRel(x, y), args, imp); }
v8::Handle<v8::Value> V8TrackEvent::trackAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { TrackEvent* trackEvent = V8TrackEvent::toNative(info.Holder()); TrackBase* track = trackEvent->track(); if (!track) return v8Null(info.GetIsolate()); switch (track->type()) { case TrackBase::BaseTrack: // This should never happen. ASSERT_NOT_REACHED(); break; case TrackBase::TextTrack: return toV8Fast(static_cast<TextTrack*>(track), info, trackEvent); break; case TrackBase::AudioTrack: case TrackBase::VideoTrack: // This should not happen until VideoTrack and AudioTrack are implemented. ASSERT_NOT_REACHED(); break; } return v8Null(info.GetIsolate()); }
static void getNamedItems(HTMLOptionsCollection* collection, const AtomicString& name, const HolderContainer& holder) { Vector<RefPtr<Node> > namedItems; collection->namedItems(name, namedItems); if (!namedItems.size()) { v8SetReturnValueNull(holder); return; } if (namedItems.size() == 1) { v8SetReturnValue(holder, toV8Fast(namedItems.at(0).release(), holder, collection)); return; } v8SetReturnValue(holder, toV8Fast(NamedNodesCollection::create(namedItems), holder, collection)); }
v8::Handle<v8::Value> V8HTMLSelectElement::indexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info) { ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder())); HTMLSelectElement* select = V8HTMLSelectElement::toNative(info.Holder()); RefPtr<Node> result = select->item(index); if (!result) return v8Undefined(); return toV8Fast(result.release(), info, select); }
v8::Handle<v8::Value> V8MessageEvent::dataAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { MessageEvent* event = V8MessageEvent::toNative(info.Holder()); v8::Handle<v8::Value> result; switch (event->dataType()) { case MessageEvent::DataTypeScriptValue: { ScriptValue scriptValue = event->dataAsScriptValue(); if (scriptValue.hasNoValue()) result = v8Null(info.GetIsolate()); else result = v8::Local<v8::Value>::New(scriptValue.v8Value()); break; } case MessageEvent::DataTypeSerializedScriptValue: if (RefPtr<SerializedScriptValue> serializedValue = event->dataAsSerializedScriptValue()) result = serializedValue->deserialize(info.GetIsolate(), event->ports()); else result = v8Null(info.GetIsolate()); break; case MessageEvent::DataTypeString: { String stringValue = event->dataAsString(); result = v8String(stringValue, info.GetIsolate()); break; } case MessageEvent::DataTypeBlob: result = toV8Fast(event->dataAsBlob(), info, event); break; case MessageEvent::DataTypeArrayBuffer: result = toV8Fast(event->dataAsArrayBuffer(), info, event); break; } // Overwrite the data attribute so it returns the cached result in future invocations. // This custom handler (dataAccessGetter) will not be called again. v8::PropertyAttribute dataAttr = static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::ReadOnly); info.Holder()->ForceSet(name, result, dataAttr); return result; }
static v8::Handle<v8::Value> createSVGPathSegCurvetoCubicAbsCallback(const v8::Arguments& args) { SVGPathElement* imp = V8SVGPathElement::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, x1, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 2, DefaultIsUndefined)->NumberValue())); V8TRYCATCH(float, y1, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 3, DefaultIsUndefined)->NumberValue())); V8TRYCATCH(float, x2, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 4, DefaultIsUndefined)->NumberValue())); V8TRYCATCH(float, y2, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 5, DefaultIsUndefined)->NumberValue())); return toV8Fast(imp->createSVGPathSegCurvetoCubicAbs(x, y, x1, y1, x2, y2), args, imp); }
void V8Document::locationAttrGetterCustom(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) { Document* document = V8Document::toNative(info.Holder()); if (!document->frame()) { v8SetReturnValueNull(info); return; } DOMWindow* window = document->domWindow(); v8SetReturnValue(info, toV8Fast(window->location(), info, document)); }
void V8Window::namedPropertyGetterCustom(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) { DOMWindow* window = V8Window::toNative(info.Holder()); if (!window) return; Frame* frame = window->frame(); // window is detached from a frame. if (!frame) return; // Search sub-frames. AtomicString propName = toWebCoreAtomicString(name); Frame* child = frame->tree()->scopedChild(propName); if (child) { v8SetReturnValue(info, toV8Fast(child->domWindow(), info, window)); return; } // Search IDL functions defined in the prototype if (!info.Holder()->GetRealNamedProperty(name).IsEmpty()) return; // Search named items in the document. Document* doc = frame->document(); if (doc && doc->isHTMLDocument()) { if (toHTMLDocument(doc)->hasNamedItem(propName.impl()) || doc->hasElementWithId(propName.impl())) { RefPtr<HTMLCollection> items = doc->windowNamedItems(propName); if (!items->isEmpty()) { if (items->hasExactlyOneItem()) { v8SetReturnValue(info, toV8Fast(items->item(0), info, window)); return; } v8SetReturnValue(info, toV8Fast(items.release(), info, window)); return; } } } }
static v8::Handle<v8::Value> createSVGPathSegArcRelCallback(const v8::Arguments& args) { SVGPathElement* imp = V8SVGPathElement::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, r1, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 2, DefaultIsUndefined)->NumberValue())); V8TRYCATCH(float, r2, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 3, DefaultIsUndefined)->NumberValue())); V8TRYCATCH(float, angle, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 4, DefaultIsUndefined)->NumberValue())); V8TRYCATCH(bool, largeArcFlag, MAYBE_MISSING_PARAMETER(args, 5, DefaultIsUndefined)->BooleanValue()); V8TRYCATCH(bool, sweepFlag, MAYBE_MISSING_PARAMETER(args, 6, DefaultIsUndefined)->BooleanValue()); return toV8Fast(imp->createSVGPathSegArcRel(x, y, r1, r2, angle, largeArcFlag, sweepFlag), args, imp); }
static v8::Handle<v8::Value> portsAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterface::toNative(info.Holder()); MessagePortArray* ports = imp->ports(); if (!ports) return v8::Array::New(0); MessagePortArray portsCopy(*ports); v8::Local<v8::Array> portArray = v8::Array::New(portsCopy.size()); for (size_t i = 0; i < portsCopy.size(); ++i) portArray->Set(v8Integer(i, info.GetIsolate()), toV8Fast(portsCopy[i].get(), info, imp)); return portArray; }
v8::Handle<v8::Value> V8XMLHttpRequest::responseAttrGetterCustom(v8::Local<v8::String> name, const v8::AccessorInfo& info) { XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder()); switch (xmlHttpRequest->responseTypeCode()) { case XMLHttpRequest::ResponseTypeDefault: case XMLHttpRequest::ResponseTypeText: return responseTextAttrGetterCustom(name, info); case XMLHttpRequest::ResponseTypeDocument: { ExceptionCode ec = 0; Document* document = xmlHttpRequest->responseXML(ec); if (ec) return setDOMException(ec, info.GetIsolate()); return toV8Fast(document, info, xmlHttpRequest); } case XMLHttpRequest::ResponseTypeBlob: { ExceptionCode ec = 0; Blob* blob = xmlHttpRequest->responseBlob(ec); if (ec) return setDOMException(ec, info.GetIsolate()); return toV8Fast(blob, info, xmlHttpRequest); } case XMLHttpRequest::ResponseTypeArrayBuffer: { ExceptionCode ec = 0; ArrayBuffer* arrayBuffer = xmlHttpRequest->responseArrayBuffer(ec); if (ec) return setDOMException(ec, info.GetIsolate()); return toV8Fast(arrayBuffer, info, xmlHttpRequest); } } return v8::Undefined(); }
static v8::Handle<v8::Value> getTransformToElementCallback(const v8::Arguments& args) { SVGSwitchElement* imp = V8SVGSwitchElement::toNative(args.Holder()); ExceptionCode ec = 0; { V8TRYCATCH(SVGElement*, element, V8SVGElement::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)) ? V8SVGElement::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))) : 0); SVGMatrix result = imp->getTransformToElement(element, ec); if (UNLIKELY(ec)) goto fail; return toV8Fast(WTF::getPtr(SVGPropertyTearOff<SVGMatrix>::create(result)), args, imp); } fail: return setDOMException(ec, args.GetIsolate()); }
static v8::Handle<v8::Value> insertCellCallback(const v8::Arguments& args) { HTMLTableRowElement* imp = V8HTMLTableRowElement::toNative(args.Holder()); ExceptionCode ec = 0; { V8TRYCATCH(int, index, toInt32(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))); RefPtr<HTMLElement> result = imp->insertCell(index, ec); if (UNLIKELY(ec)) goto fail; return toV8Fast(result.release(), args, imp); } fail: return setDOMException(ec, args.GetIsolate()); }
v8::Handle<v8::Value> V8MessageEvent::portsAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { MessageEvent* event = V8MessageEvent::toNative(info.Holder()); MessagePortArray* ports = event->ports(); if (!ports) return v8::Array::New(0); MessagePortArray portsCopy(*ports); v8::Local<v8::Array> portArray = v8::Array::New(portsCopy.size()); for (size_t i = 0; i < portsCopy.size(); ++i) portArray->Set(v8Integer(i, info.GetIsolate()), toV8Fast(portsCopy[i].get(), info, event)); return portArray; }
void V8Window::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args) { DOMWindow* impl = V8Window::toNative(args.Holder()); if (!BindingSecurity::shouldAllowAccessToFrame(impl->frame())) return; // FIXME: Handle exceptions properly. String urlString = toWebCoreStringWithUndefinedOrNullCheck(args[0]); AtomicString frameName = (args[1]->IsUndefined() || args[1]->IsNull()) ? "_blank" : AtomicString(toWebCoreString(args[1])); String windowFeaturesString = toWebCoreStringWithUndefinedOrNullCheck(args[2]); RefPtr<DOMWindow> openedWindow = impl->open(urlString, frameName, windowFeaturesString, activeDOMWindow(), firstDOMWindow()); if (!openedWindow) return; v8SetReturnValue(args, toV8Fast(openedWindow.release(), args, impl)); }
v8::Handle<v8::Value> V8Document::evaluateMethodCustom(const v8::Arguments& args) { RefPtr<Document> document = V8Document::toNative(args.Holder()); ExceptionCode ec = 0; String expression = toWebCoreString(args[0]); RefPtr<Node> contextNode; if (V8Node::HasInstance(args[1], args.GetIsolate(), worldType(args.GetIsolate()))) contextNode = V8Node::toNative(v8::Handle<v8::Object>::Cast(args[1])); RefPtr<XPathNSResolver> resolver = toXPathNSResolver(args[2], args.GetIsolate()); if (!resolver && !args[2]->IsNull() && !args[2]->IsUndefined()) return setDOMException(TYPE_MISMATCH_ERR, args.GetIsolate()); int type = toInt32(args[3]); RefPtr<XPathResult> inResult; if (V8XPathResult::HasInstance(args[4], args.GetIsolate(), worldType(args.GetIsolate()))) inResult = V8XPathResult::toNative(v8::Handle<v8::Object>::Cast(args[4])); V8TRYCATCH(RefPtr<XPathResult>, result, document->evaluate(expression, contextNode.get(), resolver.get(), type, inResult.get(), ec)); if (ec) return setDOMException(ec, args.GetIsolate()); return toV8Fast(result.release(), args, document.get()); }
static v8::Handle<v8::Value> getScreenCTMCallback(const v8::Arguments& args) { SVGSwitchElement* imp = V8SVGSwitchElement::toNative(args.Holder()); return toV8Fast(WTF::getPtr(SVGPropertyTearOff<SVGMatrix>::create(imp->getScreenCTM())), args, imp); }
static v8::Handle<v8::Value> getPresentationAttributeCallback(const v8::Arguments& args) { SVGSwitchElement* imp = V8SVGSwitchElement::toNative(args.Holder()); V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, name, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)); return toV8Fast(imp->getPresentationAttribute(name), args, imp); }
static v8::Handle<v8::Value> farthestViewportElementAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { SVGSwitchElement* imp = V8SVGSwitchElement::toNative(info.Holder()); return toV8Fast(imp->farthestViewportElement(), info, imp); }
static v8::Handle<v8::Value> transformAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { SVGSwitchElement* imp = V8SVGSwitchElement::toNative(info.Holder()); return toV8Fast(imp->transformAnimated(), info, imp); }
static v8::Handle<v8::Value> animatedPointsAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { SVGPolylineElement* imp = V8SVGPolylineElement::toNative(info.Holder()); return toV8Fast(WTF::getPtr(imp->animatedPoints()), info, imp); }
static v8::Handle<v8::Value> getBBoxCallback(const v8::Arguments& args) { SVGPolylineElement* imp = V8SVGPolylineElement::toNative(args.Holder()); return toV8Fast(WTF::getPtr(SVGPropertyTearOff<FloatRect>::create(imp->getBBox())), args, imp); }
static v8::Handle<v8::Value> styleAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { SVGPolylineElement* imp = V8SVGPolylineElement::toNative(info.Holder()); return toV8Fast(imp->style(), info, imp); }
static v8::Handle<v8::Value> externalResourcesRequiredAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { SVGPolylineElement* imp = V8SVGPolylineElement::toNative(info.Holder()); return toV8Fast(imp->externalResourcesRequiredAnimated(), info, imp); }
static v8::Handle<v8::Value> relatedNodeAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { MutationEvent* imp = V8MutationEvent::toNative(info.Holder()); return toV8Fast(imp->relatedNode(), info, imp); }
static v8::Handle<v8::Value> limitingConeAngleAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { SVGFESpotLightElement* imp = V8SVGFESpotLightElement::toNative(info.Holder()); return toV8Fast(imp->limitingConeAngleAnimated(), info, imp); }
static v8::Handle<v8::Value> systemLanguageAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { SVGSwitchElement* imp = V8SVGSwitchElement::toNative(info.Holder()); return toV8Fast(WTF::getPtr(SVGStaticListPropertyTearOff<SVGStringList>::create(imp, imp->systemLanguage())), info, imp); }
static v8::Handle<v8::Value> classNameAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { SVGFEFloodElement* imp = V8SVGFEFloodElement::toNative(info.Holder()); return toV8Fast(imp->classNameAnimated(), info, imp); }
static v8::Handle<v8::Value> requiredExtensionsAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { SVGPolylineElement* imp = V8SVGPolylineElement::toNative(info.Holder()); return toV8Fast(WTF::getPtr(SVGStaticListPropertyTearOff<SVGStringList>::create(imp, imp->requiredExtensions())), info, imp); }