[haiku-webkit-commits] r511 - webkit/trunk/WebKit/haiku/WebPositive

  • From: webkit@xxxxxxxxxxxxxxx
  • To: haiku-webkit-commits@xxxxxxxxxxxxx
  • Date: Thu, 20 May 2010 19:57:34 +0000

Author: stippi
Date: Thu May 20 19:57:34 2010
New Revision: 511
URL: http://mmlr.dyndns.org/changeset/511

Log:
* Small refactoring for retrieving the URL for a new tab.
* Load new files into the current tab, if the URL of that tab is either empty
  or the URL for new tabs, instead of always opening a new tab.

Modified:
   webkit/trunk/WebKit/haiku/WebPositive/BrowserApp.cpp
   webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp
   webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h

Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserApp.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/BrowserApp.cpp        Thu May 20 
19:31:56 2010        (r510)
+++ webkit/trunk/WebKit/haiku/WebPositive/BrowserApp.cpp        Thu May 20 
19:57:34 2010        (r511)
@@ -336,7 +336,10 @@
                        continue;
                if (webWindow->Lock()) {
                        if (webWindow->Workspaces() & workspace) {
-                               webWindow->CreateNewTab(url, true);
+                               if (webWindow->IsBlankTab())
+                                       
webWindow->CurrentWebView()->LoadURL(url);
+                               else
+                                       webWindow->CreateNewTab(url, true);
                                webWindow->Activate();
                                loadedInWindowOnCurrentWorkspace = true;
                        }

Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp     Thu May 20 
19:31:56 2010        (r510)
+++ webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp     Thu May 20 
19:57:34 2010        (r511)
@@ -474,7 +474,10 @@
                kSettingsKeyAutoHideInterfaceInFullscreenMode,
                fAutoHideInterfaceInFullscreenMode));
 
-       AddShortcut('F', B_COMMAND_KEY | B_SHIFT_KEY, new 
BMessage(EDIT_HIDE_FIND_GROUP));
+       AddShortcut('F', B_COMMAND_KEY | B_SHIFT_KEY,
+               new BMessage(EDIT_HIDE_FIND_GROUP));
+       // TODO: Should be a different shortcut, H is usually for Find 
selection.
+       AddShortcut('H', B_COMMAND_KEY, new BMessage(HOME));
 
        // Add shortcuts to select a particular tab
        for (int32 i = 1; i <= 9; i++) {
@@ -993,6 +996,17 @@
 }
 
 
+bool
+BrowserWindow::IsBlankTab() const
+{
+       if (CurrentWebView() == NULL)
+               return false;
+       BString requestedURL = CurrentWebView()->MainFrameRequestedURL();
+       return requestedURL.Length() == 0
+               || requestedURL == _NewTabURL(fTabManager->CountTabs() == 1);
+}
+
+
 void
 BrowserWindow::CreateNewTab(const BString& _url, bool select, BWebView* 
webView)
 {
@@ -1006,25 +1020,8 @@
        fTabManager->AddTab(webView, "New tab");
 
        BString url(_url);
-       if (applyNewPagePolicy && url.Length() == 0) {
-               uint32 policy = isNewWindow ? fNewWindowPolicy : fNewTabPolicy;
-               // Implement new page policy
-               switch (policy) {
-                       case OpenStartPage:
-                               url = fStartPageURL;
-                               break;
-                       case OpenSearchPage:
-                               url = fSearchPageURL;
-                               break;
-                       case CloneCurrentPage:
-                               if (CurrentWebView() != NULL)
-                                       url = CurrentWebView()->MainFrameURL();
-                               break;
-                       case OpenBlankPage:
-                       default:
-                               break;
-               }
-       }
+       if (applyNewPagePolicy && url.Length() == 0)
+               url = _NewTabURL(isNewWindow);
 
        if (url.Length() > 0)
                webView->LoadURL(url.String());
@@ -1980,3 +1977,27 @@
                fLoadingProgressBar->Hide();
 }
 
+
+BString
+BrowserWindow::_NewTabURL(bool isNewWindow) const
+{
+       BString url;
+       uint32 policy = isNewWindow ? fNewWindowPolicy : fNewTabPolicy;
+       // Implement new page policy
+       switch (policy) {
+               case OpenStartPage:
+                       url = fStartPageURL;
+                       break;
+               case OpenSearchPage:
+                       url = fSearchPageURL;
+                       break;
+               case CloneCurrentPage:
+                       if (CurrentWebView() != NULL)
+                               url = CurrentWebView()->MainFrameURL();
+                       break;
+               case OpenBlankPage:
+               default:
+                       break;
+       }
+       return url;
+}

Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h       Thu May 20 
19:31:56 2010        (r510)
+++ webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h       Thu May 20 
19:57:34 2010        (r511)
@@ -104,6 +104,7 @@
 
        virtual void                            SetCurrentWebView(BWebView* 
view);
 
+                       bool                            IsBlankTab() const;
                        void                            CreateNewTab(const 
BString& url, bool select,
                                                                        
BWebView* webView = 0);
 
@@ -187,6 +188,8 @@
                        void                            
_CheckAutoHideInterface();
                        void                            _ShowInterface(bool 
show);
 
+                       BString                         _NewTabURL(bool 
isNewWindow) const;
+
 private:
                        BMenu*                          fHistoryMenu;
                        int32                           
fHistoryMenuFixedItemCount;

Other related posts:

  • » [haiku-webkit-commits] r511 - webkit/trunk/WebKit/haiku/WebPositive - webkit