* Small refactoring for retrieving the URL for a new tab.
* Load new files into the current tab, if the URL of that tab is either empty or the URL for new tabs, instead of always opening a new tab. git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@511 94f232f2-1747-11df-bad5-a5bfde151594
This commit is contained in:
committed by
Alexandre Deckner
parent
11365e77e8
commit
02a2ef1969
@@ -336,7 +336,10 @@ BrowserApp::_CreateNewPage(const BString& url, bool fullscreen)
|
|||||||
continue;
|
continue;
|
||||||
if (webWindow->Lock()) {
|
if (webWindow->Lock()) {
|
||||||
if (webWindow->Workspaces() & workspace) {
|
if (webWindow->Workspaces() & workspace) {
|
||||||
webWindow->CreateNewTab(url, true);
|
if (webWindow->IsBlankTab())
|
||||||
|
webWindow->CurrentWebView()->LoadURL(url);
|
||||||
|
else
|
||||||
|
webWindow->CreateNewTab(url, true);
|
||||||
webWindow->Activate();
|
webWindow->Activate();
|
||||||
loadedInWindowOnCurrentWorkspace = true;
|
loadedInWindowOnCurrentWorkspace = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -474,7 +474,10 @@ BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* appSettings,
|
|||||||
kSettingsKeyAutoHideInterfaceInFullscreenMode,
|
kSettingsKeyAutoHideInterfaceInFullscreenMode,
|
||||||
fAutoHideInterfaceInFullscreenMode));
|
fAutoHideInterfaceInFullscreenMode));
|
||||||
|
|
||||||
AddShortcut('F', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(EDIT_HIDE_FIND_GROUP));
|
AddShortcut('F', B_COMMAND_KEY | B_SHIFT_KEY,
|
||||||
|
new BMessage(EDIT_HIDE_FIND_GROUP));
|
||||||
|
// TODO: Should be a different shortcut, H is usually for Find selection.
|
||||||
|
AddShortcut('H', B_COMMAND_KEY, new BMessage(HOME));
|
||||||
|
|
||||||
// Add shortcuts to select a particular tab
|
// Add shortcuts to select a particular tab
|
||||||
for (int32 i = 1; i <= 9; i++) {
|
for (int32 i = 1; i <= 9; i++) {
|
||||||
@@ -993,6 +996,17 @@ BrowserWindow::SetCurrentWebView(BWebView* webView)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
BrowserWindow::IsBlankTab() const
|
||||||
|
{
|
||||||
|
if (CurrentWebView() == NULL)
|
||||||
|
return false;
|
||||||
|
BString requestedURL = CurrentWebView()->MainFrameRequestedURL();
|
||||||
|
return requestedURL.Length() == 0
|
||||||
|
|| requestedURL == _NewTabURL(fTabManager->CountTabs() == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BrowserWindow::CreateNewTab(const BString& _url, bool select, BWebView* webView)
|
BrowserWindow::CreateNewTab(const BString& _url, bool select, BWebView* webView)
|
||||||
{
|
{
|
||||||
@@ -1006,25 +1020,8 @@ BrowserWindow::CreateNewTab(const BString& _url, bool select, BWebView* webView)
|
|||||||
fTabManager->AddTab(webView, "New tab");
|
fTabManager->AddTab(webView, "New tab");
|
||||||
|
|
||||||
BString url(_url);
|
BString url(_url);
|
||||||
if (applyNewPagePolicy && url.Length() == 0) {
|
if (applyNewPagePolicy && url.Length() == 0)
|
||||||
uint32 policy = isNewWindow ? fNewWindowPolicy : fNewTabPolicy;
|
url = _NewTabURL(isNewWindow);
|
||||||
// Implement new page policy
|
|
||||||
switch (policy) {
|
|
||||||
case OpenStartPage:
|
|
||||||
url = fStartPageURL;
|
|
||||||
break;
|
|
||||||
case OpenSearchPage:
|
|
||||||
url = fSearchPageURL;
|
|
||||||
break;
|
|
||||||
case CloneCurrentPage:
|
|
||||||
if (CurrentWebView() != NULL)
|
|
||||||
url = CurrentWebView()->MainFrameURL();
|
|
||||||
break;
|
|
||||||
case OpenBlankPage:
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (url.Length() > 0)
|
if (url.Length() > 0)
|
||||||
webView->LoadURL(url.String());
|
webView->LoadURL(url.String());
|
||||||
@@ -1980,3 +1977,27 @@ BrowserWindow::_ShowInterface(bool show)
|
|||||||
fLoadingProgressBar->Hide();
|
fLoadingProgressBar->Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BString
|
||||||
|
BrowserWindow::_NewTabURL(bool isNewWindow) const
|
||||||
|
{
|
||||||
|
BString url;
|
||||||
|
uint32 policy = isNewWindow ? fNewWindowPolicy : fNewTabPolicy;
|
||||||
|
// Implement new page policy
|
||||||
|
switch (policy) {
|
||||||
|
case OpenStartPage:
|
||||||
|
url = fStartPageURL;
|
||||||
|
break;
|
||||||
|
case OpenSearchPage:
|
||||||
|
url = fSearchPageURL;
|
||||||
|
break;
|
||||||
|
case CloneCurrentPage:
|
||||||
|
if (CurrentWebView() != NULL)
|
||||||
|
url = CurrentWebView()->MainFrameURL();
|
||||||
|
break;
|
||||||
|
case OpenBlankPage:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ public:
|
|||||||
|
|
||||||
virtual void SetCurrentWebView(BWebView* view);
|
virtual void SetCurrentWebView(BWebView* view);
|
||||||
|
|
||||||
|
bool IsBlankTab() const;
|
||||||
void CreateNewTab(const BString& url, bool select,
|
void CreateNewTab(const BString& url, bool select,
|
||||||
BWebView* webView = 0);
|
BWebView* webView = 0);
|
||||||
|
|
||||||
@@ -187,6 +188,8 @@ private:
|
|||||||
void _CheckAutoHideInterface();
|
void _CheckAutoHideInterface();
|
||||||
void _ShowInterface(bool show);
|
void _ShowInterface(bool show);
|
||||||
|
|
||||||
|
BString _NewTabURL(bool isNewWindow) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BMenu* fHistoryMenu;
|
BMenu* fHistoryMenu;
|
||||||
int32 fHistoryMenuFixedItemCount;
|
int32 fHistoryMenuFixedItemCount;
|
||||||
|
|||||||
Reference in New Issue
Block a user