Diff
Modified: trunk/Source/WebCore/ChangeLog (135376 => 135377)
--- trunk/Source/WebCore/ChangeLog 2012-11-21 11:23:12 UTC (rev 135376)
+++ trunk/Source/WebCore/ChangeLog 2012-11-21 11:25:18 UTC (rev 135377)
@@ -1,3 +1,33 @@
+2012-11-21 Kentaro Hara <hara...@chromium.org>
+
+ [V8] Move V8DOMWindowShell::initializeV8IfNeeded() to V8Initializer
+ https://bugs.webkit.org/show_bug.cgi?id=102899
+
+ Reviewed by Adam Barth.
+
+ This is an incremental step to kill WorkerContextExecutionProxy.
+ As commented by abarth in bug 97066, we move
+ V8DOMWindowShell::initializeV8IfNeeded() to V8Initializer.
+ This patch renames initializeV8IfNeeded() to initializeMainThreadIfNeeded()
+ because we will add initializeWorkerIfNeeded() in a follow-up patch.
+
+ No tests. No change in behavior.
+
+ * UseV8.cmake:
+ * WebCore.gypi:
+ * bindings/v8/V8DOMWindowShell.cpp:
+ (WebCore::V8DOMWindowShell::initializeIfNeeded):
+ * bindings/v8/V8Initializer.cpp: Added.
+ (WebCore):
+ (WebCore::findFrame):
+ (WebCore::reportFatalError):
+ (WebCore::reportUncaughtException):
+ (WebCore::reportUnsafeJavaScriptAccess):
+ (WebCore::V8Initializer::initializeMainThreadIfNeeded):
+ * bindings/v8/V8Initializer.h: Added.
+ (WebCore):
+ (V8Initializer):
+
2012-11-21 Alexander Pavlov <apav...@chromium.org>
Turn -webkit-text-emphasis into a shorthand property
Modified: trunk/Source/WebCore/UseV8.cmake (135376 => 135377)
--- trunk/Source/WebCore/UseV8.cmake 2012-11-21 11:23:12 UTC (rev 135376)
+++ trunk/Source/WebCore/UseV8.cmake 2012-11-21 11:25:18 UTC (rev 135377)
@@ -55,6 +55,7 @@
bindings/v8/V8GCController.cpp
bindings/v8/V8GCForContextDispose.cpp
bindings/v8/V8HiddenPropertyName.cpp
+ bindings/v8/V8Initializer.cpp
bindings/v8/V8LazyEventListener.cpp
bindings/v8/V8NodeFilterCondition.cpp
bindings/v8/V8ObjectConstructor.cpp
Modified: trunk/Source/WebCore/WebCore.gypi (135376 => 135377)
--- trunk/Source/WebCore/WebCore.gypi 2012-11-21 11:23:12 UTC (rev 135376)
+++ trunk/Source/WebCore/WebCore.gypi 2012-11-21 11:25:18 UTC (rev 135377)
@@ -2301,6 +2301,8 @@
'bindings/v8/V8GCForContextDispose.h',
'bindings/v8/V8HiddenPropertyName.cpp',
'bindings/v8/V8HiddenPropertyName.h',
+ 'bindings/v8/V8Initializer.cpp',
+ 'bindings/v8/V8Initializer.h',
'bindings/v8/V8LazyEventListener.cpp',
'bindings/v8/V8LazyEventListener.h',
'bindings/v8/V8NPObject.cpp',
Modified: trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp (135376 => 135377)
--- trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp 2012-11-21 11:23:12 UTC (rev 135376)
+++ trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp 2012-11-21 11:25:18 UTC (rev 135377)
@@ -31,47 +31,32 @@
#include "config.h"
#include "V8DOMWindowShell.h"
-#include "BindingState.h"
#include "ContentSecurityPolicy.h"
#include "DateExtension.h"
#include "DocumentLoader.h"
#include "Frame.h"
#include "FrameLoaderClient.h"
#include "InspectorInstrumentation.h"
-#include "MemoryUsageSupport.h"
#include "Page.h"
-#include "PageGroup.h"
#include "RuntimeEnabledFeatures.h"
-#include "ScriptCallStack.h"
-#include "ScriptCallStackFactory.h"
#include "ScriptController.h"
-#include "ScriptProfiler.h"
#include "SecurityOrigin.h"
-#include "StorageNamespace.h"
-#include "StylePropertySet.h"
#include "V8Binding.h"
-#include "V8Collection.h"
#include "V8DOMWindow.h"
#include "V8Document.h"
-#include "V8GCController.h"
#include "V8GCForContextDispose.h"
#include "V8HTMLDocument.h"
#include "V8HiddenPropertyName.h"
-#include "V8History.h"
-#include "V8Location.h"
+#include "V8Initializer.h"
#include "V8ObjectConstructor.h"
#include "V8PerContextData.h"
-#include "WorkerContextExecutionProxy.h"
#include <algorithm>
-#include <stdio.h>
#include <utility>
#include <v8-debug.h>
#include <v8.h>
#include <wtf/Assertions.h>
#include <wtf/OwnArrayPtr.h>
-#include <wtf/StdLibExtras.h>
#include <wtf/StringExtras.h>
-#include <wtf/UnusedParam.h>
#include <wtf/text/CString.h>
#if ENABLE(_javascript__I18N_API)
@@ -80,89 +65,6 @@
namespace WebCore {
-static void reportFatalError(const char* location, const char* message)
-{
- int memoryUsageMB = MemoryUsageSupport::actualMemoryUsageMB();
- printf("V8 error: %s (%s). Current memory usage: %d MB\n", message, location, memoryUsageMB);
- CRASH();
-}
-
-static void reportUncaughtException(v8::Handle<v8::Message> message, v8::Handle<v8::Value> data)
-{
- DOMWindow* firstWindow = firstDOMWindow(BindingState::instance());
- if (!firstWindow->isCurrentlyDisplayedInFrame())
- return;
-
- String errorMessage = toWebCoreString(message->Get());
-
- v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace();
- RefPtr<ScriptCallStack> callStack;
- // Currently stack trace is only collected when inspector is open.
- if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0)
- callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallStackSizeToCapture);
-
- v8::Handle<v8::Value> resourceName = message->GetScriptResourceName();
- bool shouldUseDocumentURL = resourceName.IsEmpty() || !resourceName->IsString();
- String resource = shouldUseDocumentURL ? firstWindow->document()->url() : toWebCoreString(resourceName);
- firstWindow->document()->reportException(errorMessage, message->GetLineNumber(), resource, callStack);
-}
-
-static Frame* findFrame(v8::Local<v8::Object> host, v8::Local<v8::Value> data)
-{
- WrapperTypeInfo* type = WrapperTypeInfo::unwrap(data);
-
- if (V8DOMWindow::info.equals(type)) {
- v8::Handle<v8::Object> windowWrapper = V8DOMWrapper::lookupDOMWrapper(V8DOMWindow::GetTemplate(), host);
- if (windowWrapper.IsEmpty())
- return 0;
- return V8DOMWindow::toNative(windowWrapper)->frame();
- }
-
- if (V8History::info.equals(type))
- return V8History::toNative(host)->frame();
-
- if (V8Location::info.equals(type))
- return V8Location::toNative(host)->frame();
-
- // This function can handle only those types listed above.
- ASSERT_NOT_REACHED();
- return 0;
-}
-
-static void reportUnsafeJavaScriptAccess(v8::Local<v8::Object> host, v8::AccessType type, v8::Local<v8::Value> data)
-{
- Frame* target = findFrame(host, data);
- if (!target)
- return;
- DOMWindow* targetWindow = target->document()->domWindow();
- targetWindow->printErrorMessage(targetWindow->crossDomainAccessErrorMessage(activeDOMWindow(BindingState::instance())));
-}
-
-static void initializeV8IfNeeded()
-{
- ASSERT(isMainThread());
-
- static bool initialized = false;
- if (initialized)
- return;
- initialized = true;
-
- v8::V8::IgnoreOutOfMemoryException();
- v8::V8::SetFatalErrorHandler(reportFatalError);
- v8::V8::AddGCPrologueCallback(&V8GCController::gcPrologue);
- v8::V8::AddGCEpilogueCallback(&V8GCController::gcEpilogue);
- v8::V8::AddMessageListener(&reportUncaughtException);
- v8::V8::SetFailedAccessCheckCallbackFunction(reportUnsafeJavaScriptAccess);
-#if ENABLE(_javascript__DEBUGGER)
- ScriptProfiler::initialize();
-#endif
- V8PerIsolateData::ensureInitialized(v8::Isolate::GetCurrent());
-
- // FIXME: Remove the following 2 lines when V8 default has changed.
- const char es5ReadonlyFlag[] = "--es5_readonly";
- v8::V8::SetFlagsFromString(es5ReadonlyFlag, sizeof(es5ReadonlyFlag));
-}
-
static void checkDocumentWrapper(v8::Handle<v8::Object> wrapper, Document* document)
{
ASSERT(V8Document::toNative(wrapper) == document);
@@ -309,7 +211,7 @@
v8::HandleScope handleScope;
- initializeV8IfNeeded();
+ V8Initializer::initializeMainThreadIfNeeded();
createContext();
if (m_context.isEmpty())
Added: trunk/Source/WebCore/bindings/v8/V8Initializer.cpp (0 => 135377)
--- trunk/Source/WebCore/bindings/v8/V8Initializer.cpp (rev 0)
+++ trunk/Source/WebCore/bindings/v8/V8Initializer.cpp 2012-11-21 11:25:18 UTC (rev 135377)
@@ -0,0 +1,131 @@
+/*
+ * 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:
+ * 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 INC. AND ITS 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 APPLE INC. OR ITS 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 "V8Initializer.h"
+
+#include "BindingState.h"
+#include "DOMWindow.h"
+#include "Document.h"
+#include "Frame.h"
+#include "MemoryUsageSupport.h"
+#include "ScriptCallStack.h"
+#include "ScriptCallStackFactory.h"
+#include "ScriptProfiler.h"
+#include "V8Binding.h"
+#include "V8DOMWindow.h"
+#include "V8GCController.h"
+#include "V8History.h"
+#include "V8Location.h"
+#include <v8.h>
+#include <wtf/RefPtr.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+static Frame* findFrame(v8::Local<v8::Object> host, v8::Local<v8::Value> data)
+{
+ WrapperTypeInfo* type = WrapperTypeInfo::unwrap(data);
+
+ if (V8DOMWindow::info.equals(type)) {
+ v8::Handle<v8::Object> windowWrapper = V8DOMWrapper::lookupDOMWrapper(V8DOMWindow::GetTemplate(), host);
+ if (windowWrapper.IsEmpty())
+ return 0;
+ return V8DOMWindow::toNative(windowWrapper)->frame();
+ }
+
+ if (V8History::info.equals(type))
+ return V8History::toNative(host)->frame();
+
+ if (V8Location::info.equals(type))
+ return V8Location::toNative(host)->frame();
+
+ // This function can handle only those types listed above.
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+static void reportFatalError(const char* location, const char* message)
+{
+ int memoryUsageMB = MemoryUsageSupport::actualMemoryUsageMB();
+ printf("V8 error: %s (%s). Current memory usage: %d MB\n", message, location, memoryUsageMB);
+ CRASH();
+}
+
+static void reportUncaughtException(v8::Handle<v8::Message> message, v8::Handle<v8::Value> data)
+{
+ DOMWindow* firstWindow = firstDOMWindow(BindingState::instance());
+ if (!firstWindow->isCurrentlyDisplayedInFrame())
+ return;
+
+ String errorMessage = toWebCoreString(message->Get());
+
+ v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace();
+ RefPtr<ScriptCallStack> callStack;
+ // Currently stack trace is only collected when inspector is open.
+ if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0)
+ callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallStackSizeToCapture);
+
+ v8::Handle<v8::Value> resourceName = message->GetScriptResourceName();
+ bool shouldUseDocumentURL = resourceName.IsEmpty() || !resourceName->IsString();
+ String resource = shouldUseDocumentURL ? firstWindow->document()->url() : toWebCoreString(resourceName);
+ firstWindow->document()->reportException(errorMessage, message->GetLineNumber(), resource, callStack);
+}
+
+static void reportUnsafeJavaScriptAccess(v8::Local<v8::Object> host, v8::AccessType type, v8::Local<v8::Value> data)
+{
+ Frame* target = findFrame(host, data);
+ if (!target)
+ return;
+ DOMWindow* targetWindow = target->document()->domWindow();
+ targetWindow->printErrorMessage(targetWindow->crossDomainAccessErrorMessage(activeDOMWindow(BindingState::instance())));
+}
+
+void V8Initializer::initializeMainThreadIfNeeded()
+{
+ ASSERT(isMainThread());
+
+ static bool initialized = false;
+ if (initialized)
+ return;
+ initialized = true;
+
+ v8::V8::IgnoreOutOfMemoryException();
+ v8::V8::SetFatalErrorHandler(reportFatalError);
+ v8::V8::AddGCPrologueCallback(&V8GCController::gcPrologue);
+ v8::V8::AddGCEpilogueCallback(&V8GCController::gcEpilogue);
+ v8::V8::AddMessageListener(&reportUncaughtException);
+ v8::V8::SetFailedAccessCheckCallbackFunction(reportUnsafeJavaScriptAccess);
+#if ENABLE(_javascript__DEBUGGER)
+ ScriptProfiler::initialize();
+#endif
+ V8PerIsolateData::ensureInitialized(v8::Isolate::GetCurrent());
+
+ // FIXME: Remove the following 2 lines when V8 default has changed.
+ const char es5ReadonlyFlag[] = "--es5_readonly";
+ v8::V8::SetFlagsFromString(es5ReadonlyFlag, sizeof(es5ReadonlyFlag));
+}
+
+} // namespace WebCore
Added: trunk/Source/WebCore/bindings/v8/V8Initializer.h (0 => 135377)
--- trunk/Source/WebCore/bindings/v8/V8Initializer.h (rev 0)
+++ trunk/Source/WebCore/bindings/v8/V8Initializer.h 2012-11-21 11:25:18 UTC (rev 135377)
@@ -0,0 +1,38 @@
+/*
+ * 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:
+ * 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 INC. AND ITS 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 APPLE INC. OR ITS 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 V8Initializer_h
+#define V8Initializer_h
+
+namespace WebCore {
+
+class V8Initializer {
+public:
+ static void initializeMainThreadIfNeeded();
+};
+
+} // namespace WebCore
+
+#endif // V8Initializer_h