Skip to content

Commit

Permalink
Send updated value along with DID_CHANGE messages
Browse files Browse the repository at this point in the history
Haiku's API usually includes relevant information along with the
messages it sends, so we may as well too.
  • Loading branch information
Zardshard authored and pulkomandy committed Aug 5, 2024
1 parent 2477e9f commit 7fe2fc3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
9 changes: 8 additions & 1 deletion Source/WebKit/UIProcess/API/haiku/PageLoadStateObserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ namespace WebKit {
class PageLoadStateObserver final: public PageLoadState::Observer {
WTF_MAKE_FAST_ALLOCATED;
public:
PageLoadStateObserver(BLooper* looper) {}
PageLoadStateObserver(BWebView* webView, BLooper* looper)
: webView(webView)
{}

void willChangeIsLoading() override {}
void didChangeIsLoading() override {}
Expand All @@ -46,6 +48,7 @@ class PageLoadStateObserver final: public PageLoadState::Observer {
void didChangeTitle() override
{
BMessage message(DID_CHANGE_TITLE);
message.AddString("title", webView->title());
be_app->PostMessage(&message);
}

Expand All @@ -61,6 +64,7 @@ class PageLoadStateObserver final: public PageLoadState::Observer {
void didChangeEstimatedProgress() override
{
BMessage message(DID_CHANGE_PROGRESS);
message.AddDouble("progress", webView->progress());
be_app->PostMessage(&message);
}

Expand All @@ -80,6 +84,9 @@ class PageLoadStateObserver final: public PageLoadState::Observer {
void didChangeWebProcessIsResponsive() override {}

void didSwapWebProcesses() override{}

private:
BWebView* webView;
};

}
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/UIProcess/API/haiku/WebView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void BWebView::navigationCallbacks()
{
fWebViewBase->page()->setNavigationClient(makeUniqueRef<NavigationClient>(this));

fObserver = makeUnique<PageLoadStateObserver>(fAppLooper);
fObserver = makeUnique<PageLoadStateObserver>(this, fAppLooper);
fWebViewBase->page()->pageLoadState().addObserver(*fObserver);
}

Expand Down
18 changes: 11 additions & 7 deletions Tools/MiniBrowser/haiku/BrowserWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,21 @@ void BrowserWindow::MessageReceived(BMessage* message)
break;

case URL_CHANGE:
ChangeUrl(message);
const char* url;
message->FindString("url",&url);
ChangeUrl(url);
break;

case DID_CHANGE_PROGRESS:
LoadingProgress(fWebView->progress());
double progress;
message->FindDouble("progress", &progress);
LoadingProgress(progress);
break;

case DID_CHANGE_TITLE:
ChangeTitle(fWebView->title());
const char* title;
message->FindString("title", &title);
ChangeTitle(title);
break;

case STOP:
Expand All @@ -194,11 +200,9 @@ void BrowserWindow::SetStatus(const char* str)
m_statusText->SetText(str);
}

void BrowserWindow::ChangeUrl(BMessage* message)
void BrowserWindow::ChangeUrl(const char* url)
{
BString str;
message->FindString("url",&str);
m_url->SetText(str.String());
m_url->SetText(url);
}

void BrowserWindow::LoadingProgress(double value)
Expand Down
2 changes: 1 addition & 1 deletion Tools/MiniBrowser/haiku/BrowserWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class BrowserWindow:public BWindow
void Construct(BWebView*);
private:
void SetStatus(const char*);
void ChangeUrl(BMessage*);
void ChangeUrl(const char*);
void LoadingProgress(double value);
void ChangeTitle(const char* title);

Expand Down

0 comments on commit 7fe2fc3

Please sign in to comment.