PAGE_POPUP: window.setValueAndClosePopup should be moved to a
authortkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 May 2012 06:50:38 +0000 (06:50 +0000)
committertkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 May 2012 06:50:38 +0000 (06:50 +0000)
per-context property of DOMWindow.
https://bugs.webkit.org/show_bug.cgi?id=87086

Reviewed by Adam Barth.

.:

* ManualTests/forms/calendar-picker.html:
Introduce pseudo window.pagePopupController.

Source/WebCore:

- Introduce window.pagePagePopupController property as V8EnabledPerContext.
- Move window.setValueAndClosePopup() to window.pagePopupController.
So, we can remove ad-hoc ScriptController::installFunctionsForPagePopup().

No behavior change.

Test: fast/forms/date/no-page-popup-controller.html

* Resources/calendarPicker.js:
(submitValue): Use window.pagePopupController.
(handleCancel): ditto.
* WebCore.gypi: Add new files.
* bindings/generic/ContextEnabledFeatures.cpp:
(WebCore::ContextEnabledFeatures::pagePopupEnabled): Added.
* bindings/generic/ContextEnabledFeatures.h:
(ContextEnabledFeatures): Added.
* bindings/v8/ScriptController.cpp: Remove installFunctionsForPagePopup().
* bindings/v8/ScriptController.h: ditto.
* loader/FrameLoaderClient.h:
(WebCore::FrameLoaderClient::allowPagePopup): Added.
* page/DOMWindowPagePopup.cpp:
(WebCore::DOMWindowPagePopup::DOMWindowPagePopup):
Creates a PagePopupController object for the specified PagePopupClient.
(WebCore::DOMWindowPagePopup::~DOMWindowPagePopup):
Empty destructor to generate the RefPtr<PagePopupController> destructor.
(WebCore::DOMWindowPagePopup::pagePopupController):
* page/DOMWindowPagePopup.h:
(DOMWindowPagePopup):
 - Remove setValueAndClosePopup()
 - Add pagePopupController()
 - Change the data member from PagePopupClient to PagePopupController.
* page/DOMWindowPagePopup.idl: Supply per-context window.pagePopupController.
* page/PagePopupController.cpp: Added. This object is attached to window.
* page/PagePopupController.h: ditto.
* page/PagePopupController.idl: ditto.

Source/WebKit/chromium:

* src/WebPagePopupImpl.cpp:
(WebKit): Add PagePopupFrameLoaderClient, which allows window.pagePopupController.
(WebKit::WebPagePopupImpl::initPage):
 - Use PagePopupFrameLoaderClient
 - Remove the call of ScriptController::installFunctionsForPagePopup().
 - Call DOMWindowPagePopup::install() to inform m_popupClient to a
   DOMWindowPagePopup object for the DOMWindow.

LayoutTests:

* fast/forms/date/no-page-popup-controller-expected.txt: Added.
* fast/forms/date/no-page-popup-controller.html: Added.

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

21 files changed:
ChangeLog
LayoutTests/ChangeLog
LayoutTests/fast/forms/date/no-page-popup-controller-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/date/no-page-popup-controller.html [new file with mode: 0644]
ManualTests/forms/calendar-picker.html
Source/WebCore/ChangeLog
Source/WebCore/Resources/calendarPicker.js
Source/WebCore/WebCore.gypi
Source/WebCore/bindings/generic/ContextEnabledFeatures.cpp
Source/WebCore/bindings/generic/ContextEnabledFeatures.h
Source/WebCore/bindings/v8/ScriptController.cpp
Source/WebCore/bindings/v8/ScriptController.h
Source/WebCore/loader/FrameLoaderClient.h
Source/WebCore/page/DOMWindowPagePopup.cpp
Source/WebCore/page/DOMWindowPagePopup.h
Source/WebCore/page/DOMWindowPagePopup.idl [new file with mode: 0644]
Source/WebCore/page/PagePopupController.cpp [new file with mode: 0644]
Source/WebCore/page/PagePopupController.h [new file with mode: 0644]
Source/WebCore/page/PagePopupController.idl [new file with mode: 0644]
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/WebPagePopupImpl.cpp

index 10926ce..21f6ba6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2012-05-24  Kent Tamura  <tkent@chromium.org>
+
+        PAGE_POPUP: window.setValueAndClosePopup should be moved to a
+        per-context property of DOMWindow.
+        https://bugs.webkit.org/show_bug.cgi?id=87086
+
+        Reviewed by Adam Barth.
+
+        * ManualTests/forms/calendar-picker.html:
+        Introduce pseudo window.pagePopupController.
+
 2012-05-24  Philippe Normand  <pnormand@igalia.com>
 
         [GTK] Add --enable-css3-flexbox configure option after r118304.
index 77e5ea4..6b4092a 100644 (file)
@@ -1,3 +1,14 @@
+2012-05-24  Kent Tamura  <tkent@chromium.org>
+
+        PAGE_POPUP: window.setValueAndClosePopup should be moved to a
+        per-context property of DOMWindow.
+        https://bugs.webkit.org/show_bug.cgi?id=87086
+
+        Reviewed by Adam Barth.
+
+        * fast/forms/date/no-page-popup-controller-expected.txt: Added.
+        * fast/forms/date/no-page-popup-controller.html: Added.
+
 2012-05-24  Zan Dobersek  <zandobersek@gmail.com>
 
         Unreviewed GTK gardening, rebaselining fast/multicol/span/clone-flexbox.html.
diff --git a/LayoutTests/fast/forms/date/no-page-popup-controller-expected.txt b/LayoutTests/fast/forms/date/no-page-popup-controller-expected.txt
new file mode 100644 (file)
index 0000000..f27825f
--- /dev/null
@@ -0,0 +1,10 @@
+Confirm that the main window doesn't have pagePopupController, which should be present only in a calendar picker.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.pagePopupController === undefined is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/forms/date/no-page-popup-controller.html b/LayoutTests/fast/forms/date/no-page-popup-controller.html
new file mode 100644 (file)
index 0000000..e2cc704
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<body>
+<script src="../../js/resources/js-test-pre.js"></script>
+<input type=date>
+<script>
+description('Confirm that the main window doesn\'t have pagePopupController, which should be present only in a calendar picker.');
+shouldBeTrue('window.pagePopupController === undefined');
+</script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
index 43eed5c..ff01028 100644 (file)
@@ -80,13 +80,17 @@ function openCalendar(args) {
     script.src = '../../Source/WebCore/Resources/calendarPicker.js?' + (new Date()).getTime();
     doc.body.appendChild(script);
 
-    setTimeout(function() {
-        frame.contentWindow.postMessage(JSON.stringify(args), "*");
-        frame.contentWindow.setValueAndClosePopup = function(numValue, stringValue) {
+    var pagePopupController = {
+        setValueAndClosePopup: function(numValue, stringValue) {
             window.log('number=' + numValue + ', string="' + stringValue + '"');
             if (numValue == 0)
                 window.document.getElementById('date').value = stringValue;
-        };
+        }
+    }
+
+    setTimeout(function() {
+        frame.contentWindow.postMessage(JSON.stringify(args), "*");
+        frame.contentWindow.pagePopupController = pagePopupController;
     }, 100);
 }
 
index 7b3b52e..7f0c8a0 100644 (file)
@@ -1,3 +1,47 @@
+2012-05-24  Kent Tamura  <tkent@chromium.org>
+
+        PAGE_POPUP: window.setValueAndClosePopup should be moved to a
+        per-context property of DOMWindow.
+        https://bugs.webkit.org/show_bug.cgi?id=87086
+
+        Reviewed by Adam Barth.
+
+        - Introduce window.pagePagePopupController property as V8EnabledPerContext.
+        - Move window.setValueAndClosePopup() to window.pagePopupController.
+        So, we can remove ad-hoc ScriptController::installFunctionsForPagePopup().
+
+        No behavior change.
+
+        Test: fast/forms/date/no-page-popup-controller.html
+
+        * Resources/calendarPicker.js:
+        (submitValue): Use window.pagePopupController.
+        (handleCancel): ditto.
+        * WebCore.gypi: Add new files.
+        * bindings/generic/ContextEnabledFeatures.cpp:
+        (WebCore::ContextEnabledFeatures::pagePopupEnabled): Added.
+        * bindings/generic/ContextEnabledFeatures.h:
+        (ContextEnabledFeatures): Added.
+        * bindings/v8/ScriptController.cpp: Remove installFunctionsForPagePopup().
+        * bindings/v8/ScriptController.h: ditto.
+        * loader/FrameLoaderClient.h:
+        (WebCore::FrameLoaderClient::allowPagePopup): Added.
+        * page/DOMWindowPagePopup.cpp:
+        (WebCore::DOMWindowPagePopup::DOMWindowPagePopup):
+        Creates a PagePopupController object for the specified PagePopupClient.
+        (WebCore::DOMWindowPagePopup::~DOMWindowPagePopup):
+        Empty destructor to generate the RefPtr<PagePopupController> destructor.
+        (WebCore::DOMWindowPagePopup::pagePopupController):
+        * page/DOMWindowPagePopup.h:
+        (DOMWindowPagePopup):
+         - Remove setValueAndClosePopup()
+         - Add pagePopupController()
+         - Change the data member from PagePopupClient to PagePopupController.
+        * page/DOMWindowPagePopup.idl: Supply per-context window.pagePopupController.
+        * page/PagePopupController.cpp: Added. This object is attached to window.
+        * page/PagePopupController.h: ditto.
+        * page/PagePopupController.idl: ditto.
+
 2012-05-21  Kinuko Yasuda  <kinuko@chromium.org>
 
         Cleanup: add a file system call which captures the file metadata at once.
index 5b0e56d..4a7ef06 100644 (file)
@@ -1080,11 +1080,11 @@ function handleClear() {
  * @param {string} value
  */
 function submitValue(value) {
-    window.setValueAndClosePopup(0, value);
+    window.pagePopupController.setValueAndClosePopup(0, value);
 }
 
 function handleCancel() {
-    window.setValueAndClosePopup(-1, "");
+    window.pagePopupController.setValueAndClosePopup(-1, "");
 }
 
 /**
index 7c38902..3732b11 100644 (file)
             'page/Crypto.idl',
             'page/DOMSelection.idl',
             'page/DOMWindow.idl',
+            'page/DOMWindowPagePopup.idl',
             'page/EventSource.idl',
             'page/History.idl',
             'page/Location.idl',
             'page/MemoryInfo.idl',
             'page/Navigator.idl',
             'page/NavigatorRegisterProtocolHandler.idl',
+            'page/PagePopupController.idl',
             'page/Performance.idl',
             'page/PerformanceEntry.idl',
             'page/PerformanceEntryList.idl',
             'page/PageGroup.cpp',
             'page/PageGroupLoadDeferrer.cpp',
             'page/PageGroupLoadDeferrer.h',
+            'page/PagePopupController.cpp',
+            'page/PagePopupController.h',
             'page/PageSerializer.cpp',
             'page/PageVisibilityState.cpp',
             'page/Performance.cpp',
index e380547..b8d0a51 100644 (file)
@@ -59,7 +59,17 @@ bool ContextEnabledFeatures::styleScopedEnabled(Document* document)
     if (Frame* frame = document->frame())
         return frame->loader()->client()->allowStyleScoped(RuntimeEnabledFeatures::styleScopedEnabled());
     return false;
-   
+}
+#endif   
+
+#if ENABLE(PAGE_POPUP)
+bool ContextEnabledFeatures::pagePopupEnabled(DOMWindow* window)
+{
+    if (!window)
+        return false;
+    if (Frame* frame = window->frame())
+        return frame->loader()->client()->allowPagePopup();
+    return false;
 }
 #endif
 
index 0924f24..ea7fa4b 100644 (file)
@@ -48,6 +48,9 @@ public:
 #if ENABLE(STYLE_SCOPED)
     static bool styleScopedEnabled(Document*);
 #endif
+#if ENABLE(PAGE_POPUP)
+    static bool pagePopupEnabled(DOMWindow*);
+#endif
 };
 
 } // namespace WebCore
index 0106704..42cda7a 100644 (file)
@@ -38,7 +38,6 @@
 #include "ScriptCallStackFactory.h"
 #include "ScriptableDocumentParser.h"
 #include "DOMWindow.h"
-#include "DOMWindowPagePopup.h"
 #include "Event.h"
 #include "EventListener.h"
 #include "EventNames.h"
@@ -250,36 +249,6 @@ void ScriptController::bindToWindowObject(Frame* frame, const String& key, NPObj
     global->Set(v8String(key), value);
 }
 
-#if ENABLE(PAGE_POPUP)
-static v8::Handle<v8::Value> setValueAndClosePopupCallback(const v8::Arguments& args)
-{
-    if (args.Length() < 2)
-        return V8Proxy::throwNotEnoughArgumentsError(args.GetIsolate());
-    DOMWindow* imp = V8DOMWindow::toNative(args.Data()->ToObject());
-    EXCEPTION_BLOCK(int, intValue, toInt32(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)));
-    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, stringValue, MAYBE_MISSING_PARAMETER(args, 1, DefaultIsUndefined));
-    DOMWindowPagePopup::setValueAndClosePopup(imp, intValue, stringValue);
-    // setValueAndClosePopup() deletes the window. Do not access it.
-    return v8::Undefined();
-}
-
-void ScriptController::installFunctionsForPagePopup(Frame* frame, PagePopupClient* popupClient)
-{
-    ASSERT(frame);
-    ASSERT(popupClient);
-    v8::HandleScope handleScope;
-    v8::Handle<v8::Context> context = V8Proxy::mainWorldContext(frame);
-    if (context.IsEmpty()) {
-        ASSERT_NOT_REACHED();
-        return;
-    }
-    v8::Context::Scope scope(context);
-    DOMWindowPagePopup::install(frame->existingDOMWindow(), popupClient);
-    v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(setValueAndClosePopupCallback, V8DOMWindow::wrap(frame->existingDOMWindow()));
-    context->Global()->Set(v8::String::New("setValueAndClosePopup"), v8::Handle<v8::Function>(templ->GetFunction()));
-}
-#endif
-
 void ScriptController::collectGarbage()
 {
     v8::HandleScope handleScope;
index d75fb9e..c71d284 100644 (file)
@@ -122,9 +122,6 @@ public:
     void bindToWindowObject(Frame*, const String& key, NPObject*);
 
     PassScriptInstance createScriptInstanceForWidget(Widget*);
-#if ENABLE(PAGE_POPUP)
-    void installFunctionsForPagePopup(Frame*, PagePopupClient*);
-#endif
 
     // Check if the javascript engine has been initialized.
     bool haveInterpreter() const;
index 791cc0c..15872ef 100644 (file)
@@ -313,6 +313,9 @@ namespace WebCore {
 
         virtual bool shadowDOMAllowed(bool enabledAsRuntimeFeatures) { return enabledAsRuntimeFeatures; }
         virtual bool allowStyleScoped(bool enabledAsRuntimeFeatures) { return enabledAsRuntimeFeatures; }
+#if ENABLE(PAGE_POPUP)
+        virtual bool allowPagePopup() { return false; }
+#endif
 
         // This callback notifies the client that the frame was about to run
         // JavaScript but did not because allowScript returned false. We
index 994cd39..09e3c16 100644 (file)
 
 #if ENABLE(PAGE_POPUP)
 #include "DOMWindow.h"
-#include "PagePopupClient.h"
+#include "PagePopupController.h"
 
 namespace WebCore {
 
 DOMWindowPagePopup::DOMWindowPagePopup(PagePopupClient* popupClient)
-    : m_popupClient(popupClient)
+    : m_controller(PagePopupController::create(popupClient))
 {
     ASSERT(popupClient);
 }
 
+DOMWindowPagePopup::~DOMWindowPagePopup()
+{
+}
+
 const AtomicString& DOMWindowPagePopup::supplementName()
 {
     DEFINE_STATIC_LOCAL(AtomicString, name, ("DOMWindowPagePopup"));
     return name;
 }
 
-void DOMWindowPagePopup::setValueAndClosePopup(DOMWindow* window, int intValue, const String& stringValue)
+PagePopupController* DOMWindowPagePopup::pagePopupController(DOMWindow* window)
 {
     DOMWindowPagePopup* supplement = static_cast<DOMWindowPagePopup*>(from(window, supplementName()));
     ASSERT(supplement);
-    supplement->m_popupClient->setValueAndClosePopup(intValue, stringValue);
-    // setValueAndClosePopup() deletes the window and this object. Do not access them.
+    return supplement->m_controller.get();
 }
 
 void DOMWindowPagePopup::install(DOMWindow* window, PagePopupClient* popupClient)
index 51fb85a..4f806d9 100644 (file)
@@ -38,17 +38,19 @@ namespace WebCore {
 
 class DOMWindow;
 class PagePopupClient;
+class PagePopupController;
 
 class DOMWindowPagePopup : public Supplement<DOMWindow> {
 public:
-    static void setValueAndClosePopup(DOMWindow*, int intValue, const String& stringValue);
+    static PagePopupController* pagePopupController(DOMWindow*);
     static void install(DOMWindow*, PagePopupClient*);
+    ~DOMWindowPagePopup();
 
 private:
     explicit DOMWindowPagePopup(PagePopupClient*);
     static const AtomicString& supplementName();
 
-    PagePopupClient* m_popupClient;
+    RefPtr<PagePopupController> m_controller;
 };
 
 }
diff --git a/Source/WebCore/page/DOMWindowPagePopup.idl b/Source/WebCore/page/DOMWindowPagePopup.idl
new file mode 100644 (file)
index 0000000..aa477a1
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+module window {
+    interface [
+        Conditional=PAGE_POPUP,
+        Supplemental=DOMWindow
+    ] DOMWindowPagePopup {
+        readonly attribute [V8EnabledPerContext=pagePopup] PagePopupController pagePopupController;
+    };
+}
diff --git a/Source/WebCore/page/PagePopupController.cpp b/Source/WebCore/page/PagePopupController.cpp
new file mode 100644 (file)
index 0000000..824f6df
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2012 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 "PagePopupController.h"
+
+#if ENABLE(PAGE_POPUP)
+#include "PagePopupClient.h"
+
+namespace WebCore {
+
+PagePopupController::PagePopupController(PagePopupClient* client)
+    : m_popupClient(client)
+{
+    ASSERT(client);
+}
+
+PassRefPtr<PagePopupController> PagePopupController::create(PagePopupClient* client)
+{
+    return adoptRef(new PagePopupController(client));
+}
+
+void PagePopupController::setValueAndClosePopup(int numValue, const String& stringValue)
+{
+    m_popupClient->setValueAndClosePopup(numValue, stringValue);
+}
+
+}
+#endif
diff --git a/Source/WebCore/page/PagePopupController.h b/Source/WebCore/page/PagePopupController.h
new file mode 100644 (file)
index 0000000..1ec7287
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2012 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 PagePopupController_h
+#define PagePopupController_h
+
+#if ENABLE(PAGE_POPUP)
+
+#include <wtf/Forward.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class PagePopupClient;
+
+class PagePopupController : public RefCounted<PagePopupController> {
+public:
+    static PassRefPtr<PagePopupController> create(PagePopupClient*);
+    void setValueAndClosePopup(int numValue, const String& stringValue);
+
+private:
+    explicit PagePopupController(PagePopupClient*);
+
+    PagePopupClient* m_popupClient;
+};
+
+}
+#endif
+#endif
diff --git a/Source/WebCore/page/PagePopupController.idl b/Source/WebCore/page/PagePopupController.idl
new file mode 100644 (file)
index 0000000..6e0a49d
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+module window {
+    interface [
+        Conditional=PAGE_POPUP
+    ] PagePopupController {
+        void setValueAndClosePopup(in long numberValue, in DOMString stringValue);
+    };
+}
index 2470114..1f28455 100644 (file)
@@ -1,3 +1,19 @@
+2012-05-24  Kent Tamura  <tkent@chromium.org>
+
+        PAGE_POPUP: window.setValueAndClosePopup should be moved to a
+        per-context property of DOMWindow.
+        https://bugs.webkit.org/show_bug.cgi?id=87086
+
+        Reviewed by Adam Barth.
+
+        * src/WebPagePopupImpl.cpp:
+        (WebKit): Add PagePopupFrameLoaderClient, which allows window.pagePopupController.
+        (WebKit::WebPagePopupImpl::initPage):
+         - Use PagePopupFrameLoaderClient
+         - Remove the call of ScriptController::installFunctionsForPagePopup().
+         - Call DOMWindowPagePopup::install() to inform m_popupClient to a
+           DOMWindowPagePopup object for the DOMWindow.
+
 2012-05-21  Kinuko Yasuda  <kinuko@chromium.org>
 
         Cleanup: add a file system call which captures the file metadata at once.
index 1ad417b..617b725 100644 (file)
@@ -32,6 +32,7 @@
 #include "WebPagePopupImpl.h"
 
 #include "Chrome.h"
+#include "DOMWindowPagePopup.h"
 #include "EmptyClients.h"
 #include "FileChooser.h"
 #include "FocusController.h"
@@ -127,6 +128,10 @@ private:
     WebPagePopupImpl* m_popup;
 };
 
+class PagePopupFrameLoaderClient : public EmptyFrameLoaderClient {
+    virtual bool allowPagePopup() OVERRIDE { return true; }
+};
+
 // WebPagePopupImpl ----------------------------------------------------------------
 
 WebPagePopupImpl::WebPagePopupImpl(WebWidgetClient* client)
@@ -181,8 +186,8 @@ bool WebPagePopupImpl::initPage()
     m_page->settings()->setScriptEnabled(true);
     m_page->settings()->setAllowScriptsToCloseWindows(true);
 
-    static FrameLoaderClient* emptyFrameLoaderClient =  new EmptyFrameLoaderClient;
-    RefPtr<Frame> frame = Frame::create(m_page.get(), 0, emptyFrameLoaderClient);
+    static FrameLoaderClient* pagePopupFrameLoaderClient =  new PagePopupFrameLoaderClient;
+    RefPtr<Frame> frame = Frame::create(m_page.get(), 0, pagePopupFrameLoaderClient);
     frame->setView(FrameView::create(frame.get()));
     frame->init();
     frame->view()->resize(m_popupClient->contentSize());
@@ -195,7 +200,8 @@ bool WebPagePopupImpl::initPage()
     m_popupClient->writeDocument(*writer);
     writer->end();
 
-    frame->script()->installFunctionsForPagePopup(frame.get(), m_popupClient);
+    ASSERT(frame->existingDOMWindow());
+    DOMWindowPagePopup::install(frame->existingDOMWindow(), m_popupClient);
     return true;
 }