Initial Port to Awesomium 1.6rc1

Sep 21, 2010 at 4:39 PM

Here's a patch file for an initial minimal port to Awesomium 1.6rc1 (none of the new features).



Index: WebCoreWrapper.cpp
===================================================================
--- WebCoreWrapper.cpp	(revision 51354)
+++ WebCoreWrapper.cpp	(working copy)
@@ -67,10 +67,15 @@
 	else
 		userAgentOverrideString = "";
 
-	webCore = new Awesomium::WebCore(userDataPathString, pluginPathString,
-		logPathString, (Awesomium::LogLevel)options->LogLevel,
-		options->EnablePlugins, userAgentOverrideString
-	);
+	Awesomium::WebCoreConfig* webCoreConfig = new Awesomium::WebCoreConfig();
+	webCoreConfig->setUserDataPath(userDataPathString);
+	webCoreConfig->setPluginPath(pluginPathString);
+	webCoreConfig->setLogPath(logPathString);
+	webCoreConfig->setLogLevel((Awesomium::LogLevel)options->LogLevel);
+	webCoreConfig->setEnablePlugins(options->EnablePlugins);
+	webCoreConfig->setUserAgentOverride(userAgentOverrideString);
+
+	webCore = new Awesomium::WebCore(*webCoreConfig);
 
 	webViewList = gcnew List();
 }
@@ -97,7 +102,7 @@
 
 void AwesomiumDotNet::WebCore::SetCustomResponsePage(int statusCode, String^ filePath)
 {
-	webCore->setCustomResponsePage(statusCode, MarshalString(filePath));
+	webCore->setCustomResponsePage(statusCode, MarshalStringW(filePath));
 }
 
 void AwesomiumDotNet::WebCore::Update()
Index: WebViewWrapper.cpp
===================================================================
--- WebViewWrapper.cpp	(revision 51354)
+++ WebViewWrapper.cpp	(working copy)
@@ -279,18 +279,19 @@
 	}
 
 
-
 	WebView::WebView (WebCore^ webCoreNet, int width, int height)
 	{
 		this->webCore = webCoreNet;
 		this->webView = webCore->getCore()->createWebView(width, height);
 		this->webView->setListener(new WebViewListenerWrapper(this));
+		this->zoomLevel = 100;
 	}
 
 	WebView::WebView (WebCore^ webCoreNet, Awesomium::WebView* webView)
 	{
 		this->webCore = webCoreNet;
 		this->webView = webView;
+		this->zoomLevel = 100;
 		//this->webView->setListener(new WebViewListenerWrapper(this));
 	}
 
@@ -359,12 +360,16 @@
 
 	void WebView::ZoomIn()
 	{
-		webView->zoomIn();
+		zoomLevel = zoomLevel + zoomLevel * .2;
+		zoomLevel = min(500, zoomLevel);
+		webView->setZoom(zoomLevel);
 	}
 
 	void WebView::ZoomOut()
 	{
-		webView->zoomOut();
+		zoomLevel = zoomLevel - zoomLevel * .2;
+		zoomLevel = max(10, zoomLevel);
+		webView->setZoom(zoomLevel);
 	}
 
 	void WebView::ResetZoom()
Index: WebViewWrapper.h
===================================================================
--- WebViewWrapper.h	(revision 51354)
+++ WebViewWrapper.h	(working copy)
@@ -306,6 +306,7 @@
 	private:
 		Awesomium::WebView* webView;
 		WebCore^ webCore;
+		int zoomLevel;
 
 	public:
 		/// This event is fired when a WebView begins to actually receive data from a server.

Coordinator
Sep 21, 2010 at 10:15 PM

Thanks, but I got it already :)

I hope there will be a getZoom() function so that we wouldn't have to remember the zoom level.

Sep 22, 2010 at 1:49 PM

I figured you would eventually :-)

Yes, storing aside the zoom level is kind of lame.  It's nice to be stateless.

I'll take a look at your new commits.