Modified: trunk/Source/WebCore/ChangeLog (126796 => 126797)
--- trunk/Source/WebCore/ChangeLog 2012-08-27 21:24:36 UTC (rev 126796)
+++ trunk/Source/WebCore/ChangeLog 2012-08-27 21:29:29 UTC (rev 126797)
@@ -1,5 +1,31 @@
2012-08-27 Adam Barth <[email protected]>
+ The static functions in V8DOMWindowShell.cpp are poorly named
+ https://bugs.webkit.org/show_bug.cgi?id=95122
+
+ Reviewed by Eric Seidel.
+
+ This patch cleans up the naming of the static functions in
+ V8DOMWindowShell.cpp.
+
+ I've inlined handleFatalErrorInV8 into its one caller.
+
+ * bindings/v8/V8DOMWindowShell.cpp:
+ (WebCore::reportFatalError):
+ - Removed V8 from the name becaues this entire file is about V8.
+ (WebCore::reportUncaughtException):
+ - Ditto.
+ (WebCore::findFrame):
+ - Remove the "get" prefix because it's a weak verb.
+ (WebCore::reportUnsafeJavaScriptAccess):
+ (WebCore::initializeV8IfNeeded):
+ (WebCore::checkDocumentWrapper):
+ - Move this function up to the top of the file with the rest of the
+ static functions.
+ (WebCore):
+
+2012-08-27 Adam Barth <[email protected]>
+
[V8] initContextIfNeeded is overly specific
https://bugs.webkit.org/show_bug.cgi?id=95120
Modified: trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp (126796 => 126797)
--- trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp 2012-08-27 21:24:36 UTC (rev 126796)
+++ trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp 2012-08-27 21:29:29 UTC (rev 126797)
@@ -63,17 +63,11 @@
#include "V8ObjectConstructor.h"
#include "V8PerContextData.h"
#include "WorkerContextExecutionProxy.h"
-
#include <algorithm>
#include <stdio.h>
#include <utility>
#include <v8-debug.h>
#include <v8.h>
-
-#if ENABLE(_javascript__I18N_API)
-#include <v8-i18n/include/extension.h>
-#endif
-
#include <wtf/Assertions.h>
#include <wtf/OwnArrayPtr.h>
#include <wtf/StdLibExtras.h>
@@ -81,17 +75,14 @@
#include <wtf/UnusedParam.h>
#include <wtf/text/CString.h>
+#if ENABLE(_javascript__I18N_API)
+#include <v8-i18n/include/extension.h>
+#endif
+
namespace WebCore {
-static void handleFatalErrorInV8()
+static void reportFatalError(const char* location, const char* message)
{
- // FIXME: We temporarily deal with V8 internal error situations
- // such as out-of-memory by crashing the renderer.
- CRASH();
-}
-
-static void reportFatalErrorInV8(const char* location, const char* message)
-{
// V8 is shutdown, we cannot use V8 api.
// The only thing we can do is to disable _javascript_.
// FIXME: clean up ScriptController and disable _javascript_.
@@ -100,10 +91,12 @@
memoryUsageMB = MemoryUsageSupport::actualMemoryUsageMB();
#endif
printf("V8 error: %s (%s). Current memory usage: %d MB\n", message, location, memoryUsageMB);
- handleFatalErrorInV8();
+ // FIXME: We temporarily deal with V8 internal error situations
+ // such as out-of-memory by crashing the renderer.
+ CRASH();
}
-static void v8UncaughtExceptionHandler(v8::Handle<v8::Message> message, v8::Handle<v8::Value> data)
+static void reportUncaughtException(v8::Handle<v8::Message> message, v8::Handle<v8::Value> data)
{
// Use the frame where _javascript_ is called from.
Frame* frame = firstFrame(BindingState::instance());
@@ -129,7 +122,7 @@
// Returns the owner frame pointer of a DOM wrapper object. It only works for
// these DOM objects requiring cross-domain access check.
-static Frame* getTargetFrame(v8::Local<v8::Object> host, v8::Local<v8::Value> data)
+static Frame* findFrame(v8::Local<v8::Object> host, v8::Local<v8::Value> data)
{
Frame* target = 0;
WrapperTypeInfo* type = WrapperTypeInfo::unwrap(data);
@@ -152,7 +145,7 @@
static void reportUnsafeJavaScriptAccess(v8::Local<v8::Object> host, v8::AccessType type, v8::Local<v8::Value> data)
{
- Frame* target = getTargetFrame(host, data);
+ Frame* target = findFrame(host, data);
if (!target)
return;
DOMWindow* targetWindow = target->document()->domWindow();
@@ -169,10 +162,10 @@
initialized = true;
v8::V8::IgnoreOutOfMemoryException();
- v8::V8::SetFatalErrorHandler(reportFatalErrorInV8);
+ v8::V8::SetFatalErrorHandler(reportFatalError);
v8::V8::SetGlobalGCPrologueCallback(&V8GCController::gcPrologue);
v8::V8::SetGlobalGCEpilogueCallback(&V8GCController::gcEpilogue);
- v8::V8::AddMessageListener(&v8UncaughtExceptionHandler);
+ v8::V8::AddMessageListener(&reportUncaughtException);
v8::V8::SetFailedAccessCheckCallbackFunction(reportUnsafeJavaScriptAccess);
#if ENABLE(_javascript__DEBUGGER)
ScriptProfiler::initialize();
@@ -184,6 +177,12 @@
v8::V8::SetFlagsFromString(es5ReadonlyFlag, sizeof(es5ReadonlyFlag));
}
+static void checkDocumentWrapper(v8::Handle<v8::Object> wrapper, Document* document)
+{
+ ASSERT(V8Document::toNative(wrapper) == document);
+ ASSERT(!document->isHTMLDocument() || (V8Document::toNative(v8::Handle<v8::Object>::Cast(wrapper->GetPrototype())) == document));
+}
+
PassRefPtr<V8DOMWindowShell> V8DOMWindowShell::create(Frame* frame)
{
return adoptRef(new V8DOMWindowShell(frame));
@@ -424,12 +423,6 @@
m_document.clear();
}
-static void checkDocumentWrapper(v8::Handle<v8::Object> wrapper, Document* document)
-{
- ASSERT(V8Document::toNative(wrapper) == document);
- ASSERT(!document->isHTMLDocument() || (V8Document::toNative(v8::Handle<v8::Object>::Cast(wrapper->GetPrototype())) == document));
-}
-
void V8DOMWindowShell::updateDocumentWrapperCache()
{
v8::HandleScope handleScope;