From e042d31700b0bcebba06e6e991c9f676eb97a1eb Mon Sep 17 00:00:00 2001 From: anthony taranto Date: Fri, 24 Feb 2012 02:25:31 -0800 Subject: [PATCH] start using __declspec --- CefSharp.WinForms/WebView.cpp | 5 +++-- CefSharp.Wpf/CefSharp.Wpf.vcproj | 4 ++-- CefSharp.Wpf/WebView.cpp | 14 ++++---------- CefSharp.Wpf/WebView.h | 8 ++++++-- CefSharp/CefSharp.vcproj | 8 ++++++-- CefSharp/ClientAdapter.h | 26 +++++++++++++------------- CefSharp/IOffscreenWebBrowser.h | 2 +- CefSharp/OffscreenClientAdapter.cpp | 2 +- CefSharp/OffscreenClientAdapter.h | 14 +++++++------- CefSharp/ScriptCore.cpp | 20 +++++++++----------- CefSharp/ScriptCore.h | 4 ++-- CefSharp/Stdafx.h | 6 ++++++ 12 files changed, 60 insertions(+), 53 deletions(-) diff --git a/CefSharp.WinForms/WebView.cpp b/CefSharp.WinForms/WebView.cpp index dee65ba5b..4045ba0c3 100644 --- a/CefSharp.WinForms/WebView.cpp +++ b/CefSharp.WinForms/WebView.cpp @@ -126,7 +126,7 @@ namespace WinForms CefRefPtr browser = _clientAdapter->GetCefBrowser(); CefRefPtr frame = browser->GetMainFrame(); - _scriptCore->Execute(frame, script); + _scriptCore->Execute(frame, toNative(script)); } String^ WebView::EvaluateScript(String^ script) @@ -141,7 +141,8 @@ namespace WinForms CefRefPtr browser = _clientAdapter->GetCefBrowser(); CefRefPtr frame = browser->GetMainFrame(); - return _scriptCore->Evaluate(frame, script, timeout); + CefString result = _scriptCore->Evaluate(frame, toNative(script), timeout.TotalMilliseconds); + return toClr(result); } void WebView::SetNavState(bool isLoading, bool canGoBack, bool canGoForward) diff --git a/CefSharp.Wpf/CefSharp.Wpf.vcproj b/CefSharp.Wpf/CefSharp.Wpf.vcproj index 919feb59c..1c9b2ff01 100644 --- a/CefSharp.Wpf/CefSharp.Wpf.vcproj +++ b/CefSharp.Wpf/CefSharp.Wpf.vcproj @@ -133,9 +133,9 @@ /> diff --git a/CefSharp.Wpf/WebView.cpp b/CefSharp.Wpf/WebView.cpp index 5f6af9aee..f59799dad 100644 --- a/CefSharp.Wpf/WebView.cpp +++ b/CefSharp.Wpf/WebView.cpp @@ -221,7 +221,7 @@ namespace Wpf CefRefPtr browser = _clientAdapter->GetCefBrowser(); CefRefPtr frame = browser->GetMainFrame(); - _scriptCore->Execute(frame, script); + _scriptCore->Execute(frame, toNative(script)); } String^ WebView::EvaluateScript(String^ script) @@ -236,7 +236,8 @@ namespace Wpf CefRefPtr browser = _clientAdapter->GetCefBrowser(); CefRefPtr frame = browser->GetMainFrame(); - return _scriptCore->Evaluate(frame, script, timeout); + CefString result = _scriptCore->Evaluate(frame, toNative(script), timeout.TotalMilliseconds); + return toClr(result); } void WebView::SetNavState(bool isLoading, bool canGoBack, bool canGoForward) @@ -282,15 +283,8 @@ namespace Wpf gcnew Action(this, &WebView::SetCursor), handle); } - void WebView::SetBuffer(int width, int height, const std::vector& dirtyRects, const void* buffer) + void WebView::SetBuffer(int width, int height, const void* buffer) { - /* - if (dirtyRect.width == 0 || dirtyRect.height == 0 || width == 0 || height == 0) - { - return; - } - */ - if (!_backBufferHandle || _width != width || _height != height) { _ibitmap = nullptr; diff --git a/CefSharp.Wpf/WebView.h b/CefSharp.Wpf/WebView.h index a51ad707b..57a00c8ca 100644 --- a/CefSharp.Wpf/WebView.h +++ b/CefSharp.Wpf/WebView.h @@ -2,16 +2,20 @@ /* #include "CefSharp.h" -#include "OffscreenClientAdapter.h" #include "IOffscreenWebBrowser.h" #include "ConsoleMessageEventArgs.h" #include "RtzCountdownEvent.h" #include "BrowserCore.h" #include "ScriptCore.h" */ + +#include "OffscreenClientAdapter.h" +#include "ScriptCore.h" + using namespace Microsoft::Win32::SafeHandles; using namespace System; +using namespace System::ComponentModel; using namespace System::Runtime::InteropServices; using namespace System::Windows; using namespace System::Windows::Controls; @@ -187,6 +191,6 @@ namespace Wpf virtual void OnApplyTemplate() override; virtual void SetCursor(CefCursorHandle cursor); - virtual void SetBuffer(int width, int height, const std::vector& dirtyRects, const void* buffer); + virtual void SetBuffer(int width, int height, const void* buffer); }; }} \ No newline at end of file diff --git a/CefSharp/CefSharp.vcproj b/CefSharp/CefSharp.vcproj index 31f43ca28..fe46b8ce3 100644 --- a/CefSharp/CefSharp.vcproj +++ b/CefSharp/CefSharp.vcproj @@ -43,7 +43,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="$(SolutionDir)include" - PreprocessorDefinitions="_DEBUG;_WIN32_WINNT=0x0600;WINVER=0x0600;WIN32;_WINDOWS;WIN32_LEAN_AND_MEAN;USING_CEF_SHARED;_CRT_SECURE_NO_WARNINGS" + PreprocessorDefinitions="_DEBUG;_WIN32_WINNT=0x0600;WINVER=0x0600;WIN32;_WINDOWS;WIN32_LEAN_AND_MEAN;USING_CEF_SHARED;_CRT_SECURE_NO_WARNINGS;EXPORT" RuntimeLibrary="3" UsePrecompiledHeader="2" GenerateXMLDocumentationFiles="true" @@ -123,7 +123,7 @@ + + diff --git a/CefSharp/ClientAdapter.h b/CefSharp/ClientAdapter.h index 49ac7258b..0fcc4126b 100644 --- a/CefSharp/ClientAdapter.h +++ b/CefSharp/ClientAdapter.h @@ -53,29 +53,29 @@ namespace CefSharp virtual CefRefPtr GetMenuHandler() OVERRIDE { return this; } // CefLifeSpanHandler - virtual bool OnBeforePopup(CefRefPtr parentBrowser, const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo, const CefString& url, CefRefPtr& client, CefBrowserSettings& settings) OVERRIDE; - virtual void OnAfterCreated(CefRefPtr browser) OVERRIDE; - virtual void OnBeforeClose(CefRefPtr browser) OVERRIDE; + virtual DECL bool OnBeforePopup(CefRefPtr parentBrowser, const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo, const CefString& url, CefRefPtr& client, CefBrowserSettings& settings) OVERRIDE; + virtual DECL void OnAfterCreated(CefRefPtr browser) OVERRIDE; + virtual DECL void OnBeforeClose(CefRefPtr browser) OVERRIDE; // CefLoadHandler - virtual void OnLoadStart(CefRefPtr browser, CefRefPtr frame) OVERRIDE; - virtual void OnLoadEnd(CefRefPtr browser, CefRefPtr frame, int httpStatusCode) OVERRIDE; + virtual DECL void OnLoadStart(CefRefPtr browser, CefRefPtr frame) OVERRIDE; + virtual DECL void OnLoadEnd(CefRefPtr browser, CefRefPtr frame, int httpStatusCode) OVERRIDE; // CefRequestHandler - virtual bool OnBeforeResourceLoad(CefRefPtr browser, CefRefPtr request, CefString& redirectUrl, CefRefPtr& resourceStream, CefRefPtr response, int loadFlags) OVERRIDE; - virtual void OnResourceResponse(CefRefPtr browser, const CefString& url, CefRefPtr response, CefRefPtr& filter) OVERRIDE; + virtual DECL bool OnBeforeResourceLoad(CefRefPtr browser, CefRefPtr request, CefString& redirectUrl, CefRefPtr& resourceStream, CefRefPtr response, int loadFlags) OVERRIDE; + virtual DECL void OnResourceResponse(CefRefPtr browser, const CefString& url, CefRefPtr response, CefRefPtr& filter) OVERRIDE; // CefDisplayHandler - virtual void OnAddressChange(CefRefPtr browser, CefRefPtr frame, const CefString& url) OVERRIDE; - virtual void OnTitleChange(CefRefPtr browser, const CefString& title) OVERRIDE; - virtual bool OnTooltip(CefRefPtr browser, CefString& text) OVERRIDE; - virtual bool OnConsoleMessage(CefRefPtr browser, const CefString& message, const CefString& source, int line) OVERRIDE; + virtual DECL void OnAddressChange(CefRefPtr browser, CefRefPtr frame, const CefString& url) OVERRIDE; + virtual DECL void OnTitleChange(CefRefPtr browser, const CefString& title) OVERRIDE; + virtual DECL bool OnTooltip(CefRefPtr browser, CefString& text) OVERRIDE; + virtual DECL bool OnConsoleMessage(CefRefPtr browser, const CefString& message, const CefString& source, int line) OVERRIDE; // CefV8ContextHandler - virtual void OnContextCreated(CefRefPtr browser, CefRefPtr frame, CefRefPtr context) OVERRIDE; + virtual DECL void OnContextCreated(CefRefPtr browser, CefRefPtr frame, CefRefPtr context) OVERRIDE; // CefMenuHandler - virtual bool OnBeforeMenu(CefRefPtr browser, const CefMenuInfo& menuInfo) OVERRIDE; + virtual DECL bool OnBeforeMenu(CefRefPtr browser, const CefMenuInfo& menuInfo) OVERRIDE; IMPLEMENT_LOCKING(ClientAdapter); IMPLEMENT_REFCOUNTING(ClientAdapter); diff --git a/CefSharp/IOffscreenWebBrowser.h b/CefSharp/IOffscreenWebBrowser.h index 398db57ba..6559679ff 100644 --- a/CefSharp/IOffscreenWebBrowser.h +++ b/CefSharp/IOffscreenWebBrowser.h @@ -9,6 +9,6 @@ namespace CefSharp { public: void SetCursor(CefCursorHandle cursor); - void SetBuffer(int width, int height, const std::vector& dirtyRects, const void* buffer); + void SetBuffer(int width, int height, const void* buffer); }; } \ No newline at end of file diff --git a/CefSharp/OffscreenClientAdapter.cpp b/CefSharp/OffscreenClientAdapter.cpp index c10d1e0fa..ed59e2e62 100644 --- a/CefSharp/OffscreenClientAdapter.cpp +++ b/CefSharp/OffscreenClientAdapter.cpp @@ -25,7 +25,7 @@ namespace CefSharp int width, height; browser->GetSize(type, width, height); - _offscreenBrowserControl->SetBuffer(width, height, dirtyRects, buffer); + _offscreenBrowserControl->SetBuffer(width, height, buffer); } void OffscreenClientAdapter::OnCursorChange(CefRefPtr browser, CefCursorHandle cursor) diff --git a/CefSharp/OffscreenClientAdapter.h b/CefSharp/OffscreenClientAdapter.h index 7015ae22c..0e764576b 100644 --- a/CefSharp/OffscreenClientAdapter.h +++ b/CefSharp/OffscreenClientAdapter.h @@ -26,13 +26,13 @@ namespace CefSharp virtual CefRefPtr GetRenderHandler() OVERRIDE { return this; } // CefRenderHandler - virtual bool GetViewRect(CefRefPtr browser, CefRect& rect) OVERRIDE; - virtual bool GetScreenRect(CefRefPtr browser, CefRect& rect) OVERRIDE; - virtual bool GetScreenPoint(CefRefPtr browser, int viewX, int viewY, int& screenX, int& screenY) OVERRIDE; - //virtual void OnPopupShow(CefRefPtr browser, bool show) OVERRIDE; - //virtual void OnPopupSize(CefRefPtr browser, const CefRect& rect) OVERRIDE; - virtual void OnPaint(CefRefPtr browser, PaintElementType type, const RectList& dirtyRects, const void* buffer) OVERRIDE; - virtual void OnCursorChange(CefRefPtr browser, CefCursorHandle cursor) OVERRIDE; + virtual DECL bool GetViewRect(CefRefPtr browser, CefRect& rect) OVERRIDE; + virtual DECL bool GetScreenRect(CefRefPtr browser, CefRect& rect) OVERRIDE; + virtual DECL bool GetScreenPoint(CefRefPtr browser, int viewX, int viewY, int& screenX, int& screenY) OVERRIDE; + //virtual DECL void OnPopupShow(CefRefPtr browser, bool show) OVERRIDE; + //virtual DECL void OnPopupSize(CefRefPtr browser, const CefRect& rect) OVERRIDE; + virtual DECL void OnPaint(CefRefPtr browser, PaintElementType type, const RectList& dirtyRects, const void* buffer) OVERRIDE; + virtual DECL void OnCursorChange(CefRefPtr browser, CefCursorHandle cursor) OVERRIDE; IMPLEMENT_LOCKING(OffscreenClientAdapter); IMPLEMENT_REFCOUNTING(OffscreenClientAdapter); diff --git a/CefSharp/ScriptCore.cpp b/CefSharp/ScriptCore.cpp index 10a413b3f..b8f26d4f0 100644 --- a/CefSharp/ScriptCore.cpp +++ b/CefSharp/ScriptCore.cpp @@ -47,47 +47,45 @@ namespace CefSharp SetEvent(_event); } - void ScriptCore::Execute(CefRefPtr frame, String^ script) + void ScriptCore::Execute(CefRefPtr frame, CefString script) { if (CefCurrentlyOn(TID_UI)) { - UIT_Execute(frame, toNative(script)); + UIT_Execute(frame, script); } else { CefPostTask(TID_UI, NewCefRunnableMethod(this, &ScriptCore::UIT_Execute, - frame, toNative(script))); + frame, script)); } } - String^ ScriptCore::Evaluate(CefRefPtr frame, String^ script, TimeSpan timeout) + CefString ScriptCore::Evaluate(CefRefPtr frame, CefString script, int timeout) { AutoLock lock_scope(this); if (CefCurrentlyOn(TID_UI)) { - UIT_Evaluate(frame, toNative(script)); + UIT_Evaluate(frame, script); } else { CefPostTask(TID_UI, NewCefRunnableMethod(this, &ScriptCore::UIT_Evaluate, - frame, toNative(script))); + frame, script)); - if (WaitForSingleObject(_event, timeout.TotalMilliseconds)) + if (WaitForSingleObject(_event, timeout)) { throw gcnew ScriptException("Script timed out"); } } - String^ result = toClr(_result); - if (!_success) { - throw gcnew ScriptException(result); + throw gcnew ScriptException(toClr(_result)); } else { - return result; + return _result; } } } \ No newline at end of file diff --git a/CefSharp/ScriptCore.h b/CefSharp/ScriptCore.h index a22bb19c2..b689c7ff8 100644 --- a/CefSharp/ScriptCore.h +++ b/CefSharp/ScriptCore.h @@ -20,8 +20,8 @@ namespace CefSharp _event = CreateEvent(NULL, FALSE, FALSE, NULL); } - void Execute(CefRefPtr frame, String^ script); - String^ Evaluate(CefRefPtr frame, String^ script, TimeSpan timeout); + DECL void Execute(CefRefPtr frame, CefString script); + DECL CefString Evaluate(CefRefPtr frame, CefString script, int timeout); IMPLEMENT_LOCKING(ScriptCore); IMPLEMENT_REFCOUNTING(ScriptCore); diff --git a/CefSharp/Stdafx.h b/CefSharp/Stdafx.h index 81eef074b..0b1d5b797 100644 --- a/CefSharp/Stdafx.h +++ b/CefSharp/Stdafx.h @@ -1,5 +1,11 @@ #pragma once +#ifdef EXPORT + #define DECL __declspec(dllexport) +#else + #define DECL __declspec(dllimport) +#endif + #include #include "cef.h" #include "MCefRefPtr.h"