* Reworked closing a page programatically. BWebPage no longer sends a plain

B_QUIT_REQUESTED, instead BWebWindow has a new hook and derived classes can
  implement it.
* Some refactoring in BrowserWindow to move code from MessageReceived into
  separate methods for easier debugging and cleaner code.

git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@378 94f232f2-1747-11df-bad5-a5bfde151594
This commit is contained in:
stippi 2010-04-03 12:47:12 +00:00 committed by Alexandre Deckner
parent f41f967668
commit ea8b6f3fd1
2 changed files with 38 additions and 15 deletions

View File

@ -650,20 +650,7 @@ printf(" file ok\n");
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();
}
_TabChanged(index);
break;
}
@ -876,6 +863,20 @@ BrowserWindow::NewPageCreated(BWebView* view)
}
void
BrowserWindow::CloseWindowRequested(BWebView* view)
{
int32 index = fTabManager->TabForView(view);
if (index < 0) {
// Tab is already gone.
return;
}
BMessage message(CLOSE_TAB);
message.AddInt32("tab index", index);
PostMessage(&message, this);
}
void
BrowserWindow::LoadNegotiating(const BString& url, BWebView* view)
{
@ -1122,7 +1123,7 @@ void
BrowserWindow::_UpdateTabGroupVisibility()
{
if (Lock()) {
//fTabGroup->SetVisible(fTabManager->CountTabs() > 1);
// fTabGroup->SetVisible(fTabManager->CountTabs() > 1);
fTabManager->SetCloseButtonsAvailable(fTabManager->CountTabs() > 1);
Unlock();
}
@ -1141,6 +1142,26 @@ BrowserWindow::_ShutdownTab(int32 index)
}
void
BrowserWindow::_TabChanged(int32 index)
{
BWebView* webView = dynamic_cast<BWebView*>(fTabManager->ViewForTab(index));
if (webView == CurrentWebView())
return;
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();
}
}
status_t
BrowserWindow::_BookmarkPath(BPath& path) const
{

View File

@ -87,6 +87,7 @@ private:
BWebView* view);
virtual void NewWindowRequested(const BString& url,
bool primaryAction);
virtual void CloseWindowRequested(BWebView* view);
virtual void NewPageCreated(BWebView* view);
virtual void LoadNegotiating(const BString& url,
BWebView* view);
@ -121,6 +122,7 @@ private:
void _UpdateTitle(const BString &title);
void _UpdateTabGroupVisibility();
void _ShutdownTab(int32 index);
void _TabChanged(int32 index);
status_t _BookmarkPath(BPath& path) const;
void _CreateBookmark();