[haiku-webkit-commits] r218 - in webkit/trunk/WebKit/haiku: API HaikuLauncher WebCoreSupport

  • From: webkit@xxxxxxxxxxxxxxx
  • To: haiku-webkit-commits@xxxxxxxxxxxxx
  • Date: Thu, 25 Feb 2010 18:50:51 +0000

Author: stippi
Date: Thu Feb 25 18:50:51 2010
New Revision: 218
URL: http://mmlr.dyndns.org/changeset/218

Log:
Implement creating new pages properly. This fixes content submission on
haiku-os.org and probably a few other things. Basically, we were creating
the new pages ourselves in dispatchDecidePolicyForNewWindowAction(), but
we were meant to implement dispatchCreatePage() instead. Now, what we do is
similar for the Qt port, only better (found a bug in Arora): When the user
clicked with the tertiary mouse button, we create the window ourselves, as
before, and otherwise always have WebCore create the page instead.

Modified:
   webkit/trunk/WebKit/haiku/API/WebViewConstants.h
   webkit/trunk/WebKit/haiku/API/WebWindow.cpp
   webkit/trunk/WebKit/haiku/API/WebWindow.h
   webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.cpp
   webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.h
   webkit/trunk/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp
   webkit/trunk/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.h

Modified: webkit/trunk/WebKit/haiku/API/WebViewConstants.h
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebViewConstants.h    Thu Feb 25 16:40:19 
2010        (r217)
+++ webkit/trunk/WebKit/haiku/API/WebViewConstants.h    Thu Feb 25 18:50:51 
2010        (r218)
@@ -39,11 +39,12 @@
     LOAD_FAILED =                                       307,
     LOAD_FINISHED =                                     308,
     NEW_WINDOW_REQUESTED =                              309,
-    NAVIGATION_REQUESTED =                              310,
-    JAVASCRIPT_WINDOW_OBJECT_CLEARED =                  311,
-    UPDATE_HISTORY =                                    312,
-    UPDATE_NAVIGATION_INTERFACE =                       313,
-    AUTHENTICATION_CHALLENGE =                          314
+    NEW_PAGE_CREATED =                                  310,
+    NAVIGATION_REQUESTED =                              311,
+    JAVASCRIPT_WINDOW_OBJECT_CLEARED =                  312,
+    UPDATE_HISTORY =                                    313,
+    UPDATE_NAVIGATION_INTERFACE =                       314,
+    AUTHENTICATION_CHALLENGE =                          315
 };
 
 enum {

Modified: webkit/trunk/WebKit/haiku/API/WebWindow.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebWindow.cpp Thu Feb 25 16:40:19 2010        
(r217)
+++ webkit/trunk/WebKit/haiku/API/WebWindow.cpp Thu Feb 25 18:50:51 2010        
(r218)
@@ -102,6 +102,15 @@
             NewWindowRequested(url, primaryAction);
         break;
     }
+    case NEW_PAGE_CREATED: {
+        // The FrameLoaderClient blocks until we have processed the message
+        // and sent a default reply. That's why the pointer is guaranteed
+        // to be still valid.
+        BWebView* view;
+        if (message->FindPointer("view", reinterpret_cast<void**>(&view)) == 
B_OK)
+            NewPageCreated(view);
+        break;
+    }
     case LOAD_NEGOTIATING: {
         BString url;
         if (message->FindString("url", &url) == B_OK)
@@ -234,6 +243,14 @@
 {
 }
 
+void BWebWindow::NewPageCreated(BWebView* view)
+{
+    BWebWindow* window = new BWebWindow(Frame().OffsetByCopy(10, 10),
+        "WebKit window", B_TITLED_WINDOW_LOOK, Feel(), Flags());
+    window->AddChild(view);
+    window->Show();
+}
+
 void BWebWindow::LoadNegotiating(const BString& url, BWebView* view)
 {
 }

Modified: webkit/trunk/WebKit/haiku/API/WebWindow.h
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebWindow.h   Thu Feb 25 16:40:19 2010        
(r217)
+++ webkit/trunk/WebKit/haiku/API/WebWindow.h   Thu Feb 25 18:50:51 2010        
(r218)
@@ -57,6 +57,7 @@
                                                                        
BWebView* view);
        virtual void                            NewWindowRequested(const 
BString& url,
                                                                        bool 
primaryAction);
+       virtual void                            NewPageCreated(BWebView* view);
        virtual void                            LoadNegotiating(const BString& 
url,
                                                                        
BWebView* view);
        virtual void                            LoadCommitted(const BString& 
url,

Modified: webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.cpp  Thu Feb 25 
16:40:19 2010        (r217)
+++ webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.cpp  Thu Feb 25 
18:50:51 2010        (r218)
@@ -416,10 +416,11 @@
     history->Unlock();
 }
 
-void LauncherWindow::newTab(const BString& url, bool select)
+void LauncherWindow::newTab(const BString& url, bool select, BWebView* webView)
 {
     // Executed in app thread (new BWebPage needs to be created in app thread).
-    BWebView* webView = new BWebView("web_view");
+    if (!webView)
+        webView = new BWebView("web view");
     webView->WebPage()->SetDownloadListener(m_downloadListener);
 
     m_tabView->AddTab(webView);
@@ -459,6 +460,11 @@
     be_app->PostMessage(&message);
 }
 
+void LauncherWindow::NewPageCreated(BWebView* view)
+{
+    newTab(BString(), true, view);
+}
+
 void LauncherWindow::LoadNegotiating(const BString& url, BWebView* view)
 {
     BString status("Requesting: ");

Modified: webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.h
==============================================================================
--- webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.h    Thu Feb 25 
16:40:19 2010        (r217)
+++ webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.h    Thu Feb 25 
18:50:51 2010        (r218)
@@ -68,12 +68,13 @@
     virtual bool QuitRequested();
     virtual void MenusBeginning();
 
-    void newTab(const BString& url, bool select);
+    void newTab(const BString& url, bool select, BWebView* webView = 0);
 
 private:
     // WebPage notification API implementations
     virtual void NavigationRequested(const BString& url, BWebView* view);
     virtual void NewWindowRequested(const BString& url, bool primaryAction);
+       virtual void NewPageCreated(BWebView* view);
     virtual void LoadNegotiating(const BString& url, BWebView* view);
     virtual void LoadCommitted(const BString& url, BWebView* view);
     virtual void LoadProgress(float progress, BWebView* view);

Modified: webkit/trunk/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp Thu Feb 
25 16:40:19 2010        (r217)
+++ webkit/trunk/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp Thu Feb 
25 18:50:51 2010        (r218)
@@ -39,10 +39,12 @@
 #include "CachedFrame.h"
 #include "CString.h"
 #include "DocumentLoader.h"
+#include "FormState.h"
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "FrameTree.h"
 #include "FrameView.h"
+#include "HTMLFormElement.h"
 #include "HTMLFrameOwnerElement.h"
 #include "MouseEvent.h"
 #include "MIMETypeRegistry.h"
@@ -368,10 +370,24 @@
 
 Frame* FrameLoaderClientHaiku::dispatchCreatePage()
 {
-printf("FrameLoaderClientHaiku::dispatchCreatePage()\n");
-    notImplemented();
-//    m_webFrame->webView()->createWebView();
-    return 0;
+if (!m_messenger.IsValid()) {
+printf("FrameLoaderClientHaiku::dispatchCreatePage() - can't embed new 
page!!\n");
+return 0;
+}
+    // TODO: This doesn't work for sub-frames without valid BMessenger!
+
+    // Creating the BWebView in the application thread is exactly what we need 
anyway.
+       BWebView* view = new BWebView("web view");
+       BWebPage* page = view->WebPage();
+
+    BMessage message(NEW_PAGE_CREATED);
+    message.AddPointer("view", view);
+
+    // Block until some window has embedded this view.
+    BMessage reply;
+    m_messenger.SendMessage(&message, &reply);
+
+    return page->page()->mainFrame();
 }
 
 void FrameLoaderClientHaiku::dispatchShow()
@@ -403,35 +419,7 @@
 }
 
 void 
FrameLoaderClientHaiku::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction
 function,
-    const NavigationAction& action, const ResourceRequest& request, 
PassRefPtr<FormState>, const String& targetName)
-{
-    ASSERT(function);
-    if (!function)
-        return;
-
-       // TODO: Don't do this here, implement createPage() instead!
-    BMessage message(NEW_WINDOW_REQUESTED);
-    message.AddString("url", request.url().string());
-    // Switch to the new tab immediately, since the new window action was 
caused by a primary click.
-    message.AddBool("primary", !isTertiaryMouseButton(action));
-    if (dispatchMessage(message) != B_OK) {
-        if (action.type() == NavigationTypeFormSubmitted || action.type() == 
NavigationTypeFormResubmitted)
-            
m_webFrame->Frame()->loader()->resetMultipleFormSubmissionProtection();
-
-        if (action.type() == NavigationTypeLinkClicked) {
-            ResourceRequest emptyRequest;
-            
m_webFrame->Frame()->loader()->activeDocumentLoader()->setLastCheckedRequest(emptyRequest);
-        }
-
-        callPolicyFunction(function, PolicyIgnore);
-        return;
-    }
-
-    callPolicyFunction(function, PolicyUse);
-}
-
-void 
FrameLoaderClientHaiku::dispatchDecidePolicyForNavigationAction(FramePolicyFunction
 function,
-    const NavigationAction& action, const ResourceRequest& request, 
PassRefPtr<FormState>)
+    const NavigationAction& action, const ResourceRequest& request, 
PassRefPtr<FormState> formState, const String& targetName)
 {
     ASSERT(function);
     if (!function)
@@ -449,13 +437,14 @@
 //        return;
 //    }
 
-    // Clicks with the middle mouse button shall open a new window
+    // Clicks with the middle mouse button shall open a new window,
     // (or tab respectively depending on browser) - ignore the request for 
this page then.
     BMessage message(NEW_WINDOW_REQUESTED);
     message.AddString("url", request.url().string());
     // Don't switch to the new tab, but load it in the background.
     message.AddBool("primary", false);
     dispatchMessage(message);
+
     if (action.type() == NavigationTypeFormSubmitted || action.type() == 
NavigationTypeFormResubmitted)
         m_webFrame->Frame()->loader()->resetMultipleFormSubmissionProtection();
 
@@ -463,9 +452,18 @@
         ResourceRequest emptyRequest;
         
m_webFrame->Frame()->loader()->activeDocumentLoader()->setLastCheckedRequest(emptyRequest);
     }
+
     callPolicyFunction(function, PolicyIgnore);
 }
 
+void 
FrameLoaderClientHaiku::dispatchDecidePolicyForNavigationAction(FramePolicyFunction
 function,
+    const NavigationAction& action, const ResourceRequest& request, 
PassRefPtr<FormState> formState)
+{
+    // Potentially we want to open a new window, when the user clicked with the
+    // tertiary mouse button. That's why we can reuse the other method.
+       dispatchDecidePolicyForNewWindowAction(function, action, request, 
formState, String());
+}
+
 void FrameLoaderClientHaiku::cancelPolicyCheck()
 {
     notImplemented();

Modified: webkit/trunk/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.h
==============================================================================
--- webkit/trunk/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.h   Thu Feb 
25 16:40:19 2010        (r217)
+++ webkit/trunk/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.h   Thu Feb 
25 18:50:51 2010        (r218)
@@ -208,9 +208,10 @@
     void callPolicyFunction(FramePolicyFunction, PolicyAction);
     void triggerNavigationHistoryUpdate() const;
     void postCommitFrameViewSetup(BWebFrame*, FrameView*, bool) const;
-    status_t dispatchMessage(BMessage& message) const;
     bool isTertiaryMouseButton(const NavigationAction& action) const;
 
+    status_t dispatchMessage(BMessage& message) const;
+
 private:
     BWebPage* m_webPage;
     BWebFrame* m_webFrame;

Other related posts:

  • » [haiku-webkit-commits] r218 - in webkit/trunk/WebKit/haiku: API HaikuLauncher WebCoreSupport - webkit