Remember the current URL input contents and selection when switching away from
a tab, and restore them when switching back. git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@498 94f232f2-1747-11df-bad5-a5bfde151594
This commit is contained in:
parent
208ecbcad5
commit
0e42079313
@ -148,7 +148,9 @@ public:
|
|||||||
PageUserData(BView* focusedView)
|
PageUserData(BView* focusedView)
|
||||||
:
|
:
|
||||||
fFocusedView(focusedView),
|
fFocusedView(focusedView),
|
||||||
fPageIcon(NULL)
|
fPageIcon(NULL),
|
||||||
|
fURLInputSelectionStart(-1),
|
||||||
|
fURLInputSelectionEnd(-1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,9 +183,38 @@ public:
|
|||||||
return fPageIcon;
|
return fPageIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetURLInputContents(const char* text)
|
||||||
|
{
|
||||||
|
fURLInputContents = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* URLInputContents() const
|
||||||
|
{
|
||||||
|
return fURLInputContents.String();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetURLInputSelection(int32 selectionStart, int32 selectionEnd)
|
||||||
|
{
|
||||||
|
fURLInputSelectionStart = selectionStart;
|
||||||
|
fURLInputSelectionEnd = selectionEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 URLInputSelectionStart() const
|
||||||
|
{
|
||||||
|
return fURLInputSelectionStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 URLInputSelectionEnd() const
|
||||||
|
{
|
||||||
|
return fURLInputSelectionEnd;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BView* fFocusedView;
|
BView* fFocusedView;
|
||||||
BBitmap* fPageIcon;
|
BBitmap* fPageIcon;
|
||||||
|
BString fURLInputContents;
|
||||||
|
int32 fURLInputSelectionStart;
|
||||||
|
int32 fURLInputSelectionEnd;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -883,10 +914,17 @@ BrowserWindow::SetCurrentWebView(BWebView* webView)
|
|||||||
// later.
|
// later.
|
||||||
PageUserData* userData = static_cast<PageUserData*>(
|
PageUserData* userData = static_cast<PageUserData*>(
|
||||||
CurrentWebView()->GetUserData());
|
CurrentWebView()->GetUserData());
|
||||||
if (userData)
|
if (userData == NULL) {
|
||||||
userData->SetFocusedView(CurrentFocus());
|
userData = new PageUserData(CurrentFocus());
|
||||||
else
|
CurrentWebView()->SetUserData(userData);
|
||||||
CurrentWebView()->SetUserData(new PageUserData(CurrentFocus()));
|
}
|
||||||
|
userData->SetFocusedView(CurrentFocus());
|
||||||
|
userData->SetURLInputContents(fURLInputGroup->Text());
|
||||||
|
int32 selectionStart;
|
||||||
|
int32 selectionEnd;
|
||||||
|
fURLInputGroup->TextView()->GetSelection(&selectionStart,
|
||||||
|
&selectionEnd);
|
||||||
|
userData->SetURLInputSelection(selectionStart, selectionEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
BWebWindow::SetCurrentWebView(webView);
|
BWebWindow::SetCurrentWebView(webView);
|
||||||
@ -900,10 +938,8 @@ BrowserWindow::SetCurrentWebView(BWebView* webView)
|
|||||||
PageUserData* userData = static_cast<PageUserData*>(
|
PageUserData* userData = static_cast<PageUserData*>(
|
||||||
webView->GetUserData());
|
webView->GetUserData());
|
||||||
BView* focusedView = NULL;
|
BView* focusedView = NULL;
|
||||||
if (userData != NULL) {
|
if (userData != NULL)
|
||||||
focusedView = userData->FocusedView();
|
focusedView = userData->FocusedView();
|
||||||
fURLInputGroup->SetPageIcon(userData->PageIcon());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (focusedView != NULL
|
if (focusedView != NULL
|
||||||
&& viewIsChild(GetLayout()->View(), focusedView)) {
|
&& viewIsChild(GetLayout()->View(), focusedView)) {
|
||||||
@ -911,7 +947,19 @@ BrowserWindow::SetCurrentWebView(BWebView* webView)
|
|||||||
} else
|
} else
|
||||||
webView->MakeFocus(true);
|
webView->MakeFocus(true);
|
||||||
|
|
||||||
fURLInputGroup->SetText(webView->MainFrameURL());
|
if (userData != NULL) {
|
||||||
|
fURLInputGroup->SetPageIcon(userData->PageIcon());
|
||||||
|
fURLInputGroup->SetText(userData->URLInputContents());
|
||||||
|
if (userData->URLInputSelectionStart() >= 0) {
|
||||||
|
fURLInputGroup->TextView()->Select(
|
||||||
|
userData->URLInputSelectionStart(),
|
||||||
|
userData->URLInputSelectionEnd());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fURLInputGroup->SetPageIcon(NULL);
|
||||||
|
fURLInputGroup->SetText(webView->MainFrameURL());
|
||||||
|
}
|
||||||
|
|
||||||
// Trigger update of the interface to the new page, by requesting
|
// Trigger update of the interface to the new page, by requesting
|
||||||
// to resend all notifications.
|
// to resend all notifications.
|
||||||
webView->WebPage()->ResendNotifications();
|
webView->WebPage()->ResendNotifications();
|
||||||
|
Loading…
Reference in New Issue
Block a user