Skip to content
Permalink
Browse files

Added message handler to main run loop and made changes to webview st…

…ructure
  • Loading branch information...
RAJAGOPALAN-GANGADHARAN authored and pulkomandy committed May 2, 2019
1 parent 4e6627e commit 1d893a848557302876edb7a5cea8c4df512edcfc
@@ -97,12 +97,14 @@ void RunLoop::run()
} else if (looper != be_app) {
fprintf(stderr, "Add handler to existing RunLoop looper\n");
}

looper->LockLooper();
looper->AddHandler(current().m_handler);
looper->UnlockLooper();

if (newLooper)
looper->Loop();

}

void RunLoop::stop()
@@ -115,8 +117,7 @@ void RunLoop::stop()

void RunLoop::wakeUp()
{
RunLoop::current().performWork();
//m_handler->Looper()->PostMessage('loop', m_handler);
m_handler->Looper()->PostMessage('loop', m_handler);
}

RunLoop::TimerBase::TimerBase(RunLoop& runLoop)
@@ -42,6 +42,7 @@ list(APPEND WebKit_SOURCES
UIProcess/haiku/WebPageProxyHaiku.cpp
UIProcess/haiku/WebPreferencesHaiku.cpp
UIProcess/haiku/WebProcessPoolHaiku.cpp
UIProcess/API/haiku/WebViewBase.cpp
UIProcess/API/haiku/WebView.cpp
UIProcess/API/haiku/PageClientImplHaiku.cpp

@@ -56,7 +56,7 @@ int AuxiliaryProcessMain(int argc, char** argv)

if (!auxiliaryMain.platformInitialize())
return EXIT_FAILURE;

InitializeWebKit2();

if (!auxiliaryMain.parseCommandLine(argc, argv))
@@ -26,11 +26,11 @@

namespace WebKit {

class BWebView;
class WebViewBase;
//class WebPopupItemHaiku;
//class WebPopupMenuListenerHaiku;

WK_ADD_API_MAPPING(WKViewRef, BWebView)
WK_ADD_API_MAPPING(WKViewRef, WebViewBase)
//WK_ADD_API_MAPPING(WKPopupItemRef, WebPopupItemHaiku)
//WK_ADD_API_MAPPING(WKPopupMenuListenerRef, WebPopupMenuListenerHaiku)

@@ -22,18 +22,18 @@
#include "config.h"
#include "WKView.h"

#include "WebView.h"

#include "APIPageConfiguration.h"
#include "WKAPICast.h"

#include "WebViewBase.h"
using namespace WebCore;
using namespace WebKit;

WKViewRef WKViewCreate(const char* name,BRect rect,BWindow* parentWindow,
WKPageConfigurationRef pageRef)
{
fprintf(stderr,"\n create page");
return toAPI(BWebView::create(name,rect,parentWindow,*toImpl(pageRef)).leakRef());
return toAPI(WebViewBase::create(name,rect,parentWindow,*toImpl(pageRef)).leakRef());
}
WKPageRef WKViewGetPage(WKViewRef viewRef)
{
@@ -25,15 +25,16 @@
#include "config.h"

#include "PageClientImplHaiku.h"

#include "DrawingAreaProxyCoordinatedGraphics.h"
#include "WebProcessProxy.h"
#include "DrawingAreaProxyImpl.h"
#include "WebView.h"
#include "WebViewBase.h"

namespace WebKit
{
using namespace WebCore;

PageClientImpl::PageClientImpl(BWebView& view)
PageClientImpl::PageClientImpl(WebViewBase& view)
:fWebView(view)
{
//fprintf(stderr,"page client called");
@@ -42,15 +43,15 @@ namespace WebKit
WebProcessProxy& process)
{
//fprintf(stderr,"called drawing area");
return std::make_unique<DrawingAreaProxyImpl>(*fWebView.page(),process);
return std::make_unique<DrawingAreaProxyCoordinatedGraphics>(*fWebView.page(),process);
}
void PageClientImpl::setViewNeedsDisplay(const WebCore::Region& region)
{
fprintf(stderr,"printing");
//fWebView.setViewNeedsDisplay(region);
}

void PageClientImpl::requestScroll(const WebCore::FloatPoint&, const WebCore::IntPoint&, bool)
void PageClientImpl::requestScroll(const WebCore::FloatPoint&, const WebCore::IntPoint&)
{
notImplemented();
}
@@ -66,27 +67,32 @@ namespace WebKit
notImplemented();
/*if (fWebView.drawingArea())
return fWebView.drawingArea()->size();
return IntSize();*/
*/
return IntSize();
}

bool PageClientImpl::isViewWindowActive()
{
//return fWebView.isWindowActive();
return false;
}

bool PageClientImpl::isViewFocused()
{
//return fWebView.isFocused();
return false;
}

bool PageClientImpl::isViewVisible()
{
//return fWebView.isVisible();
return false;
}

bool PageClientImpl::isViewInWindow()
{
//return fWebView.isInWindow();
return false;
}

void PageClientImpl::PageClientImpl::processDidExit()
@@ -219,7 +225,7 @@ namespace WebKit
notImplemented();
}

void PageClientImpl::handleDownloadRequest(DownloadProxy* download)
void PageClientImpl::handleDownloadRequest(DownloadProxy& download)
{
notImplemented();
}
@@ -27,21 +27,23 @@
#include "PageClient.h"
#include "WebPageProxy.h"
#include "DefaultUndoController.h"
#include "IntPoint.h"
#include "IntRect.h"

namespace WebKit
{
class BWebView;
class WebViewBase;
class DrawingAreaProxy;
class PageClientImpl: public PageClient
{
public:
PageClientImpl(BWebView&);
PageClientImpl(WebViewBase&);
BView* viewWidget();
private:
//page client def's
std::unique_ptr<DrawingAreaProxy> createDrawingAreaProxy(WebProcessProxy&) override;
void setViewNeedsDisplay(const WebCore::Region&) override;
void requestScroll(const WebCore::FloatPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin, bool isProgrammaticScroll) override;
void requestScroll(const WebCore::FloatPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin) override;
WebCore::FloatPoint viewScrollPosition() override;
WebCore::IntSize viewSize() override;
bool isViewWindowActive() override;
@@ -77,7 +79,7 @@ namespace WebKit
void exitAcceleratedCompositingMode() override;
void updateAcceleratedCompositingMode(const LayerTreeContext&) override;

void handleDownloadRequest(DownloadProxy*) override;
void handleDownloadRequest(DownloadProxy&) override;
void didChangeContentSize(const WebCore::IntSize&) override;
void didCommitLoadForMainFrame(const String& mimeType, bool useCustomContentProvider) override;
void didFailLoadForMainFrame() override { }
@@ -109,12 +111,16 @@ namespace WebKit
WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override { return WebCore::UserInterfaceLayoutDirection::LTR; }

void didFinishProcessingAllPendingMouseEvents() final { }

WebCore::IntPoint accessibilityScreenToRootView(const WebCore::IntPoint& point) final { return point; }
WebCore::IntRect rootViewToAccessibilityScreen(const WebCore::IntRect& rect) final { return rect; }
void requestDOMPasteAccess(const WebCore::IntRect& elementRect, const String& originIdentifier, CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&&) final {}

private:
DefaultUndoController fUndoController;

//haiku def
BWebView& fWebView;
WebViewBase& fWebView;
};


@@ -22,79 +22,56 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "WebView.h"
#include "APIPageConfiguration.h"
#include "WebProcessPool.h"
#include "WebPageGroup.h"
#include "DrawingAreaProxyImpl.h"
#include <WebCore/IntRect.h>

using namespace WebKit;
using namespace WebCore;
BWebView::BWebView(const char*name,BRect rect,BWindow* parentWindow,
const API::PageConfiguration& pageConfig)
:BView(name,B_WILL_DRAW),
fViewPort(new BView(name,B_WILL_DRAW)),
fPageClient(std::make_unique<PageClientImpl>(*this))
{
fprintf(stderr,"Init");
parentWindow->AddChild(fViewPort);
auto config = pageConfig.copy();
auto* preferences = config->preferences();

if(!preferences && config->pageGroup())
{
fprintf(stderr,"config");
preferences = &config->pageGroup()->preferences();
config->setPreferences(preferences);
}
if(preferences)
{
preferences->setAcceleratedCompositingEnabled(false);
}

WebProcessPool* processPool = config->processPool();
fPage = processPool->createWebPage(*fPageClient,WTFMove(config));
fPage->initializeWebPage();

if(fPage->drawingArea())
{
fprintf(stderr,"drawing available");
fPage->drawingArea()->setSize(IntSize(rect.right - rect.left,
rect.top - rect.bottom));
}
BRect p(0,0,10,20);
paint(WebCore::IntRect(p));
}
#include <Window.h>
#include <View.h>

static void drawPageBackground(const WebPageProxy* page,const BRect& rect)
{
if(!page->drawsBackground())
return;


}


void BWebView::paint(const IntRect& dirtyRect)
#include "WKPageConfigurationRef.h"
#include "WKPage.h"
#include "WKView.h"
#include "WKURL.h"
#include "WKString.h"
#include "WKContext.h"
#include "WKPreferencesRef.h"

#include "wtf/RunLoop.h"

#include "WebView.h"
namespace WebKit
{
if(dirtyRect.isEmpty())
WebView::WebView(BRect frame,BWindow* myWindow)
{
fprintf(stderr,"its empty\n");
return;
initializeOnce();
//webkit stuff
auto config = adoptWK(WKPageConfigurationCreate());
auto prefs = WKPreferencesCreate();


WKPreferencesSetDeveloperExtrasEnabled(prefs, true);
WKPageConfigurationSetPreferences(config.get(),prefs);

fContext = adoptWK(WKContextCreateWithConfiguration(nullptr));
//fprintf(stderr,"here");
WKPageConfigurationSetContext(config.get(),fContext.get());

fViewPort=adoptWK(WKViewCreate("Webkit",frame,myWindow,config.get()));
//
}
fPage->endPrinting();
if(DrawingAreaProxyImpl* drawingArea = static_cast <DrawingAreaProxyImpl*>(fPage->drawingArea()))
void WebView::initializeOnce()
{
fprintf(stderr,"its painting\n");
WebCore::Region unpainted;
BView* surface = new BView("drawing_surface",B_WILL_DRAW);
drawingArea->paint(surface,dirtyRect,unpainted);
WTF::RunLoop::initializeMainRunLoop();
WTF::RunLoop::run();
}
else
void WebView::loadHTML()
{
drawPageBackground(fPage.get(),dirtyRect);
fprintf(stderr,"\nim loading");
auto page = WKViewGetPage( fViewPort.get());
WKRetainPtr<WKURLRef> uri;
uri = adoptWK(WKURLCreateWithUTF8CString("about:blank"));
WKRetainPtr<WKStringRef> str;
str = adoptWK(WKStringCreateWithUTF8CString("<body>Hello world</body>"));
//WKPageLoadURL(page,uri.get());
WKPageLoadHTMLString(page,str.get(),uri.get());
}
}


}
@@ -22,38 +22,24 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <View.h>
#include <Window.h>
#include <Rect.h>
#include "APIObject.h"
#include "APIPageConfiguration.h"
#include "WebPageProxy.h"
#include "PageClientImplHaiku.h"

#include "WKPage.h"
#include "WKView.h"
#include "WKContext.h"
#include "WKRetainPtr.h"
using namespace WebKit;
namespace WebKit
{
class BWebView:public API::ObjectImpl<API::Object::Type::View>,
public BView
class WebView
{
public:
static RefPtr<BWebView> create(const char*name,BRect rect,
BWindow* parentWindow,const API::PageConfiguration& config)
{
fprintf(stderr,"yolo");
auto fWebView=adoptRef(*new BWebView(name,rect,parentWindow,config));
fprintf(stderr,"im stuff");
return fWebView;
}
WebPageProxy* page() const { return fPage.get(); }
BView* getView() const {return fViewPort;}
private:
BWebView(const char*,BRect,BWindow*,const API::PageConfiguration&);

void paint(const WebCore::IntRect&);

BView* fViewPort {nullptr};
RefPtr<WebPageProxy> fPage;
std::unique_ptr<PageClientImpl> fPageClient;
};
WebView(BRect,BWindow*);
void initializeOnce();
void loadHTML();
private:
WKRetainPtr<WKViewRef> fViewPort;
WKRetainPtr<WKContextRef> fContext;
};
}


0 comments on commit 1d893a8

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