Title: [123891] trunk/Source/WebKit/blackberry
Revision
123891
Author
[email protected]
Date
2012-07-27 11:13:01 -0700 (Fri, 27 Jul 2012)

Log Message

[BlackBerry] Should support onbeforeunload event and show confirmation dialog
https://bugs.webkit.org/show_bug.cgi?id=92510

Patch by Yong Li <[email protected]> on 2012-07-27
Reviewed by Antonio Gomes.

RIM PR# 155878.
1. Export dispatchBeforeUnloadEvent() so client can call it before going to close the page.
2. Forward runBeforeUnloadConfirmPanel() call to client so it can show a dialog.

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPage::dispatchBeforeUnloadEvent):
(WebKit):
* Api/WebPage.h:
* Api/WebPageClient.h:
* WebCoreSupport/ChromeClientBlackBerry.cpp:
(WebCore::ChromeClientBlackBerry::canRunBeforeUnloadConfirmPanel):
(WebCore::ChromeClientBlackBerry::runBeforeUnloadConfirmPanel):

Modified Paths

Diff

Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (123890 => 123891)


--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2012-07-27 18:04:45 UTC (rev 123890)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2012-07-27 18:13:01 UTC (rev 123891)
@@ -974,6 +974,11 @@
     d->prepareToDestroy();
 }
 
+bool WebPage::dispatchBeforeUnloadEvent()
+{
+    return d->m_page->mainFrame()->loader()->shouldClose();
+}
+
 static void enableCrossSiteXHRRecursively(Frame* frame)
 {
     frame->document()->securityOrigin()->grantUniversalAccess();

Modified: trunk/Source/WebKit/blackberry/Api/WebPage.h (123890 => 123891)


--- trunk/Source/WebKit/blackberry/Api/WebPage.h	2012-07-27 18:04:45 UTC (rev 123890)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.h	2012-07-27 18:13:01 UTC (rev 123891)
@@ -111,6 +111,8 @@
 
     void stopLoading();
 
+    bool dispatchBeforeUnloadEvent();
+
     // This will force any unload handlers to run.
     void prepareToDestroy();
 

Modified: trunk/Source/WebKit/blackberry/Api/WebPageClient.h (123890 => 123891)


--- trunk/Source/WebKit/blackberry/Api/WebPageClient.h	2012-07-27 18:04:45 UTC (rev 123890)
+++ trunk/Source/WebKit/blackberry/Api/WebPageClient.h	2012-07-27 18:13:01 UTC (rev 123891)
@@ -113,6 +113,7 @@
     virtual void runJavaScriptAlert(const unsigned short* message, unsigned messageLength, const char* origin, unsigned originLength) = 0;
     virtual bool runJavaScriptConfirm(const unsigned short* message, unsigned messageLength, const char* origin, unsigned originLength) = 0;
     virtual bool runJavaScriptPrompt(const unsigned short* message, unsigned messageLength, const unsigned short* defaultValue, unsigned defaultValueLength, const char* origin, unsigned originLength, WebString& result) = 0;
+    virtual bool runBeforeUnloadConfirmPanel(const unsigned short* message, unsigned messageLength, const char* origin, unsigned originLength) = 0;
 
     virtual bool shouldInterruptJavaScript() = 0;
 

Modified: trunk/Source/WebKit/blackberry/ChangeLog (123890 => 123891)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-07-27 18:04:45 UTC (rev 123890)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-07-27 18:13:01 UTC (rev 123891)
@@ -1,3 +1,23 @@
+2012-07-27  Yong Li  <[email protected]>
+
+        [BlackBerry] Should support onbeforeunload event and show confirmation dialog
+        https://bugs.webkit.org/show_bug.cgi?id=92510
+
+        Reviewed by Antonio Gomes.
+
+        RIM PR# 155878.
+        1. Export dispatchBeforeUnloadEvent() so client can call it before going to close the page.
+        2. Forward runBeforeUnloadConfirmPanel() call to client so it can show a dialog.
+
+        * Api/WebPage.cpp:
+        (BlackBerry::WebKit::WebPage::dispatchBeforeUnloadEvent):
+        (WebKit):
+        * Api/WebPage.h:
+        * Api/WebPageClient.h:
+        * WebCoreSupport/ChromeClientBlackBerry.cpp:
+        (WebCore::ChromeClientBlackBerry::canRunBeforeUnloadConfirmPanel):
+        (WebCore::ChromeClientBlackBerry::runBeforeUnloadConfirmPanel):
+
 2012-07-27  Mike Fenton  <[email protected]>
 
         [BlackBerry] Switch InputHandler malloc use to fastMalloc for cases that should never fail

Modified: trunk/Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.cpp (123890 => 123891)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.cpp	2012-07-27 18:04:45 UTC (rev 123890)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.cpp	2012-07-27 18:13:01 UTC (rev 123891)
@@ -375,19 +375,19 @@
 
 bool ChromeClientBlackBerry::canRunBeforeUnloadConfirmPanel()
 {
-    notImplemented();
-    return false;
+    return true;
 }
 
-bool ChromeClientBlackBerry::runBeforeUnloadConfirmPanel(const String& message, Frame*)
+bool ChromeClientBlackBerry::runBeforeUnloadConfirmPanel(const String& message, Frame* frame)
 {
 #if !defined(PUBLIC_BUILD) || !PUBLIC_BUILD
     if (m_webPagePrivate->m_dumpRenderTree)
         return m_webPagePrivate->m_dumpRenderTree->runBeforeUnloadConfirmPanel(message);
 #endif
 
-    notImplemented();
-    return false;
+    TimerBase::fireTimersInNestedEventLoop();
+    CString latinOrigin = frameOrigin(frame);
+    return m_webPagePrivate->m_client->runBeforeUnloadConfirmPanel(message.characters(), message.length(), latinOrigin.data(), latinOrigin.length());
 }
 
 void ChromeClientBlackBerry::closeWindowSoon()
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to