[V8] V8HTMLDocument::write and friends should not indirect through Frame
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Sep 2012 20:21:33 +0000 (20:21 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Sep 2012 20:21:33 +0000 (20:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=96289

Patch by Adam Barth <abarth@chromium.org> on 2012-09-10
Reviewed by Eric Seidel.

There is no reason why document.write and friends need to indirect
through the Frame to find the active document. This patch makes these
functions work the same as the JSC versions.

* bindings/v8/BindingState.cpp:
* bindings/v8/BindingState.h:
    - This patch removes the last callers of activeFrame, so we can
      remove the function entirely.
* bindings/v8/custom/V8HTMLDocumentCustom.cpp:
(WebCore::V8HTMLDocument::writeCallback):
(WebCore::V8HTMLDocument::writelnCallback):
(WebCore::V8HTMLDocument::openCallback):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@128095 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/bindings/v8/BindingState.cpp
Source/WebCore/bindings/v8/BindingState.h
Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp

index 13926af..73497e5 100644 (file)
@@ -1,5 +1,25 @@
 2012-09-10  Adam Barth  <abarth@chromium.org>
 
+        [V8] V8HTMLDocument::write and friends should not indirect through Frame
+        https://bugs.webkit.org/show_bug.cgi?id=96289
+
+        Reviewed by Eric Seidel.
+
+        There is no reason why document.write and friends need to indirect
+        through the Frame to find the active document. This patch makes these
+        functions work the same as the JSC versions.
+
+        * bindings/v8/BindingState.cpp:
+        * bindings/v8/BindingState.h:
+            - This patch removes the last callers of activeFrame, so we can
+              remove the function entirely.
+        * bindings/v8/custom/V8HTMLDocumentCustom.cpp:
+        (WebCore::V8HTMLDocument::writeCallback):
+        (WebCore::V8HTMLDocument::writelnCallback):
+        (WebCore::V8HTMLDocument::openCallback):
+
+2012-09-10  Adam Barth  <abarth@chromium.org>
+
         [V8] Constructors try to handle errors that cannot occur
         https://bugs.webkit.org/show_bug.cgi?id=96304
 
index c59bb89..f4d503f 100644 (file)
@@ -66,14 +66,6 @@ DOMWindow* firstDOMWindow(BindingState*)
     return toDOMWindow(v8::Context::GetEntered());
 }
 
-Frame* activeFrame(BindingState*)
-{
-    v8::Handle<v8::Context> context = activeContext();
-    if (context.IsEmpty())
-        return 0;
-    return toFrameIfNotDetached(context);
-}
-
 Frame* firstFrame(BindingState*)
 {
     v8::Handle<v8::Context> context = v8::Context::GetEntered();
index 9564224..19e844f 100644 (file)
@@ -49,7 +49,6 @@ public:
 DOMWindow* activeDOMWindow(BindingState*);
 DOMWindow* firstDOMWindow(BindingState*);
 
-Frame* activeFrame(BindingState*);
 Frame* firstFrame(BindingState*);
 
 // FIXME: When implementing this function for JSC, we need to understand if there
index ca39754..be53431 100644 (file)
@@ -119,8 +119,7 @@ v8::Handle<v8::Value> V8HTMLDocument::writeCallback(const v8::Arguments& args)
 {
     INC_STATS("DOM.HTMLDocument.write()");
     HTMLDocument* htmlDocument = V8HTMLDocument::toNative(args.Holder());
-    Frame* frame = activeFrame(BindingState::instance());
-    htmlDocument->write(writeHelperGetString(args), frame ? frame->document() : NULL);
+    htmlDocument->write(writeHelperGetString(args), activeDOMWindow(BindingState::instance())->document());
     return v8::Undefined();
 }
 
@@ -128,8 +127,7 @@ v8::Handle<v8::Value> V8HTMLDocument::writelnCallback(const v8::Arguments& args)
 {
     INC_STATS("DOM.HTMLDocument.writeln()");
     HTMLDocument* htmlDocument = V8HTMLDocument::toNative(args.Holder());
-    Frame* frame = activeFrame(BindingState::instance());
-    htmlDocument->writeln(writeHelperGetString(args), frame ? frame->document() : NULL);
+    htmlDocument->writeln(writeHelperGetString(args), activeDOMWindow(BindingState::instance())->document());
     return v8::Undefined();
 }
 
@@ -160,9 +158,7 @@ v8::Handle<v8::Value> V8HTMLDocument::openCallback(const v8::Arguments& args)
         }
     }
 
-    Frame* frame = activeFrame(BindingState::instance());
-    htmlDocument->open(frame ? frame->document() : NULL);
-    // Return the document.
+    htmlDocument->open(activeDOMWindow(BindingState::instance())->document());
     return args.Holder();
 }