@@ -0,0 +1,104 @@
/*
* Copyright (C) 2019 Haiku, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "Connection.h"

#include <unistd.h>
#include <Message.h>
#include <Looper.h>
namespace IPC{
class ReadLoop: public BHandler
{
public:
ReadLoop(IPC::Connection* con)
:BHandler("Read Message Loop"),
connection(con)
{
}
void MessageReceived(BMessage* message)
{

fprintf(stderr,"%s %ld\n",__PRETTY_FUNCTION__,getpid());
message->PrintToStream();
}
private:
IPC::Connection* connection;

};
void Connection::platformInitialize(Identifier identifier)
{
m_connectedProcess = identifier;
}
void Connection::platformInvalidate()
{

}
void Connection::runReadEventLoop()
{
BLooper* looper = BLooper::LooperForThread(find_thread(NULL));
looper->Lock();
looper->AddHandler(m_readHandler);
looper->SetPreferredHandler(m_readHandler);
looper->Unlock();

}
void Connection::runWriteEventLoop()
{
}
bool Connection::open()
{
m_isConnected = true;
status_t result = m_messenger.SetTo(NULL,m_connectedProcess);
m_readHandler = new ReadLoop(this);
runReadEventLoop();
if(result == B_OK)
{
fprintf(stderr,"%s %ld %ld\n",__PRETTY_FUNCTION__,m_connectedProcess,getpid());
return true;
}

return false;
}
bool Connection::platformCanSendOutgoingMessages() const
{
//write with encoder
return true;
}
bool Connection::sendOutgoingMessage(std::unique_ptr<Encoder> encoder)
{
BMessage processMessage('ipcm');
status_t result = processMessage.AddData("bufferData",B_ANY_TYPE,encoder->buffer(),encoder->bufferSize());
result = m_messenger.SendMessage(&processMessage);
//fprintf(stderr,"%s %s\n",__PRETTY_FUNCTION__,strerror(result));
}
void Connection::willSendSyncMessage(OptionSet<SendSyncOption> )
{

}
void Connection::didReceiveSyncReply(OptionSet<SendSyncOption> )
{

}
}
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 Haiku, Inc.
* Copyright (C) 2019 Haiku, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -24,17 +24,65 @@
*/

#include "config.h"
#include "AuxiliaryProcessMain.h"

#include "NotImplemented.h"
#include "SharedMemory.h"

#include "Decoder.h"
#include "Encoder.h"

namespace WebKit {

bool AuxiliaryProcessMainBase::parseCommandLine(int argc, char** argv)
SharedMemory::Handle::Handle()
{
}

SharedMemory::Handle::~Handle()
{
}

SharedMemory::Handle::Handle(Handle&&) = default;
SharedMemory::Handle& SharedMemory::Handle::operator=(Handle&& other) = default;

void SharedMemory::Handle::clear()
{
}

bool SharedMemory::Handle::isNull() const
{
}

void SharedMemory::Handle::encode(IPC::Encoder& encoder) const
{
}

bool SharedMemory::Handle::decode(IPC::Decoder& decoder, Handle& handle)
{
}

static int createSharedMemory()
{
}

RefPtr<SharedMemory> SharedMemory::allocate(size_t size)
{
}

RefPtr<SharedMemory> SharedMemory::map(const Handle& handle, Protection protection)
{

}

SharedMemory::~SharedMemory()
{
}

bool SharedMemory::createHandle(Handle& handle, Protection)
{
}

unsigned SharedMemory::systemPageSize()
{
notImplemented();
return true;
}

} // namespace WebKit


@@ -5,25 +5,29 @@ list(APPEND WebKit_SOURCES
NetworkProcess/haiku/NetworkProcessMainHaiku.cpp
NetworkProcess/haiku/RemoteNetworkingContextHaiku.cpp

Platform/IPC/unix/AttachmentUnix.cpp
Platform/IPC/unix/ConnectionUnix.cpp
Platform/IPC/haiku/ConnectionHaiku.cpp
Platform/haiku/LoggingHaiku.cpp
Platform/haiku/ModuleHaiku.cpp
Platform/unix/SharedMemoryUnix.cpp
Platform/haiku/SharedMemoryHaiku.cpp

PluginProcess/unix/PluginControllerProxyUnix.cpp
PluginProcess/unix/PluginProcessMainUnix.cpp
PluginProcess/unix/PluginProcessUnix.cpp

Shared/WebCoreArgumentCoders.cpp
Shared/haiku/AuxiliaryProcessMainHaiku.cpp
Shared/haiku/ProcessExecutablePathHaiku.cpp
Shared/haiku/ShareableBitmapHaiku.cpp
Shared/haiku/WebCoreArgumentCodersHaiku.cpp
Shared/haiku/WebMemorySamplerHaiku.cpp

UIProcess/API/C/haiku/WKView.cpp
UIProcess/API/haiku/APIWebsiteDataStoreHaiku.cpp

UIProcess/DefaultUndoController.cpp
UIProcess/BackingStore.cpp

UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp

UIProcess/Launcher/haiku/ProcessLauncherHaiku.cpp
UIProcess/LegacySessionStateCodingNone.cpp
UIProcess/Plugins/unix/PluginInfoStoreUnix.cpp
@@ -36,6 +40,9 @@ 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

WebProcess/Cookies/haiku/WebCookieManagerHaiku.cpp
WebProcess/InjectedBundle/haiku/InjectedBundleHaiku.cpp
@@ -45,24 +52,27 @@ list(APPEND WebKit_SOURCES
WebProcess/WebCoreSupport/haiku/WebEditorClientHaiku.cpp
WebProcess/WebCoreSupport/haiku/WebFrameNetworkingContext.cpp
WebProcess/WebCoreSupport/haiku/WebPopupMenuHaiku.cpp
WebProcess/WebPage/AcceleratedDrawingArea.cpp
WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp
WebProcess/WebPage/DrawingAreaImpl.cpp
WebProcess/WebPage/LayerTreeHost.cpp

WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp
WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp

WebProcess/WebPage/haiku/WebInspectorHaiku.cpp
WebProcess/WebPage/haiku/WebPageHaiku.cpp

WebProcess/haiku/WebProcessHaiku.cpp
WebProcess/haiku/WebProcessMainHaiku.cpp
)

list(APPEND WebKit_INCLUDE_DIRECTORIES
"${CMAKE_SOURCE_DIR}/Source"
#"${WEBCORE_DIR}/platform/graphics/opentype"
#"${WEBCORE_DIR}/platform/network/haiku"
"${WEBKIT_DIR}/NetworkProcess/unix"
"${WEBKIT_DIR}/Platform"
"${WEBKIT_DIR}/Platform/IPC/unix"
"${WEBKIT_DIR}/Shared/API/c/haiku"
"${WEBKIT_DIR}/Shared/CoordinatedGraphics"
"${WEBKIT_DIR}/Shared/CoordinatedGraphics/threadedcompositor"
"${WEBKIT_DIR}/Shared/unix"
"${WEBKIT_DIR}/Shared/haiku"
"${WEBKIT_DIR}/UIProcess/API/C/CoordinatedGraphics"
@@ -78,20 +88,22 @@ list(APPEND WebKit_INCLUDE_DIRECTORIES
${SQLITE_INCLUDE_DIRS}
${WTF_DIR}
${WTF_DIR}
"${DERIVED_SOURCES_WEBCORE_DIR}"
"${WEBCORE_DIR}/platform"
"${WEBCORE_DIR}/platform/text"
"${WEBCORE_DIR}/dom"
"${WEBCORE_DIR}/fileapi"
"${FORWARDING_HEADERS_DIR}/WebCore"
"${DERIVED_SOURCES_WEBCORE_DIR}"
)

list(APPEND WebKit_LOCAL_INCLUDE_DIRECTORIES
set(WebKit_LOCAL_INCLUDE_DIRECTORIES
"${WEBCORE_DIR}/css"
"${WEBCORE_DIR}/platform/graphics"
"${WEBCORE_DIR}/platform/graphics/transforms"
"${WEBCORE_DIR}/rendering/shapes"
)

foreach(inc ${WebKitLegacy_LOCAL_INCLUDE_DIRECTORIES})
foreach(inc ${WebKit_LOCAL_INCLUDE_DIRECTORIES})
ADD_DEFINITIONS(-iquote ${inc})
endforeach(inc)

@@ -152,3 +164,4 @@ set(WebKit_FORWARDING_HEADERS_FILES
WEBKIT_CREATE_FORWARDING_HEADERS(WebKit FILES ${WebKit_FORWARDING_HEADERS_FILES} DIRECTORIES
${WebKit_FORWARDING_HEADERS_DIRECTORIES})

set(WebProcess_RESOURCES DEPENDS ${WEBKIT_DIR}/haiku/WebProcess.rdef)
@@ -78,7 +78,7 @@ void AuxiliaryProcess::initialize(const AuxiliaryProcessInitializationParameters

// In WebKit2, only the UI process should ever be generating non-default PAL::SessionIDs.
PAL::SessionID::enableGenerationProtection();

fprintf(stderr,"%ld %ld\n",getpid(),parameters.connectionIdentifier);
m_connection = IPC::Connection::createClientConnection(parameters.connectionIdentifier, *this);
initializeConnection(m_connection.get());
m_connection->open();
@@ -0,0 +1,62 @@
/*
* Copyright (C) 2019 Haiku, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#pragma once

#include "AuxiliaryProcess.h"
#include "WebKit2Initialize.h"
#include <wtf/RunLoop.h>

namespace WebKit {

struct AuxiliaryProcessSettings
{
AuxiliaryProcessInitializationParameters&& takeInitializationParameters() { return WTFMove(m_parameters); }
AuxiliaryProcessInitializationParameters m_parameters;
};

template<typename AuxiliaryProcessType>
void initializeAuxiliaryProcess(AuxiliaryProcessInitializationParameters&& parameters)
{
AuxiliaryProcessType::singleton().initialize(WTFMove(parameters));
}

template<typename AuxiliaryProcessType>
int AuxiliaryProcessMain(int argc, char** argv)
{
InitializeWebKit2();

AuxiliaryProcessSettings auxMain;

auxMain.m_parameters.processIdentifier = makeObjectIdentifier<WebCore::ProcessIdentifierType>(atoll(argv[2]));
auxMain.m_parameters.connectionIdentifier = atol(argv[3]);
initializeAuxiliaryProcess<AuxiliaryProcessType>(auxMain.takeInitializationParameters());

RunLoop::run();

return EXIT_SUCCESS;
}

} // namespace WebKit
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2012 Samsung Electronics
* Copyright (C) 2014 Haiku, inc.
* Copyright (C) 2014,2019 Haiku, inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,69 +27,25 @@
#include "config.h"
#include "ProcessExecutablePath.h"

#include "NotImplemented.h"
#include <libgen.h>
#include <unistd.h>
#include <wtf/FileSystem.h>
#include <wtf/NeverDestroyed.h>
#include <wtf/StdLibExtras.h>
#include <wtf/text/CString.h>
#include <Entry.h>
#include <String.h>

namespace WebKit {

// We initially look for the process in WEBKIT_EXEC_PATH, then proceed to try the working
// directory of the running process, and finally we try LIBEXECDIR (usually /usr/local/bin).
static String findProcessPath(const char* processName)
{
String executablePath;
static const char* execDirectory = getenv("WEBKIT_EXEC_PATH");
if (execDirectory) {
executablePath = FileSystem::pathByAppendingComponent(String::fromUTF8(execDirectory), processName);
if (FileSystem::fileExists(executablePath))
return executablePath;
}

#if OS(UNIX)
char readLinkBuffer[PATH_MAX] = {0};

notImplemented();
#if OS(LINUX)
ssize_t result = readlink("/proc/self/exe", readLinkBuffer, PATH_MAX);
#else
ssize_t result = readlink("/proc/curproc/file", readLinkBuffer, PATH_MAX);
#endif
if (result > 0) {
char* executablePathPtr = dirname(readLinkBuffer);
executablePath = FileSystem::pathByAppendingComponent(String::fromUTF8(executablePathPtr), processName);
if (FileSystem::fileExists(executablePath))
return executablePath;
}
#endif
executablePath = FileSystem::pathByAppendingComponent(String(LIBEXECDIR), processName);
ASSERT(FileSystem::fileExists(executablePath));
return executablePath;
}

String executablePathOfWebProcess()
{
static NeverDestroyed<const String> webKitWebProcessName(findProcessPath(WEBPROCESSNAME));

return webKitWebProcessName;
return BString("./bin/WebProcess");
}

String executablePathOfPluginProcess()
{
static NeverDestroyed<const String> webKitPluginProcessName(findProcessPath(PLUGINPROCESSNAME));

return webKitPluginProcessName;
return BString("./bin/PluginProcess");
}

#if ENABLE(NETWORK_PROCESS)
String executablePathOfNetworkProcess()
{
static NeverDestroyed<const String> webKitNetworkProcessName(findProcessPath(NETWORKPROCESSNAME));

return webKitNetworkProcessName;
return BString("./bin/NetworkProcess");
}
#endif

@@ -36,9 +36,14 @@ bool AuxiliaryProcessMainBase::parseCommandLine(int argc, char** argv)
ASSERT(argc >= 3);
if (argc < 3)
return false;

m_parameters.processIdentifier = makeObjectIdentifier<WebCore::ProcessIdentifierType>(atoll(argv[1]));
#if PLATFORM(HAIKU)
m_parameters.processIdentifier = makeObjectIdentifier<WebCore::ProcessIdentifierType>(atoll(argv[2]));
m_parameters.connectionIdentifier = atol(argv[3]);
#else
m_parameters.processIdentifier = makeObjectIdentifier<WebCore::ProcessIdentifierType>(atoll(argv[1]));
m_parameters.connectionIdentifier = atoi(argv[2]);
#endif

return true;
}

@@ -37,6 +37,10 @@ class AuxiliaryProcessMainBase {
virtual bool parseCommandLine(int argc, char** argv);
virtual void platformFinalize() { }

#if PLATFORM(HAIKU)
virtual void runApp() {};
#endif

AuxiliaryProcessInitializationParameters&& takeInitializationParameters() { return WTFMove(m_parameters); }

protected:
@@ -56,16 +60,20 @@ int AuxiliaryProcessMain(int argc, char** argv)

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

InitializeWebKit2();

if (!auxiliaryMain.parseCommandLine(argc, argv))
return EXIT_FAILURE;

initializeAuxiliaryProcess<AuxiliaryProcessType>(auxiliaryMain.takeInitializationParameters());
#if PLATFORM(HAIKU)
auxiliaryMain.runApp();
#else
RunLoop::run();
#endif
auxiliaryMain.platformFinalize();

return EXIT_SUCCESS;
}

@@ -26,13 +26,13 @@

namespace WebKit {

class WebView;
class WebPopupItemHaiku;
class WebPopupMenuListenerHaiku;
class WebViewBase;
//class WebPopupItemHaiku;
//class WebPopupMenuListenerHaiku;

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

}

@@ -1,6 +1,7 @@
/*
* Copyright (C) 2012 Samsung Electronics
* Copyright (C) 2013 Intel Corporation. All rights reserved.
* Copyright (C) 2019 Haiku, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -21,21 +22,21 @@
#include "config.h"
#include "WKView.h"

#include <WebView.h>
#include <WebViewPrivate.h>
#include "WKAPICast.h"

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

WKViewRef WKViewCreate(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
WKViewRef WKViewCreate(const char* name,BRect rect,BWindow* parentWindow,
WKPageConfigurationRef pageRef)
{
RefPtr<WebView> webView = WebView::create(toImpl(contextRef), toImpl(pageGroupRef));
return toAPI(webView.release().leakRef());
fprintf(stderr,"\n create page");
return toAPI(WebViewBase::create(name,rect,parentWindow,*toImpl(pageRef)).leakRef());
}

WKPageRef WKViewGetPage(WKViewRef viewRef)
{
return toImpl(viewRef)->pageRef();
}

fprintf(stderr,"\nget page");
return toAPI(toImpl(viewRef)->page());
}
@@ -29,15 +29,14 @@
#define WKView_h

#include <WebKit/WKBase.h>
#include <Window.h>

#ifdef __cplusplus
extern "C" {
#endif

WK_EXPORT WKViewRef WKViewCreate(WKContextRef context, WKPageGroupRef pageGroup);

WK_EXPORT WKViewRef WKViewCreate(const char*,BRect,BWindow*,WKPageConfigurationRef pageRef);
WK_EXPORT WKPageRef WKViewGetPage(WKViewRef view);

#ifdef __cplusplus
}
#endif
@@ -34,91 +34,104 @@ namespace API {

String WebsiteDataStore::defaultApplicationCacheDirectory()
{
fprintf(stderr,"error");
notImplemented();
return String();
}

String WebsiteDataStore::defaultCacheStorageDirectory()
{
return String();
}

String WebsiteDataStore::defaultNetworkCacheDirectory()
{
return String();
}

String WebsiteDataStore::defaultIndexedDBDatabaseDirectory()
{
return String();
}

String WebsiteDataStore::defaultServiceWorkerRegistrationDirectory()
{
return String();
}

String WebsiteDataStore::defaultLocalStorageDirectory()
{
return String();
}

String WebsiteDataStore::defaultMediaKeysStorageDirectory()
{
}

String WebsiteDataStore::defaultDeviceIdHashSaltsStorageDirectory()
{
return String();
}

String WebsiteDataStore::defaultWebSQLDatabaseDirectory()
{
return String();
}

String WebsiteDataStore::defaultResourceLoadStatisticsDirectory()
{
return String();
}

String WebsiteDataStore::cacheDirectoryFileSystemRepresentation(const String& directoryName)
{
return String();
}

String WebsiteDataStore::websiteDataDirectoryFileSystemRepresentation(const String& directoryName)
{
return String();
}

String WebsiteDataStore::legacyDefaultApplicationCacheDirectory()
{
return String();
}

String WebsiteDataStore::legacyDefaultNetworkCacheDirectory()
{
return String();
}

String WebsiteDataStore::legacyDefaultWebSQLDatabaseDirectory()
{
return String();
}

String WebsiteDataStore::legacyDefaultIndexedDBDatabaseDirectory()
{
return String();
}

String WebsiteDataStore::legacyDefaultLocalStorageDirectory()
{
return String();
}

String WebsiteDataStore::legacyDefaultMediaCacheDirectory()
{
return String();
}

String WebsiteDataStore::legacyDefaultMediaKeysStorageDirectory()
{
return String();
}

String WebsiteDataStore::legacyDefaultDeviceIdHashSaltsStorageDirectory()
{
return String();
}

String WebsiteDataStore::legacyDefaultJavaScriptConfigurationDirectory()
{
}

Ref<WebKit::WebsiteDataStoreConfiguration> WebsiteDataStore::defaultDataStoreConfiguration()
{
return String();
}

} // namespace API
@@ -0,0 +1,323 @@
/*
* Copyright (C) 2019 Haiku, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"

#include "PageClientImplHaiku.h"

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

namespace WebKit
{
using namespace WebCore;

PageClientImpl::PageClientImpl(WebViewBase& view)
:fWebView(view)
{
//fprintf(stderr,"page client called");
}
std::unique_ptr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy(
WebProcessProxy& process)
{
//fprintf(stderr,"called drawing area");
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&)
{
notImplemented();
}

WebCore::FloatPoint PageClientImpl::viewScrollPosition()
{
notImplemented();
return { };
}

WebCore::IntSize PageClientImpl::viewSize()
{
notImplemented();
/*if (fWebView.drawingArea())
return fWebView.drawingArea()->size();
*/
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()
{
notImplemented();
}

void PageClientImpl::didRelaunchProcess()
{
notImplemented();
}

void PageClientImpl::toolTipChanged(const String&, const String& newToolTip)
{
//fWebView.setToolTip(newToolTip);
}

void PageClientImpl::setCursor(const WebCore::Cursor& cursor)
{
//fWebView.setCursor(cursor);
}

void PageClientImpl::setCursorHiddenUntilMouseMoves(bool /* hiddenUntilMouseMoves */)
{
notImplemented();
}

void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttributes&)
{
notImplemented();
}

void PageClientImpl::registerEditCommand(Ref<WebEditCommandProxy>&& command, UndoOrRedo undoOrRedo)
{
fUndoController.registerEditCommand(WTFMove(command), undoOrRedo);
}

void PageClientImpl::clearAllEditCommands()
{
fUndoController.clearAllEditCommands();
}

bool PageClientImpl::canUndoRedo(UndoOrRedo undoOrRedo)
{
return fUndoController.canUndoRedo(undoOrRedo);
}

void PageClientImpl::executeUndoRedo(UndoOrRedo undoOrRedo)
{
fUndoController.executeUndoRedo(undoOrRedo);
}

FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& viewRect)
{
notImplemented();
return viewRect;
}

FloatRect PageClientImpl::convertToUserSpace(const FloatRect& viewRect)
{
notImplemented();
return viewRect;
}

IntPoint PageClientImpl::screenToRootView(const IntPoint& point)
{
return IntPoint();
}

IntRect PageClientImpl::rootViewToScreen(const IntRect& rect)
{
return IntRect();
}

void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent& event, bool wasEventHandled)
{
notImplemented();
}

RefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy& page)
{
fprintf(stderr,"context menu");
notImplemented();
//return WebPopupMenuProxyWin::create(&fWebView, page);
}

#if ENABLE(CONTEXT_MENUS)
Ref<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy& page, ContextMenuContextData&& context, const UserData& userData)
{
notImplemented();
//return WebContextMenuProxyWin::create(page, WTFMove(context), userData);
}
#endif

//#if ENABLE(INPUT_TYPE_COLOR)
RefPtr<WebColorPicker> PageClientImpl::createColorPicker(WebPageProxy*, const WebCore::Color& intialColor,
const WebCore::IntRect&, Vector<WebCore::Color>&&)
{
return nullptr;
}
//#endif

void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
{
notImplemented();
}

void PageClientImpl::exitAcceleratedCompositingMode()
{
notImplemented();
}

void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
{
notImplemented();
}

void PageClientImpl::pageClosed()
{
notImplemented();
}

void PageClientImpl::preferencesDidChange()
{
notImplemented();
}

void PageClientImpl::didChangeContentSize(const IntSize& size)
{
notImplemented();
}

void PageClientImpl::handleDownloadRequest(DownloadProxy& download)
{
notImplemented();
}

void PageClientImpl::didCommitLoadForMainFrame(const String& /* mimeType */, bool /* useCustomContentProvider */ )
{
notImplemented();
}
void PageClientImpl::wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent& event)
{
notImplemented();
}

void PageClientImpl::didFinishLoadingDataForCustomContentProvider(const String&, const IPC::DataReference&)
{
notImplemented();
}

void PageClientImpl::navigationGestureDidBegin()
{
notImplemented();
}

void PageClientImpl::navigationGestureWillEnd(bool, WebBackForwardListItem&)
{
notImplemented();
}

void PageClientImpl::navigationGestureDidEnd(bool, WebBackForwardListItem&)
{
notImplemented();
}

void PageClientImpl::navigationGestureDidEnd()
{
notImplemented();
}

void PageClientImpl::willRecordNavigationSnapshot(WebBackForwardListItem&)
{
notImplemented();
}

void PageClientImpl::didRemoveNavigationGestureSnapshot()
{
notImplemented();
}

void PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame()
{
notImplemented();
}

void PageClientImpl::didFinishLoadForMainFrame()
{
notImplemented();
}

void PageClientImpl::didSameDocumentNavigationForMainFrame(SameDocumentNavigationType)
{
notImplemented();
}

void PageClientImpl::didChangeBackgroundColor()
{
notImplemented();
}

void PageClientImpl::isPlayingAudioWillChange()
{
notImplemented();
}

void PageClientImpl::isPlayingAudioDidChange()
{
notImplemented();
}

void PageClientImpl::refView()
{
notImplemented();
}

void PageClientImpl::derefView()
{
notImplemented();
}

BView* PageClientImpl::viewWidget()
{
return fWebView.getView();
}

}

@@ -0,0 +1,127 @@
/*
* Copyright (C) 2019 Haiku, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once

#include "PageClient.h"
#include "WebPageProxy.h"
#include "DefaultUndoController.h"
#include "IntPoint.h"
#include "IntRect.h"

namespace WebKit
{
class WebViewBase;
class DrawingAreaProxy;
class PageClientImpl: public PageClient
{
public:
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) override;
WebCore::FloatPoint viewScrollPosition() override;
WebCore::IntSize viewSize() override;
bool isViewWindowActive() override;
bool isViewFocused() override;
bool isViewVisible() override;
bool isViewInWindow() override;
void processDidExit() override;
void didRelaunchProcess() override;
void pageClosed() override;
void preferencesDidChange() override;
void toolTipChanged(const WTF::String&, const WTF::String&) override;
void setCursor(const WebCore::Cursor&) override;
void setCursorHiddenUntilMouseMoves(bool) override;
void didChangeViewportProperties(const WebCore::ViewportAttributes&) override;
void registerEditCommand(Ref<WebEditCommandProxy>&&, UndoOrRedo) override;
void clearAllEditCommands() override;
bool canUndoRedo(UndoOrRedo) override;
void executeUndoRedo(UndoOrRedo) override;
WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&) override;
WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&) override;
WebCore::IntPoint screenToRootView(const WebCore::IntPoint&) override;
WebCore::IntRect rootViewToScreen(const WebCore::IntRect&) override;
void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool wasEventHandled) override;
RefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy&) override;
Ref<WebContextMenuProxy> createContextMenuProxy(WebPageProxy&, ContextMenuContextData&&, const UserData&) override;

#if ENABLE(INPUT_TYPE_COLOR)
RefPtr<WebColorPicker> createColorPicker(WebPageProxy*, const WebCore::Color& intialColor,
const WebCore::IntRect&,Vector<WebCore::Color>&&) override;
#endif

void enterAcceleratedCompositingMode(const LayerTreeContext&) override;
void exitAcceleratedCompositingMode() override;
void updateAcceleratedCompositingMode(const LayerTreeContext&) override;

void handleDownloadRequest(DownloadProxy&) override;
void didChangeContentSize(const WebCore::IntSize&) override;
void didCommitLoadForMainFrame(const String& mimeType, bool useCustomContentProvider) override;
void didFailLoadForMainFrame() override { }


void didFinishLoadingDataForCustomContentProvider(const String& suggestedFilename, const IPC::DataReference&) override;
void navigationGestureDidBegin() override;
void navigationGestureWillEnd(bool, WebBackForwardListItem&) override;
void navigationGestureDidEnd(bool, WebBackForwardListItem&) override;
void navigationGestureDidEnd() override;
void willRecordNavigationSnapshot(WebBackForwardListItem&) override;
void didRemoveNavigationGestureSnapshot() override;

void didFirstVisuallyNonEmptyLayoutForMainFrame() override;
void didFinishLoadForMainFrame() override;
void didSameDocumentNavigationForMainFrame(SameDocumentNavigationType) override;

void wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent&) override;

void didChangeBackgroundColor() override;
void isPlayingAudioWillChange() override;
void isPlayingAudioDidChange() override;

void refView() override;
void derefView() override;

void didRestoreScrollPosition() override { }

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
WebViewBase& fWebView;
};


}
@@ -1,44 +1,74 @@
/*
Copyright (C) 2014 Haiku, inc.
* Copyright (C) 2019 Haiku, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
#include <Window.h>
#include <View.h>

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "WKPageConfigurationRef.h"
#include "WKPage.h"
#include "WKView.h"
#include "WKURL.h"
#include "WKString.h"
#include "WKContext.h"
#include "WKPreferencesRef.h"

#include "config.h"
#include "WebView.h"

#include "NotImplemented.h"
#include "WebContext.h"
#include "WebPageGroup.h"
#include "wtf/RunLoop.h"

using namespace WebKit;

BWebView::BWebView(WKContextRef context, WKPageGroupRef pageGroup)
: BView("web view", B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE)
#include "WebView.h"
BWebView::BWebView(BRect frame,BWindow* myWindow)
{
fWebView = adoptWK(WKViewCreate(context, pageGroup));
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()));
//
}

WKViewRef BWebView::GetWKView()
void BWebView::initializeOnce()
{
return fWebView.get();
WTF::RunLoop::initializeMainRunLoop();
WTF::RunLoop::run();
}

WKPageRef BWebView::pageRef()
void BWebView::loadHTML()
{
return WKViewGetPage(GetWKView());
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());
}

@@ -1,38 +1,42 @@
/*
Copyright (C) 2014 Haiku, inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/

#include <View.h>

#include "APIObject.h"
#include "WKBase.h"
#include "WKRetainPtr.h"
* Copyright (C) 2019 Haiku, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "WKPage.h"
#include "WKView.h"

class BWebView: public BView
#include "WKContext.h"
#include "WKRetainPtr.h"
using namespace WebKit;
class BWebView
{
public:
BWebView(WKContextRef, WKPageGroupRef);

WKViewRef GetWKView();
WKPageRef pageRef();

private:
WKRetainPtr<WKViewRef> fWebView;
public:
BWebView(BRect,BWindow*);
void initializeOnce();
void loadHTML();
private:
WKRetainPtr<WKViewRef> fViewPort;
WKRetainPtr<WKContextRef> fContext;
};


@@ -0,0 +1,83 @@
/*
* Copyright (C) 2019 Haiku, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "WebViewBase.h"
#include "APIPageConfiguration.h"
#include "DrawingAreaProxyCoordinatedGraphics.h"
#include "WebProcessPool.h"
#include "WebPageGroup.h"
#include <WebCore/IntRect.h>

using namespace WebKit;
using namespace WebCore;

WebKit::WebViewBase::WebViewBase(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));
}

void WebViewBase::paint(const IntRect& dirtyRect)
{
if(dirtyRect.isEmpty())
{
fprintf(stderr,"its empty\n");
return;
}
fPage->endPrinting();
// TODO actually paint
}



@@ -0,0 +1,60 @@
/*
* Copyright (C) 2019 Haiku, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* 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"

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

void paint(const WebCore::IntRect&);

BView* fViewPort {nullptr};
RefPtr<WebPageProxy> fPage;
std::unique_ptr<PageClientImpl> fPageClient;
};
}
@@ -48,6 +48,7 @@ void ProcessLauncher::didFinishLaunchingProcess(ProcessID processIdentifier, IPC
m_processIdentifier = processIdentifier;
m_isLaunching = false;


if (!m_client) {
// FIXME: Make Identifier a move-only object and release port rights/connections in the destructor.
#if OS(DARWIN) && !PLATFORM(GTK)
@@ -57,7 +58,7 @@ void ProcessLauncher::didFinishLaunchingProcess(ProcessID processIdentifier, IPC
#endif
return;
}

m_client->didFinishLaunching(this, identifier);
}

@@ -26,16 +26,107 @@
#include "config.h"
#include "ProcessLauncher.h"

#include "ProcessExecutablePath.h"

#include <Roster.h>
#include <StackOrHeapArray.h>
#include <String.h>
#include <unistd.h>

using namespace WebCore;

namespace WebKit {

status_t processRef(BString path, entry_ref* pathRef)
{
BEntry pathEntry(path);
if(!pathEntry.Exists())
return B_BAD_VALUE;

status_t result = pathEntry.GetRef(pathRef);
if(result != B_OK)
return result;

return B_OK;
}

void ProcessLauncher::launchProcess()
{
BString executablePath;

switch (m_launchOptions.processType) {
case ProcessLauncher::ProcessType::Web:
executablePath = executablePathOfWebProcess();
break;
#if ENABLE(NETWORK_PROCESS)
case ProcessLauncher::ProcessType::Network:
executablePath = executablePathOfNetworkProcess();
break;
#endif
default:
ASSERT_NOT_REACHED();
return;
}

BString processIdentifier,processID;
team_id UIProcessID = getpid();
processID.SetToFormat("%ld",UIProcessID);
processIdentifier.SetToFormat("%" PRIu64, m_launchOptions.processIdentifier.toUInt64());
unsigned nargs = 5; // size of the argv array for g_spawn_async()

#if ENABLE(DEVELOPER_MODE)
Vector<CString> prefixArgs;
if (!m_launchOptions.processCmdPrefix.isNull()) {
for (auto& arg : m_launchOptions.processCmdPrefix.split(' '))
prefixArgs.append(arg.utf8());
nargs += prefixArgs.size();
}
#endif

entry_ref executableRef;
if(processRef(executablePath,&executableRef)!=B_OK)
{
return;
}
BStackOrHeapArray<const char*, 10> argv(nargs);
unsigned i = 0;
#if ENABLE(DEVELOPER_MODE)
// If there's a prefix command, put it before the rest of the args.
// FIXME this won't work with lauching using BRoster...
for (auto& arg : prefixArgs)
argv[i++] = const_cast<char*>(arg.data());
#endif
argv[i++] = executablePath.String();
argv[i++] = processIdentifier.String();
argv[i++] = processID.String();
// TODO pass our team_id so the web process can message us?
argv[i++] = nullptr;

assert(i <= nargs);

team_id child_id; // TODO do we need to store this somewhere?
status_t result = be_roster->Launch(&executableRef, i-1, argv, &child_id);

fprintf(stderr, "%s: %s %ld\n", __PRETTY_FUNCTION__, strerror(result),child_id);

// We've finished launching the process, message back to the main run loop.
RunLoop::main().dispatch([protectedThis = makeRef(*this), this, child_id] {
didFinishLaunchingProcess(m_processIdentifier, child_id);
});
}

void ProcessLauncher::terminateProcess()
{
if (m_isLaunching) {
invalidate();
return;
}

if (!m_processIdentifier)
return;

kill(m_processIdentifier, SIGKILL);
m_processIdentifier = 0;
}

void ProcessLauncher::platformInvalidate()
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.device.usb</key>
<true/>
<key>com.apple.security.temporary-exception.mach-lookup.global-name</key>
<string>com.apple.Safari.SafeBrowsing.Service</string>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.temporary-exception.files.absolute-path.read-only</key>
<string>/</string>
</dict>
</plist>
@@ -35,7 +35,7 @@ ProcessAssertion::ProcessAssertion(ProcessID, const String&, AssertionState asse
{
}

ProcessAssertion::ProcessAssertion(pid_t pid, const String& name, AssertionState assertionState, AssertionReason)
ProcessAssertion::ProcessAssertion(WTF::ProcessID pid, const String& name, AssertionState assertionState, AssertionReason)
: m_assertionState(assertionState)
{
}
@@ -35,7 +35,6 @@ void WebContextConnectionClient::didCreateConnection(WebProcessPool* processPool
{
if (!m_client.didCreateConnection)
return;

m_client.didCreateConnection(toAPI(processPool), toAPI(connection), m_client.base.clientInfo);
}

@@ -810,7 +810,7 @@ void WebPageProxy::swapToWebProcess(Ref<WebProcessProxy>&& process, std::unique_
void WebPageProxy::finishAttachingToWebProcess(IsProcessSwap isProcessSwap)
{
ASSERT(m_process->state() != AuxiliaryProcessProxy::State::Terminated);

fprintf(stderr,"step1\n");
if (m_process->state() == AuxiliaryProcessProxy::State::Running) {
// In the process-swap case, the ProvisionalPageProxy constructor already took care of calling webPageEnteringWebProcess()
// when the process was provisional.
@@ -1071,9 +1071,11 @@ void WebPageProxy::addPlatformLoadParameters(LoadParameters&)

RefPtr<API::Navigation> WebPageProxy::loadRequest(ResourceRequest&& request, ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy, API::Object* userData)
{
fprintf(stderr,"Access:");
fprintf(stderr,"loadRequest: %d",m_isClosed);
if (m_isClosed)
return nullptr;

RELEASE_LOG_IF_ALLOWED(Loading, "loadRequest: webPID = %i, pageID = %" PRIu64, m_process->processIdentifier(), m_pageID);

if (!hasRunningProcess())
@@ -7513,7 +7515,7 @@ void WebPageProxy::updateBackingStoreDiscardableState()
isDiscardable = false;
else
isDiscardable = !pageClient().isViewWindowActive() || !isViewVisible();

m_drawingArea->setBackingStoreIsDiscardable(isDiscardable);
}

@@ -133,6 +133,10 @@ OBJC_CLASS _WKRemoteObjectRegistry;
#include "ArgumentCodersGtk.h"
#endif

#if PLATFORM(HAIKU)
#include <View.h>
#endif

#if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS_FAMILY)
#include <WebCore/MediaPlaybackTargetPicker.h>
#include <WebCore/WebMediaSessionManagerClient.h>
@@ -233,6 +237,10 @@ typedef struct OpaqueJSContext* JSGlobalContextRef;
typedef HWND PlatformWidget;
#endif

#if PLATFORM(HAIKU)
typedef BView* PlatformWidget;
#endif

namespace WebKit {
class DrawingAreaProxy;
class EditableImageController;
@@ -805,6 +813,9 @@ class WebPageProxy : public API::ObjectImpl<API::Object::Type::Page>
#if PLATFORM(WPE)
struct wpe_view_backend* viewBackend();
#endif
#if PLATFORM(HAIKU)
PlatformWidget viewWidget();
#endif

bool isProcessingMouseEvents() const;
void processNextQueuedMouseEvent();
@@ -34,7 +34,15 @@ namespace WebKit {

void BackingStore::incorporateUpdate(ShareableBitmap* bitmap, const UpdateInfo& updateInfo)
{
fprintf(stderr,"Updater\n");
notImplemented();
}

void BackingStore::paint(BView* context,const IntRect& rect)
{
fprintf(stderr,"Im drawing");


}

}
@@ -33,22 +33,24 @@ namespace WebKit {

void WebProcessPool::platformInitialize()
{
fprintf(stderr, "%s\n", __PRETTY_FUNCTION__);
notImplemented();
}

void WebProcessPool::platformInitializeNetworkProcess(NetworkProcessCreationParameters&)
{
fprintf(stderr, "%s\n", __PRETTY_FUNCTION__);
notImplemented();
}

void WebProcessPool::platformInitializeWebProcess(WebProcessCreationParameters& parameters)
{
fprintf(stderr, "%s\n", __PRETTY_FUNCTION__);
notImplemented();
}

void WebProcessPool::platformInvalidateContext()
{
notImplemented();
}

void WebProcessPool::platformResolvePathsForSandboxExtensions()

This file was deleted.

This file was deleted.

@@ -49,6 +49,5 @@ int main(int argc, char** argv)
#if USE(GCRYPT)
PAL::GCrypt::initialize();
#endif

return WebProcessMainUnix(argc, argv);
}
@@ -33,7 +33,7 @@ namespace WebKit {
using namespace WebCore;

Ref<WebConnectionToUIProcess> WebConnectionToUIProcess::create(WebProcess* process)
{
{fprintf(stderr,"%s\n",__PRETTY_FUNCTION__);
return adoptRef(*new WebConnectionToUIProcess(process));
}

@@ -90,6 +90,8 @@ void WebInspector::setFrontendConnection(IPC::Attachment encodedConnectionIdenti
IPC::Connection::Identifier connectionIdentifier(encodedConnectionIdentifier.port());
#elif OS(WINDOWS)
IPC::Connection::Identifier connectionIdentifier(encodedConnectionIdentifier.handle());
#elif PLATFORM(HAIKU)
IPC::Connection::Identifier connectionIdentifier(NULL);
#else
notImplemented();
return;
@@ -92,12 +92,15 @@ void WebInspectorUI::updateConnection()
IPC::Connection::Identifier connectionIdentifier, connClient;
IPC::Connection::createServerAndClientIdentifiers(connectionIdentifier, connClient);
IPC::Attachment connectionClientPort(connClient);
#elif PLATFORM(HAIKU)
IPC::Connection::Identifier connectionIdentifier;
IPC::Attachment connectionClientPort;
#else
notImplemented();
return;
#endif

#if USE(UNIX_DOMAIN_SOCKETS) || OS(DARWIN) || PLATFORM(WIN)
#if USE(UNIX_DOMAIN_SOCKETS) || OS(DARWIN) || PLATFORM(WIN) || PLATFORM(HAIKU)
m_backendConnection = IPC::Connection::createServerConnection(connectionIdentifier, *this);
m_backendConnection->open();
#endif
@@ -30,17 +30,25 @@

namespace WebKit {

void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters&& parameters)
void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters& parameters)
{
fprintf(stderr, "%s\n", __PRETTY_FUNCTION__);
notImplemented();
}

void WebProcess::platformSetWebsiteDataStoreParameters(WebProcessDataStoreParameters&&)
{
fprintf(stderr, "%s\n", __PRETTY_FUNCTION__);
}

void WebProcess::platformTerminate()
{
fprintf(stderr, "%s\n", __PRETTY_FUNCTION__);
}

void WebProcess::platformSetCacheModel(CacheModel cacheModel)
{
fprintf(stderr, "%s\n", __PRETTY_FUNCTION__);
notImplemented();
}

@@ -26,25 +26,51 @@
#include "config.h"
#include "WebProcessMainUnix.h"

#include "AuxiliaryProcessMain.h"
#include "AuxiliaryProcessMainHaiku.h"
#include "WebProcess.h"

#include <Application.h>
namespace WebKit {
#include <Message.h>
#include <Messenger.h>

using namespace std;
using namespace WebCore;

class WebProcessMain final : public AuxiliaryProcessMainBase {
public:
bool platformInitialize() override
{
BApplication* app = new BApplication("application/x-vnd.haiku-webkit.webprocess");
return true;
}
namespace WebKit {

class WebProcessApp: public BApplication
{
private:
int argc;
char** argv;
public:
WebProcessApp(int argc,char** argv):BApplication("application/x-vnd.haiku-webkit.webprocess")
{
this->argc = argc;
this->argv = argv;
}

void MessageReceived(BMessage* msg)
{
//msg->PrintToStream();
switch(msg->what)
{
default:
BApplication::MessageReceived(msg);
}
}

void ReadyToRun()
{
AuxiliaryProcessMain<WebProcess>(argc,argv);
}
};

int WebProcessMainUnix(int argc, char** argv)
{
return AuxiliaryProcessMain<WebProcess, WebProcessMain>(argc, argv);
fprintf(stderr, "%s\n", __PRETTY_FUNCTION__);
WebProcessApp* app = new WebProcessApp(argc,argv);
return app->Run();
}

} // namespace WebKit
@@ -0,0 +1,12 @@
resource app_signature "application/x-vnd.haiku-webkit.webprocess";
resource app_version {
major = 1,
middle = 7,
minor = 0,

variety = B_APPV_DEVELOPMENT,
internal = 0,

short_info = "WebProcess backend for Haiku WebKit",
long_info = "Copyright 2014-2019 Haiku, Inc."
};
@@ -15,7 +15,7 @@ CALCULATE_LIBRARY_VERSIONS_FROM_LIBTOOL_TRIPLE(JAVASCRIPTCORE 25 4 7)
# Haiku side ultimately.
add_definitions(-D_GLIBCXX_USE_C99_MATH)

set(ENABLE_WEBKIT OFF)
set(ENABLE_WEBKIT ON)
set(ENABLE_WEBKIT_LEGACY ON)

if ("${CMAKE_BUILD_TYPE}" STREQUAL "debug" AND NOT SHARED_CORE)
@@ -0,0 +1,63 @@
/*
* Copyright 2019, RAJAGOPALAN-GANGADHARAN <g.raju2000@gmail.com>
* All rights reserved. Distributed under the terms of the MIT license.
*/



#include <Window.h>
#include <View.h>

#include "App.h"



enum
{
M_BUTTON_GO_URL = 'urlg'
};

App::App(void)
: BApplication("application/x-vnd.lh-MiniBrowser")
{
//initialize counter
fCount = 0;

//create window
frame.Set(100,100,500,400);
myWindow = new BWindow(frame,"MiniBrowser"
, B_TITLED_WINDOW
, B_ASYNCHRONOUS_CONTROLS
| B_QUIT_ON_WINDOW_CLOSE);
myWindow->Show();
}

void
App::MessageReceived(BMessage *msg)
{
switch(msg->what)
{
default:
BApplication::MessageReceived(msg);
}
}
void App::ReadyToRun()
{
webView = new BWebView(frame,myWindow);
this->testLoader();
}
void
App::testLoader()
{
webView->loadHTML();
}

int
main (void)
{
App *app = new App();
app->Run();
delete app;
return 0;
}

@@ -0,0 +1,29 @@
/*
* Copyright 2019, RAJAGOPALAN-GANGADHARAN <g.raju2000@gmail.com>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#ifndef APP_H
#define APP_H

#include <Application.h>
#include <Button.h>
#include <String.h>
#include <TextControl.h>

#include "WebView.h"

class App : public BApplication
{
public:
App(void);
void MessageReceived(BMessage *msg);
void ReadyToRun();
void testLoader();
private:
int32 fCount;
BWindow *myWindow;
BWebView* webView;
BRect frame;
};

#endif
@@ -0,0 +1,8 @@
/*
* Copyright 2019, RAJAGOPALAN-GANGADHARAN <g.raju2000@gmail.com>
* All rights reserved. Distributed under the terms of the MIT license.
*/

#include "BrowserWindow.h"

BrowserWindow::
@@ -0,0 +1,19 @@
/*
* Copyright 2019, RAJAGOPALAN-GANGADHARAN <g.raju2000@gmail.com>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#ifndef BrowserWindow_H
#define BrowserWindow_H

#include <Window.h>
#include <View.h>
#include <WebKit/WebView.h>

class BrowserWindow:public BWindow{
public:
BWebView* webView;

};


#endif // _H
@@ -0,0 +1,36 @@
SET(CMAKE_BUILD_TYPE Debug)
SET(MiniBrowser_SOURCES
${TOOLS_DIR}/MiniBrowser/haiku/App.cpp
)

INCLUDE_DIRECTORIES(
"${WEBKIT_DIR}/UIProcess/API/haiku"
)

SET(MiniBrowser_LIBRARIES
WebKit
WebCore
JavaScriptCore
${LIBXML2_LIBRARIES}
${LIBXSLT_LIBRARIES}
${SQLITE_LIBRARIES}
${ICU_I18N_LIBRARIES}
${ICU_LIBRARIES}
be bsd network stdc++ translation tracker
)

set(MiniBrowser_LOCAL_INCLUDE_DIRECTORIES
"${WEBCORE_DIR}/css"
"${WEBCORE_DIR}/platform/graphics"
"${WEBCORE_DIR}/platform/graphics/transforms"
"${WEBCORE_DIR}/rendering/shapes"
)

foreach(inc ${MiniBrowser_LOCAL_INCLUDE_DIRECTORIES})
ADD_DEFINITIONS(-iquote ${inc})
endforeach(inc)

ADD_EXECUTABLE(MiniBrowser ${MiniBrowser_SOURCES})
TARGET_LINK_LIBRARIES(MiniBrowser ${MiniBrowser_LIBRARIES})
SET_TARGET_PROPERTIES(MiniBrowser PROPERTIES FOLDER "Tools")
SET_TARGET_PROPERTIES(MiniBrowser PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
@@ -1,3 +1,4 @@
add_subdirectory(DumpRenderTree)
add_subdirectory(HaikuLauncher)
add_subdirectory(ImageDiff)
add_subdirectory(MiniBrowser/haiku)
@@ -58,6 +58,9 @@ if (isGtk() || isWPE()) {
} elsif (isAppleCocoaWebKit()) {
printHelpAndExitForRunAndDebugWebKitAppIfNeeded();
exit exitStatus(runMiniBrowser());
} elsif (isHaiku()) {
print "Starting MiniBrowser\n";
exit exitStatus(runMiniBrowser());
} else {
die "Unsupported platform."
}
}
@@ -2906,6 +2906,10 @@ sub runMiniBrowser
my $webKitLauncherPath = File::Spec->catfile(executableProductDir(), "MiniBrowser.exe");
return system { $webKitLauncherPath } $webKitLauncherPath, @ARGV;
}
if(isHaiku()){
my $webKitLauncherPath = File::Spec->catfile(productDir(), "MiniBrowser");
return system { $webKitLauncherPath } $webKitLauncherPath, @ARGV;
}
return 1;
}