[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

weinig at apple.com weinig at apple.com
Wed Dec 22 11:28:17 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 2b77bec1ff3852d024a7b0e5580b1f91bf242d55
Author: weinig at apple.com <weinig at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Jul 26 19:57:04 2010 +0000

    Fix for https://bugs.webkit.org/show_bug.cgi?id=42986
    Add prompt and confirm client functions to WebKit2
    
    Reviewed by Anders Carlsson.
    
    WebKit2:
    
    * Shared/CoreIPCSupport/WebPageProxyMessageKinds.h:
    (WebPageProxyMessage::):
    * UIProcess/API/C/WKPage.h:
    * UIProcess/WebPageProxy.cpp:
    (WebKit::WebPageProxy::didReceiveSyncMessage):
    (WebKit::WebPageProxy::runJavaScriptAlert):
    (WebKit::WebPageProxy::runJavaScriptConfirm):
    (WebKit::WebPageProxy::runJavaScriptPrompt):
    * UIProcess/WebPageProxy.h:
    * UIProcess/WebUIClient.cpp:
    (WebKit::WebUIClient::runJavaScriptAlert):
    (WebKit::WebUIClient::runJavaScriptConfirm):
    (WebKit::WebUIClient::runJavaScriptPrompt):
    * UIProcess/WebUIClient.h:
    * WebKit2.xcodeproj/project.pbxproj:
    * WebProcess/WebCoreSupport/WebChromeClient.cpp:
    (WebKit::WebChromeClient::runJavaScriptConfirm):
    (WebKit::WebChromeClient::runJavaScriptPrompt):
    
    WebKitTools:
    
    * MiniBrowser/mac/BrowserWindowController.m:
    (-[BrowserWindowController awakeFromNib]):
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64065 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index c53e400..dc4bb0e 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,29 @@
+2010-07-26  Sam Weinig  <sam at webkit.org>
+
+        Reviewed by Anders Carlsson.
+
+        Fix for https://bugs.webkit.org/show_bug.cgi?id=42986
+        Add prompt and confirm client functions to WebKit2
+
+        * Shared/CoreIPCSupport/WebPageProxyMessageKinds.h:
+        (WebPageProxyMessage::):
+        * UIProcess/API/C/WKPage.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::didReceiveSyncMessage):
+        (WebKit::WebPageProxy::runJavaScriptAlert):
+        (WebKit::WebPageProxy::runJavaScriptConfirm):
+        (WebKit::WebPageProxy::runJavaScriptPrompt):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebUIClient.cpp:
+        (WebKit::WebUIClient::runJavaScriptAlert):
+        (WebKit::WebUIClient::runJavaScriptConfirm):
+        (WebKit::WebUIClient::runJavaScriptPrompt):
+        * UIProcess/WebUIClient.h:
+        * WebKit2.xcodeproj/project.pbxproj:
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::runJavaScriptConfirm):
+        (WebKit::WebChromeClient::runJavaScriptPrompt):
+
 2010-07-26  Adam Roben  <aroben at apple.com>
 
         Windows build fix
diff --git a/WebKit2/Shared/CoreIPCSupport/WebPageProxyMessageKinds.h b/WebKit2/Shared/CoreIPCSupport/WebPageProxyMessageKinds.h
index 8aced4d..02cf099 100644
--- a/WebKit2/Shared/CoreIPCSupport/WebPageProxyMessageKinds.h
+++ b/WebKit2/Shared/CoreIPCSupport/WebPageProxyMessageKinds.h
@@ -36,6 +36,8 @@ enum Kind {
     CreateNewPage,
     ShowPage,
     RunJavaScriptAlert,
+    RunJavaScriptConfirm,
+    RunJavaScriptPrompt,
     
     ClosePage,
     DecidePolicyForMIMEType,
diff --git a/WebKit2/UIProcess/API/C/WKPage.h b/WebKit2/UIProcess/API/C/WKPage.h
index ea050ee..601f555 100644
--- a/WebKit2/UIProcess/API/C/WKPage.h
+++ b/WebKit2/UIProcess/API/C/WKPage.h
@@ -116,6 +116,8 @@ typedef WKPageRef (*WKPageCreateNewPageCallback)(WKPageRef page, const void *cli
 typedef void (*WKPageShowPageCallback)(WKPageRef page, const void *clientInfo);
 typedef void (*WKPageCloseCallback)(WKPageRef page, const void *clientInfo);
 typedef void (*WKPageRunJavaScriptAlertCallback)(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void *clientInfo);
+typedef bool (*WKPageRunJavaScriptConfirmCallback)(WKPageRef page, WKStringRef message, WKFrameRef frame, const void *clientInfo);
+typedef WKStringRef (*WKPageRunJavaScriptPromptCallback)(WKPageRef page, WKStringRef message, WKStringRef defaultValue, WKFrameRef frame, const void *clientInfo);
 
 struct WKPageUIClient {
     int                                                                 version;
@@ -124,6 +126,8 @@ struct WKPageUIClient {
     WKPageShowPageCallback                                              showPage;
     WKPageCloseCallback                                                 close;
     WKPageRunJavaScriptAlertCallback                                    runJavaScriptAlert;
+    WKPageRunJavaScriptConfirmCallback                                  runJavaScriptConfirm;
+    WKPageRunJavaScriptPromptCallback                                   runJavaScriptPrompt;
 };
 typedef struct WKPageUIClient WKPageUIClient;
 
diff --git a/WebKit2/UIProcess/WebPageProxy.cpp b/WebKit2/UIProcess/WebPageProxy.cpp
index d065437..863d6d9 100644
--- a/WebKit2/UIProcess/WebPageProxy.cpp
+++ b/WebKit2/UIProcess/WebPageProxy.cpp
@@ -649,13 +649,35 @@ void WebPageProxy::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIP
         }
         case WebPageProxyMessage::RunJavaScriptAlert: {
             uint64_t frameID;
-            String alertText;
-            if (!arguments.decode(CoreIPC::Out(frameID, alertText)))
+            String message;
+            if (!arguments.decode(CoreIPC::Out(frameID, message)))
                 return;
-            runJavaScriptAlert(webFrame(frameID), alertText);
+            runJavaScriptAlert(webFrame(frameID), message);
             break;
         }
+        case WebPageProxyMessage::RunJavaScriptConfirm: {
+            // FIXME: We should probably encode something in the case that the arguments do not decode correctly.
+            uint64_t frameID;
+            String message;
+            if (!arguments.decode(CoreIPC::Out(frameID, message)))
+                return;
+
+            bool result = runJavaScriptConfirm(webFrame(frameID), message);
+            reply.encode(CoreIPC::In(result));
+            break;
+        }
+        case WebPageProxyMessage::RunJavaScriptPrompt: {
+            // FIXME: We should probably encode something in the case that the arguments do not decode correctly.
+            uint64_t frameID;
+            String message;
+            String defaultValue;
+            if (!arguments.decode(CoreIPC::Out(frameID, message, defaultValue)))
+                return;
 
+            String result = runJavaScriptPrompt(webFrame(frameID), message, defaultValue);
+            reply.encode(CoreIPC::In(result));
+            break;
+        }
         case WebPageProxyMessage::BackForwardCurrentItem: {
             WebBackForwardListItem* currentItem = m_backForwardList->currentItem();
             uint64_t currentItemID = currentItem ? currentItem->itemID() : 0;
@@ -832,11 +854,20 @@ void WebPageProxy::closePage()
     m_uiClient.close(this);
 }
 
-void WebPageProxy::runJavaScriptAlert(WebFrameProxy* frame, const WebCore::String& alertText)
+void WebPageProxy::runJavaScriptAlert(WebFrameProxy* frame, const String& message)
 {
-    m_uiClient.runJavaScriptAlert(this, alertText.impl(), frame);
+    m_uiClient.runJavaScriptAlert(this, message, frame);
 }
 
+bool WebPageProxy::runJavaScriptConfirm(WebFrameProxy* frame, const String& message)
+{
+    return m_uiClient.runJavaScriptConfirm(this, message, frame);
+}
+
+String WebPageProxy::runJavaScriptPrompt(WebFrameProxy* frame, const String& message, const String& defaultValue)
+{
+    return m_uiClient.runJavaScriptPrompt(this, message, defaultValue, frame);
+}
 
 // HistoryClient
 
diff --git a/WebKit2/UIProcess/WebPageProxy.h b/WebKit2/UIProcess/WebPageProxy.h
index 0bfdef0..55f4d7c 100644
--- a/WebKit2/UIProcess/WebPageProxy.h
+++ b/WebKit2/UIProcess/WebPageProxy.h
@@ -187,6 +187,8 @@ private:
     void showPage();
     void closePage();
     void runJavaScriptAlert(WebFrameProxy*, const WebCore::String&);
+    bool runJavaScriptConfirm(WebFrameProxy* frame, const WebCore::String&);
+    WebCore::String runJavaScriptPrompt(WebFrameProxy* frame, const WebCore::String&, const WebCore::String&);
 
     void didNavigateWithNavigationData(WebFrameProxy*, const WebNavigationDataStore&); 
     void didPerformClientRedirect(WebFrameProxy*, const WebCore::String& sourceURLString, const WebCore::String& destinationURLString);
diff --git a/WebKit2/UIProcess/WebUIClient.cpp b/WebKit2/UIProcess/WebUIClient.cpp
index ba4fc32..bc3ea1a 100644
--- a/WebKit2/UIProcess/WebUIClient.cpp
+++ b/WebKit2/UIProcess/WebUIClient.cpp
@@ -26,6 +26,7 @@
 #include "WebUIClient.h"
 
 #include "WKAPICast.h"
+#include <WebCore/PlatformString.h>
 #include <string.h>
 
 using namespace WebCore;
@@ -69,13 +70,35 @@ void WebUIClient::close(WebPageProxy* page)
     m_pageUIClient.close(toRef(page), m_pageUIClient.clientInfo);
 }
 
-void WebUIClient::runJavaScriptAlert(WebPageProxy* page, StringImpl* alertText, WebFrameProxy* frame)
+void WebUIClient::runJavaScriptAlert(WebPageProxy* page, const String& message, WebFrameProxy* frame)
 {
     if (!m_pageUIClient.runJavaScriptAlert)
         return;
     
-    m_pageUIClient.runJavaScriptAlert(toRef(page), toRef(alertText), toRef(frame), m_pageUIClient.clientInfo);
+    m_pageUIClient.runJavaScriptAlert(toRef(page), toRef(message.impl()), toRef(frame), m_pageUIClient.clientInfo);
 }
 
+bool WebUIClient::runJavaScriptConfirm(WebPageProxy* page, const String& message, WebFrameProxy* frame)
+{
+    if (!m_pageUIClient.runJavaScriptConfirm)
+        return false;
+
+    return m_pageUIClient.runJavaScriptConfirm(toRef(page), toRef(message.impl()), toRef(frame), m_pageUIClient.clientInfo);
+}
+
+String WebUIClient::runJavaScriptPrompt(WebPageProxy* page, const String& message, const String& defaultValue, WebFrameProxy* frame)
+{
+    if (!m_pageUIClient.runJavaScriptPrompt)
+        return String();
+
+    StringImpl* impl = toWK(m_pageUIClient.runJavaScriptPrompt(toRef(page), toRef(message.impl()), toRef(defaultValue.impl()), toRef(frame), m_pageUIClient.clientInfo));
+    if (!impl)
+        return String();
+
+    String result = impl;
+    impl->deref();
+
+    return result;
+}
 
 } // namespace WebKit
diff --git a/WebKit2/UIProcess/WebUIClient.h b/WebKit2/UIProcess/WebUIClient.h
index 55acef4..a656624 100644
--- a/WebKit2/UIProcess/WebUIClient.h
+++ b/WebKit2/UIProcess/WebUIClient.h
@@ -29,7 +29,7 @@
 #include "WKPage.h"
 
 namespace WebCore {
-    class StringImpl;
+    class String;
 }
 
 namespace WebKit {
@@ -45,7 +45,9 @@ public:
     WebPageProxy* createNewPage(WebPageProxy*);
     void showPage(WebPageProxy*);
     void close(WebPageProxy*);
-    void runJavaScriptAlert(WebPageProxy*, WebCore::StringImpl*, WebFrameProxy*);
+    void runJavaScriptAlert(WebPageProxy*, const WebCore::String&, WebFrameProxy*);
+    bool runJavaScriptConfirm(WebPageProxy*, const WebCore::String&, WebFrameProxy*);
+    WebCore::String runJavaScriptPrompt(WebPageProxy*, const WebCore::String&, const WebCore::String&, WebFrameProxy*);
 
 private:
     WKPageUIClient m_pageUIClient;
diff --git a/WebKit2/WebKit2.xcodeproj/project.pbxproj b/WebKit2/WebKit2.xcodeproj/project.pbxproj
index cde27ed..d62b4b2 100644
--- a/WebKit2/WebKit2.xcodeproj/project.pbxproj
+++ b/WebKit2/WebKit2.xcodeproj/project.pbxproj
@@ -367,7 +367,7 @@
 		32DBCF5E0370ADEE00C91783 /* WebKit2Prefix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKit2Prefix.h; sourceTree = "<group>"; };
 		5DAD7294116FF70B00EE5396 /* WebProcess.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = WebProcess.xcconfig; sourceTree = "<group>"; };
 		5DAD73F1116FF90C00EE5396 /* BaseTarget.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = BaseTarget.xcconfig; sourceTree = "<group>"; };
-		6D8A91A511F0EFD100DD01FE /* com.apple.WebProcess.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = com.apple.WebProcess.sb; sourceTree = "<group>"; };
+		6D8A91A511F0EFD100DD01FE /* com.apple.WebProcess.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = com.apple.WebProcess.sb; path = WebProcess/com.apple.WebProcess.sb; sourceTree = "<group>"; };
 		8DC2EF5A0486A6940098B216 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
 		8DC2EF5B0486A6940098B216 /* WebKit2.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = WebKit2.framework; sourceTree = BUILT_PRODUCTS_DIR; };
 		BC0092F5115837A300E0AE2A /* RunLoopMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RunLoopMac.mm; sourceTree = "<group>"; };
@@ -498,7 +498,6 @@
 		BCB63477116BF10600603215 /* WebKit2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKit2.h; sourceTree = "<group>"; };
 		BCB7346D11CEE3FF00EC5002 /* WebProcessProxyMessageKinds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebProcessProxyMessageKinds.h; sourceTree = "<group>"; };
 		BCB86F4B116AAACD00CE20B7 /* WebKit2.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = WebKit2.xcconfig; sourceTree = "<group>"; };
-		BCB8D4E011AF78C1008F9103 /* WebKit2.exp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.exports; name = WebKit2.exp; path = mac/WebKit2.exp; sourceTree = "<group>"; };
 		BCB9E2411120DACA00A137E0 /* WebContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebContext.h; sourceTree = "<group>"; };
 		BCB9E2421120DACA00A137E0 /* WebContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebContext.cpp; sourceTree = "<group>"; };
 		BCB9E2491120E15C00A137E0 /* WKContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKContext.h; sourceTree = "<group>"; };
@@ -619,8 +618,8 @@
 			children = (
 				BC8A500E11765AD400757573 /* WebKit2 */,
 				BC8A500F11765AE300757573 /* WebProcess */,
+				6D8A91A511F0EFD100DD01FE /* com.apple.WebProcess.sb */,
 				089C1666FE841158C02AAC07 /* InfoPlist.strings */,
-				BCB8D4E011AF78C1008F9103 /* WebKit2.exp */,
 			);
 			name = Resources;
 			sourceTree = "<group>";
@@ -796,7 +795,6 @@
 		BC032D5C10F436D50058C15A /* WebProcess */ = {
 			isa = PBXGroup;
 			children = (
-				6D8A91A511F0EFD100DD01FE /* com.apple.WebProcess.sb */,
 				BC204EDF11C83E72008F3375 /* InjectedBundle */,
 				1A6FA01C11E1526300DB1371 /* mac */,
 				1A6FB7AA11E64B4900DB1371 /* Plugins */,
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp b/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
index 848071a..2325809 100644
--- a/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
+++ b/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
@@ -229,8 +229,15 @@ bool WebChromeClient::runJavaScriptConfirm(Frame* frame, const String& message)
     // Notify the bundle client.
     m_page->injectedBundleUIClient().willRunJavaScriptConfirm(m_page, message, webFrame);
 
-    // Implement for UIProcess.
-    return false;
+    bool result = false;
+    if (!WebProcess::shared().connection()->sendSync(WebPageProxyMessage::RunJavaScriptConfirm, m_page->pageID(),
+                                                     CoreIPC::In(webFrame->frameID(), message),
+                                                     CoreIPC::Out(result),
+                                                     CoreIPC::Connection::NoTimeout)) {
+        return false;
+    }
+
+    return result;
 }
 
 bool WebChromeClient::runJavaScriptPrompt(Frame* frame, const String& message, const String& defaultValue, String& result)
@@ -240,8 +247,14 @@ bool WebChromeClient::runJavaScriptPrompt(Frame* frame, const String& message, c
     // Notify the bundle client.
     m_page->injectedBundleUIClient().willRunJavaScriptPrompt(m_page, message, defaultValue, webFrame);
 
-    // Implement for UIProcess.
-    return false;
+    if (!WebProcess::shared().connection()->sendSync(WebPageProxyMessage::RunJavaScriptPrompt, m_page->pageID(),
+                                                     CoreIPC::In(webFrame->frameID(), message, defaultValue),
+                                                     CoreIPC::Out(result),
+                                                     CoreIPC::Connection::NoTimeout)) {
+        return false;
+    }
+
+    return !result.isNull();
 }
 
 void WebChromeClient::setStatusbarText(const String& statusbarText)
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index e8dbe01..16c9dd7 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,13 @@
+2010-07-26  Sam Weinig  <sam at webkit.org>
+
+        Reviewed by Anders Carlsson.
+
+        Fix for https://bugs.webkit.org/show_bug.cgi?id=42986
+        Add prompt and confirm client functions to WebKit2
+
+        * MiniBrowser/mac/BrowserWindowController.m:
+        (-[BrowserWindowController awakeFromNib]):
+
 2010-07-26  Adam Roben  <aroben at apple.com>
 
         Windows build fix
diff --git a/WebKitTools/Makefile b/WebKitTools/Makefile
index c1f1991..57ea097 100644
--- a/WebKitTools/Makefile
+++ b/WebKitTools/Makefile
@@ -1,4 +1,4 @@
-MODULES = DumpRenderTree MiniBrowser
+MODULES = DumpRenderTree WebKitTestRunner MiniBrowser
 
 all:
 	@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
diff --git a/WebKitTools/MiniBrowser/mac/BrowserWindowController.m b/WebKitTools/MiniBrowser/mac/BrowserWindowController.m
index 234c04c..cb67648 100644
--- a/WebKitTools/MiniBrowser/mac/BrowserWindowController.m
+++ b/WebKitTools/MiniBrowser/mac/BrowserWindowController.m
@@ -152,105 +152,105 @@
 
 #pragma mark Loader Client Callbacks
 
-static void _didStartProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, const void *clientInfo)
+static void didStartProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, const void *clientInfo)
 {
     [(BrowserWindowController *)clientInfo didStartProvisionalLoadForFrame:frame];
 }
 
-static void _didReceiveServerRedirectForProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, const void *clientInfo)
+static void didReceiveServerRedirectForProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, const void *clientInfo)
 {
     [(BrowserWindowController *)clientInfo didReceiveServerRedirectForProvisionalLoadForFrame:frame];
 }
 
-static void _didFailProvisionalLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, const void *clientInfo)
+static void didFailProvisionalLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, const void *clientInfo)
 {
     [(BrowserWindowController *)clientInfo didFailProvisionalLoadWithErrorForFrame:frame];
 }
 
-static void _didCommitLoadForFrame(WKPageRef page, WKFrameRef frame, const void *clientInfo)
+static void didCommitLoadForFrame(WKPageRef page, WKFrameRef frame, const void *clientInfo)
 {
     [(BrowserWindowController *)clientInfo didCommitLoadForFrame:frame];
 }
 
-static void _didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, const void *clientInfo)
+static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, const void *clientInfo)
 {
     LOG(@"didFinishLoadForFrame");
 }
 
-static void _didFailLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, const void *clientInfo)
+static void didFailLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, const void *clientInfo)
 {
     [(BrowserWindowController *)clientInfo didFailLoadWithErrorForFrame:frame];
 }
 
-static void _didReceiveTitleForFrame(WKPageRef page, WKStringRef title, WKFrameRef frame, const void *clientInfo)
+static void didReceiveTitleForFrame(WKPageRef page, WKStringRef title, WKFrameRef frame, const void *clientInfo)
 {
     CFStringRef cfTitle = WKStringCopyCFString(0, title);
     LOG(@"didReceiveTitleForFrame \"%@\"", (NSString *)cfTitle);
     CFRelease(cfTitle);
 }
 
-static void _didFirstLayoutForFrame(WKPageRef page, WKFrameRef frame, const void *clientInfo)
+static void didFirstLayoutForFrame(WKPageRef page, WKFrameRef frame, const void *clientInfo)
 {
     LOG(@"didFirstLayoutForFrame");
 }
 
-static void _didFirstVisuallyNonEmptyLayoutForFrame(WKPageRef page, WKFrameRef frame, const void *clientInfo)
+static void didFirstVisuallyNonEmptyLayoutForFrame(WKPageRef page, WKFrameRef frame, const void *clientInfo)
 {
     LOG(@"didFirstVisuallyNonEmptyLayoutForFrame");
 }
 
-static void _didStartProgress(WKPageRef page, const void *clientInfo)
+static void didStartProgress(WKPageRef page, const void *clientInfo)
 {
     [(BrowserWindowController *)clientInfo didStartProgress];
 }
 
-static void _didChangeProgress(WKPageRef page, const void *clientInfo)
+static void didChangeProgress(WKPageRef page, const void *clientInfo)
 {
     [(BrowserWindowController *)clientInfo didChangeProgress:WKPageGetEstimatedProgress(page)];
 }
 
-static void _didFinishProgress(WKPageRef page, const void *clientInfo)
+static void didFinishProgress(WKPageRef page, const void *clientInfo)
 {
     [(BrowserWindowController *)clientInfo didFinishProgress];
 }
 
-static void _didBecomeUnresponsive(WKPageRef page, const void *clientInfo)
+static void didBecomeUnresponsive(WKPageRef page, const void *clientInfo)
 {
     LOG(@"didBecomeUnresponsive");
 }
 
-static void _didBecomeResponsive(WKPageRef page, const void *clientInfo)
+static void didBecomeResponsive(WKPageRef page, const void *clientInfo)
 {
     LOG(@"didBecomeResponsive");
 }
 
-static void _didChangeBackForwardList(WKPageRef page, const void *clientInfo)
+static void didChangeBackForwardList(WKPageRef page, const void *clientInfo)
 {
     [(BrowserWindowController *)clientInfo validateToolbar];
 }
 
 #pragma mark Policy Client Callbacks
 
-static void _decidePolicyForNavigationAction(WKPageRef page, WKFrameNavigationType navigationType, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void *clientInfo)
+static void decidePolicyForNavigationAction(WKPageRef page, WKFrameNavigationType navigationType, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void *clientInfo)
 {
     LOG(@"decidePolicyForNavigationAction");
     WKFramePolicyListenerUse(listener);
 }
 
-static void _decidePolicyForNewWindowAction(WKPageRef page, WKFrameNavigationType navigationType, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void *clientInfo)
+static void decidePolicyForNewWindowAction(WKPageRef page, WKFrameNavigationType navigationType, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void *clientInfo)
 {
     LOG(@"decidePolicyForNewWindowAction");
     WKFramePolicyListenerUse(listener);
 }
 
-static void _decidePolicyForMIMEType(WKPageRef page, WKStringRef MIMEType, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void *clientInfo)
+static void decidePolicyForMIMEType(WKPageRef page, WKStringRef MIMEType, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void *clientInfo)
 {
     WKFramePolicyListenerUse(listener);
 }
 
 #pragma mark UI Client Callbacks
 
-static WKPageRef _createNewPage(WKPageRef page, const void* clientInfo)
+static WKPageRef createNewPage(WKPageRef page, const void* clientInfo)
 {
     LOG(@"createNewPage");
     BrowserWindowController *controller = [[BrowserWindowController alloc] initWithPageNamespace:WKPageGetPageNamespace(page)];
@@ -259,13 +259,13 @@ static WKPageRef _createNewPage(WKPageRef page, const void* clientInfo)
     return controller->_webView.pageRef;
 }
 
-static void _showPage(WKPageRef page, const void *clientInfo)
+static void showPage(WKPageRef page, const void *clientInfo)
 {
     LOG(@"showPage");
     [[(BrowserWindowController *)clientInfo window] orderFront:nil];
 }
 
-static void _closePage(WKPageRef page, const void *clientInfo)
+static void closePage(WKPageRef page, const void *clientInfo)
 {
     LOG(@"closePage");
     WKPageClose(page);
@@ -273,17 +273,17 @@ static void _closePage(WKPageRef page, const void *clientInfo)
     WKPageRelease(page);
 }
 
-static void _runJavaScriptAlert(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void* clientInfo)
+static void runJavaScriptAlert(WKPageRef page, WKStringRef message, WKFrameRef frame, const void* clientInfo)
 {
     NSAlert* alert = [[NSAlert alloc] init];
 
     CFURLRef cfURL = WKURLCopyCFURL(0, WKFrameGetURL(frame));
-    [alert setMessageText:[NSString stringWithFormat:@"JavaScript Alert from %@.", [(NSURL *)cfURL absoluteString]]];
+    [alert setMessageText:[NSString stringWithFormat:@"JavaScript alert dialog from %@.", [(NSURL *)cfURL absoluteString]]];
     CFRelease(cfURL);
 
-    CFStringRef cfAlertText = WKStringCopyCFString(0, alertText);
-    [alert setInformativeText:(NSString *)alertText];
-    CFRelease(cfAlertText);
+    CFStringRef cfMessage = WKStringCopyCFString(0, message);
+    [alert setInformativeText:(NSString *)cfMessage];
+    CFRelease(cfMessage);
 
     [alert addButtonWithTitle:@"OK"];
 
@@ -291,10 +291,67 @@ static void _runJavaScriptAlert(WKPageRef page, WKStringRef alertText, WKFrameRe
     [alert release];
 }
 
+static bool runJavaScriptConfirm(WKPageRef page, WKStringRef message, WKFrameRef frame, const void* clientInfo)
+{
+    NSAlert* alert = [[NSAlert alloc] init];
+
+    CFURLRef cfURL = WKURLCopyCFURL(0, WKFrameGetURL(frame));
+    [alert setMessageText:[NSString stringWithFormat:@"JavaScript confirm dialog from %@.", [(NSURL *)cfURL absoluteString]]];
+    CFRelease(cfURL);
+
+    CFStringRef cfMessage = WKStringCopyCFString(0, message);
+    [alert setInformativeText:(NSString *)cfMessage];
+    CFRelease(cfMessage);
+
+    [alert addButtonWithTitle:@"OK"];
+    [alert addButtonWithTitle:@"Cancel"];
+
+    NSInteger button = [alert runModal];
+    [alert release];
+
+    return button == NSAlertFirstButtonReturn;
+}
+
+static WKStringRef runJavaScriptPrompt(WKPageRef page, WKStringRef message, WKStringRef defaultValue, WKFrameRef frame, const void* clientInfo)
+{
+    NSAlert* alert = [[NSAlert alloc] init];
+
+    CFURLRef cfURL = WKURLCopyCFURL(0, WKFrameGetURL(frame));
+    [alert setMessageText:[NSString stringWithFormat:@"JavaScript prompt dialog from %@.", [(NSURL *)cfURL absoluteString]]];
+    CFRelease(cfURL);
+
+    CFStringRef cfMessage = WKStringCopyCFString(0, message);
+    [alert setInformativeText:(NSString *)cfMessage];
+    CFRelease(cfMessage);
+
+    [alert addButtonWithTitle:@"OK"];
+    [alert addButtonWithTitle:@"Cancel"];
+
+    NSTextField* input = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 200, 24)];
+    CFStringRef cfDefaultValue = WKStringCopyCFString(0, defaultValue);
+    [input setStringValue:(NSString *)cfDefaultValue];
+    CFRelease(cfDefaultValue);
+
+    [alert setAccessoryView:input];
+
+    NSInteger button = [alert runModal];
+
+    NSString* result = nil;
+    if (button == NSAlertFirstButtonReturn) {
+        [input validateEditing];
+        result = [input stringValue];
+    }
+
+    [alert release];
+
+    if (!result)
+        return 0;
+    return WKStringCreateWithCFString((CFStringRef)result);
+}
 
 #pragma mark History Client Callbacks
 
-static void _didNavigateWithNavigationData(WKPageRef page, WKNavigationDataRef navigationData, WKFrameRef frame, const void *clientInfo)
+static void didNavigateWithNavigationData(WKPageRef page, WKNavigationDataRef navigationData, WKFrameRef frame, const void *clientInfo)
 {
     CFStringRef title = WKStringCopyCFString(0, WKNavigationDataGetTitle(navigationData));
     CFURLRef url = WKURLCopyCFURL(0, WKNavigationDataGetURL(navigationData));
@@ -303,7 +360,7 @@ static void _didNavigateWithNavigationData(WKPageRef page, WKNavigationDataRef n
     CFRelease(url);
 }
 
-static void _didPerformClientRedirect(WKPageRef page, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef frame, const void *clientInfo)
+static void didPerformClientRedirect(WKPageRef page, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef frame, const void *clientInfo)
 {
     CFURLRef cfSourceURL = WKURLCopyCFURL(0, sourceURL);
     CFURLRef cfDestinationURL = WKURLCopyCFURL(0, destinationURL);
@@ -312,7 +369,7 @@ static void _didPerformClientRedirect(WKPageRef page, WKURLRef sourceURL, WKURLR
     CFRelease(cfDestinationURL);
 }
 
-static void _didPerformServerRedirect(WKPageRef page, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef frame, const void *clientInfo)
+static void didPerformServerRedirect(WKPageRef page, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef frame, const void *clientInfo)
 {
     CFURLRef cfSourceURL = WKURLCopyCFURL(0, sourceURL);
     CFURLRef cfDestinationURL = WKURLCopyCFURL(0, destinationURL);
@@ -321,7 +378,7 @@ static void _didPerformServerRedirect(WKPageRef page, WKURLRef sourceURL, WKURLR
     CFRelease(cfDestinationURL);
 }
 
-static void _didUpdateHistoryTitle(WKPageRef page, WKStringRef title, WKURLRef URL, WKFrameRef frame, const void *clientInfo)
+static void didUpdateHistoryTitle(WKPageRef page, WKStringRef title, WKURLRef URL, WKFrameRef frame, const void *clientInfo)
 {
     CFStringRef cfTitle = WKStringCopyCFString(0, title);
     CFURLRef cfURL = WKURLCopyCFURL(0, URL);
@@ -342,50 +399,52 @@ static void _didUpdateHistoryTitle(WKPageRef page, WKStringRef title, WKURLRef U
     WKPageLoaderClient loadClient = {
         0,      /* version */
         self,   /* clientInfo */
-        _didStartProvisionalLoadForFrame,
-        _didReceiveServerRedirectForProvisionalLoadForFrame,
-        _didFailProvisionalLoadWithErrorForFrame,
-        _didCommitLoadForFrame,
-        _didFinishLoadForFrame,
-        _didFailLoadWithErrorForFrame,
-        _didReceiveTitleForFrame,
-        _didFirstLayoutForFrame,
-        _didFirstVisuallyNonEmptyLayoutForFrame,
-        _didStartProgress,
-        _didChangeProgress,
-        _didFinishProgress,
-        _didBecomeUnresponsive,
-        _didBecomeResponsive,
-        _didChangeBackForwardList
+        didStartProvisionalLoadForFrame,
+        didReceiveServerRedirectForProvisionalLoadForFrame,
+        didFailProvisionalLoadWithErrorForFrame,
+        didCommitLoadForFrame,
+        didFinishLoadForFrame,
+        didFailLoadWithErrorForFrame,
+        didReceiveTitleForFrame,
+        didFirstLayoutForFrame,
+        didFirstVisuallyNonEmptyLayoutForFrame,
+        didStartProgress,
+        didChangeProgress,
+        didFinishProgress,
+        didBecomeUnresponsive,
+        didBecomeResponsive,
+        didChangeBackForwardList
     };
     WKPageSetPageLoaderClient(_webView.pageRef, &loadClient);
     
     WKPagePolicyClient policyClient = {
         0,          /* version */
         self,       /* clientInfo */
-        _decidePolicyForNavigationAction,
-        _decidePolicyForNewWindowAction,
-        _decidePolicyForMIMEType
+        decidePolicyForNavigationAction,
+        decidePolicyForNewWindowAction,
+        decidePolicyForMIMEType
     };
     WKPageSetPagePolicyClient(_webView.pageRef, &policyClient);
 
     WKPageUIClient uiClient = {
         0,          /* version */
         self,       /* clientInfo */
-        _createNewPage,
-        _showPage,
-        _closePage,
-        _runJavaScriptAlert
+        createNewPage,
+        showPage,
+        closePage,
+        runJavaScriptAlert,
+        runJavaScriptConfirm,
+        runJavaScriptPrompt
     };
     WKPageSetPageUIClient(_webView.pageRef, &uiClient);
 
     WKPageHistoryClient historyClient = {
         0,
         self,
-        _didNavigateWithNavigationData,
-        _didPerformClientRedirect,
-        _didPerformServerRedirect,
-        _didUpdateHistoryTitle,
+        didNavigateWithNavigationData,
+        didPerformClientRedirect,
+        didPerformServerRedirect,
+        didUpdateHistoryTitle,
     };
 
     WKPageSetPageHistoryClient(_webView.pageRef, &historyClient);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list