[haiku-webkit-commits] r378 - in webkit/trunk/WebKit/haiku: API WebPositive

  • From: webkit@xxxxxxxxxxxxxxx
  • To: haiku-webkit-commits@xxxxxxxxxxxxx
  • Date: Sat, 03 Apr 2010 12:47:13 +0000

Author: stippi
Date: Sat Apr  3 12:47:12 2010
New Revision: 378
URL: http://mmlr.dyndns.org/changeset/378

Log:
* Reworked closing a page programatically. BWebPage no longer sends a plain
  B_QUIT_REQUESTED, instead BWebWindow has a new hook and derived classes can
  implement it.
* Some refactoring in BrowserWindow to move code from MessageReceived into
  separate methods for easier debugging and cleaner code.

Modified:
   webkit/trunk/WebKit/haiku/API/WebPage.cpp
   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/WebPositive/BrowserWindow.cpp
   webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h

Modified: webkit/trunk/WebKit/haiku/API/WebPage.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebPage.cpp   Sat Apr  3 12:45:22 2010        
(r377)
+++ webkit/trunk/WebKit/haiku/API/WebPage.cpp   Sat Apr  3 12:47:12 2010        
(r378)
@@ -563,7 +563,7 @@
 
 void BWebPage::closeWindow()
 {
-       BMessage message(B_QUIT_REQUESTED);
+       BMessage message(CLOSE_WINDOW_REQUESTED);
     dispatchMessage(message);
 }
 

Modified: webkit/trunk/WebKit/haiku/API/WebViewConstants.h
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebViewConstants.h    Sat Apr  3 12:45:22 
2010        (r377)
+++ webkit/trunk/WebKit/haiku/API/WebViewConstants.h    Sat Apr  3 12:47:12 
2010        (r378)
@@ -45,7 +45,8 @@
     UPDATE_HISTORY =                                    313,
     UPDATE_NAVIGATION_INTERFACE =                       314,
     AUTHENTICATION_CHALLENGE =                          315,
-    ICON_RECEIVED =                                     316
+    ICON_RECEIVED =                                     316,
+    CLOSE_WINDOW_REQUESTED =                            317
 };
 
 enum {

Modified: webkit/trunk/WebKit/haiku/API/WebWindow.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebWindow.cpp Sat Apr  3 12:45:22 2010        
(r377)
+++ webkit/trunk/WebKit/haiku/API/WebWindow.cpp Sat Apr  3 12:47:12 2010        
(r378)
@@ -119,6 +119,9 @@
             NewPageCreated(view);
         break;
     }
+    case CLOSE_WINDOW_REQUESTED:
+        CloseWindowRequested(_WebViewForMessage(message));
+        break;
     case LOAD_NEGOTIATING: {
         BString url;
         if (message->FindString("url", &url) == B_OK) {
@@ -296,6 +299,11 @@
     window->Show();
 }
 
+void BWebWindow::CloseWindowRequested(BWebView* view)
+{
+    PostMessage(B_QUIT_REQUESTED);
+}
+
 void BWebWindow::LoadNegotiating(const BString& url, BWebView* view)
 {
 }

Modified: webkit/trunk/WebKit/haiku/API/WebWindow.h
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebWindow.h   Sat Apr  3 12:45:22 2010        
(r377)
+++ webkit/trunk/WebKit/haiku/API/WebWindow.h   Sat Apr  3 12:47:12 2010        
(r378)
@@ -57,6 +57,7 @@
                                                                        
BWebView* view);
        virtual void                            NewWindowRequested(const 
BString& url,
                                                                        bool 
primaryAction);
+       virtual void                            CloseWindowRequested(BWebView* 
view);
        virtual void                            NewPageCreated(BWebView* view);
        virtual void                            LoadNegotiating(const BString& 
url,
                                                                        
BWebView* view);

Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp     Sat Apr  3 
12:45:22 2010        (r377)
+++ webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp     Sat Apr  3 
12:47:12 2010        (r378)
@@ -650,20 +650,7 @@
                int32 index;
                if (message->FindInt32("tab index", &index) != B_OK)
                        index = -1;
-               BWebView* webView = 
dynamic_cast<BWebView*>(fTabManager->ViewForTab(index));
-               if (webView == CurrentWebView())
-                       break;
-               SetCurrentWebView(webView);
-               if (webView)
-                       _UpdateTitle(webView->MainFrameTitle());
-               else
-                       _UpdateTitle("");
-               if (webView) {
-                       fURLTextControl->SetText(webView->MainFrameURL());
-                       // Trigger update of the interface to the new page, by 
requesting
-                       // to resend all notifications.
-                       webView->WebPage()->ResendNotifications();
-               }
+               _TabChanged(index);
                break;
        }
 
@@ -877,6 +864,20 @@
 
 
 void
+BrowserWindow::CloseWindowRequested(BWebView* view)
+{
+       int32 index = fTabManager->TabForView(view);
+       if (index < 0) {
+               // Tab is already gone.
+               return;
+       }
+       BMessage message(CLOSE_TAB);
+       message.AddInt32("tab index", index);
+       PostMessage(&message, this);
+}
+
+
+void
 BrowserWindow::LoadNegotiating(const BString& url, BWebView* view)
 {
        BString status("Requesting: ");
@@ -1122,7 +1123,7 @@
 BrowserWindow::_UpdateTabGroupVisibility()
 {
        if (Lock()) {
-               //fTabGroup->SetVisible(fTabManager->CountTabs() > 1);
+//             fTabGroup->SetVisible(fTabManager->CountTabs() > 1);
                fTabManager->SetCloseButtonsAvailable(fTabManager->CountTabs() 
> 1);
                Unlock();
        }
@@ -1141,6 +1142,26 @@
 }
 
 
+void
+BrowserWindow::_TabChanged(int32 index)
+{
+       BWebView* webView = 
dynamic_cast<BWebView*>(fTabManager->ViewForTab(index));
+       if (webView == CurrentWebView())
+               return;
+       SetCurrentWebView(webView);
+       if (webView)
+               _UpdateTitle(webView->MainFrameTitle());
+       else
+               _UpdateTitle("");
+       if (webView) {
+               fURLTextControl->SetText(webView->MainFrameURL());
+               // Trigger update of the interface to the new page, by 
requesting
+               // to resend all notifications.
+               webView->WebPage()->ResendNotifications();
+       }
+}
+
+
 status_t
 BrowserWindow::_BookmarkPath(BPath& path) const
 {

Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h       Sat Apr  3 
12:45:22 2010        (r377)
+++ webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h       Sat Apr  3 
12:47:12 2010        (r378)
@@ -87,6 +87,7 @@
                                                                        
BWebView* view);
        virtual void                            NewWindowRequested(const 
BString& url,
                                                                        bool 
primaryAction);
+       virtual void                            CloseWindowRequested(BWebView* 
view);
        virtual void                            NewPageCreated(BWebView* view);
        virtual void                            LoadNegotiating(const BString& 
url,
                                                                        
BWebView* view);
@@ -121,6 +122,7 @@
                        void                            _UpdateTitle(const 
BString &title);
                        void                            
_UpdateTabGroupVisibility();
                        void                            _ShutdownTab(int32 
index);
+                       void                            _TabChanged(int32 
index);
 
                        status_t                        _BookmarkPath(BPath& 
path) const;
                        void                            _CreateBookmark();

Other related posts:

  • » [haiku-webkit-commits] r378 - in webkit/trunk/WebKit/haiku: API WebPositive - webkit