Middle clicking links will open new tabs, but will not select them. Matches

Firefox behavior.


git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@161 94f232f2-1747-11df-bad5-a5bfde151594
This commit is contained in:
stippi
2010-02-21 13:20:57 +00:00
parent 56bdbcc74e
commit 63d76ab872
4 changed files with 25 additions and 17 deletions
+5 -6
View File
@@ -171,7 +171,9 @@ void LauncherApp::MessageReceived(BMessage* message)
break; break;
BString url; BString url;
message->FindString("url", &url); message->FindString("url", &url);
newTab(window, url); bool select = false;
message->FindBool("select", &select);
newTab(window, url, select);
break; break;
} }
case WINDOW_OPENED: case WINDOW_OPENED:
@@ -279,15 +281,12 @@ void LauncherApp::newWindow(const BString& url)
window->currentWebView()->loadRequest(url.String()); window->currentWebView()->loadRequest(url.String());
} }
void LauncherApp::newTab(LauncherWindow* window, const BString& url) void LauncherApp::newTab(LauncherWindow* window, const BString& url, bool select)
{ {
if (!window->Lock()) if (!window->Lock())
return; return;
window->newTab(); window->newTab(url, select);
window->Unlock(); window->Unlock();
if (url.Length())
window->currentWebView()->loadRequest(url.String());
} }
// #pragma mark - // #pragma mark -
+1 -1
View File
@@ -51,7 +51,7 @@ public:
private: private:
bool openSettingsFile(BFile& file, uint32 mode); bool openSettingsFile(BFile& file, uint32 mode);
void newWindow(const BString& url); void newWindow(const BString& url);
void newTab(LauncherWindow* window, const BString& url); void newTab(LauncherWindow* window, const BString& url, bool select);
int m_windowCount; int m_windowCount;
BRect m_lastWindowFrame; BRect m_lastWindowFrame;
+18 -9
View File
@@ -226,7 +226,7 @@ LauncherWindow::LauncherWindow(BRect frame, const BMessenger& downloadListener,
); );
} }
newTab(); newTab("", true);
currentWebView()->webPage()->SetDownloadListener(downloadListener); currentWebView()->webPage()->SetDownloadListener(downloadListener);
m_findGroup->SetVisible(false); m_findGroup->SetVisible(false);
@@ -406,17 +406,23 @@ void LauncherWindow::MenusBeginning()
history->Unlock(); history->Unlock();
} }
void LauncherWindow::newTab() void LauncherWindow::newTab(const BString& url, bool select)
{ {
// Executed in app thread (new BWebPage needs to be created in app thread). // Executed in app thread (new BWebPage needs to be created in app thread).
WebView* webView = new WebView("web_view"); WebView* webView = new WebView("web_view");
m_tabView->AddTab(webView); m_tabView->AddTab(webView);
m_tabView->TabAt(m_tabView->CountTabs() - 1)->SetLabel("New tab"); m_tabView->TabAt(m_tabView->CountTabs() - 1)->SetLabel("New tab");
m_tabView->Select(m_tabView->CountTabs() - 1);
setCurrentWebView(webView); if (url.Length())
navigationCapabilitiesChanged(false, false, false, webView); webView->loadRequest(url.String());
if (m_url)
m_url->MakeFocus(true); if (select) {
m_tabView->Select(m_tabView->CountTabs() - 1);
setCurrentWebView(webView);
navigationCapabilitiesChanged(false, false, false, webView);
if (m_url)
m_url->MakeFocus(true);
}
} }
// #pragma mark - Notification API // #pragma mark - Notification API
@@ -434,9 +440,12 @@ void LauncherWindow::newWindowRequested(const BString& url)
// Always open new windows in the application thread, since // Always open new windows in the application thread, since
// creating a WebView will try to grab the application lock. // creating a WebView will try to grab the application lock.
// But our own WebPage may already try to lock us from within // But our own WebPage may already try to lock us from within
// the application thread -> dead-lock. // the application thread -> dead-lock. Thus we can't wait for
BMessage message(NEW_WINDOW); // a reply here.
BMessage message(NEW_TAB);
message.AddPointer("window", this);
message.AddString("url", url); message.AddString("url", url);
message.AddBool("select", false);
be_app->PostMessage(&message); be_app->PostMessage(&message);
} }
+1 -1
View File
@@ -67,7 +67,7 @@ public:
virtual bool QuitRequested(); virtual bool QuitRequested();
virtual void MenusBeginning(); virtual void MenusBeginning();
void newTab(); void newTab(const BString& url, bool select);
private: private:
// WebPage notification API implementations // WebPage notification API implementations