[haiku-webkit-commits] r238 - in webkit/trunk/WebKit: . haiku/HaikuLauncher haiku/WebPositive

  • From: webkit@xxxxxxxxxxxxxxx
  • To: haiku-webkit-commits@xxxxxxxxxxxxx
  • Date: Sat, 27 Feb 2010 15:51:43 +0000

Author: stippi
Date: Sat Feb 27 15:51:43 2010
New Revision: 238
URL: http://mmlr.dyndns.org/changeset/238

Log:
Split up WebPositive from HaikuLauncher. HaikuLauncher is back to it's simple
self. WebPositive uses a new WebPositive folder in config/settings. Otherwise,
everything should be as before. LauncherWindow and LauncherApp have been renamed
and cleaned up for the Haiku coding style.

Added:
   webkit/trunk/WebKit/haiku/WebPositive/
      - copied from r231, webkit/trunk/WebKit/haiku/HaikuLauncher/
   webkit/trunk/WebKit/haiku/WebPositive/BrowserApp.cpp
      - copied, changed from r231, 
webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherApp.cpp
   webkit/trunk/WebKit/haiku/WebPositive/BrowserApp.h
      - copied, changed from r231, 
webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherApp.h
   webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp
      - copied, changed from r231, 
webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.cpp
   webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h
      - copied, changed from r231, 
webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.h
   webkit/trunk/WebKit/haiku/WebPositive/WebPositive.rdef
      - copied, changed from r231, 
webkit/trunk/WebKit/haiku/HaikuLauncher/Launcher.rdef
Replaced:
   webkit/trunk/WebKit/haiku/WebPositive/WebTabView.cpp
      - copied unchanged from r237, 
webkit/trunk/WebKit/haiku/HaikuLauncher/WebTabView.cpp
   webkit/trunk/WebKit/haiku/WebPositive/WebTabView.h
      - copied unchanged from r237, 
webkit/trunk/WebKit/haiku/HaikuLauncher/WebTabView.h
Deleted:
   webkit/trunk/WebKit/haiku/HaikuLauncher/AuthenticationPanel.cpp
   webkit/trunk/WebKit/haiku/HaikuLauncher/AuthenticationPanel.h
   webkit/trunk/WebKit/haiku/HaikuLauncher/BrowsingHistory.cpp
   webkit/trunk/WebKit/haiku/HaikuLauncher/BrowsingHistory.h
   webkit/trunk/WebKit/haiku/HaikuLauncher/DateTime.cpp
   webkit/trunk/WebKit/haiku/HaikuLauncher/DateTime.h
   webkit/trunk/WebKit/haiku/HaikuLauncher/DownloadWindow.cpp
   webkit/trunk/WebKit/haiku/HaikuLauncher/DownloadWindow.h
   webkit/trunk/WebKit/haiku/HaikuLauncher/IconButton.cpp
   webkit/trunk/WebKit/haiku/HaikuLauncher/IconButton.h
   webkit/trunk/WebKit/haiku/HaikuLauncher/IconUtils.h
   webkit/trunk/WebKit/haiku/HaikuLauncher/WebTabView.cpp
   webkit/trunk/WebKit/haiku/HaikuLauncher/WebTabView.h
   webkit/trunk/WebKit/haiku/WebPositive/Launcher.rdef
   webkit/trunk/WebKit/haiku/WebPositive/LauncherApp.cpp
   webkit/trunk/WebKit/haiku/WebPositive/LauncherApp.h
   webkit/trunk/WebKit/haiku/WebPositive/LauncherWindow.cpp
   webkit/trunk/WebKit/haiku/WebPositive/LauncherWindow.h
Modified:
   webkit/trunk/WebKit/Jamfile
   webkit/trunk/WebKit/haiku/HaikuLauncher/Launcher.rdef
   webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherApp.cpp
   webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherApp.h
   webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.cpp
   webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.h
   webkit/trunk/WebKit/haiku/WebPositive/BrowsingHistory.cpp
   webkit/trunk/WebKit/haiku/WebPositive/DownloadWindow.cpp

Modified: webkit/trunk/WebKit/Jamfile
==============================================================================
--- webkit/trunk/WebKit/Jamfile Sat Feb 27 13:31:29 2010        (r237)
+++ webkit/trunk/WebKit/Jamfile Sat Feb 27 15:51:43 2010        (r238)
@@ -89,13 +89,33 @@
 SEARCH_SOURCE += [ FDirName $(TOP) WebKit haiku HaikuLauncher ] ;
 
 Application HaikuLauncher :
+       LauncherApp.cpp
+       LauncherWindow.cpp
+
+       :
+       libjavascriptcore.so libwebcore.so libwebkit.so
+       # Other required libraries
+       curl icu-common icu-data png sqlite3 xml2 z
+       # Haiku libraries
+       be bsd network root stdc++ translation
+       :
+       Launcher.rdef
+;
+
+
+#-----------------------------------------------------------------------------
+# WebPositive
+#-----------------------------------------------------------------------------
+SEARCH_SOURCE += [ FDirName $(TOP) WebKit haiku WebPositive ] ;
+
+Application WebPositive :
     AuthenticationPanel.cpp
     BrowsingHistory.cpp
     DateTime.cpp
     DownloadWindow.cpp
     IconButton.cpp
-       LauncherApp.cpp
-       LauncherWindow.cpp
+       BrowserApp.cpp
+       BrowserWindow.cpp
        WebTabView.cpp
 
        :
@@ -105,5 +125,5 @@
        # Haiku libraries
        be bsd network root stdc++ translation
        :
-       Launcher.rdef
+       WebPositive.rdef
 ;

Modified: webkit/trunk/WebKit/haiku/HaikuLauncher/Launcher.rdef
==============================================================================
--- webkit/trunk/WebKit/haiku/HaikuLauncher/Launcher.rdef       Sat Feb 27 
13:31:29 2010        (r237)
+++ webkit/trunk/WebKit/haiku/HaikuLauncher/Launcher.rdef       Sat Feb 27 
15:51:43 2010        (r238)
@@ -252,52 +252,3 @@
        $"44013402360000000000000000360000485000466000"
 };
 
-resource(201) #'VICN' array {
-       $"6E636966070500020006023B2FA63AC896BCCBD33D335A4A6980490D0B00ACE2"
-       $"FFFF6ECDFF0200060236D841374D6EBD38553CC6154AA9DF4607770026A8EBFF"
-       $"0694DE020006023729EA388C8FBC29073AAE614A51AF4A729A00035E8CFF0585"
-       $"C70200060238E8A83647FBBA8E2D3D42294AF6F7496CE200047BB8FF0694DE02"
-       $"0006023957BB3923F0BC39AC3C5E604AA873475AB1000592DAFD67CBFF04FF49"
-       $"080A092E3C3A53424C484F5047503A4435442B3A300A072E3C3A533A48484F48"
-       $"403A3A3A300A043A303A3A4435442B0A033A483A53424C0A044840484F504750"
-       $"3A0A043A3A4435503A48400803C125B7D43AB99FB8D3BE0E08023A3A4840070A"
-       $"0001001001178400040A010101000A020102000A030103000A040104000A0501"
-       $"05000A06020607100117812004"
-};
-
-resource(202) #'VICN' array {
-       $"6E636966050500020006023B2FA63AC896BCCBD33D335A4A6980490D0B00ACE2"
-       $"FFFF6ECDFF0200060239AF2C39E19BBC89D83C68DC4AFA1247CFA20006A5F7FF"
-       $"069EEC02000602B8EEBEB986C33C7FB4BC13FB46FA0C49FBDD000592DAFD3EBD"
-       $"FF04FF49050A0A2E423A483A524847503F432A3A2F3A3136302E350A0748473A"
-       $"2F3A392E352E423A483A520A043A2F4847503F432A0A042E3536303A313A3908"
-       $"0536B9932FBB773B3A3BB939C0E5B755050A0001001001178400040A01010100"
-       $"0A020102000A030103000A040104100117812004"
-};
-
-resource(203) #'VICN' array {
-       $"6E63696607050002000602396DF23A056B3B94FCBB09F547CD484AAB5F0090D9"
-       $"FFFF6ECDFF02000602B5E5793878A83E023B3B2AC34893F147CC490060C8FFFF"
-       $"44BEFD02000602B6F90538542D3C2FCA3ACA9249A8634A929A00034F77FF0468"
-       $"9C020006023AC62E392AB63B6BA0BCFF0B49DAAA4AAE4500046FA7FF2BA5E502"
-       $"0006023A1CB834EBA6383E33BD3E8D499DE44A647800ACE2FFFD6DCCFF04FF49"
-       $"080A09523A48533F503C532E4C2E3E3A363A2B482E0A07523A485348473C533C"
-       $"43483A482E0A04482E483A3A363A2B0A03484748533F500A043C433C532E4C2E"
-       $"3E0A04483A3A362E3E3C430802BD8FB795C2BDB8E008023C43B8C7BF0D070A00"
-       $"01001001178400040A040101000A020102000A030103000A010104000A050105"
-       $"000A06020607100117812004"
-};
-
-resource(204) #'VICN' array {
-       $"6E63696606050102000602393D323BB602BEA28F3C4CC64B601449439F00FF3E"
-       $"3EFFF70606020006033B27153C10C7BDF9893D088A4B2F634882C500C805057D"
-       $"9D0404FFB4040403750303020006023B06EB3B5469BC08EB3BB31F4AB15D4478"
-       $"7700FF9090FFFF757504FF440A0A0C2E4C364E3C4742524A5440434A3842353C"
-       $"BE1B36312E2E38400A0636313C3C40434A54504E402E0A03364E3E483C470A04"
-       $"483FC712BADE4A3840430A042E2E3631402E382C0A0442354A38C712BADE4AB9"
-       $"EC0A0E2E4C364EBEB6C37042524A54504E483FC712BADE4AB9EC4335402E382C"
-       $"2E2E384008022FB8A0BCC3B80708033C3C42364ABA120802BCA9BFF3B8D3C47B"
-       $"060A0001061001178400040A020101000A03020302000A010100000A04020504"
-       $"000A0503070809100117810004"
-};
-

Modified: webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherApp.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherApp.cpp     Sat Feb 27 
13:31:29 2010        (r237)
+++ webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherApp.cpp     Sat Feb 27 
15:51:43 2010        (r238)
@@ -29,9 +29,6 @@
 #include "config.h"
 #include "LauncherApp.h"
 
-#include "DownloadWindow.h"
-#include "FrameView.h"
-#include "GraphicsContext.h"
 #include "LauncherWindow.h"
 #include "WebPage.h"
 #include "WebView.h"
@@ -45,7 +42,7 @@
 #include <Screen.h>
 #include <stdio.h>
 
-extern const char* kApplicationSignature = 
"application/x-vnd.RJL-HaikuLauncher";
+const char* kApplicationSignature = "application/x-vnd.RJL-HaikuLauncher";
 enum {
     LOAD_AT_STARTING = 'lost'
 };
@@ -57,7 +54,6 @@
     , m_lastWindowFrame(100, 100, 700, 750)
     , m_launchRefsMessage(0)
     , m_initialized(false)
-    , m_downloadWindow(0)
 {
 }
 
@@ -98,19 +94,13 @@
 
        BFile settingsFile;
        BRect windowFrameFromSettings = m_lastWindowFrame;
-       BRect downloadWindowFrame(100, 100, 300, 250);
-       bool showDownloads = false;
        if (openSettingsFile(settingsFile, B_READ_ONLY)) {
                BMessage settingsArchive;
                settingsArchive.Unflatten(&settingsFile);
                settingsArchive.FindRect("window frame", 
&windowFrameFromSettings);
-               settingsArchive.FindRect("downloads window frame", 
&downloadWindowFrame);
-               settingsArchive.FindBool("show downloads", &showDownloads);
        }
        m_lastWindowFrame = windowFrameFromSettings;
 
-    m_downloadWindow = new DownloadWindow(downloadWindowFrame, showDownloads);
-
        m_initialized = true;
 
        if (m_launchRefsMessage) {
@@ -118,8 +108,7 @@
                delete m_launchRefsMessage;
                m_launchRefsMessage = 0;
        } else {
-           LauncherWindow* window = new LauncherWindow(m_lastWindowFrame,
-               BMessenger(m_downloadWindow));
+           LauncherWindow* window = new LauncherWindow(m_lastWindowFrame);
            window->Show();
        }
 }
@@ -166,17 +155,6 @@
        newWindow(url);
        break;
     }
-    case NEW_TAB: {
-       LauncherWindow* window;
-               if (message->FindPointer("window", 
reinterpret_cast<void**>(&window)) != B_OK)
-                       break;
-       BString url;
-               message->FindString("url", &url);
-       bool select = false;
-               message->FindBool("select", &select);
-       newTab(window, url, select);
-        break;
-    }
     case WINDOW_OPENED:
        m_windowCount++;
        break;
@@ -187,17 +165,6 @@
                PostMessage(B_QUIT_REQUESTED);
        break;
 
-    case SHOW_DOWNLOAD_WINDOW: {
-       BAutolock _(m_downloadWindow);
-        uint32 workspaces;
-        if (message->FindUInt32("workspaces", &workspaces) == B_OK)
-            m_downloadWindow->SetWorkspaces(workspaces);
-        if (m_downloadWindow->IsHidden())
-            m_downloadWindow->Show();
-        else
-            m_downloadWindow->Activate();
-    }
-
     default:
         BApplication::MessageReceived(message);
         break;
@@ -248,11 +215,6 @@
        if (openSettingsFile(settingsFile, B_CREATE_FILE | B_ERASE_FILE | 
B_WRITE_ONLY)) {
                BMessage settingsArchive;
                settingsArchive.AddRect("window frame", m_lastWindowFrame);
-               if (m_downloadWindow->Lock()) {
-           settingsArchive.AddRect("downloads window frame", 
m_downloadWindow->Frame());
-               settingsArchive.AddBool("show downloads", 
!m_downloadWindow->IsHidden());
-               m_downloadWindow->Unlock();
-               }
                settingsArchive.Flatten(&settingsFile);
        }
 
@@ -275,21 +237,12 @@
        if (!BScreen().Frame().Contains(m_lastWindowFrame))
                m_lastWindowFrame.OffsetTo(50, 50);
 
-       LauncherWindow* window = new LauncherWindow(m_lastWindowFrame,
-           BMessenger(m_downloadWindow));
+       LauncherWindow* window = new LauncherWindow(m_lastWindowFrame);
        window->Show();
        if (url.Length())
            window->CurrentWebView()->LoadURL(url.String());
 }
 
-void LauncherApp::newTab(LauncherWindow* window, const BString& url, bool 
select)
-{
-    if (!window->Lock())
-        return;
-    window->newTab(url, select);
-    window->Unlock();
-}
-
 // #pragma mark -
 
 int main(int, char**)

Modified: webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherApp.h
==============================================================================
--- webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherApp.h       Sat Feb 27 
13:31:29 2010        (r237)
+++ webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherApp.h       Sat Feb 27 
15:51:43 2010        (r238)
@@ -33,7 +33,6 @@
 #include <Rect.h>
 
 class BFile;
-class DownloadWindow;
 class LauncherWindow;
 
 class LauncherApp : public BApplication {
@@ -51,14 +50,11 @@
 private:
        bool openSettingsFile(BFile& file, uint32 mode);
        void newWindow(const BString& url);
-       void newTab(LauncherWindow* window, const BString& url, bool select);
 
     int m_windowCount;
     BRect m_lastWindowFrame;
     BMessage* m_launchRefsMessage;
     bool m_initialized;
-
-    DownloadWindow* m_downloadWindow;
 };
 
 extern const char* kApplicationSignature;

Modified: webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.cpp  Sat Feb 27 
13:31:29 2010        (r237)
+++ webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.cpp  Sat Feb 27 
15:51:43 2010        (r238)
@@ -33,19 +33,11 @@
 #include "config.h"
 #include "LauncherWindow.h"
 
-#include "AuthenticationPanel.h"
-#include "BrowsingHistory.h"
-#include "IconButton.h"
 #include "LauncherApp.h"
 #include "WebPage.h"
-#include "WebTabView.h"
 #include "WebView.h"
 #include "WebViewConstants.h"
-#include <Alert.h>
-#include <Application.h>
-#include <Bitmap.h>
 #include <Button.h>
-#include <CheckBox.h>
 #include <Entry.h>
 #include <GridLayoutBuilder.h>
 #include <GroupLayout.h>
@@ -68,187 +60,27 @@
     STOP = 'stop',
     GOTO_URL = 'goul',
     RELOAD = 'reld',
-    CLEAR_HISTORY = 'clhs',
 
     TEXT_SIZE_INCREASE = 'tsin',
     TEXT_SIZE_DECREASE = 'tsdc',
     TEXT_SIZE_RESET = 'tsrs',
-
-    TEXT_SHOW_FIND_GROUP = 'sfnd',
-    TEXT_HIDE_FIND_GROUP = 'hfnd',
-    TEXT_FIND_NEXT = 'fndn',
-    TEXT_FIND_PREVIOUS = 'fndp',
 };
 
-using namespace WebCore;
-
-static BLayoutItem* layoutItemFor(BView* view)
+LauncherWindow::LauncherWindow(BRect frame, ToolbarPolicy toolbarPolicy)
+    : BWebWindow(frame, "HaikuLauncher",
+        B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
+        B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS)
 {
-    BLayout* layout = view->Parent()->GetLayout();
-    int32 index = layout->IndexOfView(view);
-    return layout->ItemAt(index);
+       init(new BWebView("web view"), toolbarPolicy);
 }
 
-LauncherWindow::LauncherWindow(BRect frame, const BMessenger& downloadListener,
-        ToolbarPolicy toolbarPolicy)
+LauncherWindow::LauncherWindow(BRect frame, BWebView* webView,
+               ToolbarPolicy toolbarPolicy)
     : BWebWindow(frame, "HaikuLauncher",
         B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
         B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS)
-    , m_downloadListener(downloadListener)
 {
-    BMessage* newTabMessage = new BMessage(NEW_TAB);
-    newTabMessage->AddString("url", "");
-    newTabMessage->AddPointer("window", this);
-    newTabMessage->AddBool("select", true);
-    m_tabManager = new TabManager(BMessenger(this), newTabMessage);
-
-    if (toolbarPolicy == HaveToolbar) {
-        // Menu
-        m_menuBar = new BMenuBar("Main menu");
-        BMenu* menu = new BMenu("Window");
-        BMessage* newWindowMessage = new BMessage(NEW_WINDOW);
-        newWindowMessage->AddString("url", "");
-        BMenuItem* newItem = new BMenuItem("New window", newWindowMessage, 
'N');
-        menu->AddItem(newItem);
-        newItem->SetTarget(be_app);
-        newItem = new BMenuItem("New tab", new BMessage(*newTabMessage), 'T');
-        menu->AddItem(newItem);
-        newItem->SetTarget(be_app);
-        menu->AddItem(new BMenuItem("Open location", new 
BMessage(OPEN_LOCATION), 'L'));
-        menu->AddSeparatorItem();
-        menu->AddItem(new BMenuItem("Close window", new 
BMessage(B_QUIT_REQUESTED), 'W', B_SHIFT_KEY));
-        menu->AddItem(new BMenuItem("Close tab", new BMessage(CLOSE_TAB), 
'W'));
-        menu->AddSeparatorItem();
-        menu->AddItem(new BMenuItem("Show downloads", new 
BMessage(SHOW_DOWNLOAD_WINDOW), 'J'));
-        menu->AddSeparatorItem();
-        BMenuItem* quitItem = new BMenuItem("Quit", new 
BMessage(B_QUIT_REQUESTED), 'Q');
-        menu->AddItem(quitItem);
-        quitItem->SetTarget(be_app);
-        m_menuBar->AddItem(menu);
-
-        menu = new BMenu("Text");
-        menu->AddItem(new BMenuItem("Find", new 
BMessage(TEXT_SHOW_FIND_GROUP), 'F'));
-        menu->AddSeparatorItem();
-        menu->AddItem(new BMenuItem("Increase size", new 
BMessage(TEXT_SIZE_INCREASE), '+'));
-        menu->AddItem(new BMenuItem("Decrease size", new 
BMessage(TEXT_SIZE_DECREASE), '-'));
-        menu->AddItem(new BMenuItem("Reset size", new 
BMessage(TEXT_SIZE_RESET), '0'));
-        m_menuBar->AddItem(menu);
-
-        m_goMenu = new BMenu("Go");
-        m_menuBar->AddItem(m_goMenu);
-
-        // Back, Forward & Stop
-        m_BackButton = new IconButton("Back", 0, NULL, new BMessage(GO_BACK));
-        m_BackButton->SetIcon(201);
-        m_BackButton->TrimIcon();
-
-        m_ForwardButton = new IconButton("Forward", 0, NULL, new 
BMessage(GO_FORWARD));
-        m_ForwardButton->SetIcon(202);
-        m_ForwardButton->TrimIcon();
-
-        m_StopButton = new IconButton("Stop", 0, NULL, new BMessage(STOP));
-        m_StopButton->SetIcon(204);
-        m_StopButton->TrimIcon();
-
-        // URL
-        m_url = new BTextControl("url", "", "", NULL);
-        m_url->SetDivider(50.0);
-
-        // Go
-        m_goButton = new BButton("", "Go", new BMessage(GOTO_URL));
-
-        // Status Bar
-        m_statusText = new BStringView("status", "");
-        m_statusText->SetAlignment(B_ALIGN_LEFT);
-        m_statusText->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 
B_SIZE_UNSET));
-        m_statusText->SetExplicitMinSize(BSize(150, 12));
-            // Prevent the window from growing to fit a long status message...
-        BFont font(be_plain_font);
-        font.SetSize(ceilf(font.Size() * 0.8));
-        m_statusText->SetFont(&font, B_FONT_SIZE);
-
-        // Loading progress bar
-        m_loadingProgressBar = new BStatusBar("progress");
-        m_loadingProgressBar->SetMaxValue(100);
-        m_loadingProgressBar->Hide();
-        m_loadingProgressBar->SetBarHeight(12);
-
-        const float kInsetSpacing = 5;
-        const float kElementSpacing = 7;
-
-        m_findTextControl = new BTextControl("find", "Find:", "",
-            new BMessage(TEXT_FIND_NEXT));
-        m_findCaseSensitiveCheckBox = new BCheckBox("Match case");
-        BView* findGroup = BGroupLayoutBuilder(B_VERTICAL)
-            .Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
-            .Add(BGroupLayoutBuilder(B_HORIZONTAL, kElementSpacing)
-                .Add(m_findTextControl)
-                .Add(new BButton("Previous", new BMessage(TEXT_FIND_PREVIOUS)))
-                .Add(new BButton("Next", new BMessage(TEXT_FIND_NEXT)))
-                .Add(m_findCaseSensitiveCheckBox)
-                .Add(BSpaceLayoutItem::CreateGlue())
-                .Add(new BButton("Close", new BMessage(TEXT_HIDE_FIND_GROUP)))
-                .SetInsets(kInsetSpacing, kInsetSpacing,
-                    kInsetSpacing, kInsetSpacing)
-            )
-        ;
-        // Layout
-        AddChild(BGroupLayoutBuilder(B_VERTICAL)
-            .Add(m_menuBar)
-            .Add(m_tabManager->TabGroup())
-            .Add(BGridLayoutBuilder(kElementSpacing, kElementSpacing)
-                .Add(m_BackButton, 0, 0)
-                .Add(m_ForwardButton, 1, 0)
-                .Add(m_StopButton, 2, 0)
-                .Add(m_url, 3, 0)
-                .Add(m_goButton, 4, 0)
-                .SetInsets(kInsetSpacing, kInsetSpacing, kInsetSpacing, 
kInsetSpacing)
-            )
-            .Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
-            .Add(m_tabManager->ContainerView())
-            .Add(findGroup)
-            .Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
-            .Add(BGroupLayoutBuilder(B_HORIZONTAL, kElementSpacing)
-                .Add(m_statusText)
-                .Add(m_loadingProgressBar, 0.2)
-                .AddStrut(12 - kElementSpacing)
-                .SetInsets(kInsetSpacing, 0, kInsetSpacing, 0)
-            )
-        );
-
-        m_url->MakeFocus(true);
-
-        m_findGroup = layoutItemFor(findGroup);
-        m_tabGroup = layoutItemFor(m_tabManager->TabGroup());
-    } else {
-        m_BackButton = 0;
-        m_ForwardButton = 0;
-        m_StopButton = 0;
-        m_goButton = 0;
-        m_url = 0;
-        m_menuBar = 0;
-        m_statusText = 0;
-        m_loadingProgressBar = 0;
-
-        BWebView* webView = new BWebView("web_view");
-        SetCurrentWebView(webView);
-
-        AddChild(BGroupLayoutBuilder(B_VERTICAL, 7)
-            .Add(CurrentWebView())
-        );
-    }
-
-    newTab("", true);
-
-    m_findGroup->SetVisible(false);
-
-    AddShortcut('G', B_COMMAND_KEY, new BMessage(TEXT_FIND_NEXT));
-    AddShortcut('G', B_COMMAND_KEY | B_SHIFT_KEY, new 
BMessage(TEXT_FIND_PREVIOUS));
-    AddShortcut('F', B_COMMAND_KEY, new BMessage(TEXT_SHOW_FIND_GROUP));
-    AddShortcut('F', B_COMMAND_KEY | B_SHIFT_KEY, new 
BMessage(TEXT_HIDE_FIND_GROUP));
-    AddShortcut('R', B_COMMAND_KEY, new BMessage(RELOAD));
-       
-    be_app->PostMessage(WINDOW_OPENED);
+       init(webView, toolbarPolicy);
 }
 
 LauncherWindow::~LauncherWindow()
@@ -307,17 +139,6 @@
         CurrentWebView()->StopLoading();
         break;
 
-    case CLEAR_HISTORY: {
-        BrowsingHistory* history = BrowsingHistory::defaultInstance();
-        if (history->countItems() == 0)
-            break;
-        BAlert* alert = new BAlert("Confirmation", "Do you really want to 
clear "
-            "the browsing history?", "Clear", "Cancel");
-        if (alert->Go() == 0)
-            history->clear();
-        break;
-    }
-
     case B_SIMPLE_DATA: {
         // User possibly dropped files on this window.
         // If there is more than one entry_ref, let the app handle it (open one
@@ -354,62 +175,6 @@
         CurrentWebView()->ResetTextSize();
         break;
 
-    case TEXT_FIND_NEXT:
-        CurrentWebView()->FindString(m_findTextControl->Text(), true,
-            m_findCaseSensitiveCheckBox->Value());
-        break;
-    case TEXT_FIND_PREVIOUS:
-        CurrentWebView()->FindString(m_findTextControl->Text(), false,
-            m_findCaseSensitiveCheckBox->Value());
-        break;
-    case TEXT_SHOW_FIND_GROUP:
-        if (!m_findGroup->IsVisible())
-            m_findGroup->SetVisible(true);
-        m_findTextControl->MakeFocus(true);
-        break;
-    case TEXT_HIDE_FIND_GROUP:
-        if (m_findGroup->IsVisible())
-            m_findGroup->SetVisible(false);
-        break;
-
-    case SHOW_DOWNLOAD_WINDOW:
-        message->AddUInt32("workspaces", Workspaces());
-        be_app->PostMessage(message);
-        break;
-
-    case CLOSE_TAB:
-        if (m_tabManager->CountTabs() > 1) {
-               int32 index;
-               if (message->FindInt32("tab index", &index) != B_OK)
-                       index = m_tabManager->SelectedTabIndex();
-            delete m_tabManager->RemoveTab(index);
-            updateTabGroupVisibility();
-        } else
-            PostMessage(B_QUIT_REQUESTED);
-        break;
-
-    case TAB_CHANGED: {
-       // This message may be received also when the last tab closed, i.e. 
with index == -1.
-        int32 index;
-        if (message->FindInt32("tab index", &index) != B_OK)
-            index = -1;
-        BWebView* webView = 
dynamic_cast<BWebView*>(m_tabManager->ViewForTab(index));
-        if (webView == CurrentWebView())
-               break;
-        SetCurrentWebView(webView);
-        if (webView)
-            updateTitle(webView->MainFrameTitle());
-        else
-            updateTitle("");
-        if (webView) {
-            m_url->SetText(webView->MainFrameURL());
-            // Trigger update of the interface to the new page, by requesting
-            // to resend all notifications.
-            webView->WebPage()->ResendNotifications();
-        }
-        break;
-    }
-
     default:
         BWebWindow::MessageReceived(message);
         break;
@@ -418,74 +183,10 @@
 
 bool LauncherWindow::QuitRequested()
 {
-    // TODO: Check for modified form data and ask user for confirmation, etc.
-
-    // Iterate over all tabs to delete all BWebViews.
-    // Do this here, so WebKit tear down happens earlier.
-    while (m_tabManager->CountTabs() > 0)
-        delete m_tabManager->RemoveTab(0L);
-    SetCurrentWebView(0);
-
     BMessage message(WINDOW_CLOSED);
     message.AddRect("window frame", Frame());
     be_app->PostMessage(&message);
-    return true;
-}
-
-void LauncherWindow::MenusBeginning()
-{
-    BMenuItem* menuItem;
-    while ((menuItem = m_goMenu->RemoveItem(0L)))
-        delete menuItem;
-
-    BrowsingHistory* history = BrowsingHistory::defaultInstance();
-    if (!history->Lock())
-        return;
-
-    int32 count = history->countItems();
-    for (int32 i = 0; i < count; i++) {
-        BrowsingHistoryItem historyItem = history->historyItemAt(i);
-        BMessage* message = new BMessage(GOTO_URL);
-        message->AddString("url", historyItem.url().String());
-        // TODO: More sophisticated menu structure... sorted by days/weeks...
-        BString truncatedUrl(historyItem.url());
-        be_plain_font->TruncateString(&truncatedUrl, B_TRUNCATE_END, 480);
-        menuItem = new BMenuItem(truncatedUrl, message);
-        m_goMenu->AddItem(menuItem);
-    }
-
-
-    if (m_goMenu->CountItems() > 3) {
-        m_goMenu->AddSeparatorItem();
-        m_goMenu->AddItem(new BMenuItem("Clear history", new 
BMessage(CLEAR_HISTORY)));
-    }
-
-    history->Unlock();
-}
-
-void LauncherWindow::newTab(const BString& url, bool select, BWebView* webView)
-{
-    // Executed in app thread (new BWebPage needs to be created in app thread).
-    if (!webView)
-        webView = new BWebView("web view");
-    webView->WebPage()->SetDownloadListener(m_downloadListener);
-
-    m_tabManager->AddTab(webView, "New tab");
-
-    if (url.Length())
-        webView->LoadURL(url.String());
-
-    if (select) {
-        m_tabManager->SelectTab(m_tabManager->CountTabs() - 1);
-        SetCurrentWebView(webView);
-        NavigationCapabilitiesChanged(false, false, false, webView);
-        if (m_url) {
-               m_url->SetText(url.String());
-            m_url->MakeFocus(true);
-        }
-    }
-
-    updateTabGroupVisibility();
+    return BWebWindow::QuitRequested();
 }
 
 // #pragma mark - Notification API
@@ -501,16 +202,16 @@
     // But our own WebPage may already try to lock us from within
     // the application thread -> dead-lock. Thus we can't wait for
     // a reply here.
-    BMessage message(NEW_TAB);
-    message.AddPointer("window", this);
+    BMessage message(NEW_WINDOW);
     message.AddString("url", url);
-    message.AddBool("select", primaryAction);
     be_app->PostMessage(&message);
 }
 
 void LauncherWindow::NewPageCreated(BWebView* view)
 {
-    newTab(BString(), true, view);
+       LauncherWindow* window = new LauncherWindow(Frame().OffsetByCopy(10, 
10),
+           view, HaveToolbar);
+       window->Show();
 }
 
 void LauncherWindow::LoadNegotiating(const BString& url, BWebView* view)
@@ -522,9 +223,6 @@
 
 void LauncherWindow::LoadCommitted(const BString& url, BWebView* view)
 {
-    if (view != CurrentWebView())
-        return;
-
        // This hook is invoked when the load is commited.
     if (m_url)
         m_url->SetText(url.String());
@@ -536,9 +234,6 @@
 
 void LauncherWindow::LoadProgress(float progress, BWebView* view)
 {
-    if (view != CurrentWebView())
-        return;
-
     if (m_loadingProgressBar) {
         if (progress < 100 && m_loadingProgressBar->IsHidden())
             m_loadingProgressBar->Show();
@@ -548,9 +243,6 @@
 
 void LauncherWindow::LoadFailed(const BString& url, BWebView* view)
 {
-    if (view != CurrentWebView())
-        return;
-
     BString status(url);
     status << " failed.";
     StatusChanged(status, view);
@@ -560,9 +252,6 @@
 
 void LauncherWindow::LoadFinished(const BString& url, BWebView* view)
 {
-    if (view != CurrentWebView())
-        return;
-
     BString status(url);
     status << " finished.";
     StatusChanged(status, view);
@@ -573,63 +262,28 @@
         m_ForwardButton->IsEnabled(), false, view);
 }
 
-void LauncherWindow::ResizeRequested(float width, float height, BWebView* view)
-{
-    if (view != CurrentWebView())
-        return;
-
-    // TODO: Ignore request when there is more than one BWebView embedded!
-
-    ResizeTo(width, height);
-}
-
 void LauncherWindow::SetToolBarsVisible(bool flag, BWebView* view)
 {
     // TODO
-    // TODO: Ignore request when there is more than one BWebView embedded!
 }
 
 void LauncherWindow::SetStatusBarVisible(bool flag, BWebView* view)
 {
     // TODO
-    // TODO: Ignore request when there is more than one BWebView embedded!
 }
 
 void LauncherWindow::SetMenuBarVisible(bool flag, BWebView* view)
 {
     // TODO
-    // TODO: Ignore request when there is more than one BWebView embedded!
-}
-
-void LauncherWindow::SetResizable(bool flag, BWebView* view)
-{
-    // TODO: Ignore request when there is more than one BWebView embedded!
-
-    if (flag)
-        SetFlags(Flags() & ~B_NOT_RESIZABLE);
-    else
-        SetFlags(Flags() | B_NOT_RESIZABLE);
 }
 
 void LauncherWindow::TitleChanged(const BString& title, BWebView* view)
 {
-    for (int32 i = 0; i < m_tabManager->CountTabs(); i++) {
-        if (m_tabManager->ViewForTab(i) == view) {
-            m_tabManager->SetTabLabel(i, title);
-            break;
-        }
-    }
-    if (view != CurrentWebView())
-        return;
-
     updateTitle(title);
 }
 
 void LauncherWindow::StatusChanged(const BString& statusText, BWebView* view)
 {
-    if (view != CurrentWebView())
-        return;
-
     if (m_statusText)
         m_statusText->SetText(statusText.String());
 }
@@ -637,9 +291,6 @@
 void LauncherWindow::NavigationCapabilitiesChanged(bool canGoBackward,
     bool canGoForward, bool canStop, BWebView* view)
 {
-    if (view != CurrentWebView())
-        return;
-
     if (m_BackButton)
         m_BackButton->SetEnabled(canGoBackward);
     if (m_ForwardButton)
@@ -648,25 +299,104 @@
         m_StopButton->SetEnabled(canStop);
 }
 
-void LauncherWindow::UpdateGlobalHistory(const BString& url)
+void LauncherWindow::init(BWebView* webView, ToolbarPolicy toolbarPolicy)
 {
-    BrowsingHistory::defaultInstance()->addItem(BrowsingHistoryItem(url));
-}
+       SetCurrentWebView(webView);
 
-bool LauncherWindow::AuthenticationChallenge(BString message, BString& 
inOutUser,
-       BString& inOutPassword, bool& inOutRememberCredentials, uint32 
failureCount,
-       BWebView* view)
-{
-       // Switch to the page for which this authentication is required.
-       if (view != CurrentWebView()) {
-               m_tabManager->SelectTab(view);
-               UpdateIfNeeded();
-       }
-    AuthenticationPanel* panel = new AuthenticationPanel(Frame());
-       // Panel auto-destructs.
-    return panel->getAuthentication(message, inOutUser, inOutPassword,
-       inOutRememberCredentials, failureCount > 0, inOutUser, inOutPassword,
-       &inOutRememberCredentials);
+    if (toolbarPolicy == HaveToolbar) {
+        // Menu
+        m_menuBar = new BMenuBar("Main menu");
+        BMenu* menu = new BMenu("Window");
+        BMessage* newWindowMessage = new BMessage(NEW_WINDOW);
+        newWindowMessage->AddString("url", "");
+        BMenuItem* newItem = new BMenuItem("New", newWindowMessage, 'N');
+        menu->AddItem(newItem);
+        newItem->SetTarget(be_app);
+        menu->AddItem(new BMenuItem("Open location", new 
BMessage(OPEN_LOCATION), 'L'));
+        menu->AddSeparatorItem();
+        menu->AddItem(new BMenuItem("Close", new BMessage(B_QUIT_REQUESTED), 
'W', B_SHIFT_KEY));
+        BMenuItem* quitItem = new BMenuItem("Quit", new 
BMessage(B_QUIT_REQUESTED), 'Q');
+        menu->AddItem(quitItem);
+        quitItem->SetTarget(be_app);
+        m_menuBar->AddItem(menu);
+
+        menu = new BMenu("Text");
+        menu->AddItem(new BMenuItem("Increase size", new 
BMessage(TEXT_SIZE_INCREASE), '+'));
+        menu->AddItem(new BMenuItem("Decrease size", new 
BMessage(TEXT_SIZE_DECREASE), '-'));
+        menu->AddItem(new BMenuItem("Reset size", new 
BMessage(TEXT_SIZE_RESET), '0'));
+        m_menuBar->AddItem(menu);
+
+        // Back, Forward & Stop
+        m_BackButton = new BButton("Back", new BMessage(GO_BACK));
+        m_ForwardButton = new BButton("Forward", new BMessage(GO_FORWARD));
+        m_StopButton = new BButton("Stop", new BMessage(STOP));
+
+        // URL
+        m_url = new BTextControl("url", "", "", NULL);
+
+        // Go
+        m_goButton = new BButton("", "Go", new BMessage(GOTO_URL));
+
+        // Status Bar
+        m_statusText = new BStringView("status", "");
+        m_statusText->SetAlignment(B_ALIGN_LEFT);
+        m_statusText->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 
B_SIZE_UNSET));
+        m_statusText->SetExplicitMinSize(BSize(150, 12));
+            // Prevent the window from growing to fit a long status message...
+        BFont font(be_plain_font);
+        font.SetSize(ceilf(font.Size() * 0.8));
+        m_statusText->SetFont(&font, B_FONT_SIZE);
+
+        // Loading progress bar
+        m_loadingProgressBar = new BStatusBar("progress");
+        m_loadingProgressBar->SetMaxValue(100);
+        m_loadingProgressBar->Hide();
+        m_loadingProgressBar->SetBarHeight(12);
+
+        const float kInsetSpacing = 5;
+        const float kElementSpacing = 7;
+
+        // Layout
+        AddChild(BGroupLayoutBuilder(B_VERTICAL)
+            .Add(m_menuBar)
+            .Add(BGridLayoutBuilder(kElementSpacing, kElementSpacing)
+                .Add(m_BackButton, 0, 0)
+                .Add(m_ForwardButton, 1, 0)
+                .Add(m_StopButton, 2, 0)
+                .Add(m_url, 3, 0)
+                .Add(m_goButton, 4, 0)
+                .SetInsets(kInsetSpacing, kInsetSpacing, kInsetSpacing, 
kInsetSpacing)
+            )
+            .Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
+            .Add(webView)
+            .Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
+            .Add(BGroupLayoutBuilder(B_HORIZONTAL, kElementSpacing)
+                .Add(m_statusText)
+                .Add(m_loadingProgressBar, 0.2)
+                .AddStrut(12 - kElementSpacing)
+                .SetInsets(kInsetSpacing, 0, kInsetSpacing, 0)
+            )
+        );
+
+        m_url->MakeFocus(true);
+    } else {
+        m_BackButton = 0;
+        m_ForwardButton = 0;
+        m_StopButton = 0;
+        m_goButton = 0;
+        m_url = 0;
+        m_menuBar = 0;
+        m_statusText = 0;
+        m_loadingProgressBar = 0;
+
+        AddChild(BGroupLayoutBuilder(B_VERTICAL)
+            .Add(webView)
+        );
+    }
+
+    AddShortcut('R', B_COMMAND_KEY, new BMessage(RELOAD));
+       
+    be_app->PostMessage(WINDOW_OPENED);
 }
 
 void LauncherWindow::updateTitle(const BString& title)
@@ -677,12 +407,3 @@
     windowTitle << "HaikuLauncher";
     SetTitle(windowTitle.String());
 }
-
-void LauncherWindow::updateTabGroupVisibility()
-{
-       if (Lock()) {
-           //m_tabGroup->SetVisible(m_tabManager->CountTabs() > 1);
-           m_tabManager->SetCloseButtonsAvailable(m_tabManager->CountTabs() > 
1);
-           Unlock();
-       }
-}

Modified: webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.h
==============================================================================
--- webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.h    Sat Feb 27 
13:31:29 2010        (r237)
+++ webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.h    Sat Feb 27 
15:51:43 2010        (r238)
@@ -37,12 +37,10 @@
 class BButton;
 class BCheckBox;
 class BLayoutItem;
-class BMenu;
+class BMenuBar;
 class BStatusBar;
 class BStringView;
 class BTextControl;
-class IconButton;
-class TabManager;
 class BWebView;
 
 enum ToolbarPolicy {
@@ -52,24 +50,19 @@
 
 enum {
     NEW_WINDOW = 'nwnd',
-    NEW_TAB = 'ntab',
     WINDOW_OPENED = 'wndo',
     WINDOW_CLOSED = 'wndc',
-    SHOW_DOWNLOAD_WINDOW = 'sdwd'
 };
 
 class LauncherWindow : public BWebWindow {
 public:
-    LauncherWindow(BRect frame, const BMessenger& downloadListener,
-        ToolbarPolicy = HaveToolbar);
+    LauncherWindow(BRect frame, ToolbarPolicy = HaveToolbar);
+    LauncherWindow(BRect frame, BWebView* view, ToolbarPolicy = HaveToolbar);
     virtual ~LauncherWindow();
 
        virtual void DispatchMessage(BMessage* message, BHandler* target);
     virtual void MessageReceived(BMessage* message);
     virtual bool QuitRequested();
-    virtual void MenusBeginning();
-
-    void newTab(const BString& url, bool select, BWebView* webView = 0);
 
 private:
     // WebPage notification API implementations
@@ -82,38 +75,25 @@
     virtual void LoadFailed(const BString& url, BWebView* view);
     virtual void LoadFinished(const BString& url, BWebView* view);
     virtual void TitleChanged(const BString& title, BWebView* view);
-    virtual void ResizeRequested(float width, float height, BWebView* view);
     virtual void SetToolBarsVisible(bool flag, BWebView* view);
     virtual void SetStatusBarVisible(bool flag, BWebView* view);
     virtual void SetMenuBarVisible(bool flag, BWebView* view);
-    virtual void SetResizable(bool flag, BWebView* view);
     virtual void StatusChanged(const BString& status, BWebView* view);
     virtual void NavigationCapabilitiesChanged(bool canGoBackward,
         bool canGoForward, bool canStop, BWebView* view);
-    virtual void UpdateGlobalHistory(const BString& url);
-       virtual bool AuthenticationChallenge(BString message, BString& 
inOutUser,
-               BString& inOutPassword, bool& inOutRememberCredentials,
-               uint32 failureCount, BWebView* view);
 
-    void updateTitle(const BString &title);
-    void updateTabGroupVisibility();
+    void init(BWebView* view, ToolbarPolicy);
+    void updateTitle(const BString& title);
 
 private:
-    BMessenger m_downloadListener;
     BMenuBar* m_menuBar;
-    BMenu* m_goMenu;
-    IconButton* m_BackButton;
-    IconButton* m_ForwardButton;
-    IconButton* m_StopButton;
+    BButton* m_BackButton;
+    BButton* m_ForwardButton;
+    BButton* m_StopButton;
     BButton* m_goButton;
     BTextControl* m_url;
     BStringView* m_statusText;
     BStatusBar* m_loadingProgressBar;
-    BLayoutItem* m_findGroup;
-    BLayoutItem* m_tabGroup;
-    BTextControl* m_findTextControl;
-    BCheckBox* m_findCaseSensitiveCheckBox;
-    TabManager* m_tabManager;
 };
 
 #endif // LauncherWindow_h

Copied and modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserApp.cpp (from 
r231, webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherApp.cpp)
==============================================================================
--- webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherApp.cpp     Sat Feb 27 
01:48:18 2010        (r231, copy source)
+++ webkit/trunk/WebKit/haiku/WebPositive/BrowserApp.cpp        Sat Feb 27 
15:51:43 2010        (r238)
@@ -8,10 +8,10 @@
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
+ *     notice, this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
  *
  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -27,17 +27,16 @@
  */
 
 #include "config.h"
-#include "LauncherApp.h"
+#include "BrowserApp.h"
 
+#include "BrowserWindow.h"
 #include "DownloadWindow.h"
-#include "FrameView.h"
-#include "GraphicsContext.h"
-#include "LauncherWindow.h"
 #include "WebPage.h"
 #include "WebView.h"
 #include "WebViewConstants.h"
 #include <Alert.h>
 #include <Autolock.h>
+#include <Directory.h>
 #include <Entry.h>
 #include <File.h>
 #include <FindDirectory.h>
@@ -45,170 +44,187 @@
 #include <Screen.h>
 #include <stdio.h>
 
-extern const char* kApplicationSignature = 
"application/x-vnd.RJL-HaikuLauncher";
+
+const char* kApplicationSignature = "application/x-vnd.Haiku-WebPositive";
+const char* kApplicationName = "WebPositive";
+
+
 enum {
-    LOAD_AT_STARTING = 'lost'
+       LOAD_AT_STARTING = 'lost'
 };
 
 
-LauncherApp::LauncherApp()
-    : BApplication(kApplicationSignature)
-    , m_windowCount(0)
-    , m_lastWindowFrame(100, 100, 700, 750)
-    , m_launchRefsMessage(0)
-    , m_initialized(false)
-    , m_downloadWindow(0)
+BrowserApp::BrowserApp()
+       : BApplication(kApplicationSignature)
+       , fWindowCount(0)
+       , fLastWindowFrame(100, 100, 700, 750)
+       , fLaunchRefsMessage(0)
+       , fInitialized(false)
+       , fDownloadWindow(0)
 {
 }
 
-LauncherApp::~LauncherApp()
+
+BrowserApp::~BrowserApp()
 {
-       delete m_launchRefsMessage;
+       delete fLaunchRefsMessage;
 }
 
-void LauncherApp::AboutRequested()
+
+void
+BrowserApp::AboutRequested()
 {
-    BAlert* alert = new BAlert("About HaikuLauncher",
-        "For testing WebKit...\n\nby Ryan Leavengood", "Sweet!");
-    alert->Go();
+       BAlert* alert = new BAlert("About WebPositive",
+               "WebPositive\n\nby Ryan Leavengood, Andrea Anzani, "
+               "Maxime Simone, Michael Lotz, Rene Gollent and Stephan Aßmus",
+               "Sweet!");
+       alert->Go();
 }
 
-void LauncherApp::ArgvReceived(int32 argc, char** argv)
+
+void
+BrowserApp::ArgvReceived(int32 argc, char** argv)
 {
        for (int i = 1; i < argc; i++) {
                const char* url = argv[i];
                BEntry entry(argv[i], true);
                BPath path;
                if (entry.Exists() && entry.GetPath(&path) == B_OK)
-                   url = path.Path();
-           BMessage message(LOAD_AT_STARTING);
-           message.AddString("url", url);
-           message.AddBool("new window", m_initialized || i > 1);
-           PostMessage(&message);
+                       url = path.Path();
+               BMessage message(LOAD_AT_STARTING);
+               message.AddString("url", url);
+               message.AddBool("new window", fInitialized || i > 1);
+               PostMessage(&message);
        }
 }
 
-void LauncherApp::ReadyToRun()
+
+void
+BrowserApp::ReadyToRun()
 {
        // Since we will essentially run the GUI...
        set_thread_priority(Thread(), B_DISPLAY_PRIORITY);
 
-    BWebPage::InitializeOnce();
-    BWebPage::SetCacheModel(B_WEBKIT_CACHE_MODEL_WEB_BROWSER);
+       BWebPage::InitializeOnce();
+       BWebPage::SetCacheModel(B_WEBKIT_CACHE_MODEL_WEB_BROWSER);
 
        BFile settingsFile;
-       BRect windowFrameFromSettings = m_lastWindowFrame;
+       BRect windowFrameFromSettings = fLastWindowFrame;
        BRect downloadWindowFrame(100, 100, 300, 250);
        bool showDownloads = false;
-       if (openSettingsFile(settingsFile, B_READ_ONLY)) {
+       if (_OpenSettingsFile(settingsFile, B_READ_ONLY)) {
                BMessage settingsArchive;
                settingsArchive.Unflatten(&settingsFile);
                settingsArchive.FindRect("window frame", 
&windowFrameFromSettings);
                settingsArchive.FindRect("downloads window frame", 
&downloadWindowFrame);
                settingsArchive.FindBool("show downloads", &showDownloads);
        }
-       m_lastWindowFrame = windowFrameFromSettings;
+       fLastWindowFrame = windowFrameFromSettings;
 
-    m_downloadWindow = new DownloadWindow(downloadWindowFrame, showDownloads);
+       fDownloadWindow = new DownloadWindow(downloadWindowFrame, 
showDownloads);
 
-       m_initialized = true;
+       fInitialized = true;
 
-       if (m_launchRefsMessage) {
-               RefsReceived(m_launchRefsMessage);
-               delete m_launchRefsMessage;
-               m_launchRefsMessage = 0;
+       if (fLaunchRefsMessage) {
+               RefsReceived(fLaunchRefsMessage);
+               delete fLaunchRefsMessage;
+               fLaunchRefsMessage = 0;
        } else {
-           LauncherWindow* window = new LauncherWindow(m_lastWindowFrame,
-               BMessenger(m_downloadWindow));
-           window->Show();
+               BrowserWindow* window = new BrowserWindow(fLastWindowFrame,
+                       BMessenger(fDownloadWindow));
+               window->Show();
        }
 }
 
-void LauncherApp::MessageReceived(BMessage* message)
-{
-    switch (message->what) {
-    case LOAD_AT_STARTING: {
-        BString url;
-        if (message->FindString("url", &url) != B_OK)
-               break;
-        bool openNewWindow = false;
-        message->FindBool("new window", &openNewWindow);
-        LauncherWindow* webWindow = NULL;
-        for (int i = 0; BWindow* window = WindowAt(i); i++) {
-            webWindow = dynamic_cast<LauncherWindow*>(window);
-            if (!webWindow)
-               continue;
-            if (!openNewWindow) {
-               // stop at the first window
-                   break;
-            }
-        }
-        if (webWindow) {
-               // There should always be at least one window open. If not, 
maybe we are about
-               // to quit anyway...
-               if (openNewWindow) {
-                       // open a new window with an offset to the last window
-                newWindow(url);
-               } else {
-               // load the URL in the first window
-                webWindow->CurrentWebView()->LoadURL(url.String());
-               }
-        }
-        break;
-    }
-    case B_SILENT_RELAUNCH:
-       newWindow("");
-       break;
-    case NEW_WINDOW: {
+
+void
+BrowserApp::MessageReceived(BMessage* message)
+{
+       switch (message->what) {
+       case LOAD_AT_STARTING: {
                BString url;
                if (message->FindString("url", &url) != B_OK)
                        break;
-       newWindow(url);
-       break;
-    }
-    case NEW_TAB: {
-       LauncherWindow* window;
+               bool openNewWindow = false;
+               message->FindBool("new window", &openNewWindow);
+               BrowserWindow* webWindow = NULL;
+               for (int i = 0; BWindow* window = WindowAt(i); i++) {
+                       webWindow = dynamic_cast<BrowserWindow*>(window);
+                       if (!webWindow)
+                               continue;
+                       if (!openNewWindow) {
+                               // stop at the first window
+                               break;
+                       }
+               }
+               if (webWindow) {
+                       // There should always be at least one window open. If 
not, maybe we are about
+                       // to quit anyway...
+                       if (openNewWindow) {
+                               // open a new window with an offset to the last 
window
+                               _CreateNewWindow(url);
+                       } else {
+                               // load the URL in the first window
+                               
webWindow->CurrentWebView()->LoadURL(url.String());
+                       }
+               }
+               break;
+       }
+       case B_SILENT_RELAUNCH:
+               _CreateNewWindow("");
+               break;
+       case NEW_WINDOW: {
+               BString url;
+               if (message->FindString("url", &url) != B_OK)
+                       break;
+               _CreateNewWindow(url);
+               break;
+       }
+       case NEW_TAB: {
+               BrowserWindow* window;
                if (message->FindPointer("window", 
reinterpret_cast<void**>(&window)) != B_OK)
                        break;
-       BString url;
+               BString url;
                message->FindString("url", &url);
-       bool select = false;
+               bool select = false;
                message->FindBool("select", &select);
-       newTab(window, url, select);
-        break;
-    }
-    case WINDOW_OPENED:
-       m_windowCount++;
-       break;
-    case WINDOW_CLOSED:
-       m_windowCount--;
-        message->FindRect("window frame", &m_lastWindowFrame);
-       if (m_windowCount <= 0)
-               PostMessage(B_QUIT_REQUESTED);
-       break;
-
-    case SHOW_DOWNLOAD_WINDOW: {
-       BAutolock _(m_downloadWindow);
-        uint32 workspaces;
-        if (message->FindUInt32("workspaces", &workspaces) == B_OK)
-            m_downloadWindow->SetWorkspaces(workspaces);
-        if (m_downloadWindow->IsHidden())
-            m_downloadWindow->Show();
-        else
-            m_downloadWindow->Activate();
-    }
-
-    default:
-        BApplication::MessageReceived(message);
-        break;
-    }
-}
-
-void LauncherApp::RefsReceived(BMessage* message)
-{
-       if (!m_initialized) {
-               delete m_launchRefsMessage;
-               m_launchRefsMessage = new BMessage(*message);
+               _CreateNewTab(window, url, select);
+               break;
+       }
+       case WINDOW_OPENED:
+               fWindowCount++;
+               break;
+       case WINDOW_CLOSED:
+               fWindowCount--;
+               message->FindRect("window frame", &fLastWindowFrame);
+               if (fWindowCount <= 0)
+                       PostMessage(B_QUIT_REQUESTED);
+               break;
+
+       case SHOW_DOWNLOAD_WINDOW: {
+               BAutolock _(fDownloadWindow);
+               uint32 workspaces;
+               if (message->FindUInt32("workspaces", &workspaces) == B_OK)
+                       fDownloadWindow->SetWorkspaces(workspaces);
+               if (fDownloadWindow->IsHidden())
+                       fDownloadWindow->Show();
+               else
+                       fDownloadWindow->Activate();
+       }
+
+       default:
+               BApplication::MessageReceived(message);
+               break;
+       }
+}
+
+
+void
+BrowserApp::RefsReceived(BMessage* message)
+{
+       if (!fInitialized) {
+               delete fLaunchRefsMessage;
+               fLaunchRefsMessage = new BMessage(*message);
                return;
        }
 
@@ -222,82 +238,97 @@
                        continue;
                BString url;
                url << path.Path();
-               newWindow(url);
+               _CreateNewWindow(url);
        }
 }
 
-bool LauncherApp::QuitRequested()
+
+bool
+BrowserApp::QuitRequested()
 {
-    for (int i = 0; BWindow* window = WindowAt(i); i++) {
-        LauncherWindow* webWindow = dynamic_cast<LauncherWindow*>(window);
-        if (!webWindow)
-               continue;
-        if (!webWindow->Lock())
-               continue;
-        if (webWindow->QuitRequested()) {
-               m_lastWindowFrame = webWindow->Frame();
-               webWindow->Quit();
-               i--;
-        } else {
-               webWindow->Unlock();
-               return false;
-        }
-    }
+       for (int i = 0; BWindow* window = WindowAt(i); i++) {
+               BrowserWindow* webWindow = dynamic_cast<BrowserWindow*>(window);
+               if (!webWindow)
+                       continue;
+               if (!webWindow->Lock())
+                       continue;
+               if (webWindow->QuitRequested()) {
+                       fLastWindowFrame = webWindow->Frame();
+                       webWindow->Quit();
+                       i--;
+               } else {
+                       webWindow->Unlock();
+                       return false;
+               }
+       }
 
        BFile settingsFile;
-       if (openSettingsFile(settingsFile, B_CREATE_FILE | B_ERASE_FILE | 
B_WRITE_ONLY)) {
+       if (_OpenSettingsFile(settingsFile, B_CREATE_FILE | B_ERASE_FILE | 
B_WRITE_ONLY)) {
                BMessage settingsArchive;
-               settingsArchive.AddRect("window frame", m_lastWindowFrame);
-               if (m_downloadWindow->Lock()) {
-           settingsArchive.AddRect("downloads window frame", 
m_downloadWindow->Frame());
-               settingsArchive.AddBool("show downloads", 
!m_downloadWindow->IsHidden());
-               m_downloadWindow->Unlock();
+               settingsArchive.AddRect("window frame", fLastWindowFrame);
+               if (fDownloadWindow->Lock()) {
+                       settingsArchive.AddRect("downloads window frame", 
fDownloadWindow->Frame());
+                       settingsArchive.AddBool("show downloads", 
!fDownloadWindow->IsHidden());
+                       fDownloadWindow->Unlock();
                }
                settingsArchive.Flatten(&settingsFile);
        }
 
-    return true;
+       return true;
 }
 
-bool LauncherApp::openSettingsFile(BFile& file, uint32 mode)
+
+bool
+BrowserApp::_OpenSettingsFile(BFile& file, uint32 mode)
 {
        BPath path;
        if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK
-               || path.Append("HaikuLauncher") != B_OK) {
+               || path.Append(kApplicationName) != B_OK
+               || create_directory(path.Path(), 0777) != B_OK
+               || path.Append("Application") != B_OK) {
                return false;
        }
+
        return file.SetTo(path.Path(), mode) == B_OK;
 }
 
-void LauncherApp::newWindow(const BString& url)
+
+void
+BrowserApp::_CreateNewWindow(const BString& url)
 {
-       m_lastWindowFrame.OffsetBy(20, 20);
-       if (!BScreen().Frame().Contains(m_lastWindowFrame))
-               m_lastWindowFrame.OffsetTo(50, 50);
+       fLastWindowFrame.OffsetBy(20, 20);
+       if (!BScreen().Frame().Contains(fLastWindowFrame))
+               fLastWindowFrame.OffsetTo(50, 50);
 
-       LauncherWindow* window = new LauncherWindow(m_lastWindowFrame,
-           BMessenger(m_downloadWindow));
+       BrowserWindow* window = new BrowserWindow(fLastWindowFrame,
+               BMessenger(fDownloadWindow));
        window->Show();
        if (url.Length())
-           window->CurrentWebView()->LoadURL(url.String());
+               window->CurrentWebView()->LoadURL(url.String());
 }
 
-void LauncherApp::newTab(LauncherWindow* window, const BString& url, bool 
select)
+
+void
+BrowserApp::_CreateNewTab(BrowserWindow* window, const BString& url,
+       bool select)
 {
-    if (!window->Lock())
-        return;
-    window->newTab(url, select);
-    window->Unlock();
+       if (!window->Lock())
+               return;
+       window->CreateNewTab(url, select);
+       window->Unlock();
 }
 
+
 // #pragma mark -
 
-int main(int, char**)
+
+int
+main(int, char**)
 {
-    new LauncherApp();
-    be_app->Run();
-    delete be_app;
+       new BrowserApp();
+       be_app->Run();
+       delete be_app;
 
-    return 0;
+       return 0;
 }
 

Copied and modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserApp.h (from 
r231, webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherApp.h)
==============================================================================
--- webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherApp.h       Sat Feb 27 
01:48:18 2010        (r231, copy source)
+++ webkit/trunk/WebKit/haiku/WebPositive/BrowserApp.h  Sat Feb 27 15:51:43 
2010        (r238)
@@ -8,10 +8,10 @@
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
+ *     notice, this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
  *
  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -25,43 +25,49 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
+#ifndef BROWSER_APP_H
+#define BROWSER_APP_H
 
-#ifndef LauncherApp_h
-#define LauncherApp_h
 
 #include <Application.h>
 #include <Rect.h>
 
 class BFile;
 class DownloadWindow;
-class LauncherWindow;
+class BrowserWindow;
 
-class LauncherApp : public BApplication {
+
+class BrowserApp : public BApplication {
 public:
-    LauncherApp();
-    virtual ~LauncherApp();
+                                                               BrowserApp();
+       virtual                                         ~BrowserApp();
+
+       virtual void                            AboutRequested();
+       virtual void                            ArgvReceived(int32 agrc, char** 
argv);
+       virtual void                            MessageReceived(BMessage* 
message);
+       virtual void                            RefsReceived(BMessage* message);
+       virtual void                            ReadyToRun();
+       virtual bool                            QuitRequested();
 
-    virtual void AboutRequested();
-    virtual void ArgvReceived(int32, char**);
-    virtual void MessageReceived(BMessage*);
-    virtual void RefsReceived(BMessage*);
-    virtual void ReadyToRun();
-    virtual bool QuitRequested();
+private:
+                       bool                            
_OpenSettingsFile(BFile& file, uint32 mode);
+                       void                            _CreateNewWindow(const 
BString& url);
+                       void                            
_CreateNewTab(BrowserWindow* window,
+                                                                       const 
BString& url, bool select);
 
 private:
-       bool openSettingsFile(BFile& file, uint32 mode);
-       void newWindow(const BString& url);
-       void newTab(LauncherWindow* window, const BString& url, bool select);
-
-    int m_windowCount;
-    BRect m_lastWindowFrame;
-    BMessage* m_launchRefsMessage;
-    bool m_initialized;
+                       int                                     fWindowCount;
+                       BRect                           fLastWindowFrame;
+                       BMessage*                       fLaunchRefsMessage;
+                       bool                            fInitialized;
 
-    DownloadWindow* m_downloadWindow;
+                       DownloadWindow*         fDownloadWindow;
 };
 
+
 extern const char* kApplicationSignature;
+extern const char* kApplicationName;
+
 
-#endif // LauncherApp_h
+#endif // BROWSER_APP_H
 

Copied and modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp 
(from r231, webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.cpp)
==============================================================================
--- webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.cpp  Sat Feb 27 
01:48:18 2010        (r231, copy source)
+++ webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp     Sat Feb 27 
15:51:43 2010        (r238)
@@ -31,12 +31,12 @@
  */
 
 #include "config.h"
-#include "LauncherWindow.h"
+#include "BrowserWindow.h"
 
 #include "AuthenticationPanel.h"
+#include "BrowserApp.h"
 #include "BrowsingHistory.h"
 #include "IconButton.h"
-#include "LauncherApp.h"
 #include "WebPage.h"
 #include "WebTabView.h"
 #include "WebView.h"
@@ -61,618 +61,687 @@
 
 #include <stdio.h>
 
+
 enum {
        OPEN_LOCATION = 'open',
-    GO_BACK = 'goba',
-    GO_FORWARD = 'gofo',
-    STOP = 'stop',
-    GOTO_URL = 'goul',
-    RELOAD = 'reld',
-    CLEAR_HISTORY = 'clhs',
-
-    TEXT_SIZE_INCREASE = 'tsin',
-    TEXT_SIZE_DECREASE = 'tsdc',
-    TEXT_SIZE_RESET = 'tsrs',
-
-    TEXT_SHOW_FIND_GROUP = 'sfnd',
-    TEXT_HIDE_FIND_GROUP = 'hfnd',
-    TEXT_FIND_NEXT = 'fndn',
-    TEXT_FIND_PREVIOUS = 'fndp',
+       GO_BACK = 'goba',
+       GO_FORWARD = 'gofo',
+       STOP = 'stop',
+       GOTO_URL = 'goul',
+       RELOAD = 'reld',
+       CLEAR_HISTORY = 'clhs',
+
+       TEXT_SIZE_INCREASE = 'tsin',
+       TEXT_SIZE_DECREASE = 'tsdc',
+       TEXT_SIZE_RESET = 'tsrs',
+
+       TEXT_SHOW_FIND_GROUP = 'sfnd',
+       TEXT_HIDE_FIND_GROUP = 'hfnd',
+       TEXT_FIND_NEXT = 'fndn',
+       TEXT_FIND_PREVIOUS = 'fndp',
 };
 
-using namespace WebCore;
 
-static BLayoutItem* layoutItemFor(BView* view)
+static BLayoutItem*
+layoutItemFor(BView* view)
 {
-    BLayout* layout = view->Parent()->GetLayout();
-    int32 index = layout->IndexOfView(view);
-    return layout->ItemAt(index);
-}
-
-LauncherWindow::LauncherWindow(BRect frame, const BMessenger& downloadListener,
-        ToolbarPolicy toolbarPolicy)
-    : BWebWindow(frame, "HaikuLauncher",
-        B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
-        B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS)
-    , m_downloadListener(downloadListener)
-{
-    BMessage* newTabMessage = new BMessage(NEW_TAB);
-    newTabMessage->AddString("url", "");
-    newTabMessage->AddPointer("window", this);
-    newTabMessage->AddBool("select", true);
-    m_tabManager = new TabManager(BMessenger(this), newTabMessage);
-
-    if (toolbarPolicy == HaveToolbar) {
-        // Menu
-        m_menuBar = new BMenuBar("Main menu");
-        BMenu* menu = new BMenu("Window");
-        BMessage* newWindowMessage = new BMessage(NEW_WINDOW);
-        newWindowMessage->AddString("url", "");
-        BMenuItem* newItem = new BMenuItem("New window", newWindowMessage, 
'N');
-        menu->AddItem(newItem);
-        newItem->SetTarget(be_app);
-        newItem = new BMenuItem("New tab", new BMessage(*newTabMessage), 'T');
-        menu->AddItem(newItem);
-        newItem->SetTarget(be_app);
-        menu->AddItem(new BMenuItem("Open location", new 
BMessage(OPEN_LOCATION), 'L'));
-        menu->AddSeparatorItem();
-        menu->AddItem(new BMenuItem("Close window", new 
BMessage(B_QUIT_REQUESTED), 'W', B_SHIFT_KEY));
-        menu->AddItem(new BMenuItem("Close tab", new BMessage(CLOSE_TAB), 
'W'));
-        menu->AddSeparatorItem();
-        menu->AddItem(new BMenuItem("Show downloads", new 
BMessage(SHOW_DOWNLOAD_WINDOW), 'J'));
-        menu->AddSeparatorItem();
-        BMenuItem* quitItem = new BMenuItem("Quit", new 
BMessage(B_QUIT_REQUESTED), 'Q');
-        menu->AddItem(quitItem);
-        quitItem->SetTarget(be_app);
-        m_menuBar->AddItem(menu);
-
-        menu = new BMenu("Text");
-        menu->AddItem(new BMenuItem("Find", new 
BMessage(TEXT_SHOW_FIND_GROUP), 'F'));
-        menu->AddSeparatorItem();
-        menu->AddItem(new BMenuItem("Increase size", new 
BMessage(TEXT_SIZE_INCREASE), '+'));
-        menu->AddItem(new BMenuItem("Decrease size", new 
BMessage(TEXT_SIZE_DECREASE), '-'));
-        menu->AddItem(new BMenuItem("Reset size", new 
BMessage(TEXT_SIZE_RESET), '0'));
-        m_menuBar->AddItem(menu);
-
-        m_goMenu = new BMenu("Go");
-        m_menuBar->AddItem(m_goMenu);
-
-        // Back, Forward & Stop
-        m_BackButton = new IconButton("Back", 0, NULL, new BMessage(GO_BACK));
-        m_BackButton->SetIcon(201);
-        m_BackButton->TrimIcon();
-
-        m_ForwardButton = new IconButton("Forward", 0, NULL, new 
BMessage(GO_FORWARD));
-        m_ForwardButton->SetIcon(202);
-        m_ForwardButton->TrimIcon();
-
-        m_StopButton = new IconButton("Stop", 0, NULL, new BMessage(STOP));
-        m_StopButton->SetIcon(204);
-        m_StopButton->TrimIcon();
-
-        // URL
-        m_url = new BTextControl("url", "", "", new BMessage(GOTO_URL));
-        m_url->SetDivider(50.0);
-
-        // Go
-        BButton* button = new BButton("", "Go", new BMessage(RELOAD));
-
-        // Status Bar
-        m_statusText = new BStringView("status", "");
-        m_statusText->SetAlignment(B_ALIGN_LEFT);
-        m_statusText->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 
B_SIZE_UNSET));
-        m_statusText->SetExplicitMinSize(BSize(150, 12));
-            // Prevent the window from growing to fit a long status message...
-        BFont font(be_plain_font);
-        font.SetSize(ceilf(font.Size() * 0.8));
-        m_statusText->SetFont(&font, B_FONT_SIZE);
-
-        // Loading progress bar
-        m_loadingProgressBar = new BStatusBar("progress");
-        m_loadingProgressBar->SetMaxValue(100);
-        m_loadingProgressBar->Hide();
-        m_loadingProgressBar->SetBarHeight(12);
-
-        const float kInsetSpacing = 5;
-        const float kElementSpacing = 7;
-
-        m_findTextControl = new BTextControl("find", "Find:", "",
-            new BMessage(TEXT_FIND_NEXT));
-        m_findCaseSensitiveCheckBox = new BCheckBox("Match case");
-        BView* findGroup = BGroupLayoutBuilder(B_VERTICAL)
-            .Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
-            .Add(BGroupLayoutBuilder(B_HORIZONTAL, kElementSpacing)
-                .Add(m_findTextControl)
-                .Add(new BButton("Previous", new BMessage(TEXT_FIND_PREVIOUS)))
-                .Add(new BButton("Next", new BMessage(TEXT_FIND_NEXT)))
-                .Add(m_findCaseSensitiveCheckBox)
-                .Add(BSpaceLayoutItem::CreateGlue())
-                .Add(new BButton("Close", new BMessage(TEXT_HIDE_FIND_GROUP)))
-                .SetInsets(kInsetSpacing, kInsetSpacing,
-                    kInsetSpacing, kInsetSpacing)
-            )
-        ;
-        // Layout
-        AddChild(BGroupLayoutBuilder(B_VERTICAL)
-            .Add(m_menuBar)
-            .Add(m_tabManager->TabGroup())
-            .Add(BGridLayoutBuilder(kElementSpacing, kElementSpacing)
-                .Add(m_BackButton, 0, 0)
-                .Add(m_ForwardButton, 1, 0)
-                .Add(m_StopButton, 2, 0)
-                .Add(m_url, 3, 0)
-                .Add(button, 4, 0)
-                .SetInsets(kInsetSpacing, kInsetSpacing, kInsetSpacing, 
kInsetSpacing)
-            )
-            .Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
-            .Add(m_tabManager->ContainerView())
-            .Add(findGroup)
-            .Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
-            .Add(BGroupLayoutBuilder(B_HORIZONTAL, kElementSpacing)
-                .Add(m_statusText)
-                .Add(m_loadingProgressBar, 0.2)
-                .AddStrut(12 - kElementSpacing)
-                .SetInsets(kInsetSpacing, 0, kInsetSpacing, 0)
-            )
-        );
-
-        m_url->MakeFocus(true);
-
-        m_findGroup = layoutItemFor(findGroup);
-        m_tabGroup = layoutItemFor(m_tabManager->TabGroup());
-    } else {
-        m_BackButton = 0;
-        m_ForwardButton = 0;
-        m_url = 0;
-        m_menuBar = 0;
-        m_statusText = 0;
-        m_loadingProgressBar = 0;
-
-        BWebView* webView = new BWebView("web_view");
-        SetCurrentWebView(webView);
-
-        AddChild(BGroupLayoutBuilder(B_VERTICAL, 7)
-            .Add(CurrentWebView())
-        );
-    }
-
-    newTab("", true);
-
-    m_findGroup->SetVisible(false);
-
-    AddShortcut('G', B_COMMAND_KEY, new BMessage(TEXT_FIND_NEXT));
-    AddShortcut('G', B_COMMAND_KEY | B_SHIFT_KEY, new 
BMessage(TEXT_FIND_PREVIOUS));
-    AddShortcut('F', B_COMMAND_KEY, new BMessage(TEXT_SHOW_FIND_GROUP));
-    AddShortcut('F', B_COMMAND_KEY | B_SHIFT_KEY, new 
BMessage(TEXT_HIDE_FIND_GROUP));
-    AddShortcut('R', B_COMMAND_KEY, new BMessage(RELOAD));
+       BLayout* layout = view->Parent()->GetLayout();
+       int32 index = layout->IndexOfView(view);
+       return layout->ItemAt(index);
+}
+
+
+BrowserWindow::BrowserWindow(BRect frame, const BMessenger& downloadListener,
+               ToolbarPolicy toolbarPolicy)
+       : BWebWindow(frame, kApplicationName,
+               B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
+               B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS)
+       , fDownloadListener(downloadListener)
+{
+       BMessage* newTabMessage = new BMessage(NEW_TAB);
+       newTabMessage->AddString("url", "");
+       newTabMessage->AddPointer("window", this);
+       newTabMessage->AddBool("select", true);
+       fTabManager = new TabManager(BMessenger(this), newTabMessage);
+
+       if (toolbarPolicy == HaveToolbar) {
+               // Menu
+               fMenuBar = new BMenuBar("Main menu");
+               BMenu* menu = new BMenu("Window");
+               BMessage* newWindowMessage = new BMessage(NEW_WINDOW);
+               newWindowMessage->AddString("url", "");
+               BMenuItem* newItem = new BMenuItem("New window", 
newWindowMessage, 'N');
+               menu->AddItem(newItem);
+               newItem->SetTarget(be_app);
+               newItem = new BMenuItem("New tab", new 
BMessage(*newTabMessage), 'T');
+               menu->AddItem(newItem);
+               newItem->SetTarget(be_app);
+               menu->AddItem(new BMenuItem("Open location", new 
BMessage(OPEN_LOCATION), 'L'));
+               menu->AddSeparatorItem();
+               menu->AddItem(new BMenuItem("Close window", new 
BMessage(B_QUIT_REQUESTED), 'W', B_SHIFT_KEY));
+               menu->AddItem(new BMenuItem("Close tab", new 
BMessage(CLOSE_TAB), 'W'));
+               menu->AddSeparatorItem();
+               menu->AddItem(new BMenuItem("Show downloads", new 
BMessage(SHOW_DOWNLOAD_WINDOW), 'J'));
+               menu->AddSeparatorItem();
+               BMenuItem* quitItem = new BMenuItem("Quit", new 
BMessage(B_QUIT_REQUESTED), 'Q');
+               menu->AddItem(quitItem);
+               quitItem->SetTarget(be_app);
+               fMenuBar->AddItem(menu);
+
+               menu = new BMenu("Text");
+               menu->AddItem(new BMenuItem("Find", new 
BMessage(TEXT_SHOW_FIND_GROUP), 'F'));
+               menu->AddSeparatorItem();
+               menu->AddItem(new BMenuItem("Increase size", new 
BMessage(TEXT_SIZE_INCREASE), '+'));
+               menu->AddItem(new BMenuItem("Decrease size", new 
BMessage(TEXT_SIZE_DECREASE), '-'));
+               menu->AddItem(new BMenuItem("Reset size", new 
BMessage(TEXT_SIZE_RESET), '0'));
+               fMenuBar->AddItem(menu);
+
+               fGoMenu = new BMenu("Go");
+               fMenuBar->AddItem(fGoMenu);
+
+               // Back, Forward & Stop
+               fBackButton = new IconButton("Back", 0, NULL, new 
BMessage(GO_BACK));
+               fBackButton->SetIcon(201);
+               fBackButton->TrimIcon();
+
+               fForwardButton = new IconButton("Forward", 0, NULL, new 
BMessage(GO_FORWARD));
+               fForwardButton->SetIcon(202);
+               fForwardButton->TrimIcon();
+
+               fStopButton = new IconButton("Stop", 0, NULL, new 
BMessage(STOP));
+               fStopButton->SetIcon(204);
+               fStopButton->TrimIcon();
+
+               // URL
+               fURLTextControl = new BTextControl("url", "", "", NULL);
+               fURLTextControl->SetDivider(50.0);
+
+               // Go
+               fGoButton = new BButton("", "Go", new BMessage(GOTO_URL));
+
+               // Status Bar
+               fStatusText = new BStringView("status", "");
+               fStatusText->SetAlignment(B_ALIGN_LEFT);
+               fStatusText->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 
B_SIZE_UNSET));
+               fStatusText->SetExplicitMinSize(BSize(150, 12));
+                       // Prevent the window from growing to fit a long status 
message...
+               BFont font(be_plain_font);
+               font.SetSize(ceilf(font.Size() * 0.8));
+               fStatusText->SetFont(&font, B_FONT_SIZE);
+
+               // Loading progress bar
+               fLoadingProgressBar = new BStatusBar("progress");
+               fLoadingProgressBar->SetMaxValue(100);
+               fLoadingProgressBar->Hide();
+               fLoadingProgressBar->SetBarHeight(12);
+
+               const float kInsetSpacing = 5;
+               const float kElementSpacing = 7;
+
+               fFindTextControl = new BTextControl("find", "Find:", "",
+                       new BMessage(TEXT_FIND_NEXT));
+               fFindCaseSensitiveCheckBox = new BCheckBox("Match case");
+               BView* findGroup = BGroupLayoutBuilder(B_VERTICAL)
+                       .Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
+                       .Add(BGroupLayoutBuilder(B_HORIZONTAL, kElementSpacing)
+                               .Add(fFindTextControl)
+                               .Add(new BButton("Previous", new 
BMessage(TEXT_FIND_PREVIOUS)))
+                               .Add(new BButton("Next", new 
BMessage(TEXT_FIND_NEXT)))
+                               .Add(fFindCaseSensitiveCheckBox)
+                               .Add(BSpaceLayoutItem::CreateGlue())
+                               .Add(new BButton("Close", new 
BMessage(TEXT_HIDE_FIND_GROUP)))
+                               .SetInsets(kInsetSpacing, kInsetSpacing,
+                                       kInsetSpacing, kInsetSpacing)
+                       )
+               ;
+               // Layout
+               AddChild(BGroupLayoutBuilder(B_VERTICAL)
+                       .Add(fMenuBar)
+                       .Add(fTabManager->TabGroup())
+                       .Add(BGridLayoutBuilder(kElementSpacing, 
kElementSpacing)
+                               .Add(fBackButton, 0, 0)
+                               .Add(fForwardButton, 1, 0)
+                               .Add(fStopButton, 2, 0)
+                               .Add(fURLTextControl, 3, 0)
+                               .Add(fGoButton, 4, 0)
+                               .SetInsets(kInsetSpacing, kInsetSpacing, 
kInsetSpacing, kInsetSpacing)
+                       )
+                       .Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
+                       .Add(fTabManager->ContainerView())
+                       .Add(findGroup)
+                       .Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
+                       .Add(BGroupLayoutBuilder(B_HORIZONTAL, kElementSpacing)
+                               .Add(fStatusText)
+                               .Add(fLoadingProgressBar, 0.2)
+                               .AddStrut(12 - kElementSpacing)
+                               .SetInsets(kInsetSpacing, 0, kInsetSpacing, 0)
+                       )
+               );
+
+               fURLTextControl->MakeFocus(true);
+
+               fFindGroup = layoutItemFor(findGroup);
+               fTabGroup = layoutItemFor(fTabManager->TabGroup());
+       } else {
+               fBackButton = 0;
+               fForwardButton = 0;
+               fStopButton = 0;
+               fGoButton = 0;
+               fURLTextControl = 0;
+               fMenuBar = 0;
+               fStatusText = 0;
+               fLoadingProgressBar = 0;
+
+               BWebView* webView = new BWebView("web_view");
+               SetCurrentWebView(webView);
+
+               AddChild(BGroupLayoutBuilder(B_VERTICAL, 7)
+                       .Add(CurrentWebView())
+               );
+       }
+
+       CreateNewTab("", true);
+
+       fFindGroup->SetVisible(false);
+
+       AddShortcut('G', B_COMMAND_KEY, new BMessage(TEXT_FIND_NEXT));
+       AddShortcut('G', B_COMMAND_KEY | B_SHIFT_KEY, new 
BMessage(TEXT_FIND_PREVIOUS));
+       AddShortcut('F', B_COMMAND_KEY, new BMessage(TEXT_SHOW_FIND_GROUP));
+       AddShortcut('F', B_COMMAND_KEY | B_SHIFT_KEY, new 
BMessage(TEXT_HIDE_FIND_GROUP));
+       AddShortcut('R', B_COMMAND_KEY, new BMessage(RELOAD));
        
-    be_app->PostMessage(WINDOW_OPENED);
+       be_app->PostMessage(WINDOW_OPENED);
 }
 
-LauncherWindow::~LauncherWindow()
+
+BrowserWindow::~BrowserWindow()
 {
 }
 
-void LauncherWindow::MessageReceived(BMessage* message)
+
+void
+BrowserWindow::DispatchMessage(BMessage* message, BHandler* target)
 {
-    switch (message->what) {
-    case OPEN_LOCATION:
-        if (m_url) {
-               if (m_url->TextView()->IsFocus())
-                   m_url->TextView()->SelectAll();
-               else
-                   m_url->MakeFocus(true);
-        }
-       break;
-    case RELOAD:
-        CurrentWebView()->LoadURL(m_url->Text());
-        break;
-    case GOTO_URL: {
-        BString url = m_url->Text();
-        message->FindString("url", &url);
-        if (m_loadedURL != url)
-            CurrentWebView()->LoadURL(url.String());
-        break;
-    }
-    case GO_BACK:
-        CurrentWebView()->GoBack();
-        break;
-    case GO_FORWARD:
-        CurrentWebView()->GoForward();
-        break;
-    case STOP:
-        CurrentWebView()->StopLoading();
-        break;
-
-    case CLEAR_HISTORY: {
-        BrowsingHistory* history = BrowsingHistory::defaultInstance();
-        if (history->countItems() == 0)
-            break;
-        BAlert* alert = new BAlert("Confirmation", "Do you really want to 
clear "
-            "the browsing history?", "Clear", "Cancel");
-        if (alert->Go() == 0)
-            history->clear();
-        break;
-    }
-
-    case B_SIMPLE_DATA: {
-        // User possibly dropped files on this window.
-        // If there is more than one entry_ref, let the app handle it (open one
-        // new page per ref). If there is one ref, open it in this window.
-        type_code type;
-        int32 countFound;
-        if (message->GetInfo("refs", &type, &countFound) != B_OK
-            || type != B_REF_TYPE) {
-            break;
-        }
-        if (countFound > 1) {
-            message->what = B_REFS_RECEIVED;
-            be_app->PostMessage(message);
-            break;
-        }
-        entry_ref ref;
-        if (message->FindRef("refs", &ref) != B_OK)
-            break;
-        BEntry entry(&ref, true);
-        BPath path;
-        if (!entry.Exists() || entry.GetPath(&path) != B_OK)
-            break;
-        CurrentWebView()->LoadURL(path.Path());
-        break;
-    }
-
-    case TEXT_SIZE_INCREASE:
-        CurrentWebView()->IncreaseTextSize();
-        break;
-    case TEXT_SIZE_DECREASE:
-        CurrentWebView()->DecreaseTextSize();
-        break;
-    case TEXT_SIZE_RESET:
-        CurrentWebView()->ResetTextSize();
-        break;
-
-    case TEXT_FIND_NEXT:
-        CurrentWebView()->FindString(m_findTextControl->Text(), true,
-            m_findCaseSensitiveCheckBox->Value());
-        break;
-    case TEXT_FIND_PREVIOUS:
-        CurrentWebView()->FindString(m_findTextControl->Text(), false,
-            m_findCaseSensitiveCheckBox->Value());
-        break;
-    case TEXT_SHOW_FIND_GROUP:
-        if (!m_findGroup->IsVisible())
-            m_findGroup->SetVisible(true);
-        m_findTextControl->MakeFocus(true);
-        break;
-    case TEXT_HIDE_FIND_GROUP:
-        if (m_findGroup->IsVisible())
-            m_findGroup->SetVisible(false);
-        break;
-
-    case SHOW_DOWNLOAD_WINDOW:
-        message->AddUInt32("workspaces", Workspaces());
-        be_app->PostMessage(message);
-        break;
-
-    case CLOSE_TAB:
-        if (m_tabManager->CountTabs() > 1) {
-               int32 index;
-               if (message->FindInt32("tab index", &index) != B_OK)
-                       index = m_tabManager->SelectedTabIndex();
-            delete m_tabManager->RemoveTab(index);
-            updateTabGroupVisibility();
-        } else
-            PostMessage(B_QUIT_REQUESTED);
-        break;
-
-    case TAB_CHANGED: {
-       // This message may be received also when the last tab closed, i.e. 
with index == -1.
-        int32 index;
-        if (message->FindInt32("tab index", &index) != B_OK)
-            index = -1;
-        BWebView* webView = 
dynamic_cast<BWebView*>(m_tabManager->ViewForTab(index));
-        if (webView == CurrentWebView())
-               break;
-        SetCurrentWebView(webView);
-        if (webView)
-            updateTitle(webView->MainFrameTitle());
-        else
-            updateTitle("");
-        if (webView) {
-            m_url->SetText(webView->MainFrameURL());
-            // Trigger update of the interface to the new page, by requesting
-            // to resend all notifications.
-            webView->WebPage()->ResendNotifications();
-        }
-        break;
-    }
-
-    default:
-        BWebWindow::MessageReceived(message);
-        break;
-    }
-}
-
-bool LauncherWindow::QuitRequested()
-{
-    // TODO: Check for modified form data and ask user for confirmation, etc.
-
-    // Iterate over all tabs to delete all BWebViews.
-    // Do this here, so WebKit tear down happens earlier.
-    while (m_tabManager->CountTabs() > 0)
-        delete m_tabManager->RemoveTab(0L);
-    SetCurrentWebView(0);
-
-    BMessage message(WINDOW_CLOSED);
-    message.AddRect("window frame", Frame());
-    be_app->PostMessage(&message);
-    return true;
-}
-
-void LauncherWindow::MenusBeginning()
-{
-    BMenuItem* menuItem;
-    while ((menuItem = m_goMenu->RemoveItem(0L)))
-        delete menuItem;
-
-    BrowsingHistory* history = BrowsingHistory::defaultInstance();
-    if (!history->Lock())
-        return;
-
-    int32 count = history->countItems();
-    for (int32 i = 0; i < count; i++) {
-        BrowsingHistoryItem historyItem = history->historyItemAt(i);
-        BMessage* message = new BMessage(GOTO_URL);
-        message->AddString("url", historyItem.url().String());
-        // TODO: More sophisticated menu structure... sorted by days/weeks...
-        BString truncatedUrl(historyItem.url());
-        be_plain_font->TruncateString(&truncatedUrl, B_TRUNCATE_END, 480);
-        menuItem = new BMenuItem(truncatedUrl, message);
-        m_goMenu->AddItem(menuItem);
-    }
-
-
-    if (m_goMenu->CountItems() > 3) {
-        m_goMenu->AddSeparatorItem();
-        m_goMenu->AddItem(new BMenuItem("Clear history", new 
BMessage(CLEAR_HISTORY)));
-    }
-
-    history->Unlock();
-}
-
-void LauncherWindow::newTab(const BString& url, bool select, BWebView* webView)
-{
-    // Executed in app thread (new BWebPage needs to be created in app thread).
-    if (!webView)
-        webView = new BWebView("web view");
-    webView->WebPage()->SetDownloadListener(m_downloadListener);
-
-    m_tabManager->AddTab(webView, "New tab");
-
-    if (url.Length())
-        webView->LoadURL(url.String());
-
-    if (select) {
-        m_tabManager->SelectTab(m_tabManager->CountTabs() - 1);
-        SetCurrentWebView(webView);
-        NavigationCapabilitiesChanged(false, false, false, webView);
-        if (m_url) {
-               m_url->SetText(url.String());
-            m_url->MakeFocus(true);
-        }
-    }
+       if (fURLTextControl && message->what == B_KEY_DOWN
+               && target == fURLTextControl->TextView()) {
+               // Handle B_RETURN in the URL text control. This is the easiest
+               // way to react *only* when the user presses the return key in 
the
+               // address bar, as opposed to trying to load whatever is in 
there when
+               // the text control just goes out of focus.
+               const char* bytes;
+               if (message->FindString("bytes", &bytes) == B_OK
+                       && bytes[0] == B_RETURN) {
+                       // Do it in such a way that the user sees the Go-button 
go down.
+                       fGoButton->SetValue(B_CONTROL_ON);
+                       UpdateIfNeeded();
+                       fGoButton->Invoke();
+                       snooze(1000);
+                       fGoButton->SetValue(B_CONTROL_OFF);
+               }
+       }
+       BWebWindow::DispatchMessage(message, target);
+}
+
+
+void
+BrowserWindow::MessageReceived(BMessage* message)
+{
+       switch (message->what) {
+       case OPEN_LOCATION:
+               if (fURLTextControl) {
+                       if (fURLTextControl->TextView()->IsFocus())
+                               fURLTextControl->TextView()->SelectAll();
+                       else
+                               fURLTextControl->MakeFocus(true);
+               }
+               break;
+       case RELOAD:
+               CurrentWebView()->Reload();
+               break;
+       case GOTO_URL: {
+               BString url;
+               if (message->FindString("url", &url) != B_OK)
+                       url = fURLTextControl->Text();
+               CurrentWebView()->LoadURL(url.String());
+               break;
+       }
+       case GO_BACK:
+               CurrentWebView()->GoBack();
+               break;
+       case GO_FORWARD:
+               CurrentWebView()->GoForward();
+               break;
+       case STOP:
+               CurrentWebView()->StopLoading();
+               break;
+
+       case CLEAR_HISTORY: {
+               BrowsingHistory* history = BrowsingHistory::defaultInstance();
+               if (history->countItems() == 0)
+                       break;
+               BAlert* alert = new BAlert("Confirmation", "Do you really want 
to "
+                       "clear the browsing history?", "Clear", "Cancel");
+               if (alert->Go() == 0)
+                       history->clear();
+               break;
+       }
+
+       case B_SIMPLE_DATA: {
+               // User possibly dropped files on this window.
+               // If there is more than one entry_ref, let the app handle it 
(open one
+               // new page per ref). If there is one ref, open it in this 
window.
+               type_code type;
+               int32 countFound;
+               if (message->GetInfo("refs", &type, &countFound) != B_OK
+                       || type != B_REF_TYPE) {
+                       break;
+               }
+               if (countFound > 1) {
+                       message->what = B_REFS_RECEIVED;
+                       be_app->PostMessage(message);
+                       break;
+               }
+               entry_ref ref;
+               if (message->FindRef("refs", &ref) != B_OK)
+                       break;
+               BEntry entry(&ref, true);
+               BPath path;
+               if (!entry.Exists() || entry.GetPath(&path) != B_OK)
+                       break;
+               CurrentWebView()->LoadURL(path.Path());
+               break;
+       }
+
+       case TEXT_SIZE_INCREASE:
+               CurrentWebView()->IncreaseTextSize();
+               break;
+       case TEXT_SIZE_DECREASE:
+               CurrentWebView()->DecreaseTextSize();
+               break;
+       case TEXT_SIZE_RESET:
+               CurrentWebView()->ResetTextSize();
+               break;
+
+       case TEXT_FIND_NEXT:
+               CurrentWebView()->FindString(fFindTextControl->Text(), true,
+                       fFindCaseSensitiveCheckBox->Value());
+               break;
+       case TEXT_FIND_PREVIOUS:
+               CurrentWebView()->FindString(fFindTextControl->Text(), false,
+                       fFindCaseSensitiveCheckBox->Value());
+               break;
+       case TEXT_SHOW_FIND_GROUP:
+               if (!fFindGroup->IsVisible())
+                       fFindGroup->SetVisible(true);
+               fFindTextControl->MakeFocus(true);
+               break;
+       case TEXT_HIDE_FIND_GROUP:
+               if (fFindGroup->IsVisible())
+                       fFindGroup->SetVisible(false);
+               break;
+
+       case SHOW_DOWNLOAD_WINDOW:
+               message->AddUInt32("workspaces", Workspaces());
+               be_app->PostMessage(message);
+               break;
+
+       case CLOSE_TAB:
+               if (fTabManager->CountTabs() > 1) {
+                       int32 index;
+                       if (message->FindInt32("tab index", &index) != B_OK)
+                               index = fTabManager->SelectedTabIndex();
+                       delete fTabManager->RemoveTab(index);
+                       _UpdateTabGroupVisibility();
+               } else
+                       PostMessage(B_QUIT_REQUESTED);
+               break;
+
+       case TAB_CHANGED: {
+               // This message may be received also when the last tab closed, 
i.e. with index == -1.
+               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();
+               }
+               break;
+       }
 
-    updateTabGroupVisibility();
+       default:
+               BWebWindow::MessageReceived(message);
+               break;
+       }
 }
 
-// #pragma mark - Notification API
 
-void LauncherWindow::NavigationRequested(const BString& url, BWebView* view)
+bool
+BrowserWindow::QuitRequested()
 {
+       // TODO: Check for modified form data and ask user for confirmation, 
etc.
+
+       // Iterate over all tabs to delete all BWebViews.
+       // Do this here, so WebKit tear down happens earlier.
+       while (fTabManager->CountTabs() > 0)
+               delete fTabManager->RemoveTab(0L);
+       SetCurrentWebView(0);
+
+       BMessage message(WINDOW_CLOSED);
+       message.AddRect("window frame", Frame());
+       be_app->PostMessage(&message);
+       return true;
 }
 
-void LauncherWindow::NewWindowRequested(const BString& url, bool primaryAction)
+
+void
+BrowserWindow::MenusBeginning()
+{
+       BMenuItem* menuItem;
+       while ((menuItem = fGoMenu->RemoveItem(0L)))
+               delete menuItem;
+
+       BrowsingHistory* history = BrowsingHistory::defaultInstance();
+       if (!history->Lock())
+               return;
+
+       int32 count = history->countItems();
+       for (int32 i = 0; i < count; i++) {
+               BrowsingHistoryItem historyItem = history->historyItemAt(i);
+               BMessage* message = new BMessage(GOTO_URL);
+               message->AddString("url", historyItem.url().String());
+               // TODO: More sophisticated menu structure... sorted by 
days/weeks...
+               BString truncatedUrl(historyItem.url());
+               be_plain_font->TruncateString(&truncatedUrl, B_TRUNCATE_END, 
480);
+               menuItem = new BMenuItem(truncatedUrl, message);
+               fGoMenu->AddItem(menuItem);
+       }
+
+
+       if (fGoMenu->CountItems() > 3) {
+               fGoMenu->AddSeparatorItem();
+               fGoMenu->AddItem(new BMenuItem("Clear history",
+                       new BMessage(CLEAR_HISTORY)));
+       }
+
+       history->Unlock();
+}
+
+
+void
+BrowserWindow::CreateNewTab(const BString& url, bool select, BWebView* webView)
 {
-    // Always open new windows in the application thread, since
-    // creating a BWebView will try to grab the application lock.
-    // But our own WebPage may already try to lock us from within
-    // the application thread -> dead-lock. Thus we can't wait for
-    // a reply here.
-    BMessage message(NEW_TAB);
-    message.AddPointer("window", this);
-    message.AddString("url", url);
-    message.AddBool("select", primaryAction);
-    be_app->PostMessage(&message);
+       // Executed in app thread (new BWebPage needs to be created in app 
thread).
+       if (!webView)
+               webView = new BWebView("web view");
+       webView->WebPage()->SetDownloadListener(fDownloadListener);
+
+       fTabManager->AddTab(webView, "New tab");
+
+       if (url.Length())
+               webView->LoadURL(url.String());
+
+       if (select) {
+               fTabManager->SelectTab(fTabManager->CountTabs() - 1);
+               SetCurrentWebView(webView);
+               NavigationCapabilitiesChanged(false, false, false, webView);
+               if (fURLTextControl) {
+                       fURLTextControl->SetText(url.String());
+                       fURLTextControl->MakeFocus(true);
+               }
+       }
+
+       _UpdateTabGroupVisibility();
 }
 
-void LauncherWindow::NewPageCreated(BWebView* view)
+
+// #pragma mark - Notification API
+
+
+void
+BrowserWindow::NavigationRequested(const BString& url, BWebView* view)
 {
-    newTab(BString(), true, view);
 }
 
-void LauncherWindow::LoadNegotiating(const BString& url, BWebView* view)
+
+void
+BrowserWindow::NewWindowRequested(const BString& url, bool primaryAction)
 {
-    BString status("Requesting: ");
-    status << url;
-    StatusChanged(status, view);
+       // Always open new windows in the application thread, since
+       // creating a BWebView will try to grab the application lock.
+       // But our own WebPage may already try to lock us from within
+       // the application thread -> dead-lock. Thus we can't wait for
+       // a reply here.
+       BMessage message(NEW_TAB);
+       message.AddPointer("window", this);
+       message.AddString("url", url);
+       message.AddBool("select", primaryAction);
+       be_app->PostMessage(&message);
 }
 
-void LauncherWindow::LoadCommitted(const BString& url, BWebView* view)
+
+void 
+BrowserWindow::NewPageCreated(BWebView* view)
 {
-    if (view != CurrentWebView())
-        return;
+       CreateNewTab(BString(), true, view);
+}
 
-    m_loadedURL = url;
+
+void
+BrowserWindow::LoadNegotiating(const BString& url, BWebView* view)
+{
+       BString status("Requesting: ");
+       status << url;
+       StatusChanged(status, view);
+}
+
+
+void
+BrowserWindow::LoadCommitted(const BString& url, BWebView* view)
+{
+       if (view != CurrentWebView())
+               return;
 
        // This hook is invoked when the load is commited.
-    if (m_url)
-        m_url->SetText(url.String());
+       if (fURLTextControl)
+               fURLTextControl->SetText(url.String());
 
-    BString status("Loading: ");
-    status << url;
-    StatusChanged(status, view);
+       BString status("Loading: ");
+       status << url;
+       StatusChanged(status, view);
 }
 
-void LauncherWindow::LoadProgress(float progress, BWebView* view)
+
+void
+BrowserWindow::LoadProgress(float progress, BWebView* view)
 {
-    if (view != CurrentWebView())
-        return;
+       if (view != CurrentWebView())
+               return;
 
-    if (m_loadingProgressBar) {
-        if (progress < 100 && m_loadingProgressBar->IsHidden())
-            m_loadingProgressBar->Show();
-        m_loadingProgressBar->SetTo(progress);
-    }
+       if (fLoadingProgressBar) {
+               if (progress < 100 && fLoadingProgressBar->IsHidden())
+                       fLoadingProgressBar->Show();
+               fLoadingProgressBar->SetTo(progress);
+       }
 }
 
-void LauncherWindow::LoadFailed(const BString& url, BWebView* view)
+
+void
+BrowserWindow::LoadFailed(const BString& url, BWebView* view)
 {
-    if (view != CurrentWebView())
-        return;
+       if (view != CurrentWebView())
+               return;
 
-    BString status(url);
-    status << " failed.";
-    StatusChanged(status, view);
-    if (m_loadingProgressBar && !m_loadingProgressBar->IsHidden())
-        m_loadingProgressBar->Hide();
+       BString status(url);
+       status << " failed.";
+       StatusChanged(status, view);
+       if (fLoadingProgressBar && !fLoadingProgressBar->IsHidden())
+               fLoadingProgressBar->Hide();
 }
 
-void LauncherWindow::LoadFinished(const BString& url, BWebView* view)
+
+void
+BrowserWindow::LoadFinished(const BString& url, BWebView* view)
 {
-    if (view != CurrentWebView())
-        return;
+       if (view != CurrentWebView())
+               return;
 
-    m_loadedURL = url;
-    BString status(url);
-    status << " finished.";
-    StatusChanged(status, view);
-    if (m_loadingProgressBar && !m_loadingProgressBar->IsHidden())
-        m_loadingProgressBar->Hide();
+       BString status(url);
+       status << " finished.";
+       StatusChanged(status, view);
+       if (fLoadingProgressBar && !fLoadingProgressBar->IsHidden())
+               fLoadingProgressBar->Hide();
 
-    NavigationCapabilitiesChanged(m_BackButton->IsEnabled(),
-        m_ForwardButton->IsEnabled(), false, view);
+       NavigationCapabilitiesChanged(fBackButton->IsEnabled(),
+               fForwardButton->IsEnabled(), false, view);
 }
 
-void LauncherWindow::ResizeRequested(float width, float height, BWebView* view)
+
+void
+BrowserWindow::ResizeRequested(float width, float height, BWebView* view)
 {
-    if (view != CurrentWebView())
-        return;
+       if (view != CurrentWebView())
+               return;
 
-    // TODO: Ignore request when there is more than one BWebView embedded!
+       // TODO: Ignore request when there is more than one BWebView embedded!
 
-    ResizeTo(width, height);
+       ResizeTo(width, height);
 }
 
-void LauncherWindow::SetToolBarsVisible(bool flag, BWebView* view)
+
+void
+BrowserWindow::SetToolBarsVisible(bool flag, BWebView* view)
 {
-    // TODO
-    // TODO: Ignore request when there is more than one BWebView embedded!
+       // TODO
+       // TODO: Ignore request when there is more than one BWebView embedded!
 }
 
-void LauncherWindow::SetStatusBarVisible(bool flag, BWebView* view)
+
+void
+BrowserWindow::SetStatusBarVisible(bool flag, BWebView* view)
 {
-    // TODO
-    // TODO: Ignore request when there is more than one BWebView embedded!
+       // TODO
+       // TODO: Ignore request when there is more than one BWebView embedded!
 }
 
-void LauncherWindow::SetMenuBarVisible(bool flag, BWebView* view)
+
+void
+BrowserWindow::SetMenuBarVisible(bool flag, BWebView* view)
 {
-    // TODO
-    // TODO: Ignore request when there is more than one BWebView embedded!
+       // TODO
+       // TODO: Ignore request when there is more than one BWebView embedded!
 }
 
-void LauncherWindow::SetResizable(bool flag, BWebView* view)
+
+void
+BrowserWindow::SetResizable(bool flag, BWebView* view)
 {
-    // TODO: Ignore request when there is more than one BWebView embedded!
+       // TODO: Ignore request when there is more than one BWebView embedded!
 
-    if (flag)
-        SetFlags(Flags() & ~B_NOT_RESIZABLE);
-    else
-        SetFlags(Flags() | B_NOT_RESIZABLE);
+       if (flag)
+               SetFlags(Flags() & ~B_NOT_RESIZABLE);
+       else
+               SetFlags(Flags() | B_NOT_RESIZABLE);
 }
 
-void LauncherWindow::TitleChanged(const BString& title, BWebView* view)
+
+void
+BrowserWindow::TitleChanged(const BString& title, BWebView* view)
 {
-    for (int32 i = 0; i < m_tabManager->CountTabs(); i++) {
-        if (m_tabManager->ViewForTab(i) == view) {
-            m_tabManager->SetTabLabel(i, title);
-            break;
-        }
-    }
-    if (view != CurrentWebView())
-        return;
+       for (int32 i = 0; i < fTabManager->CountTabs(); i++) {
+               if (fTabManager->ViewForTab(i) == view) {
+                       fTabManager->SetTabLabel(i, title);
+                       break;
+               }
+       }
+       if (view != CurrentWebView())
+               return;
 
-    updateTitle(title);
+       _UpdateTitle(title);
 }
 
-void LauncherWindow::StatusChanged(const BString& statusText, BWebView* view)
+
+void
+BrowserWindow::StatusChanged(const BString& statusText, BWebView* view)
 {
-    if (view != CurrentWebView())
-        return;
+       if (view != CurrentWebView())
+               return;
 
-    if (m_statusText)
-        m_statusText->SetText(statusText.String());
+       if (fStatusText)
+               fStatusText->SetText(statusText.String());
 }
 
-void LauncherWindow::NavigationCapabilitiesChanged(bool canGoBackward,
-    bool canGoForward, bool canStop, BWebView* view)
+
+void
+BrowserWindow::NavigationCapabilitiesChanged(bool canGoBackward,
+       bool canGoForward, bool canStop, BWebView* view)
 {
-    if (view != CurrentWebView())
-        return;
+       if (view != CurrentWebView())
+               return;
 
-    if (m_BackButton)
-        m_BackButton->SetEnabled(canGoBackward);
-    if (m_ForwardButton)
-        m_ForwardButton->SetEnabled(canGoForward);
-    if (m_StopButton)
-        m_StopButton->SetEnabled(canStop);
+       if (fBackButton)
+               fBackButton->SetEnabled(canGoBackward);
+       if (fForwardButton)
+               fForwardButton->SetEnabled(canGoForward);
+       if (fStopButton)
+               fStopButton->SetEnabled(canStop);
 }
 
-void LauncherWindow::UpdateGlobalHistory(const BString& url)
+
+void
+BrowserWindow::UpdateGlobalHistory(const BString& url)
 {
-    BrowsingHistory::defaultInstance()->addItem(BrowsingHistoryItem(url));
+       BrowsingHistory::defaultInstance()->addItem(BrowsingHistoryItem(url));
 }
 
-void LauncherWindow::AuthenticationChallenge(BMessage* message)
+
+bool
+BrowserWindow::AuthenticationChallenge(BString message, BString& inOutUser,
+       BString& inOutPassword, bool& inOutRememberCredentials, uint32 
failureCount,
+       BWebView* view)
 {
-    BString text;
-    bool rememberCredentials = false;
-    uint32 failureCount = 0;
-    BString user;
-    BString password;
+       // Switch to the page for which this authentication is required.
+       if (view != CurrentWebView()) {
+               fTabManager->SelectTab(view);
+               UpdateIfNeeded();
+       }
+       AuthenticationPanel* panel = new AuthenticationPanel(Frame());
+               // Panel auto-destructs.
+       return panel->getAuthentication(message, inOutUser, inOutPassword,
+               inOutRememberCredentials, failureCount > 0, inOutUser, 
inOutPassword,
+               &inOutRememberCredentials);
+}
 
-    message->FindString("text", &text);
-    message->FindString("user", &user);
-    message->FindString("password", &password);
-    message->FindUInt32("failureCount", &failureCount);
 
-    AuthenticationPanel* panel = new AuthenticationPanel(Frame());
-    if (!panel->getAuthentication(text, user, password, rememberCredentials,
-            failureCount > 0, user, password, &rememberCredentials)) {
-        message->SendReply((uint32)0);
-        return;
-    }
+// #pragma mark - private
 
-    BMessage reply;
-    reply.AddString("user", user);
-    reply.AddString("password", password);
-    reply.AddBool("rememberCredentials", rememberCredentials);
-    message->SendReply(&reply);
-}
 
-void LauncherWindow::updateTitle(const BString& title)
+void
+BrowserWindow::_UpdateTitle(const BString& title)
 {
-    BString windowTitle = title;
-    if (windowTitle.Length() > 0)
-        windowTitle << " - ";
-    windowTitle << "HaikuLauncher";
-    SetTitle(windowTitle.String());
+       BString windowTitle = title;
+       if (windowTitle.Length() > 0)
+               windowTitle << " - ";
+       windowTitle << kApplicationName;
+       SetTitle(windowTitle.String());
 }
 
-void LauncherWindow::updateTabGroupVisibility()
+
+void
+BrowserWindow::_UpdateTabGroupVisibility()
 {
        if (Lock()) {
-           m_tabGroup->SetVisible(m_tabManager->CountTabs() > 1);
-           Unlock();
+               //fTabGroup->SetVisible(fTabManager->CountTabs() > 1);
+               fTabManager->SetCloseButtonsAvailable(fTabManager->CountTabs() 
> 1);
+               Unlock();
        }
 }

Copied and modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h 
(from r231, webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.h)
==============================================================================
--- webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.h    Sat Feb 27 
01:48:18 2010        (r231, copy source)
+++ webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h       Sat Feb 27 
15:51:43 2010        (r238)
@@ -26,9 +26,9 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
+#ifndef BROWSER_WINDOW_H
+#define BROWSER_WINDOW_H
 
-#ifndef LauncherWindow_h
-#define LauncherWindow_h
 
 #include "WebWindow.h"
 #include <Messenger.h>
@@ -46,72 +46,91 @@
 class BWebView;
 
 enum ToolbarPolicy {
-    HaveToolbar,
-    DoNotHaveToolbar
+       HaveToolbar,
+       DoNotHaveToolbar
 };
 
 enum {
-    NEW_WINDOW = 'nwnd',
-    NEW_TAB = 'ntab',
-    WINDOW_OPENED = 'wndo',
-    WINDOW_CLOSED = 'wndc',
-    SHOW_DOWNLOAD_WINDOW = 'sdwd'
+       NEW_WINDOW = 'nwnd',
+       NEW_TAB = 'ntab',
+       WINDOW_OPENED = 'wndo',
+       WINDOW_CLOSED = 'wndc',
+       SHOW_DOWNLOAD_WINDOW = 'sdwd'
 };
 
-class LauncherWindow : public BWebWindow {
+
+class BrowserWindow : public BWebWindow {
 public:
-    LauncherWindow(BRect frame, const BMessenger& downloadListener,
-        ToolbarPolicy = HaveToolbar);
-    virtual ~LauncherWindow();
-
-    virtual void MessageReceived(BMessage* message);
-    virtual bool QuitRequested();
-    virtual void MenusBeginning();
+                                                               
BrowserWindow(BRect frame,
+                                                                       const 
BMessenger& downloadListener,
+                                                                       
ToolbarPolicy = HaveToolbar);
+       virtual                                         ~BrowserWindow();
+
+       virtual void                            DispatchMessage(BMessage* 
message,
+                                                                       
BHandler* target);
+       virtual void                            MessageReceived(BMessage* 
message);
+       virtual bool                            QuitRequested();
+       virtual void                            MenusBeginning();
 
-    void newTab(const BString& url, bool select, BWebView* webView = 0);
+                       void                            CreateNewTab(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);
-    virtual void LoadFailed(const BString& url, BWebView* view);
-    virtual void LoadFinished(const BString& url, BWebView* view);
-    virtual void TitleChanged(const BString& title, BWebView* view);
-    virtual void ResizeRequested(float width, float height, BWebView* view);
-    virtual void SetToolBarsVisible(bool flag, BWebView* view);
-    virtual void SetStatusBarVisible(bool flag, BWebView* view);
-    virtual void SetMenuBarVisible(bool flag, BWebView* view);
-    virtual void SetResizable(bool flag, BWebView* view);
-    virtual void StatusChanged(const BString& status, BWebView* view);
-    virtual void NavigationCapabilitiesChanged(bool canGoBackward,
-        bool canGoForward, bool canStop, BWebView* view);
-    virtual void UpdateGlobalHistory(const BString& url);
-    virtual void AuthenticationChallenge(BMessage* challenge);
+       // 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);
+       virtual void                            LoadFailed(const BString& url, 
BWebView* view);
+       virtual void                            LoadFinished(const BString& url,
+                                                                       
BWebView* view);
+       virtual void                            TitleChanged(const BString& 
title,
+                                                                       
BWebView* view);
+       virtual void                            ResizeRequested(float width, 
float height,
+                                                                       
BWebView* view);
+       virtual void                            SetToolBarsVisible(bool flag, 
BWebView* view);
+       virtual void                            SetStatusBarVisible(bool flag, 
BWebView* view);
+       virtual void                            SetMenuBarVisible(bool flag, 
BWebView* view);
+       virtual void                            SetResizable(bool flag, 
BWebView* view);
+       virtual void                            StatusChanged(const BString& 
status,
+                                                                       
BWebView* view);
+       virtual void                            NavigationCapabilitiesChanged(
+                                                                       bool 
canGoBackward, bool canGoForward,
+                                                                       bool 
canStop, BWebView* view);
+       virtual void                            UpdateGlobalHistory(const 
BString& url);
+       virtual bool                            AuthenticationChallenge(BString 
message,
+                                                                       
BString& inOutUser, BString& inOutPassword,
+                                                                       bool& 
inOutRememberCredentials,
+                                                                       uint32 
failureCount, BWebView* view);
 
-    void updateTitle(const BString &title);
-    void updateTabGroupVisibility();
+private:
+                       void                            _UpdateTitle(const 
BString &title);
+                       void                            
_UpdateTabGroupVisibility();
 
 private:
-    BMessenger m_downloadListener;
-    BMenuBar* m_menuBar;
-    BMenu* m_goMenu;
-    IconButton* m_BackButton;
-    IconButton* m_ForwardButton;
-    IconButton* m_StopButton;
-    BTextControl* m_url;
-    BString m_loadedURL;
-    BStringView* m_statusText;
-    BStatusBar* m_loadingProgressBar;
-    BLayoutItem* m_findGroup;
-    BLayoutItem* m_tabGroup;
-    BTextControl* m_findTextControl;
-    BCheckBox* m_findCaseSensitiveCheckBox;
-    TabManager* m_tabManager;
+                       BMessenger                      fDownloadListener;
+                       BMenuBar*                       fMenuBar;
+                       BMenu*                          fGoMenu;
+                       IconButton*                     fBackButton;
+                       IconButton*                     fForwardButton;
+                       IconButton*                     fStopButton;
+                       BButton*                        fGoButton;
+                       BTextControl*           fURLTextControl;
+                       BStringView*            fStatusText;
+                       BStatusBar*                     fLoadingProgressBar;
+                       BLayoutItem*            fFindGroup;
+                       BLayoutItem*            fTabGroup;
+                       BTextControl*           fFindTextControl;
+                       BCheckBox*                      
fFindCaseSensitiveCheckBox;
+                       TabManager*                     fTabManager;
 };
 
-#endif // LauncherWindow_h
+
+#endif // BROWSER_WINDOW_H
 

Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowsingHistory.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/HaikuLauncher/BrowsingHistory.cpp Sat Feb 27 
01:48:18 2010        (r231)
+++ webkit/trunk/WebKit/haiku/WebPositive/BrowsingHistory.cpp   Sat Feb 27 
15:51:43 2010        (r238)
@@ -28,6 +28,7 @@
 #include "config.h"
 #include "BrowsingHistory.h"
 
+#include "BrowserApp.h"
 #include <Autolock.h>
 #include <Entry.h>
 #include <File.h>
@@ -262,7 +263,8 @@
 {
        BPath path;
        if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK
-               || path.Append("HaikuLauncher_BrowsingHistory") != B_OK) {
+               || path.Append(kApplicationName) != B_OK
+               || path.Append("BrowsingHistory") != B_OK) {
                return false;
        }
        return file.SetTo(path.Path(), mode) == B_OK;

Modified: webkit/trunk/WebKit/haiku/WebPositive/DownloadWindow.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/HaikuLauncher/DownloadWindow.cpp  Sat Feb 27 
01:48:18 2010        (r231)
+++ webkit/trunk/WebKit/haiku/WebPositive/DownloadWindow.cpp    Sat Feb 27 
15:51:43 2010        (r238)
@@ -28,6 +28,7 @@
 #include "config.h"
 #include "DownloadWindow.h"
 
+#include "BrowserApp.h"
 #include "WebDownload.h"
 #include "WebPage.h"
 #include <Alert.h>
@@ -550,7 +551,8 @@
 {
        BPath path;
        if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK
-               || path.Append("HaikuLauncher_Downloads") != B_OK) {
+               || path.Append(kApplicationName) != B_OK
+               || path.Append("Downloads") != B_OK) {
                return false;
        }
        return file.SetTo(path.Path(), mode) == B_OK;

Copied and modified: webkit/trunk/WebKit/haiku/WebPositive/WebPositive.rdef 
(from r231, webkit/trunk/WebKit/haiku/HaikuLauncher/Launcher.rdef)
==============================================================================
--- webkit/trunk/WebKit/haiku/HaikuLauncher/Launcher.rdef       Sat Feb 27 
01:48:18 2010        (r231, copy source)
+++ webkit/trunk/WebKit/haiku/WebPositive/WebPositive.rdef      Sat Feb 27 
15:51:43 2010        (r238)
@@ -1,4 +1,4 @@
-resource app_signature "application/x-vnd.RJL-HaikuLauncher";
+resource app_signature "application/x-vnd.Haiku-WebPositive";
 
 resource app_version {
        major      = 0,
@@ -6,8 +6,8 @@
        minor      = 1,
        variety    = B_APPV_ALPHA,
        internal   = 0,
-       short_info = "HaikuLauncher",
-       long_info  = "HaikuLauncher ©2007-2010 The WebKit Haiku Project"
+       short_info = "WebPositive",
+       long_info  = "WebPositive ©2007-2010 The WebKit Haiku Project"
 };
 
 resource app_flags B_SINGLE_LAUNCH;

Copied: webkit/trunk/WebKit/haiku/WebPositive/WebTabView.cpp (from r237, 
webkit/trunk/WebKit/haiku/HaikuLauncher/WebTabView.cpp)
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ webkit/trunk/WebKit/haiku/WebPositive/WebTabView.cpp        Sat Feb 27 
15:51:43 2010        (r238, copy of r237, 
webkit/trunk/WebKit/haiku/HaikuLauncher/WebTabView.cpp)
@@ -0,0 +1,1220 @@
+/*
+ * Copyright (C) 2010 Rene Gollent <rene@xxxxxxxxxxx>
+ * Copyright (C) 2010 Stephan Aßmus <superstippi@xxxxxx>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "WebTabView.h"
+
+#include "WebView.h"
+#include <Application.h>
+#include <AbstractLayoutItem.h>
+#include <Button.h>
+#include <CardLayout.h>
+#include <ControlLook.h>
+#include <GroupView.h>
+#include <SpaceLayoutItem.h>
+#include <Window.h>
+#include <stdio.h>
+
+
+class TabView;
+class TabContainerView;
+
+
+class TabLayoutItem : public BAbstractLayoutItem {
+public:
+       TabLayoutItem(TabView* parent);
+
+       virtual bool IsVisible();
+       virtual void SetVisible(bool visible);
+
+       virtual BRect Frame();
+       virtual void SetFrame(BRect frame);
+
+       virtual BView* View();
+
+       virtual BSize BaseMinSize();
+       virtual BSize BaseMaxSize();
+       virtual BSize BasePreferredSize();
+       virtual BAlignment BaseAlignment();
+
+       TabView* Parent() const;
+
+private:
+       TabView* fParent;
+       BRect fFrame;
+};
+
+
+class TabView {
+public:
+       TabView();
+       virtual ~TabView();
+
+       virtual BSize MinSize();
+       virtual BSize PreferredSize();
+       virtual BSize MaxSize();
+
+       void Draw(BRect updateRect);
+       virtual void DrawBackground(BView* owner, BRect frame,
+               const BRect& updateRect, bool isFirst, bool isLast, bool 
isFront);
+       virtual void DrawContents(BView* owner, BRect frame,
+               const BRect& updateRect, bool isFirst, bool isLast, bool 
isFront);
+
+       virtual void MouseDown(BPoint where, uint32 buttons);
+       virtual void MouseUp(BPoint where);
+       virtual void MouseMoved(BPoint where, uint32 transit,
+               const BMessage* dragMessage);
+
+       void SetIsFront(bool isFront);
+       bool IsFront() const;
+       void SetIsLast(bool isLast);
+       virtual void Update(bool isFirst, bool isLast, bool isFront);
+
+       BLayoutItem* LayoutItem() const;
+       void SetContainerView(TabContainerView* containerView);
+       TabContainerView* ContainerView() const;
+
+       void SetLabel(const char* label);
+       const BString& Label() const;
+
+       BRect Frame() const;
+
+private:
+       float _LabelHeight() const;
+
+private:
+       TabContainerView* fContainerView;
+       TabLayoutItem* fLayoutItem;
+       
+       BString fLabel;
+
+       bool fIsFirst;
+       bool fIsLast;
+       bool fIsFront;
+};
+
+
+class TabContainerView : public BGroupView {
+public:
+       class Controller {
+       public:
+               virtual void TabSelected(int32 tabIndex) = 0;
+               virtual bool HasFrames() = 0;
+               virtual TabView* CreateTabView() = 0;
+       };
+
+public:
+       TabContainerView(Controller* controller);
+       virtual ~TabContainerView();
+
+       virtual BSize MinSize();
+
+       virtual void MessageReceived(BMessage*);
+
+       virtual void Draw(BRect updateRect);
+
+       virtual void MouseDown(BPoint where);
+       virtual void MouseUp(BPoint where);
+       virtual void MouseMoved(BPoint where, uint32 transit,
+               const BMessage* dragMessage);
+
+       void AddTab(const char* label, int32 index = -1);
+       void AddTab(TabView* tab, int32 index = -1);
+       TabView* RemoveTab(int32 index);
+
+       int32 IndexOf(TabView* tab) const;
+
+       void SelectTab(int32 tabIndex);
+       void SelectTab(TabView* tab);
+
+       void SetTabLabel(int32 tabIndex, const char* label);
+
+private:
+       TabView* _TabAt(const BPoint& where) const;
+
+private:
+       TabView* fLastMouseEventTab;
+       bool fMouseDown;
+       TabView* fSelectedTab;
+       Controller* fController;
+};
+
+
+// #pragma mark - TabContainerView
+
+
+static const float kLeftTabInset = 4;
+
+
+TabContainerView::TabContainerView(Controller* controller)
+       :
+       BGroupView(B_HORIZONTAL),
+       fLastMouseEventTab(NULL),
+       fMouseDown(false),
+       fSelectedTab(NULL),
+       fController(controller)
+{
+       SetFlags(Flags() | B_WILL_DRAW);
+       SetViewColor(B_TRANSPARENT_COLOR);
+       GroupLayout()->SetInsets(kLeftTabInset, 0, 0, 1);
+       GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue(), 0.0f);
+}
+
+
+TabContainerView::~TabContainerView()
+{
+}
+
+
+BSize
+TabContainerView::MinSize()
+{
+       // Eventually, we want to be scrolling if the tabs don't fit.
+       BSize size(BGroupView::MinSize());
+       size.width = 300;
+       return size;
+}
+
+
+void
+TabContainerView::MessageReceived(BMessage* message)
+{
+       switch (message->what) {
+               default:
+                       BGroupView::MessageReceived(message);
+       }
+}
+
+
+void
+TabContainerView::Draw(BRect updateRect)
+{
+       // Stroke separator line at bottom.
+       rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
+       BRect frame(Bounds());
+       SetHighColor(tint_color(base, B_DARKEN_2_TINT));
+       StrokeLine(frame.LeftBottom(), frame.RightBottom());
+       frame.bottom--;
+
+       // Draw empty area before first tab.
+       uint32 borders = BControlLook::B_TOP_BORDER | 
BControlLook::B_BOTTOM_BORDER;
+       BRect leftFrame(frame.left, frame.top, kLeftTabInset, frame.bottom);
+       be_control_look->DrawInactiveTab(this, leftFrame, updateRect, base, 0,
+               borders);
+
+       // Draw all tabs, keeping track of where they end.
+       BGroupLayout* layout = GroupLayout();
+       int32 count = layout->CountItems() - 1;
+       for (int32 i = 0; i < count; i++) {
+               TabLayoutItem* item = dynamic_cast<TabLayoutItem*>(
+                       layout->ItemAt(i));
+               if (!item)
+                       continue;
+               item->Parent()->Draw(updateRect);
+               frame.left = item->Frame().right + 1;
+       }
+
+       // Draw empty area after last tab.
+       be_control_look->DrawInactiveTab(this, frame, updateRect, base, 0, 
borders);
+}
+
+
+void
+TabContainerView::MouseDown(BPoint where)
+{
+       uint32 buttons;
+       if (Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons) 
!= B_OK)
+               buttons = B_PRIMARY_MOUSE_BUTTON;
+       fMouseDown = true;
+       SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
+       if (fLastMouseEventTab)
+               fLastMouseEventTab->MouseDown(where, buttons);
+}
+
+
+void
+TabContainerView::MouseUp(BPoint where)
+{
+       fMouseDown = false;
+       if (fLastMouseEventTab)
+               fLastMouseEventTab->MouseUp(where);
+}
+
+
+void
+TabContainerView::MouseMoved(BPoint where, uint32 transit,
+       const BMessage* dragMessage)
+{
+       TabView* tab = _TabAt(where);
+       if (fMouseDown) {
+               uint32 transit = tab == fLastMouseEventTab
+                       ? B_INSIDE_VIEW : B_OUTSIDE_VIEW;
+               if (fLastMouseEventTab)
+                       fLastMouseEventTab->MouseMoved(where, transit, 
dragMessage);
+               return;
+       }
+
+       if (fLastMouseEventTab && fLastMouseEventTab == tab)
+               fLastMouseEventTab->MouseMoved(where, B_INSIDE_VIEW, 
dragMessage);
+       else {
+               if (fLastMouseEventTab)
+                       fLastMouseEventTab->MouseMoved(where, B_EXITED_VIEW, 
dragMessage);
+               fLastMouseEventTab = tab;
+               if (fLastMouseEventTab)
+                       fLastMouseEventTab->MouseMoved(where, B_ENTERED_VIEW, 
dragMessage);
+       }
+}
+
+
+void
+TabContainerView::AddTab(const char* label, int32 index)
+{
+       TabView* tab;
+       if (fController)
+               tab = fController->CreateTabView();
+       else
+               tab = new TabView();
+       tab->SetLabel(label);
+       AddTab(tab, index);
+}
+
+
+void
+TabContainerView::AddTab(TabView* tab, int32 index)
+{
+       tab->SetContainerView(this);
+
+       if (index == -1)
+               index = GroupLayout()->CountItems() - 1;
+
+       bool hasFrames = fController != NULL && fController->HasFrames();
+       bool isFirst = index == 0 && hasFrames;
+       bool isLast = index == GroupLayout()->CountItems() - 1 && hasFrames;
+       bool isFront = fSelectedTab == NULL;
+       tab->Update(isFirst, isLast, isFront);
+
+       GroupLayout()->AddItem(index, tab->LayoutItem());
+
+       if (isFront)
+               SelectTab(tab);
+       if (isLast) {
+               TabLayoutItem* item
+                       = 
dynamic_cast<TabLayoutItem*>(GroupLayout()->ItemAt(index - 1));
+               if (item)
+                       item->Parent()->SetIsLast(false);
+       }
+}
+
+TabView*
+TabContainerView::RemoveTab(int32 index)
+{
+       TabLayoutItem* item
+               = 
dynamic_cast<TabLayoutItem*>(GroupLayout()->RemoveItem(index));
+
+       if (!item)
+               return NULL;
+
+       BRect dirty(Bounds());
+       dirty.left = item->Frame().left;
+       TabView* removedTab = item->Parent();
+       removedTab->SetContainerView(NULL);
+
+       if (removedTab == fLastMouseEventTab)
+               fLastMouseEventTab = NULL;
+
+       // Update tabs after or before the removed tab.
+       bool hasFrames = fController != NULL && fController->HasFrames();
+       item = dynamic_cast<TabLayoutItem*>(GroupLayout()->ItemAt(index));
+       if (item) {
+               // This tab is behind the removed tab.
+               TabView* tab = item->Parent();
+               tab->Update(index == 0 && hasFrames,
+                       index == GroupLayout()->CountItems() - 2 && hasFrames,
+                       tab == fSelectedTab);
+               if (removedTab == fSelectedTab) {
+                       fSelectedTab = NULL;
+                       SelectTab(tab);
+               } else if (fController && tab == fSelectedTab)
+                       fController->TabSelected(index);
+       } else {
+               // The removed tab was the last tab.
+               item = dynamic_cast<TabLayoutItem*>(GroupLayout()->ItemAt(index 
- 1));
+               if (item) {
+                       TabView* tab = item->Parent();
+                       tab->Update(index == 0 && hasFrames,
+                               index == GroupLayout()->CountItems() - 2 && 
hasFrames,
+                               tab == fSelectedTab);
+                       if (removedTab == fSelectedTab) {
+                               fSelectedTab = NULL;
+                               SelectTab(tab);
+                       }
+               }
+       }
+
+       Invalidate(dirty);
+
+       return removedTab;
+}
+
+
+int32
+TabContainerView::IndexOf(TabView* tab) const
+{
+       return GroupLayout()->IndexOfItem(tab->LayoutItem());
+}
+
+
+void
+TabContainerView::SelectTab(int32 index)
+{
+       TabView* tab = NULL;
+       TabLayoutItem* item = dynamic_cast<TabLayoutItem*>(
+               GroupLayout()->ItemAt(index));
+       if (item)
+               tab = item->Parent();
+       
+       SelectTab(tab);
+}
+
+
+void
+TabContainerView::SelectTab(TabView* tab)
+{
+       if (tab == fSelectedTab)
+               return;
+
+       if (fSelectedTab)
+               fSelectedTab->SetIsFront(false);
+
+       fSelectedTab = tab;
+
+       if (fSelectedTab)
+               fSelectedTab->SetIsFront(true);
+
+       if (fController != NULL) {
+               int32 index = -1;
+               if (fSelectedTab != NULL)
+                       index = GroupLayout()->IndexOfItem(tab->LayoutItem());
+
+               fController->TabSelected(index);
+       }
+}
+
+
+void
+TabContainerView::SetTabLabel(int32 tabIndex, const char* label)
+{
+       TabLayoutItem* item = dynamic_cast<TabLayoutItem*>(
+               GroupLayout()->ItemAt(tabIndex));
+       if (item == NULL)
+               return;
+
+       item->Parent()->SetLabel(label);
+}
+
+
+TabView*
+TabContainerView::_TabAt(const BPoint& where) const
+{
+       BGroupLayout* layout = GroupLayout();
+       int32 count = layout->CountItems() - 1;
+       for (int32 i = 0; i < count; i++) {
+               TabLayoutItem* item = dynamic_cast<TabLayoutItem*>(
+                       layout->ItemAt(i));
+               if (item && item->Frame().Contains(where))
+                       return item->Parent();
+       }
+       return NULL;
+}
+
+
+// #pragma mark - TabView
+
+
+TabView::TabView()
+       : fContainerView(NULL)
+       , fLayoutItem(new TabLayoutItem(this))
+       , fLabel()
+{
+}
+
+TabView::~TabView()
+{
+       // The layout item is deleted for us by the layout which contains it.
+       if (!fContainerView)
+               delete fLayoutItem;
+}
+
+BSize TabView::MinSize()
+{
+       BSize size(MaxSize());
+       size.width = 100.0f;
+       return size;
+}
+
+BSize TabView::PreferredSize()
+{
+       return MaxSize();
+}
+
+BSize TabView::MaxSize()
+{
+       float extra = be_control_look->DefaultLabelSpacing();
+       float labelWidth = fContainerView->StringWidth(fLabel.String()) + 2 * 
extra;
+       labelWidth = min_c(300.0f, labelWidth);
+       return BSize(labelWidth, _LabelHeight() + extra);
+}
+
+void TabView::Draw(BRect updateRect)
+{
+       BRect frame(fLayoutItem->Frame());
+       if (fIsFront) {
+           // Extend the front tab outward left/right in order to merge
+           // the frames of adjacent tabs.
+           if (!fIsFirst)
+               frame.left--;
+           if (!fIsLast)
+               frame.right++;
+
+               frame.bottom++;
+       }
+       DrawBackground(fContainerView, frame, updateRect, fIsFirst, fIsLast,
+               fIsFront);
+       if (fIsFront) {
+           frame.top += 3.0f;
+           if (!fIsFirst)
+               frame.left++;
+           if (!fIsLast)
+               frame.right--;
+       } else
+               frame.top += 6.0f;
+       float spacing = be_control_look->DefaultLabelSpacing();
+       frame.InsetBy(spacing, spacing / 2);
+       DrawContents(fContainerView, frame, updateRect, fIsFirst, fIsLast,
+               fIsFront);
+}
+
+void TabView::DrawBackground(BView* owner, BRect frame, const BRect& 
updateRect,
+       bool isFirst, bool isLast, bool isFront)
+{
+       rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
+       uint32 borders = BControlLook::B_TOP_BORDER
+               | BControlLook::B_BOTTOM_BORDER;
+       if (isFirst)
+               borders |= BControlLook::B_LEFT_BORDER;
+       if (isLast)
+               borders |= BControlLook::B_RIGHT_BORDER;
+       if (isFront) {
+               be_control_look->DrawActiveTab(owner, frame, updateRect, base,
+                       0, borders);
+       } else {
+               be_control_look->DrawInactiveTab(owner, frame, updateRect, base,
+                       0, borders);
+       }
+}
+
+void TabView::DrawContents(BView* owner, BRect frame, const BRect& updateRect,
+       bool isFirst, bool isLast, bool isFront)
+{
+       rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
+       be_control_look->DrawLabel(owner, fLabel.String(), frame, updateRect,
+               base, 0, BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
+}
+
+void TabView::MouseDown(BPoint where, uint32 buttons)
+{
+       fContainerView->SelectTab(this);
+}
+
+void TabView::MouseUp(BPoint where)
+{
+}
+
+void TabView::MouseMoved(BPoint where, uint32 transit,
+       const BMessage* dragMessage)
+{
+}
+
+void TabView::SetIsFront(bool isFront)
+{
+       Update(fIsFirst, fIsLast, isFront);
+}
+
+bool TabView::IsFront() const
+{
+       return fIsFront;
+}
+
+void TabView::SetIsLast(bool isLast)
+{
+       Update(fIsFirst, isLast, fIsFront);
+}
+
+void TabView::Update(bool isFirst, bool isLast, bool isFront)
+{
+       if (fIsFirst == isFirst && fIsLast == isLast && fIsFront == isFront)
+               return;
+       fIsFirst = isFirst;
+       fIsLast = isLast;
+       fIsFront = isFront;
+       BRect frame = fLayoutItem->Frame();
+       frame.bottom++;
+       fContainerView->Invalidate(frame);
+}
+
+void TabView::SetContainerView(TabContainerView* containerView)
+{
+       fContainerView = containerView;
+}
+
+TabContainerView* TabView::ContainerView() const
+{
+       return fContainerView;
+}
+
+BLayoutItem* TabView::LayoutItem() const
+{
+       return fLayoutItem;
+}
+
+void TabView::SetLabel(const char* label)
+{
+       if (fLabel == label)
+               return;
+       fLabel = label;
+       fLayoutItem->InvalidateLayout();
+}
+
+const BString& TabView::Label() const
+{
+       return fLabel;
+}
+
+
+BRect
+TabView::Frame() const
+{
+       return fLayoutItem->Frame();
+}
+
+
+float TabView::_LabelHeight() const
+{
+       font_height fontHeight;
+       fContainerView->GetFontHeight(&fontHeight);
+       return ceilf(fontHeight.ascent) + ceilf(fontHeight.descent);
+}
+
+// #pragma mark - TabLayoutItem
+
+TabLayoutItem::TabLayoutItem(TabView* parent)
+       : fParent(parent)
+{
+}
+
+bool TabLayoutItem::IsVisible()
+{
+       return !fParent->ContainerView()->IsHidden(fParent->ContainerView());
+}
+
+void TabLayoutItem::SetVisible(bool visible)
+{
+       // not allowed
+}
+
+BRect TabLayoutItem::Frame()
+{
+       return fFrame;
+}
+
+void TabLayoutItem::SetFrame(BRect frame)
+{
+       BRect dirty = fFrame;
+       fFrame = frame;
+       dirty = dirty | fFrame;
+       // Invalidate more than necessary, to help the TabContainerView
+       // redraw the parts outside any tabs...
+       dirty.bottom++;
+       dirty.right++;
+       fParent->ContainerView()->Invalidate(dirty);
+}
+
+BView* TabLayoutItem::View()
+{
+       return NULL;
+}
+
+BSize TabLayoutItem::BaseMinSize()
+{
+       return fParent->MinSize();
+}
+
+BSize TabLayoutItem::BaseMaxSize()
+{
+       return fParent->MaxSize();
+}
+
+BSize TabLayoutItem::BasePreferredSize()
+{
+       return fParent->PreferredSize();
+}
+
+BAlignment TabLayoutItem::BaseAlignment()
+{
+       return BAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT);
+}
+
+TabView* TabLayoutItem::Parent() const
+{
+       return fParent;
+}
+
+
+// #pragma mark - TabManagerController
+
+
+class TabManagerController : public TabContainerView::Controller {
+public:
+       TabManagerController(TabManager* manager);
+
+       virtual void TabSelected(int32 index)
+       {
+               fManager->SelectTab(index);
+       }
+
+       virtual bool HasFrames()
+       {
+               return false;
+       }
+
+       virtual TabView* CreateTabView();
+
+       void CloseTab(int32 index);
+
+       void SetCloseButtonsAvailable(bool available)
+       {
+               fCloseButtonsAvailable = available;
+       }
+
+       bool CloseButtonsAvailable() const
+       {
+               return fCloseButtonsAvailable;
+       }
+
+private:
+       TabManager* fManager;
+       bool fCloseButtonsAvailable;
+};
+
+
+// #pragma mark - WebTabView
+
+
+class WebTabView : public TabView {
+public:
+       WebTabView(TabManagerController* controller);
+
+       virtual BSize MaxSize();
+
+       virtual void DrawContents(BView* owner, BRect frame, const BRect& 
updateRect,
+               bool isFirst, bool isLast, bool isFront);
+
+       virtual void MouseDown(BPoint where, uint32 buttons);
+       virtual void MouseUp(BPoint where);
+       virtual void MouseMoved(BPoint where, uint32 transit,
+               const BMessage* dragMessage);
+
+private:
+       void _DrawCloseButton(BView* owner, BRect& frame, const BRect& 
updateRect,
+               bool isFirst, bool isLast, bool isFront);
+       BRect _CloseRectFrame(BRect frame) const;
+
+private:
+       TabManagerController* fController;
+       bool fOverCloseRect;
+       bool fClicked;
+};
+
+
+WebTabView::WebTabView(TabManagerController* controller)
+       :
+       TabView(),
+       fController(controller),
+       fOverCloseRect(false),
+       fClicked(false)
+{
+}
+
+
+BSize
+WebTabView::MaxSize()
+{
+       // Account for close button.
+       BSize size(TabView::MaxSize());
+       size.width += size.height;
+       return size;
+}
+
+
+void
+WebTabView::DrawContents(BView* owner, BRect frame, const BRect& updateRect,
+       bool isFirst, bool isLast, bool isFront)
+{
+       if (fController->CloseButtonsAvailable())
+               _DrawCloseButton(owner, frame, updateRect, isFirst, isLast, 
isFront);
+
+       TabView::DrawContents(owner, frame, updateRect, isFirst, isLast, 
isFront);
+}
+
+
+void
+WebTabView::MouseDown(BPoint where, uint32 buttons)
+{
+       if (buttons & B_TERTIARY_MOUSE_BUTTON) {
+               fController->CloseTab(ContainerView()->IndexOf(this));
+               return;
+       }
+
+       BRect closeRect = _CloseRectFrame(Frame());
+       if (!fController->CloseButtonsAvailable() || 
!closeRect.Contains(where)) {
+               TabView::MouseDown(where, buttons);
+               return;
+       }
+
+       fClicked = true;
+       ContainerView()->Invalidate(closeRect);
+}
+
+
+void
+WebTabView::MouseUp(BPoint where)
+{
+       if (!fClicked) {
+               TabView::MouseUp(where);
+               return;
+       }
+
+       fClicked = false;
+
+       if (_CloseRectFrame(Frame()).Contains(where))
+               fController->CloseTab(ContainerView()->IndexOf(this));
+}
+
+
+void
+WebTabView::MouseMoved(BPoint where, uint32 transit,
+       const BMessage* dragMessage)
+{
+       if (fController->CloseButtonsAvailable()) {
+               BRect closeRect = _CloseRectFrame(Frame());
+               bool overCloseRect = closeRect.Contains(where);
+               if (overCloseRect != fOverCloseRect) {
+                       fOverCloseRect = overCloseRect;
+                       ContainerView()->Invalidate(closeRect);
+               }
+       }
+
+       TabView::MouseMoved(where, transit, dragMessage);
+}
+
+
+BRect
+WebTabView::_CloseRectFrame(BRect frame) const
+{
+       frame.left = frame.right - frame.Height();
+       return frame;
+}
+
+
+void WebTabView::_DrawCloseButton(BView* owner, BRect& frame,
+       const BRect& updateRect, bool isFirst, bool isLast, bool isFront)
+{
+       BRect closeRect = _CloseRectFrame(frame);
+       frame.right = closeRect.left - be_control_look->DefaultLabelSpacing();
+
+       closeRect.left = (closeRect.left + closeRect.right) / 2 - 3;
+       closeRect.right = closeRect.left + 6;
+       closeRect.top = (closeRect.top + closeRect.bottom) / 2 - 3;
+       closeRect.bottom = closeRect.top + 6;
+
+       rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
+       float tint = B_DARKEN_1_TINT;
+       if (!IsFront())
+               tint *= 1.02;
+
+       base = tint_color(base, tint);
+
+       if (fOverCloseRect)
+               tint *= 1.2;
+
+       if (fClicked && fOverCloseRect) {
+               BRect buttonRect(closeRect.InsetByCopy(-4, -4));
+               be_control_look->DrawButtonFrame(owner, buttonRect, updateRect,
+                       base, base,
+                       BControlLook::B_ACTIVATED | 
BControlLook::B_BLEND_FRAME);
+               be_control_look->DrawButtonBackground(owner, buttonRect, 
updateRect,
+                       base, BControlLook::B_ACTIVATED);
+               tint *= 1.2;
+               closeRect.OffsetBy(1, 1);
+       }
+
+       base = tint_color(base, tint);
+       owner->SetHighColor(base);
+       owner->SetPenSize(2);
+       owner->StrokeLine(closeRect.LeftTop(), closeRect.RightBottom());
+       owner->StrokeLine(closeRect.LeftBottom(), closeRect.RightTop());
+       owner->SetPenSize(1);
+}
+
+
+// #pragma mark - TabManagerController
+
+
+TabManagerController::TabManagerController(TabManager* manager)
+       :
+       fManager(manager),
+       fCloseButtonsAvailable(false)
+{
+}
+
+
+TabView*
+TabManagerController::CreateTabView()
+{
+       return new WebTabView(this);
+}
+
+
+void
+TabManagerController::CloseTab(int32 index)
+{
+       fManager->CloseTab(index);
+}
+
+
+// #pragma mark - TabButton
+
+
+class TabButton : public BButton {
+public:
+       TabButton(BMessage* message)
+               : BButton("", message)
+       {
+       }
+
+       virtual BSize MinSize()
+       {
+               return BSize(12, 12);
+       }
+
+       virtual BSize MaxSize()
+       {
+               return BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED);
+       }
+
+       virtual BSize PreferredSize()
+       {
+               return MinSize();
+       }
+
+       virtual void Draw(BRect updateRect)
+       {
+               BRect bounds(Bounds());
+               rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
+               SetHighColor(tint_color(base, B_DARKEN_2_TINT));
+               StrokeLine(bounds.LeftBottom(), bounds.RightBottom());
+               bounds.bottom--;
+               uint32 flags = be_control_look->Flags(this);
+               uint32 borders = BControlLook::B_TOP_BORDER
+                       | BControlLook::B_BOTTOM_BORDER;
+               be_control_look->DrawInactiveTab(this, bounds, updateRect, base,
+                       flags, borders);
+               if (IsEnabled()) {
+                       rgb_color button = tint_color(base, 1.07);
+                       be_control_look->DrawButtonBackground(this, bounds, 
updateRect,
+                               button, flags, 0);
+               }
+
+               bounds.left = (bounds.left + bounds.right) / 2 - 6;
+               bounds.top = (bounds.top + bounds.bottom) / 2 - 6;
+               bounds.right = bounds.left + 12;
+               bounds.bottom = bounds.top + 12;
+               DrawSymbol(bounds, updateRect, base);
+       }
+
+       virtual void DrawSymbol(BRect frame, const BRect& updateRect,
+               const rgb_color& base)
+       {
+       }
+};
+
+
+class ScrollLeftTabButton : public TabButton {
+public:
+       ScrollLeftTabButton(BMessage* message)
+               : TabButton(message)
+       {
+       }
+
+       virtual void DrawSymbol(BRect frame, const BRect& updateRect,
+               const rgb_color& base)
+       {
+               be_control_look->DrawArrowShape(this, frame, updateRect,
+                       base, BControlLook::B_LEFT_ARROW, 0, B_DARKEN_4_TINT);
+       }
+};
+
+
+class ScrollRightTabButton : public TabButton {
+public:
+       ScrollRightTabButton(BMessage* message)
+               : TabButton(message)
+       {
+       }
+
+       virtual void DrawSymbol(BRect frame, const BRect& updateRect,
+               const rgb_color& base)
+       {
+               be_control_look->DrawArrowShape(this, frame, updateRect,
+                       base, BControlLook::B_RIGHT_ARROW, 0, B_DARKEN_4_TINT);
+       }
+};
+
+
+class NewTabButton : public TabButton {
+public:
+       NewTabButton(BMessage* message)
+               : TabButton(message)
+       {
+               SetToolTip("New tab (Cmd-T)");
+       }
+
+       virtual BSize MinSize()
+       {
+               return BSize(18, 12);
+       }
+
+       virtual void DrawSymbol(BRect frame, const BRect& updateRect,
+               const rgb_color& base)
+       {
+               SetHighColor(tint_color(base, B_DARKEN_4_TINT));
+               float inset = 3;
+               frame.InsetBy(2, 2);
+               frame.top++;
+               frame.left++;
+               FillRoundRect(BRect(frame.left, frame.top + inset,
+                       frame.right, frame.bottom - inset), 1, 1);
+               FillRoundRect(BRect(frame.left + inset, frame.top,
+                       frame.right - inset, frame.bottom), 1, 1);
+       }
+};
+
+
+class TabMenuTabButton : public TabButton {
+public:
+       TabMenuTabButton(BMessage* message)
+               : TabButton(message)
+       {
+       }
+
+       virtual BSize MinSize()
+       {
+               return BSize(18, 12);
+       }
+
+       virtual void DrawSymbol(BRect frame, const BRect& updateRect,
+               const rgb_color& base)
+       {
+               be_control_look->DrawArrowShape(this, frame, updateRect,
+                       base, BControlLook::B_DOWN_ARROW, 0, B_DARKEN_4_TINT);
+       }
+};
+
+
+// #pragma mark - TabManager
+
+
+
+TabManager::TabManager(const BMessenger& target, BMessage* newTabMessage)
+    :
+    fController(new TabManagerController(this)),
+    fTarget(target)
+{
+       fContainerView = new BView("web view container", 0);
+       fCardLayout = new BCardLayout();
+       fContainerView->SetLayout(fCardLayout);
+
+       fTabContainerView = new TabContainerView(fController);
+       fTabContainerGroup = new BGroupView(B_HORIZONTAL);
+       fTabContainerGroup->GroupLayout()->SetInsets(0, 5, 0, 0);
+       fTabContainerGroup->GroupLayout()->AddView(fTabContainerView);
+//     fTabContainerGroup->GroupLayout()->AddView(new 
ScrollLeftTabButton(NULL), 0.0f);
+//     fTabContainerGroup->GroupLayout()->AddView(new 
ScrollRightTabButton(NULL), 0.0f);
+       NewTabButton* newTabButton = new NewTabButton(newTabMessage);
+       newTabButton->SetTarget(be_app);
+       fTabContainerGroup->GroupLayout()->AddView(newTabButton, 0.0f);
+//     fTabContainerGroup->GroupLayout()->AddView(new TabMenuTabButton(NULL), 
0.0f);
+}
+
+
+TabManager::~TabManager()
+{
+       delete fController;
+}
+
+
+void
+TabManager::SetTarget(const BMessenger& target)
+{
+    fTarget = target;
+}
+
+
+const BMessenger&
+TabManager::Target() const
+{
+    return fTarget;
+}
+
+
+BView*
+TabManager::TabGroup() const
+{
+       return fTabContainerGroup;
+}
+
+
+BView*
+TabManager::ContainerView() const
+{
+       return fContainerView;
+}
+
+
+BView*
+TabManager::ViewForTab(int32 tabIndex) const
+{
+       BLayoutItem* item = fCardLayout->ItemAt(tabIndex);
+       if (item != NULL)
+               return item->View();
+       return NULL;
+}
+
+
+void
+TabManager::SelectTab(int32 tabIndex)
+{
+       fCardLayout->SetVisibleItem(tabIndex);
+       fTabContainerView->SelectTab(tabIndex);
+
+    BMessage message(TAB_CHANGED);
+    message.AddInt32("tab index", tabIndex);
+    fTarget.SendMessage(&message);
+}
+
+
+void
+TabManager::SelectTab(BView* containedView)
+{
+       int32 count = fCardLayout->CountItems();
+       for (int32 i = 0; i < count; i++) {
+               BLayoutItem* item = fCardLayout->ItemAt(i);
+               if (item->View() == containedView) {
+                       SelectTab(i);
+                       break;
+               }
+       }
+}
+
+
+int32
+TabManager::SelectedTabIndex() const
+{
+       return fCardLayout->VisibleIndex();
+}
+
+
+void
+TabManager::CloseTab(int32 tabIndex)
+{
+    BMessage message(CLOSE_TAB);
+    message.AddInt32("tab index", tabIndex);
+    fTarget.SendMessage(&message);
+}
+
+
+void
+TabManager::AddTab(BView* view, const char* label, int32 index)
+{
+       fTabContainerView->AddTab(label, index);
+       fCardLayout->AddView(index, view);
+}
+
+
+BView*
+TabManager::RemoveTab(int32 index)
+{
+       // It's important to remove the view first, since
+       // removing the tab will preliminary mess with the selected tab
+       // and then item count of card layout and tab container will not
+       // match yet.
+       BLayoutItem* item = fCardLayout->RemoveItem(index);
+       if (item == NULL)
+               return NULL;
+
+       TabView* tab = fTabContainerView->RemoveTab(index);
+       delete tab;
+
+       BView* view = item->View();
+       delete item;
+       return view;
+}
+
+
+int32
+TabManager::CountTabs() const
+{
+       return fCardLayout->CountItems();
+}
+
+
+void
+TabManager::SetTabLabel(int32 tabIndex, const char* label)
+{
+       fTabContainerView->SetTabLabel(tabIndex, label);
+}
+
+
+void
+TabManager::SetCloseButtonsAvailable(bool available)
+{
+       if (available == fController->CloseButtonsAvailable())
+               return;
+       fController->SetCloseButtonsAvailable(available);
+       fTabContainerView->Invalidate();
+}
+

Copied: webkit/trunk/WebKit/haiku/WebPositive/WebTabView.h (from r237, 
webkit/trunk/WebKit/haiku/HaikuLauncher/WebTabView.h)
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ webkit/trunk/WebKit/haiku/WebPositive/WebTabView.h  Sat Feb 27 15:51:43 
2010        (r238, copy of r237, 
webkit/trunk/WebKit/haiku/HaikuLauncher/WebTabView.h)
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2010 Stephan Aßmus <superstippi@xxxxxx>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef TAB_MANAGER_H
+#define TAB_MANAGER_H
+
+#include <Messenger.h>
+#include <TabView.h>
+
+enum {
+    TAB_CHANGED = 'tcha',
+    CLOSE_TAB = 'cltb'
+};
+
+class BCardLayout;
+class BGroupView;
+class TabContainerView;
+class TabManagerController;
+
+class TabManager {
+public:
+                                                       TabManager(const 
BMessenger& target,
+                                                               BMessage* 
newTabMessage);
+       virtual                                         ~TabManager();
+
+                       void                            SetTarget(const 
BMessenger& target);
+                       const BMessenger&       Target() const;
+
+                       BView*                          TabGroup() const;
+                       BView*                          ContainerView() const;
+
+                       BView*                          ViewForTab(int32 
tabIndex) const;
+
+                       void                            SelectTab(int32 
tabIndex);
+                       void                            SelectTab(BView* 
containedView);
+                       int32                           SelectedTabIndex() 
const;
+                       void                            CloseTab(int32 
tabIndex);
+
+                       void                            AddTab(BView* view, 
const char* label,
+                                                                       int32 
index = -1);
+                       BView*                          RemoveTab(int32 index);
+                       int32                           CountTabs() const;
+
+                       void                            SetTabLabel(int32 
tabIndex, const char* label);
+                       void                            
SetCloseButtonsAvailable(bool available);
+
+private:
+                       BGroupView*                     fTabContainerGroup;
+                       TabContainerView*       fTabContainerView;
+                       BView*                          fContainerView;
+                       BCardLayout*            fCardLayout;
+                       TabManagerController* fController;
+
+                       BMessenger                      fTarget;
+};
+
+#endif // TAB_MANAGER_H

Other related posts:

  • » [haiku-webkit-commits] r238 - in webkit/trunk/WebKit: . haiku/HaikuLauncher haiku/WebPositive - webkit