Skip to content
Permalink
Browse files

Redesign Minibrowser

1) Put widgets in window thread
2) webkit events on main thread
  • Loading branch information...
RAJAGOPALAN-GANGADHARAN authored and pulkomandy committed Jul 1, 2019
1 parent 6a0afd5 commit adb7b269ca6aa2a6b9420e69c79cda32315b82a7
@@ -261,7 +261,6 @@ void NetworkDataTaskHaiku::HeadersReceived(BUrlRequest* caller, const BUrlResult
ResourceRequest request = m_currentRequest;
ResourceResponse responseCopy = response;
request.setURL(url);
fprintf(stderr,"((((((( redirecting to %s)))))))\n",request.url().string().utf8().data());
m_client->willPerformHTTPRedirection(WTFMove(responseCopy),WTFMove(request), [this](const ResourceRequest& newRequest){

if(newRequest.isNull() || m_state == State::Canceling)
@@ -324,7 +323,6 @@ void NetworkDataTaskHaiku::RequestCompleted(BUrlRequest* caller, bool success)
}
bool NetworkDataTaskHaiku::CertificateVerificationFailed(BUrlRequest* caller, BCertificate& certificate, const char* message)
{

}
void NetworkDataTaskHaiku::DebugMessage(BUrlRequest* caller,BUrlProtocolDebugMessage type,const char* text)
{
@@ -31,6 +31,7 @@
#include <WebCore/ResourceResponse.h>
#include <WebCore/ResourceRequest.h>
#include <WebCore/NetworkLoadMetrics.h>
#include <WebCore/HaikuFormDataStream.h>

#include <UrlProtocolAsynchronousListener.h>
#include <Referenceable.h>
@@ -39,8 +40,8 @@
namespace WebKit {
using namespace WebCore;

class NetworkDataTaskHaiku final : public NetworkDataTask
,public BUrlProtocolAsynchronousListener
class NetworkDataTaskHaiku final : public NetworkDataTask,
public BUrlProtocolAsynchronousListener
{
public:
static Ref<NetworkDataTask> create(NetworkSession& session, NetworkDataTaskClient& client, const WebCore::ResourceRequest& request, WebCore::StoredCredentialsPolicy storedCredentialsPolicy, WebCore::ContentSniffingPolicy shouldContentSniff, WebCore::ContentEncodingSniffingPolicy shouldContentEncodingSniff,
@@ -81,7 +82,7 @@ class NetworkDataTaskHaiku final : public NetworkDataTask
URL m_baseUrl;
bool m_responseDataSent;
bool m_redirected;
off_t m_position;
off_t m_position;

int m_redirectionTries;
};
@@ -34,7 +34,10 @@ namespace WebKit{
class PageLoadStateObserver final :public PageLoadState::Observer
{
public:
PageLoadStateObserver(){}
PageLoadStateObserver(BLooper* looper)
:m_looper(looper)
{
}
void willChangeIsLoading() override{}
void didChangeIsLoading() override{}

@@ -44,7 +47,7 @@ class PageLoadStateObserver final :public PageLoadState::Observer
void didChangeTitle() override
{
BMessage message(DID_CHANGE_TITLE);
be_app->PostMessage(&message);
m_looper->PostMessage(&message);
}

void willChangeActiveURL() override{}
@@ -59,7 +62,7 @@ class PageLoadStateObserver final :public PageLoadState::Observer
void didChangeEstimatedProgress() override
{
BMessage message(DID_CHANGE_PROGRESS);
be_app->PostMessage(&message);
m_looper->PostMessage(&message);
}

void willChangeCanGoBack() override{}
@@ -78,6 +81,8 @@ class PageLoadStateObserver final :public PageLoadState::Observer
void didChangeWebProcessIsResponsive() override{}

void didSwapWebProcesses() override{}
private:
BLooper* m_looper;
};
}

@@ -44,9 +44,8 @@
#include "WebViewConstants.h"

BWebView::BWebView(BRect frame,BWindow* myWindow)
:fAppLooper(NULL)
{
initializeOnce();
//webkit stuff
auto config = adoptWK(WKPageConfigurationCreate());
auto prefs = WKPreferencesCreate();

@@ -58,17 +57,17 @@ BWebView::BWebView(BRect frame,BWindow* myWindow)
WKPageConfigurationSetContext(config.get(),fContext.get());


fViewPort=adoptWK(WKViewCreate("Webkit",frame,myWindow,config.get()));

fViewPort = adoptWK(WKViewCreate("Webkit",frame,myWindow,config.get()));
fAppLooper = myWindow->Looper();
}

void BWebView::navigationCallbacks(BWebView* app)
void BWebView::navigationCallbacks()
{
auto page = WKViewGetPage( fViewPort.get());
WKPageNavigationClientV0 navigationClient={};

navigationClient.base.version = 0;
navigationClient.base.clientInfo = app;
navigationClient.base.clientInfo = this;

navigationClient.didCommitNavigation = didCommitNavigation;
navigationClient.didFinishDocumentLoad = didFinishDocumentLoad;
@@ -77,8 +76,8 @@ void BWebView::navigationCallbacks(BWebView* app)
navigationClient.didReceiveServerRedirectForProvisionalNavigation = didReceiveServerRedirectForProvisionalNavigation;
WKPageSetPageNavigationClient(page,&navigationClient.base);

observer = new PageLoadStateObserver();
getRenderView()->page()->pageLoadState().addObserver(*observer);
fObserver = new PageLoadStateObserver(fAppLooper);
getRenderView()->page()->pageLoadState().addObserver(*fObserver);

}
void BWebView::initializeOnce()
@@ -97,8 +96,17 @@ void BWebView::loadHTML()

}

void BWebView::loadURI(const char* uri)
void BWebView::loadURIRequest(const char* uri)
{
BMessage message(URL_LOAD_HANDLE);
message.AddString("url",uri);
be_app->PostMessage(&message);
}

void BWebView::loadURI(BMessage* message)
{
const char* uri;
message->FindString("url",&uri);
auto page = WKViewGetPage( fViewPort.get());
WKRetainPtr<WKURLRef> wuri;
wuri = adoptWK(WKURLCreateWithUTF8CString(uri));
@@ -110,15 +118,15 @@ void BWebView::goForward()
WKPageGoForward(page);
BMessage message(URL_CHANGE);
message.AddString("url",BString(getCurrentURL()));
be_app->PostMessage(&message);
fAppLooper->PostMessage(&message);
}
void BWebView::goBackward()
{
auto page = WKViewGetPage(fViewPort.get());
WKPageGoBack(page);
BMessage message(URL_CHANGE);
message.AddString("url",BString(getCurrentURL()));
be_app->PostMessage(&message);
fAppLooper->PostMessage(&message);
}
void BWebView::stop()
{
@@ -127,23 +135,26 @@ void BWebView::stop()
}
void BWebView::didCommitNavigation(WKPageRef page, WKNavigationRef navigation, WKTypeRef userData, const void* clientInfo)
{
BLooper* looper = ((BWebView*)clientInfo)->getAppLooper();
BMessage message(DID_COMMIT_NAVIGATION);
be_app->PostMessage(&message);
looper->PostMessage(&message);
}
void BWebView::didReceiveServerRedirectForProvisionalNavigation(WKPageRef page, WKNavigationRef navigation, WKTypeRef userData, const void* clientInfo)
{
BLooper* looper = ((BWebView*)clientInfo)->getAppLooper();
BMessage message(URL_CHANGE);
message.AddString("url",BString(((BWebView*)clientInfo)->getCurrentURL()));
be_app->PostMessage(&message);
looper->PostMessage(&message);
}
void BWebView::didFinishDocumentLoad(WKPageRef page, WKNavigationRef navigation, WKTypeRef userData, const void* clientInfo)
{
fprintf(stderr,"\n %s %s\n",__PRETTY_FUNCTION__);
}
void BWebView::didFinishNavigation(WKPageRef page, WKNavigationRef navigation, WKTypeRef userData,const void* clientInfo)
{
BLooper* looper = ((BWebView*)clientInfo)->getAppLooper();
BMessage message(DID_FINISH_NAVIGATION);
be_app->PostMessage(&message);
looper->PostMessage(&message);
}

void BWebView::didFailNavigation(WKPageRef page, WKNavigationRef navigation,WKErrorRef, WKTypeRef userData,const void* clientInfo)
@@ -39,16 +39,19 @@ class BWebView
BWebView(BRect,BWindow*);
void initializeOnce();
void loadHTML();
void loadURI(const char*);
void loadURIRequest(const char*);//use this in app to load a url
void loadURI(BMessage*);
void goForward();
void goBackward();
void stop();
WebViewBase* getRenderView() { return toImpl(fViewPort.get()); }
const char* getCurrentURL() { return getRenderView()->currentURL(); }
BLooper* getAppLooper() { return fAppLooper; }

void navigationCallbacks(BWebView* app);
void navigationCallbacks();
double didChangeProgress();
const char* title();

private:
WKRetainPtr<WKViewRef> fViewPort;
WKRetainPtr<WKContextRef> fContext;
@@ -58,7 +61,8 @@ class BWebView
static void didFinishProgress(WKPageRef,const void*);
static void didFinishNavigation(WKPageRef page, WKNavigationRef navigation, WKTypeRef userData,const void* clientInfo);
static void didFailNavigation(WKPageRef page, WKNavigationRef navigation, WKErrorRef,WKTypeRef userData,const void* clientInfo);
PageLoadStateObserver* observer;
PageLoadStateObserver* fObserver;
BLooper* fAppLooper;
};


@@ -30,7 +30,8 @@ enum{
DID_FINISH_NAVIGATION = 'dfna',
URL_CHANGE = 'urlc',
DID_CHANGE_PROGRESS = 'dcpr',
DID_CHANGE_TITLE = 'dctt'
DID_CHANGE_TITLE = 'dctt',
URL_LOAD_HANDLE = 'urlh'
};

#endif // _H

0 comments on commit adb7b26

Please sign in to comment.
You can’t perform that action at this time.