[haiku-commits] haiku: hrev46673 - src/apps/webpositive

  • From: pulkomandy@xxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 14 Jan 2014 11:31:03 +0100 (CET)

hrev46673 adds 1 changeset to branch 'master'
old head: dd71f181755e323ef18a99b664d116d1d91e1891
new head: 48af26c7d3d247d790fcd7531708aca4e83e7e94
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=48af26c+%5Edd71f18

----------------------------------------------------------------------------

48af26c: Don't reuse same tab for multiple bookmarks.
  
  As WebKit is asynchronous to the window, when launching a request in a
  BWebView, IsBlankTab() will keep returning true until it gets the
  BMessage and updates its state.
  
  When opening bookmarks or refs, we would send them too fast, not detect
  this, and reuse the same tab for several items. Make sure the blank tab
  is only used once when looping over the refs, and force opening all
  remaining refs in new tabs of the same window.
  
  Fixes #6625.
  
  Also optimizes the ref loading by not looking up the window for each
  ref. Pick one window, then use it for all the bookmarks in the loop.

                             [ Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev46673
Commit:      48af26c7d3d247d790fcd7531708aca4e83e7e94
URL:         http://cgit.haiku-os.org/haiku/commit/?id=48af26c
Author:      Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Date:        Tue Jan 14 09:59:20 2014 UTC

Ticket:      https://dev.haiku-os.org/ticket/6625

----------------------------------------------------------------------------

2 files changed, 20 insertions(+), 15 deletions(-)
src/apps/webpositive/BrowserApp.cpp | 28 ++++++++++++++++------------
src/apps/webpositive/BrowserApp.h   |  7 ++++---

----------------------------------------------------------------------------

diff --git a/src/apps/webpositive/BrowserApp.cpp 
b/src/apps/webpositive/BrowserApp.cpp
index 384ab76..ba6f50b 100644
--- a/src/apps/webpositive/BrowserApp.cpp
+++ b/src/apps/webpositive/BrowserApp.cpp
@@ -374,13 +374,13 @@ BrowserApp::_RefsReceived(BMessage* message, int32* 
_pagesCreated,
                        continue;
                BString url;
                url << path.Path();
-               _CreateNewPage(url, window, fullscreen);
+               window = _CreateNewPage(url, window, fullscreen, pagesCreated 
== 0);
                pagesCreated++;
        }
 
        BString url;
        for (int32 i = 0; message->FindString("url", i, &url) == B_OK; i++) {
-               _CreateNewPage(url, window, fullscreen);
+               window = _CreateNewPage(url, window, fullscreen, pagesCreated 
== 0);
                pagesCreated++;
        }
 
@@ -391,13 +391,13 @@ BrowserApp::_RefsReceived(BMessage* message, int32* 
_pagesCreated,
 }
 
 
-void
+BrowserWindow*
 BrowserApp::_CreateNewPage(const BString& url, BrowserWindow* webWindow,
-       bool fullscreen)
+       bool fullscreen, bool useBlankTab)
 {
-       // Let's first see if we must target a specific window
+       // Let's first see if we must target a specific window...
        if (webWindow && webWindow->Lock()) {
-               if (webWindow->IsBlankTab()) {
+               if (useBlankTab && webWindow->IsBlankTab()) {
                        if (url.Length() != 0)
                                webWindow->CurrentWebView()->LoadURL(url);
                } else
@@ -405,10 +405,10 @@ BrowserApp::_CreateNewPage(const BString& url, 
BrowserWindow* webWindow,
                webWindow->Activate();
                webWindow->CurrentWebView()->MakeFocus(true);
                webWindow->Unlock();
-               return;
+               return webWindow;
        }
 
-       // In other cases, try to find a suitable one
+       // Otherwise, try to find one in the current workspace
        uint32 workspace = 1 << current_workspace();
 
        bool loadedInWindowOnCurrentWorkspace = false;
@@ -416,9 +416,10 @@ BrowserApp::_CreateNewPage(const BString& url, 
BrowserWindow* webWindow,
                webWindow = dynamic_cast<BrowserWindow*>(window);
                if (!webWindow)
                        continue;
+
                if (webWindow->Lock()) {
                        if (webWindow->Workspaces() & workspace) {
-                               if (webWindow->IsBlankTab()) {
+                               if (useBlankTab && webWindow->IsBlankTab()) {
                                        if (url.Length() != 0)
                                                
webWindow->CurrentWebView()->LoadURL(url);
                                } else
@@ -430,13 +431,15 @@ BrowserApp::_CreateNewPage(const BString& url, 
BrowserWindow* webWindow,
                        webWindow->Unlock();
                }
                if (loadedInWindowOnCurrentWorkspace)
-                       return;
+                       return webWindow;
        }
-       _CreateNewWindow(url, fullscreen);
+
+       // Finally, if no window is available, let's create one.
+       return _CreateNewWindow(url, fullscreen);
 }
 
 
-void
+BrowserWindow*
 BrowserApp::_CreateNewWindow(const BString& url, bool fullscreen)
 {
        // Offset the window frame unless this is the first window created in 
the
@@ -451,6 +454,7 @@ BrowserApp::_CreateNewWindow(const BString& url, bool 
fullscreen)
        if (fullscreen)
                window->ToggleFullscreen();
        window->Show();
+       return window;
 }
 
 
diff --git a/src/apps/webpositive/BrowserApp.h 
b/src/apps/webpositive/BrowserApp.h
index 96b3aef..937cd05 100644
--- a/src/apps/webpositive/BrowserApp.h
+++ b/src/apps/webpositive/BrowserApp.h
@@ -58,10 +58,11 @@ private:
                        void                            _RefsReceived(BMessage* 
message,
                                                                        int32* 
pagesCreated = NULL,
                                                                        bool* 
fullscreen = NULL);
-                       void                            _CreateNewPage(const 
BString& url,
+                       BrowserWindow*          _CreateNewPage(const BString& 
url,
                                                                        
BrowserWindow* window = NULL,
-                                                                       bool 
fullscreen = false);
-                       void                            _CreateNewWindow(const 
BString& url,
+                                                                       bool 
fullscreen = false,
+                                                                       bool 
useBlankTab = true);
+                       BrowserWindow*          _CreateNewWindow(const BString& 
url,
                                                                        bool 
fullscreen = false);
                        void                            
_CreateNewTab(BrowserWindow* window,
                                                                        const 
BString& url, bool select);


Other related posts: