diff options
Diffstat (limited to 'Source/WebCore/bindings')
84 files changed, 497 insertions, 453 deletions
diff --git a/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp b/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp index 9a96f22..dadcc1c 100644 --- a/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp +++ b/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp @@ -48,6 +48,7 @@ bool RuntimeEnabledFeatures::isWebkitNotificationsEnabled = false; bool RuntimeEnabledFeatures::isApplicationCacheEnabled = true; bool RuntimeEnabledFeatures::isGeolocationEnabled = true; bool RuntimeEnabledFeatures::isIndexedDBEnabled = false; +bool RuntimeEnabledFeatures::isWebAudioEnabled = false; bool RuntimeEnabledFeatures::isWebGLEnabled = false; bool RuntimeEnabledFeatures::isPushStateEnabled = false; bool RuntimeEnabledFeatures::isTouchEnabled = true; diff --git a/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h b/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h index 343c535..c1b9b8a 100644 --- a/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h +++ b/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h @@ -92,6 +92,11 @@ public: static bool openDatabaseSyncEnabled(); #endif +#if ENABLE(WEB_AUDIO) + static void setWebkitAudioContextEnabled(bool isEnabled) { isWebAudioEnabled = isEnabled; } + static bool webkitAudioContextEnabled() { return isWebAudioEnabled; } +#endif + #if ENABLE(3D_CANVAS) || ENABLE(BLOB) static void setWebGLEnabled(bool isEnabled) { isWebGLEnabled = isEnabled; } static bool arrayBufferEnabled() { return isWebGLEnabled; } @@ -174,6 +179,7 @@ private: static bool isApplicationCacheEnabled; static bool isGeolocationEnabled; static bool isIndexedDBEnabled; + static bool isWebAudioEnabled; static bool isWebGLEnabled; static bool isPushStateEnabled; static bool isTouchEnabled; diff --git a/Source/WebCore/bindings/gobject/GNUmakefile.am b/Source/WebCore/bindings/gobject/GNUmakefile.am index b4f98d1..4067dbc 100644 --- a/Source/WebCore/bindings/gobject/GNUmakefile.am +++ b/Source/WebCore/bindings/gobject/GNUmakefile.am @@ -130,6 +130,8 @@ webkitgtk_gdom_built_sources += \ DerivedSources/webkit/WebKitDOMHTMLInputElementPrivate.h \ DerivedSources/webkit/WebKitDOMHTMLIsIndexElement.cpp \ DerivedSources/webkit/WebKitDOMHTMLIsIndexElementPrivate.h \ + DerivedSources/webkit/WebKitDOMHTMLKeygenElement.cpp \ + DerivedSources/webkit/WebKitDOMHTMLKeygenElementPrivate.h \ DerivedSources/webkit/WebKitDOMHTMLLabelElement.cpp \ DerivedSources/webkit/WebKitDOMHTMLLabelElementPrivate.h \ DerivedSources/webkit/WebKitDOMHTMLLegendElement.cpp \ @@ -323,6 +325,7 @@ webkitgtk_built_h_api += \ DerivedSources/webkit/WebKitDOMHTMLImageElement.h \ DerivedSources/webkit/WebKitDOMHTMLInputElement.h \ DerivedSources/webkit/WebKitDOMHTMLIsIndexElement.h \ + DerivedSources/webkit/WebKitDOMHTMLKeygenElement.h \ DerivedSources/webkit/WebKitDOMHTMLLabelElement.h \ DerivedSources/webkit/WebKitDOMHTMLLegendElement.h \ DerivedSources/webkit/WebKitDOMHTMLLIElement.h \ diff --git a/Source/WebCore/bindings/gobject/WebKitHTMLElementWrapperFactory.cpp b/Source/WebCore/bindings/gobject/WebKitHTMLElementWrapperFactory.cpp index da420ae..3ac13d1 100644 --- a/Source/WebCore/bindings/gobject/WebKitHTMLElementWrapperFactory.cpp +++ b/Source/WebCore/bindings/gobject/WebKitHTMLElementWrapperFactory.cpp @@ -62,6 +62,7 @@ #include "HTMLImageElement.h" #include "HTMLInputElement.h" #include "HTMLIsIndexElement.h" +#include "HTMLKeygenElement.h" #include "HTMLLIElement.h" #include "HTMLLabelElement.h" #include "HTMLLegendElement.h" @@ -121,6 +122,7 @@ #include "webkit/WebKitDOMHTMLImageElementPrivate.h" #include "webkit/WebKitDOMHTMLInputElementPrivate.h" #include "webkit/WebKitDOMHTMLIsIndexElementPrivate.h" +#include "webkit/WebKitDOMHTMLKeygenElementPrivate.h" #include "webkit/WebKitDOMHTMLLIElementPrivate.h" #include "webkit/WebKitDOMHTMLLabelElementPrivate.h" #include "webkit/WebKitDOMHTMLLegendElementPrivate.h" @@ -322,6 +324,11 @@ static gpointer createIsIndexWrapper(PassRefPtr<HTMLElement> element) return wrapHTMLIsIndexElement(static_cast<HTMLIsIndexElement*>(element.get())); } +static gpointer createKeygenWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLKeygenElement(static_cast<HTMLKeygenElement*>(element.get())); +} + static gpointer createLabelWrapper(PassRefPtr<HTMLElement> element) { return wrapHTMLLabelElement(static_cast<HTMLLabelElement*>(element.get())); @@ -523,7 +530,7 @@ gpointer createHTMLElementWrapper(PassRefPtr<WebCore::HTMLElement> element) map.set(h6Tag.localName().impl(), createHeadingWrapper); map.set(imageTag.localName().impl(), createImageWrapper); map.set(insTag.localName().impl(), createModWrapper); - map.set(keygenTag.localName().impl(), createSelectWrapper); + map.set(keygenTag.localName().impl(), createKeygenWrapper); map.set(listingTag.localName().impl(), createPreWrapper); map.set(tfootTag.localName().impl(), createTableSectionWrapper); map.set(thTag.localName().impl(), createTableCellWrapper); diff --git a/Source/WebCore/bindings/js/CachedScriptSourceProvider.h b/Source/WebCore/bindings/js/CachedScriptSourceProvider.h index 809a488..9bae8ca 100644 --- a/Source/WebCore/bindings/js/CachedScriptSourceProvider.h +++ b/Source/WebCore/bindings/js/CachedScriptSourceProvider.h @@ -36,6 +36,7 @@ namespace WebCore { class CachedScriptSourceProvider : public ScriptSourceProvider, public CachedResourceClient { + WTF_MAKE_FAST_ALLOCATED; public: static PassRefPtr<CachedScriptSourceProvider> create(CachedScript* cachedScript) { return adoptRef(new CachedScriptSourceProvider(cachedScript)); } @@ -49,9 +50,14 @@ namespace WebCore { int length() const { return m_cachedScript->script().length(); } const String& source() const { return m_cachedScript->script(); } + virtual void cacheSizeChanged(int delta) + { + m_cachedScript->sourceProviderCacheSizeChanged(delta); + } + private: CachedScriptSourceProvider(CachedScript* cachedScript) - : ScriptSourceProvider(stringToUString(cachedScript->url())) + : ScriptSourceProvider(stringToUString(cachedScript->url()), cachedScript->sourceProviderCache()) , m_cachedScript(cachedScript) { m_cachedScript->addClient(this); diff --git a/Source/WebCore/bindings/js/GCController.h b/Source/WebCore/bindings/js/GCController.h index 4c25407..91f1e4c 100644 --- a/Source/WebCore/bindings/js/GCController.h +++ b/Source/WebCore/bindings/js/GCController.h @@ -26,12 +26,12 @@ #ifndef GCController_h #define GCController_h -#include <wtf/Noncopyable.h> #include "Timer.h" namespace WebCore { - class GCController : public Noncopyable { + class GCController { + WTF_MAKE_NONCOPYABLE(GCController); WTF_MAKE_FAST_ALLOCATED; friend GCController& gcController(); public: diff --git a/Source/WebCore/bindings/js/JSArrayBufferViewHelper.h b/Source/WebCore/bindings/js/JSArrayBufferViewHelper.h index e010406..73229da 100644 --- a/Source/WebCore/bindings/js/JSArrayBufferViewHelper.h +++ b/Source/WebCore/bindings/js/JSArrayBufferViewHelper.h @@ -181,6 +181,19 @@ PassRefPtr<C> constructArrayBufferView(JSC::ExecState* exec) return result; } +template <typename JSType, typename WebCoreType> +static JSC::JSValue toJSArrayBufferView(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, WebCoreType* object) +{ + if (!object) + return JSC::jsNull(); + + if (DOMObject* wrapper = getCachedDOMObjectWrapper(exec, object)) + return wrapper; + + exec->heap()->reportExtraMemoryCost(object->byteLength()); + return createDOMObjectWrapper<JSType>(exec, globalObject, object); +} + } // namespace WebCore #endif // JSArrayBufferViewHelper_h diff --git a/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp b/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp index 853e2ef..af74e8c 100644 --- a/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp +++ b/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp @@ -71,6 +71,7 @@ #include "JSDeviceOrientationEventCustom.cpp" #include "JSDocumentCustom.cpp" #include "JSElementCustom.cpp" +#include "JSErrorHandler.cpp" #include "JSEventCustom.cpp" #include "JSEventListener.cpp" #include "JSEventSourceCustom.cpp" @@ -139,7 +140,6 @@ #include "JSWebSocketCustom.cpp" #include "JSWorkerContextBase.cpp" #include "JSWorkerContextCustom.cpp" -#include "JSWorkerContextErrorHandler.cpp" #include "JSWorkerCustom.cpp" #include "JSXMLHttpRequestCustom.cpp" #include "JSXMLHttpRequestUploadCustom.cpp" diff --git a/Source/WebCore/bindings/js/JSDOMBinding.cpp b/Source/WebCore/bindings/js/JSDOMBinding.cpp index 72c7cd6..e53dcfb 100644 --- a/Source/WebCore/bindings/js/JSDOMBinding.cpp +++ b/Source/WebCore/bindings/js/JSDOMBinding.cpp @@ -53,6 +53,7 @@ #include "ProcessingInstruction.h" #include "RangeException.h" #include "ScriptCachedFrameData.h" +#include "ScriptCallStack.h" #include "ScriptController.h" #include "Settings.h" #include "WebCoreJSClientData.h" @@ -589,7 +590,7 @@ void reportException(ExecState* exec, JSValue exception) if (!scriptExecutionContext) return; - scriptExecutionContext->reportException(ustringToString(errorMessage), lineNumber, ustringToString(exceptionSourceURL)); + scriptExecutionContext->reportException(ustringToString(errorMessage), lineNumber, ustringToString(exceptionSourceURL), 0); } void reportCurrentException(ExecState* exec) diff --git a/Source/WebCore/bindings/js/JSDebugWrapperSet.h b/Source/WebCore/bindings/js/JSDebugWrapperSet.h index 94b6f78..e1138ed 100644 --- a/Source/WebCore/bindings/js/JSDebugWrapperSet.h +++ b/Source/WebCore/bindings/js/JSDebugWrapperSet.h @@ -37,7 +37,8 @@ namespace WebCore { // - wrappers being deleted without being removed from the cache // - wrappers being cached twice -class JSDebugWrapperSet : public Noncopyable { +class JSDebugWrapperSet { + WTF_MAKE_NONCOPYABLE(JSDebugWrapperSet); friend class WTF::ThreadSpecific<JSDebugWrapperSet>; public: static JSDebugWrapperSet& shared(); diff --git a/Source/WebCore/bindings/js/JSWorkerContextErrorHandler.cpp b/Source/WebCore/bindings/js/JSErrorHandler.cpp index f7d2b02..ae8e363 100644 --- a/Source/WebCore/bindings/js/JSWorkerContextErrorHandler.cpp +++ b/Source/WebCore/bindings/js/JSErrorHandler.cpp @@ -30,9 +30,7 @@ #include "config.h" -#if ENABLE(WORKERS) - -#include "JSWorkerContextErrorHandler.h" +#include "JSErrorHandler.h" #include "ErrorEvent.h" #include "Event.h" @@ -43,21 +41,26 @@ using namespace JSC; namespace WebCore { -JSWorkerContextErrorHandler::JSWorkerContextErrorHandler(JSObject* function, JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld) +JSErrorHandler::JSErrorHandler(JSObject* function, JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld) : JSEventListener(function, wrapper, isAttribute, isolatedWorld) { } -JSWorkerContextErrorHandler::~JSWorkerContextErrorHandler() +JSErrorHandler::~JSErrorHandler() { } -void JSWorkerContextErrorHandler::handleEvent(ScriptExecutionContext* scriptExecutionContext, Event* event) +void JSErrorHandler::handleEvent(ScriptExecutionContext* scriptExecutionContext, Event* event) { + if (!event->isErrorEvent()) + return JSEventListener::handleEvent(scriptExecutionContext, event); + ASSERT(scriptExecutionContext); if (!scriptExecutionContext) return; + ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event); + JSLock lock(SilenceAssertionsOnly); JSObject* jsFunction = this->jsFunction(scriptExecutionContext); @@ -74,15 +77,11 @@ void JSWorkerContextErrorHandler::handleEvent(ScriptExecutionContext* scriptExec CallType callType = jsFunction->getCallData(callData); if (callType != CallTypeNone) { - - ref(); + RefPtr<JSErrorHandler> protectedctor(this); Event* savedEvent = globalObject->currentEvent(); globalObject->setCurrentEvent(event); - ASSERT(event->isErrorEvent()); - ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event); - MarkedArgumentBuffer args; args.append(jsString(exec, errorEvent->message())); args.append(jsString(exec, errorEvent->filename())); @@ -106,11 +105,7 @@ void JSWorkerContextErrorHandler::handleEvent(ScriptExecutionContext* scriptExec if (returnValue.getBoolean(retvalbool) && !retvalbool) event->preventDefault(); } - - deref(); } } } // namespace WebCore - -#endif // ENABLE(WORKERS) diff --git a/Source/WebCore/bindings/js/JSWorkerContextErrorHandler.h b/Source/WebCore/bindings/js/JSErrorHandler.h index a188299..957fd81 100644 --- a/Source/WebCore/bindings/js/JSWorkerContextErrorHandler.h +++ b/Source/WebCore/bindings/js/JSErrorHandler.h @@ -28,37 +28,37 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef JSWorkerContextErrorHandler_h -#define JSWorkerContextErrorHandler_h +#ifndef JSErrorHandler_h +#define JSErrorHandler_h #include "JSEventListener.h" namespace WebCore { -class JSWorkerContextErrorHandler : public JSEventListener { +class JSErrorHandler : public JSEventListener { public: - static PassRefPtr<JSWorkerContextErrorHandler> create(JSC::JSObject* listener, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld) + static PassRefPtr<JSErrorHandler> create(JSC::JSObject* listener, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld) { - return adoptRef(new JSWorkerContextErrorHandler(listener, wrapper, isAttribute, isolatedWorld)); + return adoptRef(new JSErrorHandler(listener, wrapper, isAttribute, isolatedWorld)); } - virtual ~JSWorkerContextErrorHandler(); + virtual ~JSErrorHandler(); private: - JSWorkerContextErrorHandler(JSC::JSObject* function, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld); + JSErrorHandler(JSC::JSObject* function, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld); virtual void handleEvent(ScriptExecutionContext*, Event*); }; // Creates a JS EventListener for "onerror" event handler in worker context. It has custom implementation because // unlike other event listeners it accepts three parameters. -inline PassRefPtr<JSWorkerContextErrorHandler> createJSWorkerContextErrorHandler(JSC::ExecState* exec, JSC::JSValue listener, JSC::JSObject* wrapper) +inline PassRefPtr<JSErrorHandler> createJSErrorHandler(JSC::ExecState* exec, JSC::JSValue listener, JSC::JSObject* wrapper) { if (!listener.isObject()) return 0; - return JSWorkerContextErrorHandler::create(asObject(listener), wrapper, true, currentWorld(exec)); + return JSErrorHandler::create(asObject(listener), wrapper, true, currentWorld(exec)); } } // namespace WebCore -#endif // JSWorkerContextErrorHandler_h +#endif // JSErrorHandler_h diff --git a/Source/WebCore/bindings/js/JSEventListener.h b/Source/WebCore/bindings/js/JSEventListener.h index b15c589..83d0d2e 100644 --- a/Source/WebCore/bindings/js/JSEventListener.h +++ b/Source/WebCore/bindings/js/JSEventListener.h @@ -59,11 +59,11 @@ namespace WebCore { virtual JSC::JSObject* initializeJSFunction(ScriptExecutionContext*) const; virtual void markJSFunction(JSC::MarkStack&); virtual void invalidateJSFunction(JSC::JSObject*); - virtual void handleEvent(ScriptExecutionContext*, Event*); virtual bool virtualisAttribute() const; protected: JSEventListener(JSC::JSObject* function, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld); + virtual void handleEvent(ScriptExecutionContext*, Event*); private: mutable JSC::JSObject* m_jsFunction; diff --git a/Source/WebCore/bindings/js/JSFloat32ArrayCustom.cpp b/Source/WebCore/bindings/js/JSFloat32ArrayCustom.cpp index 880d68c..eb4608c 100644 --- a/Source/WebCore/bindings/js/JSFloat32ArrayCustom.cpp +++ b/Source/WebCore/bindings/js/JSFloat32ArrayCustom.cpp @@ -43,7 +43,7 @@ void JSFloat32Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSVa JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Float32Array* object) { - return getDOMObjectWrapper<JSFloat32Array>(exec, globalObject, object); + return toJSArrayBufferView<JSFloat32Array>(exec, globalObject, object); } JSC::JSValue JSFloat32Array::set(JSC::ExecState* exec) diff --git a/Source/WebCore/bindings/js/JSInt16ArrayCustom.cpp b/Source/WebCore/bindings/js/JSInt16ArrayCustom.cpp index e08da8a..2e56d0b 100644 --- a/Source/WebCore/bindings/js/JSInt16ArrayCustom.cpp +++ b/Source/WebCore/bindings/js/JSInt16ArrayCustom.cpp @@ -43,7 +43,7 @@ void JSInt16Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValu JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Int16Array* object) { - return getDOMObjectWrapper<JSInt16Array>(exec, globalObject, object); + return toJSArrayBufferView<JSInt16Array>(exec, globalObject, object); } JSC::JSValue JSInt16Array::set(JSC::ExecState* exec) diff --git a/Source/WebCore/bindings/js/JSInt32ArrayCustom.cpp b/Source/WebCore/bindings/js/JSInt32ArrayCustom.cpp index 5aa64bb..eaf474a 100644 --- a/Source/WebCore/bindings/js/JSInt32ArrayCustom.cpp +++ b/Source/WebCore/bindings/js/JSInt32ArrayCustom.cpp @@ -43,7 +43,7 @@ void JSInt32Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValu JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Int32Array* object) { - return getDOMObjectWrapper<JSInt32Array>(exec, globalObject, object); + return toJSArrayBufferView<JSInt32Array>(exec, globalObject, object); } JSC::JSValue JSInt32Array::set(JSC::ExecState* exec) diff --git a/Source/WebCore/bindings/js/JSInt8ArrayCustom.cpp b/Source/WebCore/bindings/js/JSInt8ArrayCustom.cpp index b63de54..c4bd007 100644 --- a/Source/WebCore/bindings/js/JSInt8ArrayCustom.cpp +++ b/Source/WebCore/bindings/js/JSInt8ArrayCustom.cpp @@ -44,7 +44,7 @@ void JSInt8Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Int8Array* object) { - return getDOMObjectWrapper<JSInt8Array>(exec, globalObject, object); + return toJSArrayBufferView<JSInt8Array>(exec, globalObject, object); } JSC::JSValue JSInt8Array::set(JSC::ExecState* exec) diff --git a/Source/WebCore/bindings/js/JSMainThreadExecState.h b/Source/WebCore/bindings/js/JSMainThreadExecState.h index 8193d7c..349dc14 100644 --- a/Source/WebCore/bindings/js/JSMainThreadExecState.h +++ b/Source/WebCore/bindings/js/JSMainThreadExecState.h @@ -30,11 +30,11 @@ #ifndef NDEBUG #include <wtf/MainThread.h> #endif -#include <wtf/Noncopyable.h> namespace WebCore { -class JSMainThreadExecState : public Noncopyable { +class JSMainThreadExecState { + WTF_MAKE_NONCOPYABLE(JSMainThreadExecState); public: static JSC::ExecState* currentState() { diff --git a/Source/WebCore/bindings/js/JSUint16ArrayCustom.cpp b/Source/WebCore/bindings/js/JSUint16ArrayCustom.cpp index 6a024ee..9e476f2 100644 --- a/Source/WebCore/bindings/js/JSUint16ArrayCustom.cpp +++ b/Source/WebCore/bindings/js/JSUint16ArrayCustom.cpp @@ -43,7 +43,7 @@ void JSUint16Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSVal JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Uint16Array* object) { - return getDOMObjectWrapper<JSUint16Array>(exec, globalObject, object); + return toJSArrayBufferView<JSUint16Array>(exec, globalObject, object); } JSC::JSValue JSUint16Array::set(JSC::ExecState* exec) diff --git a/Source/WebCore/bindings/js/JSUint32ArrayCustom.cpp b/Source/WebCore/bindings/js/JSUint32ArrayCustom.cpp index 34eb8de..d221c2a 100644 --- a/Source/WebCore/bindings/js/JSUint32ArrayCustom.cpp +++ b/Source/WebCore/bindings/js/JSUint32ArrayCustom.cpp @@ -43,7 +43,7 @@ void JSUint32Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSVal JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Uint32Array* object) { - return getDOMObjectWrapper<JSUint32Array>(exec, globalObject, object); + return toJSArrayBufferView<JSUint32Array>(exec, globalObject, object); } JSC::JSValue JSUint32Array::set(JSC::ExecState* exec) diff --git a/Source/WebCore/bindings/js/JSUint8ArrayCustom.cpp b/Source/WebCore/bindings/js/JSUint8ArrayCustom.cpp index a9ed73f..b37eea8 100644 --- a/Source/WebCore/bindings/js/JSUint8ArrayCustom.cpp +++ b/Source/WebCore/bindings/js/JSUint8ArrayCustom.cpp @@ -43,7 +43,7 @@ void JSUint8Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValu JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Uint8Array* object) { - return getDOMObjectWrapper<JSUint8Array>(exec, globalObject, object); + return toJSArrayBufferView<JSUint8Array>(exec, globalObject, object); } JSC::JSValue JSUint8Array::set(JSC::ExecState* exec) diff --git a/Source/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp b/Source/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp index ed4a9ca..dc32d5f 100644 --- a/Source/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp +++ b/Source/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp @@ -37,6 +37,7 @@ #include "JSHTMLCanvasElement.h" #include "JSHTMLImageElement.h" #include "JSImageData.h" +#include "JSOESStandardDerivatives.h" #include "JSOESTextureFloat.h" #include "JSWebGLBuffer.h" #include "JSFloat32Array.h" @@ -50,6 +51,7 @@ #include "JSUint8Array.h" #include "JSWebKitCSSMatrix.h" #include "NotImplemented.h" +#include "OESStandardDerivatives.h" #include "OESTextureFloat.h" #include "WebGLBuffer.h" #include "Float32Array.h" @@ -173,6 +175,8 @@ static JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, WebGLExten switch (extension->getName()) { case WebGLExtension::WebKitLoseContextName: return toJS(exec, globalObject, static_cast<WebKitLoseContext*>(extension)); + case WebGLExtension::OESStandardDerivativesName: + return toJS(exec, globalObject, static_cast<OESStandardDerivatives*>(extension)); case WebGLExtension::OESTextureFloatName: return toJS(exec, globalObject, static_cast<OESTextureFloat*>(extension)); } diff --git a/Source/WebCore/bindings/js/JavaScriptCallFrame.cpp b/Source/WebCore/bindings/js/JavaScriptCallFrame.cpp index c280d98..cc6986a 100644 --- a/Source/WebCore/bindings/js/JavaScriptCallFrame.cpp +++ b/Source/WebCore/bindings/js/JavaScriptCallFrame.cpp @@ -42,11 +42,11 @@ using namespace JSC; namespace WebCore { -JavaScriptCallFrame::JavaScriptCallFrame(const DebuggerCallFrame& debuggerCallFrame, PassRefPtr<JavaScriptCallFrame> caller, intptr_t sourceID, int line) +JavaScriptCallFrame::JavaScriptCallFrame(const DebuggerCallFrame& debuggerCallFrame, PassRefPtr<JavaScriptCallFrame> caller, intptr_t sourceID, const TextPosition1& textPosition) : m_debuggerCallFrame(debuggerCallFrame) , m_caller(caller) , m_sourceID(sourceID) - , m_line(line) + , m_textPosition(textPosition) , m_isValid(true) { } diff --git a/Source/WebCore/bindings/js/JavaScriptCallFrame.h b/Source/WebCore/bindings/js/JavaScriptCallFrame.h index c23a43d..74e0a70 100644 --- a/Source/WebCore/bindings/js/JavaScriptCallFrame.h +++ b/Source/WebCore/bindings/js/JavaScriptCallFrame.h @@ -33,14 +33,15 @@ #include <wtf/Forward.h> #include <wtf/PassRefPtr.h> #include <wtf/RefCounted.h> +#include <wtf/text/TextPosition.h> namespace WebCore { class JavaScriptCallFrame : public RefCounted<JavaScriptCallFrame> { public: - static PassRefPtr<JavaScriptCallFrame> create(const JSC::DebuggerCallFrame& debuggerCallFrame, PassRefPtr<JavaScriptCallFrame> caller, intptr_t sourceID, int line) + static PassRefPtr<JavaScriptCallFrame> create(const JSC::DebuggerCallFrame& debuggerCallFrame, PassRefPtr<JavaScriptCallFrame> caller, intptr_t sourceID, const TextPosition1& textPosition) { - return adoptRef(new JavaScriptCallFrame(debuggerCallFrame, caller, sourceID, line)); + return adoptRef(new JavaScriptCallFrame(debuggerCallFrame, caller, sourceID, textPosition)); } void invalidate() @@ -54,11 +55,13 @@ public: JavaScriptCallFrame* caller(); intptr_t sourceID() const { return m_sourceID; } - int line() const { return m_line; } - void update(const JSC::DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int line) + int line() const { return m_textPosition.m_line.oneBasedInt(); } + int column() const { return m_textPosition.m_column.oneBasedInt(); } + + void update(const JSC::DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, const TextPosition1& textPosition) { m_debuggerCallFrame = debuggerCallFrame; - m_line = line; + m_textPosition = textPosition; m_sourceID = sourceID; m_isValid = true; } @@ -72,12 +75,12 @@ public: JSC::JSValue evaluate(const JSC::UString& script, JSC::JSValue& exception) const; private: - JavaScriptCallFrame(const JSC::DebuggerCallFrame&, PassRefPtr<JavaScriptCallFrame> caller, intptr_t sourceID, int line); + JavaScriptCallFrame(const JSC::DebuggerCallFrame&, PassRefPtr<JavaScriptCallFrame> caller, intptr_t sourceID, const TextPosition1&); JSC::DebuggerCallFrame m_debuggerCallFrame; RefPtr<JavaScriptCallFrame> m_caller; intptr_t m_sourceID; - int m_line; + TextPosition1 m_textPosition; bool m_isValid; }; diff --git a/Source/WebCore/bindings/js/ScheduledAction.h b/Source/WebCore/bindings/js/ScheduledAction.h index 6c9d0ba..59ad6fc 100644 --- a/Source/WebCore/bindings/js/ScheduledAction.h +++ b/Source/WebCore/bindings/js/ScheduledAction.h @@ -41,7 +41,8 @@ namespace WebCore { * time interval, either once or repeatedly. Used for window.setTimeout() * and window.setInterval() */ - class ScheduledAction : public Noncopyable { + class ScheduledAction { + WTF_MAKE_NONCOPYABLE(ScheduledAction); WTF_MAKE_FAST_ALLOCATED; public: static PassOwnPtr<ScheduledAction> create(JSC::ExecState*, DOMWrapperWorld* isolatedWorld); diff --git a/Source/WebCore/bindings/js/ScriptCachedFrameData.h b/Source/WebCore/bindings/js/ScriptCachedFrameData.h index 15c23c5..5f691d9 100644 --- a/Source/WebCore/bindings/js/ScriptCachedFrameData.h +++ b/Source/WebCore/bindings/js/ScriptCachedFrameData.h @@ -40,7 +40,8 @@ namespace WebCore { class DOMWindow; class DOMWrapperWorld; - class ScriptCachedFrameData : public Noncopyable { + class ScriptCachedFrameData { + WTF_MAKE_NONCOPYABLE(ScriptCachedFrameData); WTF_MAKE_FAST_ALLOCATED; typedef HashMap< RefPtr<DOMWrapperWorld>, JSC::ProtectedPtr<JSDOMWindow> > JSDOMWindowSet; public: diff --git a/Source/WebCore/bindings/js/ScriptDebugServer.cpp b/Source/WebCore/bindings/js/ScriptDebugServer.cpp index 9845277..b516f6d 100644 --- a/Source/WebCore/bindings/js/ScriptDebugServer.cpp +++ b/Source/WebCore/bindings/js/ScriptDebugServer.cpp @@ -48,7 +48,7 @@ #include "ScrollView.h" #include "Widget.h" #include <debugger/DebuggerCallFrame.h> -#include <parser/SourceCode.h> +#include <parser/SourceProvider.h> #include <runtime/JSLock.h> #include <wtf/text/StringConcatenate.h> #include <wtf/MainThread.h> @@ -282,23 +282,25 @@ void ScriptDebugServer::dispatchDidContinue(ScriptDebugListener* listener) listener->didContinue(); } -void ScriptDebugServer::dispatchDidParseSource(const ListenerSet& listeners, const JSC::SourceCode& source, ScriptWorldType worldType) +void ScriptDebugServer::dispatchDidParseSource(const ListenerSet& listeners, SourceProvider* sourceProvider, ScriptWorldType worldType) { - String sourceID = ustringToString(JSC::UString::number(source.provider()->asID())); - String url = ustringToString(source.provider()->url()); - String data = ustringToString(JSC::UString(source.data(), source.length())); + String sourceID = ustringToString(JSC::UString::number(sourceProvider->asID())); + String url = ustringToString(sourceProvider->url()); + String data = ustringToString(JSC::UString(sourceProvider->data(), sourceProvider->length())); + int lineOffset = sourceProvider->startPosition().m_line.convertAsZeroBasedInt(); + int columnOffset = sourceProvider->startPosition().m_column.convertAsZeroBasedInt(); Vector<ScriptDebugListener*> copy; copyToVector(listeners, copy); for (size_t i = 0; i < copy.size(); ++i) - copy[i]->didParseSource(sourceID, url, data, source.firstLine() - 1, source.firstColumn() - 1, worldType); + copy[i]->didParseSource(sourceID, url, data, lineOffset, columnOffset, worldType); } -void ScriptDebugServer::dispatchFailedToParseSource(const ListenerSet& listeners, const SourceCode& source, int errorLine, const String& errorMessage) +void ScriptDebugServer::dispatchFailedToParseSource(const ListenerSet& listeners, SourceProvider* sourceProvider, int errorLine, const String& errorMessage) { - String url = ustringToString(source.provider()->url()); - String data = ustringToString(JSC::UString(source.data(), source.length())); - int firstLine = source.firstLine(); + String url = ustringToString(sourceProvider->url()); + String data = ustringToString(JSC::UString(sourceProvider->data(), sourceProvider->length())); + int firstLine = sourceProvider->startPosition().m_line.oneBasedInt(); Vector<ScriptDebugListener*> copy; copyToVector(listeners, copy); @@ -335,7 +337,7 @@ void ScriptDebugServer::detach(JSGlobalObject* globalObject) Debugger::detach(globalObject); } -void ScriptDebugServer::sourceParsed(ExecState* exec, const SourceCode& source, int errorLine, const UString& errorMessage) +void ScriptDebugServer::sourceParsed(ExecState* exec, SourceProvider* sourceProvider, int errorLine, const UString& errorMessage) { if (m_callingListeners) return; @@ -353,9 +355,9 @@ void ScriptDebugServer::sourceParsed(ExecState* exec, const SourceCode& source, if (ListenerSet* pageListeners = m_pageListenersMap.get(page)) { ASSERT(!pageListeners->isEmpty()); if (isError) - dispatchFailedToParseSource(*pageListeners, source, errorLine, ustringToString(errorMessage)); + dispatchFailedToParseSource(*pageListeners, sourceProvider, errorLine, ustringToString(errorMessage)); else - dispatchDidParseSource(*pageListeners, source, worldType); + dispatchDidParseSource(*pageListeners, sourceProvider, worldType); } m_callingListeners = false; @@ -440,6 +442,24 @@ void ScriptDebugServer::setJavaScriptPaused(FrameView* view, bool paused) } } +void ScriptDebugServer::createCallFrameAndPauseIfNeeded(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber) +{ + TextPosition1 textPosition(WTF::OneBasedNumber::fromOneBasedInt(lineNumber), WTF::OneBasedNumber::base()); + m_currentCallFrame = JavaScriptCallFrame::create(debuggerCallFrame, m_currentCallFrame, sourceID, textPosition); + pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject())); +} + +void ScriptDebugServer::updateCallFrameAndPauseIfNeeded(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber) +{ + ASSERT(m_currentCallFrame); + if (!m_currentCallFrame) + return; + + TextPosition1 textPosition(WTF::OneBasedNumber::fromOneBasedInt(lineNumber), WTF::OneBasedNumber::base()); + m_currentCallFrame->update(debuggerCallFrame, sourceID, textPosition); + pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject())); +} + void ScriptDebugServer::pauseIfNeeded(Page* page) { if (m_paused) @@ -480,24 +500,14 @@ void ScriptDebugServer::pauseIfNeeded(Page* page) void ScriptDebugServer::callEvent(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber) { - if (m_paused) - return; - - m_currentCallFrame = JavaScriptCallFrame::create(debuggerCallFrame, m_currentCallFrame, sourceID, lineNumber); - pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject())); + if (!m_paused) + createCallFrameAndPauseIfNeeded(debuggerCallFrame, sourceID, lineNumber); } void ScriptDebugServer::atStatement(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber) { - if (m_paused) - return; - - ASSERT(m_currentCallFrame); - if (!m_currentCallFrame) - return; - - m_currentCallFrame->update(debuggerCallFrame, sourceID, lineNumber); - pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject())); + if (!m_paused) + updateCallFrameAndPauseIfNeeded(debuggerCallFrame, sourceID, lineNumber); } void ScriptDebugServer::returnEvent(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber) @@ -505,12 +515,7 @@ void ScriptDebugServer::returnEvent(const DebuggerCallFrame& debuggerCallFrame, if (m_paused) return; - ASSERT(m_currentCallFrame); - if (!m_currentCallFrame) - return; - - m_currentCallFrame->update(debuggerCallFrame, sourceID, lineNumber); - pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject())); + updateCallFrameAndPauseIfNeeded(debuggerCallFrame, sourceID, lineNumber); // detach may have been called during pauseIfNeeded if (!m_currentCallFrame) @@ -527,24 +532,16 @@ void ScriptDebugServer::exception(const DebuggerCallFrame& debuggerCallFrame, in if (m_paused) return; - ASSERT(m_currentCallFrame); - if (!m_currentCallFrame) - return; - if (m_pauseOnExceptionsState == PauseOnAllExceptions || (m_pauseOnExceptionsState == PauseOnUncaughtExceptions && !hasHandler)) m_pauseOnNextStatement = true; - m_currentCallFrame->update(debuggerCallFrame, sourceID, lineNumber); - pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject())); + updateCallFrameAndPauseIfNeeded(debuggerCallFrame, sourceID, lineNumber); } void ScriptDebugServer::willExecuteProgram(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber) { - if (m_paused) - return; - - m_currentCallFrame = JavaScriptCallFrame::create(debuggerCallFrame, m_currentCallFrame, sourceID, lineNumber); - pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject())); + if (!m_paused) + createCallFrameAndPauseIfNeeded(debuggerCallFrame, sourceID, lineNumber); } void ScriptDebugServer::didExecuteProgram(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber) @@ -552,12 +549,7 @@ void ScriptDebugServer::didExecuteProgram(const DebuggerCallFrame& debuggerCallF if (m_paused) return; - ASSERT(m_currentCallFrame); - if (!m_currentCallFrame) - return; - - m_currentCallFrame->update(debuggerCallFrame, sourceID, lineNumber); - pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject())); + updateCallFrameAndPauseIfNeeded(debuggerCallFrame, sourceID, lineNumber); // Treat stepping over the end of a program like stepping out. if (m_currentCallFrame == m_pauseOnCallFrame) @@ -570,13 +562,8 @@ void ScriptDebugServer::didReachBreakpoint(const DebuggerCallFrame& debuggerCall if (m_paused) return; - ASSERT(m_currentCallFrame); - if (!m_currentCallFrame) - return; - m_pauseOnNextStatement = true; - m_currentCallFrame->update(debuggerCallFrame, sourceID, lineNumber); - pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject())); + updateCallFrameAndPauseIfNeeded(debuggerCallFrame, sourceID, lineNumber); } void ScriptDebugServer::recompileAllJSFunctionsSoon() diff --git a/Source/WebCore/bindings/js/ScriptDebugServer.h b/Source/WebCore/bindings/js/ScriptDebugServer.h index 81cd9ac..bde4736 100644 --- a/Source/WebCore/bindings/js/ScriptDebugServer.h +++ b/Source/WebCore/bindings/js/ScriptDebugServer.h @@ -56,7 +56,8 @@ class PageGroup; class ScriptDebugListener; class JavaScriptCallFrame; -class ScriptDebugServer : JSC::Debugger, public Noncopyable { +class ScriptDebugServer : JSC::Debugger { + WTF_MAKE_NONCOPYABLE(ScriptDebugServer); WTF_MAKE_FAST_ALLOCATED; public: static ScriptDebugServer& shared(); @@ -115,14 +116,16 @@ private: void dispatchFunctionToListeners(const ListenerSet& listeners, JavaScriptExecutionCallback callback); void dispatchDidPause(ScriptDebugListener*); void dispatchDidContinue(ScriptDebugListener*); - void dispatchDidParseSource(const ListenerSet& listeners, const JSC::SourceCode& source, enum ScriptWorldType); - void dispatchFailedToParseSource(const ListenerSet& listeners, const JSC::SourceCode& source, int errorLine, const String& errorMessage); + void dispatchDidParseSource(const ListenerSet& listeners, JSC::SourceProvider*, enum ScriptWorldType); + void dispatchFailedToParseSource(const ListenerSet& listeners, JSC::SourceProvider*, int errorLine, const String& errorMessage); + void createCallFrameAndPauseIfNeeded(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineNumber); + void updateCallFrameAndPauseIfNeeded(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineNumber); void pauseIfNeeded(Page*); virtual void detach(JSC::JSGlobalObject*); - virtual void sourceParsed(JSC::ExecState*, const JSC::SourceCode&, int errorLine, const JSC::UString& errorMsg); + virtual void sourceParsed(JSC::ExecState*, JSC::SourceProvider*, int errorLine, const JSC::UString& errorMsg); virtual void callEvent(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineNumber); virtual void atStatement(const JSC::DebuggerCallFrame&, intptr_t sourceID, int firstLine); virtual void returnEvent(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineNumber); diff --git a/Source/WebCore/bindings/js/ScriptProfiler.h b/Source/WebCore/bindings/js/ScriptProfiler.h index 05e7a25..d4dd606 100644 --- a/Source/WebCore/bindings/js/ScriptProfiler.h +++ b/Source/WebCore/bindings/js/ScriptProfiler.h @@ -32,11 +32,11 @@ #include "ScriptProfile.h" #include "ScriptState.h" -#include <wtf/Noncopyable.h> namespace WebCore { -class ScriptProfiler : public Noncopyable { +class ScriptProfiler { + WTF_MAKE_NONCOPYABLE(ScriptProfiler); public: static void start(ScriptState* state, const String& title); static PassRefPtr<ScriptProfile> stop(ScriptState* state, const String& title); diff --git a/Source/WebCore/bindings/js/ScriptSourceCode.h b/Source/WebCore/bindings/js/ScriptSourceCode.h index 6cf3987..373db31 100644 --- a/Source/WebCore/bindings/js/ScriptSourceCode.h +++ b/Source/WebCore/bindings/js/ScriptSourceCode.h @@ -43,8 +43,8 @@ namespace WebCore { class ScriptSourceCode { public: ScriptSourceCode(const String& source, const KURL& url = KURL(), const TextPosition1& startPosition = TextPosition1::minimumPosition()) - : m_provider(StringSourceProvider::create(source, url.isNull() ? String() : url.string())) - , m_code(m_provider, startPosition) + : m_provider(StringSourceProvider::create(source, url.isNull() ? String() : url.string(), startPosition)) + , m_code(m_provider, startPosition.m_line.oneBasedInt()) , m_url(url) { } diff --git a/Source/WebCore/bindings/js/ScriptSourceProvider.h b/Source/WebCore/bindings/js/ScriptSourceProvider.h index de4e307..3a5d579 100644 --- a/Source/WebCore/bindings/js/ScriptSourceProvider.h +++ b/Source/WebCore/bindings/js/ScriptSourceProvider.h @@ -34,8 +34,8 @@ namespace WebCore { class ScriptSourceProvider : public JSC::SourceProvider { public: - ScriptSourceProvider(const JSC::UString& url) - : SourceProvider(url) + ScriptSourceProvider(const JSC::UString& url, JSC::SourceProviderCache* cache = 0) + : SourceProvider(url, cache) { } diff --git a/Source/WebCore/bindings/js/ScriptState.h b/Source/WebCore/bindings/js/ScriptState.h index 0c08611..e19c0c8 100644 --- a/Source/WebCore/bindings/js/ScriptState.h +++ b/Source/WebCore/bindings/js/ScriptState.h @@ -52,7 +52,8 @@ class Page; // For now, the separation is purely by convention. typedef JSC::ExecState ScriptState; -class ScriptStateProtectedPtr : public Noncopyable { +class ScriptStateProtectedPtr { + WTF_MAKE_NONCOPYABLE(ScriptStateProtectedPtr); public: explicit ScriptStateProtectedPtr(ScriptState*); ~ScriptStateProtectedPtr(); diff --git a/Source/WebCore/bindings/js/StringSourceProvider.h b/Source/WebCore/bindings/js/StringSourceProvider.h index 478c1d1..e23fe5c 100644 --- a/Source/WebCore/bindings/js/StringSourceProvider.h +++ b/Source/WebCore/bindings/js/StringSourceProvider.h @@ -37,20 +37,26 @@ namespace WebCore { class StringSourceProvider : public ScriptSourceProvider { public: - static PassRefPtr<StringSourceProvider> create(const String& source, const String& url) { return adoptRef(new StringSourceProvider(source, url)); } + static PassRefPtr<StringSourceProvider> create(const String& source, const String& url, const TextPosition1& startPosition = TextPosition1::minimumPosition()) + { + return adoptRef(new StringSourceProvider(source, url, startPosition)); + } + virtual TextPosition1 startPosition() const { return m_startPosition; } JSC::UString getRange(int start, int end) const { return JSC::UString(m_source.characters() + start, end - start); } const UChar* data() const { return m_source.characters(); } int length() const { return m_source.length(); } const String& source() const { return m_source; } private: - StringSourceProvider(const String& source, const String& url) + StringSourceProvider(const String& source, const String& url, const TextPosition1& startPosition) : ScriptSourceProvider(stringToUString(url)) + , m_startPosition(startPosition) , m_source(source) { } + TextPosition1 m_startPosition; String m_source; }; diff --git a/Source/WebCore/bindings/js/WebCoreJSClientData.h b/Source/WebCore/bindings/js/WebCoreJSClientData.h index 5d03328..6e2d7be 100644 --- a/Source/WebCore/bindings/js/WebCoreJSClientData.h +++ b/Source/WebCore/bindings/js/WebCoreJSClientData.h @@ -24,17 +24,18 @@ #include "DOMWrapperWorld.h" #include "DOMObjectHashTableMap.h" -#include <wtf/Noncopyable.h> #include <wtf/HashSet.h> #include <wtf/RefPtr.h> namespace WebCore { -class WebCoreJSClientData : public JSC::JSGlobalData::ClientData, public Noncopyable { +class WebCoreJSClientData : public JSC::JSGlobalData::ClientData { + WTF_MAKE_NONCOPYABLE(WebCoreJSClientData); WTF_MAKE_FAST_ALLOCATED; friend class JSGlobalDataWorldIterator; friend void initNormalWorldClientData(JSC::JSGlobalData*); public: + WebCoreJSClientData() { } virtual ~WebCoreJSClientData() { ASSERT(m_worldSet.contains(m_normalWorld.get())); diff --git a/Source/WebCore/bindings/js/WorkerScriptController.h b/Source/WebCore/bindings/js/WorkerScriptController.h index be7da4d..4578913 100644 --- a/Source/WebCore/bindings/js/WorkerScriptController.h +++ b/Source/WebCore/bindings/js/WorkerScriptController.h @@ -31,7 +31,6 @@ #include <runtime/Protect.h> #include <wtf/Forward.h> -#include <wtf/Noncopyable.h> #include <wtf/Threading.h> namespace JSC { @@ -45,7 +44,8 @@ namespace WebCore { class ScriptValue; class WorkerContext; - class WorkerScriptController : public Noncopyable { + class WorkerScriptController { + WTF_MAKE_NONCOPYABLE(WorkerScriptController); WTF_MAKE_FAST_ALLOCATED; public: WorkerScriptController(WorkerContext*); ~WorkerScriptController(); diff --git a/Source/WebCore/bindings/objc/DOM.mm b/Source/WebCore/bindings/objc/DOM.mm index 44bd653..1c24de6 100644 --- a/Source/WebCore/bindings/objc/DOM.mm +++ b/Source/WebCore/bindings/objc/DOM.mm @@ -131,7 +131,6 @@ static void createElementClassMap() addElementClass(HTMLNames::preTag, [DOMHTMLPreElement class]); addElementClass(HTMLNames::qTag, [DOMHTMLQuoteElement class]); addElementClass(HTMLNames::scriptTag, [DOMHTMLScriptElement class]); - addElementClass(HTMLNames::keygenTag, [DOMHTMLSelectElement class]); addElementClass(HTMLNames::selectTag, [DOMHTMLSelectElement class]); addElementClass(HTMLNames::styleTag, [DOMHTMLStyleElement class]); addElementClass(HTMLNames::tableTag, [DOMHTMLTableElement class]); diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm b/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm index 1863d8f..ed76d08 100644 --- a/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm +++ b/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm @@ -518,7 +518,7 @@ my @eventSignalNames = ( # User Interface Event types "focus", "blur", # Basic Event types - "load", "unload", "abort", "error", "select", "change", "submit", "reset", + "load", "unload", "abort", "error", "select", "change", "formchange", "submit", "reset", "resize", "scroll", # Mouse Event types "click", "dblclick", "mousedown", "mouseup", @@ -540,7 +540,7 @@ my @eventSignalNames = ( # Animations "webkitanimationend", "webkitanimationstart", "webkitanimationiteration", # Other - "contextmenu", "input", "invalid", "search", "selectstart"); + "contextmenu", "input", "forminput", "invalid", "search", "selectstart"); sub GenerateProperties { my ($object, $interfaceName, $dataNode) = @_; diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm b/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm index cff51e9..abef04e 100644 --- a/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm +++ b/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm @@ -1721,9 +1721,9 @@ sub GenerateImplementation push(@implContent, " JSDOMGlobalObject* globalObject = castedThis->globalObject();\n"); } push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(static_cast<$className*>(thisObject)->impl());\n"); - if ($interfaceName eq "WorkerContext" and $name eq "onerror") { - $implIncludes{"JSWorkerContextErrorHandler.h"} = 1; - push(@implContent, " imp->set$implSetterFunctionName(createJSWorkerContextErrorHandler(exec, value, thisObject));\n"); + if ((($interfaceName eq "DOMWindow") or ($interfaceName eq "WorkerContext")) and $name eq "onerror") { + $implIncludes{"JSErrorHandler.h"} = 1; + push(@implContent, " imp->set$implSetterFunctionName(createJSErrorHandler(exec, value, thisObject));\n"); } else { push(@implContent, GenerateAttributeEventListenerCall($className, $implSetterFunctionName, $windowEventListener)); } diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm b/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm index f50e74a..7d36db1 100644 --- a/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm +++ b/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm @@ -1001,6 +1001,10 @@ END $implIncludes{"V8EventListenerList.h"} = 1; $implIncludes{"V8WorkerContextErrorHandler.h"} = 1; push(@implContentDecls, " imp->set$implSetterFunctionName(V8EventListenerList::findOrCreateWrapper<V8WorkerContextErrorHandler>(value, true)"); + } elsif ($interfaceName eq "DOMWindow" and $attribute->signature->name eq "onerror") { + $implIncludes{"V8EventListenerList.h"} = 1; + $implIncludes{"V8WindowErrorHandler.h"} = 1; + push(@implContentDecls, " imp->set$implSetterFunctionName(V8EventListenerList::findOrCreateWrapper<V8WindowErrorHandler>(value, true)"); } else { push(@implContentDecls, " imp->set$implSetterFunctionName(V8DOMWrapper::getEventListener(value, true, ListenerFindOrCreate)"); } @@ -2397,9 +2401,13 @@ END push(@args, " ${paramName}Handle"); } - push(@implContent, "\n v8::Handle<v8::Value> argv[] = {\n"); - push(@implContent, join(",\n", @args)); - push(@implContent, "\n };\n\n"); + if (scalar(@args) > 0) { + push(@implContent, "\n v8::Handle<v8::Value> argv[] = {\n"); + push(@implContent, join(",\n", @args)); + push(@implContent, "\n };\n\n"); + } else { + push(@implContent, "\n v8::Handle<v8::Value> *argv = 0;\n\n"); + } push(@implContent, " bool callbackReturnValue = false;\n"); push(@implContent, " return !invokeCallback(m_callback, " . scalar(@params) . ", argv, callbackReturnValue, scriptExecutionContext());\n"); push(@implContent, "}\n"); diff --git a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.cpp b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.cpp index a58da40..62ebc3c 100644 --- a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.cpp +++ b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.cpp @@ -83,6 +83,14 @@ WebDOMTestCallback::~WebDOMTestCallback() m_impl = 0; } +bool WebDOMTestCallback::callbackWithNoParam() +{ + if (!impl()) + return false; + + return impl()->callbackWithNoParam(); +} + bool WebDOMTestCallback::callbackWithClass1Param(const WebDOMClass1& class1Param) { if (!impl()) diff --git a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.h b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.h index 91ff787..7a077e2 100644 --- a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.h +++ b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.h @@ -46,6 +46,7 @@ public: WebDOMTestCallback& operator=(const WebDOMTestCallback&); virtual ~WebDOMTestCallback(); + bool callbackWithNoParam(); bool callbackWithClass1Param(const WebDOMClass1& class1Param); bool callbackWithClass2Param(const WebDOMClass2& class2Param, const WebDOMString& strArg); int callbackWithNonBoolReturnType(const WebDOMClass3& class3Param); diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp index 9c8fa59..054dc38 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp @@ -39,8 +39,9 @@ #include "webkit/WebKitDOMClass3Private.h" #include "webkit/WebKitDOMTestCallback.h" #include "webkit/WebKitDOMTestCallbackPrivate.h" +#include "webkitdefines.h" +#include "webkitglobalsprivate.h" #include "webkitmarshal.h" -#include "webkitprivate.h" namespace WebKit { @@ -57,6 +58,16 @@ WebKitDOMTestCallback* kit(WebCore::TestCallback* obj) } // namespace WebKit // gboolean +webkit_dom_test_callback_callback_with_no_param(WebKitDOMTestCallback* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestCallback * item = WebKit::core(self); + gboolean res = item->callbackWithNoParam(); + return res; +} + +gboolean webkit_dom_test_callback_callback_with_class1param(WebKitDOMTestCallback* self, WebKitDOMClass1* class1param) { g_return_val_if_fail(self, 0); diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.h index 4f0ac91..6049c79 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.h +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.h @@ -47,6 +47,9 @@ WEBKIT_API GType webkit_dom_test_callback_get_type (void); WEBKIT_API gboolean +webkit_dom_test_callback_callback_with_no_param(WebKitDOMTestCallback* self); + +WEBKIT_API gboolean webkit_dom_test_callback_callback_with_class1param(WebKitDOMTestCallback* self, WebKitDOMClass1* class1param); WEBKIT_API gboolean diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp index b68340b..7086c80 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp @@ -33,8 +33,9 @@ #include "gobject/ConvertToUTF8String.h" #include "webkit/WebKitDOMTestInterface.h" #include "webkit/WebKitDOMTestInterfacePrivate.h" +#include "webkitdefines.h" +#include "webkitglobalsprivate.h" #include "webkitmarshal.h" -#include "webkitprivate.h" namespace WebKit { diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.cpp b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.cpp index 93d0bde..5946ec0 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.cpp +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.cpp @@ -31,8 +31,9 @@ #include "gobject/ConvertToUTF8String.h" #include "webkit/WebKitDOMTestMediaQueryListListener.h" #include "webkit/WebKitDOMTestMediaQueryListListenerPrivate.h" +#include "webkitdefines.h" +#include "webkitglobalsprivate.h" #include "webkitmarshal.h" -#include "webkitprivate.h" namespace WebKit { diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp index 6c94d94..44d58d4 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp @@ -38,8 +38,9 @@ #include "webkit/WebKitDOMSerializedScriptValuePrivate.h" #include "webkit/WebKitDOMTestObj.h" #include "webkit/WebKitDOMTestObjPrivate.h" +#include "webkitdefines.h" +#include "webkitglobalsprivate.h" #include "webkitmarshal.h" -#include "webkitprivate.h" namespace WebKit { diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp index 069b8ae..1f48ee9 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp @@ -56,6 +56,23 @@ JSTestCallback::~JSTestCallback() // Functions +bool JSTestCallback::callbackWithNoParam() +{ + if (!canInvokeCallback()) + return true; + + RefPtr<JSTestCallback> protect(this); + + JSLock lock(SilenceAssertionsOnly); + + ExecState* exec = m_data->globalObject()->globalExec(); + MarkedArgumentBuffer args; + + bool raisedException = false; + m_data->invokeCallback(args, &raisedException); + return !raisedException; +} + bool JSTestCallback::callbackWithClass1Param(Class1* class1Param) { if (!canInvokeCallback()) diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.h b/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.h index ae91a6c..ba3559c 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.h @@ -40,6 +40,7 @@ public: virtual ~JSTestCallback(); // Functions + virtual bool callbackWithNoParam(); virtual bool callbackWithClass1Param(Class1* class1Param); virtual bool callbackWithClass2Param(Class2* class2Param, const String& strArg); COMPILE_ASSERT(false) virtual int callbackWithNonBoolReturnType(Class3* class3Param); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp index 8e71df1..684f587 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp @@ -166,6 +166,7 @@ JSValue jsTestInterfaceConstructor(ExecState* exec, JSValue slotBase, const Iden JSTestInterface* domObject = static_cast<JSTestInterface*>(asObject(slotBase)); return JSTestInterface::getConstructor(exec, domObject->globalObject()); } + JSValue JSTestInterface::getConstructor(ExecState* exec, JSGlobalObject* globalObject) { return getDOMConstructor<JSTestInterfaceConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp index e505ed2..f1c09b5 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp @@ -162,6 +162,7 @@ JSValue jsTestMediaQueryListListenerConstructor(ExecState* exec, JSValue slotBas JSTestMediaQueryListListener* domObject = static_cast<JSTestMediaQueryListListener*>(asObject(slotBase)); return JSTestMediaQueryListListener::getConstructor(exec, domObject->globalObject()); } + JSValue JSTestMediaQueryListListener::getConstructor(ExecState* exec, JSGlobalObject* globalObject) { return getDOMConstructor<JSTestMediaQueryListListenerConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp index c4c77ee..9d446a2 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp @@ -607,6 +607,7 @@ JSValue jsTestObjConstructor(ExecState* exec, JSValue slotBase, const Identifier JSTestObj* domObject = static_cast<JSTestObj*>(asObject(slotBase)); return JSTestObj::getConstructor(exec, domObject->globalObject()); } + void JSTestObj::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) { lookupPut<JSTestObj, Base>(exec, propertyName, value, &JSTestObjTable, this, slot); diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.h b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.h index 1213c6f..08c30b7 100644 --- a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.h +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.h @@ -36,6 +36,7 @@ @class NSString; @interface DOMTestCallback : DOMObject +- (BOOL)callbackWithNoParam; - (BOOL)callbackWithClass1Param:(DOMClass1 *)class1Param; - (BOOL)callbackWithClass2Param:(DOMClass2 *)class2Param strArg:(NSString *)strArg; - (int)callbackWithNonBoolReturnType:(DOMClass3 *)class3Param; diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.mm b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.mm index e941eda..c4be39d 100644 --- a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.mm +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.mm @@ -79,6 +79,12 @@ [super finalize]; } +- (BOOL)callbackWithNoParam +{ + WebCore::JSMainThreadNullState state; + return IMPL->callbackWithNoParam(); +} + - (BOOL)callbackWithClass1Param:(DOMClass1 *)class1Param { WebCore::JSMainThreadNullState state; diff --git a/Source/WebCore/bindings/scripts/test/TestCallback.idl b/Source/WebCore/bindings/scripts/test/TestCallback.idl index 25db4c6..9679a5a 100644 --- a/Source/WebCore/bindings/scripts/test/TestCallback.idl +++ b/Source/WebCore/bindings/scripts/test/TestCallback.idl @@ -33,6 +33,7 @@ module test { Conditional=DATABASE, Callback ] TestCallback { + boolean callbackWithNoParam(); boolean callbackWithClass1Param(in Class1 class1Param); boolean callbackWithClass2Param(in Class2 class2Param, in DOMString strArg); long callbackWithNonBoolReturnType(in Class3 class3Param); diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp b/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp index c286c24..36a5ca2 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp @@ -48,6 +48,26 @@ V8TestCallback::~V8TestCallback() // Functions +bool V8TestCallback::callbackWithNoParam() +{ + if (!canInvokeCallback()) + return true; + + v8::HandleScope handleScope; + + v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext); + if (v8Context.IsEmpty()) + return true; + + v8::Context::Scope scope(v8Context); + + + v8::Handle<v8::Value> *argv = 0; + + bool callbackReturnValue = false; + return !invokeCallback(m_callback, 0, argv, callbackReturnValue, scriptExecutionContext()); +} + bool V8TestCallback::callbackWithClass1Param(Class1* class1Param) { if (!canInvokeCallback()) diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h b/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h index a105d75..8ff8c26 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h @@ -45,6 +45,7 @@ public: virtual ~V8TestCallback(); // Functions + virtual bool callbackWithNoParam(); virtual bool callbackWithClass1Param(Class1* class1Param); virtual bool callbackWithClass2Param(Class2* class2Param, const String& strArg); COMPILE_ASSERT(false) virtual int callbackWithNonBoolReturnType(Class3* class3Param); diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp b/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp index 7a759a3..4298756 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp @@ -260,7 +260,7 @@ static v8::Handle<v8::Value> reflectedUnsignedIntegralAttrAttrGetter(v8::Local<v { INC_STATS("DOM.TestObj.reflectedUnsignedIntegralAttr._get"); TestObj* imp = V8TestObj::toNative(info.Holder()); - return v8::Integer::NewFromUnsigned(imp->getUnsignedIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr)); + return v8::Integer::NewFromUnsigned(std::max(0, imp->getIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr))); } static void reflectedUnsignedIntegralAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) diff --git a/Source/WebCore/bindings/v8/DOMData.h b/Source/WebCore/bindings/v8/DOMData.h index 78edf92..b042606 100644 --- a/Source/WebCore/bindings/v8/DOMData.h +++ b/Source/WebCore/bindings/v8/DOMData.h @@ -43,7 +43,8 @@ namespace WebCore { // thread. The DOMData for the main thread and the DOMData for child threads // use different subclasses. // - class DOMData : public Noncopyable { + class DOMData { + WTF_MAKE_NONCOPYABLE(DOMData); public: DOMData(); virtual ~DOMData(); diff --git a/Source/WebCore/bindings/v8/DOMDataStore.cpp b/Source/WebCore/bindings/v8/DOMDataStore.cpp index 0d37dc0..5393bd9 100644 --- a/Source/WebCore/bindings/v8/DOMDataStore.cpp +++ b/Source/WebCore/bindings/v8/DOMDataStore.cpp @@ -148,11 +148,13 @@ void DOMDataStore::weakActiveDOMObjectCallback(v8::Persistent<v8::Value> v8Objec DOMData::handleWeakObject(DOMDataStore::ActiveDOMObjectMap, v8::Persistent<v8::Object>::Cast(v8Object), domObject); } -void DOMDataStore::weakNodeCallback(v8::Persistent<v8::Value> v8Object, void* domObject) +void DOMDataStore::weakNodeCallback(v8::Persistent<v8::Value> value, void* domObject) { ASSERT(WTF::isMainThread()); Node* node = static_cast<Node*>(domObject); + // Node wrappers must be JS objects. + v8::Persistent<v8::Object> v8Object = v8::Persistent<v8::Object>::Cast(value); WTF::MutexLocker locker(DOMDataStore::allStoresMutex()); DOMDataList& list = DOMDataStore::allStores(); @@ -171,7 +173,7 @@ void DOMDataStore::weakNodeCallback(v8::Persistent<v8::Value> v8Object, void* do node->deref(); // Nobody overrides Node::deref so it's safe } -bool DOMDataStore::IntrusiveDOMWrapperMap::removeIfPresent(Node* obj, v8::Persistent<v8::Data> value) +bool DOMDataStore::IntrusiveDOMWrapperMap::removeIfPresent(Node* obj, v8::Persistent<v8::Object> value) { ASSERT(obj); v8::Persistent<v8::Object>* entry = obj->wrapper(); diff --git a/Source/WebCore/bindings/v8/DOMDataStore.h b/Source/WebCore/bindings/v8/DOMDataStore.h index a1051dd..dbead9c 100644 --- a/Source/WebCore/bindings/v8/DOMDataStore.h +++ b/Source/WebCore/bindings/v8/DOMDataStore.h @@ -149,7 +149,8 @@ namespace WebCore { // This class doesn't manage the lifetime of the store. The data store // lifetime is managed by subclasses. // - class DOMDataStore : public Noncopyable { + class DOMDataStore { + WTF_MAKE_NONCOPYABLE(DOMDataStore); public: enum DOMWrapperMapType { DOMNodeMap, @@ -190,7 +191,7 @@ namespace WebCore { m_table.visit(store, visitor); } - virtual bool removeIfPresent(Node* key, v8::Persistent<v8::Data> value); + virtual bool removeIfPresent(Node*, v8::Persistent<v8::Object>); virtual void clear() { diff --git a/Source/WebCore/bindings/v8/DebuggerScript.js b/Source/WebCore/bindings/v8/DebuggerScript.js index 8c9d98e..eb9de2f 100644 --- a/Source/WebCore/bindings/v8/DebuggerScript.js +++ b/Source/WebCore/bindings/v8/DebuggerScript.js @@ -201,8 +201,10 @@ DebuggerScript._frameMirrorToJSCallFrame = function(frameMirror, callerFrame) var script = func.script(); var sourceID = script && script.id(); - // Get line number. - var line = DebuggerScript._v8ToWebkitLineNumber(frameMirror.sourceLine()); + // Get location. + var location = frameMirror.sourceLocation(); + var line = DebuggerScript._v8ToWebkitLineNumber(location.line); + var column = DebuggerScript._v8ToWebkitLineNumber(location.column); // Get this object. var thisObject = frameMirror.details_.receiver(); @@ -250,6 +252,7 @@ DebuggerScript._frameMirrorToJSCallFrame = function(frameMirror, callerFrame) return { "sourceID": sourceID, "line": line, + "column": column, "functionName": functionName, "type": "function", "thisObject": thisObject, diff --git a/Source/WebCore/bindings/v8/JavaScriptCallFrame.cpp b/Source/WebCore/bindings/v8/JavaScriptCallFrame.cpp index 20bf378..5bb436f 100644 --- a/Source/WebCore/bindings/v8/JavaScriptCallFrame.cpp +++ b/Source/WebCore/bindings/v8/JavaScriptCallFrame.cpp @@ -80,6 +80,16 @@ int JavaScriptCallFrame::line() const return 0; } +int JavaScriptCallFrame::column() const +{ + v8::HandleScope handleScope; + v8::Context::Scope contextScope(m_debuggerContext.get()); + v8::Handle<v8::Value> result = m_callFrame.get()->Get(v8String("column")); + if (result->IsInt32()) + return result->Int32Value(); + return 0; +} + String JavaScriptCallFrame::functionName() const { v8::HandleScope handleScope; diff --git a/Source/WebCore/bindings/v8/JavaScriptCallFrame.h b/Source/WebCore/bindings/v8/JavaScriptCallFrame.h index 95a0510..2d14593 100644 --- a/Source/WebCore/bindings/v8/JavaScriptCallFrame.h +++ b/Source/WebCore/bindings/v8/JavaScriptCallFrame.h @@ -51,6 +51,7 @@ public: int sourceID() const; int line() const; + int column() const; String functionName() const; v8::Handle<v8::Value> scopeChain() const; diff --git a/Source/WebCore/bindings/v8/ScriptCachedFrameData.h b/Source/WebCore/bindings/v8/ScriptCachedFrameData.h index 1aa1f62..f08265b 100644 --- a/Source/WebCore/bindings/v8/ScriptCachedFrameData.h +++ b/Source/WebCore/bindings/v8/ScriptCachedFrameData.h @@ -67,7 +67,8 @@ namespace WebCore { class Frame; class DOMWindow; -class ScriptCachedFrameData : public Noncopyable { +class ScriptCachedFrameData { + WTF_MAKE_NONCOPYABLE(ScriptCachedFrameData); public: ScriptCachedFrameData(Frame*); ~ScriptCachedFrameData() { } diff --git a/Source/WebCore/bindings/v8/ScriptDebugServer.h b/Source/WebCore/bindings/v8/ScriptDebugServer.h index 40dd5fc..8fa723f 100644 --- a/Source/WebCore/bindings/v8/ScriptDebugServer.h +++ b/Source/WebCore/bindings/v8/ScriptDebugServer.h @@ -48,7 +48,8 @@ namespace WebCore { class Page; class ScriptDebugListener; -class ScriptDebugServer : public Noncopyable { +class ScriptDebugServer { + WTF_MAKE_NONCOPYABLE(ScriptDebugServer); public: static ScriptDebugServer& shared(); diff --git a/Source/WebCore/bindings/v8/ScriptProfiler.h b/Source/WebCore/bindings/v8/ScriptProfiler.h index b75a054..e0969e1 100644 --- a/Source/WebCore/bindings/v8/ScriptProfiler.h +++ b/Source/WebCore/bindings/v8/ScriptProfiler.h @@ -36,13 +36,13 @@ #include "ScriptProfile.h" #include "ScriptState.h" -#include <wtf/Noncopyable.h> namespace WebCore { class InspectorObject; -class ScriptProfiler : public Noncopyable { +class ScriptProfiler { + WTF_MAKE_NONCOPYABLE(ScriptProfiler); public: static void start(ScriptState* state, const String& title); static PassRefPtr<ScriptProfile> stop(ScriptState* state, const String& title); diff --git a/Source/WebCore/bindings/v8/ScriptState.h b/Source/WebCore/bindings/v8/ScriptState.h index 11813b0..0fecee8 100644 --- a/Source/WebCore/bindings/v8/ScriptState.h +++ b/Source/WebCore/bindings/v8/ScriptState.h @@ -42,7 +42,8 @@ class Frame; class Node; class Page; -class ScriptState : public Noncopyable { +class ScriptState { + WTF_MAKE_NONCOPYABLE(ScriptState); public: bool hadException() { return !m_exception.IsEmpty(); } void setException(v8::Local<v8::Value> exception) @@ -79,7 +80,8 @@ public: ~EmptyScriptState() { } }; -class ScriptStateProtectedPtr : public Noncopyable { +class ScriptStateProtectedPtr { + WTF_MAKE_NONCOPYABLE(ScriptStateProtectedPtr); public: ScriptStateProtectedPtr() : m_scriptState(0) { } ScriptStateProtectedPtr(ScriptState* scriptState) : m_scriptState(scriptState) diff --git a/Source/WebCore/bindings/v8/SerializedScriptValue.cpp b/Source/WebCore/bindings/v8/SerializedScriptValue.cpp index 6ac4a65..666e619 100644 --- a/Source/WebCore/bindings/v8/SerializedScriptValue.cpp +++ b/Source/WebCore/bindings/v8/SerializedScriptValue.cpp @@ -128,7 +128,8 @@ private: // Writer is responsible for serializing primitive types and storing // information used to reconstruct composite types. -class Writer : Noncopyable { +class Writer { + WTF_MAKE_NONCOPYABLE(Writer); public: Writer() : m_position(0) @@ -377,7 +378,8 @@ public: } private: - class StateBase : public Noncopyable { + class StateBase { + WTF_MAKE_NONCOPYABLE(StateBase); public: virtual ~StateBase() { } @@ -1129,12 +1131,18 @@ PassRefPtr<SerializedScriptValue> SerializedScriptValue::create() return adoptRef(new SerializedScriptValue()); } -SerializedScriptValue* SerializedScriptValue::nullValue() +SerializedScriptValue* SerializedScriptValue::nullValue() { DEFINE_STATIC_LOCAL(RefPtr<SerializedScriptValue>, nullValue, (SerializedScriptValue::create())); return nullValue.get(); } +SerializedScriptValue* SerializedScriptValue::undefinedValue() +{ + DEFINE_STATIC_LOCAL(RefPtr<SerializedScriptValue>, undefinedValue, (SerializedScriptValue::create(v8::Undefined()))); + return undefinedValue.get(); +} + PassRefPtr<SerializedScriptValue> SerializedScriptValue::release() { RefPtr<SerializedScriptValue> result = adoptRef(new SerializedScriptValue(m_data, WireData)); diff --git a/Source/WebCore/bindings/v8/SerializedScriptValue.h b/Source/WebCore/bindings/v8/SerializedScriptValue.h index b534a57..ead9511 100644 --- a/Source/WebCore/bindings/v8/SerializedScriptValue.h +++ b/Source/WebCore/bindings/v8/SerializedScriptValue.h @@ -52,8 +52,9 @@ public: static PassRefPtr<SerializedScriptValue> createFromWire(String data); static PassRefPtr<SerializedScriptValue> create(String data); static PassRefPtr<SerializedScriptValue> create(); - - static SerializedScriptValue* nullValue(); + + static SerializedScriptValue* nullValue(); + static SerializedScriptValue* undefinedValue(); PassRefPtr<SerializedScriptValue> release(); diff --git a/Source/WebCore/bindings/v8/V8ConsoleMessage.cpp b/Source/WebCore/bindings/v8/V8ConsoleMessage.cpp deleted file mode 100644 index e6871fd..0000000 --- a/Source/WebCore/bindings/v8/V8ConsoleMessage.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - * 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 "V8ConsoleMessage.h" - -#include "Console.h" -#include "DOMWindow.h" -#include "Frame.h" -#include "OwnPtr.h" -#include "Page.h" -#include "ScriptCallStack.h" -#include "ScriptCallStackFactory.h" -#include "V8Binding.h" -#include "V8Proxy.h" - -namespace WebCore { - -Vector<V8ConsoleMessage>* V8ConsoleMessage::m_delayedMessages = 0; - -V8ConsoleMessage::V8ConsoleMessage(const String& string, const String& sourceID, unsigned lineNumber) - : m_string(string) - , m_sourceID(sourceID) - , m_lineNumber(lineNumber) -{ -} - -void V8ConsoleMessage::dispatchNow(Page* page) -{ - dispatchNow(page, 0); -} - -void V8ConsoleMessage::dispatchLater() -{ - if (!m_delayedMessages) { - // Allocate a vector for the delayed messages. Will be - // deallocated when the delayed messages are processed - // in processDelayed(). - m_delayedMessages = new Vector<V8ConsoleMessage>(); - } - - m_delayedMessages->append(*this); -} - -void V8ConsoleMessage::processDelayed() -{ - if (!m_delayedMessages) - return; - - // Take ownership of the delayed vector to avoid re-entrancy issues. - OwnPtr<Vector<V8ConsoleMessage> > delayedMessages(m_delayedMessages); - m_delayedMessages = 0; - - // If we have a delayed vector it cannot be empty. - ASSERT(!delayedMessages->isEmpty()); - - // Add the delayed messages to the page of the active - // context. If that for some bizarre reason does not - // exist, we clear the list of delayed messages to avoid - // posting messages. We still deallocate the vector. - Frame* frame = V8Proxy::retrieveFrameForEnteredContext(); - if (!frame) - return; - Page* page = frame->page(); - if (!page) - return; - - // Iterate through all the delayed messages and add them - // to the console. - const int size = delayedMessages->size(); - for (int i = 0; i < size; ++i) - delayedMessages->at(i).dispatchNow(page); -} - -void V8ConsoleMessage::handler(v8::Handle<v8::Message> message, v8::Handle<v8::Value> data) -{ - // Use the frame where JavaScript is called from. - Frame* frame = V8Proxy::retrieveFrameForEnteredContext(); - if (!frame) - return; - Page* page = frame->page(); - if (!page) - return; - - v8::Handle<v8::String> errorMessageString = message->Get(); - ASSERT(!errorMessageString.IsEmpty()); - String errorMessage = toWebCoreString(errorMessageString); - - v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace(); - RefPtr<ScriptCallStack> callStack; - // Currently stack trace is only collected when inspector is open. - if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) - callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallStackSizeToCapture); - - v8::Handle<v8::Value> resourceName = message->GetScriptResourceName(); - bool useURL = resourceName.IsEmpty() || !resourceName->IsString(); - String resourceNameString = useURL ? frame->document()->url() : toWebCoreString(resourceName); - V8ConsoleMessage consoleMessage(errorMessage, resourceNameString, message->GetLineNumber()); - consoleMessage.dispatchNow(page, callStack); -} - -void V8ConsoleMessage::dispatchNow(Page* page, PassRefPtr<ScriptCallStack> callStack) -{ - ASSERT(page); - - // Process any delayed messages to make sure that messages - // appear in the right order in the console. - processDelayed(); - - Console* console = page->mainFrame()->domWindow()->console(); - MessageType messageType = callStack ? UncaughtExceptionMessageType : LogMessageType; - console->addMessage(JSMessageSource, messageType, ErrorMessageLevel, m_string, m_lineNumber, m_sourceID, callStack); -} - -} // namespace WebCore diff --git a/Source/WebCore/bindings/v8/V8ConsoleMessage.h b/Source/WebCore/bindings/v8/V8ConsoleMessage.h deleted file mode 100644 index 97de24f..0000000 --- a/Source/WebCore/bindings/v8/V8ConsoleMessage.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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. - */ - -#ifndef V8ConsoleMessage_h -#define V8ConsoleMessage_h - -#include "PlatformString.h" -#include <v8.h> -#include <wtf/PassOwnPtr.h> -#include <wtf/Vector.h> - -namespace WebCore { - - class Page; - class ScriptCallStack; - - // V8ConsoleMessage encapsulates everything needed to - // log messages originating from JavaScript to the console. - class V8ConsoleMessage { - public: - V8ConsoleMessage(const String& string, const String& sourceID, unsigned lineNumber); - - // Add a message to the console. May end up calling JavaScript code - // indirectly through the inspector so only call this function when - // it is safe to do allocations. - void dispatchNow(Page*); - - // Add a message to the console but delay the reporting until it - // is safe to do so: Either when we leave JavaScript execution or - // when adding other console messages. The primary purpose of this - // method is to avoid calling into V8 to handle console messages - // when the VM is in a state that does not support GCs or allocations. - // Delayed messages are always reported in the page corresponding - // to the active context. - void dispatchLater(); - - // Process any delayed messages. May end up calling JavaScript code - // indirectly through the inspector so only call this function when - // it is safe to do allocations. - static void processDelayed(); - - // Convenience class for ensuring that delayed messages in the - // ConsoleMessageManager are processed quickly. - class Scope { - public: - Scope() { V8ConsoleMessage::processDelayed(); } - ~Scope() { V8ConsoleMessage::processDelayed(); } - }; - - // Callback from V8. - static void handler(v8::Handle<v8::Message>, v8::Handle<v8::Value> data); - - private: - const String m_string; - const String m_sourceID; - const unsigned m_lineNumber; - - void dispatchNow(Page*, PassRefPtr<ScriptCallStack>); - - // All delayed messages are stored in this vector. If the vector - // is 0, there are no delayed messages. - static Vector<V8ConsoleMessage>* m_delayedMessages; - }; - -} // namespace WebCore - -#endif // V8ConsoleMessage_h diff --git a/Source/WebCore/bindings/v8/V8DOMMap.h b/Source/WebCore/bindings/v8/V8DOMMap.h index c2b5a9d..51d933a 100644 --- a/Source/WebCore/bindings/v8/V8DOMMap.h +++ b/Source/WebCore/bindings/v8/V8DOMMap.h @@ -60,7 +60,7 @@ namespace WebCore { virtual void set(KeyType* obj, v8::Persistent<ValueType> wrapper) = 0; virtual bool contains(KeyType* obj) = 0; virtual void visit(DOMDataStore* store, Visitor* visitor) = 0; - virtual bool removeIfPresent(KeyType* key, v8::Persistent<v8::Data> value) = 0; + virtual bool removeIfPresent(KeyType*, v8::Persistent<ValueType>) = 0; virtual void clear() = 0; v8::WeakReferenceCallback weakReferenceCallback() { return m_weakReferenceCallback; } @@ -105,7 +105,7 @@ namespace WebCore { handle.Clear(); } - bool removeIfPresent(KeyType* key, v8::Persistent<v8::Data> value) + bool removeIfPresent(KeyType* key, v8::Persistent<ValueType> value) { typename HashMap<KeyType*, ValueType*>::iterator it = m_map.find(key); if (it == m_map.end() || it->second != *value) diff --git a/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp b/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp index 9918577..f53e1b7 100644 --- a/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp +++ b/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp @@ -39,12 +39,13 @@ #include "FrameLoaderClient.h" #include "Page.h" #include "PageGroup.h" +#include "ScriptCallStack.h" +#include "ScriptCallStackFactory.h" #include "ScriptController.h" #include "StorageNamespace.h" #include "V8Binding.h" #include "V8BindingState.h" #include "V8Collection.h" -#include "V8ConsoleMessage.h" #include "V8DOMMap.h" #include "V8DOMWindow.h" #include "V8Document.h" @@ -88,12 +89,36 @@ static void reportFatalErrorInV8(const char* location, const char* message) // FIXME: clean up V8Proxy and disable JavaScript. int memoryUsageMB = -1; #if PLATFORM(CHROMIUM) - memoryUsageMB = ChromiumBridge::actualMemoryUsageMB(); + memoryUsageMB = PlatformBridge::actualMemoryUsageMB(); #endif printf("V8 error: %s (%s). Current memory usage: %d MB\n", message, location, memoryUsageMB); handleFatalErrorInV8(); } +static void v8UncaughtExceptionHandler(v8::Handle<v8::Message> message, v8::Handle<v8::Value> data) +{ + // Use the frame where JavaScript is called from. + Frame* frame = V8Proxy::retrieveFrameForEnteredContext(); + if (!frame) + return; + + v8::Handle<v8::String> errorMessageString = message->Get(); + ASSERT(!errorMessageString.IsEmpty()); + String errorMessage = toWebCoreString(errorMessageString); + + v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace(); + RefPtr<ScriptCallStack> callStack; + // Currently stack trace is only collected when inspector is open. + if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) + callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallStackSizeToCapture); + + v8::Handle<v8::Value> resourceName = message->GetScriptResourceName(); + bool useURL = resourceName.IsEmpty() || !resourceName->IsString(); + Document* document = frame->document(); + String resourceNameString = useURL ? document->url() : toWebCoreString(resourceName); + document->reportException(errorMessage, message->GetLineNumber(), resourceNameString, callStack); +} + // 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) @@ -121,7 +146,7 @@ static void reportUnsafeJavaScriptAccess(v8::Local<v8::Object> host, v8::AccessT { Frame* target = getTargetFrame(host, data); if (target) - V8Proxy::reportUnsafeAccessTo(target, V8Proxy::ReportLater); + V8Proxy::reportUnsafeAccessTo(target); } PassRefPtr<V8DOMWindowShell> V8DOMWindowShell::create(Frame* frame) @@ -270,7 +295,7 @@ bool V8DOMWindowShell::initContextIfNeeded() v8::V8::SetGlobalGCPrologueCallback(&V8GCController::gcPrologue); v8::V8::SetGlobalGCEpilogueCallback(&V8GCController::gcEpilogue); - v8::V8::AddMessageListener(&V8ConsoleMessage::handler); + v8::V8::AddMessageListener(&v8UncaughtExceptionHandler); v8::V8::SetFailedAccessCheckCallbackFunction(reportUnsafeJavaScriptAccess); diff --git a/Source/WebCore/bindings/v8/V8EventListener.h b/Source/WebCore/bindings/v8/V8EventListener.h index fb6c0bc..bcf7213 100644 --- a/Source/WebCore/bindings/v8/V8EventListener.h +++ b/Source/WebCore/bindings/v8/V8EventListener.h @@ -54,8 +54,7 @@ namespace WebCore { v8::Local<v8::Function> getListenerFunction(ScriptExecutionContext*); - private: - virtual v8::Local<v8::Value> callListenerFunction(ScriptExecutionContext*, v8::Handle<v8::Value> jsEvent, Event*); + virtual v8::Local<v8::Value> callListenerFunction(ScriptExecutionContext*, v8::Handle<v8::Value> jsEvent, Event*); }; } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/V8NPUtils.cpp b/Source/WebCore/bindings/v8/V8NPUtils.cpp index 250ee5b..dccdb15 100644 --- a/Source/WebCore/bindings/v8/V8NPUtils.cpp +++ b/Source/WebCore/bindings/v8/V8NPUtils.cpp @@ -63,9 +63,14 @@ void convertV8ObjectToNPVariant(v8::Local<v8::Value> object, NPObject* owner, NP VOID_TO_NPVARIANT(*result); else if (object->IsString()) { v8::String::Utf8Value utf8(object); +<<<<<<< HEAD int length = utf8.length() + 1; char* utf8Chars = reinterpret_cast<char*>(malloc(length)); memcpy(utf8Chars, *utf8, length); +======= + char* utf8Chars = reinterpret_cast<char*>(malloc(utf8.length())); + memcpy(utf8Chars, *utf8, utf8.length()); +>>>>>>> WebKit.org at r76408 STRINGN_TO_NPVARIANT(utf8Chars, utf8.length(), *result); } else if (object->IsObject()) { DOMWindow* window = V8Proxy::retrieveWindow(V8Proxy::currentContext()); diff --git a/Source/WebCore/bindings/v8/V8Proxy.cpp b/Source/WebCore/bindings/v8/V8Proxy.cpp index 5eaba00..831a6ef 100644 --- a/Source/WebCore/bindings/v8/V8Proxy.cpp +++ b/Source/WebCore/bindings/v8/V8Proxy.cpp @@ -50,7 +50,6 @@ #include "V8Binding.h" #include "V8BindingState.h" #include "V8Collection.h" -#include "V8ConsoleMessage.h" #include "V8DOMCoreException.h" #include "V8DOMMap.h" #include "V8DOMWindow.h" @@ -139,21 +138,22 @@ typedef HashMap<int, v8::FunctionTemplate*> FunctionTemplateMap; bool AllowAllocation::m_current = false; +static void addMessageToConsole(Page* page, const String& message, const String& sourceID, unsigned lineNumber) +{ + ASSERT(page); + Console* console = page->mainFrame()->domWindow()->console(); + console->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, message, lineNumber, sourceID); +} + void logInfo(Frame* frame, const String& message, const String& url) { Page* page = frame->page(); if (!page) return; - V8ConsoleMessage consoleMessage(message, url, 0); - consoleMessage.dispatchNow(page); + addMessageToConsole(page, message, url, 0); } -enum DelayReporting { - ReportLater, - ReportNow -}; - -void V8Proxy::reportUnsafeAccessTo(Frame* target, DelayReporting delay) +void V8Proxy::reportUnsafeAccessTo(Frame* target) { ASSERT(target); Document* targetDocument = target->document(); @@ -174,20 +174,11 @@ void V8Proxy::reportUnsafeAccessTo(Frame* target, DelayReporting delay) // Build a console message with fake source ID and line number. const String kSourceID = ""; const int kLineNumber = 1; - V8ConsoleMessage message(str, kSourceID, kLineNumber); - if (delay == ReportNow) { - // NOTE: Safari prints the message in the target page, but it seems like - // it should be in the source page. Even for delayed messages, we put it in - // the source page; see V8ConsoleMessage::processDelayed(). - message.dispatchNow(source->page()); - } else { - ASSERT(delay == ReportLater); - // We cannot safely report the message eagerly, because this may cause - // allocations and GCs internally in V8 and we cannot handle that at this - // point. Therefore we delay the reporting. - message.dispatchLater(); - } + // NOTE: Safari prints the message in the target page, but it seems like + // it should be in the source page. Even for delayed messages, we put it in + // the source page. + addMessageToConsole(source->page(), str, kSourceID, kLineNumber); } static void handleFatalErrorInV8() @@ -440,8 +431,6 @@ v8::Local<v8::Value> V8Proxy::runScriptInternal(v8::Handle<v8::Script> script, b // Run the script and keep track of the current recursion depth. v8::Local<v8::Value> result; { - V8ConsoleMessage::Scope scope; - // See comment in V8Proxy::callFunction. m_frame->keepAlive(); @@ -477,8 +466,6 @@ v8::Local<v8::Value> V8Proxy::callFunction(v8::Handle<v8::Function> function, v8 V8GCController::checkMemoryUsage(); v8::Local<v8::Value> result; { - V8ConsoleMessage::Scope scope; - if (m_recursion >= kMaxRecursionDepth) { v8::Local<v8::String> code = v8::String::New("throw new RangeError('Maximum call stack size exceeded.')"); if (code.IsEmpty()) @@ -545,8 +532,6 @@ v8::Local<v8::Value> V8Proxy::newInstance(v8::Handle<v8::Function> constructor, // V8Proxy::callFunction. v8::Local<v8::Value> result; { - V8ConsoleMessage::Scope scope; - // See comment in V8Proxy::callFunction. m_frame->keepAlive(); @@ -808,11 +793,6 @@ v8::Handle<v8::Value> V8Proxy::checkNewLegal(const v8::Arguments& args) return args.This(); } -void V8Proxy::processConsoleMessages() -{ - V8ConsoleMessage::processDelayed(); -} - void V8Proxy::registerExtensionWithV8(v8::Extension* extension) { // If the extension exists in our list, it was already registered with V8. diff --git a/Source/WebCore/bindings/v8/V8Proxy.h b/Source/WebCore/bindings/v8/V8Proxy.h index 34e80e1..746d8f8 100644 --- a/Source/WebCore/bindings/v8/V8Proxy.h +++ b/Source/WebCore/bindings/v8/V8Proxy.h @@ -132,12 +132,6 @@ namespace WebCore { GeneralError }; - // When to report errors. - enum DelayReporting { - ReportLater, - ReportNow - }; - explicit V8Proxy(Frame*); ~V8Proxy(); @@ -271,9 +265,6 @@ namespace WebCore { template <typename T> static v8::Handle<v8::Value> constructDOMObjectWithScriptExecutionContext(const v8::Arguments&, WrapperTypeInfo*); - // Process any pending JavaScript console messages. - static void processConsoleMessages(); - v8::Local<v8::Context> context(); v8::Local<v8::Context> mainWorldContext(); @@ -294,7 +285,7 @@ namespace WebCore { static const V8Extensions& extensions() { return m_extensions; } // Report an unsafe attempt to access the given frame on the console. - static void reportUnsafeAccessTo(Frame* target, DelayReporting delay); + static void reportUnsafeAccessTo(Frame* target); private: void didLeaveScriptContext(); diff --git a/Source/WebCore/bindings/v8/V8WindowErrorHandler.cpp b/Source/WebCore/bindings/v8/V8WindowErrorHandler.cpp new file mode 100644 index 0000000..4203ad5 --- /dev/null +++ b/Source/WebCore/bindings/v8/V8WindowErrorHandler.cpp @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2010 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 "V8WindowErrorHandler.h" + +#include "ErrorEvent.h" +#include "V8Binding.h" + +namespace WebCore { + +V8WindowErrorHandler::V8WindowErrorHandler(v8::Local<v8::Object> listener, bool isInline, const WorldContextHandle& worldContext) + : V8EventListener(listener, isInline, worldContext) +{ +} + +v8::Local<v8::Value> V8WindowErrorHandler::callListenerFunction(ScriptExecutionContext* context, v8::Handle<v8::Value> jsEvent, Event* event) +{ + if (!event->isErrorEvent()) + return V8EventListener::callListenerFunction(context, jsEvent, event); + + ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event); + v8::Local<v8::Object> listener = getListenerObject(context); + v8::Local<v8::Value> returnValue; + if (!listener.IsEmpty() && listener->IsFunction()) { + v8::Local<v8::Function> callFunction = v8::Local<v8::Function>::Cast(listener); + v8::Local<v8::Object> thisValue = v8::Context::GetCurrent()->Global(); + v8::Handle<v8::Value> parameters[3] = { v8String(errorEvent->message()), v8String(errorEvent->filename()), v8::Integer::New(errorEvent->lineno()) }; + returnValue = callFunction->Call(thisValue, 3, parameters); + if (!returnValue.IsEmpty() && returnValue->IsBoolean() && !returnValue->BooleanValue()) + event->preventDefault(); + } + return returnValue; +} + +} // namespace WebCore diff --git a/Source/WebCore/bindings/v8/V8WindowErrorHandler.h b/Source/WebCore/bindings/v8/V8WindowErrorHandler.h new file mode 100644 index 0000000..493a9bf --- /dev/null +++ b/Source/WebCore/bindings/v8/V8WindowErrorHandler.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2010 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. + */ + +#ifndef V8WindowErrorHandler_h +#define V8WindowErrorHandler_h + +#include "V8EventListener.h" +#include <v8.h> +#include <wtf/PassRefPtr.h> + +namespace WebCore { + +class V8WindowErrorHandler : public V8EventListener { +public: + static PassRefPtr<V8WindowErrorHandler> create(v8::Local<v8::Object> listener, bool isInline, const WorldContextHandle& worldContext) + { + return adoptRef(new V8WindowErrorHandler(listener, isInline, worldContext)); + } + +private: + V8WindowErrorHandler(v8::Local<v8::Object> listener, bool isInline, const WorldContextHandle& worldContext); + + virtual v8::Local<v8::Value> callListenerFunction(ScriptExecutionContext*, v8::Handle<v8::Value> jsEvent, Event*); +}; + +} // namespace WebCore + +#endif // V8WindowErrorHandler_h diff --git a/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp b/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp index cefb2fa..aef892a 100644 --- a/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp +++ b/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp @@ -37,10 +37,10 @@ #include "DedicatedWorkerContext.h" #include "Event.h" +#include "ScriptCallStack.h" #include "SharedWorker.h" #include "SharedWorkerContext.h" #include "V8Binding.h" -#include "V8ConsoleMessage.h" #include "V8DOMMap.h" #include "V8DedicatedWorkerContext.h" #include "V8Proxy.h" @@ -72,7 +72,7 @@ static void v8MessageHandler(v8::Handle<v8::Message> message, v8::Handle<v8::Val String errorMessage = toWebCoreString(message->Get()); int lineNumber = message->GetLineNumber(); String sourceURL = toWebCoreString(message->GetScriptResourceName()); - context->reportException(errorMessage, lineNumber, sourceURL); + context->reportException(errorMessage, lineNumber, sourceURL, 0); } isReportingException = false; diff --git a/Source/WebCore/bindings/v8/WorkerScriptController.cpp b/Source/WebCore/bindings/v8/WorkerScriptController.cpp index b56d383..42e02e6 100644 --- a/Source/WebCore/bindings/v8/WorkerScriptController.cpp +++ b/Source/WebCore/bindings/v8/WorkerScriptController.cpp @@ -34,11 +34,10 @@ #include "WorkerScriptController.h" -#include <v8.h> - +#include "DOMTimer.h" +#include "ScriptCallStack.h" #include "ScriptSourceCode.h" #include "ScriptValue.h" -#include "DOMTimer.h" #include "V8DOMMap.h" #include "V8Proxy.h" #include "V8WorkerContext.h" @@ -46,6 +45,7 @@ #include "WorkerContextExecutionProxy.h" #include "WorkerObjectProxy.h" #include "WorkerThread.h" +#include <v8.h> namespace WebCore { @@ -80,7 +80,7 @@ ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, if (exception) *exception = state.exception; else - m_workerContext->reportException(state.errorMessage, state.lineNumber, state.sourceURL); + m_workerContext->reportException(state.errorMessage, state.lineNumber, state.sourceURL, 0); } return result; diff --git a/Source/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp b/Source/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp index 9e89ce8..3d64edd 100644 --- a/Source/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp @@ -59,7 +59,10 @@ static v8::Handle<v8::Value> getItem(HTMLCollection* collection, v8::Handle<v8:: { v8::Local<v8::Uint32> index = argument->ToArrayIndex(); if (index.IsEmpty()) { - v8::Handle<v8::Value> result = getNamedItems(collection, toWebCoreString(argument->ToString())); + v8::Local<v8::String> asString = argument->ToString(); + if (asString.IsEmpty()) + return v8::Handle<v8::Value>(); + v8::Handle<v8::Value> result = getNamedItems(collection, toWebCoreString(asString)); if (result.IsEmpty()) return v8::Undefined(); diff --git a/Source/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp b/Source/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp index 70df7c1..7fdfc55 100644 --- a/Source/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp @@ -48,6 +48,7 @@ #include "V8Int16Array.h" #include "V8Int32Array.h" #include "V8Int8Array.h" +#include "V8OESStandardDerivatives.h" #include "V8OESTextureFloat.h" #include "V8Proxy.h" #include "V8Uint16Array.h" @@ -160,6 +161,9 @@ static v8::Handle<v8::Value> toV8Object(WebGLExtension* extension, v8::Handle<v8 case WebGLExtension::WebKitLoseContextName: extensionObject = toV8(static_cast<WebKitLoseContext*>(extension)); break; + case WebGLExtension::OESStandardDerivativesName: + extensionObject = toV8(static_cast<OESStandardDerivatives*>(extension)); + break; case WebGLExtension::OESTextureFloatName: extensionObject = toV8(static_cast<OESTextureFloat*>(extension)); break; diff --git a/Source/WebCore/bindings/v8/specialization/V8BindingState.cpp b/Source/WebCore/bindings/v8/specialization/V8BindingState.cpp index 891272c..e00e35b 100644 --- a/Source/WebCore/bindings/v8/specialization/V8BindingState.cpp +++ b/Source/WebCore/bindings/v8/specialization/V8BindingState.cpp @@ -81,7 +81,7 @@ Frame* State<V8Binding>::firstFrame() void State<V8Binding>::immediatelyReportUnsafeAccessTo(Frame* target) { - V8Proxy::reportUnsafeAccessTo(target, V8Proxy::ReportNow); + V8Proxy::reportUnsafeAccessTo(target); } bool State<V8Binding>::processingUserGesture() |