summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-02-05 14:27:46 +0000
committerSteve Block <steveblock@google.com>2010-02-15 10:49:50 +0000
commit5e2bc6953fe6923165b8a5d7679939693a1d58d6 (patch)
tree6ccb8c24bc2bf5e8f413e6cfae250b729b426631 /WebCore/bindings
parent4a00f4fccc3cb7e9996749a05631f5d7b9de756e (diff)
downloadexternal_webkit-5e2bc6953fe6923165b8a5d7679939693a1d58d6.zip
external_webkit-5e2bc6953fe6923165b8a5d7679939693a1d58d6.tar.gz
external_webkit-5e2bc6953fe6923165b8a5d7679939693a1d58d6.tar.bz2
Merge webkit.org at r54340 : Initial merge by git
Change-Id: Ib489d2ff91186ea3652522e1d586e54416a2cf44
Diffstat (limited to 'WebCore/bindings')
-rw-r--r--WebCore/bindings/js/JSBindingsAllInOne.cpp1
-rw-r--r--WebCore/bindings/js/JSConsoleCustom.cpp21
-rw-r--r--WebCore/bindings/js/JSDOMBinding.cpp2
-rw-r--r--WebCore/bindings/js/JSDOMWindowCustom.cpp12
-rw-r--r--WebCore/bindings/js/JSDocumentCustom.cpp2
-rw-r--r--WebCore/bindings/js/JSInjectedScriptHostCustom.cpp10
-rw-r--r--WebCore/bindings/js/ScriptController.cpp47
-rw-r--r--WebCore/bindings/js/ScriptController.h4
-rw-r--r--WebCore/bindings/js/ScriptProfile.h41
-rw-r--r--WebCore/bindings/js/ScriptProfiler.cpp49
-rw-r--r--WebCore/bindings/js/ScriptProfiler.h48
-rw-r--r--WebCore/bindings/scripts/CodeGeneratorJS.pm5
-rw-r--r--WebCore/bindings/scripts/CodeGeneratorV8.pm373
-rw-r--r--WebCore/bindings/v8/ScriptController.cpp19
-rw-r--r--WebCore/bindings/v8/ScriptController.h6
-rw-r--r--WebCore/bindings/v8/ScriptObject.cpp11
-rw-r--r--WebCore/bindings/v8/ScriptProfile.h62
-rw-r--r--WebCore/bindings/v8/ScriptProfiler.cpp (renamed from WebCore/bindings/v8/custom/V8ConsoleCustom.cpp)19
-rw-r--r--WebCore/bindings/v8/ScriptProfiler.h50
-rw-r--r--WebCore/bindings/v8/V8AbstractEventListener.cpp3
-rw-r--r--WebCore/bindings/v8/V8Collection.h288
-rw-r--r--WebCore/bindings/v8/V8DOMWindowShell.cpp4
-rw-r--r--WebCore/bindings/v8/V8DOMWrapper.cpp649
-rw-r--r--WebCore/bindings/v8/V8DOMWrapper.h86
-rw-r--r--WebCore/bindings/v8/V8NodeFilterCondition.cpp3
-rw-r--r--WebCore/bindings/v8/V8Proxy.cpp19
-rw-r--r--WebCore/bindings/v8/V8Proxy.h4
-rw-r--r--WebCore/bindings/v8/WorkerContextExecutionProxy.h5
-rw-r--r--WebCore/bindings/v8/custom/V8BarInfoCustom.cpp73
-rw-r--r--WebCore/bindings/v8/custom/V8CSSRuleCustom.cpp73
-rw-r--r--WebCore/bindings/v8/custom/V8CSSStyleSheetCustom.cpp50
-rw-r--r--WebCore/bindings/v8/custom/V8CSSValueCustom.cpp59
-rw-r--r--WebCore/bindings/v8/custom/V8CanvasPixelArrayCustom.cpp46
-rw-r--r--WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp14
-rw-r--r--WebCore/bindings/v8/custom/V8CustomPositionCallback.cpp3
-rw-r--r--WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.cpp3
-rw-r--r--WebCore/bindings/v8/custom/V8CustomSQLStatementCallback.cpp6
-rw-r--r--WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp6
-rw-r--r--WebCore/bindings/v8/custom/V8CustomSQLTransactionCallback.cpp3
-rw-r--r--WebCore/bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp3
-rw-r--r--WebCore/bindings/v8/custom/V8DOMSelectionCustom.cpp51
-rw-r--r--WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp63
-rw-r--r--WebCore/bindings/v8/custom/V8DataGridColumnListCustom.cpp2
-rw-r--r--WebCore/bindings/v8/custom/V8DocumentCustom.cpp35
-rw-r--r--WebCore/bindings/v8/custom/V8DocumentLocationCustom.cpp5
-rw-r--r--WebCore/bindings/v8/custom/V8ElementCustom.cpp16
-rw-r--r--WebCore/bindings/v8/custom/V8EventCustom.cpp78
-rw-r--r--WebCore/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp10
-rw-r--r--WebCore/bindings/v8/custom/V8HTMLAudioElementConstructor.cpp3
-rw-r--r--WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp7
-rw-r--r--WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp18
-rw-r--r--WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp32
-rw-r--r--WebCore/bindings/v8/custom/V8HTMLElementCustom.cpp45
-rw-r--r--WebCore/bindings/v8/custom/V8HTMLFormElementCustom.cpp9
-rw-r--r--WebCore/bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp4
-rw-r--r--WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp3
-rw-r--r--WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp4
-rw-r--r--WebCore/bindings/v8/custom/V8HTMLSelectElementCustom.cpp10
-rw-r--r--WebCore/bindings/v8/custom/V8HistoryCustom.cpp14
-rw-r--r--WebCore/bindings/v8/custom/V8IDBRequestCustom.cpp4
-rw-r--r--WebCore/bindings/v8/custom/V8IndexedDatabaseRequestCustom.cpp4
-rw-r--r--WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp17
-rw-r--r--WebCore/bindings/v8/custom/V8LocationCustom.cpp14
-rw-r--r--WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp5
-rw-r--r--WebCore/bindings/v8/custom/V8MessageEventCustom.cpp4
-rw-r--r--WebCore/bindings/v8/custom/V8NamedNodeMapCustom.cpp21
-rw-r--r--WebCore/bindings/v8/custom/V8NavigatorCustom.cpp21
-rw-r--r--WebCore/bindings/v8/custom/V8NodeCustom.cpp51
-rw-r--r--WebCore/bindings/v8/custom/V8NodeIteratorCustom.cpp4
-rw-r--r--WebCore/bindings/v8/custom/V8NodeListCustom.cpp7
-rw-r--r--WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp5
-rw-r--r--WebCore/bindings/v8/custom/V8SVGDocumentCustom.cpp51
-rw-r--r--WebCore/bindings/v8/custom/V8SVGElementCustom.cpp49
-rw-r--r--WebCore/bindings/v8/custom/V8SVGMatrixCustom.cpp14
-rw-r--r--WebCore/bindings/v8/custom/V8SVGPathSegCustom.cpp106
-rw-r--r--WebCore/bindings/v8/custom/V8ScreenCustom.cpp52
-rw-r--r--WebCore/bindings/v8/custom/V8StyleSheetCustom.cpp55
-rw-r--r--WebCore/bindings/v8/custom/V8StyleSheetListCustom.cpp4
-rw-r--r--WebCore/bindings/v8/custom/V8TreeWalkerCustom.cpp20
-rw-r--r--WebCore/bindings/v8/custom/V8WebGLArrayCustom.cpp69
-rw-r--r--WebCore/bindings/v8/custom/V8WebGLByteArrayCustom.cpp10
-rw-r--r--WebCore/bindings/v8/custom/V8WebGLFloatArrayCustom.cpp10
-rw-r--r--WebCore/bindings/v8/custom/V8WebGLIntArrayCustom.cpp10
-rw-r--r--WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp34
-rw-r--r--WebCore/bindings/v8/custom/V8WebGLShortArrayCustom.cpp10
-rw-r--r--WebCore/bindings/v8/custom/V8WebGLUnsignedByteArrayCustom.cpp10
-rw-r--r--WebCore/bindings/v8/custom/V8WebGLUnsignedIntArrayCustom.cpp10
-rw-r--r--WebCore/bindings/v8/custom/V8WebGLUnsignedShortArrayCustom.cpp10
-rw-r--r--WebCore/bindings/v8/custom/V8XSLTProcessorCustom.cpp6
89 files changed, 2108 insertions, 1170 deletions
diff --git a/WebCore/bindings/js/JSBindingsAllInOne.cpp b/WebCore/bindings/js/JSBindingsAllInOne.cpp
index e539042..8a918a3 100644
--- a/WebCore/bindings/js/JSBindingsAllInOne.cpp
+++ b/WebCore/bindings/js/JSBindingsAllInOne.cpp
@@ -142,6 +142,7 @@
#include "ScriptControllerWin.cpp"
#include "ScriptEventListener.cpp"
#include "ScriptFunctionCall.cpp"
+#include "ScriptProfiler.cpp"
#include "ScriptState.cpp"
#include "SerializedScriptValue.cpp"
#include "WorkerScriptController.cpp"
diff --git a/WebCore/bindings/js/JSConsoleCustom.cpp b/WebCore/bindings/js/JSConsoleCustom.cpp
index 8366b39..b631cdd 100644
--- a/WebCore/bindings/js/JSConsoleCustom.cpp
+++ b/WebCore/bindings/js/JSConsoleCustom.cpp
@@ -24,13 +24,14 @@
*/
#include "config.h"
+
#include "JSConsole.h"
+
+#include "Console.h"
#include "JavaScriptProfile.h"
#include "ScriptCallStack.h"
#include <runtime/JSArray.h>
-#include "Console.h"
-
using namespace JSC;
namespace WebCore {
@@ -51,22 +52,6 @@ JSValue JSConsole::profiles(ExecState* exec) const
return constructArray(exec, list);
}
-JSValue JSConsole::profile(ExecState* exec, const ArgList& args)
-{
- ScriptCallStack callStack(exec, args, 1);
- const UString title = valueToStringWithUndefinedOrNullCheck(exec, args.at(0));
- impl()->profile(title, &callStack);
- return jsUndefined();
-}
-
-JSValue JSConsole::profileEnd(ExecState* exec, const ArgList& args)
-{
- ScriptCallStack callStack(exec, args, 1);
- const UString title = valueToStringWithUndefinedOrNullCheck(exec, args.at(0));
- impl()->profileEnd(title, &callStack);
- return jsUndefined();
-}
-
#endif
} // namespace WebCore
diff --git a/WebCore/bindings/js/JSDOMBinding.cpp b/WebCore/bindings/js/JSDOMBinding.cpp
index 04b6dc9..abba405 100644
--- a/WebCore/bindings/js/JSDOMBinding.cpp
+++ b/WebCore/bindings/js/JSDOMBinding.cpp
@@ -776,7 +776,7 @@ Frame* toDynamicFrame(ExecState* exec)
bool processingUserGesture(ExecState* exec)
{
Frame* frame = toDynamicFrame(exec);
- return frame && frame->script()->processingUserGesture();
+ return frame && frame->script()->processingUserGesture(currentWorld(exec));
}
KURL completeURL(ExecState* exec, const String& relativeURL)
diff --git a/WebCore/bindings/js/JSDOMWindowCustom.cpp b/WebCore/bindings/js/JSDOMWindowCustom.cpp
index 1da5af2..f7be2c5 100644
--- a/WebCore/bindings/js/JSDOMWindowCustom.cpp
+++ b/WebCore/bindings/js/JSDOMWindowCustom.cpp
@@ -716,6 +716,14 @@ static Frame* createWindow(ExecState* exec, Frame* lexicalFrame, Frame* dynamicF
return newFrame;
}
+static bool domWindowAllowPopUp(Frame* activeFrame, ExecState* exec)
+{
+ ASSERT(activeFrame);
+ if (activeFrame->script()->processingUserGesture(currentWorld(exec)))
+ return true;
+ return DOMWindow::allowPopUp(activeFrame);
+}
+
JSValue JSDOMWindow::open(ExecState* exec, const ArgList& args)
{
String urlString = valueToStringWithUndefinedOrNullCheck(exec, args.at(0));
@@ -736,7 +744,7 @@ JSValue JSDOMWindow::open(ExecState* exec, const ArgList& args)
// Because FrameTree::find() returns true for empty strings, we must check for empty framenames.
// Otherwise, illegitimate window.open() calls with no name will pass right through the popup blocker.
- if (!DOMWindow::allowPopUp(dynamicFrame) && (frameName.isEmpty() || !frame->tree()->find(frameName)))
+ if (!domWindowAllowPopUp(dynamicFrame, exec) && (frameName.isEmpty() || !frame->tree()->find(frameName)))
return jsUndefined();
// Get the target frame for the special cases of _top and _parent. In those
@@ -806,7 +814,7 @@ JSValue JSDOMWindow::showModalDialog(ExecState* exec, const ArgList& args)
if (!dynamicFrame)
return jsUndefined();
- if (!DOMWindow::canShowModalDialogNow(frame) || !DOMWindow::allowPopUp(dynamicFrame))
+ if (!DOMWindow::canShowModalDialogNow(frame) || !domWindowAllowPopUp(dynamicFrame, exec))
return jsUndefined();
HashMap<String, String> features;
diff --git a/WebCore/bindings/js/JSDocumentCustom.cpp b/WebCore/bindings/js/JSDocumentCustom.cpp
index 9366399..eda153e 100644
--- a/WebCore/bindings/js/JSDocumentCustom.cpp
+++ b/WebCore/bindings/js/JSDocumentCustom.cpp
@@ -87,7 +87,7 @@ void JSDocument::setLocation(ExecState* exec, JSValue value)
if (activeFrame)
str = activeFrame->document()->completeURL(str).string();
- bool userGesture = activeFrame->script()->processingUserGesture();
+ bool userGesture = activeFrame->script()->processingUserGesture(currentWorld(exec));
frame->redirectScheduler()->scheduleLocationChange(str, activeFrame->loader()->outgoingReferrer(), !activeFrame->script()->anyPageIsProcessingUserGesture(), false, userGesture);
}
diff --git a/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp b/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp
index d38d8ee..96c5c43 100644
--- a/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp
+++ b/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp
@@ -43,6 +43,7 @@
#include "ExceptionCode.h"
#include "Frame.h"
#include "FrameLoader.h"
+#include "InjectedScript.h"
#include "InjectedScriptHost.h"
#include "InspectorController.h"
#include "InspectorResource.h"
@@ -194,20 +195,21 @@ JSValue JSInjectedScriptHost::selectDOMStorage(ExecState*, const ArgList& args)
}
#endif
-ScriptObject InjectedScriptHost::injectedScriptFor(ScriptState* scriptState)
+InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState* scriptState)
{
JSLock lock(SilenceAssertionsOnly);
JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject());
JSObject* injectedScript = globalObject->injectedScript();
if (injectedScript)
- return ScriptObject(scriptState, injectedScript);
+ return InjectedScript(ScriptObject(scriptState, injectedScript));
ASSERT(!m_injectedScriptSource.isEmpty());
ScriptObject injectedScriptObject = createInjectedScript(m_injectedScriptSource, this, scriptState, m_nextInjectedScriptId);
globalObject->setInjectedScript(injectedScriptObject.jsObject());
- m_idToInjectedScript.set(m_nextInjectedScriptId, injectedScriptObject);
+ InjectedScript result(injectedScriptObject);
+ m_idToInjectedScript.set(m_nextInjectedScriptId, result);
m_nextInjectedScriptId++;
- return injectedScriptObject;
+ return result;
}
} // namespace WebCore
diff --git a/WebCore/bindings/js/ScriptController.cpp b/WebCore/bindings/js/ScriptController.cpp
index 083e931..bd36689 100644
--- a/WebCore/bindings/js/ScriptController.cpp
+++ b/WebCore/bindings/js/ScriptController.cpp
@@ -222,39 +222,19 @@ JSDOMWindowShell* ScriptController::initScript(DOMWrapperWorld* world)
return windowShell;
}
-bool ScriptController::processingUserGesture() const
+bool ScriptController::processingUserGesture(DOMWrapperWorld* world) const
{
- return m_allowPopupsFromPlugin || processingUserGestureEvent() || isJavaScriptAnchorNavigation();
+ return m_allowPopupsFromPlugin || processingUserGestureEvent(world) || isJavaScriptAnchorNavigation();
}
-bool ScriptController::processingUserGestureEvent() const
+bool ScriptController::processingUserGestureEvent(DOMWrapperWorld* world) const
{
- JSDOMWindowShell* shell = existingWindowShell(mainThreadNormalWorld());
+ JSDOMWindowShell* shell = existingWindowShell(world);
if (!shell)
return false;
- if (Event* event = shell->window()->currentEvent()) {
- if (event->createdByDOM())
- return false;
-
- const AtomicString& type = event->type();
- if ( // mouse events
- type == eventNames().clickEvent || type == eventNames().mousedownEvent
- || type == eventNames().mouseupEvent || type == eventNames().dblclickEvent
- // keyboard events
- || type == eventNames().keydownEvent || type == eventNames().keypressEvent
- || type == eventNames().keyupEvent
-#if ENABLE(TOUCH_EVENTS)
- // touch events
- || type == eventNames().touchstartEvent || type == eventNames().touchmoveEvent
- || type == eventNames().touchendEvent || type == eventNames().touchcancelEvent
-#endif
- // other accepted events
- || type == eventNames().selectEvent || type == eventNames().changeEvent
- || type == eventNames().focusEvent || type == eventNames().blurEvent
- || type == eventNames().submitEvent)
- return true;
- }
+ if (Event* event = shell->window()->currentEvent())
+ return event->fromUserGesture();
return false;
}
@@ -280,7 +260,20 @@ bool ScriptController::anyPageIsProcessingUserGesture() const
HashSet<Page*>::const_iterator end = pages.end();
for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it) {
for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
- if (frame->script()->processingUserGesture())
+ ScriptController* script = frame->script();
+
+ if (script->m_allowPopupsFromPlugin)
+ return true;
+
+ const ShellMap::const_iterator iterEnd = m_windowShells.end();
+ for (ShellMap::const_iterator iter = m_windowShells.begin(); iter != iterEnd; ++iter) {
+ JSDOMWindowShell* shell = iter->second.get();
+ Event* event = shell->window()->currentEvent();
+ if (event && event->fromUserGesture())
+ return true;
+ }
+
+ if (isJavaScriptAnchorNavigation())
return true;
}
}
diff --git a/WebCore/bindings/js/ScriptController.h b/WebCore/bindings/js/ScriptController.h
index f3e5adf..1cbb56d 100644
--- a/WebCore/bindings/js/ScriptController.h
+++ b/WebCore/bindings/js/ScriptController.h
@@ -107,7 +107,7 @@ public:
int eventHandlerLineNumber() { return m_handlerLineNumber; }
void setProcessingTimerCallback(bool b) { m_processingTimerCallback = b; }
- bool processingUserGesture() const;
+ bool processingUserGesture(DOMWrapperWorld*) const;
bool anyPageIsProcessingUserGesture() const;
bool canExecuteScripts();
@@ -164,7 +164,7 @@ private:
void disconnectPlatformScriptObjects();
- bool processingUserGestureEvent() const;
+ bool processingUserGestureEvent(DOMWrapperWorld*) const;
bool isJavaScriptAnchorNavigation() const;
ShellMap m_windowShells;
diff --git a/WebCore/bindings/js/ScriptProfile.h b/WebCore/bindings/js/ScriptProfile.h
new file mode 100644
index 0000000..32095e3
--- /dev/null
+++ b/WebCore/bindings/js/ScriptProfile.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * 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:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 ScriptProfile_h
+#define ScriptProfile_h
+
+#if ENABLE(JAVASCRIPT_DEBUGGER)
+#include <profiler/Profile.h>
+
+namespace WebCore {
+
+typedef JSC::Profile ScriptProfile;
+
+} // namespace WebCore
+
+#endif // ENABLE(JAVASCRIPT_DEBUGGER)
+
+#endif // ScriptProfile_h
diff --git a/WebCore/bindings/js/ScriptProfiler.cpp b/WebCore/bindings/js/ScriptProfiler.cpp
new file mode 100644
index 0000000..789e3d3
--- /dev/null
+++ b/WebCore/bindings/js/ScriptProfiler.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * 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:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(JAVASCRIPT_DEBUGGER)
+
+#include "ScriptProfiler.h"
+
+#include <profiler/Profiler.h>
+
+namespace WebCore {
+
+void ScriptProfiler::start(ScriptState* state, const String& title)
+{
+ JSC::Profiler::profiler()->startProfiling(state, title);
+}
+
+PassRefPtr<ScriptProfile> ScriptProfiler::stop(ScriptState* state, const String& title)
+{
+ return JSC::Profiler::profiler()->stopProfiling(state, title);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(JAVASCRIPT_DEBUGGER)
diff --git a/WebCore/bindings/js/ScriptProfiler.h b/WebCore/bindings/js/ScriptProfiler.h
new file mode 100644
index 0000000..a86bcfb
--- /dev/null
+++ b/WebCore/bindings/js/ScriptProfiler.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * 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:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 ScriptProfiler_h
+#define ScriptProfiler_h
+
+#if ENABLE(JAVASCRIPT_DEBUGGER)
+#include "ScriptProfile.h"
+#include "ScriptState.h"
+
+#include <wtf/Noncopyable.h>
+
+namespace WebCore {
+
+class ScriptProfiler : public Noncopyable {
+public:
+ static void start(ScriptState* state, const String& title);
+ static PassRefPtr<ScriptProfile> stop(ScriptState* state, const String& title);
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(JAVASCRIPT_DEBUGGER)
+
+#endif // ScriptProfiler_h
diff --git a/WebCore/bindings/scripts/CodeGeneratorJS.pm b/WebCore/bindings/scripts/CodeGeneratorJS.pm
index 7a55a3d..c774a57 100644
--- a/WebCore/bindings/scripts/CodeGeneratorJS.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorJS.pm
@@ -1676,7 +1676,12 @@ sub GenerateImplementation
} else {
$functionString .= $name;
}
+ $paramIndex++;
+ }
+ if ($function->signature->extendedAttributes->{"NeedsUserGestureCheck"}) {
+ $functionString .= ", " if $paramIndex;
+ $functionString .= "processingUserGesture(exec)";
$paramIndex++;
}
diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm
index 305fdfd..cb4d04a 100644
--- a/WebCore/bindings/scripts/CodeGeneratorV8.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm
@@ -156,14 +156,15 @@ sub AddIncludesForType
# When we're finished with the one-file-per-class
# reorganization, we won't need these special cases.
- if ($codeGenerator->IsPrimitiveType($type) or AvoidInclusionOfType($type)) {
- } elsif ($type =~ /SVGPathSeg/) {
- $joinedName = $type;
- $joinedName =~ s/Abs|Rel//;
- $implIncludes{"${joinedName}.h"} = 1;
- } else {
+ if (!$codeGenerator->IsPrimitiveType($type) and !AvoidInclusionOfType($type) and $type ne "Date") {
# default, include the same named file
- $implIncludes{GetImplementationFileName(${type})} = 1;
+ $implIncludes{GetV8HeaderName(${type})} = 1;
+
+ if ($type =~ /SVGPathSeg/) {
+ $joinedName = $type;
+ $joinedName =~ s/Abs|Rel//;
+ $implIncludes{"${joinedName}.h"} = 1;
+ }
}
# additional includes (things needed to compile the bindings but not the header)
@@ -210,17 +211,6 @@ sub AddClassForwardIfNeeded
push(@headerContent, "class $implClassName;\n\n") unless $codeGenerator->IsSVGAnimatedType($implClassName);
}
-sub GetImplementationFileName
-{
- my $iface = shift;
- return "Event.h" if $iface eq "DOMTimeStamp";
- return "NamedAttrMap.h" if $iface eq "NamedNodeMap";
- return "NameNodeList.h" if $iface eq "NodeList";
- return "XMLHttpRequest.h" if $iface eq "XMLHttpRequest";
-
- return "${iface}.h";
-}
-
# If the node has a [Conditional=XXX] attribute, returns an "ENABLE(XXX)" string for use in an #if.
sub GenerateConditionalString
{
@@ -258,7 +248,6 @@ sub GenerateHeader
# Get correct pass/store types respecting PODType flag
my $podType = $dataNode->extendedAttributes->{"PODType"};
- my $passType = $podType ? "JSSVGPODTypeWrapper<$podType>*" : "$implClassName*";
push(@headerContent, "#include \"$podType.h\"\n") if $podType and ($podType ne "double" and $podType ne "float" and $podType ne "RGBA32");
@@ -268,15 +257,23 @@ sub GenerateHeader
push(@headerContent, "#include \"V8Index.h\"\n");
push(@headerContent, GetHeaderClassInclude($implClassName));
push(@headerContent, "\nnamespace WebCore {\n");
+ if ($podType) {
+ push(@headerContent, "\ntemplate<typename PODType> class V8SVGPODTypeWrapper;\n");
+ }
push(@headerContent, "\nclass $className {\n");
-
- my $toNativeReturnType = GetReturnTypeForToNative($interfaceName);
+
+ my $nativeType = GetNativeTypeForConversions($interfaceName);
+ if ($podType) {
+ $nativeType = "V8SVGPODTypeWrapper<${nativeType} >";
+ }
+ my $forceNewObjectParameter = IsDOMNodeType($interfaceName) ? ", bool forceNewObject = false" : "";
push(@headerContent, <<END);
public:
static bool HasInstance(v8::Handle<v8::Value> value);
static v8::Persistent<v8::FunctionTemplate> GetRawTemplate();
- static ${toNativeReturnType}* toNative(v8::Handle<v8::Object>);
+ static ${nativeType}* toNative(v8::Handle<v8::Object>);
+ static v8::Handle<v8::Object> wrap(${nativeType}*${forceNewObjectParameter});
END
if ($implClassName eq "DOMWindow") {
@@ -346,7 +343,13 @@ END
friend class V8ClassIndex;
};
+ v8::Handle<v8::Value> toV8(${nativeType}*${forceNewObjectParameter});
+END
+ if (IsRefPtrType($implClassName)) {
+ push(@headerContent, <<END);
+ v8::Handle<v8::Value> toV8(PassRefPtr<${nativeType} >${forceNewObjectParameter});
END
+ }
push(@headerContent, "}\n\n");
push(@headerContent, "#endif // $className" . "_H\n");
@@ -665,7 +668,7 @@ sub GenerateNormalAttrGetter
$attrIsPodType = 0;
}
- my $getterStringUsesImp = $implClassName ne "double";
+ my $getterStringUsesImp = $implClassName ne "float";
# Getter
push(@implContentDecls, <<END);
@@ -821,13 +824,16 @@ END
push(@implContentDecls, GenerateSVGContextAssignment($implClassName, "wrapper.get()", " "));
} else {
push(@implContentDecls, GenerateSVGContextRetrieval($implClassName, " "));
- $result = "V8Proxy::withSVGContext($result, context)";
+ # The templating associated with passing withSVGContext()'s return value directly into toV8 can get compilers confused,
+ # so just manually set the return value to a PassRefPtr of the expected type.
+ push(@implContentDecls, " PassRefPtr<$attrType> resultAsPassRefPtr = V8Proxy::withSVGContext($result, context);\n");
+ $result = "resultAsPassRefPtr";
}
}
if ($attrIsPodType) {
- my $classIndex = uc($attrType);
- push(@implContentDecls, " return V8DOMWrapper::convertToV8Object(V8ClassIndex::$classIndex, wrapper.release());\n");
+ $implIncludes{"V8${attrType}.h"} = 1;
+ push(@implContentDecls, " return toV8(wrapper.release().get());\n");
} else {
push(@implContentDecls, " " . ReturnNativeToJSValue($attribute->signature, $result, " ").";\n");
}
@@ -943,7 +949,7 @@ END
push(@implContentDecls, " ExceptionCode ec = 0;\n");
}
- if ($implClassName eq "double") {
+ if ($implClassName eq "float") {
push(@implContentDecls, " *imp = $result;\n");
} else {
my $implSetterFunctionName = $codeGenerator->WK_ucfirst($attrName);
@@ -956,7 +962,6 @@ END
push(@implContentDecls, " imp->setAttribute(${namespace}::${contentAttributeName}Attr, $result");
} elsif ($attribute->signature->type eq "EventListener") {
$implIncludes{"V8AbstractEventListener.h"} = 1;
- $implIncludes{"V8CustomBinding.h"} = 1;
push(@implContentDecls, " transferHiddenDependency(info.Holder(), imp->$attrName(), value, V8${interfaceName}::cacheIndex);\n");
push(@implContentDecls, " imp->set$implSetterFunctionName(V8DOMWrapper::getEventListener(imp, value, true, ListenerFindOrCreate)");
} else {
@@ -1472,7 +1477,9 @@ sub GenerateImplementation
"#include \"config.h\"\n" .
"#include \"V8Proxy.h\"\n" .
"#include \"V8Binding.h\"\n" .
- "#include \"V8BindingState.h\"\n\n" .
+ "#include \"V8BindingState.h\"\n" .
+ "#include \"V8DOMWrapper.h\"\n" .
+ "#include \"V8IsolatedContext.h\"\n\n" .
"#undef LOG\n\n");
push(@implFixedHeader, "\n#if ${conditionalString}\n\n") if $conditionalString;
@@ -1498,10 +1505,8 @@ sub GenerateImplementation
# Generate special code for the constructor attributes.
if ($attrType =~ /Constructor$/) {
- if ($attribute->signature->extendedAttributes->{"CustomGetter"} ||
- $attribute->signature->extendedAttributes->{"V8CustomGetter"}) {
- $implIncludes{"V8CustomBinding.h"} = 1;
- } else {
+ if (!($attribute->signature->extendedAttributes->{"CustomGetter"} ||
+ $attribute->signature->extendedAttributes->{"V8CustomGetter"})) {
$hasConstructors = 1;
}
next;
@@ -1516,25 +1521,22 @@ sub GenerateImplementation
# implementation.
if ($attribute->signature->extendedAttributes->{"Custom"} ||
$attribute->signature->extendedAttributes->{"V8Custom"}) {
- $implIncludes{"V8CustomBinding.h"} = 1;
next;
}
# Generate the accessor.
- if ($attribute->signature->extendedAttributes->{"CustomGetter"} ||
- $attribute->signature->extendedAttributes->{"V8CustomGetter"}) {
- $implIncludes{"V8CustomBinding.h"} = 1;
- } else {
+ if (!($attribute->signature->extendedAttributes->{"CustomGetter"} ||
+ $attribute->signature->extendedAttributes->{"V8CustomGetter"})) {
GenerateNormalAttrGetter($attribute, $dataNode, $classIndex, $implClassName, $interfaceName);
}
- if ($attribute->signature->extendedAttributes->{"CustomSetter"} ||
- $attribute->signature->extendedAttributes->{"V8CustomSetter"}) {
- $implIncludes{"V8CustomBinding.h"} = 1;
- } elsif ($attribute->signature->extendedAttributes->{"Replaceable"}) {
- $dataNode->extendedAttributes->{"ExtendsDOMGlobalObject"} || die "Replaceable attribute can only be used in interface that defines ExtendsDOMGlobalObject attribute!";
- # GenerateReplaceableAttrSetter($implClassName);
- } elsif ($attribute->type !~ /^readonly/ && !$attribute->signature->extendedAttributes->{"V8ReadOnly"}) {
- GenerateNormalAttrSetter($attribute, $dataNode, $classIndex, $implClassName, $interfaceName);
+ if (!($attribute->signature->extendedAttributes->{"CustomSetter"} ||
+ $attribute->signature->extendedAttributes->{"V8CustomSetter"})) {
+ if ($attribute->signature->extendedAttributes->{"Replaceable"}) {
+ $dataNode->extendedAttributes->{"ExtendsDOMGlobalObject"} || die "Replaceable attribute can only be used in interface that defines ExtendsDOMGlobalObject attribute!";
+ # GenerateReplaceableAttrSetter($implClassName);
+ } elsif ($attribute->type !~ /^readonly/ && !$attribute->signature->extendedAttributes->{"V8ReadOnly"}) {
+ GenerateNormalAttrSetter($attribute, $dataNode, $classIndex, $implClassName, $interfaceName);
+ }
}
}
@@ -1548,9 +1550,7 @@ sub GenerateImplementation
foreach my $function (@{$dataNode->functions}) {
# hack for addEventListener/RemoveEventListener
# FIXME: avoid naming conflict
- if ($function->signature->extendedAttributes->{"Custom"} || $function->signature->extendedAttributes->{"V8Custom"}) {
- $implIncludes{"V8CustomBinding.h"} = 1;
- } else {
+ if (!($function->signature->extendedAttributes->{"Custom"} || $function->signature->extendedAttributes->{"V8Custom"})) {
GenerateFunctionCallback($function, $dataNode, $classIndex, $implClassName);
}
@@ -1888,7 +1888,10 @@ END
END
}
- $toNativeReturnType = GetReturnTypeForToNative($interfaceName);
+ my $nativeType = GetNativeTypeForConversions($interfaceName);
+ if ($dataNode->extendedAttributes->{"PODType"}) {
+ $nativeType = "V8SVGPODTypeWrapper<${nativeType}>";
+ }
push(@implContent, <<END);
// Custom toString template
@@ -1906,8 +1909,8 @@ v8::Persistent<v8::FunctionTemplate> ${className}::GetTemplate() {
return ${className}_cache_;
}
-${toNativeReturnType}* ${className}::toNative(v8::Handle<v8::Object> object) {
- return reinterpret_cast<${toNativeReturnType}*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex));
+${nativeType}* ${className}::toNative(v8::Handle<v8::Object> object) {
+ return reinterpret_cast<${nativeType}*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex));
}
bool ${className}::HasInstance(v8::Handle<v8::Value> value) {
@@ -1928,6 +1931,8 @@ v8::Persistent<v8::ObjectTemplate> V8DOMWindow::GetShadowObjectTemplate() {
}
END
}
+
+ GenerateToV8Converters($dataNode, $interfaceName, $className, $nativeType);
push(@implContent, <<END);
} // namespace WebCore
@@ -1936,7 +1941,194 @@ END
push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString;
}
-sub GetReturnTypeForToNative
+sub GenerateToV8Converters
+{
+ my $dataNode = shift;
+ my $interfaceName = shift;
+ my $className = shift;
+ my $nativeType = shift;
+
+ my $wrapperType = "V8ClassIndex::" . uc($interfaceName);
+ my $domMapFunction = GetDomMapFunction($dataNode, $interfaceName);
+ my $forceNewObjectInput = IsDOMNodeType($interfaceName) ? ", bool forceNewObject" : "";
+ my $forceNewObjectCall = IsDOMNodeType($interfaceName) ? ", forceNewObject" : "";
+
+ push(@implContent, <<END);
+
+v8::Handle<v8::Object> ${className}::wrap(${nativeType}* impl${forceNewObjectInput}) {
+ v8::Handle<v8::Object> wrapper;
+END
+ if (!NeedsWorkerContextExecutionProxyToV8($interfaceName)) {
+ push(@implContent, <<END);
+ V8Proxy* proxy = 0;
+END
+ }
+
+ if (IsNodeSubType($dataNode)) {
+ push(@implContent, <<END);
+ if (impl->document()) {
+ proxy = V8Proxy::retrieve(impl->document()->frame());
+ if (proxy && static_cast<Node*>(impl->document()) == static_cast<Node*>(impl))
+ proxy->windowShell()->initContextIfNeeded();
+ }
+
+END
+ }
+
+ if ($domMapFunction) {
+ push(@implContent, " if (!forceNewObject) {\n") if IsDOMNodeType($interfaceName);
+ if (IsNodeSubType($dataNode)) {
+ push(@implContent, " wrapper = V8DOMWrapper::getWrapper(impl);\n");
+ } else {
+ push(@implContent, " wrapper = ${domMapFunction}.get(impl);\n");
+ }
+ push(@implContent, <<END);
+ if (!wrapper.IsEmpty())
+ return wrapper;
+END
+ push(@implContent, " }\n") if IsDOMNodeType($interfaceName);
+ }
+ if (IsNodeSubType($dataNode)) {
+ push(@implContent, <<END);
+
+ v8::Handle<v8::Context> context;
+ if (proxy)
+ context = proxy->context();
+
+ // Enter the node's context and create the wrapper in that context.
+ if (!context.IsEmpty())
+ context->Enter();
+END
+ }
+
+ if (NeedsWorkerContextExecutionProxyToV8($interfaceName)) {
+ $implIncludes{"WorkerContextExecutionProxy.h"} = 1;
+ push(@implContent, <<END);
+ wrapper = WorkerContextExecutionProxy::toV8(${wrapperType}, impl);
+END
+ } else {
+ push(@implContent, <<END);
+ wrapper = V8DOMWrapper::instantiateV8Object(proxy, ${wrapperType}, impl);
+END
+ }
+
+ if (IsNodeSubType($dataNode)) {
+ push(@implContent, <<END);
+ // Exit the node's context if it was entered.
+ if (!context.IsEmpty())
+ context->Exit();
+END
+ }
+
+ push(@implContent, <<END);
+ if (wrapper.IsEmpty())
+ return wrapper;
+END
+ push(@implContent, "\n impl->ref();\n") if IsRefPtrType($interfaceName);
+
+ if ($domMapFunction) {
+ push(@implContent, <<END);
+ ${domMapFunction}.set(impl, v8::Persistent<v8::Object>::New(wrapper));
+END
+ }
+
+ push(@implContent, <<END);
+ return wrapper;
+}
+END
+
+ if (IsRefPtrType($interfaceName)) {
+ push(@implContent, <<END);
+
+v8::Handle<v8::Value> toV8(PassRefPtr<${nativeType} > impl${forceNewObjectInput}) {
+ return toV8(impl.get()${forceNewObjectCall});
+}
+END
+ }
+
+ if (!HasCustomToV8Implementation($dataNode, $interfaceName)) {
+ push(@implContent, <<END);
+
+v8::Handle<v8::Value> toV8(${nativeType}* impl${forceNewObjectInput}) {
+ if (!impl)
+ return v8::Null();
+ return ${className}::wrap(impl${forceNewObjectCall});
+}
+END
+ }
+}
+
+sub NeedsWorkerContextExecutionProxyToV8 {
+ # These objects can be constructed under WorkerContextExecutionProxy. They need special
+ # handling, since if we call V8Proxy::retrieve(), we will crash.
+ # FIXME: websocket?
+ $interfaceName = shift;
+ return 1 if $interfaceName eq "DOMCoreException";
+ return 1 if $interfaceName eq "EventException";
+ return 1 if $interfaceName eq "RangeException";
+ return 1 if $interfaceName eq "XMLHttpRequestException";
+ return 1 if $interfaceName eq "MessagePort";
+ return 0;
+}
+
+sub HasCustomToV8Implementation {
+ # FIXME: This subroutine is lame. Probably should be an .idl attribute (CustomToV8)?
+ $dataNode = shift;
+ $interfaceName = shift;
+
+ # We generate a custom converter (but JSC doesn't) for the following:
+ return 1 if $interfaceName eq "BarInfo";
+ return 1 if $interfaceName eq "CSSStyleSheet";
+ return 1 if $interfaceName eq "CanvasPixelArray";
+ return 1 if $interfaceName eq "DOMSelection";
+ return 1 if $interfaceName eq "DOMWindow";
+ return 1 if $interfaceName eq "Element";
+ return 1 if $interfaceName eq "Location";
+ return 1 if $interfaceName eq "HTMLDocument";
+ return 1 if $interfaceName eq "HTMLElement";
+ return 1 if $interfaceName eq "History";
+ return 1 if $interfaceName eq "NamedNodeMap";
+ return 1 if $interfaceName eq "Navigator";
+ return 1 if $interfaceName eq "SVGDocument";
+ return 1 if $interfaceName eq "SVGElement";
+ return 1 if $interfaceName eq "Screen";
+
+ # We don't generate a custom converter (but JSC does) for the following:
+ return 0 if $interfaceName eq "AbstractWorker";
+ return 0 if $interfaceName eq "CanvasRenderingContext";
+ return 0 if $interfaceName eq "ImageData";
+ return 0 if $interfaceName eq "SVGElementInstance";
+
+ # For everything else, do what JSC does.
+ return $dataNode->extendedAttributes->{"CustomToJS"};
+}
+
+sub GetDomMapFunction
+{
+ my $dataNode = shift;
+ my $type = shift;
+ return "getDOMSVGElementInstanceMap()" if $type eq "SVGElementInstance";
+ return "getDOMNodeMap()" if IsNodeSubType($dataNode);
+ # Only use getDOMSVGObjectWithContextMap() for non-node svg objects
+ return "getDOMSVGObjectWithContextMap()" if $type =~ /SVG/;
+ return "" if $type eq "DOMImplementation";
+ return "getActiveDOMObjectMap()" if IsActiveDomType($type);
+ return "getDOMObjectMap()";
+}
+
+sub IsActiveDomType
+{
+ # FIXME: Consider making this an .idl attribute.
+ my $type = shift;
+ return 1 if $type eq "MessagePort";
+ return 1 if $type eq "XMLHttpRequest";
+ return 1 if $type eq "WebSocket";
+ return 1 if $type eq "Worker";
+ return 1 if $type eq "SharedWorker";
+ return 0;
+}
+
+sub GetNativeTypeForConversions
{
my $type = shift;
return "FloatRect" if $type eq "SVGRect";
@@ -1991,7 +2183,6 @@ sub GenerateFunctionCallString()
my $first = 1;
my $index = 0;
- my $nodeToReturn = 0;
foreach my $parameter (@{$function->parameters}) {
if ($index eq $numberOfParameters) {
@@ -2013,10 +2204,6 @@ sub GenerateFunctionCallString()
} else {
$functionString .= $paramName;
}
-
- if ($parameter->extendedAttributes->{"Return"}) {
- $nodeToReturn = $parameter->name;
- }
$index++;
}
@@ -2026,6 +2213,14 @@ sub GenerateFunctionCallString()
if ($first) { $first = 0; }
}
+ if ($function->signature->extendedAttributes->{"NeedsUserGestureCheck"}) {
+ $functionString .= ", " if not $first;
+ # FIXME: We need to pass DOMWrapperWorld as a parameter.
+ # See http://trac.webkit.org/changeset/54182
+ $functionString .= "processingUserGesture()";
+ if ($first) { $first = 0; }
+ }
+
if (@{$function->raisesExceptions}) {
$functionString .= ", " if not $first;
$functionString .= "ec";
@@ -2035,19 +2230,7 @@ sub GenerateFunctionCallString()
my $return = "result";
my $returnIsRef = IsRefPtrType($returnType);
- if ($nodeToReturn) {
- # Special case for insertBefore, replaceChild, removeChild and
- # appendChild functions from Node.
- $result .= $indent . "bool success = $functionString;\n";
- if (@{$function->raisesExceptions}) {
- $result .= $indent . "if (UNLIKELY(ec)) goto fail;\n";
- }
- $result .= $indent . "if (success)\n";
- $result .= $indent . " " .
- "return V8DOMWrapper::convertNodeToV8Object($nodeToReturn);\n";
- $result .= $indent . "return v8::Null();\n";
- return $result;
- } elsif ($returnType eq "void") {
+ if ($returnType eq "void") {
$result .= $indent . "$functionString;\n";
} elsif ($copyFirst) {
$result .=
@@ -2106,8 +2289,8 @@ sub GenerateFunctionCallString()
}
if ($returnsPodType) {
- my $classIndex = uc($returnType);
- $result .= $indent . "return V8DOMWrapper::convertToV8Object(V8ClassIndex::$classIndex, wrapper.release());\n";
+ $implIncludes{"V8${returnType}.h"} = 1;
+ $result .= $indent . "return toV8(wrapper.release());\n";
} else {
$return .= ".release()" if ($returnIsRef);
$result .= $indent . ReturnNativeToJSValue($function->signature, $return, $indent) . ";\n";
@@ -2167,6 +2350,7 @@ sub IsRefPtrType
return 0 if $type eq "unsigned";
return 0 if $type eq "unsigned long";
return 0 if $type eq "unsigned short";
+ return 0 if $type eq "SVGAnimatedPoints";
return 1;
}
@@ -2207,7 +2391,7 @@ sub GetNativeType
return "SVGTransform" if $type eq "SVGTransform";
return "SVGLength" if $type eq "SVGLength";
return "SVGAngle" if $type eq "SVGAngle";
- return "double" if $type eq "SVGNumber";
+ return "float" if $type eq "SVGNumber";
return "SVGPreserveAspectRatio" if $type eq "SVGPreserveAspectRatio";
return "SVGPaint::SVGPaintType" if $type eq "SVGPaintType";
return "DOMTimeStamp" if $type eq "DOMTimeStamp";
@@ -2423,7 +2607,11 @@ sub JSValueToNative
sub GetV8HeaderName
{
my $type = shift;
- return "V8" . GetImplementationFileName($type);
+ return "V8Event.h" if $type eq "DOMTimeStamp";
+ return "EventListener.h" if $type eq "EventListener";
+ return "EventTarget.h" if $type eq "EventTarget";
+ return "SerializedScriptValue.h" if $type eq "SerializedScriptValue";
+ return "V8${type}.h";
}
@@ -2548,7 +2736,6 @@ sub ReturnNativeToJSValue
my $value = shift;
my $indent = shift;
my $type = GetTypeFromSignature($signature);
- my $className= "V8$type";
return "return v8::Date::New(static_cast<double>($value))" if $type eq "DOMTimeStamp";
return "return v8Boolean($value)" if $type eq "boolean";
@@ -2575,29 +2762,20 @@ sub ReturnNativeToJSValue
return "return v8String($value)";
}
- # V8 specific.
- my $implClassName = $type;
AddIncludesForType($type);
# special case for non-DOM node interfaces
if (IsDOMNodeType($type)) {
- if ($signature->extendedAttributes->{"ReturnsNew"}) {
- return "return V8DOMWrapper::convertNewNodeToV8Object($value)";
- } else {
- return "return V8DOMWrapper::convertNodeToV8Object($value)";
- }
+ return "return toV8(${value}" . ($signature->extendedAttributes->{"ReturnsNew"} ? ", true)" : ")");
}
- if ($type eq "EventTarget" or $type eq "SVGElementInstance") {
+ if ($type eq "EventTarget") {
return "return V8DOMWrapper::convertEventTargetToV8Object($value)";
}
- if ($type eq "Event") {
- return "return V8DOMWrapper::convertEventToV8Object($value)";
- }
-
if ($type eq "EventListener") {
- return "return V8DOMWrapper::convertEventListenerToV8Object(imp->scriptExecutionContext(), $value)";
+ $implIncludes{"V8AbstractEventListener.h"} = 1;
+ return "return ${value} ? v8::Handle<v8::Value>(static_cast<V8AbstractEventListener*>(${value})->getListenerObject(imp->scriptExecutionContext())) : v8::Handle<v8::Value>(v8::Null())";
}
if ($type eq "SerializedScriptValue") {
@@ -2617,18 +2795,15 @@ sub ReturnNativeToJSValue
return "return WorkerContextExecutionProxy::convertToV8Object(V8ClassIndex::$classIndex, $value)";
}
- else {
- $implIncludes{"wtf/RefCounted.h"} = 1;
- $implIncludes{"wtf/RefPtr.h"} = 1;
- $implIncludes{"wtf/GetPtr.h"} = 1;
- my $classIndex = uc($type);
+ $implIncludes{"wtf/RefCounted.h"} = 1;
+ $implIncludes{"wtf/RefPtr.h"} = 1;
+ $implIncludes{"wtf/GetPtr.h"} = 1;
- if (IsPodType($type)) {
- $value = GenerateSVGStaticPodTypeWrapper($type, $value);
- }
-
- return "return V8DOMWrapper::convertToV8Object(V8ClassIndex::$classIndex, $value)";
+ if (IsPodType($type)) {
+ $value = GenerateSVGStaticPodTypeWrapper($type, $value) . ".get()";
}
+
+ return "return toV8($value)";
}
sub GenerateSVGStaticPodTypeWrapper {
diff --git a/WebCore/bindings/v8/ScriptController.cpp b/WebCore/bindings/v8/ScriptController.cpp
index 8db55a1..e2b886d 100644
--- a/WebCore/bindings/v8/ScriptController.cpp
+++ b/WebCore/bindings/v8/ScriptController.cpp
@@ -50,7 +50,9 @@
#include "Settings.h"
#include "V8Binding.h"
#include "V8BindingState.h"
+#include "V8DOMWindow.h"
#include "V8Event.h"
+#include "V8HTMLEmbedElement.h"
#include "V8IsolatedContext.h"
#include "V8NPObject.h"
#include "V8Proxy.h"
@@ -148,7 +150,7 @@ void ScriptController::updatePlatformScriptObjects()
notImplemented();
}
-bool ScriptController::processingUserGesture() const
+bool ScriptController::processingUserGesture(DOMWrapperWorld*) const
{
Frame* activeFrame = V8Proxy::retrieveFrameForEnteredContext();
// No script is running, so it must be run by users.
@@ -169,7 +171,7 @@ bool ScriptController::processingUserGesture() const
v8::Handle<v8::Object> global = v8Context->Global();
v8::Handle<v8::Value> jsEvent = global->Get(v8::String::NewSymbol("event"));
- Event* event = V8DOMWrapper::isDOMEventWrapper(jsEvent) ? V8Event::toNative(v8::Handle<v8::Object>::Cast(jsEvent)) : 0;
+ Event* event = (!jsEvent.IsEmpty() && jsEvent->IsObject()) ? V8Event::toNative(v8::Handle<v8::Object>::Cast(jsEvent)) : 0;
// Based on code from kjs_bindings.cpp.
// Note: This is more liberal than Firefox's implementation.
@@ -353,6 +355,15 @@ void ScriptController::getAllWorlds(Vector<DOMWrapperWorld*>& worlds)
worlds.append(mainThreadNormalWorld());
}
+void ScriptController::evaluateInWorld(const ScriptSourceCode& source,
+ DOMWrapperWorld* world)
+{
+ Vector<ScriptSourceCode> sources;
+ sources.append(source);
+ // FIXME: Get an ID from the world param.
+ evaluateInIsolatedWorld(0, sources);
+}
+
static NPObject* createNoScriptObject()
{
notImplemented();
@@ -368,7 +379,7 @@ static NPObject* createScriptObject(Frame* frame)
v8::Context::Scope scope(v8Context);
DOMWindow* window = frame->domWindow();
- v8::Handle<v8::Value> global = V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, window);
+ v8::Handle<v8::Value> global = toV8(window);
ASSERT(global->IsObject());
return npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(global), window);
}
@@ -405,7 +416,7 @@ NPObject* ScriptController::createScriptObjectForPluginElement(HTMLPlugInElement
v8::Context::Scope scope(v8Context);
DOMWindow* window = m_frame->domWindow();
- v8::Handle<v8::Value> v8plugin = V8DOMWrapper::convertToV8Object(V8ClassIndex::HTMLEMBEDELEMENT, plugin);
+ v8::Handle<v8::Value> v8plugin = toV8(static_cast<HTMLEmbedElement*>(plugin));
if (!v8plugin->IsObject())
return createNoScriptObject();
diff --git a/WebCore/bindings/v8/ScriptController.h b/WebCore/bindings/v8/ScriptController.h
index b45bdef..b3995b2 100644
--- a/WebCore/bindings/v8/ScriptController.h
+++ b/WebCore/bindings/v8/ScriptController.h
@@ -143,7 +143,9 @@ public:
void setEventHandlerLineNumber(int lineNumber);
void setProcessingTimerCallback(bool processingTimerCallback) { m_processingTimerCallback = processingTimerCallback; }
- bool processingUserGesture() const;
+ // FIXME: Currently we don't use the parameter world at all.
+ // See http://trac.webkit.org/changeset/54182
+ bool processingUserGesture(DOMWrapperWorld* world = 0) const;
bool anyPageIsProcessingUserGesture() const;
void setPaused(bool paused) { m_paused = paused; }
@@ -165,7 +167,7 @@ public:
#endif
// Dummy method to avoid a bunch of ifdef's in WebCore.
- void evaluateInWorld(const ScriptSourceCode&, DOMWrapperWorld*) { }
+ void evaluateInWorld(const ScriptSourceCode&, DOMWrapperWorld*);
static void getAllWorlds(Vector<DOMWrapperWorld*>& worlds);
private:
diff --git a/WebCore/bindings/v8/ScriptObject.cpp b/WebCore/bindings/v8/ScriptObject.cpp
index 8d80d34..0fcd16f 100644
--- a/WebCore/bindings/v8/ScriptObject.cpp
+++ b/WebCore/bindings/v8/ScriptObject.cpp
@@ -36,9 +36,10 @@
#include "Document.h"
#include "Frame.h"
-#include "InspectorBackend.h"
-#include "InspectorFrontendHost.h"
#include "V8Binding.h"
+#include "V8InjectedScriptHost.h"
+#include "V8InspectorBackend.h"
+#include "V8InspectorFrontendHost.h"
#include "V8Proxy.h"
#include <v8.h>
@@ -144,21 +145,21 @@ bool ScriptGlobalObject::set(ScriptState* scriptState, const char* name, const S
bool ScriptGlobalObject::set(ScriptState* scriptState, const char* name, InspectorBackend* value)
{
ScriptScope scope(scriptState);
- scope.global()->Set(v8::String::New(name), V8DOMWrapper::convertToV8Object(V8ClassIndex::INSPECTORBACKEND, value));
+ scope.global()->Set(v8::String::New(name), toV8(value));
return scope.success();
}
bool ScriptGlobalObject::set(ScriptState* scriptState, const char* name, InspectorFrontendHost* value)
{
ScriptScope scope(scriptState);
- scope.global()->Set(v8::String::New(name), V8DOMWrapper::convertToV8Object(V8ClassIndex::INSPECTORFRONTENDHOST, value));
+ scope.global()->Set(v8::String::New(name), toV8(value));
return scope.success();
}
bool ScriptGlobalObject::set(ScriptState* scriptState, const char* name, InjectedScriptHost* value)
{
ScriptScope scope(scriptState);
- scope.global()->Set(v8::String::New(name), V8DOMWrapper::convertToV8Object(V8ClassIndex::INJECTEDSCRIPTHOST, value));
+ scope.global()->Set(v8::String::New(name), toV8(value));
return scope.success();
}
#endif
diff --git a/WebCore/bindings/v8/ScriptProfile.h b/WebCore/bindings/v8/ScriptProfile.h
new file mode 100644
index 0000000..1a4d677
--- /dev/null
+++ b/WebCore/bindings/v8/ScriptProfile.h
@@ -0,0 +1,62 @@
+/*
+ * 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 ScriptProfile_h
+#define ScriptProfile_h
+
+#include "PlatformString.h"
+
+namespace WebCore {
+
+class ScriptProfile : public RefCounted<ScriptProfile> {
+public:
+ static PassRefPtr<ScriptProfile> create(const String& title, unsigned uid)
+ {
+ return adoptRef(new ScriptProfile(title, uid));
+ }
+ virtual ~ScriptProfile() {}
+
+ String title() const { return m_title; }
+ unsigned int uid() const { return m_uid; }
+
+protected:
+ ScriptProfile(const String& title, unsigned uid)
+ : m_title(title)
+ , m_uid(uid)
+ {}
+
+private:
+ String m_title;
+ unsigned int m_uid;
+};
+
+} // namespace WebCore
+
+#endif // ScriptProfile_h
diff --git a/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp b/WebCore/bindings/v8/ScriptProfiler.cpp
index 0dbdcd7..f238f6f 100644
--- a/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp
+++ b/WebCore/bindings/v8/ScriptProfiler.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 Google Inc. All rights reserved.
+ * 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
@@ -29,29 +29,22 @@
*/
#include "config.h"
-#include "V8Console.h"
-#include "V8Binding.h"
-#include "V8CustomBinding.h"
-#include "V8Proxy.h"
-#include <v8.h>
+#include "ScriptProfiler.h"
namespace WebCore {
-v8::Handle<v8::Value> V8Console::profileCallback(const v8::Arguments& args)
+void ScriptProfiler::start(ScriptState* state, const String& title)
{
- INC_STATS("console.profile()");
v8::HandleScope scope;
- v8::Context::Scope context_scope(v8::Context::GetCurrent());
+ v8::Context::Scope contextScope(v8::Context::GetCurrent());
v8::V8::ResumeProfiler();
- return v8::Undefined();
}
-v8::Handle<v8::Value> V8Console::profileEndCallback(const v8::Arguments& args)
+PassRefPtr<ScriptProfile> ScriptProfiler::stop(ScriptState* state, const String& title)
{
- INC_STATS("console.profileEnd()");
v8::V8::PauseProfiler();
- return v8::Undefined();
+ return 0;
}
} // namespace WebCore
diff --git a/WebCore/bindings/v8/ScriptProfiler.h b/WebCore/bindings/v8/ScriptProfiler.h
new file mode 100644
index 0000000..c02cc32
--- /dev/null
+++ b/WebCore/bindings/v8/ScriptProfiler.h
@@ -0,0 +1,50 @@
+/*
+ * 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 ScriptProfiler_h
+#define ScriptProfiler_h
+
+#include "PlatformString.h"
+#include "ScriptProfile.h"
+#include "ScriptState.h"
+
+#include <wtf/Noncopyable.h>
+
+namespace WebCore {
+
+class ScriptProfiler : public Noncopyable {
+public:
+ static void start(ScriptState* state, const String& title);
+ static PassRefPtr<ScriptProfile> stop(ScriptState* state, const String& title);
+};
+
+} // namespace WebCore
+
+#endif // ScriptProfiler_h
diff --git a/WebCore/bindings/v8/V8AbstractEventListener.cpp b/WebCore/bindings/v8/V8AbstractEventListener.cpp
index 0f5b5c8..944fd57 100644
--- a/WebCore/bindings/v8/V8AbstractEventListener.cpp
+++ b/WebCore/bindings/v8/V8AbstractEventListener.cpp
@@ -36,6 +36,7 @@
#include "Event.h"
#include "Frame.h"
#include "V8Binding.h"
+#include "V8Event.h"
#include "V8EventListenerList.h"
#include "V8Proxy.h"
#include "V8Utilities.h"
@@ -84,7 +85,7 @@ void V8AbstractEventListener::handleEvent(ScriptExecutionContext* context, Event
v8::Context::Scope scope(v8Context);
// Get the V8 wrapper for the event object.
- v8::Handle<v8::Value> jsEvent = V8DOMWrapper::convertEventToV8Object(event);
+ v8::Handle<v8::Value> jsEvent = toV8(event);
invokeEventHandler(context, event, jsEvent);
diff --git a/WebCore/bindings/v8/V8Collection.h b/WebCore/bindings/v8/V8Collection.h
index 84150d8..9611571 100644
--- a/WebCore/bindings/v8/V8Collection.h
+++ b/WebCore/bindings/v8/V8Collection.h
@@ -38,155 +38,149 @@
#include <v8.h>
namespace WebCore {
- // FIXME: These functions should be named using to* since they return the item (get* is used for method that take a ref param).
- // See https://bugs.webkit.org/show_bug.cgi?id=24664.
-
- inline v8::Handle<v8::Value> getV8Object(void* implementation, v8::Local<v8::Value> implementationType)
- {
- if (!implementation)
- return v8::Handle<v8::Value>();
- V8ClassIndex::V8WrapperType type = V8ClassIndex::FromInt(implementationType->Int32Value());
- if (type == V8ClassIndex::NODE)
- return V8DOMWrapper::convertNodeToV8Object(static_cast<Node*>(implementation));
- return V8DOMWrapper::convertToV8Object(type, implementation);
+// FIXME: These functions should be named using to* since they return the item (get* is used for method that take a ref param).
+// See https://bugs.webkit.org/show_bug.cgi?id=24664.
+
+template<class T> static v8::Handle<v8::Value> getV8Object(T* implementation)
+{
+ if (!implementation)
+ return v8::Handle<v8::Value>();
+ return toV8(implementation);
+}
+
+template<class Collection> static Collection* toNativeCollection(v8::Local<v8::Object> object)
+{
+ return reinterpret_cast<Collection*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex));
+}
+
+template<class T> static v8::Handle<v8::Value> getV8Object(PassRefPtr<T> implementation)
+{
+ return getV8Object(implementation.get());
+}
+
+// Returns named property of a collection.
+template<class Collection, class ItemType> static v8::Handle<v8::Value> getNamedPropertyOfCollection(v8::Local<v8::String> name, v8::Local<v8::Object> object)
+{
+ // FIXME: assert object is a collection type
+ ASSERT(V8DOMWrapper::maybeDOMWrapper(object));
+ ASSERT(V8DOMWrapper::domWrapperType(object) != V8ClassIndex::NODE);
+ Collection* collection = toNativeCollection<Collection>(object);
+ AtomicString propertyName = toAtomicWebCoreStringWithNullCheck(name);
+ return getV8Object<ItemType>(collection->namedItem(propertyName));
+}
+
+// A template of named property accessor of collections.
+template<class Collection, class ItemType> static v8::Handle<v8::Value> collectionNamedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+{
+ v8::Handle<v8::Value> value = info.Holder()->GetRealNamedPropertyInPrototypeChain(name);
+
+ if (!value.IsEmpty())
+ return value;
+
+ // Search local callback properties next to find IDL defined
+ // properties.
+ if (info.Holder()->HasRealNamedCallbackProperty(name))
+ return notHandledByInterceptor();
+ return getNamedPropertyOfCollection<Collection, ItemType>(name, info.Holder());
+}
+
+// Returns the property at the index of a collection.
+template<class Collection, class ItemType> static v8::Handle<v8::Value> getIndexedPropertyOfCollection(uint32_t index, v8::Local<v8::Object> object)
+{
+ // FIXME: Assert that object must be a collection type.
+ ASSERT(V8DOMWrapper::maybeDOMWrapper(object));
+ ASSERT(V8DOMWrapper::domWrapperType(object) != V8ClassIndex::NODE);
+ Collection* collection = toNativeCollection<Collection>(object);
+ return getV8Object<ItemType>(collection->item(index));
+}
+
+// A template of index interceptor of collections.
+template<class Collection, class ItemType> static v8::Handle<v8::Value> collectionIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
+{
+ return getIndexedPropertyOfCollection<Collection, ItemType>(index, info.Holder());
+}
+
+// Get an array containing the names of indexed properties of HTMLSelectElement and HTMLFormElement.
+template<class Collection> static v8::Handle<v8::Array> nodeCollectionIndexedPropertyEnumerator(const v8::AccessorInfo& info)
+{
+ ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
+ Collection* collection = toNativeCollection<Collection>(info.Holder());
+ int length = collection->length();
+ v8::Handle<v8::Array> properties = v8::Array::New(length);
+ for (int i = 0; i < length; ++i) {
+ // FIXME: Do we need to check that the item function returns a non-null value for this index?
+ v8::Handle<v8::Integer> integer = v8::Integer::New(i);
+ properties->Set(integer, integer);
}
-
- template<class Collection> static Collection* toNativeCollection(v8::Local<v8::Object> object)
- {
- return reinterpret_cast<Collection*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex));
- }
-
- template<class T> static v8::Handle<v8::Value> getV8Object(PassRefPtr<T> implementation, v8::Local<v8::Value> implementationType)
- {
- return getV8Object(implementation.get(), implementationType);
- }
-
- // Returns named property of a collection.
- template<class Collection, class ItemType> static v8::Handle<v8::Value> getNamedPropertyOfCollection(v8::Local<v8::String> name, v8::Local<v8::Object> object,
- v8::Local<v8::Value> implementationType)
- {
- // FIXME: assert object is a collection type
- ASSERT(V8DOMWrapper::maybeDOMWrapper(object));
- ASSERT(V8DOMWrapper::domWrapperType(object) != V8ClassIndex::NODE);
- Collection* collection = toNativeCollection<Collection>(object);
- AtomicString propertyName = toAtomicWebCoreStringWithNullCheck(name);
- return getV8Object<ItemType>(collection->namedItem(propertyName), implementationType);
- }
-
- // A template of named property accessor of collections.
- template<class Collection, class ItemType> static v8::Handle<v8::Value> collectionNamedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
- {
- v8::Handle<v8::Value> value = info.Holder()->GetRealNamedPropertyInPrototypeChain(name);
-
- if (!value.IsEmpty())
- return value;
-
- // Search local callback properties next to find IDL defined
- // properties.
- if (info.Holder()->HasRealNamedCallbackProperty(name))
- return notHandledByInterceptor();
- return getNamedPropertyOfCollection<Collection, ItemType>(name, info.Holder(), info.Data());
+ return properties;
+}
+
+// Get an array containing the names of indexed properties in a collection.
+template<class Collection> static v8::Handle<v8::Array> collectionIndexedPropertyEnumerator(const v8::AccessorInfo& info)
+{
+ ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
+ Collection* collection = toNativeCollection<Collection>(info.Holder());
+ int length = collection->length();
+ v8::Handle<v8::Array> properties = v8::Array::New(length);
+ for (int i = 0; i < length; ++i) {
+ // FIXME: Do we need to check that the item function returns a non-null value for this index?
+ v8::Handle<v8::Integer> integer = v8::Integer::New(i);
+ properties->Set(integer, integer);
}
-
- // Returns the property at the index of a collection.
- template<class Collection, class ItemType> static v8::Handle<v8::Value> getIndexedPropertyOfCollection(uint32_t index, v8::Local<v8::Object> object,
- v8::Local<v8::Value> implementationType)
- {
- // FIXME: Assert that object must be a collection type.
- ASSERT(V8DOMWrapper::maybeDOMWrapper(object));
- ASSERT(V8DOMWrapper::domWrapperType(object) != V8ClassIndex::NODE);
- Collection* collection = toNativeCollection<Collection>(object);
- return getV8Object<ItemType>(collection->item(index), implementationType);
- }
-
- // A template of index interceptor of collections.
- template<class Collection, class ItemType> static v8::Handle<v8::Value> collectionIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
- {
- return getIndexedPropertyOfCollection<Collection, ItemType>(index, info.Holder(), info.Data());
- }
-
- // Get an array containing the names of indexed properties of HTMLSelectElement and HTMLFormElement.
- template<class Collection> static v8::Handle<v8::Array> nodeCollectionIndexedPropertyEnumerator(const v8::AccessorInfo& info)
- {
- ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
- ASSERT(V8DOMWrapper::domWrapperType(info.Holder()) == V8ClassIndex::NODE);
- Collection* collection = toNativeCollection<Collection>(info.Holder());
- int length = collection->length();
- v8::Handle<v8::Array> properties = v8::Array::New(length);
- for (int i = 0; i < length; ++i) {
- // FIXME: Do we need to check that the item function returns a non-null value for this index?
- v8::Handle<v8::Integer> integer = v8::Integer::New(i);
- properties->Set(integer, integer);
- }
- return properties;
- }
-
- // Get an array containing the names of indexed properties in a collection.
- template<class Collection> static v8::Handle<v8::Array> collectionIndexedPropertyEnumerator(const v8::AccessorInfo& info)
- {
- ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
- Collection* collection = toNativeCollection<Collection>(info.Holder());
- int length = collection->length();
- v8::Handle<v8::Array> properties = v8::Array::New(length);
- for (int i = 0; i < length; ++i) {
- // FIXME: Do we need to check that the item function returns a non-null value for this index?
- v8::Handle<v8::Integer> integer = v8::Integer::New(i);
- properties->Set(integer, integer);
- }
- return properties;
- }
-
-
- // A template for indexed getters on collections of strings that should return null if the resulting string is a null string.
- template<class Collection> static v8::Handle<v8::Value> collectionStringOrNullIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
- {
- // FIXME: assert that object must be a collection type
- ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
- Collection* collection = toNativeCollection<Collection>(info.Holder());
- String result = collection->item(index);
- return v8StringOrNull(result);
- }
-
-
- // A template for indexed getters on collections of strings.
- template<class Collection> static v8::Handle<v8::Value> collectionStringIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
- {
- // FIXME: assert that object must be a collection type
- ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
- Collection* collection = toNativeCollection<Collection>(info.Holder());
- String result = collection->item(index);
- return v8String(result);
- }
-
-
- // Add indexed getter to the function template for a collection.
- template<class Collection, class ItemType> static void setCollectionIndexedGetter(v8::Handle<v8::FunctionTemplate> desc, V8ClassIndex::V8WrapperType type)
- {
- desc->InstanceTemplate()->SetIndexedPropertyHandler(collectionIndexedPropertyGetter<Collection, ItemType>, 0, 0, 0, collectionIndexedPropertyEnumerator<Collection>,
- v8::Integer::New(V8ClassIndex::ToInt(type)));
- }
-
-
- // Add named getter to the function template for a collection.
- template<class Collection, class ItemType> static void setCollectionNamedGetter(v8::Handle<v8::FunctionTemplate> desc, V8ClassIndex::V8WrapperType type)
- {
- desc->InstanceTemplate()->SetNamedPropertyHandler(collectionNamedPropertyGetter<Collection, ItemType>, 0, 0, 0, 0, v8::Integer::New(V8ClassIndex::ToInt(type)));
- }
-
- // Add indexed getter returning a string or null to a function template for a collection.
- template<class Collection> static void setCollectionStringOrNullIndexedGetter(v8::Handle<v8::FunctionTemplate> desc)
- {
- desc->InstanceTemplate()->SetIndexedPropertyHandler(collectionStringOrNullIndexedPropertyGetter<Collection>, 0, 0, 0, collectionIndexedPropertyEnumerator<Collection>);
- }
-
-
- // Add indexed getter returning a string to a function template for a collection.
- template<class Collection> static void setCollectionStringIndexedGetter(v8::Handle<v8::FunctionTemplate> desc)
- {
- desc->InstanceTemplate()->SetIndexedPropertyHandler(collectionStringIndexedPropertyGetter<Collection>, 0, 0, 0, collectionIndexedPropertyEnumerator<Collection>);
- }
-
- v8::Handle<v8::Value> toOptionsCollectionSetter(uint32_t index, v8::Handle<v8::Value>, HTMLSelectElement*);
+ return properties;
+}
+
+
+// A template for indexed getters on collections of strings that should return null if the resulting string is a null string.
+template<class Collection> static v8::Handle<v8::Value> collectionStringOrNullIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
+{
+ // FIXME: assert that object must be a collection type
+ ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
+ Collection* collection = toNativeCollection<Collection>(info.Holder());
+ String result = collection->item(index);
+ return v8StringOrNull(result);
+}
+
+
+// A template for indexed getters on collections of strings.
+template<class Collection> static v8::Handle<v8::Value> collectionStringIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
+{
+ // FIXME: assert that object must be a collection type
+ ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
+ Collection* collection = toNativeCollection<Collection>(info.Holder());
+ String result = collection->item(index);
+ return v8String(result);
+}
+
+
+// Add indexed getter to the function template for a collection.
+template<class Collection, class ItemType> static void setCollectionIndexedGetter(v8::Handle<v8::FunctionTemplate> desc, V8ClassIndex::V8WrapperType type)
+{
+ desc->InstanceTemplate()->SetIndexedPropertyHandler(collectionIndexedPropertyGetter<Collection, ItemType>, 0, 0, 0, collectionIndexedPropertyEnumerator<Collection>,
+ v8::Integer::New(V8ClassIndex::ToInt(type)));
+}
+
+
+// Add named getter to the function template for a collection.
+template<class Collection, class ItemType> static void setCollectionNamedGetter(v8::Handle<v8::FunctionTemplate> desc, V8ClassIndex::V8WrapperType type)
+{
+ desc->InstanceTemplate()->SetNamedPropertyHandler(collectionNamedPropertyGetter<Collection, ItemType>, 0, 0, 0, 0, v8::Integer::New(V8ClassIndex::ToInt(type)));
+}
+
+// Add indexed getter returning a string or null to a function template for a collection.
+template<class Collection> static void setCollectionStringOrNullIndexedGetter(v8::Handle<v8::FunctionTemplate> desc)
+{
+ desc->InstanceTemplate()->SetIndexedPropertyHandler(collectionStringOrNullIndexedPropertyGetter<Collection>, 0, 0, 0, collectionIndexedPropertyEnumerator<Collection>);
+}
+
+
+// Add indexed getter returning a string to a function template for a collection.
+template<class Collection> static void setCollectionStringIndexedGetter(v8::Handle<v8::FunctionTemplate> desc)
+{
+ desc->InstanceTemplate()->SetIndexedPropertyHandler(collectionStringIndexedPropertyGetter<Collection>, 0, 0, 0, collectionIndexedPropertyEnumerator<Collection>);
+}
+
+v8::Handle<v8::Value> toOptionsCollectionSetter(uint32_t index, v8::Handle<v8::Value>, HTMLSelectElement*);
} // namespace WebCore
diff --git a/WebCore/bindings/v8/V8DOMWindowShell.cpp b/WebCore/bindings/v8/V8DOMWindowShell.cpp
index 7e1452b..683fea5 100644
--- a/WebCore/bindings/v8/V8DOMWindowShell.cpp
+++ b/WebCore/bindings/v8/V8DOMWindowShell.cpp
@@ -48,9 +48,9 @@
#include "V8BindingState.h"
#include "V8Collection.h"
#include "V8ConsoleMessage.h"
-#include "V8CustomBinding.h"
#include "V8DOMMap.h"
#include "V8DOMWindow.h"
+#include "V8Document.h"
#include "V8HiddenPropertyName.h"
#include "V8History.h"
#include "V8Index.h"
@@ -430,7 +430,7 @@ void V8DOMWindowShell::updateDocumentWrapperCache()
return;
}
- v8::Handle<v8::Value> documentWrapper = V8DOMWrapper::convertNodeToV8Object(m_frame->document());
+ v8::Handle<v8::Value> documentWrapper = toV8(m_frame->document());
// If instantiation of the document wrapper fails, clear the cache
// and let the DOMWindow accessor handle access to the document.
diff --git a/WebCore/bindings/v8/V8DOMWrapper.cpp b/WebCore/bindings/v8/V8DOMWrapper.cpp
index a24742d..fd0edc5 100644
--- a/WebCore/bindings/v8/V8DOMWrapper.cpp
+++ b/WebCore/bindings/v8/V8DOMWrapper.cpp
@@ -43,8 +43,8 @@
#include "V8AbstractEventListener.h"
#include "V8Binding.h"
#include "V8Collection.h"
-#include "V8CustomBinding.h"
#include "V8CustomEventListener.h"
+#include "V8DOMApplicationCache.h"
#include "V8DOMMap.h"
#include "V8DOMWindow.h"
#include "V8EventListenerList.h"
@@ -52,12 +52,18 @@
#include "V8HTMLDocument.h"
#include "V8Index.h"
#include "V8IsolatedContext.h"
-#include "V8MessageChannel.h"
#include "V8Location.h"
+#include "V8MessageChannel.h"
#include "V8NamedNodeMap.h"
+#include "V8Node.h"
#include "V8NodeList.h"
+#include "V8Notification.h"
#include "V8Proxy.h"
+#include "V8SVGElementInstance.h"
+#include "V8SharedWorker.h"
#include "V8StyleSheet.h"
+#include "V8WebSocket.h"
+#include "V8Worker.h"
#include "WebGLArray.h"
#include "WebGLContextAttributes.h"
#include "WebGLUniformLocation.h"
@@ -77,93 +83,6 @@ namespace WebCore {
typedef HashMap<Node*, v8::Object*> DOMNodeMap;
typedef HashMap<void*, v8::Object*> DOMObjectMap;
-#if ENABLE(SVG)
-
-static V8ClassIndex::V8WrapperType downcastSVGPathSeg(void* pathSeg)
-{
- SVGPathSeg* realPathSeg = reinterpret_cast<SVGPathSeg*>(pathSeg);
-
- switch (realPathSeg->pathSegType()) {
- case SVGPathSeg::PATHSEG_CLOSEPATH: return V8ClassIndex::SVGPATHSEGCLOSEPATH;
- case SVGPathSeg::PATHSEG_MOVETO_ABS: return V8ClassIndex::SVGPATHSEGMOVETOABS;
- case SVGPathSeg::PATHSEG_MOVETO_REL: return V8ClassIndex::SVGPATHSEGMOVETOREL;
- case SVGPathSeg::PATHSEG_LINETO_ABS: return V8ClassIndex::SVGPATHSEGLINETOABS;
- case SVGPathSeg::PATHSEG_LINETO_REL: return V8ClassIndex::SVGPATHSEGLINETOREL;
- case SVGPathSeg::PATHSEG_CURVETO_CUBIC_ABS: return V8ClassIndex::SVGPATHSEGCURVETOCUBICABS;
- case SVGPathSeg::PATHSEG_CURVETO_CUBIC_REL: return V8ClassIndex::SVGPATHSEGCURVETOCUBICREL;
- case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_ABS: return V8ClassIndex::SVGPATHSEGCURVETOQUADRATICABS;
- case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_REL: return V8ClassIndex::SVGPATHSEGCURVETOQUADRATICREL;
- case SVGPathSeg::PATHSEG_ARC_ABS: return V8ClassIndex::SVGPATHSEGARCABS;
- case SVGPathSeg::PATHSEG_ARC_REL: return V8ClassIndex::SVGPATHSEGARCREL;
- case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_ABS: return V8ClassIndex::SVGPATHSEGLINETOHORIZONTALABS;
- case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_REL: return V8ClassIndex::SVGPATHSEGLINETOHORIZONTALREL;
- case SVGPathSeg::PATHSEG_LINETO_VERTICAL_ABS: return V8ClassIndex::SVGPATHSEGLINETOVERTICALABS;
- case SVGPathSeg::PATHSEG_LINETO_VERTICAL_REL: return V8ClassIndex::SVGPATHSEGLINETOVERTICALREL;
- case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: return V8ClassIndex::SVGPATHSEGCURVETOCUBICSMOOTHABS;
- case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_REL: return V8ClassIndex::SVGPATHSEGCURVETOCUBICSMOOTHREL;
- case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: return V8ClassIndex::SVGPATHSEGCURVETOQUADRATICSMOOTHABS;
- case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: return V8ClassIndex::SVGPATHSEGCURVETOQUADRATICSMOOTHREL;
- default: return V8ClassIndex::INVALID_CLASS_INDEX;
- }
-}
-
-v8::Handle<v8::Value> V8DOMWrapper::convertSVGElementInstanceToV8Object(SVGElementInstance* instance)
-{
- if (!instance)
- return v8::Null();
-
- v8::Handle<v8::Object> existingInstance = getDOMSVGElementInstanceMap().get(instance);
- if (!existingInstance.IsEmpty())
- return existingInstance;
-
- instance->ref();
-
- // Instantiate the V8 object and remember it
- v8::Handle<v8::Object> result = instantiateV8Object(V8ClassIndex::SVGELEMENTINSTANCE, V8ClassIndex::SVGELEMENTINSTANCE, instance);
- if (!result.IsEmpty()) {
- // Only update the DOM SVG element map if the result is non-empty.
- getDOMSVGElementInstanceMap().set(instance, v8::Persistent<v8::Object>::New(result));
- }
- return result;
-}
-
-v8::Handle<v8::Value> V8DOMWrapper::convertSVGObjectWithContextToV8Object(V8ClassIndex::V8WrapperType type, void* object)
-{
- if (!object)
- return v8::Null();
-
- v8::Persistent<v8::Object> result = getDOMSVGObjectWithContextMap().get(object);
- if (!result.IsEmpty())
- return result;
-
- // Special case: SVGPathSegs need to be downcast to their real type
- if (type == V8ClassIndex::SVGPATHSEG)
- type = downcastSVGPathSeg(object);
-
- v8::Local<v8::Object> v8Object = instantiateV8Object(type, type, object);
- if (!v8Object.IsEmpty()) {
- result = v8::Persistent<v8::Object>::New(v8Object);
- switch (type) {
-#define MAKE_CASE(TYPE, NAME) \
- case V8ClassIndex::TYPE: static_cast<NAME*>(object)->ref(); break;
- SVG_OBJECT_TYPES(MAKE_CASE)
-#undef MAKE_CASE
-#define MAKE_CASE(TYPE, NAME) \
- case V8ClassIndex::TYPE: \
- static_cast<V8SVGPODTypeWrapper<NAME>*>(object)->ref(); break;
- SVG_POD_NATIVE_TYPES(MAKE_CASE)
-#undef MAKE_CASE
- default:
- ASSERT_NOT_REACHED();
- }
- getDOMSVGObjectWithContextMap().set(object, result);
- }
-
- return result;
-}
-
-#endif // ENABLE(SVG)
-
#if ENABLE(3D_CANVAS)
void V8DOMWrapper::setIndexedPropertiesToExternalArray(v8::Handle<v8::Object> wrapper,
int index,
@@ -317,188 +236,6 @@ v8::Local<v8::Function> V8DOMWrapper::getConstructor(V8ClassIndex::V8WrapperType
return getConstructorForContext(type, context);
}
-v8::Handle<v8::Value> V8DOMWrapper::convertToV8Object(V8ClassIndex::V8WrapperType type, void* impl)
-{
- ASSERT(type != V8ClassIndex::EVENTLISTENER);
- ASSERT(type != V8ClassIndex::EVENTTARGET);
- ASSERT(type != V8ClassIndex::EVENT);
-
- // These objects can be constructed under WorkerContextExecutionProxy. They need special
- // handling, since if we proceed below V8Proxy::retrieve() will get called and will crash.
- // TODO(ukai): websocket?
- if ((type == V8ClassIndex::DOMCOREEXCEPTION
- || type == V8ClassIndex::RANGEEXCEPTION
- || type == V8ClassIndex::EVENTEXCEPTION
- || type == V8ClassIndex::XMLHTTPREQUESTEXCEPTION
- || type == V8ClassIndex::MESSAGEPORT)
- && WorkerContextExecutionProxy::retrieve()) {
- return WorkerContextExecutionProxy::convertToV8Object(type, impl);
- }
-
- bool isActiveDomObject = false;
- switch (type) {
-#define MAKE_CASE(TYPE, NAME) case V8ClassIndex::TYPE:
- DOM_NODE_TYPES(MAKE_CASE)
-#if ENABLE(SVG)
- SVG_NODE_TYPES(MAKE_CASE)
-#endif
- return convertNodeToV8Object(static_cast<Node*>(impl));
- case V8ClassIndex::CSSVALUE:
- return convertCSSValueToV8Object(static_cast<CSSValue*>(impl));
- case V8ClassIndex::CSSRULE:
- return convertCSSRuleToV8Object(static_cast<CSSRule*>(impl));
- case V8ClassIndex::STYLESHEET:
- return convertStyleSheetToV8Object(static_cast<StyleSheet*>(impl));
- case V8ClassIndex::DOMWINDOW:
- return convertWindowToV8Object(static_cast<DOMWindow*>(impl));
- case V8ClassIndex::NAMEDNODEMAP:
- return convertNamedNodeMapToV8Object(static_cast<NamedNodeMap*>(impl));
-#if ENABLE(SVG)
- SVG_NONNODE_TYPES(MAKE_CASE)
- if (type == V8ClassIndex::SVGELEMENTINSTANCE)
- return convertSVGElementInstanceToV8Object(static_cast<SVGElementInstance*>(impl));
- return convertSVGObjectWithContextToV8Object(type, impl);
-#endif
-
- ACTIVE_DOM_OBJECT_TYPES(MAKE_CASE)
- isActiveDomObject = true;
- break;
- default:
- break;
- }
-
-#undef MAKE_CASE
-
- if (!impl)
- return v8::Null();
-
- // Non DOM node
- v8::Persistent<v8::Object> result = isActiveDomObject ? getActiveDOMObjectMap().get(impl) : getDOMObjectMap().get(impl);
- if (result.IsEmpty()) {
-#if ENABLE(3D_CANVAS)
- if (type == V8ClassIndex::WEBGLARRAY && impl) {
- // Determine which subclass we are wrapping.
- WebGLArray* array = reinterpret_cast<WebGLArray*>(impl);
- if (array->isByteArray())
- type = V8ClassIndex::WEBGLBYTEARRAY;
- else if (array->isFloatArray())
- type = V8ClassIndex::WEBGLFLOATARRAY;
- else if (array->isIntArray())
- type = V8ClassIndex::WEBGLINTARRAY;
- else if (array->isShortArray())
- type = V8ClassIndex::WEBGLSHORTARRAY;
- else if (array->isUnsignedByteArray())
- type = V8ClassIndex::WEBGLUNSIGNEDBYTEARRAY;
- else if (array->isUnsignedIntArray())
- type = V8ClassIndex::WEBGLUNSIGNEDINTARRAY;
- else if (array->isUnsignedShortArray())
- type = V8ClassIndex::WEBGLUNSIGNEDSHORTARRAY;
- }
-#endif
-
- v8::Local<v8::Object> v8Object = instantiateV8Object(type, type, impl);
- if (!v8Object.IsEmpty()) {
- // Go through big switch statement, it has some duplications
- // that were handled by code above (such as CSSVALUE, CSSRULE, etc).
- switch (type) {
-#define MAKE_CASE(TYPE, NAME) \
- case V8ClassIndex::TYPE: static_cast<NAME*>(impl)->ref(); break;
- DOM_OBJECT_TYPES(MAKE_CASE)
-#undef MAKE_CASE
- default:
- ASSERT_NOT_REACHED();
- }
- result = v8::Persistent<v8::Object>::New(v8Object);
- if (isActiveDomObject)
- setJSWrapperForActiveDOMObject(impl, result);
- else
- setJSWrapperForDOMObject(impl, result);
-
- if (type == V8ClassIndex::CANVASPIXELARRAY) {
- CanvasPixelArray* pixels = reinterpret_cast<CanvasPixelArray*>(impl);
- result->SetIndexedPropertiesToPixelData(pixels->data()->data(), pixels->length());
- }
-
-#if ENABLE(3D_CANVAS)
- // Set up WebGLArray subclasses' accesses similarly.
- switch (type) {
- case V8ClassIndex::WEBGLBYTEARRAY:
- case V8ClassIndex::WEBGLUNSIGNEDBYTEARRAY:
- case V8ClassIndex::WEBGLSHORTARRAY:
- case V8ClassIndex::WEBGLUNSIGNEDSHORTARRAY:
- case V8ClassIndex::WEBGLINTARRAY:
- case V8ClassIndex::WEBGLUNSIGNEDINTARRAY:
- case V8ClassIndex::WEBGLFLOATARRAY: {
- WebGLArray* array = reinterpret_cast<WebGLArray*>(impl);
- setIndexedPropertiesToExternalArray(result,
- V8ClassIndex::ToInt(type),
- array->baseAddress(),
- array->length());
- break;
- }
- default:
- break;
- }
-#endif
-
- // Special case for non-node objects associated with a
- // DOMWindow. Both Safari and FF let the JS wrappers for these
- // objects survive GC. To mimic their behavior, V8 creates
- // hidden references from the DOMWindow to these wrapper
- // objects. These references get cleared when the DOMWindow is
- // reused by a new page.
- switch (type) {
- case V8ClassIndex::CONSOLE:
- setHiddenWindowReference(static_cast<Console*>(impl)->frame(), V8DOMWindow::consoleIndex, result);
- break;
- case V8ClassIndex::HISTORY:
- setHiddenWindowReference(static_cast<History*>(impl)->frame(), V8DOMWindow::historyIndex, result);
- break;
- case V8ClassIndex::NAVIGATOR:
- setHiddenWindowReference(static_cast<Navigator*>(impl)->frame(), V8DOMWindow::navigatorIndex, result);
- break;
- case V8ClassIndex::SCREEN:
- setHiddenWindowReference(static_cast<Screen*>(impl)->frame(), V8DOMWindow::screenIndex, result);
- break;
- case V8ClassIndex::LOCATION:
- setHiddenWindowReference(static_cast<Location*>(impl)->frame(), V8DOMWindow::locationIndex, result);
- break;
- case V8ClassIndex::DOMSELECTION:
- setHiddenWindowReference(static_cast<DOMSelection*>(impl)->frame(), V8DOMWindow::domSelectionIndex, result);
- break;
- case V8ClassIndex::BARINFO: {
- BarInfo* barInfo = static_cast<BarInfo*>(impl);
- Frame* frame = barInfo->frame();
- switch (barInfo->type()) {
- case BarInfo::Locationbar:
- setHiddenWindowReference(frame, V8DOMWindow::locationbarIndex, result);
- break;
- case BarInfo::Menubar:
- setHiddenWindowReference(frame, V8DOMWindow::menubarIndex, result);
- break;
- case BarInfo::Personalbar:
- setHiddenWindowReference(frame, V8DOMWindow::personalbarIndex, result);
- break;
- case BarInfo::Scrollbars:
- setHiddenWindowReference(frame, V8DOMWindow::scrollbarsIndex, result);
- break;
- case BarInfo::Statusbar:
- setHiddenWindowReference(frame, V8DOMWindow::statusbarIndex, result);
- break;
- case BarInfo::Toolbar:
- setHiddenWindowReference(frame, V8DOMWindow::toolbarIndex, result);
- break;
- }
- break;
- }
- default:
- break;
- }
- }
- }
- return result;
-}
-
void V8DOMWrapper::setHiddenWindowReference(Frame* frame, const int internalIndex, v8::Handle<v8::Object> jsObject)
{
// Get DOMWindow
@@ -542,12 +279,8 @@ PassRefPtr<NodeFilter> V8DOMWrapper::wrapNativeNodeFilter(v8::Handle<v8::Value>
return NodeFilter::create(condition);
}
-v8::Local<v8::Object> V8DOMWrapper::instantiateV8Object(V8Proxy* proxy, V8ClassIndex::V8WrapperType descriptorType, V8ClassIndex::V8WrapperType cptrType, void* impl)
+v8::Local<v8::Object> V8DOMWrapper::instantiateV8Object(V8Proxy* proxy, V8ClassIndex::V8WrapperType type, void* impl)
{
- // Make a special case for document.all
- if (descriptorType == V8ClassIndex::HTMLCOLLECTION && static_cast<HTMLCollection*>(impl)->type() == DocAll)
- descriptorType = V8ClassIndex::HTMLALLCOLLECTION;
-
if (V8IsolatedContext::getEntered()) {
// This effectively disables the wrapper cache for isolated worlds.
proxy = 0;
@@ -560,14 +293,14 @@ v8::Local<v8::Object> V8DOMWrapper::instantiateV8Object(V8Proxy* proxy, V8ClassI
v8::Local<v8::Object> instance;
if (proxy)
// FIXME: Fix this to work properly with isolated worlds (see above).
- instance = proxy->windowShell()->createWrapperFromCache(descriptorType);
+ instance = proxy->windowShell()->createWrapperFromCache(type);
else {
- v8::Local<v8::Function> function = getTemplate(descriptorType)->GetFunction();
+ v8::Local<v8::Function> function = getTemplate(type)->GetFunction();
instance = SafeAllocation::newInstance(function);
}
if (!instance.IsEmpty()) {
// Avoid setting the DOM wrapper for failed allocations.
- setDOMWrapper(instance, V8ClassIndex::ToInt(cptrType), impl);
+ setDOMWrapper(instance, V8ClassIndex::ToInt(type), impl);
}
return instance;
}
@@ -595,13 +328,6 @@ bool V8DOMWrapper::maybeDOMWrapper(v8::Handle<v8::Value> value)
}
#endif
-bool V8DOMWrapper::isDOMEventWrapper(v8::Handle<v8::Value> value)
-{
- // All kinds of events use EVENT as dom type in JS wrappers.
- // See EventToV8Object
- return isWrapperOfType(value, V8ClassIndex::EVENT);
-}
-
bool V8DOMWrapper::isWrapperOfType(v8::Handle<v8::Value> value, V8ClassIndex::V8WrapperType classType)
{
if (value.IsEmpty() || !value->IsObject())
@@ -623,6 +349,7 @@ bool V8DOMWrapper::isWrapperOfType(v8::Handle<v8::Value> value, V8ClassIndex::V8
return V8ClassIndex::FromInt(type->Int32Value()) == classType;
}
+<<<<<<< HEAD
#if ENABLE(VIDEO)
#define FOR_EACH_VIDEO_TAG(macro) \
macro(audio, AUDIO) \
@@ -982,13 +709,16 @@ v8::Handle<v8::Value> V8DOMWrapper::convertDocumentToV8Object(Document* document
}
static v8::Handle<v8::Value> getWrapper(Node* node)
+=======
+v8::Handle<v8::Object> V8DOMWrapper::getWrapper(Node* node)
+>>>>>>> webkit.org at r54340
{
ASSERT(WTF::isMainThread());
V8IsolatedContext* context = V8IsolatedContext::getEntered();
if (LIKELY(!context)) {
v8::Persistent<v8::Object>* wrapper = node->wrapper();
if (!wrapper)
- return v8::Handle<v8::Value>();
+ return v8::Handle<v8::Object>();
return *wrapper;
}
@@ -996,101 +726,6 @@ static v8::Handle<v8::Value> getWrapper(Node* node)
return domNodeMap.get(node);
}
-v8::Handle<v8::Value> V8DOMWrapper::convertNodeToV8Object(Node* node)
-{
- if (!node)
- return v8::Null();
-
- v8::Handle<v8::Value> wrapper = getWrapper(node);
- if (!wrapper.IsEmpty())
- return wrapper;
-
- Document* document = node->document();
- if (node == document)
- return convertDocumentToV8Object(document);
-
- return convertNewNodeToV8Object(node, 0, getDOMNodeMap());
-}
-
-// Caller checks node is not null.
-v8::Handle<v8::Value> V8DOMWrapper::convertNewNodeToV8Object(Node* node, V8Proxy* proxy, DOMNodeMapping& domNodeMap)
-{
- if (!proxy && node->document())
- proxy = V8Proxy::retrieve(node->document()->frame());
-
- bool isDocument = false; // document type node has special handling
- V8ClassIndex::V8WrapperType type;
-
- Node::NodeType nodeType = node->nodeType();
- if (nodeType == Node::ELEMENT_NODE) {
- if (node->isHTMLElement())
- type = htmlElementType(static_cast<HTMLElement*>(node));
-#if ENABLE(SVG)
- else if (node->isSVGElement())
- type = svgElementType(static_cast<SVGElement*>(node));
-#endif
- else
- type = V8ClassIndex::ELEMENT;
- } else if (nodeType == Node::DOCUMENT_NODE) {
- isDocument = true;
- Document* document = static_cast<Document*>(node);
- if (document->isHTMLDocument())
- type = V8ClassIndex::HTMLDOCUMENT;
-#if ENABLE(SVG)
- else if (document->isSVGDocument())
- type = V8ClassIndex::SVGDOCUMENT;
-#endif
- else
- type = V8ClassIndex::DOCUMENT;
- } else {
- ASSERT(nodeType < static_cast<int>(sizeof(mapping)/sizeof(mapping[0])));
- type = mapping[nodeType];
- ASSERT(type != V8ClassIndex::INVALID_CLASS_INDEX);
- }
-
- v8::Handle<v8::Context> context;
- if (proxy)
- context = proxy->context();
-
- // Enter the node's context and create the wrapper in that context.
- if (!context.IsEmpty())
- context->Enter();
-
- v8::Local<v8::Object> result = instantiateV8Object(proxy, type, V8ClassIndex::NODE, node);
-
- // Exit the node's context if it was entered.
- if (!context.IsEmpty())
- context->Exit();
-
- if (result.IsEmpty()) {
- // If instantiation failed it's important not to add the result
- // to the DOM node map. Instead we return an empty handle, which
- // should already be handled by callers of this function in case
- // the node is NULL.
- return result;
- }
-
- node->ref();
- domNodeMap.set(node, v8::Persistent<v8::Object>::New(result));
-
- if (isDocument) {
- if (proxy)
- proxy->windowShell()->updateDocumentWrapper(result);
-
- if (type == V8ClassIndex::HTMLDOCUMENT) {
- // Create marker object and insert it in two internal fields.
- // This is used to implement temporary shadowing of
- // document.all.
- ASSERT(result->InternalFieldCount() == V8HTMLDocument::internalFieldCount);
- v8::Local<v8::Object> marker = v8::Object::New();
- result->SetInternalField(V8HTMLDocument::markerIndex, marker);
- result->SetInternalField(V8HTMLDocument::shadowIndex, marker);
- }
- }
-
- return result;
-}
-
// A JS object of type EventTarget is limited to a small number of possible classes.
// Check EventTarget.h for new type conversion methods
v8::Handle<v8::Value> V8DOMWrapper::convertEventTargetToV8Object(EventTarget* target)
@@ -1099,91 +734,70 @@ v8::Handle<v8::Value> V8DOMWrapper::convertEventTargetToV8Object(EventTarget* ta
return v8::Null();
#if ENABLE(SVG)
- SVGElementInstance* instance = target->toSVGElementInstance();
- if (instance)
- return convertToV8Object(V8ClassIndex::SVGELEMENTINSTANCE, instance);
+ if (SVGElementInstance* instance = target->toSVGElementInstance())
+ return toV8(instance);
#endif
#if ENABLE(WORKERS)
- Worker* worker = target->toWorker();
- if (worker)
- return convertToV8Object(V8ClassIndex::WORKER, worker);
+ if (Worker* worker = target->toWorker())
+ return toV8(worker);
#endif // WORKERS
#if ENABLE(SHARED_WORKERS)
- SharedWorker* sharedWorker = target->toSharedWorker();
- if (sharedWorker)
- return convertToV8Object(V8ClassIndex::SHAREDWORKER, sharedWorker);
+ if (SharedWorker* sharedWorker = target->toSharedWorker())
+ return toV8(sharedWorker);
#endif // SHARED_WORKERS
#if ENABLE(NOTIFICATIONS)
- Notification* notification = target->toNotification();
- if (notification)
- return convertToV8Object(V8ClassIndex::NOTIFICATION, notification);
+ if (Notification* notification = target->toNotification())
+ return toV8(notification);
#endif
#if ENABLE(WEB_SOCKETS)
- WebSocket* webSocket = target->toWebSocket();
- if (webSocket)
- return convertToV8Object(V8ClassIndex::WEBSOCKET, webSocket);
+ if (WebSocket* webSocket = target->toWebSocket())
+ return toV8(webSocket);
#endif
- Node* node = target->toNode();
- if (node)
- return convertNodeToV8Object(node);
+ if (Node* node = target->toNode())
+ return toV8(node);
if (DOMWindow* domWindow = target->toDOMWindow())
- return convertToV8Object(V8ClassIndex::DOMWINDOW, domWindow);
+ return toV8(domWindow);
// XMLHttpRequest is created within its JS counterpart.
- XMLHttpRequest* xmlHttpRequest = target->toXMLHttpRequest();
- if (xmlHttpRequest) {
+ if (XMLHttpRequest* xmlHttpRequest = target->toXMLHttpRequest()) {
v8::Handle<v8::Object> wrapper = getActiveDOMObjectMap().get(xmlHttpRequest);
ASSERT(!wrapper.IsEmpty());
return wrapper;
}
// MessagePort is created within its JS counterpart
- MessagePort* port = target->toMessagePort();
- if (port) {
+ if (MessagePort* port = target->toMessagePort()) {
v8::Handle<v8::Object> wrapper = getActiveDOMObjectMap().get(port);
ASSERT(!wrapper.IsEmpty());
return wrapper;
}
- XMLHttpRequestUpload* upload = target->toXMLHttpRequestUpload();
- if (upload) {
+ if (XMLHttpRequestUpload* upload = target->toXMLHttpRequestUpload()) {
v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(upload);
ASSERT(!wrapper.IsEmpty());
return wrapper;
}
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
- DOMApplicationCache* domAppCache = target->toDOMApplicationCache();
- if (domAppCache)
- return convertToV8Object(V8ClassIndex::DOMAPPLICATIONCACHE, domAppCache);
+ if (DOMApplicationCache* domAppCache = target->toDOMApplicationCache())
+ return toV8(domAppCache);
#endif
#if ENABLE(EVENTSOURCE)
- EventSource* eventSource = target->toEventSource();
- if (eventSource)
- return convertToV8Object(V8ClassIndex::EVENTSOURCE, eventSource);
+ if (EventSource* eventSource = target->toEventSource())
+ return toV8(eventSource);
#endif
ASSERT(0);
return notHandledByInterceptor();
}
-v8::Handle<v8::Value> V8DOMWrapper::convertEventListenerToV8Object(ScriptExecutionContext* context, EventListener* listener)
-{
- if (!listener)
- return v8::Null();
-
- // FIXME: can a user take a lazy event listener and set to other places?
- V8AbstractEventListener* v8listener = static_cast<V8AbstractEventListener*>(listener);
- return v8listener->getListenerObject(context);
-}
-
PassRefPtr<EventListener> V8DOMWrapper::getEventListener(Node* node, v8::Local<v8::Value> value, bool isAttribute, ListenerLookupType lookup)
{
return (lookup == ListenerFindOnly) ? V8EventListenerList::findWrapper(value, isAttribute) : V8EventListenerList::findOrCreateWrapper<V8EventListener>(value, isAttribute);
@@ -1269,193 +883,4 @@ PassRefPtr<EventListener> V8DOMWrapper::getEventListener(V8Proxy* proxy, v8::Loc
return (lookup == ListenerFindOnly) ? V8EventListenerList::findWrapper(value, isAttribute) : V8EventListenerList::findOrCreateWrapper<V8EventListener>(value, isAttribute);
}
-v8::Handle<v8::Value> V8DOMWrapper::convertDOMImplementationToV8Object(DOMImplementation* impl)
-{
- v8::Handle<v8::Object> result = instantiateV8Object(V8ClassIndex::DOMIMPLEMENTATION, V8ClassIndex::DOMIMPLEMENTATION, impl);
- if (result.IsEmpty()) {
- // If the instantiation failed, we ignore it and return null instead
- // of returning an empty handle.
- return v8::Null();
- }
- return result;
-}
-
-v8::Handle<v8::Value> V8DOMWrapper::convertStyleSheetToV8Object(StyleSheet* sheet)
-{
- if (!sheet)
- return v8::Null();
-
- v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(sheet);
- if (!wrapper.IsEmpty())
- return wrapper;
-
- V8ClassIndex::V8WrapperType type = V8ClassIndex::STYLESHEET;
- if (sheet->isCSSStyleSheet())
- type = V8ClassIndex::CSSSTYLESHEET;
-
- v8::Handle<v8::Object> result = instantiateV8Object(type, V8ClassIndex::STYLESHEET, sheet);
- if (!result.IsEmpty()) {
- // Only update the DOM object map if the result is non-empty.
- sheet->ref();
- setJSWrapperForDOMObject(sheet, v8::Persistent<v8::Object>::New(result));
- }
-
- // Add a hidden reference from stylesheet object to its owner node.
- Node* ownerNode = sheet->ownerNode();
- if (ownerNode) {
- v8::Handle<v8::Object> owner = v8::Handle<v8::Object>::Cast(convertNodeToV8Object(ownerNode));
- result->SetInternalField(V8StyleSheet::ownerNodeIndex, owner);
- }
-
- return result;
-}
-
-v8::Handle<v8::Value> V8DOMWrapper::convertCSSValueToV8Object(CSSValue* value)
-{
- if (!value)
- return v8::Null();
-
- v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(value);
- if (!wrapper.IsEmpty())
- return wrapper;
-
- V8ClassIndex::V8WrapperType type;
-
- if (value->isWebKitCSSTransformValue())
- type = V8ClassIndex::WEBKITCSSTRANSFORMVALUE;
- else if (value->isValueList())
- type = V8ClassIndex::CSSVALUELIST;
- else if (value->isPrimitiveValue())
- type = V8ClassIndex::CSSPRIMITIVEVALUE;
-#if ENABLE(SVG)
- else if (value->isSVGPaint())
- type = V8ClassIndex::SVGPAINT;
- else if (value->isSVGColor())
- type = V8ClassIndex::SVGCOLOR;
-#endif
- else
- type = V8ClassIndex::CSSVALUE;
-
- v8::Handle<v8::Object> result = instantiateV8Object(type, V8ClassIndex::CSSVALUE, value);
- if (!result.IsEmpty()) {
- // Only update the DOM object map if the result is non-empty.
- value->ref();
- setJSWrapperForDOMObject(value, v8::Persistent<v8::Object>::New(result));
- }
-
- return result;
-}
-
-v8::Handle<v8::Value> V8DOMWrapper::convertCSSRuleToV8Object(CSSRule* rule)
-{
- if (!rule)
- return v8::Null();
-
- v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(rule);
- if (!wrapper.IsEmpty())
- return wrapper;
-
- V8ClassIndex::V8WrapperType type;
-
- switch (rule->type()) {
- case CSSRule::STYLE_RULE:
- type = V8ClassIndex::CSSSTYLERULE;
- break;
- case CSSRule::CHARSET_RULE:
- type = V8ClassIndex::CSSCHARSETRULE;
- break;
- case CSSRule::IMPORT_RULE:
- type = V8ClassIndex::CSSIMPORTRULE;
- break;
- case CSSRule::MEDIA_RULE:
- type = V8ClassIndex::CSSMEDIARULE;
- break;
- case CSSRule::FONT_FACE_RULE:
- type = V8ClassIndex::CSSFONTFACERULE;
- break;
- case CSSRule::PAGE_RULE:
- type = V8ClassIndex::CSSPAGERULE;
- break;
- case CSSRule::VARIABLES_RULE:
- type = V8ClassIndex::CSSVARIABLESRULE;
- break;
- case CSSRule::WEBKIT_KEYFRAME_RULE:
- type = V8ClassIndex::WEBKITCSSKEYFRAMERULE;
- break;
- case CSSRule::WEBKIT_KEYFRAMES_RULE:
- type = V8ClassIndex::WEBKITCSSKEYFRAMESRULE;
- break;
- default: // CSSRule::UNKNOWN_RULE
- type = V8ClassIndex::CSSRULE;
- break;
- }
-
- v8::Handle<v8::Object> result = instantiateV8Object(type, V8ClassIndex::CSSRULE, rule);
- if (!result.IsEmpty()) {
- // Only update the DOM object map if the result is non-empty.
- rule->ref();
- setJSWrapperForDOMObject(rule, v8::Persistent<v8::Object>::New(result));
- }
- return result;
-}
-
-v8::Handle<v8::Value> V8DOMWrapper::convertWindowToV8Object(DOMWindow* window)
-{
- if (!window)
- return v8::Null();
- // Initializes environment of a frame, and return the global object
- // of the frame.
- Frame* frame = window->frame();
- if (!frame)
- return v8::Handle<v8::Object>();
-
- // Special case: Because of evaluateInIsolatedWorld() one DOMWindow can have
- // multiple contexts and multiple global objects associated with it. When
- // code running in one of those contexts accesses the window object, we
- // want to return the global object associated with that context, not
- // necessarily the first global object associated with that DOMWindow.
- v8::Handle<v8::Context> currentContext = v8::Context::GetCurrent();
- v8::Handle<v8::Object> currentGlobal = currentContext->Global();
- v8::Handle<v8::Object> windowWrapper = V8DOMWrapper::lookupDOMWrapper(V8ClassIndex::DOMWINDOW, currentGlobal);
- if (!windowWrapper.IsEmpty()) {
- if (V8DOMWindow::toNative(windowWrapper) == window)
- return currentGlobal;
- }
-
- // Otherwise, return the global object associated with this frame.
- v8::Handle<v8::Context> context = V8Proxy::context(frame);
- if (context.IsEmpty())
- return v8::Handle<v8::Object>();
-
- v8::Handle<v8::Object> global = context->Global();
- ASSERT(!global.IsEmpty());
- return global;
-}
-
-v8::Handle<v8::Value> V8DOMWrapper::convertNamedNodeMapToV8Object(NamedNodeMap* map)
-{
- if (!map)
- return v8::Null();
-
- v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(map);
- if (!wrapper.IsEmpty())
- return wrapper;
-
- v8::Handle<v8::Object> result = instantiateV8Object(V8ClassIndex::NAMEDNODEMAP, V8ClassIndex::NAMEDNODEMAP, map);
- if (result.IsEmpty())
- return result;
-
- // Only update the DOM object map if the result is non-empty.
- map->ref();
- setJSWrapperForDOMObject(map, v8::Persistent<v8::Object>::New(result));
-
- // Add a hidden reference from named node map to its owner node.
- if (Element* element = map->element()) {
- v8::Handle<v8::Object> owner = v8::Handle<v8::Object>::Cast(convertNodeToV8Object(element));
- result->SetInternalField(V8NamedNodeMap::ownerNodeIndex, owner);
- }
-
- return result;
-}
-
} // namespace WebCore
diff --git a/WebCore/bindings/v8/V8DOMWrapper.h b/WebCore/bindings/v8/V8DOMWrapper.h
index 3cff691..51abff7 100644
--- a/WebCore/bindings/v8/V8DOMWrapper.h
+++ b/WebCore/bindings/v8/V8DOMWrapper.h
@@ -36,7 +36,6 @@
#include "Node.h"
#include "NodeFilter.h"
#include "PlatformString.h" // for WebCore::String
-#include "V8CustomBinding.h"
#include "V8CustomXPathNSResolver.h"
#include "V8DOMMap.h"
#include "V8Event.h"
@@ -123,45 +122,8 @@ namespace WebCore {
return object.IsEmpty() ? object : object->FindInstanceInPrototypeChain(getTemplate(type));
}
- template<typename T>
- static v8::Handle<v8::Value> convertToV8Object(V8ClassIndex::V8WrapperType type, PassRefPtr<T> imp)
- {
- return convertToV8Object(type, imp.get());
- }
-
- static v8::Handle<v8::Value> convertToV8Object(V8ClassIndex::V8WrapperType, void*);
-
- // Fast-path for Node objects.
- static v8::Handle<v8::Value> convertNodeToV8Object(PassRefPtr<Node> node)
- {
- return convertNodeToV8Object(node.get());
- }
-
- static v8::Handle<v8::Value> convertNodeToV8Object(Node*);
-
- static v8::Handle<v8::Value> convertDocumentToV8Object(Document*);
-
- static v8::Handle<v8::Value> convertNewNodeToV8Object(PassRefPtr<Node> node)
- {
- return convertNewNodeToV8Object(node.get());
- }
-
- static v8::Handle<v8::Value> convertNewNodeToV8Object(Node* node)
- {
- return convertNewNodeToV8Object(node, 0, getDOMNodeMap());
- }
-
- static v8::Handle<v8::Value> convertNewNodeToV8Object(Node*, V8Proxy*, DOMNodeMapping&);
-
static V8ClassIndex::V8WrapperType domWrapperType(v8::Handle<v8::Object>);
- static v8::Handle<v8::Value> convertEventToV8Object(PassRefPtr<Event> event)
- {
- return convertEventToV8Object(event.get());
- }
-
- static v8::Handle<v8::Value> convertEventToV8Object(Event*);
-
static v8::Handle<v8::Value> convertEventTargetToV8Object(PassRefPtr<EventTarget> eventTarget)
{
return convertEventTargetToV8Object(eventTarget.get());
@@ -169,14 +131,6 @@ namespace WebCore {
static v8::Handle<v8::Value> convertEventTargetToV8Object(EventTarget*);
- // Wrap and unwrap JS event listeners.
- static v8::Handle<v8::Value> convertEventListenerToV8Object(ScriptExecutionContext* context, PassRefPtr<EventListener> eventListener)
- {
- return convertEventListenerToV8Object(context, eventListener.get());
- }
-
- static v8::Handle<v8::Value> convertEventListenerToV8Object(ScriptExecutionContext*, EventListener*);
-
static PassRefPtr<EventListener> getEventListener(Node* node, v8::Local<v8::Value> value, bool isAttribute, ListenerLookupType lookup);
static PassRefPtr<EventListener> getEventListener(SVGElementInstance* element, v8::Local<v8::Value> value, bool isAttribute, ListenerLookupType lookup);
@@ -211,10 +165,6 @@ namespace WebCore {
return resolver;
}
#endif
- // DOMImplementation is a singleton and it is handled in a special
- // way. A wrapper is generated per document and stored in an
- // internal field of the document.
- static v8::Handle<v8::Value> convertDOMImplementationToV8Object(DOMImplementation*);
// Wrap JS node filter in C++.
static PassRefPtr<NodeFilter> wrapNativeNodeFilter(v8::Handle<v8::Value>);
@@ -233,50 +183,18 @@ namespace WebCore {
// Check whether a V8 value is a wrapper of type |classType|.
static bool isWrapperOfType(v8::Handle<v8::Value>, V8ClassIndex::V8WrapperType);
- // Check whether a V8 value is a DOM Event wrapper.
- static bool isDOMEventWrapper(v8::Handle<v8::Value>);
-
- static v8::Handle<v8::Value> convertStyleSheetToV8Object(StyleSheet*);
- static v8::Handle<v8::Value> convertCSSValueToV8Object(CSSValue*);
- static v8::Handle<v8::Value> convertCSSRuleToV8Object(CSSRule*);
- // Returns the JS wrapper of a window object, initializes the environment
- // of the window frame if needed.
- static v8::Handle<v8::Value> convertWindowToV8Object(DOMWindow*);
- static v8::Handle<v8::Value> convertNamedNodeMapToV8Object(NamedNodeMap*);
-
-#if ENABLE(SVG)
- static v8::Handle<v8::Value> convertSVGElementInstanceToV8Object(SVGElementInstance*);
- static v8::Handle<v8::Value> convertSVGObjectWithContextToV8Object(V8ClassIndex::V8WrapperType, void*);
-#endif
-
#if ENABLE(3D_CANVAS)
static void setIndexedPropertiesToExternalArray(v8::Handle<v8::Object>,
int,
void*,
int);
#endif
-
- private:
// Set hidden references in a DOMWindow object of a frame.
static void setHiddenWindowReference(Frame*, const int internalIndex, v8::Handle<v8::Object>);
- static V8ClassIndex::V8WrapperType htmlElementType(HTMLElement*);
-#if ENABLE(SVG)
- static V8ClassIndex::V8WrapperType svgElementType(SVGElement*);
-#endif
-
- // The first V8WrapperType specifies the function descriptor
- // used to create JS object. The second V8WrapperType specifies
- // the actual type of the void* for type casting.
- // For example, a HTML element has HTMLELEMENT for the first V8WrapperType, but always
- // use NODE as the second V8WrapperType. JS wrapper stores the second
- // V8WrapperType and the void* as internal fields.
- static v8::Local<v8::Object> instantiateV8Object(V8ClassIndex::V8WrapperType descType, V8ClassIndex::V8WrapperType cptrType, void* impl)
- {
- return instantiateV8Object(NULL, descType, cptrType, impl);
- }
+ static v8::Local<v8::Object> instantiateV8Object(V8Proxy* proxy, V8ClassIndex::V8WrapperType type, void* impl);
- static v8::Local<v8::Object> instantiateV8Object(V8Proxy*, V8ClassIndex::V8WrapperType, V8ClassIndex::V8WrapperType, void*);
+ static v8::Handle<v8::Object> getWrapper(Node*);
};
}
diff --git a/WebCore/bindings/v8/V8NodeFilterCondition.cpp b/WebCore/bindings/v8/V8NodeFilterCondition.cpp
index 9f57a44..a8868b5 100644
--- a/WebCore/bindings/v8/V8NodeFilterCondition.cpp
+++ b/WebCore/bindings/v8/V8NodeFilterCondition.cpp
@@ -34,6 +34,7 @@
#include "Node.h"
#include "NodeFilter.h"
#include "ScriptState.h"
+#include "V8Node.h"
#include "V8Proxy.h"
#include <wtf/OwnArrayPtr.h>
@@ -69,7 +70,7 @@ short V8NodeFilterCondition::acceptNode(ScriptState* state, Node* node) const
v8::Handle<v8::Object> object = v8::Context::GetCurrent()->Global();
v8::Handle<v8::Function> callback = v8::Handle<v8::Function>::Cast(m_filter);
OwnArrayPtr<v8::Handle<v8::Value> > args(new v8::Handle<v8::Value>[1]);
- args[0] = V8DOMWrapper::convertToV8Object(V8ClassIndex::NODE, node);
+ args[0] = toV8(node);
V8Proxy* proxy = V8Proxy::retrieve();
ASSERT(proxy);
diff --git a/WebCore/bindings/v8/V8Proxy.cpp b/WebCore/bindings/v8/V8Proxy.cpp
index 7ed1c46..b0a47b8 100644
--- a/WebCore/bindings/v8/V8Proxy.cpp
+++ b/WebCore/bindings/v8/V8Proxy.cpp
@@ -45,12 +45,17 @@
#include "V8BindingState.h"
#include "V8Collection.h"
#include "V8ConsoleMessage.h"
-#include "V8CustomBinding.h"
+#include "V8DOMCoreException.h"
#include "V8DOMMap.h"
#include "V8DOMWindow.h"
+#include "V8EventException.h"
#include "V8HiddenPropertyName.h"
#include "V8Index.h"
#include "V8IsolatedContext.h"
+#include "V8RangeException.h"
+#include "V8SVGException.h"
+#include "V8XMLHttpRequestException.h"
+#include "V8XPathException.h"
#include "WorkerContextExecutionProxy.h"
#include <algorithm>
@@ -656,25 +661,25 @@ void V8Proxy::setDOMException(int exceptionCode)
v8::Handle<v8::Value> exception;
switch (description.type) {
case DOMExceptionType:
- exception = V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMCOREEXCEPTION, DOMCoreException::create(description));
+ exception = toV8(DOMCoreException::create(description));
break;
case RangeExceptionType:
- exception = V8DOMWrapper::convertToV8Object(V8ClassIndex::RANGEEXCEPTION, RangeException::create(description));
+ exception = toV8(RangeException::create(description));
break;
case EventExceptionType:
- exception = V8DOMWrapper::convertToV8Object(V8ClassIndex::EVENTEXCEPTION, EventException::create(description));
+ exception = toV8(EventException::create(description));
break;
case XMLHttpRequestExceptionType:
- exception = V8DOMWrapper::convertToV8Object(V8ClassIndex::XMLHTTPREQUESTEXCEPTION, XMLHttpRequestException::create(description));
+ exception = toV8(XMLHttpRequestException::create(description));
break;
#if ENABLE(SVG)
case SVGExceptionType:
- exception = V8DOMWrapper::convertToV8Object(V8ClassIndex::SVGEXCEPTION, SVGException::create(description));
+ exception = toV8(SVGException::create(description));
break;
#endif
#if ENABLE(XPATH)
case XPathExceptionType:
- exception = V8DOMWrapper::convertToV8Object(V8ClassIndex::XPATHEXCEPTION, XPathException::create(description));
+ exception = toV8(XPathException::create(description));
break;
#endif
}
diff --git a/WebCore/bindings/v8/V8Proxy.h b/WebCore/bindings/v8/V8Proxy.h
index 6f6470e..9aba723 100644
--- a/WebCore/bindings/v8/V8Proxy.h
+++ b/WebCore/bindings/v8/V8Proxy.h
@@ -191,7 +191,9 @@ namespace WebCore {
setSVGContext(object.get(), context);
return object;
}
- static void* withSVGContext(void* object, SVGElement* context)
+
+ template <typename T>
+ static T* withSVGContext(T* object, SVGElement* context)
{
setSVGContext(object, context);
return object;
diff --git a/WebCore/bindings/v8/WorkerContextExecutionProxy.h b/WebCore/bindings/v8/WorkerContextExecutionProxy.h
index 3b8ab9e..b5e6afb 100644
--- a/WebCore/bindings/v8/WorkerContextExecutionProxy.h
+++ b/WebCore/bindings/v8/WorkerContextExecutionProxy.h
@@ -95,6 +95,11 @@ namespace WebCore {
static v8::Handle<v8::Value> convertEventTargetToV8Object(EventTarget*);
static v8::Handle<v8::Value> convertWorkerContextToV8Object(WorkerContext*);
+ static v8::Local<v8::Object> toV8(V8ClassIndex::V8WrapperType type, void* impl)
+ {
+ return toV8(type, type, impl);
+ }
+
private:
void initV8IfNeeded();
void initContextIfNeeded();
diff --git a/WebCore/bindings/v8/custom/V8BarInfoCustom.cpp b/WebCore/bindings/v8/custom/V8BarInfoCustom.cpp
new file mode 100644
index 0000000..44f0b62
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8BarInfoCustom.cpp
@@ -0,0 +1,73 @@
+/*
+ * 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 "V8BarInfo.h"
+
+#include "V8DOMWindow.h"
+#include "V8DOMWrapper.h"
+
+namespace WebCore {
+
+v8::Handle<v8::Value> toV8(BarInfo* impl)
+{
+ if (!impl)
+ return v8::Null();
+ v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(impl);
+ if (wrapper.IsEmpty()) {
+ wrapper = V8BarInfo::wrap(impl);
+ if (!wrapper.IsEmpty()) {
+ Frame* frame = impl->frame();
+ switch (impl->type()) {
+ case BarInfo::Locationbar:
+ V8DOMWrapper::setHiddenWindowReference(frame, V8DOMWindow::locationbarIndex, wrapper);
+ break;
+ case BarInfo::Menubar:
+ V8DOMWrapper::setHiddenWindowReference(frame, V8DOMWindow::menubarIndex, wrapper);
+ break;
+ case BarInfo::Personalbar:
+ V8DOMWrapper::setHiddenWindowReference(frame, V8DOMWindow::personalbarIndex, wrapper);
+ break;
+ case BarInfo::Scrollbars:
+ V8DOMWrapper::setHiddenWindowReference(frame, V8DOMWindow::scrollbarsIndex, wrapper);
+ break;
+ case BarInfo::Statusbar:
+ V8DOMWrapper::setHiddenWindowReference(frame, V8DOMWindow::statusbarIndex, wrapper);
+ break;
+ case BarInfo::Toolbar:
+ V8DOMWrapper::setHiddenWindowReference(frame, V8DOMWindow::toolbarIndex, wrapper);
+ break;
+ }
+ }
+ }
+ return wrapper;
+}
+
+} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8CSSRuleCustom.cpp b/WebCore/bindings/v8/custom/V8CSSRuleCustom.cpp
new file mode 100644
index 0000000..90a111c
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8CSSRuleCustom.cpp
@@ -0,0 +1,73 @@
+/*
+ * 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 "V8CSSRule.h"
+
+#include "V8CSSCharsetRule.h"
+#include "V8CSSFontFaceRule.h"
+#include "V8CSSImportRule.h"
+#include "V8CSSMediaRule.h"
+#include "V8CSSPageRule.h"
+#include "V8CSSStyleRule.h"
+#include "V8CSSVariablesRule.h"
+#include "V8WebKitCSSKeyframeRule.h"
+#include "V8WebKitCSSKeyframesRule.h"
+
+namespace WebCore {
+
+v8::Handle<v8::Value> toV8(CSSRule* impl)
+{
+ if (!impl)
+ return v8::Null();
+ switch (impl->type()) {
+ case CSSRule::STYLE_RULE:
+ return toV8(static_cast<CSSStyleRule*>(impl));
+ case CSSRule::CHARSET_RULE:
+ return toV8(static_cast<CSSCharsetRule*>(impl));
+ case CSSRule::IMPORT_RULE:
+ return toV8(static_cast<CSSImportRule*>(impl));
+ case CSSRule::MEDIA_RULE:
+ return toV8(static_cast<CSSMediaRule*>(impl));
+ case CSSRule::FONT_FACE_RULE:
+ return toV8(static_cast<CSSFontFaceRule*>(impl));
+ case CSSRule::PAGE_RULE:
+ return toV8(static_cast<CSSPageRule*>(impl));
+ case CSSRule::VARIABLES_RULE:
+ return toV8(static_cast<CSSVariablesRule*>(impl));
+ case CSSRule::WEBKIT_KEYFRAME_RULE:
+ return toV8(static_cast<WebKitCSSKeyframeRule*>(impl));
+ case CSSRule::WEBKIT_KEYFRAMES_RULE:
+ return toV8(static_cast<WebKitCSSKeyframesRule*>(impl));
+ }
+ return V8CSSRule::wrap(impl);
+}
+
+} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8CSSStyleSheetCustom.cpp b/WebCore/bindings/v8/custom/V8CSSStyleSheetCustom.cpp
new file mode 100644
index 0000000..5dcc966
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8CSSStyleSheetCustom.cpp
@@ -0,0 +1,50 @@
+/*
+ * 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 "V8CSSStyleSheet.h"
+
+#include "V8Node.h"
+
+namespace WebCore {
+
+v8::Handle<v8::Value> toV8(CSSStyleSheet* impl)
+{
+ if (!impl)
+ return v8::Null();
+ v8::Handle<v8::Object> wrapper = V8CSSStyleSheet::wrap(impl);
+ // Add a hidden reference from stylesheet object to its owner node.
+ Node* ownerNode = impl->ownerNode();
+ if (ownerNode && !wrapper.IsEmpty())
+ wrapper->SetInternalField(V8CSSStyleSheet::ownerNodeIndex, toV8(ownerNode));
+ return wrapper;
+}
+
+} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8CSSValueCustom.cpp b/WebCore/bindings/v8/custom/V8CSSValueCustom.cpp
new file mode 100644
index 0000000..9e692ad
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8CSSValueCustom.cpp
@@ -0,0 +1,59 @@
+/*
+ * 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 "V8CSSValue.h"
+
+#include "V8CSSPrimitiveValue.h"
+#include "V8CSSValueList.h"
+#include "V8SVGColor.h"
+#include "V8SVGPaint.h"
+#include "V8WebKitCSSTransformValue.h"
+
+namespace WebCore {
+
+v8::Handle<v8::Value> toV8(CSSValue* impl)
+{
+ if (!impl)
+ return v8::Null();
+ if (impl->isWebKitCSSTransformValue())
+ return toV8(static_cast<WebKitCSSTransformValue*>(impl));
+ if (impl->isValueList())
+ return toV8(static_cast<CSSValueList*>(impl));
+ if (impl->isPrimitiveValue())
+ return toV8(static_cast<CSSPrimitiveValue*>(impl));
+ if (impl->isSVGPaint())
+ return toV8(static_cast<SVGPaint*>(impl));
+ if (impl->isSVGColor())
+ return toV8(static_cast<SVGColor*>(impl));
+ return V8CSSValue::wrap(impl);
+}
+
+} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8CanvasPixelArrayCustom.cpp b/WebCore/bindings/v8/custom/V8CanvasPixelArrayCustom.cpp
new file mode 100644
index 0000000..cd638ce
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8CanvasPixelArrayCustom.cpp
@@ -0,0 +1,46 @@
+/*
+ * 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 "V8CanvasPixelArray.h"
+
+namespace WebCore {
+
+v8::Handle<v8::Value> toV8(CanvasPixelArray* impl)
+{
+ if (!impl)
+ return v8::Null();
+ v8::Handle<v8::Object> wrapper = V8CanvasPixelArray::wrap(impl);
+ if (!wrapper.IsEmpty())
+ wrapper->SetIndexedPropertiesToPixelData(impl->data()->data(), impl->length());
+ return wrapper;
+}
+
+} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp b/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp
index b45ef35..70be193 100644
--- a/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp
@@ -50,13 +50,13 @@
namespace WebCore {
-static v8::Handle<v8::Value> toV8(CanvasStyle* style)
+static v8::Handle<v8::Value> toV8Object(CanvasStyle* style)
{
if (style->canvasGradient())
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASGRADIENT, style->canvasGradient());
+ return toV8(style->canvasGradient());
if (style->canvasPattern())
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASPATTERN, style->canvasPattern());
+ return toV8(style->canvasPattern());
return v8String(style->color());
}
@@ -78,7 +78,7 @@ static PassRefPtr<CanvasStyle> toCanvasStyle(v8::Handle<v8::Value> value)
v8::Handle<v8::Value> V8CanvasRenderingContext2D::strokeStyleAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
CanvasRenderingContext2D* impl = V8CanvasRenderingContext2D::toNative(info.Holder());
- return toV8(impl->strokeStyle());
+ return toV8Object(impl->strokeStyle());
}
void V8CanvasRenderingContext2D::strokeStyleAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
@@ -90,7 +90,7 @@ void V8CanvasRenderingContext2D::strokeStyleAccessorSetter(v8::Local<v8::String>
v8::Handle<v8::Value> V8CanvasRenderingContext2D::fillStyleAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
CanvasRenderingContext2D* impl = V8CanvasRenderingContext2D::toNative(info.Holder());
- return toV8(impl->fillStyle());
+ return toV8Object(impl->fillStyle());
}
void V8CanvasRenderingContext2D::fillStyleAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
@@ -348,7 +348,7 @@ v8::Handle<v8::Value> V8CanvasRenderingContext2D::createPatternCallback(const v8
V8Proxy::setDOMException(ec);
return notHandledByInterceptor();
}
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASPATTERN, pattern.release());
+ return toV8(pattern.release());
}
if (V8HTMLCanvasElement::HasInstance(arg)) {
@@ -359,7 +359,7 @@ v8::Handle<v8::Value> V8CanvasRenderingContext2D::createPatternCallback(const v8
V8Proxy::setDOMException(ec);
return notHandledByInterceptor();
}
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASPATTERN, pattern.release());
+ return toV8(pattern.release());
}
V8Proxy::setDOMException(TYPE_MISMATCH_ERR);
diff --git a/WebCore/bindings/v8/custom/V8CustomPositionCallback.cpp b/WebCore/bindings/v8/custom/V8CustomPositionCallback.cpp
index 5e9a8f2..19300b0 100644
--- a/WebCore/bindings/v8/custom/V8CustomPositionCallback.cpp
+++ b/WebCore/bindings/v8/custom/V8CustomPositionCallback.cpp
@@ -28,6 +28,7 @@
#include "Frame.h"
#include "V8CustomVoidCallback.h" // For invokeCallback
+#include "V8Geoposition.h"
namespace WebCore {
@@ -53,7 +54,7 @@ void V8CustomPositionCallback::handleEvent(Geoposition* position)
v8::Context::Scope scope(context);
v8::Handle<v8::Value> argv[] = {
- V8DOMWrapper::convertToV8Object(V8ClassIndex::GEOPOSITION, position)
+ toV8(position)
};
// Protect the frame until the callback returns.
diff --git a/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.cpp b/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.cpp
index 117f374..c6c632b 100644
--- a/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.cpp
+++ b/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.cpp
@@ -28,6 +28,7 @@
#include "Frame.h"
#include "V8CustomVoidCallback.h" // For invokeCallback
+#include "V8PositionError.h"
namespace WebCore {
@@ -53,7 +54,7 @@ void V8CustomPositionErrorCallback::handleEvent(PositionError* error)
v8::Context::Scope scope(context);
v8::Handle<v8::Value> argv[] = {
- V8DOMWrapper::convertToV8Object(V8ClassIndex::POSITIONERROR, error)
+ toV8(error)
};
// Protect the frame until the callback returns.
diff --git a/WebCore/bindings/v8/custom/V8CustomSQLStatementCallback.cpp b/WebCore/bindings/v8/custom/V8CustomSQLStatementCallback.cpp
index 64abdc4..d30b95a 100644
--- a/WebCore/bindings/v8/custom/V8CustomSQLStatementCallback.cpp
+++ b/WebCore/bindings/v8/custom/V8CustomSQLStatementCallback.cpp
@@ -36,6 +36,8 @@
#include "Frame.h"
#include "V8CustomVoidCallback.h"
+#include "V8SQLResultSet.h"
+#include "V8SQLTransaction.h"
namespace WebCore {
@@ -61,8 +63,8 @@ void V8CustomSQLStatementCallback::handleEvent(SQLTransaction* transaction, SQLR
v8::Context::Scope scope(context);
v8::Handle<v8::Value> argv[] = {
- V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLTRANSACTION, transaction),
- V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLRESULTSET, resultSet)
+ toV8(transaction),
+ toV8(resultSet)
};
// Protect the frame until the callback returns.
diff --git a/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp b/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp
index 1af3562..84a3b96 100644
--- a/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp
+++ b/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp
@@ -36,6 +36,8 @@
#include "Frame.h"
#include "V8CustomVoidCallback.h"
+#include "V8SQLError.h"
+#include "V8SQLTransaction.h"
namespace WebCore {
@@ -61,8 +63,8 @@ bool V8CustomSQLStatementErrorCallback::handleEvent(SQLTransaction* transaction,
v8::Context::Scope scope(context);
v8::Handle<v8::Value> argv[] = {
- V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLTRANSACTION, transaction),
- V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLERROR, error)
+ toV8(transaction),
+ toV8(error)
};
// Protect the frame until the callback returns.
diff --git a/WebCore/bindings/v8/custom/V8CustomSQLTransactionCallback.cpp b/WebCore/bindings/v8/custom/V8CustomSQLTransactionCallback.cpp
index 2cef6b3..68002d7 100644
--- a/WebCore/bindings/v8/custom/V8CustomSQLTransactionCallback.cpp
+++ b/WebCore/bindings/v8/custom/V8CustomSQLTransactionCallback.cpp
@@ -36,6 +36,7 @@
#include "Frame.h"
#include "V8CustomVoidCallback.h"
+#include "V8SQLTransaction.h"
namespace WebCore {
@@ -62,7 +63,7 @@ void V8CustomSQLTransactionCallback::handleEvent(SQLTransaction* transaction, bo
v8::Context::Scope scope(context);
v8::Handle<v8::Value> argv[] = {
- V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLTRANSACTION, transaction)
+ toV8(transaction)
};
// Protect the frame until the callback returns.
diff --git a/WebCore/bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp b/WebCore/bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp
index 1a0939d..cf5a0ef 100644
--- a/WebCore/bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp
+++ b/WebCore/bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp
@@ -36,6 +36,7 @@
#include "Frame.h"
#include "V8CustomVoidCallback.h"
+#include "V8SQLError.h"
namespace WebCore {
@@ -61,7 +62,7 @@ void V8CustomSQLTransactionErrorCallback::handleEvent(SQLError* error)
v8::Context::Scope scope(context);
v8::Handle<v8::Value> argv[] = {
- V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLERROR, error)
+ toV8(error)
};
// Protect the frame until the callback returns.
diff --git a/WebCore/bindings/v8/custom/V8DOMSelectionCustom.cpp b/WebCore/bindings/v8/custom/V8DOMSelectionCustom.cpp
new file mode 100644
index 0000000..0c9e745
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8DOMSelectionCustom.cpp
@@ -0,0 +1,51 @@
+/*
+ * 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 "V8DOMSelection.h"
+
+#include "V8DOMWindow.h"
+#include "V8DOMWrapper.h"
+
+namespace WebCore {
+
+v8::Handle<v8::Value> toV8(DOMSelection* impl)
+{
+ if (!impl)
+ return v8::Null();
+ v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(impl);
+ if (wrapper.IsEmpty()) {
+ wrapper = V8DOMSelection::wrap(impl);
+ V8DOMWrapper::setHiddenWindowReference(impl->frame(), V8DOMWindow::domSelectionIndex, wrapper);
+ }
+ return wrapper;
+}
+
+} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
index 2933b4d..ba6c738 100644
--- a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
@@ -57,7 +57,9 @@
#include "V8BindingState.h"
#include "V8CustomBinding.h"
#include "V8CustomEventListener.h"
+#include "V8HTMLCollection.h"
#include "V8MessagePortCustom.h"
+#include "V8Node.h"
#include "V8Proxy.h"
#include "V8Utilities.h"
#if ENABLE(WEB_SOCKETS)
@@ -78,8 +80,15 @@ v8::Handle<v8::Value> WindowSetTimeoutImpl(const v8::Arguments& args, bool singl
if (argumentCount < 1)
return v8::Undefined();
- v8::Handle<v8::Value> function = args[0];
+ DOMWindow* imp = V8DOMWindow::toNative(args.Holder());
+ ScriptExecutionContext* scriptContext = static_cast<ScriptExecutionContext*>(imp->document());
+
+ if (!scriptContext) {
+ V8Proxy::setDOMException(INVALID_ACCESS_ERR);
+ return v8::Undefined();
+ }
+ v8::Handle<v8::Value> function = args[0];
WebCore::String functionString;
if (!function->IsFunction()) {
if (function->IsString())
@@ -104,16 +113,9 @@ v8::Handle<v8::Value> WindowSetTimeoutImpl(const v8::Arguments& args, bool singl
if (argumentCount >= 2)
timeout = args[1]->Int32Value();
- DOMWindow* imp = V8DOMWindow::toNative(args.Holder());
-
if (!V8BindingSecurity::canAccessFrame(V8BindingState::Only(), imp->frame(), true))
return v8::Undefined();
- ScriptExecutionContext* scriptContext = static_cast<ScriptExecutionContext*>(imp->document());
-
- if (!scriptContext)
- return v8::Undefined();
-
int id;
if (function->IsFunction()) {
int paramCount = argumentCount >= 2 ? argumentCount - 2 : 0;
@@ -708,7 +710,7 @@ v8::Handle<v8::Value> V8DOMWindow::openCallback(const v8::Arguments& args)
frame->redirectScheduler()->scheduleLocationChange(completedUrl, referrer, false, userGesture);
}
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow());
+ return toV8(frame->domWindow());
}
// In the case of a named frame or a new window, we'll use the
@@ -768,7 +770,7 @@ v8::Handle<v8::Value> V8DOMWindow::openCallback(const v8::Arguments& args)
if (!frame)
return v8::Undefined();
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow());
+ return toV8(frame->domWindow());
}
@@ -786,7 +788,7 @@ v8::Handle<v8::Value> V8DOMWindow::indexedPropertyGetter(uint32_t index, const v
Frame* child = frame->tree()->child(index);
if (child)
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, child->domWindow());
+ return toV8(child->domWindow());
return notHandledByInterceptor();
}
@@ -809,7 +811,7 @@ v8::Handle<v8::Value> V8DOMWindow::namedPropertyGetter(v8::Local<v8::String> nam
AtomicString propName = v8StringToAtomicWebCoreString(name);
Frame* child = frame->tree()->child(propName);
if (child)
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, child->domWindow());
+ return toV8(child->domWindow());
// Search IDL functions defined in the prototype
v8::Handle<v8::Value> result = info.Holder()->GetRealNamedProperty(name);
@@ -824,8 +826,8 @@ v8::Handle<v8::Value> V8DOMWindow::namedPropertyGetter(v8::Local<v8::String> nam
RefPtr<HTMLCollection> items = doc->windowNamedItems(propName);
if (items->length() >= 1) {
if (items->length() == 1)
- return V8DOMWrapper::convertNodeToV8Object(items->firstItem());
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::HTMLCOLLECTION, items.release());
+ return toV8(items->firstItem());
+ return toV8(items.release());
}
}
}
@@ -925,4 +927,37 @@ bool V8DOMWindow::indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t inde
return V8BindingSecurity::canAccessFrame(V8BindingState::Only(), target, false);
}
+v8::Handle<v8::Value> toV8(DOMWindow* window)
+{
+ if (!window)
+ return v8::Null();
+ // Initializes environment of a frame, and return the global object
+ // of the frame.
+ Frame* frame = window->frame();
+ if (!frame)
+ return v8::Handle<v8::Object>();
+
+ // Special case: Because of evaluateInIsolatedWorld() one DOMWindow can have
+ // multiple contexts and multiple global objects associated with it. When
+ // code running in one of those contexts accesses the window object, we
+ // want to return the global object associated with that context, not
+ // necessarily the first global object associated with that DOMWindow.
+ v8::Handle<v8::Context> currentContext = v8::Context::GetCurrent();
+ v8::Handle<v8::Object> currentGlobal = currentContext->Global();
+ v8::Handle<v8::Object> windowWrapper = V8DOMWrapper::lookupDOMWrapper(V8ClassIndex::DOMWINDOW, currentGlobal);
+ if (!windowWrapper.IsEmpty()) {
+ if (V8DOMWindow::toNative(windowWrapper) == window)
+ return currentGlobal;
+ }
+
+ // Otherwise, return the global object associated with this frame.
+ v8::Handle<v8::Context> context = V8Proxy::context(frame);
+ if (context.IsEmpty())
+ return v8::Handle<v8::Object>();
+
+ v8::Handle<v8::Object> global = context->Global();
+ ASSERT(!global.IsEmpty());
+ return global;
+}
+
} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8DataGridColumnListCustom.cpp b/WebCore/bindings/v8/custom/V8DataGridColumnListCustom.cpp
index 8980cfe..58e5d01 100644
--- a/WebCore/bindings/v8/custom/V8DataGridColumnListCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DataGridColumnListCustom.cpp
@@ -57,7 +57,7 @@ NAMED_PROPERTY_GETTER(DataGridColumnList)
DataGridColumn* result = imp->itemWithName(toWebCoreString(name));
if (!result)
return notHandledByInterceptor();
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::DATAGRIDCOLUMN, result);
+ return toV8(result);
}
} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8DocumentCustom.cpp b/WebCore/bindings/v8/custom/V8DocumentCustom.cpp
index 9cb8ae1..d8dde7a 100644
--- a/WebCore/bindings/v8/custom/V8DocumentCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DocumentCustom.cpp
@@ -37,16 +37,23 @@
#include "Node.h"
#include "XPathNSResolver.h"
#include "XPathResult.h"
-#include "CanvasRenderingContext.h"
#include "V8Binding.h"
-#include "V8CustomBinding.h"
+#include "V8CanvasRenderingContext2D.h"
#include "V8CustomXPathNSResolver.h"
+#include "V8DOMImplementation.h"
+#include "V8HTMLDocument.h"
+#include "V8IsolatedContext.h"
#include "V8Node.h"
#include "V8Proxy.h"
+<<<<<<< HEAD
// ANDROID
// TODO: Upstream to webkit.org
#if ENABLE(XPATH)
+=======
+#include "V8SVGDocument.h"
+#include "V8WebGLRenderingContext.h"
+>>>>>>> webkit.org at r54340
#include "V8XPathNSResolver.h"
#include "V8XPathResult.h"
#endif
@@ -86,7 +93,7 @@ v8::Handle<v8::Value> V8Document::evaluateCallback(const v8::Arguments& args)
if (ec)
return throwError(ec);
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::XPATHRESULT, result.release());
+ return toV8(result.release());
}
#endif
@@ -103,10 +110,10 @@ v8::Handle<v8::Value> V8Document::getCSSCanvasContextCallback(const v8::Argument
if (!result)
return v8::Undefined();
if (result->is2d())
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASRENDERINGCONTEXT2D, result);
+ return toV8(static_cast<CanvasRenderingContext2D*>(result));
#if ENABLE(3D_CANVAS)
else if (result->is3d())
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLRENDERINGCONTEXT, result);
+ return toV8(static_cast<WebGLRenderingContext*>(result));
#endif // ENABLE(3D_CANVAS)
ASSERT_NOT_REACHED();
return v8::Undefined();
@@ -132,7 +139,7 @@ v8::Handle<v8::Value> V8Document::implementationAccessorGetter(v8::Local<v8::Str
// Generate a wrapper.
Document* document = V8Document::toNative(info.Holder());
- v8::Handle<v8::Value> wrapper = V8DOMWrapper::convertDOMImplementationToV8Object(document->implementation());
+ v8::Handle<v8::Value> wrapper = toV8(document->implementation());
// Store the wrapper in the internal field.
info.Holder()->SetInternalField(implementationIndex, wrapper);
@@ -140,4 +147,20 @@ v8::Handle<v8::Value> V8Document::implementationAccessorGetter(v8::Local<v8::Str
return wrapper;
}
+v8::Handle<v8::Value> toV8(Document* impl, bool forceNewObject)
+{
+ if (!impl)
+ return v8::Null();
+ if (impl->isHTMLDocument())
+ return toV8(static_cast<HTMLDocument*>(impl), forceNewObject);
+ if (impl->isSVGDocument())
+ return toV8(static_cast<SVGDocument*>(impl), forceNewObject);
+ v8::Handle<v8::Value> wrapper = V8Document::wrap(impl, forceNewObject);
+ if (!V8IsolatedContext::getEntered()) {
+ if (V8Proxy* proxy = V8Proxy::retrieve(impl->frame()))
+ proxy->windowShell()->updateDocumentWrapper(wrapper);
+ }
+ return wrapper;
+}
+
} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8DocumentLocationCustom.cpp b/WebCore/bindings/v8/custom/V8DocumentLocationCustom.cpp
index 8dc4672..f86054b 100644
--- a/WebCore/bindings/v8/custom/V8DocumentLocationCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DocumentLocationCustom.cpp
@@ -27,8 +27,7 @@
#include "DOMWindow.h"
#include "Frame.h"
#include "V8Binding.h"
-#include "V8CustomBinding.h"
-#include "V8Document.h"
+#include "V8Location.h"
#include "V8Proxy.h"
namespace WebCore {
@@ -40,7 +39,7 @@ v8::Handle<v8::Value> V8Document::locationAccessorGetter(v8::Local<v8::String> n
return v8::Null();
DOMWindow* window = document->frame()->domWindow();
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::LOCATION, window->location());
+ return toV8(window->location());
}
void V8Document::locationAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
diff --git a/WebCore/bindings/v8/custom/V8ElementCustom.cpp b/WebCore/bindings/v8/custom/V8ElementCustom.cpp
index 0f13f9d..b420f6a 100644
--- a/WebCore/bindings/v8/custom/V8ElementCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8ElementCustom.cpp
@@ -44,7 +44,9 @@
#include "V8Binding.h"
#include "V8BindingState.h"
#include "V8CustomBinding.h"
+#include "V8HTMLElement.h"
#include "V8Proxy.h"
+#include "V8SVGElement.h"
#include <wtf/RefPtr.h>
@@ -85,7 +87,7 @@ v8::Handle<v8::Value> V8Element::setAttributeNodeCallback(const v8::Arguments& a
if (ec)
throwError(ec);
- return V8DOMWrapper::convertNodeToV8Object(result.release());
+ return toV8(result.release());
}
v8::Handle<v8::Value> V8Element::setAttributeNSCallback(const v8::Arguments& args)
@@ -124,7 +126,17 @@ v8::Handle<v8::Value> V8Element::setAttributeNodeNSCallback(const v8::Arguments&
if (ec)
throwError(ec);
- return V8DOMWrapper::convertNodeToV8Object(result.release());
+ return toV8(result.release());
}
+v8::Handle<v8::Value> toV8(Element* impl, bool forceNewObject)
+{
+ if (!impl)
+ return v8::Null();
+ if (impl->isHTMLElement())
+ return toV8(static_cast<HTMLElement*>(impl), forceNewObject);
+ if (impl->isSVGElement())
+ return toV8(static_cast<SVGElement*>(impl), forceNewObject);
+ return V8Element::wrap(impl, forceNewObject);
+}
} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8EventCustom.cpp b/WebCore/bindings/v8/custom/V8EventCustom.cpp
index 65cd41e..a13603e 100644
--- a/WebCore/bindings/v8/custom/V8EventCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8EventCustom.cpp
@@ -34,10 +34,28 @@
#include "Clipboard.h"
#include "ClipboardEvent.h"
#include "Event.h"
-#include "MouseEvent.h"
+#include "V8BeforeLoadEvent.h"
#include "V8Binding.h"
-#include "V8CustomBinding.h"
+#include "V8Clipboard.h"
+#include "V8CompositionEvent.h"
+#include "V8ErrorEvent.h"
+#include "V8KeyboardEvent.h"
+#include "V8MessageEvent.h"
+#include "V8MouseEvent.h"
+#include "V8MutationEvent.h"
+#include "V8OverflowEvent.h"
+#include "V8PageTransitionEvent.h"
+#include "V8PopStateEvent.h"
+#include "V8ProgressEvent.h"
#include "V8Proxy.h"
+#include "V8SVGZoomEvent.h"
+#include "V8StorageEvent.h"
+#include "V8TextEvent.h"
+#include "V8UIEvent.h"
+#include "V8WebKitAnimationEvent.h"
+#include "V8WebKitTransitionEvent.h"
+#include "V8WheelEvent.h"
+#include "V8XMLHttpRequestProgressEvent.h"
namespace WebCore {
@@ -52,7 +70,7 @@ v8::Handle<v8::Value> V8Event::dataTransferAccessorGetter(v8::Local<v8::String>
Event* event = V8Event::toNative(info.Holder());
if (event->isDragEvent())
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::CLIPBOARD, static_cast<MouseEvent*>(event)->clipboard());
+ return toV8(static_cast<MouseEvent*>(event)->clipboard());
return v8::Undefined();
}
@@ -62,9 +80,61 @@ v8::Handle<v8::Value> V8Event::clipboardDataAccessorGetter(v8::Local<v8::String>
Event* event = V8Event::toNative(info.Holder());
if (event->isClipboardEvent())
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::CLIPBOARD, static_cast<ClipboardEvent*>(event)->clipboard());
+ return toV8(static_cast<ClipboardEvent*>(event)->clipboard());
return v8::Undefined();
}
+v8::Handle<v8::Value> toV8(Event* impl)
+{
+ if (!impl)
+ return v8::Null();
+ if (impl->isUIEvent()) {
+ if (impl->isKeyboardEvent())
+ return toV8(static_cast<KeyboardEvent*>(impl));
+ if (impl->isTextEvent())
+ return toV8(static_cast<TextEvent*>(impl));
+ if (impl->isMouseEvent())
+ return toV8(static_cast<MouseEvent*>(impl));
+ if (impl->isWheelEvent())
+ return toV8(static_cast<WheelEvent*>(impl));
+#if ENABLE(SVG)
+ if (impl->isSVGZoomEvent())
+ return toV8(static_cast<SVGZoomEvent*>(impl));
+#endif
+ if (impl->isCompositionEvent())
+ return toV8(static_cast<CompositionEvent*>(impl));
+ return toV8(static_cast<UIEvent*>(impl));
+ }
+ if (impl->isMutationEvent())
+ return toV8(static_cast<MutationEvent*>(impl));
+ if (impl->isOverflowEvent())
+ return toV8(static_cast<OverflowEvent*>(impl));
+ if (impl->isMessageEvent())
+ return toV8(static_cast<MessageEvent*>(impl));
+ if (impl->isPageTransitionEvent())
+ return toV8(static_cast<PageTransitionEvent*>(impl));
+ if (impl->isPopStateEvent())
+ return toV8(static_cast<PopStateEvent*>(impl));
+ if (impl->isProgressEvent()) {
+ if (impl->isXMLHttpRequestProgressEvent())
+ return toV8(static_cast<XMLHttpRequestProgressEvent*>(impl));
+ return toV8(static_cast<ProgressEvent*>(impl));
+ }
+ if (impl->isWebKitAnimationEvent())
+ return toV8(static_cast<WebKitAnimationEvent*>(impl));
+ if (impl->isWebKitTransitionEvent())
+ return toV8(static_cast<WebKitTransitionEvent*>(impl));
+#if ENABLE(WORKERS)
+ if (impl->isErrorEvent())
+ return toV8(static_cast<ErrorEvent*>(impl));
+#endif
+#if ENABLE(DOM_STORAGE)
+ if (impl->isStorageEvent())
+ return toV8(static_cast<StorageEvent*>(impl));
+#endif
+ if (impl->isBeforeLoadEvent())
+ return toV8(static_cast<BeforeLoadEvent*>(impl));
+ return V8Event::wrap(impl);
+}
} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp
index c34d9e7..88b3a9d 100644
--- a/WebCore/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp
@@ -36,6 +36,8 @@
#include "V8Binding.h"
#include "V8CustomBinding.h"
#include "V8NamedNodesCollection.h"
+#include "V8Node.h"
+#include "V8NodeList.h"
#include "V8Proxy.h"
namespace WebCore {
@@ -49,10 +51,10 @@ static v8::Handle<v8::Value> getNamedItems(HTMLAllCollection* collection, Atomic
return v8::Handle<v8::Value>();
if (namedItems.size() == 1)
- return V8DOMWrapper::convertNodeToV8Object(namedItems.at(0).release());
+ return toV8(namedItems.at(0).release());
NodeList* list = new V8NamedNodesCollection(namedItems);
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODELIST, list);
+ return toV8(list);
}
static v8::Handle<v8::Value> getItem(HTMLAllCollection* collection, v8::Handle<v8::Value> argument)
@@ -68,7 +70,7 @@ static v8::Handle<v8::Value> getItem(HTMLAllCollection* collection, v8::Handle<v
}
RefPtr<Node> result = collection->item(index->Uint32Value());
- return V8DOMWrapper::convertNodeToV8Object(result.release());
+ return toV8(result.release());
}
v8::Handle<v8::Value> V8HTMLAllCollection::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
@@ -130,7 +132,7 @@ v8::Handle<v8::Value> V8HTMLAllCollection::callAsFunctionCallback(const v8::Argu
Node* node = imp->namedItem(name);
while (node) {
if (!current)
- return V8DOMWrapper::convertNodeToV8Object(node);
+ return toV8(node);
node = imp->nextNamedItem(name);
current--;
diff --git a/WebCore/bindings/v8/custom/V8HTMLAudioElementConstructor.cpp b/WebCore/bindings/v8/custom/V8HTMLAudioElementConstructor.cpp
index e634003..28b0a99 100644
--- a/WebCore/bindings/v8/custom/V8HTMLAudioElementConstructor.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLAudioElementConstructor.cpp
@@ -36,6 +36,7 @@
#include "Frame.h"
#include "HTMLNames.h"
#include "V8Binding.h"
+#include "V8Document.h"
#include "V8HTMLAudioElement.h"
#include "V8Proxy.h"
@@ -78,7 +79,7 @@ v8::Handle<v8::Value> V8Custom::v8HTMLAudioElementConstructorCallback(const v8::
// Make sure the document is added to the DOM Node map. Otherwise, the HTMLAudioElement instance
// may end up being the only node in the map and get garbage-ccollected prematurely.
- V8DOMWrapper::convertNodeToV8Object(document);
+ toV8(document);
RefPtr<HTMLAudioElement> audio = new HTMLAudioElement(HTMLNames::audioTag, document);
audio->setAutobuffer(true);
diff --git a/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp
index 0d1ff44..54a003c 100644
--- a/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp
@@ -36,9 +36,10 @@
#include "HTMLCanvasElement.h"
#include "WebGLContextAttributes.h"
#include "V8Binding.h"
-#include "V8CustomBinding.h"
+#include "V8CanvasRenderingContext2D.h"
#include "V8Node.h"
#include "V8Proxy.h"
+#include "V8WebGLRenderingContext.h"
namespace WebCore {
@@ -77,10 +78,10 @@ v8::Handle<v8::Value> V8HTMLCanvasElement::getContextCallback(const v8::Argument
if (!result)
return v8::Undefined();
if (result->is2d())
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASRENDERINGCONTEXT2D, result);
+ return toV8(static_cast<CanvasRenderingContext2D*>(result));
#if ENABLE(3D_CANVAS)
else if (result->is3d())
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLRENDERINGCONTEXT, result);
+ return toV8(static_cast<WebGLRenderingContext*>(result));
#endif
ASSERT_NOT_REACHED();
return v8::Undefined();
diff --git a/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp
index 8bb3c3a..29ff6eb 100644
--- a/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp
@@ -34,7 +34,10 @@
#include "HTMLCollection.h"
#include "V8Binding.h"
#include "V8CustomBinding.h"
+#include "V8HTMLAllCollection.h"
#include "V8NamedNodesCollection.h"
+#include "V8Node.h"
+#include "V8NodeList.h"
#include "V8Proxy.h"
namespace WebCore {
@@ -48,10 +51,10 @@ static v8::Handle<v8::Value> getNamedItems(HTMLCollection* collection, AtomicStr
return v8::Handle<v8::Value>();
if (namedItems.size() == 1)
- return V8DOMWrapper::convertNodeToV8Object(namedItems.at(0).release());
+ return toV8(namedItems.at(0).release());
NodeList* list = new V8NamedNodesCollection(namedItems);
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODELIST, list);
+ return toV8(list);
}
static v8::Handle<v8::Value> getItem(HTMLCollection* collection, v8::Handle<v8::Value> argument)
@@ -67,7 +70,7 @@ static v8::Handle<v8::Value> getItem(HTMLCollection* collection, v8::Handle<v8::
}
RefPtr<Node> result = collection->item(index->Uint32Value());
- return V8DOMWrapper::convertNodeToV8Object(result.release());
+ return toV8(result.release());
}
v8::Handle<v8::Value> V8HTMLCollection::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
@@ -129,7 +132,7 @@ v8::Handle<v8::Value> V8HTMLCollection::callAsFunctionCallback(const v8::Argumen
Node* node = imp->namedItem(name);
while (node) {
if (!current)
- return V8DOMWrapper::convertNodeToV8Object(node);
+ return toV8(node);
node = imp->nextNamedItem(name);
current--;
@@ -138,4 +141,11 @@ v8::Handle<v8::Value> V8HTMLCollection::callAsFunctionCallback(const v8::Argumen
return v8::Undefined();
}
+v8::Handle<v8::Value> toV8(HTMLCollection* impl)
+{
+ if (impl->type() == DocAll)
+ return toV8(static_cast<HTMLAllCollection*>(impl));
+ return V8HTMLCollection::wrap(impl);
+}
+
} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp
index 13243ef..6478e07 100644
--- a/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp
@@ -38,6 +38,11 @@
#include "HTMLIFrameElement.h"
#include "HTMLNames.h"
#include "V8Binding.h"
+#include "V8DOMWindow.h"
+#include "V8HTMLAllCollection.h"
+#include "V8HTMLCollection.h"
+#include "V8IsolatedContext.h"
+#include "V8Node.h"
#include "V8Proxy.h"
#include <wtf/RefPtr.h>
#include <wtf/StdLibExtras.h>
@@ -91,12 +96,12 @@ v8::Handle<v8::Value> V8HTMLDocument::namedPropertyGetter(v8::Local<v8::String>
Node* node = items->firstItem();
Frame* frame = 0;
if (node->hasTagName(HTMLNames::iframeTag) && (frame = static_cast<HTMLIFrameElement*>(node)->contentFrame()))
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow());
+ return toV8(frame->domWindow());
- return V8DOMWrapper::convertNodeToV8Object(node);
+ return toV8(node);
}
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::HTMLCOLLECTION, items.release());
+ return toV8(items.release());
}
v8::Handle<v8::Value> V8HTMLDocument::indexedPropertyGetter(uint32_t index, const v8::AccessorInfo &info)
@@ -181,10 +186,9 @@ v8::Handle<v8::Value> V8HTMLDocument::openCallback(const v8::Arguments& args)
v8::Handle<v8::Value> V8HTMLDocument::allAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
INC_STATS("DOM.HTMLDocument.all._get");
- v8::HandleScope scope;
v8::Handle<v8::Object> holder = info.Holder();
HTMLDocument* htmlDocument = V8HTMLDocument::toNative(holder);
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::HTMLCOLLECTION, htmlDocument->all());
+ return toV8(htmlDocument->all());
}
void V8HTMLDocument::allAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
@@ -195,4 +199,22 @@ void V8HTMLDocument::allAccessorSetter(v8::Local<v8::String> name, v8::Local<v8:
info.Holder()->SetInternalField(V8HTMLDocument::shadowIndex, value);
}
+v8::Handle<v8::Value> toV8(HTMLDocument* impl, bool forceNewObject)
+{
+ if (!impl)
+ return v8::Null();
+ v8::Handle<v8::Object> wrapper = V8HTMLDocument::wrap(impl, forceNewObject);
+ if (!V8IsolatedContext::getEntered()) {
+ if (V8Proxy* proxy = V8Proxy::retrieve(impl->frame()))
+ proxy->windowShell()->updateDocumentWrapper(wrapper);
+ }
+ // Create marker object and insert it in two internal fields.
+ // This is used to implement temporary shadowing of document.all.
+ ASSERT(wrapper->InternalFieldCount() == V8HTMLDocument::internalFieldCount);
+ v8::Local<v8::Object> marker = v8::Object::New();
+ wrapper->SetInternalField(V8HTMLDocument::markerIndex, marker);
+ wrapper->SetInternalField(V8HTMLDocument::shadowIndex, marker);
+ return wrapper;
+}
+
} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8HTMLElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLElementCustom.cpp
new file mode 100644
index 0000000..0eb55e9
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8HTMLElementCustom.cpp
@@ -0,0 +1,45 @@
+/*
+ * 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 "V8HTMLElement.h"
+
+#include "V8HTMLElementWrapperFactory.h"
+
+namespace WebCore {
+
+v8::Handle<v8::Value> toV8(HTMLElement* impl, bool forceNewObject)
+{
+ if (!impl)
+ return v8::Null();
+ return createV8HTMLWrapper(impl, forceNewObject);
+}
+
+} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8HTMLFormElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLFormElementCustom.cpp
index d819e9b..0a9e8dd 100644
--- a/WebCore/bindings/v8/custom/V8HTMLFormElementCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLFormElementCustom.cpp
@@ -34,8 +34,9 @@
#include "HTMLCollection.h"
#include "HTMLFormElement.h"
#include "V8Binding.h"
-#include "V8CustomBinding.h"
#include "V8NamedNodesCollection.h"
+#include "V8Node.h"
+#include "V8NodeList.h"
#include "V8Proxy.h"
namespace WebCore {
@@ -48,7 +49,7 @@ v8::Handle<v8::Value> V8HTMLFormElement::indexedPropertyGetter(uint32_t index, c
RefPtr<Node> formElement = form->elements()->item(index);
if (!formElement)
return notHandledByInterceptor();
- return V8DOMWrapper::convertNodeToV8Object(formElement.release());
+ return toV8(formElement.release());
}
v8::Handle<v8::Value> V8HTMLFormElement::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
@@ -74,10 +75,10 @@ v8::Handle<v8::Value> V8HTMLFormElement::namedPropertyGetter(v8::Local<v8::Strin
ASSERT(!elements.isEmpty());
if (elements.size() == 1)
- return V8DOMWrapper::convertNodeToV8Object(elements.at(0).release());
+ return toV8(elements.at(0).release());
NodeList* collection = new V8NamedNodesCollection(elements);
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODELIST, collection);
+ return toV8(collection);
}
v8::Handle<v8::Value> V8HTMLFormElement::submitCallback(const v8::Arguments& args)
diff --git a/WebCore/bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp
index 214b11e..6a45be7 100644
--- a/WebCore/bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp
@@ -40,7 +40,7 @@
#include "Node.h"
#include "V8Binding.h"
-#include "V8CustomBinding.h"
+#include "V8DOMWindow.h"
#include "V8Proxy.h"
namespace WebCore {
@@ -55,7 +55,7 @@ v8::Handle<v8::Value> V8HTMLFrameSetElement::namedPropertyGetter(v8::Local<v8::S
if (!doc)
return v8::Undefined();
if (Frame* frame = doc->frame())
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow());
+ return toV8(frame->domWindow());
}
return notHandledByInterceptor();
}
diff --git a/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp b/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp
index 57efa34..2c28fa5 100644
--- a/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp
@@ -36,6 +36,7 @@
#include "Frame.h"
#include "HTMLNames.h"
#include "V8Binding.h"
+#include "V8Document.h"
#include "V8HTMLImageElement.h"
#include "V8Proxy.h"
@@ -78,7 +79,7 @@ v8::Handle<v8::Value> V8Custom::v8HTMLImageElementConstructorCallback(const v8::
// Make sure the document is added to the DOM Node map. Otherwise, the HTMLImageElement instance
// may end up being the only node in the map and get garbage-ccollected prematurely.
- V8DOMWrapper::convertNodeToV8Object(document);
+ toV8(document);
RefPtr<HTMLImageElement> image = new HTMLImageElement(HTMLNames::imgTag, document);
if (args.Length() > 0) {
diff --git a/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp
index c060df7..81bc287 100644
--- a/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp
@@ -37,9 +37,9 @@
#include "V8Binding.h"
#include "V8Collection.h"
-#include "V8CustomBinding.h"
#include "V8HTMLOptionElement.h"
#include "V8HTMLSelectElementCustom.h"
+#include "V8Node.h"
#include "V8Proxy.h"
namespace WebCore {
@@ -123,7 +123,7 @@ v8::Handle<v8::Value> V8HTMLOptionsCollection::indexedPropertyGetter(uint32_t in
if (!result)
return notHandledByInterceptor();
- return V8DOMWrapper::convertNodeToV8Object(result.release());
+ return toV8(result.release());
}
v8::Handle<v8::Value> V8HTMLOptionsCollection::indexedPropertySetter(uint32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
diff --git a/WebCore/bindings/v8/custom/V8HTMLSelectElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLSelectElementCustom.cpp
index 0904b3e..d0d8dac 100644
--- a/WebCore/bindings/v8/custom/V8HTMLSelectElementCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLSelectElementCustom.cpp
@@ -37,10 +37,11 @@
#include "V8Binding.h"
#include "V8Collection.h"
-#include "V8CustomBinding.h"
#include "V8HTMLOptionElement.h"
#include "V8HTMLSelectElement.h"
#include "V8NamedNodesCollection.h"
+#include "V8Node.h"
+#include "V8NodeList.h"
#include "V8Proxy.h"
namespace WebCore {
@@ -67,21 +68,20 @@ v8::Handle<v8::Value> V8HTMLSelectElement::namedPropertyGetter(v8::Local<v8::Str
return notHandledByInterceptor();
if (items.size() == 1)
- return V8DOMWrapper::convertNodeToV8Object(items.at(0).release());
+ return toV8(items.at(0).release());
NodeList* list = new V8NamedNodesCollection(items);
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODELIST, list);
+ return toV8(list);
}
v8::Handle<v8::Value> V8HTMLSelectElement::indexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
{
ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
- ASSERT(V8DOMWrapper::domWrapperType(info.Holder()) == V8ClassIndex::NODE);
RefPtr<Node> result = V8HTMLSelectElement::toNative(info.Holder())->item(index);
if (!result)
return notHandledByInterceptor();
- return V8DOMWrapper::convertNodeToV8Object(result.release());
+ return toV8(result.release());
}
v8::Handle<v8::Value> V8HTMLSelectElement::indexedPropertySetter(uint32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
diff --git a/WebCore/bindings/v8/custom/V8HistoryCustom.cpp b/WebCore/bindings/v8/custom/V8HistoryCustom.cpp
index b857d6e..5e9c7c8 100644
--- a/WebCore/bindings/v8/custom/V8HistoryCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HistoryCustom.cpp
@@ -37,6 +37,7 @@
#include "V8Binding.h"
#include "V8BindingState.h"
#include "V8CustomBinding.h"
+#include "V8DOMWindow.h"
#include "V8Proxy.h"
namespace WebCore {
@@ -99,4 +100,17 @@ bool V8History::namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Val
return V8BindingSecurity::canAccessFrame(V8BindingState::Only(), history->frame(), false);
}
+v8::Handle<v8::Value> toV8(History* impl)
+{
+ if (!impl)
+ return v8::Null();
+ v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(impl);
+ if (wrapper.IsEmpty()) {
+ wrapper = V8History::wrap(impl);
+ if (!wrapper.IsEmpty())
+ V8DOMWrapper::setHiddenWindowReference(impl->frame(), V8DOMWindow::historyIndex, wrapper);
+ }
+ return wrapper;
+}
+
} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8IDBRequestCustom.cpp b/WebCore/bindings/v8/custom/V8IDBRequestCustom.cpp
index 5ee9542..ccf4d0e 100644
--- a/WebCore/bindings/v8/custom/V8IDBRequestCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8IDBRequestCustom.cpp
@@ -29,6 +29,8 @@
*/
#include "config.h"
+
+#if ENABLE(INDEXED_DATABASE)
#include "V8IDBRequest.h"
#include "SerializedScriptValue.h"
@@ -47,3 +49,5 @@ v8::Handle<v8::Value> V8IDBRequest::resultAccessorGetter(v8::Local<v8::String> n
}
} // namespace WebCore
+
+#endif
diff --git a/WebCore/bindings/v8/custom/V8IndexedDatabaseRequestCustom.cpp b/WebCore/bindings/v8/custom/V8IndexedDatabaseRequestCustom.cpp
index 66220ea..0fd182c 100644
--- a/WebCore/bindings/v8/custom/V8IndexedDatabaseRequestCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8IndexedDatabaseRequestCustom.cpp
@@ -29,6 +29,8 @@
*/
#include "config.h"
+
+#if ENABLE(INDEXED_DATABASE)
#include "V8IndexedDatabaseRequest.h"
#include "V8Binding.h"
@@ -55,3 +57,5 @@ v8::Handle<v8::Value> V8IndexedDatabaseRequest::openCallback(const v8::Arguments
}
} // namespace WebCore
+
+#endif
diff --git a/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp b/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
index 0ddcf97..ad4ed01 100644
--- a/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
@@ -34,13 +34,13 @@
#include "DOMWindow.h"
#include "Database.h"
#include "Frame.h"
+#include "InjectedScript.h"
#include "InjectedScriptHost.h"
#include "InspectorController.h"
#include "Node.h"
#include "Page.h"
#include "V8Binding.h"
-#include "V8CustomBinding.h"
#include "V8Database.h"
#include "V8Node.h"
#include "V8Proxy.h"
@@ -85,7 +85,7 @@ static ScriptObject createInjectedScript(const String& scriptSource, InjectedScr
v8::Context::Scope contextScope(inspectedContext);
// Call custom code to create InjectedScripHost wrapper specific for the context
- // instead of calling V8DOMWrapper::convertToV8Object that would create the
+ // instead of calling toV8() that would create the
// wrapper in the current context.
// FIXME: make it possible to use generic bindings factory for InjectedScriptHost.
v8::Local<v8::Object> scriptHostWrapper = createInjectedScriptHostV8Wrapper(injectedScriptHost);
@@ -130,7 +130,7 @@ v8::Handle<v8::Value> V8InjectedScriptHost::nodeForIdCallback(const v8::Argument
if (!ic)
return v8::Undefined();
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODE, node);
+ return toV8(node);
}
v8::Handle<v8::Value> V8InjectedScriptHost::pushNodePathToFrontendCallback(const v8::Arguments& args)
@@ -160,7 +160,7 @@ v8::Handle<v8::Value> V8InjectedScriptHost::databaseForIdCallback(const v8::Argu
Database* database = host->databaseForId(args[0]->ToInt32()->Value());
if (!database)
return v8::Undefined();
- return V8DOMWrapper::convertToV8Object<Database>(V8ClassIndex::DATABASE, database);
+ return toV8(database);
}
v8::Handle<v8::Value> V8InjectedScriptHost::selectDatabaseCallback(const v8::Arguments& args)
@@ -194,7 +194,7 @@ v8::Handle<v8::Value> V8InjectedScriptHost::selectDOMStorageCallback(const v8::A
}
#endif
-ScriptObject InjectedScriptHost::injectedScriptFor(ScriptState* inspectedScriptState)
+InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState* inspectedScriptState)
{
v8::HandleScope handleScope;
v8::Local<v8::Context> context = inspectedScriptState->context();
@@ -208,14 +208,15 @@ ScriptObject InjectedScriptHost::injectedScriptFor(ScriptState* inspectedScriptS
v8::Local<v8::String> key = v8::String::New("Devtools_InjectedScript");
v8::Local<v8::Value> val = global->GetHiddenValue(key);
if (!val.IsEmpty() && val->IsObject())
- return ScriptObject(inspectedScriptState, v8::Local<v8::Object>::Cast(val));
+ return InjectedScript(ScriptObject(inspectedScriptState, v8::Local<v8::Object>::Cast(val)));
ASSERT(!m_injectedScriptSource.isEmpty());
ScriptObject injectedScriptObject = createInjectedScript(m_injectedScriptSource, this, inspectedScriptState, m_nextInjectedScriptId);
- m_idToInjectedScript.set(m_nextInjectedScriptId, injectedScriptObject);
+ InjectedScript result(injectedScriptObject);
+ m_idToInjectedScript.set(m_nextInjectedScriptId, result);
++m_nextInjectedScriptId;
global->SetHiddenValue(key, injectedScriptObject.v8Object());
- return injectedScriptObject;
+ return result;
}
} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8LocationCustom.cpp b/WebCore/bindings/v8/custom/V8LocationCustom.cpp
index ce816b6..7c9c529 100644
--- a/WebCore/bindings/v8/custom/V8LocationCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8LocationCustom.cpp
@@ -43,6 +43,7 @@
#include "V8BindingState.h"
#include "V8CustomBinding.h"
#include "V8CustomEventListener.h"
+#include "V8DOMWindow.h"
#include "V8Location.h"
#include "V8Utilities.h"
#include "V8Proxy.h"
@@ -358,5 +359,18 @@ bool V8Location::namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Va
return V8BindingSecurity::canAccessFrame(V8BindingState::Only(), imp->frame(), false);
}
+v8::Handle<v8::Value> toV8(Location* impl)
+{
+ if (!impl)
+ return v8::Null();
+ v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(impl);
+ if (wrapper.IsEmpty()) {
+ wrapper = V8Location::wrap(impl);
+ if (!wrapper.IsEmpty())
+ V8DOMWrapper::setHiddenWindowReference(impl->frame(), V8DOMWindow::locationIndex, wrapper);
+ }
+ return wrapper;
+}
+
} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp b/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp
index 3ea8e26..4fb82ba 100644
--- a/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp
+++ b/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp
@@ -35,6 +35,7 @@
#include "Frame.h"
#include "MessageChannel.h"
#include "V8Binding.h"
+#include "V8MessagePort.h"
#include "V8Proxy.h"
#include "V8Utilities.h"
#include "WorkerContext.h"
@@ -66,8 +67,8 @@ v8::Handle<v8::Value> V8MessageChannel::constructorCallback(const v8::Arguments&
// Create references from the MessageChannel wrapper to the two
// MessagePort wrappers to make sure that the MessagePort wrappers
// stay alive as long as the MessageChannel wrapper is around.
- messageChannel->SetInternalField(V8MessageChannel::port1Index, V8DOMWrapper::convertToV8Object(V8ClassIndex::MESSAGEPORT, obj->port1()));
- messageChannel->SetInternalField(V8MessageChannel::port2Index, V8DOMWrapper::convertToV8Object(V8ClassIndex::MESSAGEPORT, obj->port2()));
+ messageChannel->SetInternalField(V8MessageChannel::port1Index, toV8(obj->port1()));
+ messageChannel->SetInternalField(V8MessageChannel::port2Index, toV8(obj->port2()));
// Setup the standard wrapper object internal fields.
V8DOMWrapper::setDOMWrapper(messageChannel, V8ClassIndex::MESSAGECHANNEL, obj.get());
diff --git a/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp b/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp
index 9e40855..9f2c080 100644
--- a/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp
@@ -35,8 +35,8 @@
#include "SerializedScriptValue.h"
#include "V8Binding.h"
-#include "V8CustomBinding.h"
#include "V8DOMWindow.h"
+#include "V8MessagePort.h"
#include "V8MessagePortCustom.h"
#include "V8Proxy.h"
@@ -53,7 +53,7 @@ v8::Handle<v8::Value> V8MessageEvent::portsAccessorGetter(v8::Local<v8::String>
v8::Local<v8::Array> portArray = v8::Array::New(ports->size());
for (size_t i = 0; i < ports->size(); ++i)
- portArray->Set(v8::Integer::New(i), V8DOMWrapper::convertToV8Object(V8ClassIndex::MESSAGEPORT, (*ports)[i].get()));
+ portArray->Set(v8::Integer::New(i), toV8((*ports)[i].get()));
return portArray;
}
diff --git a/WebCore/bindings/v8/custom/V8NamedNodeMapCustom.cpp b/WebCore/bindings/v8/custom/V8NamedNodeMapCustom.cpp
index c7fff5a..611ab94 100644
--- a/WebCore/bindings/v8/custom/V8NamedNodeMapCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8NamedNodeMapCustom.cpp
@@ -33,7 +33,8 @@
#include "NamedNodeMap.h"
#include "V8Binding.h"
-#include "V8CustomBinding.h"
+#include "V8Element.h"
+#include "V8Node.h"
#include "V8Proxy.h"
#include <wtf/RefPtr.h>
@@ -48,7 +49,7 @@ v8::Handle<v8::Value> V8NamedNodeMap::indexedPropertyGetter(uint32_t index, cons
if (!result)
return notHandledByInterceptor();
- return V8DOMWrapper::convertNodeToV8Object(result.release());
+ return toV8(result.release());
}
v8::Handle<v8::Value> V8NamedNodeMap::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
@@ -69,7 +70,21 @@ v8::Handle<v8::Value> V8NamedNodeMap::namedPropertyGetter(v8::Local<v8::String>
if (!result)
return notHandledByInterceptor();
- return V8DOMWrapper::convertNodeToV8Object(result.release());
+ return toV8(result.release());
+}
+
+v8::Handle<v8::Value> toV8(NamedNodeMap* impl)
+{
+ if (!impl)
+ return v8::Null();
+ v8::Handle<v8::Object> wrapper = V8NamedNodeMap::wrap(impl);
+ // Add a hidden reference from named node map to its owner node.
+ Element* element = impl->element();
+ if (!wrapper.IsEmpty() && element) {
+ v8::Handle<v8::Value> owner = toV8(element);
+ wrapper->SetInternalField(V8NamedNodeMap::ownerNodeIndex, owner);
+ }
+ return wrapper;
}
} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8NavigatorCustom.cpp b/WebCore/bindings/v8/custom/V8NavigatorCustom.cpp
index ec5c1dc..22e84c9 100644
--- a/WebCore/bindings/v8/custom/V8NavigatorCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8NavigatorCustom.cpp
@@ -33,12 +33,17 @@
#include "ExceptionCode.h"
#include "RuntimeEnabledFeatures.h"
+<<<<<<< HEAD
#include "V8Binding.h"
#include "V8Proxy.h"
#if PLATFORM(ANDROID)
#include "V8CustomApplicationInstalledCallback.h"
#endif
+=======
+#include "V8DOMWindow.h"
+#include "V8DOMWrapper.h"
+>>>>>>> webkit.org at r54340
namespace WebCore {
@@ -49,6 +54,7 @@ bool V8Navigator::GeolocationEnabled()
}
#endif
+<<<<<<< HEAD
#if PLATFORM(ANDROID) && ENABLE(APPLICATION_INSTALLED)
static PassRefPtr<ApplicationInstalledCallback> createApplicationInstalledCallback(
@@ -93,4 +99,19 @@ v8::Handle<v8::Value> V8Navigator::isApplicationInstalledCallback(const v8::Argu
#endif // PLATFORM(ANDROID) && ENABLE(APPLICATION_INSTALLED)
+=======
+v8::Handle<v8::Value> toV8(Navigator* impl)
+{
+ if (!impl)
+ return v8::Null();
+ v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(impl);
+ if (wrapper.IsEmpty()) {
+ wrapper = V8Navigator::wrap(impl);
+ if (!wrapper.IsEmpty())
+ V8DOMWrapper::setHiddenWindowReference(impl->frame(), V8DOMWindow::navigatorIndex, wrapper);
+ }
+ return wrapper;
+}
+
+>>>>>>> webkit.org at r54340
} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8NodeCustom.cpp b/WebCore/bindings/v8/custom/V8NodeCustom.cpp
index 79afbe8..06489fd 100644
--- a/WebCore/bindings/v8/custom/V8NodeCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8NodeCustom.cpp
@@ -35,11 +35,23 @@
#include "EventListener.h"
#include "V8AbstractEventListener.h"
+#include "V8Attr.h"
#include "V8Binding.h"
+#include "V8CDATASection.h"
+#include "V8Comment.h"
#include "V8CustomBinding.h"
#include "V8CustomEventListener.h"
+#include "V8Document.h"
+#include "V8DocumentFragment.h"
+#include "V8DocumentType.h"
+#include "V8Element.h"
+#include "V8Entity.h"
+#include "V8EntityReference.h"
#include "V8Node.h"
+#include "V8Notation.h"
+#include "V8ProcessingInstruction.h"
#include "V8Proxy.h"
+#include "V8Text.h"
#include <wtf/RefPtr.h>
@@ -152,4 +164,43 @@ v8::Handle<v8::Value> V8Node::appendChildCallback(const v8::Arguments& args)
return v8::Null();
}
+v8::Handle<v8::Value> toV8(Node* impl, bool forceNewObject)
+{
+ if (!impl)
+ return v8::Null();
+
+ if (!forceNewObject) {
+ v8::Handle<v8::Value> wrapper = V8DOMWrapper::getWrapper(impl);
+ if (!wrapper.IsEmpty())
+ return wrapper;
+ }
+ switch (impl->nodeType()) {
+ case Node::ELEMENT_NODE:
+ return toV8(static_cast<Element*>(impl), forceNewObject);
+ case Node::ATTRIBUTE_NODE:
+ return toV8(static_cast<Attr*>(impl), forceNewObject);
+ case Node::TEXT_NODE:
+ return toV8(static_cast<Text*>(impl), forceNewObject);
+ case Node::CDATA_SECTION_NODE:
+ return toV8(static_cast<CDATASection*>(impl), forceNewObject);
+ case Node::ENTITY_REFERENCE_NODE:
+ return toV8(static_cast<EntityReference*>(impl), forceNewObject);
+ case Node::ENTITY_NODE:
+ return toV8(static_cast<Entity*>(impl), forceNewObject);
+ case Node::PROCESSING_INSTRUCTION_NODE:
+ return toV8(static_cast<ProcessingInstruction*>(impl), forceNewObject);
+ case Node::COMMENT_NODE:
+ return toV8(static_cast<Comment*>(impl), forceNewObject);
+ case Node::DOCUMENT_NODE:
+ return toV8(static_cast<Document*>(impl), forceNewObject);
+ case Node::DOCUMENT_TYPE_NODE:
+ return toV8(static_cast<DocumentType*>(impl), forceNewObject);
+ case Node::DOCUMENT_FRAGMENT_NODE:
+ return toV8(static_cast<DocumentFragment*>(impl), forceNewObject);
+ case Node::NOTATION_NODE:
+ return toV8(static_cast<Notation*>(impl), forceNewObject);
+ default: break; // XPATH_NAMESPACE_NODE
+ }
+ return V8Node::wrap(impl, forceNewObject);
+}
} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8NodeIteratorCustom.cpp b/WebCore/bindings/v8/custom/V8NodeIteratorCustom.cpp
index 074eac3..728b3dc 100644
--- a/WebCore/bindings/v8/custom/V8NodeIteratorCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8NodeIteratorCustom.cpp
@@ -35,7 +35,7 @@
#include "ScriptState.h"
#include "V8Binding.h"
-#include "V8CustomBinding.h"
+#include "V8Node.h"
#include "V8Proxy.h"
#include <wtf/PassRefPtr.h>
@@ -54,7 +54,7 @@ static inline v8::Handle<v8::Value> toV8(PassRefPtr<Node> object, ExceptionCode
if (!object)
return v8::Null();
- return V8DOMWrapper::convertNodeToV8Object(object);
+ return toV8(object);
}
v8::Handle<v8::Value> V8NodeIterator::nextNodeCallback(const v8::Arguments& args)
diff --git a/WebCore/bindings/v8/custom/V8NodeListCustom.cpp b/WebCore/bindings/v8/custom/V8NodeListCustom.cpp
index 5721a7e..20a5471 100644
--- a/WebCore/bindings/v8/custom/V8NodeListCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8NodeListCustom.cpp
@@ -32,9 +32,8 @@
#include "V8NodeList.h"
#include "NodeList.h"
-
#include "V8Binding.h"
-#include "V8CustomBinding.h"
+#include "V8Node.h"
#include "V8Proxy.h"
#include <wtf/RefPtr.h>
@@ -57,7 +56,7 @@ v8::Handle<v8::Value> V8NodeList::namedPropertyGetter(v8::Local<v8::String> name
if (!result)
return notHandledByInterceptor();
- return V8DOMWrapper::convertNodeToV8Object(result.release());
+ return toV8(result.release());
}
// Need to support call so that list(0) works.
@@ -75,7 +74,7 @@ v8::Handle<v8::Value> V8NodeList::callAsFunctionCallback(const v8::Arguments& ar
return v8::Undefined();
RefPtr<Node> result = list->item(index->Uint32Value());
- return V8DOMWrapper::convertNodeToV8Object(result.release());
+ return toV8(result.release());
}
} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp b/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp
index 1cb4554..5531b48 100644
--- a/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp
@@ -37,7 +37,6 @@
#include "Notification.h"
#include "NotificationCenter.h"
#include "V8Binding.h"
-#include "V8CustomBinding.h"
#include "V8CustomEventListener.h"
#include "V8CustomVoidCallback.h"
#include "V8Notification.h"
@@ -95,7 +94,7 @@ v8::Handle<v8::Value> V8NotificationCenter::createHTMLNotificationCallback(const
if (notificationCenter->context()->isWorkerContext())
return WorkerContextExecutionProxy::convertToV8Object(V8ClassIndex::NOTIFICATION, notification.get());
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::NOTIFICATION, notification.get());
+ return toV8(notification.get());
}
v8::Handle<v8::Value> V8NotificationCenter::createNotificationCallback(const v8::Arguments& args)
@@ -112,7 +111,7 @@ v8::Handle<v8::Value> V8NotificationCenter::createNotificationCallback(const v8:
if (notificationCenter->context()->isWorkerContext())
return WorkerContextExecutionProxy::convertToV8Object(V8ClassIndex::NOTIFICATION, notification.get());
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::NOTIFICATION, notification.get());
+ return toV8(notification.get());
}
v8::Handle<v8::Value> V8NotificationCenter::requestPermissionCallback(const v8::Arguments& args)
diff --git a/WebCore/bindings/v8/custom/V8SVGDocumentCustom.cpp b/WebCore/bindings/v8/custom/V8SVGDocumentCustom.cpp
new file mode 100644
index 0000000..4cefc0e
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8SVGDocumentCustom.cpp
@@ -0,0 +1,51 @@
+/*
+ * 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 "V8SVGDocument.h"
+
+#include "V8IsolatedContext.h"
+#include "V8Proxy.h"
+
+namespace WebCore {
+
+v8::Handle<v8::Value> toV8(SVGDocument* impl, bool forceNewObject)
+{
+ if (!impl)
+ return v8::Null();
+ v8::Handle<v8::Object> wrapper = V8SVGDocument::wrap(impl, forceNewObject);
+ if (!V8IsolatedContext::getEntered()) {
+ if (V8Proxy* proxy = V8Proxy::retrieve(impl->frame()))
+ proxy->windowShell()->updateDocumentWrapper(wrapper);
+ }
+ return wrapper;
+}
+
+} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8SVGElementCustom.cpp b/WebCore/bindings/v8/custom/V8SVGElementCustom.cpp
new file mode 100644
index 0000000..0ce48ce
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8SVGElementCustom.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms") return toV8(static_cast<SVGwith or without
+ * modification") return toV8(static_cast<SVGare permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice") return toV8(static_cast<SVGthis list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice") return toV8(static_cast<SVGthis 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") return toV8(static_cast<SVGINCLUDING") return toV8(static_cast<SVGBUT NOT
+ * LIMITED TO") return toV8(static_cast<SVGTHE 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") return toV8(static_cast<SVGINDIRECT") return toV8(static_cast<SVGINCIDENTAL,
+ * SPECIAL") return toV8(static_cast<SVGEXEMPLARY") return toV8(static_cast<SVGOR CONSEQUENTIAL DAMAGES (INCLUDING") return toV8(static_cast<SVGBUT NOT
+ * LIMITED TO") return toV8(static_cast<SVGPROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA") return toV8(static_cast<SVGOR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY") return toV8(static_cast<SVGWHETHER IN CONTRACT") return toV8(static_cast<SVGSTRICT LIABILITY") return toV8(static_cast<SVGOR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE") return toV8(static_cast<SVGEVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "V8SVGElement.h"
+
+#if ENABLE(SVG)
+
+#include "V8SVGElementWrapperFactory.h"
+
+namespace WebCore {
+
+v8::Handle<v8::Value> toV8(SVGElement* impl, bool forceNewObject)
+{
+ if (!impl)
+ return v8::Null();
+ return createV8SVGWrapper(impl, forceNewObject);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/bindings/v8/custom/V8SVGMatrixCustom.cpp b/WebCore/bindings/v8/custom/V8SVGMatrixCustom.cpp
index 78284cd..0a75c9f 100644
--- a/WebCore/bindings/v8/custom/V8SVGMatrixCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8SVGMatrixCustom.cpp
@@ -31,16 +31,13 @@
#include <config.h>
#if ENABLE(SVG)
-
#include "TransformationMatrix.h"
#include "SVGException.h"
-
#include "V8Binding.h"
-#include "V8CustomBinding.h"
+#include "V8Proxy.h"
#include "V8SVGMatrix.h"
#include "V8SVGPODTypeWrapper.h"
-#include "V8Proxy.h"
namespace WebCore {
@@ -56,7 +53,8 @@ v8::Handle<v8::Value> V8SVGMatrix::multiplyCallback(const v8::Arguments& args)
TransformationMatrix m1 = *V8SVGPODTypeWrapper<TransformationMatrix>::toNative(args.Holder());
TransformationMatrix m2 = *V8SVGPODTypeWrapper<TransformationMatrix>::toNative(v8::Handle<v8::Object>::Cast(args[0]));
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::SVGMATRIX, V8SVGStaticPODTypeWrapper<TransformationMatrix>::create(m1.multLeft(m2)));
+ RefPtr<V8SVGStaticPODTypeWrapper<TransformationMatrix> > wrapper = V8SVGStaticPODTypeWrapper<TransformationMatrix>::create(m1.multLeft(m2));
+ return toV8(wrapper.get());
}
v8::Handle<v8::Value> V8SVGMatrix::inverseCallback(const v8::Arguments& args)
@@ -74,7 +72,8 @@ v8::Handle<v8::Value> V8SVGMatrix::inverseCallback(const v8::Arguments& args)
return v8::Handle<v8::Value>();
}
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::SVGMATRIX, V8SVGStaticPODTypeWrapper<TransformationMatrix>::create(result));
+ RefPtr<V8SVGStaticPODTypeWrapper<TransformationMatrix> > wrapper = V8SVGStaticPODTypeWrapper<TransformationMatrix>::create(result);
+ return toV8(wrapper.get());
}
v8::Handle<v8::Value> V8SVGMatrix::rotateFromVectorCallback(const v8::Arguments& args)
@@ -94,7 +93,8 @@ v8::Handle<v8::Value> V8SVGMatrix::rotateFromVectorCallback(const v8::Arguments&
return v8::Handle<v8::Value>();
}
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::SVGMATRIX, V8SVGStaticPODTypeWrapper<TransformationMatrix>::create(result));
+ RefPtr<V8SVGStaticPODTypeWrapper<TransformationMatrix> > wrapper = V8SVGStaticPODTypeWrapper<TransformationMatrix>::create(result);
+ return toV8(wrapper.get());
}
} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8SVGPathSegCustom.cpp b/WebCore/bindings/v8/custom/V8SVGPathSegCustom.cpp
new file mode 100644
index 0000000..a96d55e
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8SVGPathSegCustom.cpp
@@ -0,0 +1,106 @@
+/*
+ * 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 "V8SVGPathSeg.h"
+
+#include "V8DOMWindow.h"
+#include "V8DOMWrapper.h"
+#include "V8SVGPathSegArcAbs.h"
+#include "V8SVGPathSegArcRel.h"
+#include "V8SVGPathSegClosePath.h"
+#include "V8SVGPathSegCurvetoCubicAbs.h"
+#include "V8SVGPathSegCurvetoCubicRel.h"
+#include "V8SVGPathSegCurvetoCubicSmoothAbs.h"
+#include "V8SVGPathSegCurvetoCubicSmoothRel.h"
+#include "V8SVGPathSegCurvetoQuadraticAbs.h"
+#include "V8SVGPathSegCurvetoQuadraticRel.h"
+#include "V8SVGPathSegCurvetoQuadraticSmoothAbs.h"
+#include "V8SVGPathSegCurvetoQuadraticSmoothRel.h"
+#include "V8SVGPathSegLinetoAbs.h"
+#include "V8SVGPathSegLinetoHorizontalAbs.h"
+#include "V8SVGPathSegLinetoHorizontalRel.h"
+#include "V8SVGPathSegLinetoRel.h"
+#include "V8SVGPathSegLinetoVerticalAbs.h"
+#include "V8SVGPathSegLinetoVerticalRel.h"
+#include "V8SVGPathSegMovetoAbs.h"
+#include "V8SVGPathSegMovetoRel.h"
+
+namespace WebCore {
+
+v8::Handle<v8::Value> toV8(SVGPathSeg* impl)
+{
+ if (!impl)
+ return v8::Null();
+ switch (impl->pathSegType()) {
+ case SVGPathSeg::PATHSEG_CLOSEPATH:
+ return toV8(static_cast<SVGPathSegClosePath*>(impl));
+ case SVGPathSeg::PATHSEG_MOVETO_ABS:
+ return toV8(static_cast<SVGPathSegMovetoAbs*>(impl));
+ case SVGPathSeg::PATHSEG_MOVETO_REL:
+ return toV8(static_cast<SVGPathSegMovetoRel*>(impl));
+ case SVGPathSeg::PATHSEG_LINETO_ABS:
+ return toV8(static_cast<SVGPathSegLinetoAbs*>(impl));
+ case SVGPathSeg::PATHSEG_LINETO_REL:
+ return toV8(static_cast<SVGPathSegLinetoRel*>(impl));
+ case SVGPathSeg::PATHSEG_CURVETO_CUBIC_ABS:
+ return toV8(static_cast<SVGPathSegCurvetoCubicAbs*>(impl));
+ case SVGPathSeg::PATHSEG_CURVETO_CUBIC_REL:
+ return toV8(static_cast<SVGPathSegCurvetoCubicRel*>(impl));
+ case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_ABS:
+ return toV8(static_cast<SVGPathSegCurvetoQuadraticAbs*>(impl));
+ case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_REL:
+ return toV8(static_cast<SVGPathSegCurvetoQuadraticRel*>(impl));
+ case SVGPathSeg::PATHSEG_ARC_ABS:
+ return toV8(static_cast<SVGPathSegArcAbs*>(impl));
+ case SVGPathSeg::PATHSEG_ARC_REL:
+ return toV8(static_cast<SVGPathSegArcRel*>(impl));
+ case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_ABS:
+ return toV8(static_cast<SVGPathSegLinetoHorizontalAbs*>(impl));
+ case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_REL:
+ return toV8(static_cast<SVGPathSegLinetoHorizontalRel*>(impl));
+ case SVGPathSeg::PATHSEG_LINETO_VERTICAL_ABS:
+ return toV8(static_cast<SVGPathSegLinetoVerticalAbs*>(impl));
+ case SVGPathSeg::PATHSEG_LINETO_VERTICAL_REL:
+ return toV8(static_cast<SVGPathSegLinetoVerticalRel*>(impl));
+ case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:
+ return toV8(static_cast<SVGPathSegCurvetoCubicSmoothAbs*>(impl));
+ case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_REL:
+ return toV8(static_cast<SVGPathSegCurvetoCubicSmoothRel*>(impl));
+ case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:
+ return toV8(static_cast<SVGPathSegCurvetoQuadraticSmoothAbs*>(impl));
+ case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:
+ return toV8(static_cast<SVGPathSegCurvetoQuadraticSmoothRel*>(impl));
+ }
+ ASSERT_NOT_REACHED();
+ return V8SVGPathSeg::wrap(impl);
+}
+
+} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8ScreenCustom.cpp b/WebCore/bindings/v8/custom/V8ScreenCustom.cpp
new file mode 100644
index 0000000..98d9dd7
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8ScreenCustom.cpp
@@ -0,0 +1,52 @@
+/*
+ * 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 "V8Screen.h"
+
+#include "V8DOMWindow.h"
+#include "V8DOMWrapper.h"
+
+namespace WebCore {
+
+v8::Handle<v8::Value> toV8(Screen* impl)
+{
+ if (!impl)
+ return v8::Null();
+ v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(impl);
+ if (wrapper.IsEmpty()) {
+ wrapper = V8Screen::wrap(impl);
+ if (!wrapper.IsEmpty())
+ V8DOMWrapper::setHiddenWindowReference(impl->frame(), V8DOMWindow::screenIndex, wrapper);
+ }
+ return wrapper;
+}
+
+} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8StyleSheetCustom.cpp b/WebCore/bindings/v8/custom/V8StyleSheetCustom.cpp
new file mode 100644
index 0000000..b062cdc
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8StyleSheetCustom.cpp
@@ -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.
+ */
+
+#include "config.h"
+#include "V8StyleSheet.h"
+
+#include "V8CSSStyleSheet.h"
+#include "V8Node.h"
+
+namespace WebCore {
+
+v8::Handle<v8::Value> toV8(StyleSheet* impl)
+{
+ if (!impl)
+ return v8::Null();
+ if (impl->isCSSStyleSheet())
+ return toV8(static_cast<CSSStyleSheet*>(impl));
+ v8::Handle<v8::Object> wrapper = V8StyleSheet::wrap(impl);
+ // Add a hidden reference from stylesheet object to its owner node.
+ Node* ownerNode = impl->ownerNode();
+ if (ownerNode && !wrapper.IsEmpty()) {
+ v8::Handle<v8::Object> owner = v8::Handle<v8::Object>::Cast(toV8(ownerNode));
+ wrapper->SetInternalField(V8StyleSheet::ownerNodeIndex, owner);
+ }
+ return wrapper;
+}
+
+} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8StyleSheetListCustom.cpp b/WebCore/bindings/v8/custom/V8StyleSheetListCustom.cpp
index a718451..cee1838 100644
--- a/WebCore/bindings/v8/custom/V8StyleSheetListCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8StyleSheetListCustom.cpp
@@ -34,8 +34,8 @@
#include "HTMLStyleElement.h"
#include "StyleSheetList.h"
#include "V8Binding.h"
-#include "V8CustomBinding.h"
#include "V8Proxy.h"
+#include "V8StyleSheet.h"
namespace WebCore {
@@ -52,7 +52,7 @@ v8::Handle<v8::Value> V8StyleSheetList::namedPropertyGetter(v8::Local<v8::String
if (!item)
return notHandledByInterceptor();
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::STYLESHEET, item->sheet());
+ return toV8(item->sheet());
}
} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8TreeWalkerCustom.cpp b/WebCore/bindings/v8/custom/V8TreeWalkerCustom.cpp
index b848197..37087df 100644
--- a/WebCore/bindings/v8/custom/V8TreeWalkerCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8TreeWalkerCustom.cpp
@@ -36,7 +36,7 @@
#include "TreeWalker.h"
#include "V8Binding.h"
-#include "V8CustomBinding.h"
+#include "V8Node.h"
#include "V8Proxy.h"
#include <wtf/PassRefPtr.h>
@@ -44,7 +44,7 @@
namespace WebCore {
-static inline v8::Handle<v8::Value> toV8(PassRefPtr<Node> object, ScriptState* state)
+static inline v8::Handle<v8::Value> toV8Object(PassRefPtr<Node> object, ScriptState* state)
{
if (state->hadException())
return throwError(state->exception());
@@ -52,7 +52,7 @@ static inline v8::Handle<v8::Value> toV8(PassRefPtr<Node> object, ScriptState* s
if (!object)
return v8::Null();
- return V8DOMWrapper::convertNodeToV8Object(object);
+ return toV8(object);
}
v8::Handle<v8::Value> V8TreeWalker::parentNodeCallback(const v8::Arguments& args)
@@ -62,7 +62,7 @@ v8::Handle<v8::Value> V8TreeWalker::parentNodeCallback(const v8::Arguments& args
EmptyScriptState state;
RefPtr<Node> result = treeWalker->parentNode(&state);
- return toV8(result.release(), &state);
+ return toV8Object(result.release(), &state);
}
v8::Handle<v8::Value> V8TreeWalker::firstChildCallback(const v8::Arguments& args)
@@ -72,7 +72,7 @@ v8::Handle<v8::Value> V8TreeWalker::firstChildCallback(const v8::Arguments& args
EmptyScriptState state;
RefPtr<Node> result = treeWalker->firstChild(&state);
- return toV8(result.release(), &state);
+ return toV8Object(result.release(), &state);
}
v8::Handle<v8::Value> V8TreeWalker::lastChildCallback(const v8::Arguments& args)
@@ -82,7 +82,7 @@ v8::Handle<v8::Value> V8TreeWalker::lastChildCallback(const v8::Arguments& args)
EmptyScriptState state;
RefPtr<Node> result = treeWalker->lastChild(&state);
- return toV8(result.release(), &state);
+ return toV8Object(result.release(), &state);
}
v8::Handle<v8::Value> V8TreeWalker::nextNodeCallback(const v8::Arguments& args)
@@ -92,7 +92,7 @@ v8::Handle<v8::Value> V8TreeWalker::nextNodeCallback(const v8::Arguments& args)
EmptyScriptState state;
RefPtr<Node> result = treeWalker->nextNode(&state);
- return toV8(result.release(), &state);
+ return toV8Object(result.release(), &state);
}
v8::Handle<v8::Value> V8TreeWalker::previousNodeCallback(const v8::Arguments& args)
@@ -102,7 +102,7 @@ v8::Handle<v8::Value> V8TreeWalker::previousNodeCallback(const v8::Arguments& ar
EmptyScriptState state;
RefPtr<Node> result = treeWalker->previousNode(&state);
- return toV8(result.release(), &state);
+ return toV8Object(result.release(), &state);
}
v8::Handle<v8::Value> V8TreeWalker::nextSiblingCallback(const v8::Arguments& args)
@@ -112,7 +112,7 @@ v8::Handle<v8::Value> V8TreeWalker::nextSiblingCallback(const v8::Arguments& arg
EmptyScriptState state;
RefPtr<Node> result = treeWalker->nextSibling(&state);
- return toV8(result.release(), &state);
+ return toV8Object(result.release(), &state);
}
v8::Handle<v8::Value> V8TreeWalker::previousSiblingCallback(const v8::Arguments& args)
@@ -122,7 +122,7 @@ v8::Handle<v8::Value> V8TreeWalker::previousSiblingCallback(const v8::Arguments&
EmptyScriptState state;
RefPtr<Node> result = treeWalker->previousSibling(&state);
- return toV8(result.release(), &state);
+ return toV8Object(result.release(), &state);
}
} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8WebGLArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLArrayCustom.cpp
new file mode 100644
index 0000000..a92e4f2
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8WebGLArrayCustom.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+#include "V8WebGLArray.h"
+
+#include "V8WebGLByteArray.h"
+#include "V8WebGLFloatArray.h"
+#include "V8WebGLIntArray.h"
+#include "V8WebGLShortArray.h"
+#include "V8WebGLUnsignedByteArray.h"
+#include "V8WebGLUnsignedIntArray.h"
+#include "V8WebGLUnsignedShortArray.h"
+
+namespace WebCore {
+
+v8::Handle<v8::Value> toV8(WebGLArray* impl)
+{
+ if (!impl)
+ return v8::Null();
+ if (impl->isByteArray())
+ return toV8(static_cast<WebGLByteArray*>(impl));
+ if (impl->isFloatArray())
+ return toV8(static_cast<WebGLFloatArray*>(impl));
+ if (impl->isIntArray())
+ return toV8(static_cast<WebGLIntArray*>(impl));
+ if (impl->isShortArray())
+ return toV8(static_cast<WebGLShortArray*>(impl));
+ if (impl->isUnsignedByteArray())
+ return toV8(static_cast<WebGLUnsignedByteArray*>(impl));
+ if (impl->isUnsignedIntArray())
+ return toV8(static_cast<WebGLUnsignedIntArray*>(impl));
+ if (impl->isUnsignedShortArray())
+ return toV8(static_cast<WebGLUnsignedShortArray*>(impl));
+ return v8::Handle<v8::Value>();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8WebGLByteArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLByteArrayCustom.cpp
index 6d52c83..95f6879 100644
--- a/WebCore/bindings/v8/custom/V8WebGLByteArrayCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLByteArrayCustom.cpp
@@ -63,6 +63,16 @@ v8::Handle<v8::Value> V8WebGLByteArray::setCallback(const v8::Arguments& args)
return setWebGLArray<WebGLByteArray, V8WebGLByteArray>(args, V8ClassIndex::WEBGLBYTEARRAY);
}
+v8::Handle<v8::Value> toV8(WebGLByteArray* impl)
+{
+ if (!impl)
+ return v8::Null();
+ v8::Handle<v8::Object> wrapper = V8WebGLByteArray::wrap(impl);
+ if (!wrapper.IsEmpty())
+ wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalByteArray, impl->length());
+ return wrapper;
+}
+
} // namespace WebCore
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8WebGLFloatArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLFloatArrayCustom.cpp
index 4d4b0e2..5882450 100644
--- a/WebCore/bindings/v8/custom/V8WebGLFloatArrayCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLFloatArrayCustom.cpp
@@ -63,6 +63,16 @@ v8::Handle<v8::Value> V8WebGLFloatArray::setCallback(const v8::Arguments& args)
return setWebGLArray<WebGLFloatArray, V8WebGLFloatArray>(args, V8ClassIndex::WEBGLFLOATARRAY);
}
+v8::Handle<v8::Value> toV8(WebGLFloatArray* impl)
+{
+ if (!impl)
+ return v8::Null();
+ v8::Handle<v8::Object> wrapper = V8WebGLFloatArray::wrap(impl);
+ if (!wrapper.IsEmpty())
+ wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalFloatArray, impl->length());
+ return wrapper;
+}
+
} // namespace WebCore
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8WebGLIntArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLIntArrayCustom.cpp
index 7dde0a0..7e2f2ed 100644
--- a/WebCore/bindings/v8/custom/V8WebGLIntArrayCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLIntArrayCustom.cpp
@@ -63,6 +63,16 @@ v8::Handle<v8::Value> V8WebGLIntArray::setCallback(const v8::Arguments& args)
return setWebGLArray<WebGLIntArray, V8WebGLIntArray>(args, V8ClassIndex::WEBGLINTARRAY);
}
+v8::Handle<v8::Value> toV8(WebGLIntArray* impl)
+{
+ if (!impl)
+ return v8::Null();
+ v8::Handle<v8::Object> wrapper = V8WebGLIntArray::wrap(impl);
+ if (!wrapper.IsEmpty())
+ wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalIntArray, impl->length());
+ return wrapper;
+}
+
} // namespace WebCore
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
index 19b73d4..78de5e6 100644
--- a/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
@@ -42,12 +42,16 @@
#include "V8Binding.h"
#include "V8WebGLArray.h"
+#include "V8WebGLBuffer.h"
#include "V8WebGLByteArray.h"
#include "V8WebGLFloatArray.h"
+#include "V8WebGLFramebuffer.h"
#include "V8WebGLIntArray.h"
#include "V8WebGLProgram.h"
+#include "V8WebGLRenderbuffer.h"
#include "V8WebGLShader.h"
#include "V8WebGLShortArray.h"
+#include "V8WebGLTexture.h"
#include "V8WebGLUniformLocation.h"
#include "V8WebGLUnsignedByteArray.h"
#include "V8WebGLUnsignedIntArray.h"
@@ -175,7 +179,7 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::bufferSubDataCallback(const v8::A
return v8::Undefined();
}
-static v8::Handle<v8::Value> toV8(const WebGLGetInfo& info)
+static v8::Handle<v8::Value> toV8Object(const WebGLGetInfo& info)
{
switch (info.getType()) {
case WebGLGetInfo::kTypeBool:
@@ -191,23 +195,23 @@ static v8::Handle<v8::Value> toV8(const WebGLGetInfo& info)
case WebGLGetInfo::kTypeUnsignedLong:
return v8::Integer::NewFromUnsigned(info.getUnsignedLong());
case WebGLGetInfo::kTypeWebGLBuffer:
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLBUFFER, info.getWebGLBuffer());
+ return toV8(info.getWebGLBuffer());
case WebGLGetInfo::kTypeWebGLFloatArray:
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLFLOATARRAY, info.getWebGLFloatArray());
+ return toV8(info.getWebGLFloatArray());
case WebGLGetInfo::kTypeWebGLFramebuffer:
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLFRAMEBUFFER, info.getWebGLFramebuffer());
+ return toV8(info.getWebGLFramebuffer());
case WebGLGetInfo::kTypeWebGLIntArray:
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLINTARRAY, info.getWebGLIntArray());
+ return toV8(info.getWebGLIntArray());
// FIXME: implement WebGLObjectArray
// case WebGLGetInfo::kTypeWebGLObjectArray:
case WebGLGetInfo::kTypeWebGLProgram:
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLPROGRAM, info.getWebGLProgram());
+ return toV8(info.getWebGLProgram());
case WebGLGetInfo::kTypeWebGLRenderbuffer:
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLRENDERBUFFER, info.getWebGLRenderbuffer());
+ return toV8(info.getWebGLRenderbuffer());
case WebGLGetInfo::kTypeWebGLTexture:
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLTEXTURE, info.getWebGLTexture());
+ return toV8(info.getWebGLTexture());
case WebGLGetInfo::kTypeWebGLUnsignedByteArray:
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLUNSIGNEDBYTEARRAY, info.getWebGLUnsignedByteArray());
+ return toV8(info.getWebGLUnsignedByteArray());
default:
notImplemented();
return v8::Undefined();
@@ -261,7 +265,7 @@ static v8::Handle<v8::Value> getObjectParameter(const v8::Arguments& args, Objec
V8Proxy::setDOMException(ec);
return v8::Undefined();
}
- return toV8(info);
+ return toV8Object(info);
}
static WebGLUniformLocation* toWebGLUniformLocation(v8::Handle<v8::Value> value, bool& ok)
@@ -317,7 +321,7 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getFramebufferAttachmentParameter
V8Proxy::setDOMException(ec);
return v8::Undefined();
}
- return toV8(info);
+ return toV8Object(info);
}
v8::Handle<v8::Value> V8WebGLRenderingContext::getParameterCallback(const v8::Arguments& args)
@@ -342,7 +346,7 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getParameterCallback(const v8::Ar
V8Proxy::setDOMException(ec);
return v8::Undefined();
}
- return toV8(info);
+ return toV8Object(info);
}
v8::Handle<v8::Value> V8WebGLRenderingContext::getProgramParameterCallback(const v8::Arguments& args)
@@ -368,7 +372,7 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getProgramParameterCallback(const
V8Proxy::setDOMException(ec);
return v8::Undefined();
}
- return toV8(info);
+ return toV8Object(info);
}
v8::Handle<v8::Value> V8WebGLRenderingContext::getRenderbufferParameterCallback(const v8::Arguments& args)
@@ -400,7 +404,7 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getShaderParameterCallback(const
V8Proxy::setDOMException(ec);
return v8::Undefined();
}
- return toV8(info);
+ return toV8Object(info);
}
v8::Handle<v8::Value> V8WebGLRenderingContext::getTexParameterCallback(const v8::Arguments& args)
@@ -434,7 +438,7 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getUniformCallback(const v8::Argu
V8Proxy::setDOMException(ec);
return v8::Undefined();
}
- return toV8(info);
+ return toV8Object(info);
}
v8::Handle<v8::Value> V8WebGLRenderingContext::getVertexAttribCallback(const v8::Arguments& args)
diff --git a/WebCore/bindings/v8/custom/V8WebGLShortArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLShortArrayCustom.cpp
index 9d3b478..4cbccf5 100644
--- a/WebCore/bindings/v8/custom/V8WebGLShortArrayCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLShortArrayCustom.cpp
@@ -63,6 +63,16 @@ v8::Handle<v8::Value> V8WebGLShortArray::setCallback(const v8::Arguments& args)
return setWebGLArray<WebGLShortArray, V8WebGLShortArray>(args, V8ClassIndex::WEBGLSHORTARRAY);
}
+v8::Handle<v8::Value> toV8(WebGLShortArray* impl)
+{
+ if (!impl)
+ return v8::Null();
+ v8::Handle<v8::Object> wrapper = V8WebGLShortArray::wrap(impl);
+ if (!wrapper.IsEmpty())
+ wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalShortArray, impl->length());
+ return wrapper;
+}
+
} // namespace WebCore
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8WebGLUnsignedByteArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLUnsignedByteArrayCustom.cpp
index 3cc658a..962e390 100644
--- a/WebCore/bindings/v8/custom/V8WebGLUnsignedByteArrayCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLUnsignedByteArrayCustom.cpp
@@ -63,6 +63,16 @@ v8::Handle<v8::Value> V8WebGLUnsignedByteArray::setCallback(const v8::Arguments&
return setWebGLArray<WebGLUnsignedByteArray, V8WebGLUnsignedByteArray>(args, V8ClassIndex::WEBGLUNSIGNEDBYTEARRAY);
}
+v8::Handle<v8::Value> toV8(WebGLUnsignedByteArray* impl)
+{
+ if (!impl)
+ return v8::Null();
+ v8::Handle<v8::Object> wrapper = V8WebGLUnsignedByteArray::wrap(impl);
+ if (!wrapper.IsEmpty())
+ wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalUnsignedByteArray, impl->length());
+ return wrapper;
+}
+
} // namespace WebCore
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8WebGLUnsignedIntArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLUnsignedIntArrayCustom.cpp
index 93ccbd4..eb0b7cf 100644
--- a/WebCore/bindings/v8/custom/V8WebGLUnsignedIntArrayCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLUnsignedIntArrayCustom.cpp
@@ -63,6 +63,16 @@ v8::Handle<v8::Value> V8WebGLUnsignedIntArray::setCallback(const v8::Arguments&
return setWebGLArray<WebGLUnsignedIntArray, V8WebGLUnsignedIntArray>(args, V8ClassIndex::WEBGLUNSIGNEDINTARRAY);
}
+v8::Handle<v8::Value> toV8(WebGLUnsignedIntArray* impl)
+{
+ if (!impl)
+ return v8::Null();
+ v8::Handle<v8::Object> wrapper = V8WebGLUnsignedIntArray::wrap(impl);
+ if (!wrapper.IsEmpty())
+ wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalUnsignedIntArray, impl->length());
+ return wrapper;
+}
+
} // namespace WebCore
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8WebGLUnsignedShortArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLUnsignedShortArrayCustom.cpp
index d9e47cd..5f30de3 100644
--- a/WebCore/bindings/v8/custom/V8WebGLUnsignedShortArrayCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLUnsignedShortArrayCustom.cpp
@@ -63,6 +63,16 @@ v8::Handle<v8::Value> V8WebGLUnsignedShortArray::setCallback(const v8::Arguments
return setWebGLArray<WebGLUnsignedShortArray, V8WebGLUnsignedShortArray>(args, V8ClassIndex::WEBGLUNSIGNEDSHORTARRAY);
}
+v8::Handle<v8::Value> toV8(WebGLUnsignedShortArray* impl)
+{
+ if (!impl)
+ return v8::Null();
+ v8::Handle<v8::Object> wrapper = V8WebGLUnsignedShortArray::wrap(impl);
+ if (!wrapper.IsEmpty())
+ wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalUnsignedShortArray, impl->length());
+ return wrapper;
+}
+
} // namespace WebCore
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8XSLTProcessorCustom.cpp b/WebCore/bindings/v8/custom/V8XSLTProcessorCustom.cpp
index fd0305a..89f804c 100644
--- a/WebCore/bindings/v8/custom/V8XSLTProcessorCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8XSLTProcessorCustom.cpp
@@ -36,8 +36,8 @@
#include "Node.h"
#include "V8Binding.h"
-#include "V8CustomBinding.h"
#include "V8Document.h"
+#include "V8DocumentFragment.h"
#include "V8Node.h"
#include "V8Proxy.h"
#include "XSLTProcessor.h"
@@ -78,7 +78,7 @@ v8::Handle<v8::Value> V8XSLTProcessor::transformToFragmentCallback(const v8::Arg
Node* source = V8Node::toNative(v8::Handle<v8::Object>::Cast(args[0]));
Document* owner = V8Document::toNative(v8::Handle<v8::Object>::Cast(args[1]));
RefPtr<DocumentFragment> result = imp->transformToFragment(source, owner);
- return V8DOMWrapper::convertNodeToV8Object(result.release());
+ return toV8(result.release());
}
@@ -99,7 +99,7 @@ v8::Handle<v8::Value> V8XSLTProcessor::transformToDocumentCallback(const v8::Arg
if (!result)
return v8::Undefined();
- return V8DOMWrapper::convertNodeToV8Object(result.release());
+ return toV8(result.release());
}