diff options
Diffstat (limited to 'WebCore/bindings/v8/custom')
71 files changed, 2026 insertions, 833 deletions
diff --git a/WebCore/bindings/v8/custom/V8AbstractWorkerCustom.cpp b/WebCore/bindings/v8/custom/V8AbstractWorkerCustom.cpp new file mode 100644 index 0000000..ce759eb --- /dev/null +++ b/WebCore/bindings/v8/custom/V8AbstractWorkerCustom.cpp @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#if ENABLE(WORKERS) + +#include "AbstractWorker.h" + +#include "ExceptionCode.h" +#include "ScriptExecutionContext.h" +#include "V8Binding.h" +#include "V8CustomBinding.h" +#include "V8ObjectEventListener.h" +#include "V8Proxy.h" +#include "V8Utilities.h" +#include "WorkerContextExecutionProxy.h" + +namespace WebCore { + +PassRefPtr<EventListener> getEventListener(AbstractWorker* worker, v8::Local<v8::Value> value, bool isAttribute, bool findOnly) +{ + if (worker->scriptExecutionContext()->isWorkerContext()) { + WorkerContextExecutionProxy* workerContextProxy = WorkerContextExecutionProxy::retrieve(); + ASSERT(workerContextProxy); + return workerContextProxy->findOrCreateObjectEventListener(value, isAttribute, findOnly); + } + + V8Proxy* proxy = V8Proxy::retrieve(worker->scriptExecutionContext()); + if (proxy) { + V8EventListenerList* list = proxy->objectListeners(); + return findOnly ? list->findWrapper(value, isAttribute) : list->findOrCreateWrapper<V8ObjectEventListener>(proxy->frame(), value, isAttribute); + } + + return 0; +} + +ACCESSOR_GETTER(AbstractWorkerOnerror) +{ + INC_STATS(L"DOM.AbstractWorker.onerror._get"); + AbstractWorker* worker = V8DOMWrapper::convertToNativeObject<AbstractWorker>(V8ClassIndex::ABSTRACTWORKER, info.Holder()); + if (worker->onerror()) { + V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(worker->onerror()); + v8::Local<v8::Object> v8Listener = listener->getListenerObject(); + return v8Listener; + } + return v8::Undefined(); +} + +ACCESSOR_SETTER(AbstractWorkerOnerror) +{ + INC_STATS(L"DOM.AbstractWorker.onerror._set"); + AbstractWorker* worker = V8DOMWrapper::convertToNativeObject<AbstractWorker>(V8ClassIndex::ABSTRACTWORKER, info.Holder()); + V8ObjectEventListener* oldListener = static_cast<V8ObjectEventListener*>(worker->onerror()); + if (value->IsNull()) { + if (oldListener) { + v8::Local<v8::Object> oldV8Listener = oldListener->getListenerObject(); + removeHiddenDependency(info.Holder(), oldV8Listener, V8Custom::kAbstractWorkerRequestCacheIndex); + } + + // Clear the listener. + worker->setOnerror(0); + } else { + RefPtr<EventListener> listener = getEventListener(worker, value, true, false); + if (listener) { + if (oldListener) { + v8::Local<v8::Object> oldV8Listener = oldListener->getListenerObject(); + removeHiddenDependency(info.Holder(), oldV8Listener, V8Custom::kAbstractWorkerRequestCacheIndex); + } + + worker->setOnerror(listener); + createHiddenDependency(info.Holder(), value, V8Custom::kAbstractWorkerRequestCacheIndex); + } + } +} + +CALLBACK_FUNC_DECL(AbstractWorkerAddEventListener) +{ + INC_STATS(L"DOM.AbstractWorker.addEventListener()"); + AbstractWorker* worker = V8DOMWrapper::convertToNativeObject<AbstractWorker>(V8ClassIndex::ABSTRACTWORKER, args.Holder()); + + RefPtr<EventListener> listener = getEventListener(worker, args[1], false, false); + if (listener) { + String type = toWebCoreString(args[0]); + bool useCapture = args[2]->BooleanValue(); + worker->addEventListener(type, listener, useCapture); + + createHiddenDependency(args.Holder(), args[1], V8Custom::kAbstractWorkerRequestCacheIndex); + } + return v8::Undefined(); +} + +CALLBACK_FUNC_DECL(AbstractWorkerRemoveEventListener) +{ + INC_STATS(L"DOM.AbstractWorker.removeEventListener()"); + AbstractWorker* worker = V8DOMWrapper::convertToNativeObject<AbstractWorker>(V8ClassIndex::ABSTRACTWORKER, args.Holder()); + + RefPtr<EventListener> listener = getEventListener(worker, args[1], false, true); + if (listener) { + String type = toWebCoreString(args[0]); + bool useCapture = args[2]->BooleanValue(); + worker->removeEventListener(type, listener.get(), useCapture); + + removeHiddenDependency(args.Holder(), args[1], V8Custom::kAbstractWorkerRequestCacheIndex); + } + + return v8::Undefined(); +} + +} // namespace WebCore + +#endif // ENABLE(WORKERS) diff --git a/WebCore/bindings/v8/custom/V8AttrCustom.cpp b/WebCore/bindings/v8/custom/V8AttrCustom.cpp index f34a441..81f1586 100644 --- a/WebCore/bindings/v8/custom/V8AttrCustom.cpp +++ b/WebCore/bindings/v8/custom/V8AttrCustom.cpp @@ -42,7 +42,7 @@ namespace WebCore { ACCESSOR_SETTER(AttrValue) { - Attr* imp = V8Proxy::DOMWrapperToNode<Attr>(info.Holder()); + Attr* imp = V8DOMWrapper::convertDOMWrapperToNode<Attr>(info.Holder()); String attrValue = toWebCoreStringWithNullCheck(value); Element* ownerElement = imp->ownerElement(); diff --git a/WebCore/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp b/WebCore/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp index 1ad0e7a..6bd0035 100644 --- a/WebCore/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp +++ b/WebCore/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp @@ -161,7 +161,7 @@ NAMED_PROPERTY_GETTER(CSSStyleDeclaration) // Search the style declaration. CSSStyleDeclaration* imp = - V8Proxy::ToNativeObject<CSSStyleDeclaration>(V8ClassIndex::CSSSTYLEDECLARATION, info.Holder()); + V8DOMWrapper::convertToNativeObject<CSSStyleDeclaration>(V8ClassIndex::CSSSTYLEDECLARATION, info.Holder()); CSSPropertyInfo* propInfo = cssPropertyInfo(name); // Do not handle non-property names. @@ -195,13 +195,13 @@ NAMED_PROPERTY_SETTER(CSSStyleDeclaration) { INC_STATS("DOM.CSSStyleDeclaration.NamedPropertySetter"); CSSStyleDeclaration* imp = - V8Proxy::ToNativeObject<CSSStyleDeclaration>( + V8DOMWrapper::convertToNativeObject<CSSStyleDeclaration>( V8ClassIndex::CSSSTYLEDECLARATION, info.Holder()); CSSPropertyInfo* propInfo = cssPropertyInfo(name); if (!propInfo) return notHandledByInterceptor(); - String propertyValue = valueToStringWithNullCheck(value); + String propertyValue = toWebCoreStringWithNullCheck(value); if (propInfo->hadPixelOrPosPrefix) propertyValue.append("px"); diff --git a/WebCore/bindings/v8/custom/V8CanvasPixelArrayCustom.cpp b/WebCore/bindings/v8/custom/V8CanvasPixelArrayCustom.cpp index 28f6b59..5fe2710 100644 --- a/WebCore/bindings/v8/custom/V8CanvasPixelArrayCustom.cpp +++ b/WebCore/bindings/v8/custom/V8CanvasPixelArrayCustom.cpp @@ -41,7 +41,7 @@ namespace WebCore { INDEXED_PROPERTY_GETTER(CanvasPixelArray) { INC_STATS("DOM.CanvasPixelArray.IndexedPropertyGetter"); - CanvasPixelArray* pixelBuffer = V8Proxy::ToNativeObject<CanvasPixelArray>(V8ClassIndex::CANVASPIXELARRAY, info.Holder()); + CanvasPixelArray* pixelBuffer = V8DOMWrapper::convertToNativeObject<CanvasPixelArray>(V8ClassIndex::CANVASPIXELARRAY, info.Holder()); if ((index < 0) || (index >= pixelBuffer->length())) return v8::Undefined(); @@ -55,7 +55,7 @@ INDEXED_PROPERTY_GETTER(CanvasPixelArray) INDEXED_PROPERTY_SETTER(CanvasPixelArray) { INC_STATS("DOM.CanvasPixelArray.IndexedPropertySetter"); - CanvasPixelArray* pixelBuffer = V8Proxy::ToNativeObject<CanvasPixelArray>(V8ClassIndex::CANVASPIXELARRAY, info.Holder()); + CanvasPixelArray* pixelBuffer = V8DOMWrapper::convertToNativeObject<CanvasPixelArray>(V8ClassIndex::CANVASPIXELARRAY, info.Holder()); if ((index >= 0) && (index < pixelBuffer->length())) pixelBuffer->set(index, value->NumberValue()); diff --git a/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp b/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp index 26086ab..676610c 100644 --- a/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp +++ b/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp @@ -43,6 +43,7 @@ #include "V8CustomBinding.h" #include "V8HTMLCanvasElement.h" #include "V8HTMLImageElement.h" +#include "V8HTMLVideoElement.h" #include "V8Proxy.h" namespace WebCore { @@ -50,10 +51,10 @@ namespace WebCore { static v8::Handle<v8::Value> toV8(CanvasStyle* style) { if (style->canvasGradient()) - return V8Proxy::ToV8Object(V8ClassIndex::CANVASGRADIENT, style->canvasGradient()); + return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASGRADIENT, style->canvasGradient()); if (style->canvasPattern()) - return V8Proxy::ToV8Object(V8ClassIndex::CANVASPATTERN, style->canvasPattern()); + return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASPATTERN, style->canvasPattern()); return v8String(style->color()); } @@ -64,35 +65,35 @@ static PassRefPtr<CanvasStyle> toCanvasStyle(v8::Handle<v8::Value> value) return CanvasStyle::create(toWebCoreString(value)); if (V8CanvasGradient::HasInstance(value)) - return CanvasStyle::create(V8Proxy::DOMWrapperToNative<CanvasGradient>(value)); + return CanvasStyle::create(V8DOMWrapper::convertDOMWrapperToNative<CanvasGradient>(v8::Handle<v8::Object>::Cast(value))); if (V8CanvasPattern::HasInstance(value)) - return CanvasStyle::create(V8Proxy::DOMWrapperToNative<CanvasPattern>(value)); + return CanvasStyle::create(V8DOMWrapper::convertDOMWrapperToNative<CanvasPattern>(v8::Handle<v8::Object>::Cast(value))); return 0; } ACCESSOR_GETTER(CanvasRenderingContext2DStrokeStyle) { - CanvasRenderingContext2D* impl = V8Proxy::DOMWrapperToNative<CanvasRenderingContext2D>(info.Holder()); + CanvasRenderingContext2D* impl = V8DOMWrapper::convertDOMWrapperToNative<CanvasRenderingContext2D>(info.Holder()); return toV8(impl->strokeStyle()); } ACCESSOR_SETTER(CanvasRenderingContext2DStrokeStyle) { - CanvasRenderingContext2D* impl = V8Proxy::DOMWrapperToNative<CanvasRenderingContext2D>(info.Holder()); + CanvasRenderingContext2D* impl = V8DOMWrapper::convertDOMWrapperToNative<CanvasRenderingContext2D>(info.Holder()); impl->setStrokeStyle(toCanvasStyle(value)); } ACCESSOR_GETTER(CanvasRenderingContext2DFillStyle) { - CanvasRenderingContext2D* impl = V8Proxy::DOMWrapperToNative<CanvasRenderingContext2D>(info.Holder()); + CanvasRenderingContext2D* impl = V8DOMWrapper::convertDOMWrapperToNative<CanvasRenderingContext2D>(info.Holder()); return toV8(impl->fillStyle()); } ACCESSOR_SETTER(CanvasRenderingContext2DFillStyle) { - CanvasRenderingContext2D* impl = V8Proxy::DOMWrapperToNative<CanvasRenderingContext2D>(info.Holder()); + CanvasRenderingContext2D* impl = V8DOMWrapper::convertDOMWrapperToNative<CanvasRenderingContext2D>(info.Holder()); impl->setFillStyle(toCanvasStyle(value)); } @@ -101,17 +102,17 @@ ACCESSOR_SETTER(CanvasRenderingContext2DFillStyle) CALLBACK_FUNC_DECL(CanvasRenderingContext2DSetStrokeColor) { INC_STATS("DOM.CanvasRenderingContext2D.setStrokeColor()"); - CanvasRenderingContext2D* context = V8Proxy::ToNativeObject<CanvasRenderingContext2D>(V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); + CanvasRenderingContext2D* context = V8DOMWrapper::convertToNativeObject<CanvasRenderingContext2D>(V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); switch (args.Length()) { case 1: if (args[0]->IsString()) - context->setStrokeColor(ToWebCoreString(args[0])); + context->setStrokeColor(toWebCoreString(args[0])); else context->setStrokeColor(toFloat(args[0])); break; case 2: if (args[0]->IsString()) - context->setStrokeColor(ToWebCoreString(args[0]), toFloat(args[1])); + context->setStrokeColor(toWebCoreString(args[0]), toFloat(args[1])); else context->setStrokeColor(toFloat(args[0]), toFloat(args[1])); break; @@ -122,7 +123,7 @@ CALLBACK_FUNC_DECL(CanvasRenderingContext2DSetStrokeColor) context->setStrokeColor(toFloat(args[0]), toFloat(args[1]), toFloat(args[2]), toFloat(args[3]), toFloat(args[4])); break; default: - V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "setStrokeColor: Invalid number of arguments"); + V8Proxy::throwError(V8Proxy::SyntaxError, "setStrokeColor: Invalid number of arguments"); break; } return v8::Undefined(); @@ -131,17 +132,17 @@ CALLBACK_FUNC_DECL(CanvasRenderingContext2DSetStrokeColor) CALLBACK_FUNC_DECL(CanvasRenderingContext2DSetFillColor) { INC_STATS("DOM.CanvasRenderingContext2D.setFillColor()"); - CanvasRenderingContext2D* context = V8Proxy::ToNativeObject<CanvasRenderingContext2D>(V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); + CanvasRenderingContext2D* context = V8DOMWrapper::convertToNativeObject<CanvasRenderingContext2D>(V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); switch (args.Length()) { case 1: if (args[0]->IsString()) - context->setFillColor(ToWebCoreString(args[0])); + context->setFillColor(toWebCoreString(args[0])); else context->setFillColor(toFloat(args[0])); break; case 2: if (args[0]->IsString()) - context->setFillColor(ToWebCoreString(args[0]), toFloat(args[1])); + context->setFillColor(toWebCoreString(args[0]), toFloat(args[1])); else context->setFillColor(toFloat(args[0]), toFloat(args[1])); break; @@ -152,7 +153,7 @@ CALLBACK_FUNC_DECL(CanvasRenderingContext2DSetFillColor) context->setFillColor(toFloat(args[0]), toFloat(args[1]), toFloat(args[2]), toFloat(args[3]), toFloat(args[4])); break; default: - V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "setFillColor: Invalid number of arguments"); + V8Proxy::throwError(V8Proxy::SyntaxError, "setFillColor: Invalid number of arguments"); break; } return v8::Undefined(); @@ -161,13 +162,13 @@ CALLBACK_FUNC_DECL(CanvasRenderingContext2DSetFillColor) CALLBACK_FUNC_DECL(CanvasRenderingContext2DStrokeRect) { INC_STATS("DOM.CanvasRenderingContext2D.strokeRect()"); - CanvasRenderingContext2D* context = V8Proxy::ToNativeObject<CanvasRenderingContext2D>(V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); + CanvasRenderingContext2D* context = V8DOMWrapper::convertToNativeObject<CanvasRenderingContext2D>(V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); if (args.Length() == 5) context->strokeRect(toFloat(args[0]), toFloat(args[1]), toFloat(args[2]), toFloat(args[3]), toFloat(args[4])); else if (args.Length() == 4) context->strokeRect(toFloat(args[0]), toFloat(args[1]), toFloat(args[2]), toFloat(args[3])); else { - V8Proxy::SetDOMException(INDEX_SIZE_ERR); + V8Proxy::setDOMException(INDEX_SIZE_ERR); return notHandledByInterceptor(); } return v8::Undefined(); @@ -176,7 +177,7 @@ CALLBACK_FUNC_DECL(CanvasRenderingContext2DStrokeRect) CALLBACK_FUNC_DECL(CanvasRenderingContext2DSetShadow) { INC_STATS("DOM.CanvasRenderingContext2D.setShadow()"); - CanvasRenderingContext2D* context = V8Proxy::ToNativeObject<CanvasRenderingContext2D>(V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); + CanvasRenderingContext2D* context = V8DOMWrapper::convertToNativeObject<CanvasRenderingContext2D>(V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); switch (args.Length()) { case 3: @@ -184,13 +185,13 @@ CALLBACK_FUNC_DECL(CanvasRenderingContext2DSetShadow) break; case 4: if (args[3]->IsString()) - context->setShadow(toFloat(args[0]), toFloat(args[1]), toFloat(args[2]), ToWebCoreString(args[3])); + context->setShadow(toFloat(args[0]), toFloat(args[1]), toFloat(args[2]), toWebCoreString(args[3])); else context->setShadow(toFloat(args[0]), toFloat(args[1]), toFloat(args[2]), toFloat(args[3])); break; case 5: if (args[3]->IsString()) - context->setShadow(toFloat(args[0]), toFloat(args[1]), toFloat(args[2]), ToWebCoreString(args[3]), toFloat(args[4])); + context->setShadow(toFloat(args[0]), toFloat(args[1]), toFloat(args[2]), toWebCoreString(args[3]), toFloat(args[4])); else context->setShadow(toFloat(args[0]), toFloat(args[1]), toFloat(args[2]), toFloat(args[3]), toFloat(args[4])); break; @@ -201,7 +202,7 @@ CALLBACK_FUNC_DECL(CanvasRenderingContext2DSetShadow) context->setShadow(toFloat(args[0]), toFloat(args[1]), toFloat(args[2]), toFloat(args[3]), toFloat(args[4]), toFloat(args[5]), toFloat(args[6]), toFloat(args[7])); break; default: - V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "setShadow: Invalid number of arguments"); + V8Proxy::throwError(V8Proxy::SyntaxError, "setShadow: Invalid number of arguments"); break; } @@ -211,13 +212,13 @@ CALLBACK_FUNC_DECL(CanvasRenderingContext2DSetShadow) CALLBACK_FUNC_DECL(CanvasRenderingContext2DDrawImage) { INC_STATS("DOM.CanvasRenderingContext2D.drawImage()"); - CanvasRenderingContext2D* context = V8Proxy::ToNativeObject<CanvasRenderingContext2D>(V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); + CanvasRenderingContext2D* context = V8DOMWrapper::convertToNativeObject<CanvasRenderingContext2D>(V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); v8::Handle<v8::Value> arg = args[0]; if (V8HTMLImageElement::HasInstance(arg)) { ExceptionCode ec = 0; - HTMLImageElement* image_element = V8Proxy::DOMWrapperToNode<HTMLImageElement>(arg); + HTMLImageElement* image_element = V8DOMWrapper::convertDOMWrapperToNode<HTMLImageElement>(v8::Handle<v8::Object>::Cast(arg)); switch (args.Length()) { case 3: context->drawImage(image_element, toFloat(args[1]), toFloat(args[2])); @@ -225,7 +226,7 @@ CALLBACK_FUNC_DECL(CanvasRenderingContext2DDrawImage) case 5: context->drawImage(image_element, toFloat(args[1]), toFloat(args[2]), toFloat(args[3]), toFloat(args[4]), ec); if (ec != 0) { - V8Proxy::SetDOMException(ec); + V8Proxy::setDOMException(ec); return notHandledByInterceptor(); } break; @@ -235,13 +236,12 @@ CALLBACK_FUNC_DECL(CanvasRenderingContext2DDrawImage) FloatRect(toFloat(args[5]), toFloat(args[6]), toFloat(args[7]), toFloat(args[8])), ec); if (ec != 0) { - V8Proxy::SetDOMException(ec); + V8Proxy::setDOMException(ec); return notHandledByInterceptor(); } break; default: - V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "drawImage: Invalid number of arguments"); - return v8::Undefined(); + return throwError("drawImage: Invalid number of arguments", V8Proxy::SyntaxError); } return v8::Undefined(); } @@ -249,7 +249,7 @@ CALLBACK_FUNC_DECL(CanvasRenderingContext2DDrawImage) // HTMLCanvasElement if (V8HTMLCanvasElement::HasInstance(arg)) { ExceptionCode ec = 0; - HTMLCanvasElement* canvas_element = V8Proxy::DOMWrapperToNode<HTMLCanvasElement>(arg); + HTMLCanvasElement* canvas_element = V8DOMWrapper::convertDOMWrapperToNode<HTMLCanvasElement>(v8::Handle<v8::Object>::Cast(arg)); switch (args.Length()) { case 3: context->drawImage(canvas_element, toFloat(args[1]), toFloat(args[2])); @@ -257,7 +257,7 @@ CALLBACK_FUNC_DECL(CanvasRenderingContext2DDrawImage) case 5: context->drawImage(canvas_element, toFloat(args[1]), toFloat(args[2]), toFloat(args[3]), toFloat(args[4]), ec); if (ec != 0) { - V8Proxy::SetDOMException(ec); + V8Proxy::setDOMException(ec); return notHandledByInterceptor(); } break; @@ -267,33 +267,65 @@ CALLBACK_FUNC_DECL(CanvasRenderingContext2DDrawImage) FloatRect(toFloat(args[5]), toFloat(args[6]), toFloat(args[7]), toFloat(args[8])), ec); if (ec != 0) { - V8Proxy::SetDOMException(ec); + V8Proxy::setDOMException(ec); return notHandledByInterceptor(); } break; default: - V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "drawImage: Invalid number of arguments"); - return v8::Undefined(); + return throwError("drawImage: Invalid number of arguments", V8Proxy::SyntaxError); } return v8::Undefined(); } - V8Proxy::SetDOMException(TYPE_MISMATCH_ERR); +#if ENABLE(VIDEO) + // HTMLVideoElement + if (V8HTMLVideoElement::HasInstance(arg)) { + ExceptionCode ec = 0; + HTMLVideoElement* video_element = V8DOMWrapper::convertDOMWrapperToNode<HTMLVideoElement>(v8::Handle<v8::Object>::Cast(arg)); + switch (args.Length()) { + case 3: + context->drawImage(video_element, toFloat(args[1]), toFloat(args[2])); + break; + case 5: + context->drawImage(video_element, toFloat(args[1]), toFloat(args[2]), toFloat(args[3]), toFloat(args[4]), ec); + if (ec != 0) { + V8Proxy::setDOMException(ec); + return notHandledByInterceptor(); + } + break; + case 9: + context->drawImage(video_element, + FloatRect(toFloat(args[1]), toFloat(args[2]), toFloat(args[3]), toFloat(args[4])), + FloatRect(toFloat(args[5]), toFloat(args[6]), toFloat(args[7]), toFloat(args[8])), + ec); + if (ec != 0) { + V8Proxy::setDOMException(ec); + return notHandledByInterceptor(); + } + break; + default: + return throwError("drawImage: Invalid number of arguments", V8Proxy::SyntaxError); + } + return v8::Undefined(); + } +#endif + + V8Proxy::setDOMException(TYPE_MISMATCH_ERR); return notHandledByInterceptor(); } CALLBACK_FUNC_DECL(CanvasRenderingContext2DDrawImageFromRect) { INC_STATS("DOM.CanvasRenderingContext2D.drawImageFromRect()"); - CanvasRenderingContext2D* context = V8Proxy::ToNativeObject<CanvasRenderingContext2D>(V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); + CanvasRenderingContext2D* context = V8DOMWrapper::convertToNativeObject<CanvasRenderingContext2D>(V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); v8::Handle<v8::Value> arg = args[0]; if (V8HTMLImageElement::HasInstance(arg)) { - HTMLImageElement* image_element = V8Proxy::DOMWrapperToNode<HTMLImageElement>(arg); - context->drawImageFromRect(image_element, toFloat(args[1]), toFloat(args[2]), toFloat(args[3]), toFloat(args[4]), toFloat(args[5]), toFloat(args[6]), toFloat(args[7]), toFloat(args[8]), ToWebCoreString(args[9])); + HTMLImageElement* image_element = V8DOMWrapper::convertDOMWrapperToNode<HTMLImageElement>(v8::Handle<v8::Object>::Cast(arg)); + context->drawImageFromRect(image_element, toFloat(args[1]), toFloat(args[2]), toFloat(args[3]), toFloat(args[4]), toFloat(args[5]), toFloat(args[6]), toFloat(args[7]), toFloat(args[8]), toWebCoreString(args[9])); } else - V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, "drawImageFromRect: Invalid type of arguments"); + V8Proxy::throwError(V8Proxy::TypeError, "drawImageFromRect: Invalid type of arguments"); return v8::Undefined(); } @@ -301,33 +333,33 @@ CALLBACK_FUNC_DECL(CanvasRenderingContext2DDrawImageFromRect) CALLBACK_FUNC_DECL(CanvasRenderingContext2DCreatePattern) { INC_STATS("DOM.CanvasRenderingContext2D.createPattern()"); - CanvasRenderingContext2D* context = V8Proxy::ToNativeObject<CanvasRenderingContext2D>(V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); + CanvasRenderingContext2D* context = V8DOMWrapper::convertToNativeObject<CanvasRenderingContext2D>(V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); v8::Handle<v8::Value> arg = args[0]; if (V8HTMLImageElement::HasInstance(arg)) { - HTMLImageElement* image_element = V8Proxy::DOMWrapperToNode<HTMLImageElement>(arg); + HTMLImageElement* image_element = V8DOMWrapper::convertDOMWrapperToNode<HTMLImageElement>(v8::Handle<v8::Object>::Cast(arg)); ExceptionCode ec = 0; - RefPtr<CanvasPattern> pattern = context->createPattern(image_element, valueToStringWithNullCheck(args[1]), ec); + RefPtr<CanvasPattern> pattern = context->createPattern(image_element, toWebCoreStringWithNullCheck(args[1]), ec); if (ec != 0) { - V8Proxy::SetDOMException(ec); + V8Proxy::setDOMException(ec); return notHandledByInterceptor(); } - return V8Proxy::ToV8Object(V8ClassIndex::CANVASPATTERN, pattern.get()); + return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASPATTERN, pattern.release()); } if (V8HTMLCanvasElement::HasInstance(arg)) { - HTMLCanvasElement* canvas_element = V8Proxy::DOMWrapperToNode<HTMLCanvasElement>(arg); + HTMLCanvasElement* canvas_element = V8DOMWrapper::convertDOMWrapperToNode<HTMLCanvasElement>(v8::Handle<v8::Object>::Cast(arg)); ExceptionCode ec = 0; - RefPtr<CanvasPattern> pattern = context->createPattern(canvas_element, valueToStringWithNullCheck(args[1]), ec); + RefPtr<CanvasPattern> pattern = context->createPattern(canvas_element, toWebCoreStringWithNullCheck(args[1]), ec); if (ec != 0) { - V8Proxy::SetDOMException(ec); + V8Proxy::setDOMException(ec); return notHandledByInterceptor(); } - return V8Proxy::ToV8Object(V8ClassIndex::CANVASPATTERN, pattern.get()); + return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASPATTERN, pattern.release()); } - V8Proxy::SetDOMException(TYPE_MISMATCH_ERR); + V8Proxy::setDOMException(TYPE_MISMATCH_ERR); return notHandledByInterceptor(); } @@ -335,17 +367,17 @@ CALLBACK_FUNC_DECL(CanvasRenderingContext2DFillText) { INC_STATS("DOM.CanvasRenderingContext2D.fillText()"); - CanvasRenderingContext2D* context = V8Proxy::ToNativeObject<CanvasRenderingContext2D>(V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); + CanvasRenderingContext2D* context = V8DOMWrapper::convertToNativeObject<CanvasRenderingContext2D>(V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); // Two forms: // * fillText(text, x, y) // * fillText(text, x, y, maxWidth) if (args.Length() < 3 || args.Length() > 4) { - V8Proxy::SetDOMException(SYNTAX_ERR); + V8Proxy::setDOMException(SYNTAX_ERR); return notHandledByInterceptor(); } - String text = ToWebCoreString(args[0]); + String text = toWebCoreString(args[0]); float x = toFloat(args[1]); float y = toFloat(args[2]); @@ -361,17 +393,17 @@ CALLBACK_FUNC_DECL(CanvasRenderingContext2DFillText) CALLBACK_FUNC_DECL(CanvasRenderingContext2DStrokeText) { INC_STATS("DOM.CanvasRenderingContext2D.strokeText()"); - CanvasRenderingContext2D* context = V8Proxy::ToNativeObject<CanvasRenderingContext2D>(V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); + CanvasRenderingContext2D* context = V8DOMWrapper::convertToNativeObject<CanvasRenderingContext2D>(V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); // Two forms: // * strokeText(text, x, y) // * strokeText(text, x, y, maxWidth) if (args.Length() < 3 || args.Length() > 4) { - V8Proxy::SetDOMException(SYNTAX_ERR); + V8Proxy::setDOMException(SYNTAX_ERR); return notHandledByInterceptor(); } - String text = ToWebCoreString(args[0]); + String text = toWebCoreString(args[0]); float x = toFloat(args[1]); float y = toFloat(args[2]); @@ -392,20 +424,20 @@ CALLBACK_FUNC_DECL(CanvasRenderingContext2DPutImageData) // * putImageData(ImageData, x, y) // * putImageData(ImageData, x, y, dirtyX, dirtyY, dirtyWidth, dirtyHeight) if (args.Length() != 3 && args.Length() != 7) { - V8Proxy::SetDOMException(SYNTAX_ERR); + V8Proxy::setDOMException(SYNTAX_ERR); return notHandledByInterceptor(); } - CanvasRenderingContext2D* context = V8Proxy::ToNativeObject<CanvasRenderingContext2D>(V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); + CanvasRenderingContext2D* context = V8DOMWrapper::convertToNativeObject<CanvasRenderingContext2D>(V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); ImageData* imageData = 0; // Need to check that the argument is of the correct type, since - // ToNativeObject() expects it to be correct. If the argument was incorrect + // convertToNativeObject() expects it to be correct. If the argument was incorrect // we leave it null, and putImageData() will throw the correct exception // (TYPE_MISMATCH_ERR). - if (V8Proxy::IsWrapperOfType(args[0], V8ClassIndex::IMAGEDATA)) - imageData = V8Proxy::ToNativeObject<ImageData>(V8ClassIndex::IMAGEDATA, args[0]); + if (V8DOMWrapper::isWrapperOfType(args[0], V8ClassIndex::IMAGEDATA)) + imageData = V8DOMWrapper::convertToNativeObject<ImageData>(V8ClassIndex::IMAGEDATA, v8::Handle<v8::Object>::Cast(args[0])); ExceptionCode ec = 0; @@ -415,7 +447,7 @@ CALLBACK_FUNC_DECL(CanvasRenderingContext2DPutImageData) context->putImageData(imageData, toFloat(args[1]), toFloat(args[2]), ec); if (ec != 0) { - V8Proxy::SetDOMException(ec); + V8Proxy::setDOMException(ec); return notHandledByInterceptor(); } diff --git a/WebCore/bindings/v8/custom/V8ClientRectListCustom.cpp b/WebCore/bindings/v8/custom/V8ClientRectListCustom.cpp index e3f89b9..3c62e14 100644 --- a/WebCore/bindings/v8/custom/V8ClientRectListCustom.cpp +++ b/WebCore/bindings/v8/custom/V8ClientRectListCustom.cpp @@ -44,12 +44,12 @@ namespace WebCore { INDEXED_PROPERTY_GETTER(ClientRectList) { INC_STATS("DOM.ClientRectList.IndexedPropertyGetter"); - ClientRectList* imp = V8Proxy::ToNativeObject<ClientRectList>(V8ClassIndex::CLIENTRECTLIST, info.Holder()); + ClientRectList* imp = V8DOMWrapper::convertToNativeObject<ClientRectList>(V8ClassIndex::CLIENTRECTLIST, info.Holder()); RefPtr<ClientRect> result = imp->item(index); if (!result) return notHandledByInterceptor(); - return V8Proxy::ToV8Object(V8ClassIndex::CLIENTRECT, result.get()); + return V8DOMWrapper::convertToV8Object(V8ClassIndex::CLIENTRECT, result.release()); } } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8ClipboardCustom.cpp b/WebCore/bindings/v8/custom/V8ClipboardCustom.cpp index eff5511..4526304 100644 --- a/WebCore/bindings/v8/custom/V8ClipboardCustom.cpp +++ b/WebCore/bindings/v8/custom/V8ClipboardCustom.cpp @@ -47,7 +47,7 @@ namespace WebCore { ACCESSOR_GETTER(ClipboardTypes) { INC_STATS("DOM.Clipboard.types()"); - Clipboard* clipboard = V8Proxy::ToNativeObject<Clipboard>(V8ClassIndex::CLIPBOARD, info.Holder()); + Clipboard* clipboard = V8DOMWrapper::convertToNativeObject<Clipboard>(V8ClassIndex::CLIPBOARD, info.Holder()); HashSet<String> types = clipboard->types(); if (types.isEmpty()) @@ -65,7 +65,7 @@ ACCESSOR_GETTER(ClipboardTypes) CALLBACK_FUNC_DECL(ClipboardClearData) { INC_STATS("DOM.Clipboard.clearData()"); - Clipboard* clipboard = V8Proxy::ToNativeObject<Clipboard>(V8ClassIndex::CLIPBOARD, args.Holder()); + Clipboard* clipboard = V8DOMWrapper::convertToNativeObject<Clipboard>(V8ClassIndex::CLIPBOARD, args.Holder()); if (!args.Length()) { clipboard->clearAllData(); @@ -73,7 +73,7 @@ CALLBACK_FUNC_DECL(ClipboardClearData) } if (args.Length() != 1) - return throwError("clearData: Invalid number of arguments", V8Proxy::SYNTAX_ERROR); + return throwError("clearData: Invalid number of arguments", V8Proxy::SyntaxError); String type = toWebCoreString(args[0]); clipboard->clearData(type); @@ -83,10 +83,10 @@ CALLBACK_FUNC_DECL(ClipboardClearData) CALLBACK_FUNC_DECL(ClipboardGetData) { INC_STATS("DOM.Clipboard.getData()"); - Clipboard* clipboard = V8Proxy::ToNativeObject<Clipboard>(V8ClassIndex::CLIPBOARD, args.Holder()); + Clipboard* clipboard = V8DOMWrapper::convertToNativeObject<Clipboard>(V8ClassIndex::CLIPBOARD, args.Holder()); if (args.Length() != 1) - return throwError("getData: Invalid number of arguments", V8Proxy::SYNTAX_ERROR); + return throwError("getData: Invalid number of arguments", V8Proxy::SyntaxError); bool success; String result = clipboard->getData(toWebCoreString(args[0]), success); @@ -99,10 +99,10 @@ CALLBACK_FUNC_DECL(ClipboardGetData) CALLBACK_FUNC_DECL(ClipboardSetData) { INC_STATS("DOM.Clipboard.setData()"); - Clipboard* clipboard = V8Proxy::ToNativeObject<Clipboard>(V8ClassIndex::CLIPBOARD, args.Holder()); + Clipboard* clipboard = V8DOMWrapper::convertToNativeObject<Clipboard>(V8ClassIndex::CLIPBOARD, args.Holder()); if (args.Length() != 2) - return throwError("setData: Invalid number of arguments", V8Proxy::SYNTAX_ERROR); + return throwError("setData: Invalid number of arguments", V8Proxy::SyntaxError); String type = toWebCoreString(args[0]); String data = toWebCoreString(args[1]); @@ -112,20 +112,20 @@ CALLBACK_FUNC_DECL(ClipboardSetData) CALLBACK_FUNC_DECL(ClipboardSetDragImage) { INC_STATS("DOM.Clipboard.setDragImage()"); - Clipboard* clipboard = V8Proxy::ToNativeObject<Clipboard>(V8ClassIndex::CLIPBOARD, args.Holder()); + Clipboard* clipboard = V8DOMWrapper::convertToNativeObject<Clipboard>(V8ClassIndex::CLIPBOARD, args.Holder()); if (!clipboard->isForDragging()) return v8::Undefined(); if (args.Length() != 3) - return throwError("setDragImage: Invalid number of arguments", V8Proxy::SYNTAX_ERROR); + return throwError("setDragImage: Invalid number of arguments", V8Proxy::SyntaxError); int x = toInt32(args[1]); int y = toInt32(args[2]); Node* node = 0; if (V8Node::HasInstance(args[0])) - node = V8Proxy::DOMWrapperToNode<Node>(args[0]); + node = V8DOMWrapper::convertDOMWrapperToNode<Node>(v8::Handle<v8::Object>::Cast(args[0])); if (!node || !node->isElementNode()) return throwError("setDragImageFromElement: Invalid first argument"); diff --git a/WebCore/bindings/v8/custom/V8CustomBinding.cpp b/WebCore/bindings/v8/custom/V8CustomBinding.cpp index 7789797..ee45abd 100644 --- a/WebCore/bindings/v8/custom/V8CustomBinding.cpp +++ b/WebCore/bindings/v8/custom/V8CustomBinding.cpp @@ -49,9 +49,9 @@ namespace WebCore { bool allowSettingFrameSrcToJavascriptUrl(HTMLFrameElementBase* frame, String value) { - if (protocolIs(parseURL(value), "javascript")) { + if (protocolIs(deprecatedParseURL(value), "javascript")) { Node* contentDoc = frame->contentDocument(); - if (contentDoc && !V8Proxy::CheckNodeSecurity(contentDoc)) + if (contentDoc && !V8Proxy::checkNodeSecurity(contentDoc)) return false; } return true; @@ -64,6 +64,7 @@ bool allowSettingSrcToJavascriptURL(Element* element, String name, String value) return true; } +#ifdef MANUAL_MERGE_REQUIRED // DOMImplementation is a singleton in WebCore. If we use our normal // mapping from DOM objects to V8 wrappers, the same wrapper will be // shared for all frames in the same process. This is a major @@ -179,4 +180,121 @@ V8ClassIndex::V8WrapperType V8Custom::DowncastSVGPathSeg(void* pathSeg) #endif // ENABLE(SVG) +#else // MANUAL_MERGE_REQUIRED +// DOMImplementation is a singleton in WebCore. If we use our normal +// mapping from DOM objects to V8 wrappers, the same wrapper will be +// shared for all frames in the same process. This is a major +// security problem. Therefore, we generate a DOMImplementation +// wrapper per document and store it in an internal field of the +// document. Since the DOMImplementation object is a singleton, we do +// not have to do anything to keep the DOMImplementation object alive +// for the lifetime of the wrapper. +ACCESSOR_GETTER(DocumentImplementation) +{ + ASSERT(info.Holder()->InternalFieldCount() >= kDocumentMinimumInternalFieldCount); + + // Check if the internal field already contains a wrapper. + v8::Local<v8::Value> implementation = info.Holder()->GetInternalField(kDocumentImplementationIndex); + if (!implementation->IsUndefined()) + return implementation; + + // Generate a wrapper. + Document* document = V8DOMWrapper::convertDOMWrapperToNative<Document>(info.Holder()); + v8::Handle<v8::Value> wrapper = V8DOMWrapper::convertDOMImplementationToV8Object(document->implementation()); + + // Store the wrapper in the internal field. + info.Holder()->SetInternalField(kDocumentImplementationIndex, wrapper); + + return wrapper; +} + +// --------------- Security Checks ------------------------- +INDEXED_ACCESS_CHECK(History) +{ + ASSERT(V8ClassIndex::FromInt(data->Int32Value()) == V8ClassIndex::HISTORY); + // Only allow same origin access. + History* history = V8DOMWrapper::convertToNativeObject<History>(V8ClassIndex::HISTORY, host); + return V8Proxy::canAccessFrame(history->frame(), false); +} + +NAMED_ACCESS_CHECK(History) +{ + ASSERT(V8ClassIndex::FromInt(data->Int32Value()) == V8ClassIndex::HISTORY); + // Only allow same origin access. + History* history = V8DOMWrapper::convertToNativeObject<History>(V8ClassIndex::HISTORY, host); + return V8Proxy::canAccessFrame(history->frame(), false); +} + +#undef INDEXED_ACCESS_CHECK +#undef NAMED_ACCESS_CHECK +#undef NAMED_PROPERTY_GETTER +#undef NAMED_PROPERTY_SETTER + +Frame* V8Custom::GetTargetFrame(v8::Local<v8::Object> host, v8::Local<v8::Value> data) +{ + Frame* target = 0; + switch (V8ClassIndex::FromInt(data->Int32Value())) { + case V8ClassIndex::DOMWINDOW: { + v8::Handle<v8::Object> window = V8DOMWrapper::lookupDOMWrapper(V8ClassIndex::DOMWINDOW, host); + if (window.IsEmpty()) + return target; + + DOMWindow* targetWindow = V8DOMWrapper::convertToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, window); + target = targetWindow->frame(); + break; + } + case V8ClassIndex::LOCATION: { + History* history = V8DOMWrapper::convertToNativeObject<History>(V8ClassIndex::HISTORY, host); + target = history->frame(); + break; + } + case V8ClassIndex::HISTORY: { + Location* location = V8DOMWrapper::convertToNativeObject<Location>(V8ClassIndex::LOCATION, host); + target = location->frame(); + break; + } + default: + break; + } + return target; +} + +#if ENABLE(SVG) +V8ClassIndex::V8WrapperType V8Custom::DowncastSVGPathSeg(void* pathSeg) +{ + WebCore::SVGPathSeg* realPathSeg = reinterpret_cast<WebCore::SVGPathSeg*>(pathSeg); + + switch (realPathSeg->pathSegType()) { +#define MAKE_CASE(svgValue, v8Value) case WebCore::SVGPathSeg::svgValue: return V8ClassIndex::v8Value + + MAKE_CASE(PATHSEG_CLOSEPATH, SVGPATHSEGCLOSEPATH); + MAKE_CASE(PATHSEG_MOVETO_ABS, SVGPATHSEGMOVETOABS); + MAKE_CASE(PATHSEG_MOVETO_REL, SVGPATHSEGMOVETOREL); + MAKE_CASE(PATHSEG_LINETO_ABS, SVGPATHSEGLINETOABS); + MAKE_CASE(PATHSEG_LINETO_REL, SVGPATHSEGLINETOREL); + MAKE_CASE(PATHSEG_CURVETO_CUBIC_ABS, SVGPATHSEGCURVETOCUBICABS); + MAKE_CASE(PATHSEG_CURVETO_CUBIC_REL, SVGPATHSEGCURVETOCUBICREL); + MAKE_CASE(PATHSEG_CURVETO_QUADRATIC_ABS, SVGPATHSEGCURVETOQUADRATICABS); + MAKE_CASE(PATHSEG_CURVETO_QUADRATIC_REL, SVGPATHSEGCURVETOQUADRATICREL); + MAKE_CASE(PATHSEG_ARC_ABS, SVGPATHSEGARCABS); + MAKE_CASE(PATHSEG_ARC_REL, SVGPATHSEGARCREL); + MAKE_CASE(PATHSEG_LINETO_HORIZONTAL_ABS, SVGPATHSEGLINETOHORIZONTALABS); + MAKE_CASE(PATHSEG_LINETO_HORIZONTAL_REL, SVGPATHSEGLINETOHORIZONTALREL); + MAKE_CASE(PATHSEG_LINETO_VERTICAL_ABS, SVGPATHSEGLINETOVERTICALABS); + MAKE_CASE(PATHSEG_LINETO_VERTICAL_REL, SVGPATHSEGLINETOVERTICALREL); + MAKE_CASE(PATHSEG_CURVETO_CUBIC_SMOOTH_ABS, SVGPATHSEGCURVETOCUBICSMOOTHABS); + MAKE_CASE(PATHSEG_CURVETO_CUBIC_SMOOTH_REL, SVGPATHSEGCURVETOCUBICSMOOTHREL); + MAKE_CASE(PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS, SVGPATHSEGCURVETOQUADRATICSMOOTHABS); + MAKE_CASE(PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL, SVGPATHSEGCURVETOQUADRATICSMOOTHREL); + +#undef MAKE_CASE + + default: + return V8ClassIndex::INVALID_CLASS_INDEX; + } +} + +#endif // ENABLE(SVG) + +#endif // MANUAL_MERGE_REQUIRED } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8CustomBinding.h b/WebCore/bindings/v8/custom/V8CustomBinding.h index e039c6f..42aca44 100644 --- a/WebCore/bindings/v8/custom/V8CustomBinding.h +++ b/WebCore/bindings/v8/custom/V8CustomBinding.h @@ -91,6 +91,7 @@ namespace WebCore { bool allowSettingFrameSrcToJavascriptUrl(HTMLFrameElementBase*, String value); bool allowSettingSrcToJavascriptURL(Element*, String name, String value); +#ifdef MANUAL_MERGE_REQUIRED class V8Custom { public: // Constants. @@ -542,6 +543,469 @@ namespace WebCore { static void WindowSetLocation(DOMWindow*, const String&); }; +#else // MANUAL_MERGE_REQUIRED + class V8Custom { + public: + // Constants. + static const int kDOMWrapperTypeIndex = 0; + static const int kDOMWrapperObjectIndex = 1; + static const int kDefaultWrapperInternalFieldCount = 2; + + static const int kNPObjectInternalFieldCount = kDefaultWrapperInternalFieldCount + 0; + + static const int kNodeEventListenerCacheIndex = kDefaultWrapperInternalFieldCount + 0; + static const int kNodeMinimumInternalFieldCount = kDefaultWrapperInternalFieldCount + 1; + + static const int kDocumentImplementationIndex = kNodeMinimumInternalFieldCount + 0; + static const int kDocumentMinimumInternalFieldCount = kNodeMinimumInternalFieldCount + 1; + + static const int kHTMLDocumentMarkerIndex = kDocumentMinimumInternalFieldCount + 0; + static const int kHTMLDocumentShadowIndex = kDocumentMinimumInternalFieldCount + 1; + static const int kHTMLDocumentInternalFieldCount = kDocumentMinimumInternalFieldCount + 2; + + static const int kXMLHttpRequestCacheIndex = kDefaultWrapperInternalFieldCount + 0; + static const int kXMLHttpRequestInternalFieldCount = kDefaultWrapperInternalFieldCount + 1; + + static const int kMessageChannelPort1Index = kDefaultWrapperInternalFieldCount + 0; + static const int kMessageChannelPort2Index = kDefaultWrapperInternalFieldCount + 1; + static const int kMessageChannelInternalFieldCount = kDefaultWrapperInternalFieldCount + 2; + + static const int kMessagePortRequestCacheIndex = kDefaultWrapperInternalFieldCount + 0; + static const int kMessagePortEntangledPortIndex = kDefaultWrapperInternalFieldCount + 1; + static const int kMessagePortInternalFieldCount = kDefaultWrapperInternalFieldCount + 2; + +#if ENABLE(WORKERS) + static const int kWorkerRequestCacheIndex = kDefaultWrapperInternalFieldCount + 0; + static const int kWorkerInternalFieldCount = kDefaultWrapperInternalFieldCount + 1; + + static const int kWorkerContextRequestCacheIndex = kDefaultWrapperInternalFieldCount + 0; + static const int kWorkerContextMinimumInternalFieldCount = kDefaultWrapperInternalFieldCount + 1; + + static const int kDedicatedWorkerContextRequestCacheIndex = kWorkerContextMinimumInternalFieldCount + 0; + static const int kDedicatedWorkerContextInternalFieldCount = kWorkerContextMinimumInternalFieldCount + 1; + + static const int kAbstractWorkerRequestCacheIndex = kDefaultWrapperInternalFieldCount + 0; + static const int kAbstractWorkerInternalFieldCount = kDefaultWrapperInternalFieldCount + 1; +#endif + + static const int kDOMWindowConsoleIndex = kDefaultWrapperInternalFieldCount + 0; + static const int kDOMWindowHistoryIndex = kDefaultWrapperInternalFieldCount + 1; + static const int kDOMWindowLocationbarIndex = kDefaultWrapperInternalFieldCount + 2; + static const int kDOMWindowMenubarIndex = kDefaultWrapperInternalFieldCount + 3; + static const int kDOMWindowNavigatorIndex = kDefaultWrapperInternalFieldCount + 4; + static const int kDOMWindowPersonalbarIndex = kDefaultWrapperInternalFieldCount + 5; + static const int kDOMWindowScreenIndex = kDefaultWrapperInternalFieldCount + 6; + static const int kDOMWindowScrollbarsIndex = kDefaultWrapperInternalFieldCount + 7; + static const int kDOMWindowSelectionIndex = kDefaultWrapperInternalFieldCount + 8; + static const int kDOMWindowStatusbarIndex = kDefaultWrapperInternalFieldCount + 9; + static const int kDOMWindowToolbarIndex = kDefaultWrapperInternalFieldCount + 10; + static const int kDOMWindowLocationIndex = kDefaultWrapperInternalFieldCount + 11; + static const int kDOMWindowDOMSelectionIndex = kDefaultWrapperInternalFieldCount + 12; + static const int kDOMWindowInternalFieldCount = kDefaultWrapperInternalFieldCount + 13; + + static const int kStyleSheetOwnerNodeIndex = kDefaultWrapperInternalFieldCount + 0; + static const int kStyleSheetInternalFieldCount = kDefaultWrapperInternalFieldCount + 1; + +#if ENABLE(OFFLINE_WEB_APPLICATIONS) + static const int kDOMApplicationCacheCacheIndex = kDefaultWrapperInternalFieldCount + 0; + static const int kDOMApplicationCacheFieldCount = kDefaultWrapperInternalFieldCount + 1; +#endif + +#define DECLARE_PROPERTY_ACCESSOR_GETTER(NAME) \ + static v8::Handle<v8::Value> v8##NAME##AccessorGetter( \ + v8::Local<v8::String> name, const v8::AccessorInfo& info) + +#define DECLARE_PROPERTY_ACCESSOR_SETTER(NAME) \ + static void v8##NAME##AccessorSetter(v8::Local<v8::String> name, \ + v8::Local<v8::Value> value, const v8::AccessorInfo& info) + +#define DECLARE_PROPERTY_ACCESSOR(NAME) DECLARE_PROPERTY_ACCESSOR_GETTER(NAME); DECLARE_PROPERTY_ACCESSOR_SETTER(NAME) + +#define DECLARE_NAMED_PROPERTY_GETTER(NAME) \ + static v8::Handle<v8::Value> v8##NAME##NamedPropertyGetter( \ + v8::Local<v8::String> name, const v8::AccessorInfo& info) + +#define DECLARE_NAMED_PROPERTY_SETTER(NAME) \ + static v8::Handle<v8::Value> v8##NAME##NamedPropertySetter( \ + v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) + +#define DECLARE_NAMED_PROPERTY_DELETER(NAME) \ + static v8::Handle<v8::Boolean> v8##NAME##NamedPropertyDeleter( \ + v8::Local<v8::String> name, const v8::AccessorInfo& info) + +#define USE_NAMED_PROPERTY_GETTER(NAME) V8Custom::v8##NAME##NamedPropertyGetter + +#define USE_NAMED_PROPERTY_SETTER(NAME) V8Custom::v8##NAME##NamedPropertySetter + +#define USE_NAMED_PROPERTY_DELETER(NAME) V8Custom::v8##NAME##NamedPropertyDeleter + +#define DECLARE_INDEXED_PROPERTY_GETTER(NAME) \ + static v8::Handle<v8::Value> v8##NAME##IndexedPropertyGetter( \ + uint32_t index, const v8::AccessorInfo& info) + +#define DECLARE_INDEXED_PROPERTY_SETTER(NAME) \ + static v8::Handle<v8::Value> v8##NAME##IndexedPropertySetter( \ + uint32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info) + +#define DECLARE_INDEXED_PROPERTY_DELETER(NAME) \ + static v8::Handle<v8::Boolean> v8##NAME##IndexedPropertyDeleter( \ + uint32_t index, const v8::AccessorInfo& info) + +#define USE_INDEXED_PROPERTY_GETTER(NAME) V8Custom::v8##NAME##IndexedPropertyGetter + +#define USE_INDEXED_PROPERTY_SETTER(NAME) V8Custom::v8##NAME##IndexedPropertySetter + +#define USE_INDEXED_PROPERTY_DELETER(NAME) V8Custom::v8##NAME##IndexedPropertyDeleter + +#define DECLARE_CALLBACK(NAME) static v8::Handle<v8::Value> v8##NAME##Callback(const v8::Arguments& args) + +#define USE_CALLBACK(NAME) V8Custom::v8##NAME##Callback + +#define DECLARE_NAMED_ACCESS_CHECK(NAME) \ + static bool v8##NAME##NamedSecurityCheck(v8::Local<v8::Object> host, \ + v8::Local<v8::Value> key, v8::AccessType type, v8::Local<v8::Value> data) + +#define DECLARE_INDEXED_ACCESS_CHECK(NAME) \ + static bool v8##NAME##IndexedSecurityCheck(v8::Local<v8::Object> host, \ + uint32_t index, v8::AccessType type, v8::Local<v8::Value> data) + + DECLARE_PROPERTY_ACCESSOR(CanvasRenderingContext2DStrokeStyle); + DECLARE_PROPERTY_ACCESSOR(CanvasRenderingContext2DFillStyle); + DECLARE_PROPERTY_ACCESSOR_GETTER(DOMWindowEvent); + DECLARE_PROPERTY_ACCESSOR_GETTER(DOMWindowCrypto); + DECLARE_PROPERTY_ACCESSOR_SETTER(DOMWindowLocation); + DECLARE_PROPERTY_ACCESSOR_SETTER(DOMWindowOpener); + + DECLARE_PROPERTY_ACCESSOR(DocumentLocation); + DECLARE_PROPERTY_ACCESSOR(DocumentImplementation); + DECLARE_PROPERTY_ACCESSOR_GETTER(EventSrcElement); + DECLARE_PROPERTY_ACCESSOR(EventReturnValue); + DECLARE_PROPERTY_ACCESSOR_GETTER(EventDataTransfer); + DECLARE_PROPERTY_ACCESSOR_GETTER(EventClipboardData); + + DECLARE_PROPERTY_ACCESSOR(DOMWindowEventHandler); + DECLARE_PROPERTY_ACCESSOR(NodeEventHandler); + + DECLARE_CALLBACK(HTMLCanvasElementGetContext); + + DECLARE_PROPERTY_ACCESSOR_SETTER(HTMLFrameElementSrc); + DECLARE_PROPERTY_ACCESSOR_SETTER(HTMLFrameElementLocation); + DECLARE_PROPERTY_ACCESSOR_SETTER(HTMLIFrameElementSrc); + + DECLARE_PROPERTY_ACCESSOR_SETTER(AttrValue); + + DECLARE_PROPERTY_ACCESSOR(HTMLOptionsCollectionLength); + + DECLARE_CALLBACK(HTMLInputElementSetSelectionRange); + + DECLARE_PROPERTY_ACCESSOR(HTMLInputElementSelectionStart); + DECLARE_PROPERTY_ACCESSOR(HTMLInputElementSelectionEnd); + + DECLARE_NAMED_ACCESS_CHECK(Location); + DECLARE_INDEXED_ACCESS_CHECK(History); + + DECLARE_NAMED_ACCESS_CHECK(History); + DECLARE_INDEXED_ACCESS_CHECK(Location); + + DECLARE_CALLBACK(HTMLCollectionItem); + DECLARE_CALLBACK(HTMLCollectionNamedItem); + DECLARE_CALLBACK(HTMLCollectionCallAsFunction); + + DECLARE_CALLBACK(HTMLSelectElementRemove); + + DECLARE_CALLBACK(HTMLOptionsCollectionRemove); + DECLARE_CALLBACK(HTMLOptionsCollectionAdd); + + DECLARE_CALLBACK(HTMLDocumentWrite); + DECLARE_CALLBACK(HTMLDocumentWriteln); + DECLARE_CALLBACK(HTMLDocumentOpen); + DECLARE_PROPERTY_ACCESSOR(HTMLDocumentAll); + DECLARE_NAMED_PROPERTY_GETTER(HTMLDocument); + DECLARE_NAMED_PROPERTY_DELETER(HTMLDocument); + + DECLARE_CALLBACK(DocumentEvaluate); + DECLARE_CALLBACK(DocumentGetCSSCanvasContext); + + DECLARE_CALLBACK(DOMWindowAddEventListener); + DECLARE_CALLBACK(DOMWindowRemoveEventListener); + DECLARE_CALLBACK(DOMWindowPostMessage); + DECLARE_CALLBACK(DOMWindowSetTimeout); + DECLARE_CALLBACK(DOMWindowSetInterval); + DECLARE_CALLBACK(DOMWindowAtob); + DECLARE_CALLBACK(DOMWindowBtoa); + DECLARE_CALLBACK(DOMWindowNOP); + DECLARE_CALLBACK(DOMWindowToString); + DECLARE_CALLBACK(DOMWindowShowModalDialog); + DECLARE_CALLBACK(DOMWindowOpen); + DECLARE_CALLBACK(DOMWindowClearTimeout); + DECLARE_CALLBACK(DOMWindowClearInterval); + + DECLARE_CALLBACK(DOMParserConstructor); + DECLARE_CALLBACK(HTMLAudioElementConstructor); + DECLARE_CALLBACK(HTMLImageElementConstructor); + DECLARE_CALLBACK(HTMLOptionElementConstructor); + DECLARE_CALLBACK(MessageChannelConstructor); + DECLARE_CALLBACK(WebKitCSSMatrixConstructor); + DECLARE_CALLBACK(WebKitPointConstructor); + DECLARE_CALLBACK(XMLHttpRequestConstructor); + DECLARE_CALLBACK(XMLSerializerConstructor); + DECLARE_CALLBACK(XPathEvaluatorConstructor); + DECLARE_CALLBACK(XSLTProcessorConstructor); + + DECLARE_CALLBACK(XSLTProcessorImportStylesheet); + DECLARE_CALLBACK(XSLTProcessorTransformToFragment); + DECLARE_CALLBACK(XSLTProcessorTransformToDocument); + DECLARE_CALLBACK(XSLTProcessorSetParameter); + DECLARE_CALLBACK(XSLTProcessorGetParameter); + DECLARE_CALLBACK(XSLTProcessorRemoveParameter); + + DECLARE_CALLBACK(CSSPrimitiveValueGetRGBColorValue); + + DECLARE_CALLBACK(CanvasRenderingContext2DSetStrokeColor); + DECLARE_CALLBACK(CanvasRenderingContext2DSetFillColor); + DECLARE_CALLBACK(CanvasRenderingContext2DStrokeRect); + DECLARE_CALLBACK(CanvasRenderingContext2DSetShadow); + DECLARE_CALLBACK(CanvasRenderingContext2DDrawImage); + DECLARE_CALLBACK(CanvasRenderingContext2DDrawImageFromRect); + DECLARE_CALLBACK(CanvasRenderingContext2DCreatePattern); + DECLARE_CALLBACK(CanvasRenderingContext2DFillText); + DECLARE_CALLBACK(CanvasRenderingContext2DStrokeText); + DECLARE_CALLBACK(CanvasRenderingContext2DPutImageData); + + DECLARE_PROPERTY_ACCESSOR_GETTER(ClipboardTypes); + DECLARE_CALLBACK(ClipboardClearData); + DECLARE_CALLBACK(ClipboardGetData); + DECLARE_CALLBACK(ClipboardSetData); + DECLARE_CALLBACK(ClipboardSetDragImage); + + DECLARE_CALLBACK(ElementQuerySelector); + DECLARE_CALLBACK(ElementQuerySelectorAll); + DECLARE_CALLBACK(ElementSetAttribute); + DECLARE_CALLBACK(ElementSetAttributeNode); + DECLARE_CALLBACK(ElementSetAttributeNS); + DECLARE_CALLBACK(ElementSetAttributeNodeNS); + + DECLARE_PROPERTY_ACCESSOR_SETTER(LocationProtocol); + DECLARE_PROPERTY_ACCESSOR_SETTER(LocationHost); + DECLARE_PROPERTY_ACCESSOR_SETTER(LocationHostname); + DECLARE_PROPERTY_ACCESSOR_SETTER(LocationPort); + DECLARE_PROPERTY_ACCESSOR_SETTER(LocationPathname); + DECLARE_PROPERTY_ACCESSOR_SETTER(LocationSearch); + DECLARE_PROPERTY_ACCESSOR_SETTER(LocationHash); + DECLARE_PROPERTY_ACCESSOR_SETTER(LocationHref); + DECLARE_PROPERTY_ACCESSOR_GETTER(LocationAssign); + DECLARE_PROPERTY_ACCESSOR_GETTER(LocationReplace); + DECLARE_PROPERTY_ACCESSOR_GETTER(LocationReload); + DECLARE_CALLBACK(LocationAssign); + DECLARE_CALLBACK(LocationReplace); + DECLARE_CALLBACK(LocationReload); + DECLARE_CALLBACK(LocationToString); + DECLARE_CALLBACK(LocationValueOf); + + DECLARE_CALLBACK(NodeAddEventListener); + DECLARE_CALLBACK(NodeRemoveEventListener); + DECLARE_CALLBACK(NodeInsertBefore); + DECLARE_CALLBACK(NodeReplaceChild); + DECLARE_CALLBACK(NodeRemoveChild); + DECLARE_CALLBACK(NodeAppendChild); + + // We actually only need this because WebKit has + // navigator.appVersion as custom. Our version just + // passes through. + DECLARE_PROPERTY_ACCESSOR(NavigatorAppVersion); + + DECLARE_PROPERTY_ACCESSOR(XMLHttpRequestOnabort); + DECLARE_PROPERTY_ACCESSOR(XMLHttpRequestOnerror); + DECLARE_PROPERTY_ACCESSOR(XMLHttpRequestOnload); + DECLARE_PROPERTY_ACCESSOR(XMLHttpRequestOnloadstart); + DECLARE_PROPERTY_ACCESSOR(XMLHttpRequestOnprogress); + DECLARE_PROPERTY_ACCESSOR(XMLHttpRequestOnreadystatechange); + DECLARE_PROPERTY_ACCESSOR(XMLHttpRequestResponseText); + DECLARE_CALLBACK(XMLHttpRequestAddEventListener); + DECLARE_CALLBACK(XMLHttpRequestRemoveEventListener); + DECLARE_CALLBACK(XMLHttpRequestOpen); + DECLARE_CALLBACK(XMLHttpRequestSend); + DECLARE_CALLBACK(XMLHttpRequestSetRequestHeader); + DECLARE_CALLBACK(XMLHttpRequestGetResponseHeader); + DECLARE_CALLBACK(XMLHttpRequestOverrideMimeType); + DECLARE_CALLBACK(XMLHttpRequestDispatchEvent); + + DECLARE_PROPERTY_ACCESSOR(XMLHttpRequestUploadOnabort); + DECLARE_PROPERTY_ACCESSOR(XMLHttpRequestUploadOnerror); + DECLARE_PROPERTY_ACCESSOR(XMLHttpRequestUploadOnload); + DECLARE_PROPERTY_ACCESSOR(XMLHttpRequestUploadOnloadstart); + DECLARE_PROPERTY_ACCESSOR(XMLHttpRequestUploadOnprogress); + DECLARE_CALLBACK(XMLHttpRequestUploadAddEventListener); + DECLARE_CALLBACK(XMLHttpRequestUploadRemoveEventListener); + DECLARE_CALLBACK(XMLHttpRequestUploadDispatchEvent); + + DECLARE_CALLBACK(TreeWalkerParentNode); + DECLARE_CALLBACK(TreeWalkerFirstChild); + DECLARE_CALLBACK(TreeWalkerLastChild); + DECLARE_CALLBACK(TreeWalkerNextNode); + DECLARE_CALLBACK(TreeWalkerPreviousNode); + DECLARE_CALLBACK(TreeWalkerNextSibling); + DECLARE_CALLBACK(TreeWalkerPreviousSibling); + + DECLARE_CALLBACK(InspectorBackendProfiles); + DECLARE_CALLBACK(InspectorBackendHighlightDOMNode); + DECLARE_CALLBACK(InspectorBackendAddResourceSourceToFrame); + DECLARE_CALLBACK(InspectorBackendAddSourceToFrame); + DECLARE_CALLBACK(InspectorBackendSearch); + DECLARE_CALLBACK(InspectorBackendSetting); + DECLARE_CALLBACK(InspectorBackendInspectedWindow); + DECLARE_CALLBACK(InspectorBackendSetSetting); + DECLARE_CALLBACK(InspectorBackendCurrentCallFrame); + DECLARE_CALLBACK(InspectorBackendDebuggerEnabled); + DECLARE_CALLBACK(InspectorBackendPauseOnExceptions); + DECLARE_CALLBACK(InspectorBackendProfilerEnabled); +#if ENABLE(DATABASE) + DECLARE_CALLBACK(InspectorBackendDatabaseTableNames); +#endif + DECLARE_CALLBACK(InspectorBackendWrapCallback); + + DECLARE_CALLBACK(NodeIteratorNextNode); + DECLARE_CALLBACK(NodeIteratorPreviousNode); + + DECLARE_CALLBACK(NodeFilterAcceptNode); + + DECLARE_CALLBACK(HTMLFormElementSubmit); + + DECLARE_NAMED_PROPERTY_GETTER(DOMWindow); + DECLARE_INDEXED_PROPERTY_GETTER(DOMWindow); + DECLARE_NAMED_ACCESS_CHECK(DOMWindow); + DECLARE_INDEXED_ACCESS_CHECK(DOMWindow); + + DECLARE_NAMED_PROPERTY_GETTER(HTMLFrameSetElement); + DECLARE_NAMED_PROPERTY_GETTER(HTMLFormElement); + DECLARE_NAMED_PROPERTY_GETTER(NodeList); + DECLARE_NAMED_PROPERTY_GETTER(NamedNodeMap); + DECLARE_NAMED_PROPERTY_GETTER(CSSStyleDeclaration); + DECLARE_NAMED_PROPERTY_SETTER(CSSStyleDeclaration); + DECLARE_NAMED_PROPERTY_GETTER(HTMLPlugInElement); + DECLARE_NAMED_PROPERTY_SETTER(HTMLPlugInElement); + DECLARE_INDEXED_PROPERTY_GETTER(HTMLPlugInElement); + DECLARE_INDEXED_PROPERTY_SETTER(HTMLPlugInElement); + + DECLARE_CALLBACK(HTMLPlugInElement); + + DECLARE_NAMED_PROPERTY_GETTER(StyleSheetList); + DECLARE_INDEXED_PROPERTY_GETTER(NamedNodeMap); + DECLARE_INDEXED_PROPERTY_GETTER(HTMLFormElement); + DECLARE_INDEXED_PROPERTY_GETTER(HTMLOptionsCollection); + DECLARE_INDEXED_PROPERTY_SETTER(HTMLOptionsCollection); + DECLARE_NAMED_PROPERTY_GETTER(HTMLSelectElementCollection); + DECLARE_INDEXED_PROPERTY_SETTER(HTMLSelectElementCollection); + DECLARE_NAMED_PROPERTY_GETTER(HTMLCollection); + + DECLARE_INDEXED_PROPERTY_GETTER(CanvasPixelArray); + DECLARE_INDEXED_PROPERTY_SETTER(CanvasPixelArray); + + DECLARE_PROPERTY_ACCESSOR(MessagePortOnmessage); + DECLARE_PROPERTY_ACCESSOR(MessagePortOnclose); + DECLARE_CALLBACK(MessagePortStartConversation); + DECLARE_CALLBACK(MessagePortAddEventListener); + DECLARE_CALLBACK(MessagePortRemoveEventListener); + + DECLARE_CALLBACK(DatabaseChangeVersion); + DECLARE_CALLBACK(DatabaseTransaction); + DECLARE_CALLBACK(SQLTransactionExecuteSql); + DECLARE_CALLBACK(SQLResultSetRowListItem); + + DECLARE_INDEXED_PROPERTY_GETTER(ClientRectList); + +#if ENABLE(DATAGRID) + DECLARE_PROPERTY_ACCESSOR(HTMLDataGridElementDataSource); + DECLARE_INDEXED_PROPERTY_GETTER(DataGridColumnList); + DECLARE_NAMED_PROPERTY_GETTER(DataGridColumnList); +#endif + +#if ENABLE(DOM_STORAGE) + DECLARE_INDEXED_PROPERTY_GETTER(Storage); + DECLARE_INDEXED_PROPERTY_SETTER(Storage); + DECLARE_INDEXED_PROPERTY_DELETER(Storage); + DECLARE_NAMED_PROPERTY_GETTER(Storage); + DECLARE_NAMED_PROPERTY_SETTER(Storage); + DECLARE_NAMED_PROPERTY_DELETER(Storage); + static v8::Handle<v8::Array> v8StorageNamedPropertyEnumerator(const v8::AccessorInfo& info); +#endif + +#if ENABLE(SVG) + DECLARE_PROPERTY_ACCESSOR_GETTER(SVGLengthValue); + DECLARE_CALLBACK(SVGLengthConvertToSpecifiedUnits); + DECLARE_CALLBACK(SVGMatrixInverse); + DECLARE_CALLBACK(SVGMatrixRotateFromVector); + DECLARE_CALLBACK(SVGElementInstanceAddEventListener); + DECLARE_CALLBACK(SVGElementInstanceRemoveEventListener); +#endif + +#if ENABLE(WORKERS) + DECLARE_PROPERTY_ACCESSOR(AbstractWorkerOnerror); + DECLARE_CALLBACK(AbstractWorkerAddEventListener); + DECLARE_CALLBACK(AbstractWorkerRemoveEventListener); + + DECLARE_PROPERTY_ACCESSOR(DedicatedWorkerContextOnmessage); + + DECLARE_PROPERTY_ACCESSOR(WorkerOnmessage); + DECLARE_CALLBACK(WorkerConstructor); + + DECLARE_PROPERTY_ACCESSOR_GETTER(WorkerContextSelf); + DECLARE_PROPERTY_ACCESSOR(WorkerContextOnerror); + DECLARE_CALLBACK(WorkerContextImportScripts); + DECLARE_CALLBACK(WorkerContextSetTimeout); + DECLARE_CALLBACK(WorkerContextClearTimeout); + DECLARE_CALLBACK(WorkerContextSetInterval); + DECLARE_CALLBACK(WorkerContextClearInterval); + DECLARE_CALLBACK(WorkerContextAddEventListener); + DECLARE_CALLBACK(WorkerContextRemoveEventListener); +#endif + +#if ENABLE(OFFLINE_WEB_APPLICATIONS) + DECLARE_PROPERTY_ACCESSOR(DOMApplicationCacheEventHandler); + DECLARE_CALLBACK(DOMApplicationCacheAddEventListener); + DECLARE_CALLBACK(DOMApplicationCacheRemoveEventListener); +#endif + +#if ENABLE(SHARED_WORKERS) + DECLARE_CALLBACK(SharedWorkerConstructor); +#endif + +#undef DECLARE_INDEXED_ACCESS_CHECK +#undef DECLARE_NAMED_ACCESS_CHECK + +#undef DECLARE_PROPERTY_ACCESSOR_SETTER +#undef DECLARE_PROPERTY_ACCESSOR_GETTER +#undef DECLARE_PROPERTY_ACCESSOR + +#undef DECLARE_NAMED_PROPERTY_GETTER +#undef DECLARE_NAMED_PROPERTY_SETTER +#undef DECLARE_NAMED_PROPERTY_DELETER + +#undef DECLARE_INDEXED_PROPERTY_GETTER +#undef DECLARE_INDEXED_PROPERTY_SETTER +#undef DECLARE_INDEXED_PROPERTY_DELETER + +#undef DECLARE_CALLBACK + + // Returns the NPObject corresponding to an HTMLElement object. + static NPObject* GetHTMLPlugInElementNPObject(v8::Handle<v8::Object>); + + // Returns the owner frame pointer of a DOM wrapper object. It only works for + // these DOM objects requiring cross-domain access check. + static Frame* GetTargetFrame(v8::Local<v8::Object> host, v8::Local<v8::Value> data); + + // Special case for downcasting SVG path segments. +#if ENABLE(SVG) + static V8ClassIndex::V8WrapperType DowncastSVGPathSeg(void* pathSeg); +#endif + + private: + static v8::Handle<v8::Value> WindowSetTimeoutImpl(const v8::Arguments&, bool singleShot); + static void ClearTimeoutImpl(const v8::Arguments&); + static void WindowSetLocation(DOMWindow*, const String&); + }; + +#endif // MANUAL_MERGE_REQUIRED } // namespace WebCore #endif // V8CustomBinding_h diff --git a/WebCore/bindings/v8/custom/V8CustomEventListener.cpp b/WebCore/bindings/v8/custom/V8CustomEventListener.cpp index bd9e307..305da8d 100644 --- a/WebCore/bindings/v8/custom/V8CustomEventListener.cpp +++ b/WebCore/bindings/v8/custom/V8CustomEventListener.cpp @@ -40,7 +40,7 @@ V8EventListener::V8EventListener(Frame* frame, v8::Local<v8::Object> listener, b { m_listener = v8::Persistent<v8::Object>::New(listener); #ifndef NDEBUG - V8Proxy::RegisterGlobalHandle(EVENT_LISTENER, this, m_listener); + V8GCController::registerGlobalHandle(EVENT_LISTENER, this, m_listener); #endif } @@ -49,7 +49,7 @@ V8EventListener::~V8EventListener() if (m_frame) { V8Proxy* proxy = V8Proxy::retrieve(m_frame); if (proxy) - proxy->RemoveV8EventListener(this); + proxy->eventListeners()->remove(this); } disposeListenerObject(); @@ -83,7 +83,9 @@ v8::Local<v8::Value> V8EventListener::callListenerFunction(v8::Handle<v8::Value> v8::Handle<v8::Value> parameters[1] = { jsEvent }; V8Proxy* proxy = V8Proxy::retrieve(m_frame); - return proxy->CallFunction(handlerFunction, receiver, 1, parameters); + if (!proxy) + return v8::Local<v8::Value>(); + return proxy->callFunction(handlerFunction, receiver, 1, parameters); } } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8CustomSQLStatementCallback.cpp b/WebCore/bindings/v8/custom/V8CustomSQLStatementCallback.cpp index daa9b34..2abdb15 100644 --- a/WebCore/bindings/v8/custom/V8CustomSQLStatementCallback.cpp +++ b/WebCore/bindings/v8/custom/V8CustomSQLStatementCallback.cpp @@ -55,15 +55,15 @@ void V8CustomSQLStatementCallback::handleEvent(SQLTransaction* transaction, SQLR LOCK_V8; v8::HandleScope handleScope; - v8::Handle<v8::Context> context = V8Proxy::GetContext(m_frame.get()); + v8::Handle<v8::Context> context = V8Proxy::context(m_frame.get()); if (context.IsEmpty()) return; v8::Context::Scope scope(context); v8::Handle<v8::Value> argv[] = { - V8Proxy::ToV8Object(V8ClassIndex::SQLTRANSACTION, transaction), - V8Proxy::ToV8Object(V8ClassIndex::SQLRESULTSET, resultSet) + V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLTRANSACTION, transaction), + V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLRESULTSET, resultSet) }; // Protect the frame until the callback returns. diff --git a/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp b/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp index 6c7aba2..4b84ebe 100644 --- a/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp +++ b/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp @@ -55,15 +55,15 @@ bool V8CustomSQLStatementErrorCallback::handleEvent(SQLTransaction* transaction, LOCK_V8; v8::HandleScope handleScope; - v8::Handle<v8::Context> context = V8Proxy::GetContext(m_frame.get()); + v8::Handle<v8::Context> context = V8Proxy::context(m_frame.get()); if (context.IsEmpty()) return true; v8::Context::Scope scope(context); v8::Handle<v8::Value> argv[] = { - V8Proxy::ToV8Object(V8ClassIndex::SQLTRANSACTION, transaction), - V8Proxy::ToV8Object(V8ClassIndex::SQLERROR, error) + V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLTRANSACTION, transaction), + V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLERROR, error) }; // Protect the frame until the callback returns. diff --git a/WebCore/bindings/v8/custom/V8CustomSQLTransactionCallback.cpp b/WebCore/bindings/v8/custom/V8CustomSQLTransactionCallback.cpp index c255483..704115e 100644 --- a/WebCore/bindings/v8/custom/V8CustomSQLTransactionCallback.cpp +++ b/WebCore/bindings/v8/custom/V8CustomSQLTransactionCallback.cpp @@ -56,14 +56,14 @@ void V8CustomSQLTransactionCallback::handleEvent(SQLTransaction* transaction, bo LOCK_V8; v8::HandleScope handleScope; - v8::Handle<v8::Context> context = V8Proxy::GetContext(m_frame.get()); + v8::Handle<v8::Context> context = V8Proxy::context(m_frame.get()); if (context.IsEmpty()) return; v8::Context::Scope scope(context); v8::Handle<v8::Value> argv[] = { - V8Proxy::ToV8Object(V8ClassIndex::SQLTRANSACTION, transaction) + V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLTRANSACTION, transaction) }; // Protect the frame until the callback returns. diff --git a/WebCore/bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp b/WebCore/bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp index 8dcb0a8..f30467c 100644 --- a/WebCore/bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp +++ b/WebCore/bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp @@ -55,14 +55,14 @@ void V8CustomSQLTransactionErrorCallback::handleEvent(SQLError* error) LOCK_V8; v8::HandleScope handleScope; - v8::Handle<v8::Context> context = V8Proxy::GetContext(m_frame.get()); + v8::Handle<v8::Context> context = V8Proxy::context(m_frame.get()); if (context.IsEmpty()) return; v8::Context::Scope scope(context); v8::Handle<v8::Value> argv[] = { - V8Proxy::ToV8Object(V8ClassIndex::SQLERROR, error) + V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLERROR, error) }; // Protect the frame until the callback returns. diff --git a/WebCore/bindings/v8/custom/V8CustomVoidCallback.cpp b/WebCore/bindings/v8/custom/V8CustomVoidCallback.cpp index b2972e4..925271f 100644 --- a/WebCore/bindings/v8/custom/V8CustomVoidCallback.cpp +++ b/WebCore/bindings/v8/custom/V8CustomVoidCallback.cpp @@ -51,7 +51,7 @@ void V8CustomVoidCallback::handleEvent() LOCK_V8; v8::HandleScope handleScope; - v8::Handle<v8::Context> context = V8Proxy::GetContext(m_frame.get()); + v8::Handle<v8::Context> context = V8Proxy::context(m_frame.get()); if (context.IsEmpty()) return; @@ -88,7 +88,7 @@ bool invokeCallback(v8::Persistent<v8::Object> callback, int argc, v8::Handle<v8 V8Proxy* proxy = V8Proxy::retrieve(); ASSERT(proxy); - v8::Handle<v8::Value> result = proxy->CallFunction(callbackFunction, thisObject, argc, argv); + v8::Handle<v8::Value> result = proxy->callFunction(callbackFunction, thisObject, argc, argv); callbackReturnValue = !result.IsEmpty() && result->IsBoolean() && result->BooleanValue(); diff --git a/WebCore/bindings/v8/custom/V8CustomXPathNSResolver.cpp b/WebCore/bindings/v8/custom/V8CustomXPathNSResolver.cpp new file mode 100644 index 0000000..3341924 --- /dev/null +++ b/WebCore/bindings/v8/custom/V8CustomXPathNSResolver.cpp @@ -0,0 +1,93 @@ +// Copyright (c) 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include "config.h" +#include "V8CustomXPathNSResolver.h" + +#if ENABLE(XPATH) + +#include "PlatformString.h" +#include "V8Binding.h" +#include "V8Proxy.h" + +namespace WebCore { + +PassRefPtr<V8CustomXPathNSResolver> V8CustomXPathNSResolver::create(v8::Handle<v8::Object> resolver) +{ + return adoptRef(new V8CustomXPathNSResolver(resolver)); +} + +V8CustomXPathNSResolver::V8CustomXPathNSResolver(v8::Handle<v8::Object> resolver) + : m_resolver(resolver) +{ +} + +V8CustomXPathNSResolver::~V8CustomXPathNSResolver() +{ +} + +String V8CustomXPathNSResolver::lookupNamespaceURI(const String& prefix) +{ + v8::Handle<v8::Function> lookupNamespaceURIFunc; + v8::Handle<v8::String> lookupNamespaceURIName = v8::String::New("lookupNamespaceURI"); + + // Check if the resolver has a function property named lookupNamespaceURI. + if (m_resolver->Has(lookupNamespaceURIName)) { + v8::Handle<v8::Value> lookupNamespaceURI = m_resolver->Get(lookupNamespaceURIName); + if (lookupNamespaceURI->IsFunction()) + lookupNamespaceURIFunc = v8::Handle<v8::Function>::Cast(lookupNamespaceURI); + } + + if (lookupNamespaceURIFunc.IsEmpty() && !m_resolver->IsFunction()) { + Frame* frame = V8Proxy::retrieveFrameForEnteredContext(); + logInfo(frame, "XPathNSResolver does not have a lookupNamespaceURI method.", String()); + return String(); + } + + // Catch exceptions from calling the namespace resolver. + v8::TryCatch try_catch; + try_catch.SetVerbose(true); // Print exceptions to console. + + const int argc = 1; + v8::Handle<v8::Value> argv[argc] = { v8String(prefix) }; + v8::Handle<v8::Function> function = lookupNamespaceURIFunc.IsEmpty() ? v8::Handle<v8::Function>::Cast(m_resolver) : lookupNamespaceURIFunc; + + V8Proxy* proxy = V8Proxy::retrieve(); + v8::Handle<v8::Value> retval = proxy->callFunction(function, m_resolver, argc, argv); + + // Eat exceptions from namespace resolver and return an empty string. This will most likely cause NAMESPACE_ERR. + if (try_catch.HasCaught()) + return String(); + + return toWebCoreStringWithNullCheck(retval); +} + +} // namespace WebCore + +#endif // ENABLE(XPATH) diff --git a/WebCore/bindings/v8/custom/V8DOMStringListCustom.cpp b/WebCore/bindings/v8/custom/V8CustomXPathNSResolver.h index 52d4399..f1dc65c 100644 --- a/WebCore/bindings/v8/custom/V8DOMStringListCustom.cpp +++ b/WebCore/bindings/v8/custom/V8CustomXPathNSResolver.h @@ -1,10 +1,10 @@ /* - * Copyright (C) 2007-2009 Google Inc. All rights reserved. - * + * Copyright (C) 2009 Google Inc. All rights reserved. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above @@ -14,7 +14,7 @@ * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -28,35 +28,36 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "config.h" -#include "DOMStringList.h" -#include "V8Binding.h" -#include "V8CustomBinding.h" -#include "V8Proxy.h" +#ifndef V8CustomXPathNSResolver_h +#define V8CustomXPathNSResolver_h + +#if ENABLE(XPATH) + +#include "XPathNSResolver.h" +#include <v8.h> +#include <wtf/Forward.h> +#include <wtf/RefPtr.h> namespace WebCore { -INDEXED_PROPERTY_GETTER(DOMStringList) -{ - INC_STATS("DOM.DOMStringList.IndexedPropertyGetter"); - DOMStringList* imp = V8Proxy::DOMWrapperToNative<DOMStringList>(info.Holder()); - return v8String(imp->item(index)); -} +class String; -CALLBACK_FUNC_DECL(DOMStringListItem) -{ - INC_STATS("DOM.DOMStringListItem()"); - if (!args.Length()) - return v8::Null(); +class V8CustomXPathNSResolver : public XPathNSResolver { +public: + static PassRefPtr<V8CustomXPathNSResolver> create(v8::Handle<v8::Object> resolver); - uint32_t index = args[0]->Uint32Value(); + virtual ~V8CustomXPathNSResolver(); + virtual String lookupNamespaceURI(const String& prefix); - DOMStringList* imp = V8Proxy::DOMWrapperToNative<DOMStringList>(args.Holder()); - if (index >= imp->length()) - return v8::Null(); +private: + V8CustomXPathNSResolver(v8::Handle<v8::Object> resolver); - return v8String(imp->item(index)); -} + v8::Handle<v8::Object> m_resolver; // Handle to resolver object. +}; } // namespace WebCore + +#endif // ENABLE(XPATH) + +#endif // V8CustomXPathNSResolver_h diff --git a/WebCore/bindings/v8/custom/V8DOMApplicationCacheCustom.cpp b/WebCore/bindings/v8/custom/V8DOMApplicationCacheCustom.cpp index 2ed1638..dd05b45 100644 --- a/WebCore/bindings/v8/custom/V8DOMApplicationCacheCustom.cpp +++ b/WebCore/bindings/v8/custom/V8DOMApplicationCacheCustom.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008, 2009 Google Inc. All rights reserved. + * Copyright (C) 2009 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -33,9 +33,10 @@ #if ENABLE(OFFLINE_WEB_APPLICATIONS) +#include "ApplicationCacheHost.h" #include "V8Binding.h" -#include "V8Document.h" #include "V8CustomBinding.h" +#include "V8Document.h" #include "V8ObjectEventListener.h" #include "V8Proxy.h" #include "V8Utilities.h" @@ -48,17 +49,10 @@ static const bool kFindOrCreate = false; static PassRefPtr<EventListener> argumentToEventListener(DOMApplicationCache* appcache, v8::Local<v8::Value> value, bool findOnly) { -#if 0 && ENABLE(WORKERS) - // FIXME: this is not tested yet - WorkerContextExecutionProxy* workerContextProxy = WorkerContextExecutionProxy::retrieve(); - if (workerContextProxy) - return workerContextProxy->findOrCreateObjectEventListener(value, false, findOnly); -#endif - V8Proxy* proxy = V8Proxy::retrieve(appcache->scriptExecutionContext()); if (proxy) - return findOnly ? proxy->FindObjectEventListener(value, false) - : proxy->FindOrCreateObjectEventListener(value, false); + return findOnly ? proxy->objectListeners()->findWrapper(value, false) + : proxy->objectListeners()->findOrCreateWrapper<V8ObjectEventListener>(proxy->frame(), value, false); return 0; } @@ -67,30 +61,28 @@ static v8::Local<v8::Object> eventListenerToV8Object(EventListener* listener) return (static_cast<V8ObjectEventListener*>(listener))->getListenerObject(); } -static inline String toEventType(v8::Local<v8::String> value) +static inline ApplicationCacheHost::EventID toEventID(v8::Local<v8::String> value) { String key = toWebCoreString(value); ASSERT(key.startsWith("on")); - return key.substring(2); + return DOMApplicationCache::toEventID(key.substring(2)); } // Handles appcache.onfooevent attribute getting ACCESSOR_GETTER(DOMApplicationCacheEventHandler) { INC_STATS("DOMApplicationCache.onevent_getter"); - DOMApplicationCache* appcache = V8Proxy::ToNativeObject<DOMApplicationCache>(V8ClassIndex::DOMAPPLICATIONCACHE, info.Holder()); - if (EventListener* listener = appcache->getAttributeEventListener(toEventType(name))) { - return eventListenerToV8Object(listener); - } - return v8::Null(); + DOMApplicationCache* appcache = V8DOMWrapper::convertToNativeObject<DOMApplicationCache>(V8ClassIndex::DOMAPPLICATIONCACHE, info.Holder()); + EventListener* listener = appcache->getAttributeEventListener(toEventID(name)); + return eventListenerToV8Object(listener); } // Handles appcache.onfooevent attribute setting ACCESSOR_SETTER(DOMApplicationCacheEventHandler) { INC_STATS("DOMApplicationCache.onevent_setter"); - DOMApplicationCache* appcache = V8Proxy::ToNativeObject<DOMApplicationCache>(V8ClassIndex::DOMAPPLICATIONCACHE, info.Holder()); - String eventType = toEventType(name); + DOMApplicationCache* appcache = V8DOMWrapper::convertToNativeObject<DOMApplicationCache>(V8ClassIndex::DOMAPPLICATIONCACHE, info.Holder()); + ApplicationCacheHost::EventID eventType = toEventID(name); if (EventListener* oldListener = appcache->getAttributeEventListener(eventType)) { v8::Local<v8::Object> object = eventListenerToV8Object(oldListener); @@ -111,7 +103,7 @@ ACCESSOR_SETTER(DOMApplicationCacheEventHandler) CALLBACK_FUNC_DECL(DOMApplicationCacheAddEventListener) { INC_STATS("DOMApplicationCache.addEventListener()"); - DOMApplicationCache* appcache = V8Proxy::ToNativeObject<DOMApplicationCache>(V8ClassIndex::DOMAPPLICATIONCACHE, args.Holder()); + DOMApplicationCache* appcache = V8DOMWrapper::convertToNativeObject<DOMApplicationCache>(V8ClassIndex::DOMAPPLICATIONCACHE, args.Holder()); RefPtr<EventListener> listener = argumentToEventListener(appcache, args[1], kFindOrCreate); if (listener) { @@ -127,7 +119,7 @@ CALLBACK_FUNC_DECL(DOMApplicationCacheAddEventListener) CALLBACK_FUNC_DECL(DOMApplicationCacheRemoveEventListener) { INC_STATS("DOMApplicationCache.removeEventListener()"); - DOMApplicationCache* appcache = V8Proxy::ToNativeObject<DOMApplicationCache>(V8ClassIndex::DOMAPPLICATIONCACHE, args.Holder()); + DOMApplicationCache* appcache = V8DOMWrapper::convertToNativeObject<DOMApplicationCache>(V8ClassIndex::DOMAPPLICATIONCACHE, args.Holder()); RefPtr<EventListener> listener = argumentToEventListener(appcache, args[1], kFindOnly); if (listener) { diff --git a/WebCore/bindings/v8/custom/V8DOMParserConstructor.cpp b/WebCore/bindings/v8/custom/V8DOMParserConstructor.cpp index f96b889..4af5c6e 100644 --- a/WebCore/bindings/v8/custom/V8DOMParserConstructor.cpp +++ b/WebCore/bindings/v8/custom/V8DOMParserConstructor.cpp @@ -39,7 +39,7 @@ namespace WebCore { CALLBACK_FUNC_DECL(DOMParserConstructor) { INC_STATS("DOM.DOMParser.Contructor"); - return V8Proxy::ConstructDOMObject<V8ClassIndex::DOMPARSER, DOMParser>(args); + return V8Proxy::constructDOMObject<V8ClassIndex::DOMPARSER, DOMParser>(args); } } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp index c13c3b2..7d0b9e6 100644 --- a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp +++ b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp @@ -64,12 +64,12 @@ v8::Handle<v8::Value> V8Custom::WindowSetTimeoutImpl(const v8::Arguments& args, if (argumentCount < 1) return v8::Undefined(); - DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, args.Holder()); + DOMWindow* imp = V8DOMWrapper::convertToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, args.Holder()); if (!imp->frame()) return v8::Undefined(); - if (!V8Proxy::CanAccessFrame(imp->frame(), true)) + if (!V8Proxy::canAccessFrame(imp->frame(), true)) return v8::Undefined(); ScriptExecutionContext* scriptContext = static_cast<ScriptExecutionContext*>(imp->frame()->document()); @@ -124,7 +124,7 @@ static bool isAscii(const String& str) static v8::Handle<v8::Value> convertBase64(const String& str, bool encode) { if (!isAscii(str)) { - V8Proxy::SetDOMException(INVALID_CHARACTER_ERR); + V8Proxy::setDOMException(INVALID_CHARACTER_ERR); return notHandledByInterceptor(); } @@ -137,7 +137,7 @@ static v8::Handle<v8::Value> convertBase64(const String& str, bool encode) base64Encode(inputCharacters, outputCharacters); else { if (!base64Decode(inputCharacters, outputCharacters)) - return throwError("Cannot decode base64", V8Proxy::GENERAL_ERROR); + return throwError("Cannot decode base64", V8Proxy::GeneralError); } return v8String(String(outputCharacters.data(), outputCharacters.size())); @@ -161,20 +161,20 @@ ACCESSOR_GETTER(DOMWindowCrypto) ACCESSOR_SETTER(DOMWindowLocation) { - v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper(V8ClassIndex::DOMWINDOW, info.This()); + v8::Handle<v8::Object> holder = V8DOMWrapper::lookupDOMWrapper(V8ClassIndex::DOMWINDOW, info.This()); if (holder.IsEmpty()) return; - DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, holder); + DOMWindow* imp = V8DOMWrapper::convertToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, holder); WindowSetLocation(imp, toWebCoreString(value)); } ACCESSOR_SETTER(DOMWindowOpener) { - DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, info.Holder()); + DOMWindow* imp = V8DOMWrapper::convertToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, info.Holder()); - if (!V8Proxy::CanAccessFrame(imp->frame(), true)) + if (!V8Proxy::canAccessFrame(imp->frame(), true)) return; // Opener can be shadowed if it is in the same domain. @@ -197,9 +197,9 @@ ACCESSOR_SETTER(DOMWindowOpener) CALLBACK_FUNC_DECL(DOMWindowAddEventListener) { INC_STATS("DOM.DOMWindow.addEventListener()"); - DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, args.Holder()); + DOMWindow* imp = V8DOMWrapper::convertToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, args.Holder()); - if (!V8Proxy::CanAccessFrame(imp->frame(), true)) + if (!V8Proxy::canAccessFrame(imp->frame(), true)) return v8::Undefined(); if (!imp->frame()) @@ -214,7 +214,7 @@ CALLBACK_FUNC_DECL(DOMWindowAddEventListener) if (!proxy) return v8::Undefined(); - RefPtr<EventListener> listener = proxy->FindOrCreateV8EventListener(args[1], false); + RefPtr<EventListener> listener = proxy->eventListeners()->findOrCreateWrapper<V8EventListener>(proxy->frame(), args[1], false); if (listener) { String eventType = toWebCoreString(args[0]); @@ -229,9 +229,9 @@ CALLBACK_FUNC_DECL(DOMWindowAddEventListener) CALLBACK_FUNC_DECL(DOMWindowRemoveEventListener) { INC_STATS("DOM.DOMWindow.removeEventListener()"); - DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, args.Holder()); + DOMWindow* imp = V8DOMWrapper::convertToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, args.Holder()); - if (!V8Proxy::CanAccessFrame(imp->frame(), true)) + if (!V8Proxy::canAccessFrame(imp->frame(), true)) return v8::Undefined(); if (!imp->frame()) @@ -245,7 +245,7 @@ CALLBACK_FUNC_DECL(DOMWindowRemoveEventListener) if (!proxy) return v8::Undefined(); - RefPtr<EventListener> listener = proxy->FindV8EventListener(args[1], false); + RefPtr<EventListener> listener = proxy->eventListeners()->findWrapper(args[1], false); if (listener) { String eventType = toWebCoreString(args[0]); @@ -259,13 +259,12 @@ CALLBACK_FUNC_DECL(DOMWindowRemoveEventListener) CALLBACK_FUNC_DECL(DOMWindowPostMessage) { INC_STATS("DOM.DOMWindow.postMessage()"); - DOMWindow* window = V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, args.Holder()); + DOMWindow* window = V8DOMWrapper::convertToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, args.Holder()); DOMWindow* source = V8Proxy::retrieveFrameForCallingContext()->domWindow(); ASSERT(source->frame()); v8::TryCatch tryCatch; - String message = toWebCoreString(args[0]); MessagePort* port = 0; String targetOrigin; @@ -275,11 +274,11 @@ CALLBACK_FUNC_DECL(DOMWindowPostMessage) // or // postMessage(message, targetOrigin); if (args.Length() > 2) { - if (V8Proxy::IsWrapperOfType(args[1], V8ClassIndex::MESSAGEPORT)) - port = V8Proxy::ToNativeObject<MessagePort>(V8ClassIndex::MESSAGEPORT, args[1]); - targetOrigin = valueToStringWithNullOrUndefinedCheck(args[2]); + if (V8DOMWrapper::isWrapperOfType(args[1], V8ClassIndex::MESSAGEPORT)) + port = V8DOMWrapper::convertToNativeObject<MessagePort>(V8ClassIndex::MESSAGEPORT, v8::Handle<v8::Object>::Cast(args[1])); + targetOrigin = toWebCoreStringWithNullOrUndefinedCheck(args[2]); } else { - targetOrigin = valueToStringWithNullOrUndefinedCheck(args[1]); + targetOrigin = toWebCoreStringWithNullOrUndefinedCheck(args[1]); } if (tryCatch.HasCaught()) @@ -288,7 +287,7 @@ CALLBACK_FUNC_DECL(DOMWindowPostMessage) ExceptionCode ec = 0; window->postMessage(message, port, targetOrigin, source, ec); if (ec) - V8Proxy::SetDOMException(ec); + V8Proxy::setDOMException(ec); return v8::Undefined(); } @@ -296,13 +295,13 @@ CALLBACK_FUNC_DECL(DOMWindowPostMessage) CALLBACK_FUNC_DECL(DOMWindowAtob) { INC_STATS("DOM.DOMWindow.atob()"); - DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, args.Holder()); + DOMWindow* imp = V8DOMWrapper::convertToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, args.Holder()); - if (!V8Proxy::CanAccessFrame(imp->frame(), true)) + if (!V8Proxy::canAccessFrame(imp->frame(), true)) return v8::Undefined(); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::SYNTAX_ERROR); + return throwError("Not enough arguments", V8Proxy::SyntaxError); if (args[0]->IsNull()) return v8String(""); @@ -314,13 +313,13 @@ CALLBACK_FUNC_DECL(DOMWindowAtob) CALLBACK_FUNC_DECL(DOMWindowBtoa) { INC_STATS("DOM.DOMWindow.btoa()"); - DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, args.Holder()); + DOMWindow* imp = V8DOMWrapper::convertToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, args.Holder()); - if (!V8Proxy::CanAccessFrame(imp->frame(), true)) + if (!V8Proxy::canAccessFrame(imp->frame(), true)) return v8::Undefined(); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::SYNTAX_ERROR); + return throwError("Not enough arguments", V8Proxy::SyntaxError); if (args[0]->IsNull()) return v8String(""); @@ -373,11 +372,11 @@ static String eventNameFromAttributeName(const String& name) ACCESSOR_SETTER(DOMWindowEventHandler) { - v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper(V8ClassIndex::DOMWINDOW, info.This()); + v8::Handle<v8::Object> holder = V8DOMWrapper::lookupDOMWrapper(V8ClassIndex::DOMWINDOW, info.This()); if (holder.IsEmpty()) return; - DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, holder); + DOMWindow* imp = V8DOMWrapper::convertToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, holder); if (!imp->frame()) return; @@ -396,8 +395,7 @@ ACCESSOR_SETTER(DOMWindowEventHandler) if (!proxy) return; - RefPtr<EventListener> listener = - proxy->FindOrCreateV8EventListener(value, true); + RefPtr<EventListener> listener = proxy->eventListeners()->findOrCreateWrapper<V8EventListener>(proxy->frame(), value, true); if (listener) imp->setAttributeEventListener(eventType, listener); } @@ -405,11 +403,11 @@ ACCESSOR_SETTER(DOMWindowEventHandler) ACCESSOR_GETTER(DOMWindowEventHandler) { - v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper(V8ClassIndex::DOMWINDOW, info.This()); + v8::Handle<v8::Object> holder = V8DOMWrapper::lookupDOMWrapper(V8ClassIndex::DOMWINDOW, info.This()); if (holder.IsEmpty()) return v8::Undefined(); - DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, holder); + DOMWindow* imp = V8DOMWrapper::convertToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, holder); if (!imp->frame()) return v8::Undefined(); @@ -421,7 +419,7 @@ ACCESSOR_GETTER(DOMWindowEventHandler) String eventType = eventNameFromAttributeName(key); EventListener* listener = imp->getAttributeEventListener(eventType); - return V8Proxy::EventListenerToV8Object(listener); + return V8DOMWrapper::convertEventListenerToV8Object(listener); } static bool canShowModalDialogNow(const Frame* frame) @@ -518,7 +516,7 @@ static Frame* createWindow(Frame* callingFrame, // Set dialog arguments on the global object of the new frame. if (!dialogArgs.IsEmpty()) { - v8::Local<v8::Context> context = V8Proxy::GetContext(newFrame); + v8::Local<v8::Context> context = V8Proxy::context(newFrame); if (!context.IsEmpty()) { v8::Context::Scope scope(context); context->Global()->Set(v8::String::New("dialogArguments"), dialogArgs); @@ -544,11 +542,11 @@ static Frame* createWindow(Frame* callingFrame, CALLBACK_FUNC_DECL(DOMWindowShowModalDialog) { INC_STATS("DOM.DOMWindow.showModalDialog()"); - DOMWindow* window = V8Proxy::ToNativeObject<DOMWindow>( + DOMWindow* window = V8DOMWrapper::convertToNativeObject<DOMWindow>( V8ClassIndex::DOMWINDOW, args.Holder()); Frame* frame = window->frame(); - if (!frame || !V8Proxy::CanAccessFrame(frame, true)) + if (!frame || !V8Proxy::canAccessFrame(frame, true)) return v8::Undefined(); Frame* callingFrame = V8Proxy::retrieveFrameForCallingContext(); @@ -562,9 +560,9 @@ CALLBACK_FUNC_DECL(DOMWindowShowModalDialog) if (!canShowModalDialogNow(frame) || !allowPopUp()) return v8::Undefined(); - String url = valueToStringWithNullOrUndefinedCheck(args[0]); + String url = toWebCoreStringWithNullOrUndefinedCheck(args[0]); v8::Local<v8::Value> dialogArgs = args[1]; - String featureArgs = valueToStringWithNullOrUndefinedCheck(args[2]); + String featureArgs = toWebCoreStringWithNullOrUndefinedCheck(args[2]); const HashMap<String, String> features = parseModalDialogFeatures(featureArgs); @@ -611,7 +609,7 @@ CALLBACK_FUNC_DECL(DOMWindowShowModalDialog) // Hold on to the context of the dialog window long enough to retrieve the // value of the return value property. - v8::Local<v8::Context> context = V8Proxy::GetContext(dialogFrame); + v8::Local<v8::Context> context = V8Proxy::context(dialogFrame); // Run the dialog. dialogFrame->page()->chrome()->runModal(); @@ -633,10 +631,10 @@ CALLBACK_FUNC_DECL(DOMWindowShowModalDialog) CALLBACK_FUNC_DECL(DOMWindowOpen) { INC_STATS("DOM.DOMWindow.open()"); - DOMWindow* parent = V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, args.Holder()); + DOMWindow* parent = V8DOMWrapper::convertToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, args.Holder()); Frame* frame = parent->frame(); - if (!frame || !V8Proxy::CanAccessFrame(frame, true)) + if (!frame || !V8Proxy::canAccessFrame(frame, true)) return v8::Undefined(); Frame* callingFrame = V8Proxy::retrieveFrameForCallingContext(); @@ -651,7 +649,7 @@ CALLBACK_FUNC_DECL(DOMWindowOpen) if (!page) return v8::Undefined(); - String urlString = valueToStringWithNullOrUndefinedCheck(args[0]); + String urlString = toWebCoreStringWithNullOrUndefinedCheck(args[0]); AtomicString frameName = (args[1]->IsUndefined() || args[1]->IsNull()) ? "_blank" : AtomicString(toWebCoreString(args[1])); // Because FrameTree::find() returns true for empty strings, we must check @@ -691,7 +689,7 @@ CALLBACK_FUNC_DECL(DOMWindowOpen) frame->loader()->scheduleLocationChange(completedUrl, referrer, false, userGesture); } - return V8Proxy::ToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow()); + return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow()); } // In the case of a named frame or a new window, we'll use the @@ -700,7 +698,7 @@ CALLBACK_FUNC_DECL(DOMWindowOpen) // Parse the values, and then work with a copy of the parsed values // so we can restore the values we may not want to overwrite after // we do the multiple monitor fixes. - WindowFeatures rawFeatures(valueToStringWithNullOrUndefinedCheck(args[2])); + WindowFeatures rawFeatures(toWebCoreStringWithNullOrUndefinedCheck(args[2])); WindowFeatures windowFeatures(rawFeatures); FloatRect screenRect = screenAvailableRect(page->mainFrame()->view()); @@ -751,18 +749,18 @@ CALLBACK_FUNC_DECL(DOMWindowOpen) if (!frame) return v8::Undefined(); - return V8Proxy::ToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow()); + return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow()); } INDEXED_PROPERTY_GETTER(DOMWindow) { INC_STATS("DOM.DOMWindow.IndexedPropertyGetter"); - v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper(V8ClassIndex::DOMWINDOW, info.This()); + v8::Handle<v8::Object> holder = V8DOMWrapper::lookupDOMWrapper(V8ClassIndex::DOMWINDOW, info.This()); if (holder.IsEmpty()) return notHandledByInterceptor(); - DOMWindow* window = V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, holder); + DOMWindow* window = V8DOMWrapper::convertToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, holder); if (!window) return notHandledByInterceptor(); @@ -772,7 +770,7 @@ INDEXED_PROPERTY_GETTER(DOMWindow) Frame* child = frame->tree()->child(index); if (child) - return V8Proxy::ToV8Object(V8ClassIndex::DOMWINDOW, child->domWindow()); + return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, child->domWindow()); return notHandledByInterceptor(); } @@ -782,11 +780,11 @@ NAMED_PROPERTY_GETTER(DOMWindow) { INC_STATS("DOM.DOMWindow.NamedPropertyGetter"); - v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper(V8ClassIndex::DOMWINDOW, info.This()); + v8::Handle<v8::Object> holder = V8DOMWrapper::lookupDOMWrapper(V8ClassIndex::DOMWINDOW, info.This()); if (holder.IsEmpty()) return notHandledByInterceptor(); - DOMWindow* window = V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, holder); + DOMWindow* window = V8DOMWrapper::convertToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, holder); if (!window) return notHandledByInterceptor(); @@ -799,7 +797,7 @@ NAMED_PROPERTY_GETTER(DOMWindow) AtomicString propName = v8StringToAtomicWebCoreString(name); Frame* child = frame->tree()->child(propName); if (child) - return V8Proxy::ToV8Object(V8ClassIndex::DOMWINDOW, child->domWindow()); + return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, child->domWindow()); // Search IDL functions defined in the prototype v8::Handle<v8::Value> result = holder->GetRealNamedPropertyInPrototypeChain(name); @@ -812,9 +810,9 @@ NAMED_PROPERTY_GETTER(DOMWindow) RefPtr<HTMLCollection> items = doc->windowNamedItems(propName); if (items->length() >= 1) { if (items->length() == 1) - return V8Proxy::NodeToV8Object(items->firstItem()); + return V8DOMWrapper::convertNodeToV8Object(items->firstItem()); else - return V8Proxy::ToV8Object(V8ClassIndex::HTMLCOLLECTION, items.get()); + return V8DOMWrapper::convertToV8Object(V8ClassIndex::HTMLCOLLECTION, items.release()); } } @@ -855,9 +853,9 @@ CALLBACK_FUNC_DECL(DOMWindowSetInterval) void V8Custom::ClearTimeoutImpl(const v8::Arguments& args) { - v8::Handle<v8::Value> holder = args.Holder(); - DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, holder); - if (!V8Proxy::CanAccessFrame(imp->frame(), true)) + v8::Handle<v8::Object> holder = args.Holder(); + DOMWindow* imp = V8DOMWrapper::convertToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, holder); + if (!V8Proxy::canAccessFrame(imp->frame(), true)) return; ScriptExecutionContext* context = static_cast<ScriptExecutionContext*>(imp->frame()->document()); int handle = toInt32(args[0]); @@ -882,11 +880,11 @@ CALLBACK_FUNC_DECL(DOMWindowClearInterval) NAMED_ACCESS_CHECK(DOMWindow) { ASSERT(V8ClassIndex::FromInt(data->Int32Value()) == V8ClassIndex::DOMWINDOW); - v8::Handle<v8::Value> window = V8Proxy::LookupDOMWrapper(V8ClassIndex::DOMWINDOW, host); + v8::Handle<v8::Object> window = V8DOMWrapper::lookupDOMWrapper(V8ClassIndex::DOMWINDOW, host); if (window.IsEmpty()) return false; // the frame is gone. - DOMWindow* targetWindow = V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, window); + DOMWindow* targetWindow = V8DOMWrapper::convertToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, window); ASSERT(targetWindow); @@ -902,17 +900,17 @@ NAMED_ACCESS_CHECK(DOMWindow) return true; } - return V8Proxy::CanAccessFrame(target, false); + return V8Proxy::canAccessFrame(target, false); } INDEXED_ACCESS_CHECK(DOMWindow) { ASSERT(V8ClassIndex::FromInt(data->Int32Value()) == V8ClassIndex::DOMWINDOW); - v8::Handle<v8::Value> window = V8Proxy::LookupDOMWrapper(V8ClassIndex::DOMWINDOW, host); + v8::Handle<v8::Object> window = V8DOMWrapper::lookupDOMWrapper(V8ClassIndex::DOMWINDOW, host); if (window.IsEmpty()) return false; - DOMWindow* targetWindow = V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, window); + DOMWindow* targetWindow = V8DOMWrapper::convertToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, window); ASSERT(targetWindow); @@ -924,7 +922,7 @@ INDEXED_ACCESS_CHECK(DOMWindow) if ((type == v8::ACCESS_GET || type == v8::ACCESS_HAS) && target->tree()->child(index)) return true; - return V8Proxy::CanAccessFrame(target, false); + return V8Proxy::canAccessFrame(target, false); } } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8DataGridColumnListCustom.cpp b/WebCore/bindings/v8/custom/V8DataGridColumnListCustom.cpp new file mode 100644 index 0000000..1dde996 --- /dev/null +++ b/WebCore/bindings/v8/custom/V8DataGridColumnListCustom.cpp @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "DataGridColumnList.h" + +#include "Document.h" +#include "V8Binding.h" +#include "V8CustomBinding.h" +#include "V8Proxy.h" + +#if ENABLE(DATAGRID) + +namespace WebCore { + +INDEXED_PROPERTY_GETTER(DataGridColumnList) +{ + INC_STATS("DataGridColumnList.IndexedPropertyGetter"); + DataGridColumnList* imp = V8DOMWrapper::convertToNativeObject<DataGridColumnList>(V8ClassIndex::DATAGRIDCOLUMNLIST, info.Holder()); + DataGridColumn* result = imp->item(index); + if (!result) + return notHandledByInterceptor(); + return V8DOMWrapper::convertToV8Object(V8ClassIndex::DATAGRIDCOLUMN, result); +} + +NAMED_PROPERTY_GETTER(DataGridColumnList) +{ + INC_STATS("DataGridColumnList.NamedPropertyGetter"); + // Search the prototype chain first. + v8::Handle<v8::Value> value = info.Holder()->GetRealNamedPropertyInPrototypeChain(name); + if (!value.IsEmpty()) + return value; + + // Then look for IDL defined properties on the object itself. + if (info.Holder()->HasRealNamedCallbackProperty(name)) + return notHandledByInterceptor(); + + // Finally, look up a column by name. + DataGridColumnList* imp = V8DOMWrapper::convertToNativeObject<DataGridColumnList>(V8ClassIndex::DATAGRIDCOLUMNLIST, info.Holder()); + DataGridColumn* result = imp->itemWithName(toWebCoreString(name)); + if (!result) + return notHandledByInterceptor(); + return V8DOMWrapper::convertToV8Object(V8ClassIndex::DATAGRIDCOLUMN, result); +} + +} // namespace WebCore + +#endif // ENABLE(DATAGRID) diff --git a/WebCore/bindings/v8/custom/V8DatabaseCustom.cpp b/WebCore/bindings/v8/custom/V8DatabaseCustom.cpp index 6996d35..dbaa942 100644 --- a/WebCore/bindings/v8/custom/V8DatabaseCustom.cpp +++ b/WebCore/bindings/v8/custom/V8DatabaseCustom.cpp @@ -32,14 +32,23 @@ #if ENABLE(DATABASE) +#ifdef MANUAL_MERGE_REQUIRED #include "v8_binding.h" #include "v8_proxy.h" +#else // MANUAL_MERGE_REQUIRED +#endif // MANUAL_MERGE_REQUIRED #include "Database.h" +#ifdef MANUAL_MERGE_REQUIRED #include "V8CustomBinding.h" +#else // MANUAL_MERGE_REQUIRED +#include "V8Binding.h" +#include "V8CustomBinding.h" +#endif // MANUAL_MERGE_REQUIRED #include "V8CustomSQLTransactionCallback.h" #include "V8CustomSQLTransactionErrorCallback.h" #include "V8CustomVoidCallback.h" +#include "V8Proxy.h" namespace WebCore { @@ -53,37 +62,33 @@ CALLBACK_FUNC_DECL(DatabaseTransaction) { INC_STATS("DOM.Database.transaction()"); - if (args.Length() == 0) { - V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Transaction callback is required."); - return v8::Undefined(); - } + if (!args.Length()) + return throwError("Transaction callback is required.", V8Proxy::SyntaxError); - if (!args[0]->IsObject()) { - V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, "Transaction callback must be of valid type."); - return v8::Undefined(); - } + if (!args[0]->IsObject()) + return throwError("Transaction callback must be of valid type."); - Database* database = V8Proxy::ToNativeObject<Database>(V8ClassIndex::DATABASE, args.Holder()); + Database* database = V8DOMWrapper::convertToNativeObject<Database>(V8ClassIndex::DATABASE, args.Holder()); - Frame* frame = V8Proxy::retrieveFrame(); + Frame* frame = V8Proxy::retrieveFrameForCurrentContext(); + if (!frame) + return v8::Undefined(); RefPtr<V8CustomSQLTransactionCallback> callback = V8CustomSQLTransactionCallback::create(args[0], frame); RefPtr<V8CustomSQLTransactionErrorCallback> errorCallback; if (args.Length() > 1) { - if (!args[1]->IsObject()) { - V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, "Transaction error callback must be of valid type."); - return v8::Undefined(); - } + if (!args[1]->IsObject()) + return throwError("Transaction error callback must be of valid type."); + errorCallback = V8CustomSQLTransactionErrorCallback::create(args[1], frame); } RefPtr<V8CustomVoidCallback> successCallback; if (args.Length() > 2) { - if (!args[1]->IsObject()) { - V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, "Transaction success callback must be of valid type."); - return v8::Undefined(); - } + if (!args[1]->IsObject()) + return throwError("Transaction success callback must be of valid type."); + successCallback = V8CustomVoidCallback::create(args[2], frame); } diff --git a/WebCore/bindings/v8/custom/V8DedicatedWorkerContextCustom.cpp b/WebCore/bindings/v8/custom/V8DedicatedWorkerContextCustom.cpp new file mode 100644 index 0000000..f13e45e --- /dev/null +++ b/WebCore/bindings/v8/custom/V8DedicatedWorkerContextCustom.cpp @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#if ENABLE(WORKERS) + +#include "WorkerContextExecutionProxy.h" + +#include "DedicatedWorkerContext.h" +#include "V8Proxy.h" +#include "V8WorkerContextEventListener.h" + +namespace WebCore { + +ACCESSOR_GETTER(DedicatedWorkerContextOnmessage) +{ + INC_STATS(L"DOM.DedicatedWorkerContext.onmessage._get"); + DedicatedWorkerContext* workerContext = V8DOMWrapper::convertToNativeObject<DedicatedWorkerContext>(V8ClassIndex::DEDICATEDWORKERCONTEXT, info.Holder()); + if (workerContext->onmessage()) { + V8WorkerContextEventListener* listener = static_cast<V8WorkerContextEventListener*>(workerContext->onmessage()); + v8::Local<v8::Object> v8Listener = listener->getListenerObject(); + return v8Listener; + } + return v8::Undefined(); +} + +ACCESSOR_SETTER(DedicatedWorkerContextOnmessage) +{ + INC_STATS(L"DOM.DedicatedWorkerContext.onmessage._set"); + DedicatedWorkerContext* workerContext = V8DOMWrapper::convertToNativeObject<DedicatedWorkerContext>(V8ClassIndex::DEDICATEDWORKERCONTEXT, info.Holder()); + V8WorkerContextEventListener* oldListener = static_cast<V8WorkerContextEventListener*>(workerContext->onmessage()); + if (value->IsNull()) { + if (workerContext->onmessage()) { + v8::Local<v8::Object> oldV8Listener = oldListener->getListenerObject(); + removeHiddenDependency(info.Holder(), oldV8Listener, V8Custom::kDedicatedWorkerContextRequestCacheIndex); + } + + // Clear the listener. + workerContext->setOnmessage(0); + } else { + RefPtr<V8EventListener> listener = workerContext->script()->proxy()->findOrCreateEventListener(v8::Local<v8::Object>::Cast(value), false, false); + if (listener) { + if (oldListener) { + v8::Local<v8::Object> oldV8Listener = oldListener->getListenerObject(); + removeHiddenDependency(info.Holder(), oldV8Listener, V8Custom::kDedicatedWorkerContextRequestCacheIndex); + } + + workerContext->setOnmessage(listener); + createHiddenDependency(info.Holder(), value, V8Custom::kDedicatedWorkerContextRequestCacheIndex); + } + } +} + +} // namespace WebCore + +#endif // ENABLE(WORKERS) diff --git a/WebCore/bindings/v8/custom/V8DocumentCustom.cpp b/WebCore/bindings/v8/custom/V8DocumentCustom.cpp index 3eadce7..60fc22f 100644 --- a/WebCore/bindings/v8/custom/V8DocumentCustom.cpp +++ b/WebCore/bindings/v8/custom/V8DocumentCustom.cpp @@ -32,13 +32,13 @@ #include "Document.h" #include "ExceptionCode.h" -#include "JSXPathNSResolver.h" #include "Node.h" #include "XPathNSResolver.h" #include "XPathResult.h" #include "V8Binding.h" #include "V8CustomBinding.h" +#include "V8CustomXPathNSResolver.h" #include "V8Node.h" #include "V8Proxy.h" @@ -54,52 +54,61 @@ namespace WebCore { CALLBACK_FUNC_DECL(DocumentEvaluate) { INC_STATS("DOM.Document.evaluate()"); +#ifdef MANUAL_MERGE_REQUIRED #if ENABLE(XPATH) Document* document = V8Proxy::DOMWrapperToNode<Document>(args.Holder()); +#else // MANUAL_MERGE_REQUIRED + + RefPtr<Document> document = V8DOMWrapper::convertDOMWrapperToNode<Document>(args.Holder()); +#endif // MANUAL_MERGE_REQUIRED ExceptionCode ec = 0; String expression = toWebCoreString(args[0]); - Node* contextNode = 0; + RefPtr<Node> contextNode; if (V8Node::HasInstance(args[1])) - contextNode = V8Proxy::DOMWrapperToNode<Node>(args[1]); + contextNode = V8DOMWrapper::convertDOMWrapperToNode<Node>(v8::Handle<v8::Object>::Cast(args[1])); - XPathNSResolver* resolver = 0; + RefPtr<XPathNSResolver> resolver; if (V8XPathNSResolver::HasInstance(args[2])) - resolver = V8Proxy::ToNativeObject<XPathNSResolver>(V8ClassIndex::XPATHNSRESOLVER, args[2]); + resolver = V8DOMWrapper::convertToNativeObject<XPathNSResolver>(V8ClassIndex::XPATHNSRESOLVER, v8::Handle<v8::Object>::Cast(args[2])); else if (args[2]->IsObject()) - resolver = new JSXPathNSResolver(args[2]->ToObject()); + resolver = V8CustomXPathNSResolver::create(args[2]->ToObject()); else if (!args[2]->IsNull() && !args[2]->IsUndefined()) return throwError(TYPE_MISMATCH_ERR); int type = toInt32(args[3]); - XPathResult* inResult = 0; + RefPtr<XPathResult> inResult; if (V8XPathResult::HasInstance(args[4])) - inResult = V8Proxy::ToNativeObject<XPathResult>(V8ClassIndex::XPATHRESULT, args[4]); + inResult = V8DOMWrapper::convertToNativeObject<XPathResult>(V8ClassIndex::XPATHRESULT, v8::Handle<v8::Object>::Cast(args[4])); v8::TryCatch exceptionCatcher; - RefPtr<XPathResult> result = document->evaluate(expression, contextNode, resolver, type, inResult, ec); + RefPtr<XPathResult> result = document->evaluate(expression, contextNode.get(), resolver.get(), type, inResult.get(), ec); if (exceptionCatcher.HasCaught()) return throwError(exceptionCatcher.Exception()); if (ec) return throwError(ec); +#ifdef MANUAL_MERGE_REQUIRED return V8Proxy::ToV8Object(V8ClassIndex::XPATHRESULT, result.get()); #else return throwError(NOT_SUPPORTED_ERR); #endif +#else // MANUAL_MERGE_REQUIRED + return V8DOMWrapper::convertToV8Object(V8ClassIndex::XPATHRESULT, result.release()); +#endif // MANUAL_MERGE_REQUIRED } CALLBACK_FUNC_DECL(DocumentGetCSSCanvasContext) { INC_STATS("DOM.Document.getCSSCanvasContext"); - v8::Handle<v8::Value> holder = args.Holder(); - Document* imp = V8Proxy::DOMWrapperToNode<Document>(holder); + v8::Handle<v8::Object> holder = args.Holder(); + Document* imp = V8DOMWrapper::convertDOMWrapperToNode<Document>(holder); String contextId = toWebCoreString(args[0]); String name = toWebCoreString(args[1]); int width = toInt32(args[2]); int height = toInt32(args[3]); CanvasRenderingContext2D* result = imp->getCSSCanvasContext(contextId, name, width, height); - return V8Proxy::ToV8Object(V8ClassIndex::CANVASRENDERINGCONTEXT2D, result); + return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASRENDERINGCONTEXT2D, result); } } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8DocumentLocationCustom.cpp b/WebCore/bindings/v8/custom/V8DocumentLocationCustom.cpp index dfcacef..440bbdc 100644 --- a/WebCore/bindings/v8/custom/V8DocumentLocationCustom.cpp +++ b/WebCore/bindings/v8/custom/V8DocumentLocationCustom.cpp @@ -34,17 +34,17 @@ namespace WebCore { ACCESSOR_GETTER(DocumentLocation) { - Document* document = V8Proxy::DOMWrapperToNative<Document>(info.Holder()); + Document* document = V8DOMWrapper::convertDOMWrapperToNative<Document>(info.Holder()); if (!document->frame()) return v8::Null(); DOMWindow* window = document->frame()->domWindow(); - return V8Proxy::ToV8Object(V8ClassIndex::LOCATION, window->location()); + return V8DOMWrapper::convertToV8Object(V8ClassIndex::LOCATION, window->location()); } ACCESSOR_SETTER(DocumentLocation) { - Document* document = V8Proxy::DOMWrapperToNative<Document>(info.Holder()); + Document* document = V8DOMWrapper::convertDOMWrapperToNative<Document>(info.Holder()); if (!document->frame()) return; diff --git a/WebCore/bindings/v8/custom/V8ElementCustom.cpp b/WebCore/bindings/v8/custom/V8ElementCustom.cpp index 64a9d3d..e17e0a9 100644 --- a/WebCore/bindings/v8/custom/V8ElementCustom.cpp +++ b/WebCore/bindings/v8/custom/V8ElementCustom.cpp @@ -34,7 +34,6 @@ #include "Attr.h" #include "CSSHelper.h" #include "Document.h" -#include "EventListener.h" #include "ExceptionCode.h" #include "HTMLFrameElementBase.h" #include "HTMLNames.h" @@ -43,7 +42,6 @@ #include "V8Attr.h" #include "V8Binding.h" #include "V8CustomBinding.h" -#include "V8CustomEventListener.h" #include "V8Proxy.h" #include <wtf/RefPtr.h> @@ -53,7 +51,7 @@ namespace WebCore { CALLBACK_FUNC_DECL(ElementSetAttribute) { INC_STATS("DOM.Element.setAttribute()"); - Element* element = V8Proxy::DOMWrapperToNode<Element>(args.Holder()); + Element* element = V8DOMWrapper::convertDOMWrapperToNode<Element>(args.Holder()); String name = toWebCoreString(args[0]); String value = toWebCoreString(args[1]); @@ -74,8 +72,8 @@ CALLBACK_FUNC_DECL(ElementSetAttributeNode) if (!V8Attr::HasInstance(args[0])) return throwError(TYPE_MISMATCH_ERR); - Attr* newAttr = V8Proxy::DOMWrapperToNode<Attr>(args[0]); - Element* element = V8Proxy::DOMWrapperToNode<Element>(args.Holder()); + Attr* newAttr = V8DOMWrapper::convertDOMWrapperToNode<Attr>(v8::Handle<v8::Object>::Cast(args[0])); + Element* element = V8DOMWrapper::convertDOMWrapperToNode<Element>(args.Holder()); if (!allowSettingSrcToJavascriptURL(element, newAttr->name(), newAttr->value())) return v8::Undefined(); @@ -85,13 +83,13 @@ CALLBACK_FUNC_DECL(ElementSetAttributeNode) if (ec) throwError(ec); - return V8Proxy::NodeToV8Object(result.get()); + return V8DOMWrapper::convertNodeToV8Object(result.release()); } CALLBACK_FUNC_DECL(ElementSetAttributeNS) { INC_STATS("DOM.Element.setAttributeNS()"); - Element* element = V8Proxy::DOMWrapperToNode<Element>(args.Holder()); + Element* element = V8DOMWrapper::convertDOMWrapperToNode<Element>(args.Holder()); String namespaceURI = toWebCoreStringWithNullCheck(args[0]); String qualifiedName = toWebCoreString(args[1]); String value = toWebCoreString(args[2]); @@ -113,8 +111,8 @@ CALLBACK_FUNC_DECL(ElementSetAttributeNodeNS) if (!V8Attr::HasInstance(args[0])) return throwError(TYPE_MISMATCH_ERR); - Attr* newAttr = V8Proxy::DOMWrapperToNode<Attr>(args[0]); - Element* element = V8Proxy::DOMWrapperToNode<Element>(args.Holder()); + Attr* newAttr = V8DOMWrapper::convertDOMWrapperToNode<Attr>(v8::Handle<v8::Object>::Cast(args[0])); + Element* element = V8DOMWrapper::convertDOMWrapperToNode<Element>(args.Holder()); if (!allowSettingSrcToJavascriptURL(element, newAttr->name(), newAttr->value())) return v8::Undefined(); @@ -124,45 +122,7 @@ CALLBACK_FUNC_DECL(ElementSetAttributeNodeNS) if (ec) throwError(ec); - return V8Proxy::NodeToV8Object(result.get()); -} - -static inline String toEventType(v8::Local<v8::String> value) -{ - String key = toWebCoreString(value); - ASSERT(key.startsWith("on")); - return key.substring(2); -} - -ACCESSOR_SETTER(ElementEventHandler) -{ - Node* node = V8Proxy::DOMWrapperToNode<Node>(info.Holder()); - - String eventType = toEventType(name); - - // Set handler if the value is a function. Otherwise, clear the - // event handler. - if (value->IsFunction()) { - V8Proxy* proxy = V8Proxy::retrieve(node->document()->frame()); - // the document might be created using createDocument, - // which does not have a frame, use the active frame - if (!proxy) - proxy = V8Proxy::retrieve(V8Proxy::retrieveFrameForEnteredContext()); - if (!proxy) - return; - - if (RefPtr<EventListener> listener = proxy->FindOrCreateV8EventListener(value, true)) - node->setAttributeEventListener(eventType, listener); - } else - node->clearAttributeEventListener(eventType); -} - -ACCESSOR_GETTER(ElementEventHandler) -{ - Node* node = V8Proxy::DOMWrapperToNode<Node>(info.Holder()); - - EventListener* listener = node->getAttributeEventListener(toEventType(name)); - return V8Proxy::EventListenerToV8Object(listener); + return V8DOMWrapper::convertNodeToV8Object(result.release()); } } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8EventCustom.cpp b/WebCore/bindings/v8/custom/V8EventCustom.cpp index 1dae845..8bac40f 100644 --- a/WebCore/bindings/v8/custom/V8EventCustom.cpp +++ b/WebCore/bindings/v8/custom/V8EventCustom.cpp @@ -43,39 +43,39 @@ namespace WebCore { ACCESSOR_SETTER(EventReturnValue) { - Event* event = V8Proxy::DOMWrapperToNative<Event>(info.Holder()); + Event* event = V8DOMWrapper::convertDOMWrapperToNative<Event>(info.Holder()); event->setDefaultPrevented(!value->BooleanValue()); } ACCESSOR_GETTER(EventDataTransfer) { - Event* event = V8Proxy::DOMWrapperToNative<Event>(info.Holder()); + Event* event = V8DOMWrapper::convertDOMWrapperToNative<Event>(info.Holder()); if (event->isDragEvent()) - return V8Proxy::ToV8Object(V8ClassIndex::CLIPBOARD, static_cast<MouseEvent*>(event)->clipboard()); + return V8DOMWrapper::convertToV8Object(V8ClassIndex::CLIPBOARD, static_cast<MouseEvent*>(event)->clipboard()); return v8::Undefined(); } ACCESSOR_GETTER(EventClipboardData) { - Event* event = V8Proxy::DOMWrapperToNative<Event>(info.Holder()); + Event* event = V8DOMWrapper::convertDOMWrapperToNative<Event>(info.Holder()); if (event->isClipboardEvent()) - return V8Proxy::ToV8Object(V8ClassIndex::CLIPBOARD, static_cast<ClipboardEvent*>(event)->clipboard()); + return V8DOMWrapper::convertToV8Object(V8ClassIndex::CLIPBOARD, static_cast<ClipboardEvent*>(event)->clipboard()); return v8::Undefined(); } ACCESSOR_GETTER(EventSrcElement) { - Event* event = V8Proxy::DOMWrapperToNative<Event>(info.Holder()); - return V8Proxy::EventTargetToV8Object(event->target()); + Event* event = V8DOMWrapper::convertDOMWrapperToNative<Event>(info.Holder()); + return V8DOMWrapper::convertEventTargetToV8Object(event->target()); } ACCESSOR_GETTER(EventReturnValue) { - Event* event = V8Proxy::DOMWrapperToNative<Event>(info.Holder()); + Event* event = V8DOMWrapper::convertDOMWrapperToNative<Event>(info.Holder()); return event->defaultPrevented() ? v8::False() : v8::True(); } diff --git a/WebCore/bindings/v8/custom/V8HTMLAudioElementConstructor.cpp b/WebCore/bindings/v8/custom/V8HTMLAudioElementConstructor.cpp new file mode 100644 index 0000000..6f9b761 --- /dev/null +++ b/WebCore/bindings/v8/custom/V8HTMLAudioElementConstructor.cpp @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "HTMLAudioElement.h" + +#include "Document.h" +#include "Frame.h" +#include "HTMLNames.h" + +#include "V8Binding.h" +#include "V8Proxy.h" + +#include <wtf/RefPtr.h> + +namespace WebCore { + +CALLBACK_FUNC_DECL(HTMLAudioElementConstructor) +{ + INC_STATS("DOM.HTMLAudioElement.Contructor"); + + if (!args.IsConstructCall()) + return throwError("DOM object constructor cannot be called as a function."); + + Frame* frame = V8Proxy::retrieveFrameForCurrentContext(); + if (!frame) + return throwError("Audio constructor associated frame is unavailable", V8Proxy::ReferenceError); + + Document* document = frame->document(); + if (!document) + return throwError("Audio constructor associated document is unavailable", V8Proxy::ReferenceError); + + // Make sure the document is added to the DOM Node map. Otherwise, the HTMLAudioElement instance + // may end up being the only node in the map and get garbage-ccollected prematurely. + V8DOMWrapper::convertNodeToV8Object(document); + + RefPtr<HTMLAudioElement> audio = new HTMLAudioElement(HTMLNames::audioTag, document); + if (args.Length() > 0) + audio->setSrc(toWebCoreString(args[0])); + + V8DOMWrapper::setDOMWrapper(args.Holder(), V8ClassIndex::ToInt(V8ClassIndex::NODE), audio.get()); + audio->ref(); + V8DOMWrapper::setJSWrapperForDOMNode(audio.get(), v8::Persistent<v8::Object>::New(args.Holder())); + return args.Holder(); +} + +} // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp index cf66e39..6ba9367 100644 --- a/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp @@ -40,12 +40,12 @@ namespace WebCore { CALLBACK_FUNC_DECL(HTMLCanvasElementGetContext) { - INC_STATS("DOM.HTMLCanvasElement.getContext"); - v8::Handle<v8::Value> holder = args.Holder(); - HTMLCanvasElement* imp = V8Proxy::DOMWrapperToNode<HTMLCanvasElement>(holder); - String contextId = ToWebCoreString(args[0]); + INC_STATS("DOM.HTMLCanvasElement.context"); + v8::Handle<v8::Object> holder = args.Holder(); + HTMLCanvasElement* imp = V8DOMWrapper::convertDOMWrapperToNode<HTMLCanvasElement>(holder); + String contextId = toWebCoreString(args[0]); CanvasRenderingContext2D* result = imp->getContext(contextId); - return V8Proxy::ToV8Object(V8ClassIndex::CANVASRENDERINGCONTEXT2D, result); + return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASRENDERINGCONTEXT2D, result); } } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp index 1436a48..7c9b40f 100644 --- a/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp @@ -47,10 +47,10 @@ static v8::Handle<v8::Value> getNamedItems(HTMLCollection* collection, AtomicStr return v8::Handle<v8::Value>(); if (namedItems.size() == 1) - return V8Proxy::NodeToV8Object(namedItems.at(0).get()); + return V8DOMWrapper::convertNodeToV8Object(namedItems.at(0).release()); NodeList* list = new V8NamedNodesCollection(namedItems); - return V8Proxy::ToV8Object(V8ClassIndex::NODELIST, list); + return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODELIST, list); } static v8::Handle<v8::Value> getItem(HTMLCollection* collection, v8::Handle<v8::Value> argument) @@ -66,7 +66,7 @@ static v8::Handle<v8::Value> getItem(HTMLCollection* collection, v8::Handle<v8:: } RefPtr<Node> result = collection->item(index->Uint32Value()); - return V8Proxy::NodeToV8Object(result.get()); + return V8DOMWrapper::convertNodeToV8Object(result.release()); } NAMED_PROPERTY_GETTER(HTMLCollection) @@ -84,21 +84,21 @@ NAMED_PROPERTY_GETTER(HTMLCollection) return v8::Handle<v8::Value>(); // Finally, search the DOM structure. - HTMLCollection* imp = V8Proxy::ToNativeObject<HTMLCollection>(V8ClassIndex::HTMLCOLLECTION, info.Holder()); + HTMLCollection* imp = V8DOMWrapper::convertToNativeObject<HTMLCollection>(V8ClassIndex::HTMLCOLLECTION, info.Holder()); return getNamedItems(imp, v8StringToAtomicWebCoreString(name)); } CALLBACK_FUNC_DECL(HTMLCollectionItem) { INC_STATS("DOM.HTMLCollection.item()"); - HTMLCollection* imp = V8Proxy::ToNativeObject<HTMLCollection>(V8ClassIndex::HTMLCOLLECTION, args.Holder()); + HTMLCollection* imp = V8DOMWrapper::convertToNativeObject<HTMLCollection>(V8ClassIndex::HTMLCOLLECTION, args.Holder()); return getItem(imp, args[0]); } CALLBACK_FUNC_DECL(HTMLCollectionNamedItem) { INC_STATS("DOM.HTMLCollection.namedItem()"); - HTMLCollection* imp = V8Proxy::ToNativeObject<HTMLCollection>(V8ClassIndex::HTMLCOLLECTION, args.Holder()); + HTMLCollection* imp = V8DOMWrapper::convertToNativeObject<HTMLCollection>(V8ClassIndex::HTMLCOLLECTION, args.Holder()); v8::Handle<v8::Value> result = getNamedItems(imp, toWebCoreString(args[0])); if (result.IsEmpty()) @@ -113,7 +113,7 @@ CALLBACK_FUNC_DECL(HTMLCollectionCallAsFunction) if (args.Length() < 1) return v8::Undefined(); - HTMLCollection* imp = V8Proxy::ToNativeObject<HTMLCollection>(V8ClassIndex::HTMLCOLLECTION, args.Holder()); + HTMLCollection* imp = V8DOMWrapper::convertToNativeObject<HTMLCollection>(V8ClassIndex::HTMLCOLLECTION, args.Holder()); if (args.Length() == 1) return getItem(imp, args[0]); @@ -128,7 +128,7 @@ CALLBACK_FUNC_DECL(HTMLCollectionCallAsFunction) Node* node = imp->namedItem(name); while (node) { if (!current) - return V8Proxy::NodeToV8Object(node); + return V8DOMWrapper::convertNodeToV8Object(node); node = imp->nextNamedItem(name); current--; diff --git a/WebCore/bindings/v8/custom/V8HTMLDataGridElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLDataGridElementCustom.cpp new file mode 100644 index 0000000..0ef4150 --- /dev/null +++ b/WebCore/bindings/v8/custom/V8HTMLDataGridElementCustom.cpp @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "HTMLDataGridElement.h" + +#include "Document.h" +#include "V8Binding.h" +#include "V8CustomBinding.h" +#include "V8DataGridDataSource.h" +#include "V8Proxy.h" + +#if ENABLE(DATAGRID) + +namespace WebCore { + +ACCESSOR_GETTER(HTMLDataGridElementDataSource) +{ + INC_STATS("DOM.HTMLDataGridElement.dataSource._get"); + v8::Handle<v8::Object> holder = info.Holder(); + HTMLDataGridElement* imp = V8DOMWrapper::convertDOMWrapperToNode<HTMLDataGridElement>(holder); + DataGridDataSource* dataSource = imp->dataSource(); + if (dataSource && dataSource->isJSDataGridDataSource()) + return asV8DataGridDataSource(dataSource)->jsDataSource(); + return v8::Null(); +} + +ACCESSOR_SETTER(HTMLDataGridElementDataSource) +{ + INC_STATS("DOM.HTMLDataGridElement.dataSource._set"); + v8::Handle<v8::Object> holder = info.Holder(); + HTMLDataGridElement* imp = V8DOMWrapper::convertDOMWrapperToNode<HTMLDataGridElement>(holder); + RefPtr<DataGridDataSource> dataSource; + if (!value.IsEmpty()) { + Frame *frame = imp->document()->frame(); + dataSource = V8DataGridDataSource::create(value, frame); + } + imp->setDataSource(dataSource.get()); +} + +} // namespace WebCore + +#endif // ENABLE(DATAGRID) diff --git a/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp index 34bf89c..a0c3d74 100644 --- a/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp @@ -78,7 +78,7 @@ NAMED_PROPERTY_GETTER(HTMLDocument) return value; } - HTMLDocument* htmlDocument = V8Proxy::DOMWrapperToNode<HTMLDocument>(info.Holder()); + HTMLDocument* htmlDocument = V8DOMWrapper::convertDOMWrapperToNode<HTMLDocument>(info.Holder()); // Fast case for named elements that are not there. if (!htmlDocument->hasNamedItem(key.impl()) && !htmlDocument->hasExtraNamedItem(key.impl())) @@ -92,12 +92,12 @@ NAMED_PROPERTY_GETTER(HTMLDocument) Node* node = items->firstItem(); Frame* frame = 0; if (node->hasTagName(HTMLNames::iframeTag) && (frame = static_cast<HTMLIFrameElement*>(node)->contentFrame())) - return V8Proxy::ToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow()); + return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow()); - return V8Proxy::NodeToV8Object(node); + return V8DOMWrapper::convertNodeToV8Object(node); } - return V8Proxy::ToV8Object(V8ClassIndex::HTMLCOLLECTION, items.get()); + return V8DOMWrapper::convertToV8Object(V8ClassIndex::HTMLCOLLECTION, items.release()); } // HTMLDocument ---------------------------------------------------------------- @@ -117,7 +117,7 @@ static String writeHelperGetString(const v8::Arguments& args) CALLBACK_FUNC_DECL(HTMLDocumentWrite) { INC_STATS("DOM.HTMLDocument.write()"); - HTMLDocument* htmlDocument = V8Proxy::DOMWrapperToNode<HTMLDocument>(args.Holder()); + HTMLDocument* htmlDocument = V8DOMWrapper::convertDOMWrapperToNode<HTMLDocument>(args.Holder()); Frame* frame = V8Proxy::retrieveFrameForCallingContext(); ASSERT(frame); htmlDocument->write(writeHelperGetString(args), frame->document()); @@ -127,7 +127,7 @@ CALLBACK_FUNC_DECL(HTMLDocumentWrite) CALLBACK_FUNC_DECL(HTMLDocumentWriteln) { INC_STATS("DOM.HTMLDocument.writeln()"); - HTMLDocument* htmlDocument = V8Proxy::DOMWrapperToNode<HTMLDocument>(args.Holder()); + HTMLDocument* htmlDocument = V8DOMWrapper::convertDOMWrapperToNode<HTMLDocument>(args.Holder()); Frame* frame = V8Proxy::retrieveFrameForCallingContext(); ASSERT(frame); htmlDocument->writeln(writeHelperGetString(args), frame->document()); @@ -137,12 +137,12 @@ CALLBACK_FUNC_DECL(HTMLDocumentWriteln) CALLBACK_FUNC_DECL(HTMLDocumentOpen) { INC_STATS("DOM.HTMLDocument.open()"); - HTMLDocument* htmlDocument = V8Proxy::DOMWrapperToNode<HTMLDocument>(args.Holder()); + HTMLDocument* htmlDocument = V8DOMWrapper::convertDOMWrapperToNode<HTMLDocument>(args.Holder()); if (args.Length() > 2) { if (Frame* frame = htmlDocument->frame()) { // Fetch the global object for the frame. - v8::Local<v8::Context> context = V8Proxy::GetContext(frame); + v8::Local<v8::Context> context = V8Proxy::context(frame); // Bail out if we cannot get the context. if (context.IsEmpty()) return v8::Undefined(); @@ -162,7 +162,7 @@ CALLBACK_FUNC_DECL(HTMLDocumentOpen) V8Proxy* proxy = V8Proxy::retrieve(frame); ASSERT(proxy); - v8::Local<v8::Value> result = proxy->CallFunction(v8::Local<v8::Function>::Cast(function), global, args.Length(), params); + v8::Local<v8::Value> result = proxy->callFunction(v8::Local<v8::Function>::Cast(function), global, args.Length(), params); delete[] params; return result; } @@ -179,9 +179,8 @@ ACCESSOR_GETTER(HTMLDocumentAll) INC_STATS("DOM.HTMLDocument.all._get"); v8::HandleScope scope; v8::Handle<v8::Object> holder = info.Holder(); - HTMLDocument* htmlDocument = V8Proxy::DOMWrapperToNode<HTMLDocument>(holder); - RefPtr<HTMLCollection> collection = WTF::getPtr(htmlDocument->all()); - return V8Proxy::ToV8Object(V8ClassIndex::HTMLCOLLECTION, WTF::getPtr(collection)); + HTMLDocument* htmlDocument = V8DOMWrapper::convertDOMWrapperToNode<HTMLDocument>(holder); + return V8DOMWrapper::convertToV8Object(V8ClassIndex::HTMLCOLLECTION, htmlDocument->all()); } ACCESSOR_SETTER(HTMLDocumentAll) diff --git a/WebCore/bindings/v8/custom/V8HTMLFormElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLFormElementCustom.cpp index 27ab7e3..1ec09f7 100644 --- a/WebCore/bindings/v8/custom/V8HTMLFormElementCustom.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLFormElementCustom.cpp @@ -42,19 +42,19 @@ namespace WebCore { INDEXED_PROPERTY_GETTER(HTMLFormElement) { INC_STATS("DOM.HTMLFormElement.IndexedPropertyGetter"); - HTMLFormElement* form = V8Proxy::DOMWrapperToNode<HTMLFormElement>(info.Holder()); - + HTMLFormElement* form = V8DOMWrapper::convertDOMWrapperToNode<HTMLFormElement>(info.Holder()); + RefPtr<Node> formElement = form->elements()->item(index); if (!formElement) return notHandledByInterceptor(); - return V8Proxy::NodeToV8Object(formElement.get()); + return V8DOMWrapper::convertNodeToV8Object(formElement.release()); } NAMED_PROPERTY_GETTER(HTMLFormElement) { INC_STATS("DOM.HTMLFormElement.NamedPropertyGetter"); - HTMLFormElement* imp = V8Proxy::DOMWrapperToNode<HTMLFormElement>(info.Holder()); + HTMLFormElement* imp = V8DOMWrapper::convertDOMWrapperToNode<HTMLFormElement>(info.Holder()); AtomicString v = v8StringToAtomicWebCoreString(name); // Call getNamedElements twice, first time check if it has a value @@ -74,15 +74,15 @@ NAMED_PROPERTY_GETTER(HTMLFormElement) ASSERT(!elements.isEmpty()); if (elements.size() == 1) - return V8Proxy::NodeToV8Object(elements.at(0).get()); + return V8DOMWrapper::convertNodeToV8Object(elements.at(0).release()); NodeList* collection = new V8NamedNodesCollection(elements); - return V8Proxy::ToV8Object(V8ClassIndex::NODELIST, collection); + return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODELIST, collection); } - + CALLBACK_FUNC_DECL(HTMLFormElementSubmit) { INC_STATS("DOM.HTMLFormElement.submit()"); - HTMLFormElement* form = V8Proxy::DOMWrapperToNative<HTMLFormElement>(args.Holder()); + HTMLFormElement* form = V8DOMWrapper::convertDOMWrapperToNative<HTMLFormElement>(args.Holder()); form->submit(0, false, false); return v8::Undefined(); } diff --git a/WebCore/bindings/v8/custom/V8HTMLFrameElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLFrameElementCustom.cpp index bfc4c28..4f865dd 100644 --- a/WebCore/bindings/v8/custom/V8HTMLFrameElementCustom.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLFrameElementCustom.cpp @@ -39,7 +39,7 @@ namespace WebCore { ACCESSOR_SETTER(HTMLFrameElementSrc) { - HTMLFrameElement* frame = V8Proxy::DOMWrapperToNode<HTMLFrameElement>(info.Holder()); + HTMLFrameElement* frame = V8DOMWrapper::convertDOMWrapperToNode<HTMLFrameElement>(info.Holder()); String srcValue = toWebCoreStringWithNullCheck(value); if (!allowSettingFrameSrcToJavascriptUrl(frame, srcValue)) @@ -50,7 +50,7 @@ ACCESSOR_SETTER(HTMLFrameElementSrc) ACCESSOR_SETTER(HTMLFrameElementLocation) { - HTMLFrameElement* frame = V8Proxy::DOMWrapperToNode<HTMLFrameElement>(info.Holder()); + HTMLFrameElement* frame = V8DOMWrapper::convertDOMWrapperToNode<HTMLFrameElement>(info.Holder()); String locationValue = toWebCoreStringWithNullCheck(value); if (!allowSettingFrameSrcToJavascriptUrl(frame, locationValue)) diff --git a/WebCore/bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp index 220af02..e8e2e72 100644 --- a/WebCore/bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp @@ -47,14 +47,14 @@ namespace WebCore { NAMED_PROPERTY_GETTER(HTMLFrameSetElement) { INC_STATS("DOM.HTMLFrameSetElement.NamedPropertyGetter"); - HTMLFrameSetElement* imp = V8Proxy::DOMWrapperToNode<HTMLFrameSetElement>(info.Holder()); + HTMLFrameSetElement* imp = V8DOMWrapper::convertDOMWrapperToNode<HTMLFrameSetElement>(info.Holder()); Node* frameNode = imp->children()->namedItem(v8StringToAtomicWebCoreString(name)); if (frameNode && frameNode->hasTagName(HTMLNames::frameTag)) { Document* doc = static_cast<HTMLFrameElement*>(frameNode)->contentDocument(); if (!doc) return v8::Undefined(); if (Frame* frame = doc->frame()) - return V8Proxy::ToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow()); + return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow()); } return notHandledByInterceptor(); } diff --git a/WebCore/bindings/v8/custom/V8HTMLIFrameElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLIFrameElementCustom.cpp index 3739a4e..ce2c29a 100644 --- a/WebCore/bindings/v8/custom/V8HTMLIFrameElementCustom.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLIFrameElementCustom.cpp @@ -39,8 +39,8 @@ namespace WebCore { ACCESSOR_SETTER(HTMLIFrameElementSrc) { - HTMLIFrameElement* iframe = V8Proxy::DOMWrapperToNode<HTMLIFrameElement>(info.Holder()); - String v = valueToStringWithNullCheck(value); + HTMLIFrameElement* iframe = V8DOMWrapper::convertDOMWrapperToNode<HTMLIFrameElement>(info.Holder()); + String v = toWebCoreStringWithNullCheck(value); if (!allowSettingFrameSrcToJavascriptUrl(iframe, v)) return; diff --git a/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp b/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp index afcc29d..91ebd5f 100644 --- a/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp @@ -49,24 +49,28 @@ CALLBACK_FUNC_DECL(HTMLImageElementConstructor) if (!args.IsConstructCall()) return throwError("DOM object constructor cannot be called as a function."); - Document* document = V8Proxy::retrieveFrame()->document(); + Frame* frame = V8Proxy::retrieveFrameForCurrentContext(); + if (!frame) + return throwError("Image constructor associated frame is unavailable", V8Proxy::ReferenceError); + + Document* document = frame->document(); if (!document) - return throwError("Image constructor associated document is unavailable", V8Proxy::REFERENCE_ERROR); + return throwError("Image constructor associated document is unavailable", V8Proxy::ReferenceError); // Make sure the document is added to the DOM Node map. Otherwise, the HTMLImageElement instance // may end up being the only node in the map and get garbage-ccollected prematurely. - V8Proxy::NodeToV8Object(document); + V8DOMWrapper::convertNodeToV8Object(document); - RefPtr<HTMLImageElement> image = new HTMLImageElement(HTMLNames::imgTag, V8Proxy::retrieveFrame()->document()); + RefPtr<HTMLImageElement> image = new HTMLImageElement(HTMLNames::imgTag, document); if (args.Length() > 0) { image->setWidth(toInt32(args[0])); if (args.Length() > 1) image->setHeight(toInt32(args[1])); } - V8Proxy::SetDOMWrapper(args.Holder(), V8ClassIndex::ToInt(V8ClassIndex::NODE), image.get()); + V8DOMWrapper::setDOMWrapper(args.Holder(), V8ClassIndex::ToInt(V8ClassIndex::NODE), image.get()); image->ref(); - V8Proxy::SetJSWrapperForDOMNode(image.get(), v8::Persistent<v8::Object>::New(args.Holder())); + V8DOMWrapper::setJSWrapperForDOMNode(image.get(), v8::Persistent<v8::Object>::New(args.Holder())); return args.Holder(); } diff --git a/WebCore/bindings/v8/custom/V8HTMLInputElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLInputElementCustom.cpp index 628634d..63fbcec 100644 --- a/WebCore/bindings/v8/custom/V8HTMLInputElementCustom.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLInputElementCustom.cpp @@ -41,7 +41,7 @@ ACCESSOR_GETTER(HTMLInputElementSelectionStart) { INC_STATS("DOM.HTMLInputElement.selectionStart._get"); v8::Handle<v8::Object> holder = info.Holder(); - HTMLInputElement* imp = V8Proxy::DOMWrapperToNode<HTMLInputElement>(holder); + HTMLInputElement* imp = V8DOMWrapper::convertDOMWrapperToNode<HTMLInputElement>(holder); if (!imp->canHaveSelection()) return throwError("Accessing selectionStart on an input element that cannot have a selection."); @@ -54,7 +54,7 @@ ACCESSOR_SETTER(HTMLInputElementSelectionStart) { INC_STATS("DOM.HTMLInputElement.selectionStart._set"); v8::Handle<v8::Object> holder = info.Holder(); - HTMLInputElement* imp = V8Proxy::DOMWrapperToNode<HTMLInputElement>(holder); + HTMLInputElement* imp = V8DOMWrapper::convertDOMWrapperToNode<HTMLInputElement>(holder); if (!imp->canHaveSelection()) { throwError("Accessing selectionStart on an input element that cannot have a selection."); @@ -67,7 +67,7 @@ ACCESSOR_GETTER(HTMLInputElementSelectionEnd) { INC_STATS("DOM.HTMLInputElement.selectionEnd._get"); v8::Handle<v8::Object> holder = info.Holder(); - HTMLInputElement* imp = V8Proxy::DOMWrapperToNode<HTMLInputElement>(holder); + HTMLInputElement* imp = V8DOMWrapper::convertDOMWrapperToNode<HTMLInputElement>(holder); if (!imp->canHaveSelection()) return throwError("Accessing selectionEnd on an input element that cannot have a selection."); @@ -80,7 +80,7 @@ ACCESSOR_SETTER(HTMLInputElementSelectionEnd) { INC_STATS("DOM.HTMLInputElement.selectionEnd._set"); v8::Handle<v8::Object> holder = info.Holder(); - HTMLInputElement* imp = V8Proxy::DOMWrapperToNode<HTMLInputElement>(holder); + HTMLInputElement* imp = V8DOMWrapper::convertDOMWrapperToNode<HTMLInputElement>(holder); if (!imp->canHaveSelection()) { throwError("Accessing selectionEnd on an input element that cannot have a selection."); @@ -94,7 +94,7 @@ CALLBACK_FUNC_DECL(HTMLInputElementSetSelectionRange) { INC_STATS("DOM.HTMLInputElement.setSelectionRange"); v8::Handle<v8::Object> holder = args.Holder(); - HTMLInputElement* imp = V8Proxy::DOMWrapperToNode<HTMLInputElement>(holder); + HTMLInputElement* imp = V8DOMWrapper::convertDOMWrapperToNode<HTMLInputElement>(holder); if (!imp->canHaveSelection()) return throwError("Calling setSelectionRange on an input element that cannot have a selection."); diff --git a/WebCore/bindings/v8/custom/V8HTMLOptionElementConstructor.cpp b/WebCore/bindings/v8/custom/V8HTMLOptionElementConstructor.cpp index 93a9b68..c22d127 100644 --- a/WebCore/bindings/v8/custom/V8HTMLOptionElementConstructor.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLOptionElementConstructor.cpp @@ -50,11 +50,15 @@ CALLBACK_FUNC_DECL(HTMLOptionElementConstructor) if (!args.IsConstructCall()) return throwError("DOM object constructor cannot be called as a function."); - Document* document = V8Proxy::retrieveFrame()->document(); + Frame* frame = V8Proxy::retrieveFrameForCurrentContext(); + if (!frame) + return throwError("Option constructor associated frame is unavailable", V8Proxy::ReferenceError); + + Document* document = frame->document(); if (!document) - return throwError("Option constructor associated document is unavailable", V8Proxy::REFERENCE_ERROR); + return throwError("Option constructor associated document is unavailable", V8Proxy::ReferenceError); - RefPtr<HTMLOptionElement> option = new HTMLOptionElement(HTMLNames::optionTag, V8Proxy::retrieveFrame()->document()); + RefPtr<HTMLOptionElement> option = new HTMLOptionElement(HTMLNames::optionTag, document); ExceptionCode ec = 0; RefPtr<Text> text = document->createTextNode(""); @@ -81,9 +85,9 @@ CALLBACK_FUNC_DECL(HTMLOptionElementConstructor) } } - V8Proxy::SetDOMWrapper(args.Holder(), V8ClassIndex::ToInt(V8ClassIndex::NODE), option.get()); + V8DOMWrapper::setDOMWrapper(args.Holder(), V8ClassIndex::ToInt(V8ClassIndex::NODE), option.get()); option->ref(); - V8Proxy::SetJSWrapperForDOMNode(option.get(), v8::Persistent<v8::Object>::New(args.Holder())); + V8DOMWrapper::setJSWrapperForDOMNode(option.get(), v8::Persistent<v8::Object>::New(args.Holder())); return args.Holder(); } diff --git a/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp index 9f0d25e..02c3499 100644 --- a/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp @@ -46,7 +46,7 @@ namespace WebCore { CALLBACK_FUNC_DECL(HTMLOptionsCollectionRemove) { INC_STATS("DOM.HTMLOptionsCollection.remove()"); - HTMLOptionsCollection* imp = V8Proxy::ToNativeObject<HTMLOptionsCollection>(V8ClassIndex::HTMLOPTIONSCOLLECTION, args.Holder()); + HTMLOptionsCollection* imp = V8DOMWrapper::convertToNativeObject<HTMLOptionsCollection>(V8ClassIndex::HTMLOPTIONSCOLLECTION, args.Holder()); HTMLSelectElement* base = static_cast<HTMLSelectElement*>(imp->base()); return removeElement(base, args); } @@ -55,11 +55,11 @@ CALLBACK_FUNC_DECL(HTMLOptionsCollectionAdd) { INC_STATS("DOM.HTMLOptionsCollection.add()"); if (!V8HTMLOptionElement::HasInstance(args[0])) { - V8Proxy::SetDOMException(TYPE_MISMATCH_ERR); + V8Proxy::setDOMException(TYPE_MISMATCH_ERR); return v8::Undefined(); } - HTMLOptionsCollection* imp = V8Proxy::ToNativeObject<HTMLOptionsCollection>(V8ClassIndex::HTMLOPTIONSCOLLECTION, args.Holder()); - HTMLOptionElement* option = V8Proxy::DOMWrapperToNode<HTMLOptionElement>(args[0]); + HTMLOptionsCollection* imp = V8DOMWrapper::convertToNativeObject<HTMLOptionsCollection>(V8ClassIndex::HTMLOPTIONSCOLLECTION, args.Holder()); + HTMLOptionElement* option = V8DOMWrapper::convertDOMWrapperToNode<HTMLOptionElement>(v8::Handle<v8::Object>(v8::Handle<v8::Object>::Cast(args[0]))); ExceptionCode ec = 0; if (args.Length() < 2) @@ -67,7 +67,7 @@ CALLBACK_FUNC_DECL(HTMLOptionsCollectionAdd) else { bool ok; v8::TryCatch try_catch; - int index = ToInt32(args[1], ok); + int index = toInt32(args[1], ok); if (try_catch.HasCaught()) return v8::Undefined(); @@ -79,7 +79,7 @@ CALLBACK_FUNC_DECL(HTMLOptionsCollectionAdd) } if (ec != 0) - V8Proxy::SetDOMException(ec); + V8Proxy::setDOMException(ec); return v8::Undefined(); } @@ -87,7 +87,7 @@ CALLBACK_FUNC_DECL(HTMLOptionsCollectionAdd) ACCESSOR_GETTER(HTMLOptionsCollectionLength) { INC_STATS("DOM.HTMLOptionsCollection.length._get"); - HTMLOptionsCollection* imp = V8Proxy::ToNativeObject<HTMLOptionsCollection>(V8ClassIndex::HTMLOPTIONSCOLLECTION, info.Holder()); + HTMLOptionsCollection* imp = V8DOMWrapper::convertToNativeObject<HTMLOptionsCollection>(V8ClassIndex::HTMLOPTIONSCOLLECTION, info.Holder()); int v = imp->length(); return v8::Integer::New(v); } @@ -95,7 +95,7 @@ ACCESSOR_GETTER(HTMLOptionsCollectionLength) ACCESSOR_SETTER(HTMLOptionsCollectionLength) { INC_STATS("DOM.HTMLOptionsCollection.length._set"); - HTMLOptionsCollection* imp = V8Proxy::ToNativeObject<HTMLOptionsCollection>(V8ClassIndex::HTMLOPTIONSCOLLECTION, info.Holder()); + HTMLOptionsCollection* imp = V8DOMWrapper::convertToNativeObject<HTMLOptionsCollection>(V8ClassIndex::HTMLOPTIONSCOLLECTION, info.Holder()); double v = value->NumberValue(); unsigned newLength = 0; ExceptionCode ec = 0; @@ -110,25 +110,25 @@ ACCESSOR_SETTER(HTMLOptionsCollectionLength) if (!ec) imp->setLength(value->Uint32Value(), ec); - V8Proxy::SetDOMException(ec); + V8Proxy::setDOMException(ec); } INDEXED_PROPERTY_GETTER(HTMLOptionsCollection) { INC_STATS("DOM.HTMLOptionsCollection.IndexedPropertyGetter"); - HTMLOptionsCollection* collection = V8Proxy::ToNativeObject<HTMLOptionsCollection>(V8ClassIndex::HTMLOPTIONSCOLLECTION, info.Holder()); + HTMLOptionsCollection* collection = V8DOMWrapper::convertToNativeObject<HTMLOptionsCollection>(V8ClassIndex::HTMLOPTIONSCOLLECTION, info.Holder()); RefPtr<Node> result = collection->item(index); if (!result) return notHandledByInterceptor(); - return V8Proxy::NodeToV8Object(result.get()); + return V8DOMWrapper::convertNodeToV8Object(result.release()); } INDEXED_PROPERTY_SETTER(HTMLOptionsCollection) { INC_STATS("DOM.HTMLOptionsCollection.IndexedPropertySetter"); - HTMLOptionsCollection* collection = V8Proxy::ToNativeObject<HTMLOptionsCollection>(V8ClassIndex::HTMLOPTIONSCOLLECTION, info.Holder()); + HTMLOptionsCollection* collection = V8DOMWrapper::convertToNativeObject<HTMLOptionsCollection>(V8ClassIndex::HTMLOPTIONSCOLLECTION, info.Holder()); HTMLSelectElement* base = static_cast<HTMLSelectElement*>(collection->base()); return toOptionsCollectionSetter(index, value, base); } diff --git a/WebCore/bindings/v8/custom/V8HTMLPlugInElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLPlugInElementCustom.cpp index a6e41a1..13c82f3 100644 --- a/WebCore/bindings/v8/custom/V8HTMLPlugInElementCustom.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLPlugInElementCustom.cpp @@ -35,17 +35,15 @@ #include "V8Binding.h" #include "V8CustomBinding.h" +#include "V8NPObject.h" #include "V8Proxy.h" -// FIXME: The name of this file will change once refactoring is complete -#include "v8_npobject.h" - namespace WebCore { NAMED_PROPERTY_GETTER(HTMLPlugInElement) { INC_STATS("DOM.HTMLPlugInElement.NamedPropertyGetter"); - HTMLPlugInElement* imp = V8Proxy::DOMWrapperToNode<HTMLPlugInElement>(info.Holder()); + HTMLPlugInElement* imp = V8DOMWrapper::convertDOMWrapperToNode<HTMLPlugInElement>(info.Holder()); ScriptInstance scriptInstance = imp->getInstance(); if (!scriptInstance) return notHandledByInterceptor(); @@ -54,13 +52,13 @@ NAMED_PROPERTY_GETTER(HTMLPlugInElement) if (instance.IsEmpty()) return notHandledByInterceptor(); - return NPObjectGetNamedProperty(instance, name); + return npObjectGetNamedProperty(instance, name); } NAMED_PROPERTY_SETTER(HTMLPlugInElement) { INC_STATS("DOM.HTMLPlugInElement.NamedPropertySetter"); - HTMLPlugInElement* imp = V8Proxy::DOMWrapperToNode<HTMLPlugInElement>(info.Holder()); + HTMLPlugInElement* imp = V8DOMWrapper::convertDOMWrapperToNode<HTMLPlugInElement>(info.Holder()); ScriptInstance scriptInstance = imp->getInstance(); if (!scriptInstance) return notHandledByInterceptor(); @@ -69,19 +67,19 @@ NAMED_PROPERTY_SETTER(HTMLPlugInElement) if (instance.IsEmpty()) return notHandledByInterceptor(); - return NPObjectSetNamedProperty(instance, name, value); + return npObjectSetNamedProperty(instance, name, value); } CALLBACK_FUNC_DECL(HTMLPlugInElement) { INC_STATS("DOM.HTMLPluginElement()"); - return NPObjectInvokeDefaultHandler(args); + return npObjectInvokeDefaultHandler(args); } INDEXED_PROPERTY_GETTER(HTMLPlugInElement) { INC_STATS("DOM.HTMLPlugInElement.IndexedPropertyGetter"); - HTMLPlugInElement* imp = V8Proxy::DOMWrapperToNode<HTMLPlugInElement>(info.Holder()); + HTMLPlugInElement* imp = V8DOMWrapper::convertDOMWrapperToNode<HTMLPlugInElement>(info.Holder()); ScriptInstance scriptInstance = imp->getInstance(); if (!scriptInstance) return notHandledByInterceptor(); @@ -90,13 +88,13 @@ INDEXED_PROPERTY_GETTER(HTMLPlugInElement) if (instance.IsEmpty()) return notHandledByInterceptor(); - return NPObjectGetIndexedProperty(instance, index); + return npObjectGetIndexedProperty(instance, index); } INDEXED_PROPERTY_SETTER(HTMLPlugInElement) { INC_STATS("DOM.HTMLPlugInElement.IndexedPropertySetter"); - HTMLPlugInElement* imp = V8Proxy::DOMWrapperToNode<HTMLPlugInElement>(info.Holder()); + HTMLPlugInElement* imp = V8DOMWrapper::convertDOMWrapperToNode<HTMLPlugInElement>(info.Holder()); ScriptInstance scriptInstance = imp->getInstance(); if (!scriptInstance) return notHandledByInterceptor(); @@ -105,7 +103,7 @@ INDEXED_PROPERTY_SETTER(HTMLPlugInElement) if (instance.IsEmpty()) return notHandledByInterceptor(); - return NPObjectSetIndexedProperty(instance, index, value); + return npObjectSetIndexedProperty(instance, index, value); } } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8HTMLSelectElementCollectionCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLSelectElementCollectionCustom.cpp index 8b3b72a..0dfa515 100644 --- a/WebCore/bindings/v8/custom/V8HTMLSelectElementCollectionCustom.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLSelectElementCollectionCustom.cpp @@ -43,7 +43,7 @@ namespace WebCore { NAMED_PROPERTY_GETTER(HTMLSelectElementCollection) { INC_STATS("DOM.HTMLSelectElementCollection.NamedPropertySetter"); - HTMLSelectElement* select = V8Proxy::DOMWrapperToNode<HTMLSelectElement>(info.Holder()); + HTMLSelectElement* select = V8DOMWrapper::convertDOMWrapperToNode<HTMLSelectElement>(info.Holder()); v8::Handle<v8::Value> value = info.Holder()->GetRealNamedPropertyInPrototypeChain(name); if (!value.IsEmpty()) @@ -62,16 +62,16 @@ NAMED_PROPERTY_GETTER(HTMLSelectElementCollection) return notHandledByInterceptor(); if (items.size() == 1) - return V8Proxy::NodeToV8Object(items.at(0).get()); + return V8DOMWrapper::convertNodeToV8Object(items.at(0).release()); NodeList* list = new V8NamedNodesCollection(items); - return V8Proxy::ToV8Object(V8ClassIndex::NODELIST, list); + return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODELIST, list); } INDEXED_PROPERTY_SETTER(HTMLSelectElementCollection) { INC_STATS("DOM.HTMLSelectElementCollection.IndexedPropertySetter"); - HTMLSelectElement* select = V8Proxy::DOMWrapperToNode<HTMLSelectElement>(info.Holder()); + HTMLSelectElement* select = V8DOMWrapper::convertDOMWrapperToNode<HTMLSelectElement>(info.Holder()); return toOptionsCollectionSetter(index, value, select); } diff --git a/WebCore/bindings/v8/custom/V8HTMLSelectElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLSelectElementCustom.cpp index 97f7726..661ffa2 100644 --- a/WebCore/bindings/v8/custom/V8HTMLSelectElementCustom.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLSelectElementCustom.cpp @@ -44,19 +44,19 @@ namespace WebCore { CALLBACK_FUNC_DECL(HTMLSelectElementRemove) { INC_STATS("DOM.HTMLSelectElement.remove"); - HTMLSelectElement* imp = V8Proxy::DOMWrapperToNode<HTMLSelectElement>(args.Holder()); + HTMLSelectElement* imp = V8DOMWrapper::convertDOMWrapperToNode<HTMLSelectElement>(args.Holder()); return removeElement(imp, args); } v8::Handle<v8::Value> removeElement(HTMLSelectElement* imp, const v8::Arguments& args) { if (V8HTMLOptionElement::HasInstance(args[0])) { - HTMLOptionElement* element = V8Proxy::DOMWrapperToNode<HTMLOptionElement>(args[0]); + HTMLOptionElement* element = V8DOMWrapper::convertDOMWrapperToNode<HTMLOptionElement>(v8::Handle<v8::Object>::Cast(args[0])); imp->remove(element->index()); return v8::Undefined(); } - imp->remove(ToInt32(args[0])); + imp->remove(toInt32(args[0])); return v8::Undefined(); } diff --git a/WebCore/bindings/v8/custom/V8InspectorControllerCustom.cpp b/WebCore/bindings/v8/custom/V8InspectorBackendCustom.cpp index a85c0d6..2571df4 100644 --- a/WebCore/bindings/v8/custom/V8InspectorControllerCustom.cpp +++ b/WebCore/bindings/v8/custom/V8InspectorBackendCustom.cpp @@ -29,12 +29,13 @@ */ #include "config.h" -#include "InspectorController.h" +#include "InspectorBackend.h" #include "DOMWindow.h" #include "Frame.h" #include "FrameLoader.h" #include "ExceptionCode.h" +#include "InspectorController.h" #include "InspectorResource.h" #include "NotImplemented.h" #include "Node.h" @@ -49,58 +50,31 @@ namespace WebCore { -CALLBACK_FUNC_DECL(InspectorControllerHighlightDOMNode) +CALLBACK_FUNC_DECL(InspectorBackendHighlightDOMNode) { - INC_STATS("InspectorController.highlightDOMNode()"); + INC_STATS("InspectorBackend.highlightDOMNode()"); if (args.Length() < 1) return v8::Undefined(); - Node* node = V8Proxy::DOMWrapperToNode<Node>(args[0]); + Node* node = V8DOMWrapper::convertDOMWrapperToNode<Node>(v8::Handle<v8::Object>::Cast(args[0])); if (!node) return v8::Undefined(); - InspectorController* inspectorController = V8Proxy::ToNativeObject<InspectorController>(V8ClassIndex::INSPECTORCONTROLLER, args.Holder()); - inspectorController->highlight(node); + InspectorBackend* inspectorBackend = V8DOMWrapper::convertToNativeObject<InspectorBackend>(V8ClassIndex::INSPECTORBACKEND, args.Holder()); + inspectorBackend->highlight(node); return v8::Undefined(); } -CALLBACK_FUNC_DECL(InspectorControllerGetResourceDocumentNode) +CALLBACK_FUNC_DECL(InspectorBackendSearch) { - INC_STATS("InspectorController.getResourceDocumentNode()"); - - if (args.Length() < 1) - return v8::Undefined(); - - if (!args[1]->IsNumber()) - return v8::Undefined(); - - unsigned identifier = args[1]->Int32Value(); - - InspectorController* inspectorController = V8Proxy::ToNativeObject<InspectorController>(V8ClassIndex::INSPECTORCONTROLLER, args.Holder()); - RefPtr<InspectorResource> resource = inspectorController->resources().get(identifier); - ASSERT(resource); - if (!resource) - return v8::Undefined(); - - Frame* frame = resource->frame(); - Document* document = frame->document(); - - if (document->isPluginDocument() || document->isImageDocument() || document->isMediaDocument()) - return v8::Undefined(); - - return V8Proxy::ToV8Object(V8ClassIndex::DOCUMENT, document); -} - -CALLBACK_FUNC_DECL(InspectorControllerSearch) -{ - INC_STATS("InspectorController.search()"); + INC_STATS("InspectorBackend.search()"); if (args.Length() < 2) return v8::Undefined(); - Node* node = V8Proxy::DOMWrapperToNode<Node>(args[0]); + Node* node = V8DOMWrapper::convertDOMWrapperToNode<Node>(v8::Handle<v8::Object>::Cast(args[0])); if (!node) return v8::Undefined(); @@ -124,7 +98,7 @@ CALLBACK_FUNC_DECL(InspectorControllerSearch) if (newStart == startVisiblePosition(searchRange.get(), DOWNSTREAM)) break; - result->Set(v8::Number::New(index++), V8Proxy::ToV8Object<Range>(V8ClassIndex::RANGE, resultRange.get())); + result->Set(v8::Number::New(index++), V8DOMWrapper::convertToV8Object(V8ClassIndex::RANGE, resultRange.release())); setStart(searchRange.get(), newStart); } while (true); @@ -133,25 +107,28 @@ CALLBACK_FUNC_DECL(InspectorControllerSearch) } #if ENABLE(DATABASE) -CALLBACK_FUNC_DECL(InspectorControllerDatabaseTableNames) +CALLBACK_FUNC_DECL(InspectorBackendDatabaseTableNames) { - INC_STATS("InspectorController.databaseTableNames()"); + INC_STATS("InspectorBackend.databaseTableNames()"); v8::Local<v8::Array> result = v8::Array::New(0); return result; } #endif -CALLBACK_FUNC_DECL(InspectorControllerInspectedWindow) +CALLBACK_FUNC_DECL(InspectorBackendInspectedWindow) { - INC_STATS("InspectorController.inspectedWindow()"); + INC_STATS("InspectorBackend.inspectedWindow()"); - InspectorController* inspectorController = V8Proxy::ToNativeObject<InspectorController>(V8ClassIndex::INSPECTORCONTROLLER, args.Holder()); - return V8Proxy::ToV8Object<DOMWindow>(V8ClassIndex::DOMWINDOW, inspectorController->inspectedPage()->mainFrame()->domWindow()); + InspectorBackend* inspectorBackend = V8DOMWrapper::convertToNativeObject<InspectorBackend>(V8ClassIndex::INSPECTORBACKEND, args.Holder()); + InspectorController* ic = inspectorBackend->inspectorController(); + if (!ic) + return v8::Undefined(); + return V8DOMWrapper::convertToV8Object<DOMWindow>(V8ClassIndex::DOMWINDOW, ic->inspectedPage()->mainFrame()->domWindow()); } -CALLBACK_FUNC_DECL(InspectorControllerSetting) +CALLBACK_FUNC_DECL(InspectorBackendSetting) { - INC_STATS("InspectorController.setting()"); + INC_STATS("InspectorBackend.setting()"); if (args.Length() < 1) return v8::Undefined(); @@ -160,8 +137,11 @@ CALLBACK_FUNC_DECL(InspectorControllerSetting) if (key.isEmpty()) return v8::Undefined(); - InspectorController* inspectorController = V8Proxy::ToNativeObject<InspectorController>(V8ClassIndex::INSPECTORCONTROLLER, args.Holder()); - const InspectorController::Setting& setting = inspectorController ->setting(key); + InspectorBackend* inspectorBackend = V8DOMWrapper::convertToNativeObject<InspectorBackend>(V8ClassIndex::INSPECTORBACKEND, args.Holder()); + InspectorController* ic = inspectorBackend->inspectorController(); + if (!ic) + return v8::Undefined(); + const InspectorController::Setting& setting = ic->setting(key); switch (setting.type()) { default: @@ -186,9 +166,9 @@ CALLBACK_FUNC_DECL(InspectorControllerSetting) } } -CALLBACK_FUNC_DECL(InspectorControllerSetSetting) +CALLBACK_FUNC_DECL(InspectorBackendSetSetting) { - INC_STATS("InspectorController.setSetting()"); + INC_STATS("InspectorBackend.setSetting()"); if (args.Length() < 2) return v8::Undefined(); @@ -221,15 +201,17 @@ CALLBACK_FUNC_DECL(InspectorControllerSetSetting) } else return v8::Undefined(); - InspectorController* inspectorController = V8Proxy::ToNativeObject<InspectorController>(V8ClassIndex::INSPECTORCONTROLLER, args.Holder()); - inspectorController->setSetting(key, setting); + InspectorBackend* inspectorBackend = V8DOMWrapper::convertToNativeObject<InspectorBackend>(V8ClassIndex::INSPECTORBACKEND, args.Holder()); + InspectorController* ic = inspectorBackend->inspectorController(); + if (ic) + inspectorBackend->inspectorController()->setSetting(key, setting); return v8::Undefined(); } -CALLBACK_FUNC_DECL(InspectorControllerWrapCallback) +CALLBACK_FUNC_DECL(InspectorBackendWrapCallback) { - INC_STATS("InspectorController.wrapCallback()"); + INC_STATS("InspectorBackend.wrapCallback()"); return args[0]; } diff --git a/WebCore/bindings/v8/custom/V8LocationCustom.cpp b/WebCore/bindings/v8/custom/V8LocationCustom.cpp index c5f3b1d..3f3ff6b 100644 --- a/WebCore/bindings/v8/custom/V8LocationCustom.cpp +++ b/WebCore/bindings/v8/custom/V8LocationCustom.cpp @@ -62,7 +62,7 @@ ACCESSOR_SETTER(LocationHash) { INC_STATS("DOM.Location.hash._set"); v8::Handle<v8::Object> holder = info.Holder(); - Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, holder); + Location* imp = V8DOMWrapper::convertToNativeObject<Location>(V8ClassIndex::LOCATION, holder); String hash = toWebCoreString(value); Frame* frame = imp->frame(); @@ -70,13 +70,13 @@ ACCESSOR_SETTER(LocationHash) return; KURL url = frame->loader()->url(); - String oldRef = url.ref(); + String oldRef = url.fragmentIdentifier(); if (hash.startsWith("#")) hash = hash.substring(1); if (oldRef == hash || (oldRef.isNull() && hash.isEmpty())) return; - url.setRef(hash); + url.setFragmentIdentifier(hash); navigateIfAllowed(frame, url, false, false); } @@ -85,7 +85,7 @@ ACCESSOR_SETTER(LocationHost) { INC_STATS("DOM.Location.host._set"); v8::Handle<v8::Object> holder = info.Holder(); - Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, holder); + Location* imp = V8DOMWrapper::convertToNativeObject<Location>(V8ClassIndex::LOCATION, holder); String host = toWebCoreString(value); Frame* frame = imp->frame(); @@ -105,7 +105,7 @@ ACCESSOR_SETTER(LocationHostname) { INC_STATS("DOM.Location.hostname._set"); v8::Handle<v8::Object> holder = info.Holder(); - Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, holder); + Location* imp = V8DOMWrapper::convertToNativeObject<Location>(V8ClassIndex::LOCATION, holder); String hostname = toWebCoreString(value); Frame* frame = imp->frame(); @@ -122,7 +122,7 @@ ACCESSOR_SETTER(LocationHref) { INC_STATS("DOM.Location.href._set"); v8::Handle<v8::Object> holder = info.Holder(); - Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, holder); + Location* imp = V8DOMWrapper::convertToNativeObject<Location>(V8ClassIndex::LOCATION, holder); Frame* frame = imp->frame(); if (!frame) @@ -142,7 +142,7 @@ ACCESSOR_SETTER(LocationPathname) { INC_STATS("DOM.Location.pathname._set"); v8::Handle<v8::Object> holder = info.Holder(); - Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, holder); + Location* imp = V8DOMWrapper::convertToNativeObject<Location>(V8ClassIndex::LOCATION, holder); String pathname = toWebCoreString(value); Frame* frame = imp->frame(); @@ -159,7 +159,7 @@ ACCESSOR_SETTER(LocationPort) { INC_STATS("DOM.Location.port._set"); v8::Handle<v8::Object> holder = info.Holder(); - Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, holder); + Location* imp = V8DOMWrapper::convertToNativeObject<Location>(V8ClassIndex::LOCATION, holder); String port = toWebCoreString(value); Frame* frame = imp->frame(); @@ -176,7 +176,7 @@ ACCESSOR_SETTER(LocationProtocol) { INC_STATS("DOM.Location.protocol._set"); v8::Handle<v8::Object> holder = info.Holder(); - Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, holder); + Location* imp = V8DOMWrapper::convertToNativeObject<Location>(V8ClassIndex::LOCATION, holder); String protocol = toWebCoreString(value); Frame* frame = imp->frame(); @@ -193,7 +193,7 @@ ACCESSOR_SETTER(LocationSearch) { INC_STATS("DOM.Location.search._set"); v8::Handle<v8::Object> holder = info.Holder(); - Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, holder); + Location* imp = V8DOMWrapper::convertToNativeObject<Location>(V8ClassIndex::LOCATION, holder); String query = toWebCoreString(value); Frame* frame = imp->frame(); @@ -210,14 +210,14 @@ ACCESSOR_GETTER(LocationReload) { INC_STATS("DOM.Location.reload._get"); static v8::Persistent<v8::FunctionTemplate> privateTemplate = v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(v8LocationReloadCallback, v8::Handle<v8::Value>(), v8::Signature::New(V8Location::GetRawTemplate()))); - v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper(V8ClassIndex::LOCATION, info.This()); + v8::Handle<v8::Object> holder = V8DOMWrapper::lookupDOMWrapper(V8ClassIndex::LOCATION, info.This()); if (holder.IsEmpty()) { // can only reach here by 'object.__proto__.func', and it should passed // domain security check already return privateTemplate->GetFunction(); } - Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, holder); - if (!V8Proxy::CanAccessFrame(imp->frame(), false)) { + Location* imp = V8DOMWrapper::convertToNativeObject<Location>(V8ClassIndex::LOCATION, holder); + if (!V8Proxy::canAccessFrame(imp->frame(), false)) { static v8::Persistent<v8::FunctionTemplate> sharedTemplate = v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(v8LocationReloadCallback, v8::Handle<v8::Value>(), v8::Signature::New(V8Location::GetRawTemplate()))); return sharedTemplate->GetFunction(); } else @@ -228,14 +228,14 @@ ACCESSOR_GETTER(LocationReplace) { INC_STATS("DOM.Location.replace._get"); static v8::Persistent<v8::FunctionTemplate> privateTemplate = v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(v8LocationReplaceCallback, v8::Handle<v8::Value>(), v8::Signature::New(V8Location::GetRawTemplate()))); - v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper(V8ClassIndex::LOCATION, info.This()); + v8::Handle<v8::Object> holder = V8DOMWrapper::lookupDOMWrapper(V8ClassIndex::LOCATION, info.This()); if (holder.IsEmpty()) { // can only reach here by 'object.__proto__.func', and it should passed // domain security check already return privateTemplate->GetFunction(); } - Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, holder); - if (!V8Proxy::CanAccessFrame(imp->frame(), false)) { + Location* imp = V8DOMWrapper::convertToNativeObject<Location>(V8ClassIndex::LOCATION, holder); + if (!V8Proxy::canAccessFrame(imp->frame(), false)) { static v8::Persistent<v8::FunctionTemplate> sharedTemplate = v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(v8LocationReplaceCallback, v8::Handle<v8::Value>(), v8::Signature::New(V8Location::GetRawTemplate()))); return sharedTemplate->GetFunction(); } else @@ -247,14 +247,14 @@ ACCESSOR_GETTER(LocationAssign) INC_STATS("DOM.Location.assign._get"); static v8::Persistent<v8::FunctionTemplate> privateTemplate = v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(v8LocationAssignCallback, v8::Handle<v8::Value>(), v8::Signature::New(V8Location::GetRawTemplate()))); - v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper(V8ClassIndex::LOCATION, info.This()); + v8::Handle<v8::Object> holder = V8DOMWrapper::lookupDOMWrapper(V8ClassIndex::LOCATION, info.This()); if (holder.IsEmpty()) { // can only reach here by 'object.__proto__.func', and it should passed // domain security check already return privateTemplate->GetFunction(); } - Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, holder); - if (!V8Proxy::CanAccessFrame(imp->frame(), false)) { + Location* imp = V8DOMWrapper::convertToNativeObject<Location>(V8ClassIndex::LOCATION, holder); + if (!V8Proxy::canAccessFrame(imp->frame(), false)) { static v8::Persistent<v8::FunctionTemplate> sharedTemplate = v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(v8LocationAssignCallback, v8::Handle<v8::Value>(), v8::Signature::New(V8Location::GetRawTemplate()))); return sharedTemplate->GetFunction(); } else @@ -266,8 +266,8 @@ CALLBACK_FUNC_DECL(LocationReload) // FIXME: we ignore the "forceget" parameter. INC_STATS("DOM.Location.reload"); - v8::Handle<v8::Value> holder = args.Holder(); - Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, holder); + v8::Handle<v8::Object> holder = args.Holder(); + Location* imp = V8DOMWrapper::convertToNativeObject<Location>(V8ClassIndex::LOCATION, holder); Frame* frame = imp->frame(); if (!frame || !ScriptController::isSafeScript(frame)) @@ -281,8 +281,8 @@ CALLBACK_FUNC_DECL(LocationReload) CALLBACK_FUNC_DECL(LocationReplace) { INC_STATS("DOM.Location.replace"); - v8::Handle<v8::Value> holder = args.Holder(); - Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, holder); + v8::Handle<v8::Object> holder = args.Holder(); + Location* imp = V8DOMWrapper::convertToNativeObject<Location>(V8ClassIndex::LOCATION, holder); Frame* frame = imp->frame(); if (!frame) @@ -302,8 +302,8 @@ CALLBACK_FUNC_DECL(LocationReplace) CALLBACK_FUNC_DECL(LocationAssign) { INC_STATS("DOM.Location.assign"); - v8::Handle<v8::Value> holder = args.Holder(); - Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, holder); + v8::Handle<v8::Object> holder = args.Holder(); + Location* imp = V8DOMWrapper::convertToNativeObject<Location>(V8ClassIndex::LOCATION, holder); Frame* frame = imp->frame(); if (!frame) @@ -333,9 +333,9 @@ CALLBACK_FUNC_DECL(LocationValueOf) CALLBACK_FUNC_DECL(LocationToString) { INC_STATS("DOM.Location.toString"); - v8::Handle<v8::Value> holder = args.Holder(); - Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, holder); - if (!V8Proxy::CanAccessFrame(imp->frame(), true)) + v8::Handle<v8::Object> holder = args.Holder(); + Location* imp = V8DOMWrapper::convertToNativeObject<Location>(V8ClassIndex::LOCATION, holder); + if (!V8Proxy::canAccessFrame(imp->frame(), true)) return v8::Undefined(); String result = imp->href(); return v8String(result); @@ -345,16 +345,16 @@ INDEXED_ACCESS_CHECK(Location) { ASSERT(V8ClassIndex::FromInt(data->Int32Value()) == V8ClassIndex::LOCATION); // Only allow same origin access - Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, host); - return V8Proxy::CanAccessFrame(imp->frame(), false); + Location* imp = V8DOMWrapper::convertToNativeObject<Location>(V8ClassIndex::LOCATION, host); + return V8Proxy::canAccessFrame(imp->frame(), false); } NAMED_ACCESS_CHECK(Location) { ASSERT(V8ClassIndex::FromInt(data->Int32Value()) == V8ClassIndex::LOCATION); // Only allow same origin access - Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, host); - return V8Proxy::CanAccessFrame(imp->frame(), false); + Location* imp = V8DOMWrapper::convertToNativeObject<Location>(V8ClassIndex::LOCATION, host); + return V8Proxy::canAccessFrame(imp->frame(), false); } } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp b/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp index 3a41467..f45aecf 100644 --- a/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp +++ b/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp @@ -31,12 +31,14 @@ #include "config.h" #include "MessageChannel.h" -#include "Document.h" -#include "Frame.h" - #include "V8Binding.h" #include "V8Proxy.h" +#include "Document.h" +#include "Frame.h" +#include "WorkerContext.h" +#include "WorkerContextExecutionProxy.h" + #include <wtf/RefPtr.h> namespace WebCore { @@ -44,32 +46,37 @@ namespace WebCore { CALLBACK_FUNC_DECL(MessageChannelConstructor) { INC_STATS("DOM.MessageChannel.Constructor"); - // FIXME: The logic here is almost exact duplicate of V8::ConstructDOMObject. + // FIXME: The logic here is almost exact duplicate of V8::constructDOMObject. // Consider refactoring to reduce duplication. if (!args.IsConstructCall()) return throwError("DOM object constructor cannot be called as a function."); - // Get the document. - Frame* frame = V8Proxy::retrieveFrame(); - if (!frame) - return v8::Undefined(); - - Document* document = frame->document(); + // Get the ScriptExecutionContext (WorkerContext or Document) + ScriptExecutionContext* context = 0; + WorkerContextExecutionProxy* proxy = WorkerContextExecutionProxy::retrieve(); + if (proxy) + context = proxy->workerContext(); + else { + Frame* frame = V8Proxy::retrieveFrameForCurrentContext(); + if (!frame) + return v8::Undefined(); + context = frame->document(); + } // Note: it's OK to let this RefPtr go out of scope because we also call // SetDOMWrapper(), which effectively holds a reference to obj. - RefPtr<MessageChannel> obj = MessageChannel::create(document); + RefPtr<MessageChannel> obj = MessageChannel::create(context); v8::Local<v8::Object> messageChannel = args.Holder(); // Create references from the MessageChannel wrapper to the two // MessagePort wrappers to make sure that the MessagePort wrappers // stay alive as long as the MessageChannel wrapper is around. - messageChannel->SetInternalField(kMessageChannelPort1Index, V8Proxy::ToV8Object(V8ClassIndex::MESSAGEPORT, obj->port1())); - messageChannel->SetInternalField(kMessageChannelPort2Index, V8Proxy::ToV8Object(V8ClassIndex::MESSAGEPORT, obj->port2())); + messageChannel->SetInternalField(kMessageChannelPort1Index, V8DOMWrapper::convertToV8Object(V8ClassIndex::MESSAGEPORT, obj->port1())); + messageChannel->SetInternalField(kMessageChannelPort2Index, V8DOMWrapper::convertToV8Object(V8ClassIndex::MESSAGEPORT, obj->port2())); // Setup the standard wrapper object internal fields. - V8Proxy::SetDOMWrapper(messageChannel, V8ClassIndex::MESSAGECHANNEL, obj.get()); + V8DOMWrapper::setDOMWrapper(messageChannel, V8ClassIndex::MESSAGECHANNEL, obj.get()); return toV8(obj.release(), messageChannel); } diff --git a/WebCore/bindings/v8/custom/V8MessagePortCustom.cpp b/WebCore/bindings/v8/custom/V8MessagePortCustom.cpp index fce04b6..95d248c 100644 --- a/WebCore/bindings/v8/custom/V8MessagePortCustom.cpp +++ b/WebCore/bindings/v8/custom/V8MessagePortCustom.cpp @@ -37,20 +37,38 @@ #include "V8ObjectEventListener.h" #include "V8Proxy.h" #include "V8Utilities.h" +#include "WorkerContextExecutionProxy.h" namespace WebCore { +PassRefPtr<EventListener> getEventListener(MessagePort* messagePort, v8::Local<v8::Value> value, bool findOnly, bool createObjectEventListener) +{ + V8Proxy* proxy = V8Proxy::retrieve(messagePort->scriptExecutionContext()); + if (proxy) { + V8EventListenerList* list = proxy->objectListeners(); + return findOnly ? list->findWrapper(value, false) : list->findOrCreateWrapper<V8ObjectEventListener>(proxy->frame(), value, false); + } + +#if ENABLE(WORKERS) + WorkerContextExecutionProxy* workerContextProxy = WorkerContextExecutionProxy::retrieve(); + if (workerContextProxy) + return workerContextProxy->findOrCreateEventListenerHelper(value, false, findOnly, createObjectEventListener); +#endif + + return PassRefPtr<EventListener>(); +} + ACCESSOR_GETTER(MessagePortOnmessage) { INC_STATS("DOM.MessagePort.onmessage._get"); - MessagePort* messagePort = V8Proxy::ToNativeObject<MessagePort>(V8ClassIndex::MESSAGEPORT, info.Holder()); - return V8Proxy::EventListenerToV8Object(messagePort->onmessage()); + MessagePort* messagePort = V8DOMWrapper::convertToNativeObject<MessagePort>(V8ClassIndex::MESSAGEPORT, info.Holder()); + return V8DOMWrapper::convertEventListenerToV8Object(messagePort->onmessage()); } ACCESSOR_SETTER(MessagePortOnmessage) { INC_STATS("DOM.MessagePort.onmessage._set"); - MessagePort* messagePort = V8Proxy::ToNativeObject<MessagePort>(V8ClassIndex::MESSAGEPORT, info.Holder()); + MessagePort* messagePort = V8DOMWrapper::convertToNativeObject<MessagePort>(V8ClassIndex::MESSAGEPORT, info.Holder()); if (value->IsNull()) { if (messagePort->onmessage()) { V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(messagePort->onmessage()); @@ -61,11 +79,7 @@ ACCESSOR_SETTER(MessagePortOnmessage) messagePort->setOnmessage(0); } else { - V8Proxy* proxy = V8Proxy::retrieve(messagePort->scriptExecutionContext()); - if (!proxy) - return; - - RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false); + RefPtr<EventListener> listener = getEventListener(messagePort, value, false, false); if (listener) { messagePort->setOnmessage(listener); createHiddenDependency(info.Holder(), value, V8Custom::kMessagePortRequestCacheIndex); @@ -73,64 +87,11 @@ ACCESSOR_SETTER(MessagePortOnmessage) } } -ACCESSOR_GETTER(MessagePortOnclose) -{ - INC_STATS("DOM.MessagePort.onclose._get"); - MessagePort* messagePort = V8Proxy::ToNativeObject<MessagePort>(V8ClassIndex::MESSAGEPORT, info.Holder()); - return V8Proxy::EventListenerToV8Object(messagePort->onclose()); -} - -ACCESSOR_SETTER(MessagePortOnclose) -{ - INC_STATS("DOM.MessagePort.onclose._set"); - MessagePort* messagePort = V8Proxy::ToNativeObject<MessagePort>(V8ClassIndex::MESSAGEPORT, info.Holder()); - if (value->IsNull()) { - if (messagePort->onclose()) { - V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(messagePort->onclose()); - removeHiddenDependency(info.Holder(), listener->getListenerObject(), V8Custom::kXMLHttpRequestCacheIndex); - } - - // Clear the listener. - messagePort->setOnclose(0); - } else { - V8Proxy* proxy = V8Proxy::retrieve(messagePort->scriptExecutionContext()); - if (!proxy) - return; - - RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false); - if (listener) { - messagePort->setOnclose(listener); - createHiddenDependency(info.Holder(), value, V8Custom::kMessagePortRequestCacheIndex); - } - } -} - -CALLBACK_FUNC_DECL(MessagePortStartConversation) -{ - INC_STATS("DOM.MessagePort.StartConversation()"); - if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::SYNTAX_ERROR); - MessagePort* messagePort = V8Proxy::ToNativeObject<MessagePort>(V8ClassIndex::MESSAGEPORT, args.Holder()); - - V8Proxy* proxy = V8Proxy::retrieve(messagePort->scriptExecutionContext()); - if (!proxy) - return v8::Undefined(); - - RefPtr<MessagePort> port = messagePort->startConversation(messagePort->scriptExecutionContext(), toWebCoreString(args[0])); - v8::Handle<v8::Value> wrapper = V8Proxy::ToV8Object(V8ClassIndex::MESSAGEPORT, port.get()); - return wrapper; -} - CALLBACK_FUNC_DECL(MessagePortAddEventListener) { - INC_STATS("DOM.MessagePort.AddEventListener()"); - MessagePort* messagePort = V8Proxy::ToNativeObject<MessagePort>(V8ClassIndex::MESSAGEPORT, args.Holder()); - - V8Proxy* proxy = V8Proxy::retrieve(messagePort->scriptExecutionContext()); - if (!proxy) - return v8::Undefined(); - - RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(args[1], false); + INC_STATS("DOM.MessagePort.addEventListener()"); + MessagePort* messagePort = V8DOMWrapper::convertToNativeObject<MessagePort>(V8ClassIndex::MESSAGEPORT, args.Holder()); + RefPtr<EventListener> listener = getEventListener(messagePort, args[1], false, true); if (listener) { String type = toWebCoreString(args[0]); bool useCapture = args[2]->BooleanValue(); @@ -143,15 +104,9 @@ CALLBACK_FUNC_DECL(MessagePortAddEventListener) CALLBACK_FUNC_DECL(MessagePortRemoveEventListener) { - INC_STATS("DOM.MessagePort.RemoveEventListener()"); - MessagePort* messagePort = V8Proxy::ToNativeObject<MessagePort>(V8ClassIndex::MESSAGEPORT, args.Holder()); - - V8Proxy* proxy = V8Proxy::retrieve(messagePort->scriptExecutionContext()); - if (!proxy) - return v8::Undefined(); // probably leaked - - RefPtr<EventListener> listener = proxy->FindObjectEventListener(args[1], false); - + INC_STATS("DOM.MessagePort.removeEventListener()"); + MessagePort* messagePort = V8DOMWrapper::convertToNativeObject<MessagePort>(V8ClassIndex::MESSAGEPORT, args.Holder()); + RefPtr<EventListener> listener = getEventListener(messagePort, args[1], true, true); if (listener) { String type = toWebCoreString(args[0]); bool useCapture = args[2]->BooleanValue(); diff --git a/WebCore/bindings/v8/custom/V8NamedNodeMapCustom.cpp b/WebCore/bindings/v8/custom/V8NamedNodeMapCustom.cpp index 8e529cc..afa90b7 100644 --- a/WebCore/bindings/v8/custom/V8NamedNodeMapCustom.cpp +++ b/WebCore/bindings/v8/custom/V8NamedNodeMapCustom.cpp @@ -42,12 +42,12 @@ namespace WebCore { INDEXED_PROPERTY_GETTER(NamedNodeMap) { INC_STATS("DOM.NamedNodeMap.IndexedPropertyGetter"); - NamedNodeMap* imp = V8Proxy::ToNativeObject<NamedNodeMap>(V8ClassIndex::NAMEDNODEMAP, info.Holder()); + NamedNodeMap* imp = V8DOMWrapper::convertToNativeObject<NamedNodeMap>(V8ClassIndex::NAMEDNODEMAP, info.Holder()); RefPtr<Node> result = imp->item(index); if (!result) return notHandledByInterceptor(); - return V8Proxy::NodeToV8Object(result.get()); + return V8DOMWrapper::convertNodeToV8Object(result.release()); } NAMED_PROPERTY_GETTER(NamedNodeMap) @@ -63,12 +63,12 @@ NAMED_PROPERTY_GETTER(NamedNodeMap) return notHandledByInterceptor(); // Finally, search the DOM. - NamedNodeMap* imp = V8Proxy::ToNativeObject<NamedNodeMap>(V8ClassIndex::NAMEDNODEMAP, info.Holder()); + NamedNodeMap* imp = V8DOMWrapper::convertToNativeObject<NamedNodeMap>(V8ClassIndex::NAMEDNODEMAP, info.Holder()); RefPtr<Node> result = imp->getNamedItem(toWebCoreString(name)); if (!result) return notHandledByInterceptor(); - return V8Proxy::NodeToV8Object(result.get()); + return V8DOMWrapper::convertNodeToV8Object(result.release()); } } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8NavigatorCustom.cpp b/WebCore/bindings/v8/custom/V8NavigatorCustom.cpp index 9adfe25..6a7b209 100644 --- a/WebCore/bindings/v8/custom/V8NavigatorCustom.cpp +++ b/WebCore/bindings/v8/custom/V8NavigatorCustom.cpp @@ -41,7 +41,7 @@ ACCESSOR_GETTER(NavigatorAppVersion) { INC_STATS("DOM.Navigator.appVersion"); v8::Handle<v8::Object> holder = info.Holder(); - Navigator* navigator = V8Proxy::ToNativeObject<Navigator>(V8ClassIndex::NAVIGATOR, holder); + Navigator* navigator = V8DOMWrapper::convertToNativeObject<Navigator>(V8ClassIndex::NAVIGATOR, holder); return v8StringOrUndefined(navigator->appVersion()); } diff --git a/WebCore/bindings/v8/custom/V8NodeCustom.cpp b/WebCore/bindings/v8/custom/V8NodeCustom.cpp index e81e8b5..6b0d740 100644 --- a/WebCore/bindings/v8/custom/V8NodeCustom.cpp +++ b/WebCore/bindings/v8/custom/V8NodeCustom.cpp @@ -34,30 +34,86 @@ #include "Document.h" #include "EventListener.h" +#include "V8AbstractEventListener.h" #include "V8Binding.h" #include "V8CustomBinding.h" #include "V8CustomEventListener.h" #include "V8Node.h" +#include "V8ObjectEventListener.h" #include "V8Proxy.h" #include <wtf/RefPtr.h> namespace WebCore { -CALLBACK_FUNC_DECL(NodeAddEventListener) +static inline String toEventType(v8::Local<v8::String> value) { - INC_STATS("DOM.Node.addEventListener()"); - Node* node = V8Proxy::DOMWrapperToNode<Node>(args.Holder()); + String key = toWebCoreString(value); + ASSERT(key.startsWith("on")); + return key.substring(2); +} - V8Proxy* proxy = V8Proxy::retrieve(node->document()->frame()); +static PassRefPtr<EventListener> getEventListener(Node* node, v8::Local<v8::Value> value, bool isAttribute, bool findOnly) +{ + V8Proxy* proxy = V8Proxy::retrieve(node->scriptExecutionContext()); + // The document might be created using createDocument, which does + // not have a frame, use the active frame. if (!proxy) - return v8::Undefined(); + proxy = V8Proxy::retrieve(V8Proxy::retrieveFrameForEnteredContext()); + + if (proxy) { + V8EventListenerList* list = proxy->objectListeners(); + return findOnly ? list->findWrapper(value, isAttribute) : list->findOrCreateWrapper<V8ObjectEventListener>(proxy->frame(), value, isAttribute); + } + + return 0; +} + +ACCESSOR_SETTER(NodeEventHandler) +{ + Node* node = V8DOMWrapper::convertDOMWrapperToNode<Node>(info.Holder()); + String eventType = toEventType(name); + + // Remove hidden dependency on the old event handler. + if (EventListener* listener = node->getAttributeEventListener(eventType)) { + if (static_cast<V8AbstractEventListener*>(listener)->isObjectListener()) { + v8::Local<v8::Object> v8Listener = static_cast<V8ObjectEventListener*>(listener)->getListenerObject(); + removeHiddenDependency(info.Holder(), v8Listener, V8Custom::kNodeEventListenerCacheIndex); + } + } + + // Set handler if the value is a function. + if (value->IsFunction()) { + RefPtr<EventListener> listener = getEventListener(node, value, true, false); + if (listener) { + node->setAttributeEventListener(eventType, listener); + createHiddenDependency(info.Holder(), value, V8Custom::kNodeEventListenerCacheIndex); + } + } else { + // Otherwise, clear the handler. + node->clearAttributeEventListener(eventType); + } +} + +ACCESSOR_GETTER(NodeEventHandler) +{ + Node* node = V8DOMWrapper::convertDOMWrapperToNode<Node>(info.Holder()); + + EventListener* listener = node->getAttributeEventListener(toEventType(name)); + return V8DOMWrapper::convertEventListenerToV8Object(listener); +} - RefPtr<EventListener> listener = proxy->FindOrCreateV8EventListener(args[1], false); +CALLBACK_FUNC_DECL(NodeAddEventListener) +{ + INC_STATS("DOM.Node.addEventListener()"); + Node* node = V8DOMWrapper::convertDOMWrapperToNode<Node>(args.Holder()); + + RefPtr<EventListener> listener = getEventListener(node, args[1], false, false); if (listener) { String type = toWebCoreString(args[0]); bool useCapture = args[2]->BooleanValue(); node->addEventListener(type, listener, useCapture); + createHiddenDependency(args.Holder(), args[1], V8Custom::kNodeEventListenerCacheIndex); } return v8::Undefined(); } @@ -65,20 +121,17 @@ CALLBACK_FUNC_DECL(NodeAddEventListener) CALLBACK_FUNC_DECL(NodeRemoveEventListener) { INC_STATS("DOM.Node.removeEventListener()"); - Node* node = V8Proxy::DOMWrapperToNode<Node>(args.Holder()); + Node* node = V8DOMWrapper::convertDOMWrapperToNode<Node>(args.Holder()); - V8Proxy* proxy = V8Proxy::retrieve(node->document()->frame()); // It is possbile that the owner document of the node is detached - // from the frame, return immediately in this case. + // from the frame. // See issue http://b/878909 - if (!proxy) - return v8::Undefined(); - - RefPtr<EventListener> listener = proxy->FindV8EventListener(args[1], false); + RefPtr<EventListener> listener = getEventListener(node, args[1], false, true); if (listener) { String type = toWebCoreString(args[0]); bool useCapture = args[2]->BooleanValue(); node->removeEventListener(type, listener.get(), useCapture); + removeHiddenDependency(args.Holder(), args[1], V8Custom::kNodeEventListenerCacheIndex); } return v8::Undefined(); @@ -88,14 +141,14 @@ CALLBACK_FUNC_DECL(NodeRemoveEventListener) CALLBACK_FUNC_DECL(NodeInsertBefore) { INC_STATS("DOM.Node.insertBefore"); - v8::Handle<v8::Value> holder = args.Holder(); - Node* imp = V8Proxy::DOMWrapperToNode<Node>(holder); + v8::Handle<v8::Object> holder = args.Holder(); + Node* imp = V8DOMWrapper::convertDOMWrapperToNode<Node>(holder); ExceptionCode ec = 0; - Node* newChild = V8Node::HasInstance(args[0]) ? V8Proxy::DOMWrapperToNode<Node>(args[0]) : 0; - Node* refChild = V8Node::HasInstance(args[1]) ? V8Proxy::DOMWrapperToNode<Node>(args[1]) : 0; + Node* newChild = V8Node::HasInstance(args[0]) ? V8DOMWrapper::convertDOMWrapperToNode<Node>(v8::Handle<v8::Object>::Cast(args[0])) : 0; + Node* refChild = V8Node::HasInstance(args[1]) ? V8DOMWrapper::convertDOMWrapperToNode<Node>(v8::Handle<v8::Object>::Cast(args[1])) : 0; bool success = imp->insertBefore(newChild, refChild, ec, true); if (ec) { - V8Proxy::SetDOMException(ec); + V8Proxy::setDOMException(ec); return v8::Handle<v8::Value>(); } if (success) @@ -107,14 +160,14 @@ CALLBACK_FUNC_DECL(NodeInsertBefore) CALLBACK_FUNC_DECL(NodeReplaceChild) { INC_STATS("DOM.Node.replaceChild"); - v8::Handle<v8::Value> holder = args.Holder(); - Node* imp = V8Proxy::DOMWrapperToNode<Node>(holder); + v8::Handle<v8::Object> holder = args.Holder(); + Node* imp = V8DOMWrapper::convertDOMWrapperToNode<Node>(holder); ExceptionCode ec = 0; - Node* newChild = V8Node::HasInstance(args[0]) ? V8Proxy::DOMWrapperToNode<Node>(args[0]) : 0; - Node* oldChild = V8Node::HasInstance(args[1]) ? V8Proxy::DOMWrapperToNode<Node>(args[1]) : 0; + Node* newChild = V8Node::HasInstance(args[0]) ? V8DOMWrapper::convertDOMWrapperToNode<Node>(v8::Handle<v8::Object>::Cast(args[0])) : 0; + Node* oldChild = V8Node::HasInstance(args[1]) ? V8DOMWrapper::convertDOMWrapperToNode<Node>(v8::Handle<v8::Object>::Cast(args[1])) : 0; bool success = imp->replaceChild(newChild, oldChild, ec, true); if (ec) { - V8Proxy::SetDOMException(ec); + V8Proxy::setDOMException(ec); return v8::Handle<v8::Value>(); } if (success) @@ -125,13 +178,13 @@ CALLBACK_FUNC_DECL(NodeReplaceChild) CALLBACK_FUNC_DECL(NodeRemoveChild) { INC_STATS("DOM.Node.removeChild"); - v8::Handle<v8::Value> holder = args.Holder(); - Node* imp = V8Proxy::DOMWrapperToNode<Node>(holder); + v8::Handle<v8::Object> holder = args.Holder(); + Node* imp = V8DOMWrapper::convertDOMWrapperToNode<Node>(holder); ExceptionCode ec = 0; - Node* oldChild = V8Node::HasInstance(args[0]) ? V8Proxy::DOMWrapperToNode<Node>(args[0]) : 0; + Node* oldChild = V8Node::HasInstance(args[0]) ? V8DOMWrapper::convertDOMWrapperToNode<Node>(v8::Handle<v8::Object>::Cast(args[0])) : 0; bool success = imp->removeChild(oldChild, ec); if (ec) { - V8Proxy::SetDOMException(ec); + V8Proxy::setDOMException(ec); return v8::Handle<v8::Value>(); } if (success) @@ -143,13 +196,13 @@ CALLBACK_FUNC_DECL(NodeRemoveChild) CALLBACK_FUNC_DECL(NodeAppendChild) { INC_STATS("DOM.Node.appendChild"); - v8::Handle<v8::Value> holder = args.Holder(); - Node* imp = V8Proxy::DOMWrapperToNode<Node>(holder); + v8::Handle<v8::Object> holder = args.Holder(); + Node* imp = V8DOMWrapper::convertDOMWrapperToNode<Node>(holder); ExceptionCode ec = 0; - Node* newChild = V8Node::HasInstance(args[0]) ? V8Proxy::DOMWrapperToNode<Node>(args[0]) : 0; + Node* newChild = V8Node::HasInstance(args[0]) ? V8DOMWrapper::convertDOMWrapperToNode<Node>(v8::Handle<v8::Object>::Cast(args[0])) : 0; bool success = imp->appendChild(newChild, ec, true ); if (ec) { - V8Proxy::SetDOMException(ec); + V8Proxy::setDOMException(ec); return v8::Handle<v8::Value>(); } if (success) diff --git a/WebCore/bindings/v8/custom/V8NodeIteratorCustom.cpp b/WebCore/bindings/v8/custom/V8NodeIteratorCustom.cpp index 48e6b8f..47ae8ee 100644 --- a/WebCore/bindings/v8/custom/V8NodeIteratorCustom.cpp +++ b/WebCore/bindings/v8/custom/V8NodeIteratorCustom.cpp @@ -53,13 +53,13 @@ static inline v8::Handle<v8::Value> toV8(PassRefPtr<Node> object, ExceptionCode if (!object) return v8::Null(); - return V8Proxy::NodeToV8Object(object.get()); + return V8DOMWrapper::convertNodeToV8Object(object); } CALLBACK_FUNC_DECL(NodeIteratorNextNode) { INC_STATS("DOM.NodeIterator.nextNode()"); - NodeIterator* nodeIterator = V8Proxy::ToNativeObject<NodeIterator>(V8ClassIndex::NODEITERATOR, args.Holder()); + NodeIterator* nodeIterator = V8DOMWrapper::convertToNativeObject<NodeIterator>(V8ClassIndex::NODEITERATOR, args.Holder()); ExceptionCode ec = 0; ScriptState state; @@ -70,7 +70,7 @@ CALLBACK_FUNC_DECL(NodeIteratorNextNode) CALLBACK_FUNC_DECL(NodeIteratorPreviousNode) { INC_STATS("DOM.NodeIterator.previousNode()"); - NodeIterator* nodeIterator = V8Proxy::ToNativeObject<NodeIterator>(V8ClassIndex::NODEITERATOR, args.Holder()); + NodeIterator* nodeIterator = V8DOMWrapper::convertToNativeObject<NodeIterator>(V8ClassIndex::NODEITERATOR, args.Holder()); ExceptionCode ec = 0; ScriptState state; diff --git a/WebCore/bindings/v8/custom/V8NodeListCustom.cpp b/WebCore/bindings/v8/custom/V8NodeListCustom.cpp index 27a47f5..ad10952 100644 --- a/WebCore/bindings/v8/custom/V8NodeListCustom.cpp +++ b/WebCore/bindings/v8/custom/V8NodeListCustom.cpp @@ -36,24 +36,26 @@ #include "V8Proxy.h" #include <wtf/RefPtr.h> +#include <wtf/StdLibExtras.h> namespace WebCore { NAMED_PROPERTY_GETTER(NodeList) { INC_STATS("DOM.NodeList.NamedPropertyGetter"); - NodeList* list = V8Proxy::ToNativeObject<NodeList>(V8ClassIndex::NODELIST, info.Holder()); + NodeList* list = V8DOMWrapper::convertToNativeObject<NodeList>(V8ClassIndex::NODELIST, info.Holder()); String key = toWebCoreString(name); // Length property cannot be overridden. - if (key == "length") - return v8::Number::New(list->length()); + DEFINE_STATIC_LOCAL(const AtomicString, length, ("length")); + if (key == length) + return v8::Integer::New(list->length()); RefPtr<Node> result = list->itemWithName(key); if (!result) return notHandledByInterceptor(); - return V8Proxy::NodeToV8Object(result.get()); + return V8DOMWrapper::convertNodeToV8Object(result.release()); } } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8SQLResultSetRowListCustom.cpp b/WebCore/bindings/v8/custom/V8SQLResultSetRowListCustom.cpp index eaeb26d..aced4ee 100644 --- a/WebCore/bindings/v8/custom/V8SQLResultSetRowListCustom.cpp +++ b/WebCore/bindings/v8/custom/V8SQLResultSetRowListCustom.cpp @@ -32,11 +32,20 @@ #if ENABLE(DATABASE) +#ifdef MANUAL_MERGE_REQUIRED #include "v8_binding.h" #include "v8_proxy.h" +#else // MANUAL_MERGE_REQUIRED +#endif // MANUAL_MERGE_REQUIRED #include "SQLResultSetRowList.h" +#ifdef MANUAL_MERGE_REQUIRED #include "V8CustomBinding.h" +#else // MANUAL_MERGE_REQUIRED +#include "V8Binding.h" +#include "V8CustomBinding.h" +#include "V8Proxy.h" +#endif // MANUAL_MERGE_REQUIRED namespace WebCore { @@ -45,20 +54,20 @@ CALLBACK_FUNC_DECL(SQLResultSetRowListItem) INC_STATS("DOM.SQLResultSetRowList.item()"); if (args.Length() == 0) { - V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Item index is required."); + V8Proxy::throwError(V8Proxy::SyntaxError, "Item index is required."); return v8::Undefined(); } if (!args[0]->IsNumber()) { - V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, "Item index must be a number."); + V8Proxy::throwError(V8Proxy::TypeError, "Item index must be a number."); return v8::Undefined(); } - SQLResultSetRowList* rowList = V8Proxy::ToNativeObject<SQLResultSetRowList>(V8ClassIndex::SQLRESULTSETROWLIST, args.Holder()); + SQLResultSetRowList* rowList = V8DOMWrapper::convertToNativeObject<SQLResultSetRowList>(V8ClassIndex::SQLRESULTSETROWLIST, args.Holder()); unsigned long index = args[0]->IntegerValue(); if (index < 0 || index >= rowList->length()) { - V8Proxy::ThrowError(V8Proxy::RANGE_ERROR, "Item index is out of range."); + V8Proxy::throwError(V8Proxy::RangeError, "Item index is out of range."); return v8::Undefined(); } diff --git a/WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp b/WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp index 15cd379..b9b86fc 100644 --- a/WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp +++ b/WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp @@ -32,14 +32,23 @@ #if ENABLE(DATABASE) +#ifdef MANUAL_MERGE_REQUIRED #include "v8_binding.h" #include "v8_proxy.h" +#else // MANUAL_MERGE_REQUIRED +#endif // MANUAL_MERGE_REQUIRED #include "Database.h" #include "SQLValue.h" +#ifdef MANUAL_MERGE_REQUIRED #include "V8CustomBinding.h" +#else // MANUAL_MERGE_REQUIRED +#include "V8Binding.h" +#include "V8CustomBinding.h" +#endif // MANUAL_MERGE_REQUIRED #include "V8CustomSQLStatementCallback.h" #include "V8CustomSQLStatementErrorCallback.h" +#include "V8Proxy.h" #include <wtf/Vector.h> using namespace WTF; @@ -51,18 +60,18 @@ CALLBACK_FUNC_DECL(SQLTransactionExecuteSql) INC_STATS("DOM.SQLTransaction.executeSql()"); if (args.Length() == 0) { - V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "SQL statement is required."); + V8Proxy::throwError(V8Proxy::SyntaxError, "SQL statement is required."); return v8::Undefined(); } - String statement = ToWebCoreString(args[0]); + String statement = toWebCoreString(args[0]); Vector<SQLValue> sqlValues; if (args.Length() > 1) { // FIXME: Make this work for v8::Arrayish objects, as well if (!args[1]->IsArray()) { - V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, "Statement arguments must be an v8::Array."); + V8Proxy::throwError(V8Proxy::TypeError, "Statement arguments must be an v8::Array."); return v8::Undefined(); } @@ -76,18 +85,18 @@ CALLBACK_FUNC_DECL(SQLTransactionExecuteSql) else if (value->IsNumber()) sqlValues.append(SQLValue(value->NumberValue())); else - sqlValues.append(SQLValue(ToWebCoreString(value))); + sqlValues.append(SQLValue(toWebCoreString(value))); } } - SQLTransaction* transaction = V8Proxy::ToNativeObject<SQLTransaction>(V8ClassIndex::SQLTRANSACTION, args.Holder()); + SQLTransaction* transaction = V8DOMWrapper::convertToNativeObject<SQLTransaction>(V8ClassIndex::SQLTRANSACTION, args.Holder()); - Frame* frame = V8Proxy::retrieveFrame(); + Frame* frame = V8Proxy::retrieveFrameForCurrentContext(); RefPtr<SQLStatementCallback> callback; if (args.Length() > 2) { if (!args[2]->IsObject()) { - V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, "Statement callback must be of valid type."); + V8Proxy::throwError(V8Proxy::TypeError, "Statement callback must be of valid type."); return v8::Undefined(); } @@ -98,7 +107,7 @@ CALLBACK_FUNC_DECL(SQLTransactionExecuteSql) RefPtr<SQLStatementErrorCallback> errorCallback; if (args.Length() > 3) { if (!args[2]->IsObject()) { - V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, "Statement error callback must be of valid type."); + V8Proxy::throwError(V8Proxy::TypeError, "Statement error callback must be of valid type."); return v8::Undefined(); } @@ -108,7 +117,7 @@ CALLBACK_FUNC_DECL(SQLTransactionExecuteSql) ExceptionCode ec = 0; transaction->executeSQL(statement, sqlValues, callback, errorCallback, ec); - V8Proxy::SetDOMException(ec); + V8Proxy::setDOMException(ec); return v8::Undefined(); } diff --git a/WebCore/bindings/v8/custom/V8SVGElementInstanceCustom.cpp b/WebCore/bindings/v8/custom/V8SVGElementInstanceCustom.cpp index 351b030..ce9c345 100644 --- a/WebCore/bindings/v8/custom/V8SVGElementInstanceCustom.cpp +++ b/WebCore/bindings/v8/custom/V8SVGElementInstanceCustom.cpp @@ -47,13 +47,13 @@ namespace WebCore { CALLBACK_FUNC_DECL(SVGElementInstanceAddEventListener) { INC_STATS("DOM.SVGElementInstance.AddEventListener()"); - SVGElementInstance* instance = V8Proxy::DOMWrapperToNative<SVGElementInstance>(args.Holder()); + SVGElementInstance* instance = V8DOMWrapper::convertDOMWrapperToNative<SVGElementInstance>(args.Holder()); V8Proxy* proxy = V8Proxy::retrieve(instance->scriptExecutionContext()); if (!proxy) return v8::Undefined(); - RefPtr<EventListener> listener = proxy->FindOrCreateV8EventListener(args[1], false); + RefPtr<EventListener> listener = proxy->eventListeners()->findOrCreateWrapper<V8EventListener>(proxy->frame(), args[1], false); if (listener) { String type = toWebCoreString(args[0]); bool useCapture = args[2]->BooleanValue(); @@ -66,13 +66,13 @@ CALLBACK_FUNC_DECL(SVGElementInstanceAddEventListener) CALLBACK_FUNC_DECL(SVGElementInstanceRemoveEventListener) { INC_STATS("DOM.SVGElementInstance.RemoveEventListener()"); - SVGElementInstance* instance = V8Proxy::DOMWrapperToNative<SVGElementInstance>(args.Holder()); + SVGElementInstance* instance = V8DOMWrapper::convertDOMWrapperToNative<SVGElementInstance>(args.Holder()); V8Proxy* proxy = V8Proxy::retrieve(instance->scriptExecutionContext()); if (!proxy) return v8::Undefined(); - RefPtr<EventListener> listener = proxy->FindV8EventListener(args[1], false); + RefPtr<EventListener> listener = proxy->eventListeners()->findWrapper(args[1], false); if (listener) { String type = toWebCoreString(args[0]); bool useCapture = args[2]->BooleanValue(); diff --git a/WebCore/bindings/v8/custom/V8SVGLengthCustom.cpp b/WebCore/bindings/v8/custom/V8SVGLengthCustom.cpp index a2a4d49..9f75f5a 100644 --- a/WebCore/bindings/v8/custom/V8SVGLengthCustom.cpp +++ b/WebCore/bindings/v8/custom/V8SVGLengthCustom.cpp @@ -44,17 +44,17 @@ namespace WebCore { ACCESSOR_GETTER(SVGLengthValue) { INC_STATS("DOM.SVGLength.value"); - V8SVGPODTypeWrapper<SVGLength>* wrapper = V8Proxy::ToNativeObject<V8SVGPODTypeWrapper<SVGLength> >(V8ClassIndex::SVGLENGTH, info.Holder()); + V8SVGPODTypeWrapper<SVGLength>* wrapper = V8DOMWrapper::convertToNativeObject<V8SVGPODTypeWrapper<SVGLength> >(V8ClassIndex::SVGLENGTH, info.Holder()); SVGLength imp = *wrapper; - return v8::Number::New(imp.value(V8Proxy::GetSVGContext(wrapper))); + return v8::Number::New(imp.value(V8Proxy::svgContext(wrapper))); } CALLBACK_FUNC_DECL(SVGLengthConvertToSpecifiedUnits) { INC_STATS("DOM.SVGLength.convertToSpecifiedUnits"); - V8SVGPODTypeWrapper<SVGLength>* wrapper = V8Proxy::ToNativeObject<V8SVGPODTypeWrapper<SVGLength> >(V8ClassIndex::SVGLENGTH, args.Holder()); + V8SVGPODTypeWrapper<SVGLength>* wrapper = V8DOMWrapper::convertToNativeObject<V8SVGPODTypeWrapper<SVGLength> >(V8ClassIndex::SVGLENGTH, args.Holder()); SVGLength imp = *wrapper; - SVGElement* context = V8Proxy::GetSVGContext(wrapper); + SVGElement* context = V8Proxy::svgContext(wrapper); imp.convertToSpecifiedUnits(toInt32(args[0]), context); wrapper->commitChange(imp, context); return v8::Undefined(); diff --git a/WebCore/bindings/v8/custom/V8SVGMatrixCustom.cpp b/WebCore/bindings/v8/custom/V8SVGMatrixCustom.cpp index b69202b..3766397 100644 --- a/WebCore/bindings/v8/custom/V8SVGMatrixCustom.cpp +++ b/WebCore/bindings/v8/custom/V8SVGMatrixCustom.cpp @@ -46,7 +46,7 @@ namespace WebCore { CALLBACK_FUNC_DECL(SVGMatrixInverse) { INC_STATS("DOM.SVGMatrix.inverse()"); - TransformationMatrix matrix = *V8Proxy::ToNativeObject<V8SVGPODTypeWrapper<TransformationMatrix> >(V8ClassIndex::SVGMATRIX, args.Holder()); + TransformationMatrix matrix = *V8DOMWrapper::convertToNativeObject<V8SVGPODTypeWrapper<TransformationMatrix> >(V8ClassIndex::SVGMATRIX, args.Holder()); ExceptionCode ec = 0; TransformationMatrix result = matrix.inverse(); @@ -54,17 +54,17 @@ CALLBACK_FUNC_DECL(SVGMatrixInverse) ec = SVGException::SVG_MATRIX_NOT_INVERTABLE; if (ec != 0) { - V8Proxy::SetDOMException(ec); + V8Proxy::setDOMException(ec); return v8::Handle<v8::Value>(); } - return V8Proxy::ToV8Object(V8ClassIndex::SVGMATRIX, new V8SVGStaticPODTypeWrapper<TransformationMatrix>(result)); + return V8DOMWrapper::convertToV8Object(V8ClassIndex::SVGMATRIX, V8SVGStaticPODTypeWrapper<TransformationMatrix>::create(result)); } CALLBACK_FUNC_DECL(SVGMatrixRotateFromVector) { INC_STATS("DOM.SVGMatrix.rotateFromVector()"); - TransformationMatrix matrix = *V8Proxy::ToNativeObject<V8SVGPODTypeWrapper<TransformationMatrix> >(V8ClassIndex::SVGMATRIX, args.Holder()); + TransformationMatrix matrix = *V8DOMWrapper::convertToNativeObject<V8SVGPODTypeWrapper<TransformationMatrix> >(V8ClassIndex::SVGMATRIX, args.Holder()); ExceptionCode ec = 0; float x = toFloat(args[0]); float y = toFloat(args[1]); @@ -74,11 +74,11 @@ CALLBACK_FUNC_DECL(SVGMatrixRotateFromVector) ec = SVGException::SVG_INVALID_VALUE_ERR; if (ec != 0) { - V8Proxy::SetDOMException(ec); + V8Proxy::setDOMException(ec); return v8::Handle<v8::Value>(); } - return V8Proxy::ToV8Object(V8ClassIndex::SVGMATRIX, new V8SVGStaticPODTypeWrapper<TransformationMatrix>(result)); + return V8DOMWrapper::convertToV8Object(V8ClassIndex::SVGMATRIX, V8SVGStaticPODTypeWrapper<TransformationMatrix>::create(result)); } } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8SharedWorkerCustom.cpp b/WebCore/bindings/v8/custom/V8SharedWorkerCustom.cpp new file mode 100644 index 0000000..3ab2f8e --- /dev/null +++ b/WebCore/bindings/v8/custom/V8SharedWorkerCustom.cpp @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#if ENABLE(SHARED_WORKERS) + +#include "SharedWorker.h" + +#include "ExceptionCode.h" +#include "Frame.h" +#include "V8Binding.h" +#include "V8CustomBinding.h" +#include "V8ObjectEventListener.h" +#include "V8Proxy.h" +#include "V8Utilities.h" +#include "WorkerContext.h" +#include "WorkerContextExecutionProxy.h" + +namespace WebCore { + +CALLBACK_FUNC_DECL(SharedWorkerConstructor) +{ + INC_STATS(L"DOM.SharedWorker.Constructor"); + + if (!args.IsConstructCall()) + return throwError("DOM object constructor cannot be called as a function."); + + if (args.Length() < 2) + return throwError("Not enough arguments", V8Proxy::SyntaxError); + + v8::TryCatch tryCatch; + v8::Handle<v8::String> scriptUrl = args[0]->ToString(); + v8::Handle<v8::String> name = args[1]->ToString(); + if (tryCatch.HasCaught()) + return throwError(tryCatch.Exception()); + + if (scriptUrl.IsEmpty()) + return v8::Undefined(); + + // Get the script execution context. + ScriptExecutionContext* context = 0; + WorkerContextExecutionProxy* proxy = WorkerContextExecutionProxy::retrieve(); + if (proxy) + context = proxy->workerContext(); + else { + Frame* frame = V8Proxy::retrieveFrame(); + if (!frame) + return v8::Undefined(); + context = frame->document(); + } + + // Create the worker object. + // Note: it's OK to let this RefPtr go out of scope because we also call SetDOMWrapper(), which effectively holds a reference to obj. + ExceptionCode ec = 0; + RefPtr<SharedWorker> obj = SharedWorker::create(toWebCoreString(scriptUrl), toWebCoreString(name), context, ec); + + // Setup the standard wrapper object internal fields. + v8::Handle<v8::Object> wrapperObject = args.Holder(); + V8Proxy::setDOMWrapper(wrapperObject, V8ClassIndex::SHAREDWORKER, obj.get()); + + obj->ref(); + V8Proxy::setJSWrapperForActiveDOMObject(obj.get(), v8::Persistent<v8::Object>::New(wrapperObject)); + + return wrapperObject; +} + +} // namespace WebCore + +#endif // ENABLE(SHARED_WORKERS) diff --git a/WebCore/bindings/v8/custom/V8StorageCustom.cpp b/WebCore/bindings/v8/custom/V8StorageCustom.cpp index af8b4c8..b54e50e 100755 --- a/WebCore/bindings/v8/custom/V8StorageCustom.cpp +++ b/WebCore/bindings/v8/custom/V8StorageCustom.cpp @@ -42,13 +42,12 @@ namespace WebCore { // Get an array containing the names of indexed properties in a collection. v8::Handle<v8::Array> V8Custom::v8StorageNamedPropertyEnumerator(const v8::AccessorInfo& info) { - Storage* storage = V8Proxy::ToNativeObject<Storage>(V8ClassIndex::STORAGE, info.Holder()); + Storage* storage = V8DOMWrapper::convertToNativeObject<Storage>(V8ClassIndex::STORAGE, info.Holder()); unsigned int length = storage->length(); v8::Handle<v8::Array> properties = v8::Array::New(length); for (unsigned int i = 0; i < length; ++i) { - ExceptionCode ec = 0; - String key = storage->key(i, ec); - ASSERT(!ec); + String key = storage->key(i); + ASSERT(!key.isNull()); String val = storage->getItem(key); properties->Set(v8::Integer::New(i), v8String(key)); } @@ -58,7 +57,7 @@ v8::Handle<v8::Array> V8Custom::v8StorageNamedPropertyEnumerator(const v8::Acces static v8::Handle<v8::Value> storageGetter(v8::Local<v8::String> v8Name, const v8::AccessorInfo& info) { - Storage* storage = V8Proxy::ToNativeObject<Storage>(V8ClassIndex::STORAGE, info.Holder()); + Storage* storage = V8DOMWrapper::convertToNativeObject<Storage>(V8ClassIndex::STORAGE, info.Holder()); String name = toWebCoreString(v8Name); if (storage->contains(name)) @@ -82,7 +81,7 @@ NAMED_PROPERTY_GETTER(Storage) static v8::Handle<v8::Value> storageSetter(v8::Local<v8::String> v8Name, v8::Local<v8::Value> v8Value, const v8::AccessorInfo& info) { - Storage* storage = V8Proxy::ToNativeObject<Storage>(V8ClassIndex::STORAGE, info.Holder()); + Storage* storage = V8DOMWrapper::convertToNativeObject<Storage>(V8ClassIndex::STORAGE, info.Holder()); String name = toWebCoreString(v8Name); String value = toWebCoreString(v8Value); @@ -117,7 +116,7 @@ NAMED_PROPERTY_SETTER(Storage) static v8::Handle<v8::Boolean> storageDeleter(v8::Local<v8::String> v8Name, const v8::AccessorInfo& info) { - Storage* storage = V8Proxy::ToNativeObject<Storage>(V8ClassIndex::STORAGE, info.Holder()); + Storage* storage = V8DOMWrapper::convertToNativeObject<Storage>(V8ClassIndex::STORAGE, info.Holder()); String name = toWebCoreString(v8Name); if (storage->contains(name)) { diff --git a/WebCore/bindings/v8/custom/V8StyleSheetListCustom.cpp b/WebCore/bindings/v8/custom/V8StyleSheetListCustom.cpp index a362ce5..ecd0153 100644 --- a/WebCore/bindings/v8/custom/V8StyleSheetListCustom.cpp +++ b/WebCore/bindings/v8/custom/V8StyleSheetListCustom.cpp @@ -45,12 +45,12 @@ NAMED_PROPERTY_GETTER(StyleSheetList) return notHandledByInterceptor(); // Search style sheet. - StyleSheetList* imp = V8Proxy::ToNativeObject<StyleSheetList>(V8ClassIndex::STYLESHEETLIST, info.Holder()); + StyleSheetList* imp = V8DOMWrapper::convertToNativeObject<StyleSheetList>(V8ClassIndex::STYLESHEETLIST, info.Holder()); HTMLStyleElement* item = imp->getNamedItem(toWebCoreString(name)); if (!item) return notHandledByInterceptor(); - return V8Proxy::ToV8Object(V8ClassIndex::HTMLSTYLEELEMENT, item); + return V8DOMWrapper::convertToV8Object(V8ClassIndex::HTMLSTYLEELEMENT, item); } } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8TreeWalkerCustom.cpp b/WebCore/bindings/v8/custom/V8TreeWalkerCustom.cpp index baf49c0..5052b7a 100644 --- a/WebCore/bindings/v8/custom/V8TreeWalkerCustom.cpp +++ b/WebCore/bindings/v8/custom/V8TreeWalkerCustom.cpp @@ -51,13 +51,13 @@ static inline v8::Handle<v8::Value> toV8(PassRefPtr<Node> object, ScriptState* s if (!object) return v8::Null(); - return V8Proxy::NodeToV8Object(object.get()); + return V8DOMWrapper::convertNodeToV8Object(object); } CALLBACK_FUNC_DECL(TreeWalkerParentNode) { INC_STATS("DOM.TreeWalker.parentNode()"); - TreeWalker* treeWalker = V8Proxy::ToNativeObject<TreeWalker>(V8ClassIndex::TREEWALKER, args.Holder()); + TreeWalker* treeWalker = V8DOMWrapper::convertToNativeObject<TreeWalker>(V8ClassIndex::TREEWALKER, args.Holder()); ScriptState state; RefPtr<Node> result = treeWalker->parentNode(&state); @@ -67,7 +67,7 @@ CALLBACK_FUNC_DECL(TreeWalkerParentNode) CALLBACK_FUNC_DECL(TreeWalkerFirstChild) { INC_STATS("DOM.TreeWalker.firstChild()"); - TreeWalker* treeWalker = V8Proxy::ToNativeObject<TreeWalker>(V8ClassIndex::TREEWALKER, args.Holder()); + TreeWalker* treeWalker = V8DOMWrapper::convertToNativeObject<TreeWalker>(V8ClassIndex::TREEWALKER, args.Holder()); ScriptState state; RefPtr<Node> result = treeWalker->firstChild(&state); @@ -77,7 +77,7 @@ CALLBACK_FUNC_DECL(TreeWalkerFirstChild) CALLBACK_FUNC_DECL(TreeWalkerLastChild) { INC_STATS("DOM.TreeWalker.lastChild()"); - TreeWalker* treeWalker = V8Proxy::ToNativeObject<TreeWalker>(V8ClassIndex::TREEWALKER, args.Holder()); + TreeWalker* treeWalker = V8DOMWrapper::convertToNativeObject<TreeWalker>(V8ClassIndex::TREEWALKER, args.Holder()); ScriptState state; RefPtr<Node> result = treeWalker->lastChild(&state); @@ -87,7 +87,7 @@ CALLBACK_FUNC_DECL(TreeWalkerLastChild) CALLBACK_FUNC_DECL(TreeWalkerNextNode) { INC_STATS("DOM.TreeWalker.nextNode()"); - TreeWalker* treeWalker = V8Proxy::ToNativeObject<TreeWalker>(V8ClassIndex::TREEWALKER, args.Holder()); + TreeWalker* treeWalker = V8DOMWrapper::convertToNativeObject<TreeWalker>(V8ClassIndex::TREEWALKER, args.Holder()); ScriptState state; RefPtr<Node> result = treeWalker->nextNode(&state); @@ -97,7 +97,7 @@ CALLBACK_FUNC_DECL(TreeWalkerNextNode) CALLBACK_FUNC_DECL(TreeWalkerPreviousNode) { INC_STATS("DOM.TreeWalker.previousNode()"); - TreeWalker* treeWalker = V8Proxy::ToNativeObject<TreeWalker>(V8ClassIndex::TREEWALKER, args.Holder()); + TreeWalker* treeWalker = V8DOMWrapper::convertToNativeObject<TreeWalker>(V8ClassIndex::TREEWALKER, args.Holder()); ScriptState state; RefPtr<Node> result = treeWalker->previousNode(&state); @@ -107,7 +107,7 @@ CALLBACK_FUNC_DECL(TreeWalkerPreviousNode) CALLBACK_FUNC_DECL(TreeWalkerNextSibling) { INC_STATS("DOM.TreeWalker.nextSibling()"); - TreeWalker* treeWalker = V8Proxy::ToNativeObject<TreeWalker>(V8ClassIndex::TREEWALKER, args.Holder()); + TreeWalker* treeWalker = V8DOMWrapper::convertToNativeObject<TreeWalker>(V8ClassIndex::TREEWALKER, args.Holder()); ScriptState state; RefPtr<Node> result = treeWalker->nextSibling(&state); @@ -117,7 +117,7 @@ CALLBACK_FUNC_DECL(TreeWalkerNextSibling) CALLBACK_FUNC_DECL(TreeWalkerPreviousSibling) { INC_STATS("DOM.TreeWalker.previousSibling()"); - TreeWalker* treeWalker = V8Proxy::ToNativeObject<TreeWalker>(V8ClassIndex::TREEWALKER, args.Holder()); + TreeWalker* treeWalker = V8DOMWrapper::convertToNativeObject<TreeWalker>(V8ClassIndex::TREEWALKER, args.Holder()); ScriptState state; RefPtr<Node> result = treeWalker->previousSibling(&state); diff --git a/WebCore/bindings/v8/custom/V8WebKitCSSMatrixConstructor.cpp b/WebCore/bindings/v8/custom/V8WebKitCSSMatrixConstructor.cpp index b07d288..4819064 100644 --- a/WebCore/bindings/v8/custom/V8WebKitCSSMatrixConstructor.cpp +++ b/WebCore/bindings/v8/custom/V8WebKitCSSMatrixConstructor.cpp @@ -47,7 +47,11 @@ namespace WebCore { CALLBACK_FUNC_DECL(WebKitCSSMatrixConstructor) { INC_STATS("DOM.WebKitCSSMatrix.Constructor"); - // FIXME: The logic here is almost exact duplicate of V8::ConstructDOMObject. + + if (!args.IsConstructCall()) + return throwError("DOM object constructor cannot be called as a function."); + + // FIXME: The logic here is almost exact duplicate of V8::constructDOMObject. // Consider refactoring to reduce duplication. String cssValue; if (args.Length() >= 1) @@ -59,7 +63,7 @@ CALLBACK_FUNC_DECL(WebKitCSSMatrixConstructor) throwError(ec); // Transform the holder into a wrapper object for the matrix. - V8Proxy::SetDOMWrapper(args.Holder(), V8ClassIndex::ToInt(V8ClassIndex::WEBKITCSSMATRIX), matrix.get()); + V8DOMWrapper::setDOMWrapper(args.Holder(), V8ClassIndex::ToInt(V8ClassIndex::WEBKITCSSMATRIX), matrix.get()); return toV8(matrix.release(), args.Holder()); } diff --git a/WebCore/bindings/v8/custom/V8WebKitPointConstructor.cpp b/WebCore/bindings/v8/custom/V8WebKitPointConstructor.cpp index d70ebf1..dd19a88 100755 --- a/WebCore/bindings/v8/custom/V8WebKitPointConstructor.cpp +++ b/WebCore/bindings/v8/custom/V8WebKitPointConstructor.cpp @@ -40,7 +40,7 @@ namespace WebCore { CALLBACK_FUNC_DECL(WebKitPointConstructor) { INC_STATS("DOM.WebKitPoint.Constructor"); - return V8Proxy::ConstructDOMObject<V8ClassIndex::WEBKITPOINT, WebKitPoint>(args); + return V8Proxy::constructDOMObject<V8ClassIndex::WEBKITPOINT, WebKitPoint>(args); } } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp b/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp index a67cb10..b526040 100755 --- a/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp +++ b/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp @@ -32,11 +32,8 @@ #if ENABLE(WORKERS) -#include "WorkerContextExecutionProxy.h" - -#include "ExceptionCode.h" #include "DOMTimer.h" -#include "NotImplemented.h" +#include "ExceptionCode.h" #include "ScheduledAction.h" #include "V8Binding.h" #include "V8CustomBinding.h" @@ -44,50 +41,51 @@ #include "V8Utilities.h" #include "V8WorkerContextEventListener.h" #include "WorkerContext.h" +#include "WorkerContextExecutionProxy.h" namespace WebCore { ACCESSOR_GETTER(WorkerContextSelf) { INC_STATS(L"DOM.WorkerContext.self._get"); - WorkerContext* workerContext = V8Proxy::ToNativeObject<WorkerContext>(V8ClassIndex::WORKERCONTEXT, info.Holder()); - return WorkerContextExecutionProxy::WorkerContextToV8Object(workerContext); + WorkerContext* workerContext = V8DOMWrapper::convertDOMWrapperToNative<WorkerContext>(info.Holder()); + return WorkerContextExecutionProxy::convertWorkerContextToV8Object(workerContext); } -ACCESSOR_GETTER(WorkerContextOnmessage) +ACCESSOR_GETTER(WorkerContextOnerror) { - INC_STATS(L"DOM.WorkerContext.onmessage._get"); - WorkerContext* workerContext = V8Proxy::ToNativeObject<WorkerContext>(V8ClassIndex::WORKERCONTEXT, info.Holder()); - if (workerContext->onmessage()) { - V8WorkerContextEventListener* listener = static_cast<V8WorkerContextEventListener*>(workerContext->onmessage()); + INC_STATS(L"DOM.WorkerContext.onerror._get"); + WorkerContext* workerContext = V8DOMWrapper::convertToNativeObject<WorkerContext>(V8ClassIndex::WORKERCONTEXT, info.Holder()); + if (workerContext->onerror()) { + V8WorkerContextEventListener* listener = static_cast<V8WorkerContextEventListener*>(workerContext->onerror()); v8::Local<v8::Object> v8Listener = listener->getListenerObject(); return v8Listener; } return v8::Undefined(); } -ACCESSOR_SETTER(WorkerContextOnmessage) +ACCESSOR_SETTER(WorkerContextOnerror) { - INC_STATS(L"DOM.WorkerContext.onmessage._set"); - WorkerContext* workerContext = V8Proxy::ToNativeObject<WorkerContext>(V8ClassIndex::WORKERCONTEXT, info.Holder()); - V8WorkerContextEventListener* oldListener = static_cast<V8WorkerContextEventListener*>(workerContext->onmessage()); + INC_STATS(L"DOM.WorkerContext.onerror._set"); + WorkerContext* workerContext = V8DOMWrapper::convertToNativeObject<WorkerContext>(V8ClassIndex::WORKERCONTEXT, info.Holder()); + V8WorkerContextEventListener* oldListener = static_cast<V8WorkerContextEventListener*>(workerContext->onerror()); if (value->IsNull()) { - if (workerContext->onmessage()) { + if (workerContext->onerror()) { v8::Local<v8::Object> oldV8Listener = oldListener->getListenerObject(); removeHiddenDependency(info.Holder(), oldV8Listener, V8Custom::kWorkerContextRequestCacheIndex); } // Clear the listener. - workerContext->setOnmessage(0); + workerContext->setOnerror(0); } else { - RefPtr<V8EventListener> listener = workerContext->script()->proxy()->findOrCreateEventListener(v8::Local<v8::Object>::Cast(value), false, false); + RefPtr<V8EventListener> listener = workerContext->script()->proxy()->findOrCreateEventListener(v8::Local<v8::Object>::Cast(value), true, false); if (listener) { if (oldListener) { v8::Local<v8::Object> oldV8Listener = oldListener->getListenerObject(); removeHiddenDependency(info.Holder(), oldV8Listener, V8Custom::kWorkerContextRequestCacheIndex); } - workerContext->setOnmessage(listener); + workerContext->setOnerror(listener); createHiddenDependency(info.Holder(), value, V8Custom::kWorkerContextRequestCacheIndex); } } @@ -95,7 +93,7 @@ ACCESSOR_SETTER(WorkerContextOnmessage) v8::Handle<v8::Value> SetTimeoutOrInterval(const v8::Arguments& args, bool singleShot) { - WorkerContext* workerContext = V8Proxy::ToNativeObject<WorkerContext>(V8ClassIndex::WORKERCONTEXT, args.Holder()); + WorkerContext* workerContext = V8DOMWrapper::convertDOMWrapperToNative<WorkerContext>(args.Holder()); int argumentCount = args.Length(); if (argumentCount < 1) @@ -106,7 +104,7 @@ v8::Handle<v8::Value> SetTimeoutOrInterval(const v8::Arguments& args, bool singl int timerId; if (function->IsString()) { - WebCore::String stringFunction = ToWebCoreString(function); + WebCore::String stringFunction = toWebCoreString(function); timerId = DOMTimer::install(workerContext, new ScheduledAction(stringFunction, workerContext->url()), timeout, singleShot); } else if (function->IsFunction()) { size_t paramCount = argumentCount >= 2 ? argumentCount - 2 : 0; @@ -129,7 +127,29 @@ v8::Handle<v8::Value> SetTimeoutOrInterval(const v8::Arguments& args, bool singl CALLBACK_FUNC_DECL(WorkerContextImportScripts) { INC_STATS(L"DOM.WorkerContext.importScripts()"); - notImplemented(); + if (!args.Length()) + return v8::Undefined(); + + String callerURL = V8Proxy::sourceName(); + int callerLine = V8Proxy::sourceLineNumber() + 1; + + Vector<String> urls; + for (int i = 0; i < args.Length(); i++) { + v8::TryCatch tryCatch; + v8::Handle<v8::String> scriptUrl = args[i]->ToString(); + if (tryCatch.HasCaught() || scriptUrl.IsEmpty()) + return v8::Undefined(); + urls.append(toWebCoreString(scriptUrl)); + } + + WorkerContext* workerContext = V8DOMWrapper::convertDOMWrapperToNative<WorkerContext>(args.Holder()); + + ExceptionCode ec = 0; + workerContext->importScripts(urls, callerURL, callerLine, ec); + + if (ec) + return throwError(ec); + return v8::Undefined(); } @@ -139,7 +159,8 @@ CALLBACK_FUNC_DECL(WorkerContextSetTimeout) return SetTimeoutOrInterval(args, true); } -CALLBACK_FUNC_DECL(WorkerContextSetInterval) { +CALLBACK_FUNC_DECL(WorkerContextSetInterval) +{ INC_STATS(L"DOM.WorkerContext.setInterval()"); return SetTimeoutOrInterval(args, false); } @@ -147,7 +168,7 @@ CALLBACK_FUNC_DECL(WorkerContextSetInterval) { CALLBACK_FUNC_DECL(WorkerContextAddEventListener) { INC_STATS(L"DOM.WorkerContext.addEventListener()"); - WorkerContext* workerContext = V8Proxy::ToNativeObject<WorkerContext>(V8ClassIndex::WORKERCONTEXT, args.Holder()); + WorkerContext* workerContext = V8DOMWrapper::convertDOMWrapperToNative<WorkerContext>(args.Holder()); RefPtr<V8EventListener> listener = workerContext->script()->proxy()->findOrCreateEventListener(v8::Local<v8::Object>::Cast(args[1]), false, false); @@ -164,7 +185,7 @@ CALLBACK_FUNC_DECL(WorkerContextAddEventListener) CALLBACK_FUNC_DECL(WorkerContextRemoveEventListener) { INC_STATS(L"DOM.WorkerContext.removeEventListener()"); - WorkerContext* workerContext = V8Proxy::ToNativeObject<WorkerContext>(V8ClassIndex::WORKERCONTEXT, args.Holder()); + WorkerContext* workerContext = V8DOMWrapper::convertDOMWrapperToNative<WorkerContext>(args.Holder()); WorkerContextExecutionProxy* proxy = workerContext->script()->proxy(); RefPtr<V8EventListener> listener = proxy->findOrCreateEventListener(v8::Local<v8::Object>::Cast(args[1]), false, true); diff --git a/WebCore/bindings/v8/custom/V8WorkerCustom.cpp b/WebCore/bindings/v8/custom/V8WorkerCustom.cpp index 3edaa8e..32450b8 100755 --- a/WebCore/bindings/v8/custom/V8WorkerCustom.cpp +++ b/WebCore/bindings/v8/custom/V8WorkerCustom.cpp @@ -50,23 +50,17 @@ CALLBACK_FUNC_DECL(WorkerConstructor) { INC_STATS(L"DOM.Worker.Constructor"); - if (!WorkerContextExecutionProxy::isWebWorkersEnabled()) { - return throwError("Worker is not enabled.", V8Proxy::SYNTAX_ERROR); - } - - if (!args.IsConstructCall()) { + if (!args.IsConstructCall()) return throwError("DOM object constructor cannot be called as a function."); - } - if (args.Length() == 0) { - return throwError("Not enough arguments", V8Proxy::SYNTAX_ERROR); - } + if (!args.Length()) + return throwError("Not enough arguments", V8Proxy::SyntaxError); v8::TryCatch tryCatch; v8::Handle<v8::String> scriptUrl = args[0]->ToString(); - if (tryCatch.HasCaught()) { + if (tryCatch.HasCaught()) return throwError(tryCatch.Exception()); - } + if (scriptUrl.IsEmpty()) return v8::Undefined(); @@ -76,38 +70,42 @@ CALLBACK_FUNC_DECL(WorkerConstructor) if (proxy) context = proxy->workerContext(); else { - Frame* frame = V8Proxy::retrieveFrame(); + Frame* frame = V8Proxy::retrieveFrameForCurrentContext(); if (!frame) return v8::Undefined(); context = frame->document(); } // Create the worker object. - // Note: it's OK to let this RefPtr go out of scope because we also call SetDOMWrapper(), which effectively holds a reference to obj. + // Note: it's OK to let this RefPtr go out of scope because we also call setDOMWrapper(), which effectively holds a reference to obj. ExceptionCode ec = 0; RefPtr<Worker> obj = Worker::create(toWebCoreString(scriptUrl), context, ec); + if (ec) + return throwError(ec); // Setup the standard wrapper object internal fields. v8::Handle<v8::Object> wrapperObject = args.Holder(); - V8Proxy::SetDOMWrapper(wrapperObject, V8ClassIndex::WORKER, obj.get()); + V8DOMWrapper::setDOMWrapper(wrapperObject, V8ClassIndex::WORKER, obj.get()); obj->ref(); - V8Proxy::SetJSWrapperForActiveDOMObject(obj.get(), v8::Persistent<v8::Object>::New(wrapperObject)); + V8DOMWrapper::setJSWrapperForActiveDOMObject(obj.get(), v8::Persistent<v8::Object>::New(wrapperObject)); return wrapperObject; } -PassRefPtr<EventListener> getEventListener(Worker* worker, v8::Local<v8::Value> value, bool findOnly) +PassRefPtr<EventListener> getEventListener(Worker* worker, v8::Local<v8::Value> value, bool isAttribute, bool findOnly) { if (worker->scriptExecutionContext()->isWorkerContext()) { WorkerContextExecutionProxy* workerContextProxy = WorkerContextExecutionProxy::retrieve(); ASSERT(workerContextProxy); - return workerContextProxy->findOrCreateObjectEventListener(value, false, findOnly); + return workerContextProxy->findOrCreateObjectEventListener(value, isAttribute, findOnly); } V8Proxy* proxy = V8Proxy::retrieve(worker->scriptExecutionContext()); - if (proxy) - return findOnly ? proxy->FindObjectEventListener(value, false) : proxy->FindOrCreateObjectEventListener(value, false); + if (proxy) { + V8EventListenerList* list = proxy->objectListeners(); + return findOnly ? list->findWrapper(value, isAttribute) : list->findOrCreateWrapper<V8ObjectEventListener>(proxy->frame(), value, isAttribute); + } return 0; } @@ -115,7 +113,7 @@ PassRefPtr<EventListener> getEventListener(Worker* worker, v8::Local<v8::Value> ACCESSOR_GETTER(WorkerOnmessage) { INC_STATS(L"DOM.Worker.onmessage._get"); - Worker* worker = V8Proxy::ToNativeObject<Worker>(V8ClassIndex::WORKER, info.Holder()); + Worker* worker = V8DOMWrapper::convertToNativeObject<Worker>(V8ClassIndex::WORKER, info.Holder()); if (worker->onmessage()) { V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(worker->onmessage()); v8::Local<v8::Object> v8Listener = listener->getListenerObject(); @@ -127,7 +125,7 @@ ACCESSOR_GETTER(WorkerOnmessage) ACCESSOR_SETTER(WorkerOnmessage) { INC_STATS(L"DOM.Worker.onmessage._set"); - Worker* worker = V8Proxy::ToNativeObject<Worker>(V8ClassIndex::WORKER, info.Holder()); + Worker* worker = V8DOMWrapper::convertToNativeObject<Worker>(V8ClassIndex::WORKER, info.Holder()); V8ObjectEventListener* oldListener = static_cast<V8ObjectEventListener*>(worker->onmessage()); if (value->IsNull()) { if (oldListener) { @@ -138,7 +136,7 @@ ACCESSOR_SETTER(WorkerOnmessage) // Clear the listener. worker->setOnmessage(0); } else { - RefPtr<EventListener> listener = getEventListener(worker, value, false); + RefPtr<EventListener> listener = getEventListener(worker, value, true, false); if (listener) { if (oldListener) { v8::Local<v8::Object> oldV8Listener = oldListener->getListenerObject(); @@ -151,78 +149,6 @@ ACCESSOR_SETTER(WorkerOnmessage) } } -ACCESSOR_GETTER(WorkerOnerror) -{ - INC_STATS(L"DOM.Worker.onerror._get"); - Worker* worker = V8Proxy::ToNativeObject<Worker>(V8ClassIndex::WORKER, info.Holder()); - if (worker->onerror()) { - V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(worker->onerror()); - v8::Local<v8::Object> v8Listener = listener->getListenerObject(); - return v8Listener; - } - return v8::Undefined(); -} - -ACCESSOR_SETTER(WorkerOnerror) -{ - INC_STATS(L"DOM.Worker.onerror._set"); - Worker* worker = V8Proxy::ToNativeObject<Worker>(V8ClassIndex::WORKER, info.Holder()); - V8ObjectEventListener* oldListener = static_cast<V8ObjectEventListener*>(worker->onerror()); - if (value->IsNull()) { - if (oldListener) { - v8::Local<v8::Object> oldV8Listener = oldListener->getListenerObject(); - removeHiddenDependency(info.Holder(), oldV8Listener, V8Custom::kWorkerRequestCacheIndex); - } - - // Clear the listener. - worker->setOnerror(0); - } else { - RefPtr<EventListener> listener = getEventListener(worker, value, false); - if (listener) { - if (oldListener) { - v8::Local<v8::Object> oldV8Listener = oldListener->getListenerObject(); - removeHiddenDependency(info.Holder(), oldV8Listener, V8Custom::kWorkerRequestCacheIndex); - } - - worker->setOnerror(listener); - createHiddenDependency(info.Holder(), value, V8Custom::kWorkerRequestCacheIndex); - } - } -} - -CALLBACK_FUNC_DECL(WorkerAddEventListener) -{ - INC_STATS(L"DOM.Worker.addEventListener()"); - Worker* worker = V8Proxy::ToNativeObject<Worker>(V8ClassIndex::WORKER, args.Holder()); - - RefPtr<EventListener> listener = getEventListener(worker, args[1], false); - if (listener) { - String type = toWebCoreString(args[0]); - bool useCapture = args[2]->BooleanValue(); - worker->addEventListener(type, listener, useCapture); - - createHiddenDependency(args.Holder(), args[1], V8Custom::kWorkerRequestCacheIndex); - } - return v8::Undefined(); -} - -CALLBACK_FUNC_DECL(WorkerRemoveEventListener) -{ - INC_STATS(L"DOM.Worker.removeEventListener()"); - Worker* worker = V8Proxy::ToNativeObject<Worker>(V8ClassIndex::WORKER, args.Holder()); - - RefPtr<EventListener> listener = getEventListener(worker, args[1], true); - if (listener) { - String type = toWebCoreString(args[0]); - bool useCapture = args[2]->BooleanValue(); - worker->removeEventListener(type, listener.get(), useCapture); - - removeHiddenDependency(args.Holder(), args[1], V8Custom::kWorkerRequestCacheIndex); - } - - return v8::Undefined(); -} - } // namespace WebCore #endif // ENABLE(WORKERS) diff --git a/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp b/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp index c913c08..02ce8e2 100644 --- a/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp +++ b/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp @@ -46,7 +46,7 @@ CALLBACK_FUNC_DECL(XMLHttpRequestConstructor) INC_STATS("DOM.XMLHttpRequest.Constructor"); if (!args.IsConstructCall()) - return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TYPE_ERROR); + return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError); // Expect no parameters. // Allocate a XMLHttpRequest object as its internal field. @@ -55,15 +55,21 @@ CALLBACK_FUNC_DECL(XMLHttpRequestConstructor) WorkerContextExecutionProxy* proxy = WorkerContextExecutionProxy::retrieve(); if (proxy) context = proxy->workerContext(); - else + else { +#endif + Frame* frame = V8Proxy::retrieveFrameForCurrentContext(); + if (!frame) + return throwError("XMLHttpRequest constructor's associated frame is not available", V8Proxy::ReferenceError); + context = frame->document(); +#if ENABLE(WORKERS) + } #endif - context = V8Proxy::retrieveFrame()->document(); RefPtr<XMLHttpRequest> xmlHttpRequest = XMLHttpRequest::create(context); - V8Proxy::SetDOMWrapper(args.Holder(), V8ClassIndex::ToInt(V8ClassIndex::XMLHTTPREQUEST), xmlHttpRequest.get()); + V8DOMWrapper::setDOMWrapper(args.Holder(), V8ClassIndex::ToInt(V8ClassIndex::XMLHTTPREQUEST), xmlHttpRequest.get()); // Add object to the wrapper map. xmlHttpRequest->ref(); - V8Proxy::SetJSWrapperForActiveDOMObject(xmlHttpRequest.get(), v8::Persistent<v8::Object>::New(args.Holder())); + V8DOMWrapper::setJSWrapperForActiveDOMObject(xmlHttpRequest.get(), v8::Persistent<v8::Object>::New(args.Holder())); return args.Holder(); } diff --git a/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp b/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp index cb80a4f..7204a61 100644 --- a/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp +++ b/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp @@ -44,7 +44,7 @@ namespace WebCore { -PassRefPtr<EventListener> getEventListener(XMLHttpRequest* xmlHttpRequest, v8::Local<v8::Value> value, bool findOnly) +static PassRefPtr<EventListener> getEventListener(XMLHttpRequest* xmlHttpRequest, v8::Local<v8::Value> value, bool findOnly) { #if ENABLE(WORKERS) WorkerContextExecutionProxy* workerContextProxy = WorkerContextExecutionProxy::retrieve(); @@ -53,8 +53,10 @@ PassRefPtr<EventListener> getEventListener(XMLHttpRequest* xmlHttpRequest, v8::L #endif V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest->scriptExecutionContext()); - if (proxy) - return findOnly ? proxy->FindObjectEventListener(value, false) : proxy->FindOrCreateObjectEventListener(value, false); + if (proxy) { + V8EventListenerList* list = proxy->objectListeners(); + return findOnly ? list->findWrapper(value, false) : list->findOrCreateWrapper<V8ObjectEventListener>(proxy->frame(), value, false); + } return PassRefPtr<EventListener>(); } @@ -62,7 +64,7 @@ PassRefPtr<EventListener> getEventListener(XMLHttpRequest* xmlHttpRequest, v8::L ACCESSOR_GETTER(XMLHttpRequestOnabort) { INC_STATS("DOM.XMLHttpRequest.onabort._get"); - XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder()); + XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder()); if (xmlHttpRequest->onabort()) { V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onabort()); v8::Local<v8::Object> v8Listener = listener->getListenerObject(); @@ -74,7 +76,7 @@ ACCESSOR_GETTER(XMLHttpRequestOnabort) ACCESSOR_SETTER(XMLHttpRequestOnabort) { INC_STATS("DOM.XMLHttpRequest.onabort._set"); - XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder()); + XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder()); if (value->IsNull()) { if (xmlHttpRequest->onabort()) { V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onabort()); @@ -96,7 +98,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnabort) ACCESSOR_GETTER(XMLHttpRequestOnerror) { INC_STATS("DOM.XMLHttpRequest.onerror._get"); - XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder()); + XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder()); if (xmlHttpRequest->onerror()) { RefPtr<V8ObjectEventListener> listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onerror()); v8::Local<v8::Object> v8Listener = listener->getListenerObject(); @@ -108,7 +110,7 @@ ACCESSOR_GETTER(XMLHttpRequestOnerror) ACCESSOR_SETTER(XMLHttpRequestOnerror) { INC_STATS("DOM.XMLHttpRequest.onerror._set"); - XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder()); + XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder()); if (value->IsNull()) { if (xmlHttpRequest->onerror()) { V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onerror()); @@ -130,7 +132,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnerror) ACCESSOR_GETTER(XMLHttpRequestOnload) { INC_STATS("DOM.XMLHttpRequest.onload._get"); - XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder()); + XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder()); if (xmlHttpRequest->onload()) { V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onload()); v8::Local<v8::Object> v8Listener = listener->getListenerObject(); @@ -142,7 +144,7 @@ ACCESSOR_GETTER(XMLHttpRequestOnload) ACCESSOR_SETTER(XMLHttpRequestOnload) { INC_STATS("DOM.XMLHttpRequest.onload._set"); - XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder()); + XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder()); if (value->IsNull()) { if (xmlHttpRequest->onload()) { V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onload()); @@ -164,7 +166,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnload) ACCESSOR_GETTER(XMLHttpRequestOnloadstart) { INC_STATS("DOM.XMLHttpRequest.onloadstart._get"); - XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder()); + XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder()); if (xmlHttpRequest->onloadstart()) { V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onloadstart()); v8::Local<v8::Object> v8Listener = listener->getListenerObject(); @@ -176,7 +178,7 @@ ACCESSOR_GETTER(XMLHttpRequestOnloadstart) ACCESSOR_SETTER(XMLHttpRequestOnloadstart) { INC_STATS("DOM.XMLHttpRequest.onloadstart._set"); - XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder()); + XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder()); if (value->IsNull()) { if (xmlHttpRequest->onloadstart()) { V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onloadstart()); @@ -198,7 +200,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnloadstart) ACCESSOR_GETTER(XMLHttpRequestOnprogress) { INC_STATS("DOM.XMLHttpRequest.onprogress._get"); - XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder()); + XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder()); if (xmlHttpRequest->onprogress()) { V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onprogress()); v8::Local<v8::Object> v8Listener = listener->getListenerObject(); @@ -210,7 +212,7 @@ ACCESSOR_GETTER(XMLHttpRequestOnprogress) ACCESSOR_SETTER(XMLHttpRequestOnprogress) { INC_STATS("DOM.XMLHttpRequest.onprogress._set"); - XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder()); + XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder()); if (value->IsNull()) { if (xmlHttpRequest->onprogress()) { V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onprogress()); @@ -232,7 +234,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnprogress) ACCESSOR_GETTER(XMLHttpRequestOnreadystatechange) { INC_STATS("DOM.XMLHttpRequest.onreadystatechange._get"); - XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder()); + XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder()); if (xmlHttpRequest->onreadystatechange()) { V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onreadystatechange()); v8::Local<v8::Object> v8Listener = listener->getListenerObject(); @@ -244,7 +246,7 @@ ACCESSOR_GETTER(XMLHttpRequestOnreadystatechange) ACCESSOR_SETTER(XMLHttpRequestOnreadystatechange) { INC_STATS("DOM.XMLHttpRequest.onreadystatechange._set"); - XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder()); + XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder()); if (value->IsNull()) { if (xmlHttpRequest->onreadystatechange()) { V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onreadystatechange()); @@ -268,14 +270,14 @@ ACCESSOR_GETTER(XMLHttpRequestResponseText) // FIXME: This is only needed because webkit set this getter as custom. // So we need a custom method to avoid forking the IDL file. INC_STATS("DOM.XMLHttpRequest.responsetext._get"); - XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder()); + XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder()); return v8StringOrNull(xmlHttpRequest->responseText()); } CALLBACK_FUNC_DECL(XMLHttpRequestAddEventListener) { INC_STATS("DOM.XMLHttpRequest.addEventListener()"); - XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder()); + XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder()); RefPtr<EventListener> listener = getEventListener(xmlHttpRequest, args[1], false); if (listener) { @@ -291,7 +293,7 @@ CALLBACK_FUNC_DECL(XMLHttpRequestAddEventListener) CALLBACK_FUNC_DECL(XMLHttpRequestRemoveEventListener) { INC_STATS("DOM.XMLHttpRequest.removeEventListener()"); - XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder()); + XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder()); RefPtr<EventListener> listener = getEventListener(xmlHttpRequest, args[1], true); if (listener) { @@ -315,9 +317,9 @@ CALLBACK_FUNC_DECL(XMLHttpRequestOpen) // open(method, url, async, user, passwd) if (args.Length() < 2) - return throwError("Not enough arguments", V8Proxy::SYNTAX_ERROR); + return throwError("Not enough arguments", V8Proxy::SyntaxError); - XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder()); + XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder()); String method = toWebCoreString(args[0]); String urlstring = toWebCoreString(args[1]); @@ -345,10 +347,10 @@ CALLBACK_FUNC_DECL(XMLHttpRequestOpen) ExceptionCode ec = 0; String user, passwd; if (args.Length() >= 4 && !args[3]->IsUndefined()) { - user = valueToStringWithNullCheck(args[3]); + user = toWebCoreStringWithNullCheck(args[3]); if (args.Length() >= 5 && !args[4]->IsUndefined()) { - passwd = valueToStringWithNullCheck(args[4]); + passwd = toWebCoreStringWithNullCheck(args[4]); xmlHttpRequest->open(method, url, async, user, passwd, ec); } else xmlHttpRequest->open(method, url, async, user, ec); @@ -370,7 +372,7 @@ static bool IsDocumentType(v8::Handle<v8::Value> value) CALLBACK_FUNC_DECL(XMLHttpRequestSend) { INC_STATS("DOM.XMLHttpRequest.send()"); - XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder()); + XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder()); ExceptionCode ec = 0; if (args.Length() < 1) @@ -380,11 +382,11 @@ CALLBACK_FUNC_DECL(XMLHttpRequestSend) // FIXME: upstream handles "File" objects too. if (IsDocumentType(arg)) { v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); - Document* document = V8Proxy::DOMWrapperToNode<Document>(object); + Document* document = V8DOMWrapper::convertDOMWrapperToNode<Document>(object); ASSERT(document); xmlHttpRequest->send(document, ec); } else - xmlHttpRequest->send(valueToStringWithNullCheck(arg), ec); + xmlHttpRequest->send(toWebCoreStringWithNullCheck(arg), ec); } if (ec) @@ -396,9 +398,9 @@ CALLBACK_FUNC_DECL(XMLHttpRequestSend) CALLBACK_FUNC_DECL(XMLHttpRequestSetRequestHeader) { INC_STATS("DOM.XMLHttpRequest.setRequestHeader()"); if (args.Length() < 2) - return throwError("Not enough arguments", V8Proxy::SYNTAX_ERROR); + return throwError("Not enough arguments", V8Proxy::SyntaxError); - XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder()); + XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder()); ExceptionCode ec = 0; String header = toWebCoreString(args[0]); String value = toWebCoreString(args[1]); @@ -412,9 +414,9 @@ CALLBACK_FUNC_DECL(XMLHttpRequestGetResponseHeader) { INC_STATS("DOM.XMLHttpRequest.getResponseHeader()"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::SYNTAX_ERROR); + return throwError("Not enough arguments", V8Proxy::SyntaxError); - XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder()); + XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder()); ExceptionCode ec = 0; String header = toWebCoreString(args[0]); String result = xmlHttpRequest->getResponseHeader(header, ec); @@ -427,9 +429,9 @@ CALLBACK_FUNC_DECL(XMLHttpRequestOverrideMimeType) { INC_STATS("DOM.XMLHttpRequest.overrideMimeType()"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::SYNTAX_ERROR); + return throwError("Not enough arguments", V8Proxy::SyntaxError); - XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder()); + XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder()); String value = toWebCoreString(args[0]); xmlHttpRequest->overrideMimeType(value); return v8::Undefined(); diff --git a/WebCore/bindings/v8/custom/V8XMLHttpRequestUploadCustom.cpp b/WebCore/bindings/v8/custom/V8XMLHttpRequestUploadCustom.cpp index 7afa82c..bbc69dd 100644 --- a/WebCore/bindings/v8/custom/V8XMLHttpRequestUploadCustom.cpp +++ b/WebCore/bindings/v8/custom/V8XMLHttpRequestUploadCustom.cpp @@ -46,7 +46,7 @@ namespace WebCore { ACCESSOR_GETTER(XMLHttpRequestUploadOnabort) { INC_STATS("DOM.XMLHttpRequestUpload.onabort._get"); - XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); + XMLHttpRequestUpload* xmlHttpRequestUpload = V8DOMWrapper::convertToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); if (xmlHttpRequestUpload->onabort()) { V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onabort()); v8::Local<v8::Object> v8Listener = listener->getListenerObject(); @@ -58,7 +58,7 @@ ACCESSOR_GETTER(XMLHttpRequestUploadOnabort) ACCESSOR_SETTER(XMLHttpRequestUploadOnabort) { INC_STATS("DOM.XMLHttpRequestUpload.onabort._set"); - XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); + XMLHttpRequestUpload* xmlHttpRequestUpload = V8DOMWrapper::convertToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); if (value->IsNull()) { if (xmlHttpRequestUpload->onabort()) { V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onabort()); @@ -74,7 +74,7 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnabort) if (!proxy) return; - RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false); + RefPtr<EventListener> listener = proxy->objectListeners()->findOrCreateWrapper<V8ObjectEventListener>(proxy->frame(), value, false); if (listener) { xmlHttpRequestUpload->setOnabort(listener); createHiddenDependency(info.Holder(), value, V8Custom::kXMLHttpRequestCacheIndex); @@ -85,7 +85,7 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnabort) ACCESSOR_GETTER(XMLHttpRequestUploadOnerror) { INC_STATS("DOM.XMLHttpRequestUpload.onerror._get"); - XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); + XMLHttpRequestUpload* xmlHttpRequestUpload = V8DOMWrapper::convertToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); if (xmlHttpRequestUpload->onerror()) { V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onerror()); v8::Local<v8::Object> v8Listener = listener->getListenerObject(); @@ -97,7 +97,7 @@ ACCESSOR_GETTER(XMLHttpRequestUploadOnerror) ACCESSOR_SETTER(XMLHttpRequestUploadOnerror) { INC_STATS("DOM.XMLHttpRequestUpload.onerror._set"); - XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); + XMLHttpRequestUpload* xmlHttpRequestUpload = V8DOMWrapper::convertToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); if (value->IsNull()) { if (xmlHttpRequestUpload->onerror()) { V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onerror()); @@ -113,7 +113,7 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnerror) if (!proxy) return; - RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false); + RefPtr<EventListener> listener = proxy->objectListeners()->findOrCreateWrapper<V8ObjectEventListener>(proxy->frame(), value, false); if (listener) { xmlHttpRequestUpload->setOnerror(listener); createHiddenDependency(info.Holder(), value, V8Custom::kXMLHttpRequestCacheIndex); @@ -124,7 +124,7 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnerror) ACCESSOR_GETTER(XMLHttpRequestUploadOnload) { INC_STATS("DOM.XMLHttpRequestUpload.onload._get"); - XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); + XMLHttpRequestUpload* xmlHttpRequestUpload = V8DOMWrapper::convertToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); if (xmlHttpRequestUpload->onload()) { V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onload()); v8::Local<v8::Object> v8Listener = listener->getListenerObject(); @@ -136,7 +136,7 @@ ACCESSOR_GETTER(XMLHttpRequestUploadOnload) ACCESSOR_SETTER(XMLHttpRequestUploadOnload) { INC_STATS("DOM.XMLHttpRequestUpload.onload._set"); - XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); + XMLHttpRequestUpload* xmlHttpRequestUpload = V8DOMWrapper::convertToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); if (value->IsNull()) { if (xmlHttpRequestUpload->onload()) { V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onload()); @@ -152,7 +152,7 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnload) if (!proxy) return; - RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false); + RefPtr<EventListener> listener = proxy->objectListeners()->findOrCreateWrapper<V8ObjectEventListener>(proxy->frame(), value, false); if (listener) { xmlHttpRequestUpload->setOnload(listener); createHiddenDependency(info.Holder(), value, V8Custom::kXMLHttpRequestCacheIndex); @@ -163,7 +163,7 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnload) ACCESSOR_GETTER(XMLHttpRequestUploadOnloadstart) { INC_STATS("DOM.XMLHttpRequestUpload.onloadstart._get"); - XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); + XMLHttpRequestUpload* xmlHttpRequestUpload = V8DOMWrapper::convertToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); if (xmlHttpRequestUpload->onloadstart()) { V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onloadstart()); v8::Local<v8::Object> v8Listener = listener->getListenerObject(); @@ -175,7 +175,7 @@ ACCESSOR_GETTER(XMLHttpRequestUploadOnloadstart) ACCESSOR_SETTER(XMLHttpRequestUploadOnloadstart) { INC_STATS("DOM.XMLHttpRequestUpload.onloadstart._set"); - XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); + XMLHttpRequestUpload* xmlHttpRequestUpload = V8DOMWrapper::convertToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); if (value->IsNull()) { if (xmlHttpRequestUpload->onloadstart()) { V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onloadstart()); @@ -191,7 +191,7 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnloadstart) if (!proxy) return; - RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false); + RefPtr<EventListener> listener = proxy->objectListeners()->findOrCreateWrapper<V8ObjectEventListener>(proxy->frame(), value, false); if (listener) { xmlHttpRequestUpload->setOnloadstart(listener); createHiddenDependency(info.Holder(), value, V8Custom::kXMLHttpRequestCacheIndex); @@ -202,7 +202,7 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnloadstart) ACCESSOR_GETTER(XMLHttpRequestUploadOnprogress) { INC_STATS("DOM.XMLHttpRequestUpload.onprogress._get"); - XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); + XMLHttpRequestUpload* xmlHttpRequestUpload = V8DOMWrapper::convertToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); if (xmlHttpRequestUpload->onprogress()) { V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onprogress()); v8::Local<v8::Object> v8Listener = listener->getListenerObject(); @@ -214,7 +214,7 @@ ACCESSOR_GETTER(XMLHttpRequestUploadOnprogress) ACCESSOR_SETTER(XMLHttpRequestUploadOnprogress) { INC_STATS("DOM.XMLHttpRequestUpload.onprogress._set"); - XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); + XMLHttpRequestUpload* xmlHttpRequestUpload = V8DOMWrapper::convertToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); if (value->IsNull()) { if (xmlHttpRequestUpload->onprogress()) { V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onprogress()); @@ -230,7 +230,7 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnprogress) if (!proxy) return; - RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false); + RefPtr<EventListener> listener = proxy->objectListeners()->findOrCreateWrapper<V8ObjectEventListener>(proxy->frame(), value, false); if (listener) { xmlHttpRequestUpload->setOnprogress(listener); createHiddenDependency(info.Holder(), value, V8Custom::kXMLHttpRequestCacheIndex); @@ -241,14 +241,14 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnprogress) CALLBACK_FUNC_DECL(XMLHttpRequestUploadAddEventListener) { INC_STATS("DOM.XMLHttpRequestUpload.addEventListener()"); - XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, args.Holder()); + XMLHttpRequestUpload* xmlHttpRequestUpload = V8DOMWrapper::convertToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, args.Holder()); XMLHttpRequest* xmlHttpRequest = xmlHttpRequestUpload->associatedXMLHttpRequest(); V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest->scriptExecutionContext()); if (!proxy) return v8::Undefined(); - RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(args[1], false); + RefPtr<EventListener> listener = proxy->objectListeners()->findOrCreateWrapper<V8ObjectEventListener>(proxy->frame(), args[1], false); if (listener) { String type = toWebCoreString(args[0]); bool useCapture = args[2]->BooleanValue(); @@ -262,14 +262,14 @@ CALLBACK_FUNC_DECL(XMLHttpRequestUploadAddEventListener) CALLBACK_FUNC_DECL(XMLHttpRequestUploadRemoveEventListener) { INC_STATS("DOM.XMLHttpRequestUpload.removeEventListener()"); - XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, args.Holder()); + XMLHttpRequestUpload* xmlHttpRequestUpload = V8DOMWrapper::convertToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, args.Holder()); XMLHttpRequest* xmlHttpRequest = xmlHttpRequestUpload->associatedXMLHttpRequest(); V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest->scriptExecutionContext()); if (!proxy) return v8::Undefined(); // Probably leaked. - RefPtr<EventListener> listener = proxy->FindObjectEventListener(args[1], false); + RefPtr<EventListener> listener = proxy->objectListeners()->findWrapper(args[1], false); if (listener) { String type = toWebCoreString(args[0]); diff --git a/WebCore/bindings/v8/custom/V8XMLSerializerConstructor.cpp b/WebCore/bindings/v8/custom/V8XMLSerializerConstructor.cpp index 7b20293..dd1c3ad 100644 --- a/WebCore/bindings/v8/custom/V8XMLSerializerConstructor.cpp +++ b/WebCore/bindings/v8/custom/V8XMLSerializerConstructor.cpp @@ -39,7 +39,7 @@ namespace WebCore { CALLBACK_FUNC_DECL(XMLSerializerConstructor) { INC_STATS("DOM.XMLSerializer.Constructor"); - return V8Proxy::ConstructDOMObject<V8ClassIndex::XMLSERIALIZER, XMLSerializer>(args); + return V8Proxy::constructDOMObject<V8ClassIndex::XMLSERIALIZER, XMLSerializer>(args); } } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8XPathEvaluatorConstructor.cpp b/WebCore/bindings/v8/custom/V8XPathEvaluatorConstructor.cpp index 84d75db..69a8635 100644 --- a/WebCore/bindings/v8/custom/V8XPathEvaluatorConstructor.cpp +++ b/WebCore/bindings/v8/custom/V8XPathEvaluatorConstructor.cpp @@ -39,7 +39,7 @@ namespace WebCore { CALLBACK_FUNC_DECL(XPathEvaluatorConstructor) { INC_STATS("DOM.XPathEvaluator.Constructor"); - return V8Proxy::ConstructDOMObject<V8ClassIndex::XPATHEVALUATOR, XPathEvaluator>(args); + return V8Proxy::constructDOMObject<V8ClassIndex::XPATHEVALUATOR, XPathEvaluator>(args); } } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8XSLTProcessorCustom.cpp b/WebCore/bindings/v8/custom/V8XSLTProcessorCustom.cpp index d470f84..1ad7d4a 100644 --- a/WebCore/bindings/v8/custom/V8XSLTProcessorCustom.cpp +++ b/WebCore/bindings/v8/custom/V8XSLTProcessorCustom.cpp @@ -48,7 +48,7 @@ namespace WebCore { CALLBACK_FUNC_DECL(XSLTProcessorConstructor) { INC_STATS("DOM.XSLTProcessor.Constructor"); - return V8Proxy::ConstructDOMObject<V8ClassIndex::XSLTPROCESSOR, XSLTProcessor>(args); + return V8Proxy::constructDOMObject<V8ClassIndex::XSLTPROCESSOR, XSLTProcessor>(args); } @@ -58,9 +58,9 @@ CALLBACK_FUNC_DECL(XSLTProcessorImportStylesheet) if (!V8Node::HasInstance(args[0])) return v8::Undefined(); - XSLTProcessor* imp = V8Proxy::ToNativeObject<XSLTProcessor>(V8ClassIndex::XSLTPROCESSOR, args.Holder()); + XSLTProcessor* imp = V8DOMWrapper::convertToNativeObject<XSLTProcessor>(V8ClassIndex::XSLTPROCESSOR, args.Holder()); - Node* node = V8Proxy::DOMWrapperToNode<Node>(args[0]); + Node* node = V8DOMWrapper::convertDOMWrapperToNode<Node>(v8::Handle<v8::Object>::Cast(args[0])); imp->importStylesheet(node); return v8::Undefined(); } @@ -72,12 +72,12 @@ CALLBACK_FUNC_DECL(XSLTProcessorTransformToFragment) if (!V8Node::HasInstance(args[0]) || !V8Document::HasInstance(args[1])) return v8::Undefined(); - XSLTProcessor* imp = V8Proxy::ToNativeObject<XSLTProcessor>(V8ClassIndex::XSLTPROCESSOR, args.Holder()); + XSLTProcessor* imp = V8DOMWrapper::convertToNativeObject<XSLTProcessor>(V8ClassIndex::XSLTPROCESSOR, args.Holder()); - Node* source = V8Proxy::DOMWrapperToNode<Node>(args[0]); - Document* owner = V8Proxy::DOMWrapperToNode<Document>(args[1]); + Node* source = V8DOMWrapper::convertDOMWrapperToNode<Node>(v8::Handle<v8::Object>::Cast(args[0])); + Document* owner = V8DOMWrapper::convertDOMWrapperToNode<Document>(v8::Handle<v8::Object>::Cast(args[1])); RefPtr<DocumentFragment> result = imp->transformToFragment(source, owner); - return V8Proxy::NodeToV8Object(result.get()); + return V8DOMWrapper::convertNodeToV8Object(result.release()); } @@ -88,9 +88,9 @@ CALLBACK_FUNC_DECL(XSLTProcessorTransformToDocument) if (!V8Node::HasInstance(args[0])) return v8::Undefined(); - XSLTProcessor* imp = V8Proxy::ToNativeObject<XSLTProcessor>(V8ClassIndex::XSLTPROCESSOR, args.Holder()); + XSLTProcessor* imp = V8DOMWrapper::convertToNativeObject<XSLTProcessor>(V8ClassIndex::XSLTPROCESSOR, args.Holder()); - Node* source = V8Proxy::DOMWrapperToNode<Node>(args[0]); + Node* source = V8DOMWrapper::convertDOMWrapperToNode<Node>(v8::Handle<v8::Object>::Cast(args[0])); if (!source) return v8::Undefined(); @@ -98,7 +98,7 @@ CALLBACK_FUNC_DECL(XSLTProcessorTransformToDocument) if (!result) return v8::Undefined(); - return V8Proxy::NodeToV8Object(result.get()); + return V8DOMWrapper::convertNodeToV8Object(result.release()); } @@ -108,7 +108,7 @@ CALLBACK_FUNC_DECL(XSLTProcessorSetParameter) if (isUndefinedOrNull(args[1]) || isUndefinedOrNull(args[2])) return v8::Undefined(); - XSLTProcessor* imp = V8Proxy::ToNativeObject<XSLTProcessor>(V8ClassIndex::XSLTPROCESSOR, args.Holder()); + XSLTProcessor* imp = V8DOMWrapper::convertToNativeObject<XSLTProcessor>(V8ClassIndex::XSLTPROCESSOR, args.Holder()); String namespaceURI = toWebCoreString(args[0]); String localName = toWebCoreString(args[1]); @@ -125,7 +125,7 @@ CALLBACK_FUNC_DECL(XSLTProcessorGetParameter) if (isUndefinedOrNull(args[1])) return v8::Undefined(); - XSLTProcessor* imp = V8Proxy::ToNativeObject<XSLTProcessor>(V8ClassIndex::XSLTPROCESSOR, args.Holder()); + XSLTProcessor* imp = V8DOMWrapper::convertToNativeObject<XSLTProcessor>(V8ClassIndex::XSLTPROCESSOR, args.Holder()); String namespaceURI = toWebCoreString(args[0]); String localName = toWebCoreString(args[1]); @@ -142,7 +142,7 @@ CALLBACK_FUNC_DECL(XSLTProcessorRemoveParameter) if (isUndefinedOrNull(args[1])) return v8::Undefined(); - XSLTProcessor* imp = V8Proxy::ToNativeObject<XSLTProcessor>(V8ClassIndex::XSLTPROCESSOR, args.Holder()); + XSLTProcessor* imp = V8DOMWrapper::convertToNativeObject<XSLTProcessor>(V8ClassIndex::XSLTPROCESSOR, args.Holder()); String namespaceURI = toWebCoreString(args[0]); String localName = toWebCoreString(args[1]); |