Actually allow using wxWebVieWIE-specific methods for setting the
emulation level.

Make it possible to include wx/msw/webvieW_ie.h by removing inclusion of
the private headers from it, which was in turn achieved by moving all
the implementation details into a private class.

See https://github.com/wxWidgets/wxWidgets/pull/1647
This commit is contained in:
Vadim Zeitlin
2019-11-14 17:26:00 +01:00
15 changed files with 430 additions and 394 deletions

View File

@@ -2260,11 +2260,8 @@ COND_PLATFORM_WIN32_1_GTK_PLATFORM_HDR = \
@COND_TOOLKIT_GTK@WEBVIEW_HDR_PLATFORM = \ @COND_TOOLKIT_GTK@WEBVIEW_HDR_PLATFORM = \
@COND_TOOLKIT_GTK@ wx/gtk/webviewhistoryitem_webkit.h \ @COND_TOOLKIT_GTK@ wx/gtk/webviewhistoryitem_webkit.h \
@COND_TOOLKIT_GTK@ wx/gtk/webview_webkit.h @COND_TOOLKIT_GTK@ wx/gtk/webview_webkit.h
COND_TOOLKIT_MSW_WEBVIEW_HDR_PLATFORM = \ @COND_TOOLKIT_MSW@WEBVIEW_HDR_PLATFORM = \
wx/msw/webviewhistoryitem_ie.h \ @COND_TOOLKIT_MSW@ wx/msw/webviewhistoryitem_ie.h wx/msw/webview_ie.h
wx/msw/webview_ie.h \
wx/msw/webview_missing.h
@COND_TOOLKIT_MSW@WEBVIEW_HDR_PLATFORM = $(COND_TOOLKIT_MSW_WEBVIEW_HDR_PLATFORM)
@COND_TOOLKIT_COCOA@OPENGL_HDR_PLATFORM = wx/cocoa/glcanvas.h @COND_TOOLKIT_COCOA@OPENGL_HDR_PLATFORM = wx/cocoa/glcanvas.h
@COND_TOOLKIT_GTK_TOOLKIT_VERSION_@OPENGL_HDR_PLATFORM \ @COND_TOOLKIT_GTK_TOOLKIT_VERSION_@OPENGL_HDR_PLATFORM \
@COND_TOOLKIT_GTK_TOOLKIT_VERSION_@ = wx/gtk1/glcanvas.h wx/unix/glx11.h @COND_TOOLKIT_GTK_TOOLKIT_VERSION_@ = wx/gtk1/glcanvas.h wx/unix/glx11.h

View File

@@ -3034,7 +3034,6 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
<if cond="TOOLKIT=='MSW'"> <if cond="TOOLKIT=='MSW'">
wx/msw/webviewhistoryitem_ie.h wx/msw/webviewhistoryitem_ie.h
wx/msw/webview_ie.h wx/msw/webview_ie.h
wx/msw/webview_missing.h
</if> </if>
<if cond="TOOLKIT=='GTK'"> <if cond="TOOLKIT=='GTK'">
wx/gtk/webviewhistoryitem_webkit.h wx/gtk/webviewhistoryitem_webkit.h

View File

@@ -2844,7 +2844,6 @@ set(WEBVIEW_CMN_SRC
set(WEBVIEW_MSW_HDR set(WEBVIEW_MSW_HDR
wx/msw/webviewhistoryitem_ie.h wx/msw/webviewhistoryitem_ie.h
wx/msw/webview_ie.h wx/msw/webview_ie.h
wx/msw/webview_missing.h
) )
set(WEBVIEW_CMN_HDR set(WEBVIEW_CMN_HDR

View File

@@ -2794,7 +2794,6 @@ WEBVIEW_CMN_SRC =
WEBVIEW_MSW_HDR = WEBVIEW_MSW_HDR =
wx/msw/webviewhistoryitem_ie.h wx/msw/webviewhistoryitem_ie.h
wx/msw/webview_ie.h wx/msw/webview_ie.h
wx/msw/webview_missing.h
WEBVIEW_CMN_HDR = WEBVIEW_CMN_HDR =
wx/webview.h wx/webview.h
wx/webviewarchivehandler.h wx/webviewarchivehandler.h

View File

@@ -1796,9 +1796,6 @@
<File <File
RelativePath="..\..\include\wx\msw\webview_ie.h"> RelativePath="..\..\include\wx\msw\webview_ie.h">
</File> </File>
<File
RelativePath="..\..\include\wx\msw\webview_missing.h">
</File>
<File <File
RelativePath="..\..\include\wx\msw\webviewhistoryitem_ie.h"> RelativePath="..\..\include\wx\msw\webviewhistoryitem_ie.h">
</File> </File>

View File

@@ -424,9 +424,6 @@
<File <File
RelativePath="..\..\include\wx\msw\webview_ie.h"> RelativePath="..\..\include\wx\msw\webview_ie.h">
</File> </File>
<File
RelativePath="..\..\include\wx\msw\webview_missing.h">
</File>
<File <File
RelativePath="..\..\include\wx\msw\webviewhistoryitem_ie.h"> RelativePath="..\..\include\wx\msw\webviewhistoryitem_ie.h">
</File> </File>

View File

@@ -2897,10 +2897,6 @@
RelativePath="..\..\include\wx\msw\webview_ie.h" RelativePath="..\..\include\wx\msw\webview_ie.h"
> >
</File> </File>
<File
RelativePath="..\..\include\wx\msw\webview_missing.h"
>
</File>
<File <File
RelativePath="..\..\include\wx\msw\webviewhistoryitem_ie.h" RelativePath="..\..\include\wx\msw\webviewhistoryitem_ie.h"
> >

View File

@@ -1068,10 +1068,6 @@
RelativePath="..\..\include\wx\msw\webview_ie.h" RelativePath="..\..\include\wx\msw\webview_ie.h"
> >
</File> </File>
<File
RelativePath="..\..\include\wx\msw\webview_missing.h"
>
</File>
<File <File
RelativePath="..\..\include\wx\msw\webviewhistoryitem_ie.h" RelativePath="..\..\include\wx\msw\webviewhistoryitem_ie.h"
> >

View File

@@ -2893,10 +2893,6 @@
RelativePath="..\..\include\wx\msw\webview_ie.h" RelativePath="..\..\include\wx\msw\webview_ie.h"
> >
</File> </File>
<File
RelativePath="..\..\include\wx\msw\webview_missing.h"
>
</File>
<File <File
RelativePath="..\..\include\wx\msw\webviewhistoryitem_ie.h" RelativePath="..\..\include\wx\msw\webviewhistoryitem_ie.h"
> >

View File

@@ -1064,10 +1064,6 @@
RelativePath="..\..\include\wx\msw\webview_ie.h" RelativePath="..\..\include\wx\msw\webview_ie.h"
> >
</File> </File>
<File
RelativePath="..\..\include\wx\msw\webview_missing.h"
>
</File>
<File <File
RelativePath="..\..\include\wx\msw\webviewhistoryitem_ie.h" RelativePath="..\..\include\wx\msw\webviewhistoryitem_ie.h"
> >

View File

@@ -0,0 +1,219 @@
/////////////////////////////////////////////////////////////////////////////
// Name: include/wx/msw/private/webview_ie.h
// Purpose: wxMSW IE wxWebView backend private classes
// Author: Marianne Gagnon
// Copyright: (c) 2010 Marianne Gagnon, 2011 Steven Lamerton
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef wxWebViewIE_PRIVATE_H
#define wxWebViewIE_PRIVATE_H
#include "wx/msw/ole/automtn.h"
#include "wx/msw/private/comptr.h"
#include "wx/msw/private/webview_missing.h"
class ClassFactory;
class wxIEContainer;
class DocHostUIHandler;
class wxFindPointers;
class wxWebViewIEImpl
{
public:
explicit wxWebViewIEImpl(wxWebViewIE* webview);
~wxWebViewIEImpl();
bool Create();
wxWebViewIE* m_webview;
wxIEContainer* m_container;
wxAutomationObject m_ie;
IWebBrowser2* m_webBrowser;
wxCOMPtr<DocHostUIHandler> m_uiHandler;
//We store the current zoom type;
wxWebViewZoomType m_zoomType;
/** The "Busy" property of IWebBrowser2 does not always return busy when
* we'd want it to; this variable may be set to true in cases where the
* Busy property is false but should be true.
*/
bool m_isBusy;
//We manage our own history, the history list contains the history items
//which are added as documentcomplete events arrive, unless we are loading
//an item from the history. The position is stored as an int, and reflects
//where we are in the history list.
wxVector<wxSharedPtr<wxWebViewHistoryItem> > m_historyList;
wxVector<ClassFactory*> m_factories;
int m_historyPosition;
bool m_historyLoadingFromList;
bool m_historyEnabled;
//We store find flag, results and position.
wxVector<wxFindPointers> m_findPointers;
int m_findFlags;
wxString m_findText;
int m_findPosition;
//Generic helper functions
bool CanExecCommand(wxString command) const;
void ExecCommand(wxString command);
wxCOMPtr<IHTMLDocument2> GetDocument() const;
bool IsElementVisible(wxCOMPtr<IHTMLElement> elm);
//Find helper functions.
long Find(const wxString& text, int flags = wxWEBVIEW_FIND_DEFAULT);
void FindInternal(const wxString& text, int flags, int internal_flag);
long FindNext(int direction = 1);
void FindClear();
//Toggles control features see INTERNETFEATURELIST for values.
bool EnableControlFeature(long flag, bool enable = true);
wxDECLARE_NO_COPY_CLASS(wxWebViewIEImpl);
};
class VirtualProtocol : public wxIInternetProtocol
{
protected:
wxIInternetProtocolSink* m_protocolSink;
wxString m_html;
VOID * fileP;
wxFSFile* m_file;
wxSharedPtr<wxWebViewHandler> m_handler;
public:
VirtualProtocol(wxSharedPtr<wxWebViewHandler> handler);
virtual ~VirtualProtocol() {}
//IUnknown
DECLARE_IUNKNOWN_METHODS;
//IInternetProtocolRoot
HRESULT STDMETHODCALLTYPE Abort(HRESULT WXUNUSED(hrReason),
DWORD WXUNUSED(dwOptions)) wxOVERRIDE
{ return E_NOTIMPL; }
HRESULT STDMETHODCALLTYPE Continue(wxPROTOCOLDATA *WXUNUSED(pProtocolData)) wxOVERRIDE
{ return S_OK; }
HRESULT STDMETHODCALLTYPE Resume() wxOVERRIDE { return S_OK; }
HRESULT STDMETHODCALLTYPE Start(LPCWSTR szUrl,
wxIInternetProtocolSink *pOIProtSink,
wxIInternetBindInfo *pOIBindInfo,
DWORD grfPI,
HANDLE_PTR dwReserved) wxOVERRIDE;
HRESULT STDMETHODCALLTYPE Suspend() wxOVERRIDE { return S_OK; }
HRESULT STDMETHODCALLTYPE Terminate(DWORD WXUNUSED(dwOptions)) wxOVERRIDE { return S_OK; }
//IInternetProtocol
HRESULT STDMETHODCALLTYPE LockRequest(DWORD WXUNUSED(dwOptions)) wxOVERRIDE
{ return S_OK; }
HRESULT STDMETHODCALLTYPE Read(void *pv, ULONG cb, ULONG *pcbRead) wxOVERRIDE;
HRESULT STDMETHODCALLTYPE Seek(LARGE_INTEGER WXUNUSED(dlibMove),
DWORD WXUNUSED(dwOrigin),
ULARGE_INTEGER* WXUNUSED(plibNewPosition)) wxOVERRIDE
{ return E_FAIL; }
HRESULT STDMETHODCALLTYPE UnlockRequest() wxOVERRIDE { return S_OK; }
};
class ClassFactory : public IClassFactory
{
public:
ClassFactory(wxSharedPtr<wxWebViewHandler> handler) : m_handler(handler)
{ AddRef(); }
virtual ~ClassFactory() {}
wxString GetName() { return m_handler->GetName(); }
//IClassFactory
HRESULT STDMETHODCALLTYPE CreateInstance(IUnknown* pUnkOuter,
REFIID riid, void** ppvObject) wxOVERRIDE;
HRESULT STDMETHODCALLTYPE LockServer(BOOL fLock) wxOVERRIDE;
//IUnknown
DECLARE_IUNKNOWN_METHODS;
private:
wxSharedPtr<wxWebViewHandler> m_handler;
};
class wxIEContainer : public wxActiveXContainer
{
public:
wxIEContainer(wxWindow *parent, REFIID iid, IUnknown *pUnk, DocHostUIHandler* uiHandler = NULL);
virtual ~wxIEContainer();
virtual bool QueryClientSiteInterface(REFIID iid, void **_interface, const char *&desc) wxOVERRIDE;
private:
DocHostUIHandler* m_uiHandler;
};
class DocHostUIHandler : public wxIDocHostUIHandler
{
public:
DocHostUIHandler(wxWebView* browser) { m_browser = browser; }
virtual ~DocHostUIHandler() {}
virtual HRESULT wxSTDCALL ShowContextMenu(DWORD dwID, POINT *ppt,
IUnknown *pcmdtReserved,
IDispatch *pdispReserved) wxOVERRIDE;
virtual HRESULT wxSTDCALL GetHostInfo(DOCHOSTUIINFO *pInfo) wxOVERRIDE;
virtual HRESULT wxSTDCALL ShowUI(DWORD dwID,
IOleInPlaceActiveObject *pActiveObject,
IOleCommandTarget *pCommandTarget,
IOleInPlaceFrame *pFrame,
IOleInPlaceUIWindow *pDoc) wxOVERRIDE;
virtual HRESULT wxSTDCALL HideUI(void) wxOVERRIDE;
virtual HRESULT wxSTDCALL UpdateUI(void) wxOVERRIDE;
virtual HRESULT wxSTDCALL EnableModeless(BOOL fEnable) wxOVERRIDE;
virtual HRESULT wxSTDCALL OnDocWindowActivate(BOOL fActivate) wxOVERRIDE;
virtual HRESULT wxSTDCALL OnFrameWindowActivate(BOOL fActivate) wxOVERRIDE;
virtual HRESULT wxSTDCALL ResizeBorder(LPCRECT prcBorder,
IOleInPlaceUIWindow *pUIWindow,
BOOL fRameWindow) wxOVERRIDE;
virtual HRESULT wxSTDCALL TranslateAccelerator(LPMSG lpMsg,
const GUID *pguidCmdGroup,
DWORD nCmdID) wxOVERRIDE;
virtual HRESULT wxSTDCALL GetOptionKeyPath(LPOLESTR *pchKey,
DWORD dw) wxOVERRIDE;
virtual HRESULT wxSTDCALL GetDropTarget(IDropTarget *pDropTarget,
IDropTarget **ppDropTarget) wxOVERRIDE;
virtual HRESULT wxSTDCALL GetExternal(IDispatch **ppDispatch) wxOVERRIDE;
virtual HRESULT wxSTDCALL TranslateUrl(DWORD dwTranslate,
OLECHAR *pchURLIn,
OLECHAR **ppchURLOut) wxOVERRIDE;
virtual HRESULT wxSTDCALL FilterDataObject(IDataObject *pDO,
IDataObject **ppDORet) wxOVERRIDE;
//IUnknown
DECLARE_IUNKNOWN_METHODS;
private:
wxWebView* m_browser;
};
class wxFindPointers
{
public:
wxFindPointers(wxIMarkupPointer *ptrBegin, wxIMarkupPointer *ptrEnd)
{
begin = ptrBegin;
end = ptrEnd;
}
//The two markup pointers.
wxIMarkupPointer *begin, *end;
};
#endif // wxWebViewIE_PRIVATE_H

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: include/wx/msw/webview_missing.h // Name: include/wx/msw/private/webview_missing.h
// Purpose: Definitions / classes commonly missing used by wxWebViewIE // Purpose: Definitions / classes commonly missing used by wxWebViewIE
// Author: Steven Lamerton // Author: Steven Lamerton
// Copyright: (c) 2012 Steven Lamerton // Copyright: (c) 2012 Steven Lamerton

View File

@@ -13,28 +13,10 @@
#if wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE && defined(__WXMSW__) #if wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE && defined(__WXMSW__)
#include "wx/control.h"
#include "wx/webview.h" #include "wx/webview.h"
#include "wx/msw/ole/automtn.h"
#include "wx/msw/ole/activex.h" #include "wx/msw/ole/activex.h"
#include "wx/msw/ole/oleutils.h"
#include "wx/msw/private/comptr.h"
#include "wx/msw/wrapwin.h"
#include "wx/msw/missing.h"
#include "wx/msw/webview_missing.h"
#include "wx/sharedptr.h"
#include "wx/vector.h"
#include "wx/msw/private.h"
struct IHTMLDocument2; class wxWebViewIEImpl;
struct IHTMLElement;
struct IMarkupPointer;
class wxFSFile;
class ClassFactory;
class wxIEContainer;
class DocHostUIHandler;
class wxFindPointers;
class wxIInternetProtocol;
// Note that the highest emulation level may be used even when the // Note that the highest emulation level may be used even when the
// corresponding browser version is not installed. // corresponding browser version is not installed.
@@ -152,7 +134,7 @@ public:
//Virtual Filesystem Support //Virtual Filesystem Support
virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler) wxOVERRIDE; virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler) wxOVERRIDE;
virtual void* GetNativeBackend() const wxOVERRIDE { return m_webBrowser; } virtual void* GetNativeBackend() const wxOVERRIDE;
// ---- IE-specific methods // ---- IE-specific methods
@@ -189,46 +171,7 @@ protected:
virtual void DoSetPage(const wxString& html, const wxString& baseUrl) wxOVERRIDE; virtual void DoSetPage(const wxString& html, const wxString& baseUrl) wxOVERRIDE;
private: private:
wxIEContainer* m_container; wxWebViewIEImpl* m_impl;
wxAutomationObject m_ie;
IWebBrowser2* m_webBrowser;
wxCOMPtr<DocHostUIHandler> m_uiHandler;
//We store the current zoom type;
wxWebViewZoomType m_zoomType;
/** The "Busy" property of IWebBrowser2 does not always return busy when
* we'd want it to; this variable may be set to true in cases where the
* Busy property is false but should be true.
*/
bool m_isBusy;
//We manage our own history, the history list contains the history items
//which are added as documentcomplete events arrive, unless we are loading
//an item from the history. The position is stored as an int, and reflects
//where we are in the history list.
wxVector<wxSharedPtr<wxWebViewHistoryItem> > m_historyList;
wxVector<ClassFactory*> m_factories;
int m_historyPosition;
bool m_historyLoadingFromList;
bool m_historyEnabled;
//We store find flag, results and position.
wxVector<wxFindPointers> m_findPointers;
int m_findFlags;
wxString m_findText;
int m_findPosition;
//Generic helper functions
bool CanExecCommand(wxString command) const;
void ExecCommand(wxString command);
wxCOMPtr<IHTMLDocument2> GetDocument() const;
bool IsElementVisible(wxCOMPtr<IHTMLElement> elm);
//Find helper functions.
void FindInternal(const wxString& text, int flags, int internal_flag);
long FindNext(int direction = 1);
void FindClear();
//Toggles control features see INTERNETFEATURELIST for values.
bool EnableControlFeature(long flag, bool enable = true);
wxDECLARE_DYNAMIC_CLASS(wxWebViewIE); wxDECLARE_DYNAMIC_CLASS(wxWebViewIE);
}; };
@@ -247,149 +190,6 @@ public:
{ return new wxWebViewIE(parent, id, url, pos, size, style, name); } { return new wxWebViewIE(parent, id, url, pos, size, style, name); }
}; };
class VirtualProtocol : public wxIInternetProtocol
{
protected:
wxIInternetProtocolSink* m_protocolSink;
wxString m_html;
VOID * fileP;
wxFSFile* m_file;
wxSharedPtr<wxWebViewHandler> m_handler;
public:
VirtualProtocol(wxSharedPtr<wxWebViewHandler> handler);
virtual ~VirtualProtocol() {}
//IUnknown
DECLARE_IUNKNOWN_METHODS;
//IInternetProtocolRoot
HRESULT STDMETHODCALLTYPE Abort(HRESULT WXUNUSED(hrReason),
DWORD WXUNUSED(dwOptions)) wxOVERRIDE
{ return E_NOTIMPL; }
HRESULT STDMETHODCALLTYPE Continue(wxPROTOCOLDATA *WXUNUSED(pProtocolData)) wxOVERRIDE
{ return S_OK; }
HRESULT STDMETHODCALLTYPE Resume() wxOVERRIDE { return S_OK; }
HRESULT STDMETHODCALLTYPE Start(LPCWSTR szUrl,
wxIInternetProtocolSink *pOIProtSink,
wxIInternetBindInfo *pOIBindInfo,
DWORD grfPI,
HANDLE_PTR dwReserved) wxOVERRIDE;
HRESULT STDMETHODCALLTYPE Suspend() wxOVERRIDE { return S_OK; }
HRESULT STDMETHODCALLTYPE Terminate(DWORD WXUNUSED(dwOptions)) wxOVERRIDE { return S_OK; }
//IInternetProtocol
HRESULT STDMETHODCALLTYPE LockRequest(DWORD WXUNUSED(dwOptions)) wxOVERRIDE
{ return S_OK; }
HRESULT STDMETHODCALLTYPE Read(void *pv, ULONG cb, ULONG *pcbRead) wxOVERRIDE;
HRESULT STDMETHODCALLTYPE Seek(LARGE_INTEGER WXUNUSED(dlibMove),
DWORD WXUNUSED(dwOrigin),
ULARGE_INTEGER* WXUNUSED(plibNewPosition)) wxOVERRIDE
{ return E_FAIL; }
HRESULT STDMETHODCALLTYPE UnlockRequest() wxOVERRIDE { return S_OK; }
};
class ClassFactory : public IClassFactory
{
public:
ClassFactory(wxSharedPtr<wxWebViewHandler> handler) : m_handler(handler)
{ AddRef(); }
virtual ~ClassFactory() {}
wxString GetName() { return m_handler->GetName(); }
//IClassFactory
HRESULT STDMETHODCALLTYPE CreateInstance(IUnknown* pUnkOuter,
REFIID riid, void** ppvObject) wxOVERRIDE;
HRESULT STDMETHODCALLTYPE LockServer(BOOL fLock) wxOVERRIDE;
//IUnknown
DECLARE_IUNKNOWN_METHODS;
private:
wxSharedPtr<wxWebViewHandler> m_handler;
};
class wxIEContainer : public wxActiveXContainer
{
public:
wxIEContainer(wxWindow *parent, REFIID iid, IUnknown *pUnk, DocHostUIHandler* uiHandler = NULL);
virtual ~wxIEContainer();
virtual bool QueryClientSiteInterface(REFIID iid, void **_interface, const char *&desc) wxOVERRIDE;
private:
DocHostUIHandler* m_uiHandler;
};
class DocHostUIHandler : public wxIDocHostUIHandler
{
public:
DocHostUIHandler(wxWebView* browser) { m_browser = browser; }
virtual ~DocHostUIHandler() {}
virtual HRESULT wxSTDCALL ShowContextMenu(DWORD dwID, POINT *ppt,
IUnknown *pcmdtReserved,
IDispatch *pdispReserved) wxOVERRIDE;
virtual HRESULT wxSTDCALL GetHostInfo(DOCHOSTUIINFO *pInfo) wxOVERRIDE;
virtual HRESULT wxSTDCALL ShowUI(DWORD dwID,
IOleInPlaceActiveObject *pActiveObject,
IOleCommandTarget *pCommandTarget,
IOleInPlaceFrame *pFrame,
IOleInPlaceUIWindow *pDoc) wxOVERRIDE;
virtual HRESULT wxSTDCALL HideUI(void) wxOVERRIDE;
virtual HRESULT wxSTDCALL UpdateUI(void) wxOVERRIDE;
virtual HRESULT wxSTDCALL EnableModeless(BOOL fEnable) wxOVERRIDE;
virtual HRESULT wxSTDCALL OnDocWindowActivate(BOOL fActivate) wxOVERRIDE;
virtual HRESULT wxSTDCALL OnFrameWindowActivate(BOOL fActivate) wxOVERRIDE;
virtual HRESULT wxSTDCALL ResizeBorder(LPCRECT prcBorder,
IOleInPlaceUIWindow *pUIWindow,
BOOL fRameWindow) wxOVERRIDE;
virtual HRESULT wxSTDCALL TranslateAccelerator(LPMSG lpMsg,
const GUID *pguidCmdGroup,
DWORD nCmdID) wxOVERRIDE;
virtual HRESULT wxSTDCALL GetOptionKeyPath(LPOLESTR *pchKey,
DWORD dw) wxOVERRIDE;
virtual HRESULT wxSTDCALL GetDropTarget(IDropTarget *pDropTarget,
IDropTarget **ppDropTarget) wxOVERRIDE;
virtual HRESULT wxSTDCALL GetExternal(IDispatch **ppDispatch) wxOVERRIDE;
virtual HRESULT wxSTDCALL TranslateUrl(DWORD dwTranslate,
OLECHAR *pchURLIn,
OLECHAR **ppchURLOut) wxOVERRIDE;
virtual HRESULT wxSTDCALL FilterDataObject(IDataObject *pDO,
IDataObject **ppDORet) wxOVERRIDE;
//IUnknown
DECLARE_IUNKNOWN_METHODS;
private:
wxWebView* m_browser;
};
class wxFindPointers
{
public:
wxFindPointers(wxIMarkupPointer *ptrBegin, wxIMarkupPointer *ptrEnd)
{
begin = ptrBegin;
end = ptrEnd;
}
//The two markup pointers.
wxIMarkupPointer *begin, *end;
};
#endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE && defined(__WXMSW__) #endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE && defined(__WXMSW__)
#endif // wxWebViewIE_H #endif // wxWebViewIE_H

View File

@@ -267,6 +267,7 @@ public:
@section descriptions Backend Descriptions @section descriptions Backend Descriptions
@par wxWEBVIEW_BACKEND_IE (MSW) @par wxWEBVIEW_BACKEND_IE (MSW)
@anchor wxWEBVIEW_BACKEND_IE
The IE backend uses Microsoft's Trident rendering engine, specifically the The IE backend uses Microsoft's Trident rendering engine, specifically the
version used by the locally installed copy of Internet Explorer. As such it version used by the locally installed copy of Internet Explorer. As such it
@@ -514,56 +515,6 @@ public:
*/ */
virtual void Reload(wxWebViewReloadFlags flags = wxWEBVIEW_RELOAD_DEFAULT) = 0; virtual void Reload(wxWebViewReloadFlags flags = wxWEBVIEW_RELOAD_DEFAULT) = 0;
/**
Sets emulation level.
This function is useful to change the emulation level of
the system browser control used for wxWebView implementation under
MSW, rather than using the currently default, IE7-compatible, level.
Please notice that this function works by modifying the per-user part
of MSW registry, which has several implications: first, it is
sufficient to call it only once (per user) as the changes done by it
are persistent and, second, if you do not want them to be persistent,
you need to call it with @c wxWEBVIEWIE_EMU_DEFAULT argument explicitly.
In particular, this function should be called to allow RunScript() to
work for JavaScript code returning arbitrary objects, which is not
supported at the default emulation level.
If set to a level higher than installed version, the highest available
level will be used instead. @c wxWEBVIEWIE_EMU_IE11 is recommended for
best performance and experience.
This function is MSW-specific and doesn't exist under other platforms.
See https://msdn.microsoft.com/en-us/library/ee330730#browser_emulation
for more information about browser control emulation levels.
@param level the target emulation level
@return @true on success, @false on failure (a warning message is also
logged in the latter case).
@since 3.1.3
*/
static bool MSWSetEmulationLevel(wxWebViewIE_EmulationLevel level = wxWEBVIEWIE_EMU_IE11);
/**
@deprecated
This function is kept mostly for backwards compatibility.
Please explicitly specify emulation level with MSWSetEmulationLevel().
@param modernLevel @true to set level to IE8, synonym for @c wxWEBVIEWIE_EMU_IE8.
@false to reset the emulation level to its default,
synonym for @c wxWEBVIEWIE_EMU_DEFAULT.
@return @true on success, @false on failure (a warning message is also
logged in the latter case).
@since 3.1.1
*/
static bool MSWSetModernEmulationLevel(bool modernLevel = true);
/** /**
Runs the given JavaScript code. Runs the given JavaScript code.
@@ -904,6 +855,72 @@ public:
/**
@class wxWebViewIE
wxWebView using IE backend, see @ref wxWEBVIEW_BACKEND_IE.
@onlyfor{wxmsw}
@since 2.9.3
@library{wxwebview}
@category{ctrl,webview}
@see wxWebView
*/
class wxWebViewIE : public wxWebView
{
public:
/**
Sets emulation level.
This function is useful to change the emulation level of
the system browser control used for wxWebView implementation under
MSW, rather than using the currently default, IE7-compatible, level.
Please notice that this function works by modifying the per-user part
of MSW registry, which has several implications: first, it is
sufficient to call it only once (per user) as the changes done by it
are persistent and, second, if you do not want them to be persistent,
you need to call it with @c wxWEBVIEWIE_EMU_DEFAULT argument explicitly.
In particular, this function should be called to allow RunScript() to
work for JavaScript code returning arbitrary objects, which is not
supported at the default emulation level.
If set to a level higher than installed version, the highest available
level will be used instead. @c wxWEBVIEWIE_EMU_IE11 is recommended for
best performance and experience.
This function is MSW-specific and doesn't exist under other platforms.
See https://msdn.microsoft.com/en-us/library/ee330730#browser_emulation
for more information about browser control emulation levels.
@param level the target emulation level
@return @true on success, @false on failure (a warning message is also
logged in the latter case).
@since 3.1.3
*/
static bool MSWSetEmulationLevel(wxWebViewIE_EmulationLevel level = wxWEBVIEWIE_EMU_IE11);
/**
@deprecated
This function is kept mostly for backwards compatibility.
Please explicitly specify emulation level with MSWSetEmulationLevel().
@param modernLevel @true to set level to IE8, synonym for @c wxWEBVIEWIE_EMU_IE8.
@false to reset the emulation level to its default,
synonym for @c wxWEBVIEWIE_EMU_DEFAULT.
@return @true on success, @false on failure (a warning message is also
logged in the latter case).
@since 3.1.1
*/
static bool MSWSetModernEmulationLevel(bool modernLevel = true);
};
/** /**
@class wxWebViewEvent @class wxWebViewEvent

View File

@@ -17,22 +17,20 @@
#if wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE #if wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE
#include <olectl.h>
#include <oleidl.h>
#include <exdispid.h>
#include <exdisp.h>
#include <mshtml.h>
#include "wx/msw/registry.h" #include "wx/msw/registry.h"
#include "wx/msw/missing.h"
#include "wx/msw/ole/safearray.h" #include "wx/msw/ole/safearray.h"
#include "wx/filesys.h" #include "wx/filesys.h"
#include "wx/dynlib.h" #include "wx/dynlib.h"
#include "wx/scopeguard.h" #include "wx/scopeguard.h"
#include "wx/msw/missing.h"
#include "wx/msw/private.h"
#include "wx/msw/private/webview_ie.h"
#include "wx/private/jsscriptwrapper.h" #include "wx/private/jsscriptwrapper.h"
#include <initguid.h> #include <initguid.h>
#include <wininet.h> #include <exdispid.h>
#include <mshtml.h>
/* These GUID definitions are our own implementation to support interfaces /* These GUID definitions are our own implementation to support interfaces
* normally in urlmon.h. See include/wx/msw/webview_ie.h * normally in urlmon.h. See include/wx/msw/webview_ie.h
@@ -83,6 +81,25 @@ bool wxWebViewIE::Create(wxWindow* parent,
return false; return false;
} }
m_impl = new wxWebViewIEImpl(this);
if ( !m_impl->Create() )
return false;
// Make behaviour consistent with the other backends when loading localhost
// pages without any physical network connection.
SetOfflineMode(false);
LoadURL(url);
return true;
}
wxWebViewIEImpl::wxWebViewIEImpl(wxWebViewIE* webview)
: m_webview(webview)
{
}
bool wxWebViewIEImpl::Create()
{
m_webBrowser = NULL; m_webBrowser = NULL;
m_isBusy = false; m_isBusy = false;
m_historyLoadingFromList = false; m_historyLoadingFromList = false;
@@ -104,21 +121,21 @@ bool wxWebViewIE::Create(wxWindow* parent,
m_webBrowser->put_RegisterAsBrowser(VARIANT_TRUE); m_webBrowser->put_RegisterAsBrowser(VARIANT_TRUE);
m_webBrowser->put_RegisterAsDropTarget(VARIANT_TRUE); m_webBrowser->put_RegisterAsDropTarget(VARIANT_TRUE);
m_uiHandler = new DocHostUIHandler(this); m_uiHandler = new DocHostUIHandler(m_webview);
m_container = new wxIEContainer(this, IID_IWebBrowser2, m_webBrowser, m_uiHandler); m_container = new wxIEContainer(m_webview, IID_IWebBrowser2, m_webBrowser, m_uiHandler);
EnableControlFeature(21 /* FEATURE_DISABLE_NAVIGATION_SOUNDS */); EnableControlFeature(21 /* FEATURE_DISABLE_NAVIGATION_SOUNDS */);
// Make behaviour consistent with the other backends when loading localhost
// pages without any physical network connection.
SetOfflineMode(false);
LoadURL(url);
return true; return true;
} }
wxWebViewIE::~wxWebViewIE() wxWebViewIE::~wxWebViewIE()
{
delete m_impl;
}
wxWebViewIEImpl::~wxWebViewIEImpl()
{ {
wxDynamicLibrary urlMon(wxT("urlmon.dll")); wxDynamicLibrary urlMon(wxT("urlmon.dll"));
if(urlMon.HasSymbol(wxT("CoInternetGetSession"))) if(urlMon.HasSymbol(wxT("CoInternetGetSession")))
@@ -147,7 +164,7 @@ wxWebViewIE::~wxWebViewIE()
void wxWebViewIE::LoadURL(const wxString& url) void wxWebViewIE::LoadURL(const wxString& url)
{ {
m_ie.CallMethod("Navigate", wxConvertStringToOle(url)); m_impl->m_ie.CallMethod("Navigate", wxConvertStringToOle(url));
} }
namespace namespace
@@ -184,7 +201,7 @@ void wxWebViewIE::DoSetPage(const wxString& html, const wxString& baseUrl)
wxON_BLOCK_EXIT1(SafeArrayDestroy, psaStrings); wxON_BLOCK_EXIT1(SafeArrayDestroy, psaStrings);
wxCOMPtr<IHTMLDocument2> document(GetDocument()); wxCOMPtr<IHTMLDocument2> document(m_impl->GetDocument());
if(!document) if(!document)
return; return;
@@ -201,7 +218,7 @@ void wxWebViewIE::DoSetPage(const wxString& html, const wxString& baseUrl)
wxON_BLOCK_EXIT1(SafeArrayDestroy, psaStrings); wxON_BLOCK_EXIT1(SafeArrayDestroy, psaStrings);
wxCOMPtr<IHTMLDocument2> document(GetDocument()); wxCOMPtr<IHTMLDocument2> document(m_impl->GetDocument());
if(!document) if(!document)
return; return;
@@ -224,7 +241,7 @@ void wxWebViewIE::DoSetPage(const wxString& html, const wxString& baseUrl)
wxString wxWebViewIE::GetPageSource() const wxString wxWebViewIE::GetPageSource() const
{ {
wxCOMPtr<IHTMLDocument2> document(GetDocument()); wxCOMPtr<IHTMLDocument2> document(m_impl->GetDocument());
if(document) if(document)
{ {
@@ -252,7 +269,7 @@ wxString wxWebViewIE::GetPageSource() const
wxWebViewZoom wxWebViewIE::GetZoom() const wxWebViewZoom wxWebViewIE::GetZoom() const
{ {
switch( m_zoomType ) switch( m_impl->m_zoomType )
{ {
case wxWEBVIEW_ZOOM_TYPE_LAYOUT: case wxWEBVIEW_ZOOM_TYPE_LAYOUT:
return GetIEOpticalZoom(); return GetIEOpticalZoom();
@@ -269,7 +286,7 @@ wxWebViewZoom wxWebViewIE::GetZoom() const
void wxWebViewIE::SetZoom(wxWebViewZoom zoom) void wxWebViewIE::SetZoom(wxWebViewZoom zoom)
{ {
switch( m_zoomType ) switch( m_impl->m_zoomType )
{ {
case wxWEBVIEW_ZOOM_TYPE_LAYOUT: case wxWEBVIEW_ZOOM_TYPE_LAYOUT:
SetIEOpticalZoom(zoom); SetIEOpticalZoom(zoom);
@@ -295,9 +312,9 @@ void wxWebViewIE::SetIETextZoom(wxWebViewZoom level)
#if wxDEBUG_LEVEL #if wxDEBUG_LEVEL
HRESULT result = HRESULT result =
#endif #endif
m_webBrowser->ExecWB(OLECMDID_ZOOM, m_impl->m_webBrowser->ExecWB(OLECMDID_ZOOM,
OLECMDEXECOPT_DONTPROMPTUSER, OLECMDEXECOPT_DONTPROMPTUSER,
&zoomVariant, NULL); &zoomVariant, NULL);
wxASSERT(result == S_OK); wxASSERT(result == S_OK);
} }
@@ -310,9 +327,9 @@ wxWebViewZoom wxWebViewIE::GetIETextZoom() const
#if wxDEBUG_LEVEL #if wxDEBUG_LEVEL
HRESULT result = HRESULT result =
#endif #endif
m_webBrowser->ExecWB(OLECMDID_ZOOM, m_impl->m_webBrowser->ExecWB(OLECMDID_ZOOM,
OLECMDEXECOPT_DONTPROMPTUSER, OLECMDEXECOPT_DONTPROMPTUSER,
NULL, &zoomVariant); NULL, &zoomVariant);
wxASSERT(result == S_OK); wxASSERT(result == S_OK);
//We can safely cast here as we know that the range matches our enum //We can safely cast here as we know that the range matches our enum
@@ -352,10 +369,10 @@ void wxWebViewIE::SetIEOpticalZoom(wxWebViewZoom level)
#if wxDEBUG_LEVEL #if wxDEBUG_LEVEL
HRESULT result = HRESULT result =
#endif #endif
m_webBrowser->ExecWB((OLECMDID)63 /*OLECMDID_OPTICAL_ZOOM*/, m_impl->m_webBrowser->ExecWB((OLECMDID)63 /*OLECMDID_OPTICAL_ZOOM*/,
OLECMDEXECOPT_DODEFAULT, OLECMDEXECOPT_DODEFAULT,
&zoomVariant, &zoomVariant,
NULL); NULL);
wxASSERT(result == S_OK); wxASSERT(result == S_OK);
} }
@@ -368,9 +385,9 @@ wxWebViewZoom wxWebViewIE::GetIEOpticalZoom() const
#if wxDEBUG_LEVEL #if wxDEBUG_LEVEL
HRESULT result = HRESULT result =
#endif #endif
m_webBrowser->ExecWB((OLECMDID)63 /*OLECMDID_OPTICAL_ZOOM*/, m_impl->m_webBrowser->ExecWB((OLECMDID)63 /*OLECMDID_OPTICAL_ZOOM*/,
OLECMDEXECOPT_DODEFAULT, NULL, OLECMDEXECOPT_DODEFAULT, NULL,
&zoomVariant); &zoomVariant);
wxASSERT(result == S_OK); wxASSERT(result == S_OK);
const int zoom = V_I4(&zoomVariant); const int zoom = V_I4(&zoomVariant);
@@ -400,12 +417,12 @@ wxWebViewZoom wxWebViewIE::GetIEOpticalZoom() const
void wxWebViewIE::SetZoomType(wxWebViewZoomType type) void wxWebViewIE::SetZoomType(wxWebViewZoomType type)
{ {
m_zoomType = type; m_impl->m_zoomType = type;
} }
wxWebViewZoomType wxWebViewIE::GetZoomType() const wxWebViewZoomType wxWebViewIE::GetZoomType() const
{ {
return m_zoomType; return m_impl->m_zoomType;
} }
bool wxWebViewIE::CanSetZoomType(wxWebViewZoomType type) const bool wxWebViewIE::CanSetZoomType(wxWebViewZoomType type) const
@@ -425,22 +442,23 @@ bool wxWebViewIE::CanSetZoomType(wxWebViewZoomType type) const
void wxWebViewIE::Print() void wxWebViewIE::Print()
{ {
m_webBrowser->ExecWB(OLECMDID_PRINTPREVIEW, m_impl->m_webBrowser->ExecWB(OLECMDID_PRINTPREVIEW,
OLECMDEXECOPT_DODEFAULT, NULL, NULL); OLECMDEXECOPT_DODEFAULT, NULL, NULL);
} }
bool wxWebViewIE::CanGoBack() const bool wxWebViewIE::CanGoBack() const
{ {
if(m_historyEnabled) if(m_impl->m_historyEnabled)
return m_historyPosition > 0; return m_impl->m_historyPosition > 0;
else else
return false; return false;
} }
bool wxWebViewIE::CanGoForward() const bool wxWebViewIE::CanGoForward() const
{ {
if(m_historyEnabled) if(m_impl->m_historyEnabled)
return m_historyPosition != static_cast<int>(m_historyList.size()) - 1; return m_impl->m_historyPosition !=
static_cast<int>(m_impl->m_historyList.size()) - 1;
else else
return false; return false;
} }
@@ -448,17 +466,17 @@ bool wxWebViewIE::CanGoForward() const
void wxWebViewIE::LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem> item) void wxWebViewIE::LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem> item)
{ {
int pos = -1; int pos = -1;
for(unsigned int i = 0; i < m_historyList.size(); i++) for(unsigned int i = 0; i < m_impl->m_historyList.size(); i++)
{ {
//We compare the actual pointers to find the correct item //We compare the actual pointers to find the correct item
if(m_historyList[i].get() == item.get()) if(m_impl->m_historyList[i].get() == item.get())
pos = i; pos = i;
} }
wxASSERT_MSG(pos != static_cast<int>(m_historyList.size()), wxASSERT_MSG(pos != static_cast<int>(m_impl->m_historyList.size()),
"invalid history item"); "invalid history item");
m_historyLoadingFromList = true; m_impl->m_historyLoadingFromList = true;
LoadURL(item->GetUrl()); LoadURL(item->GetUrl());
m_historyPosition = pos; m_impl->m_historyPosition = pos;
} }
wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewIE::GetBackwardHistory() wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewIE::GetBackwardHistory()
@@ -466,9 +484,9 @@ wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewIE::GetBackwardHistory()
wxVector<wxSharedPtr<wxWebViewHistoryItem> > backhist; wxVector<wxSharedPtr<wxWebViewHistoryItem> > backhist;
//As we don't have std::copy or an iterator constructor in the wxwidgets //As we don't have std::copy or an iterator constructor in the wxwidgets
//native vector we construct it by hand //native vector we construct it by hand
for(int i = 0; i < m_historyPosition; i++) for(int i = 0; i < m_impl->m_historyPosition; i++)
{ {
backhist.push_back(m_historyList[i]); backhist.push_back(m_impl->m_historyList[i]);
} }
return backhist; return backhist;
} }
@@ -478,39 +496,39 @@ wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewIE::GetForwardHistory()
wxVector<wxSharedPtr<wxWebViewHistoryItem> > forwardhist; wxVector<wxSharedPtr<wxWebViewHistoryItem> > forwardhist;
//As we don't have std::copy or an iterator constructor in the wxwidgets //As we don't have std::copy or an iterator constructor in the wxwidgets
//native vector we construct it by hand //native vector we construct it by hand
for(int i = m_historyPosition + 1; i < static_cast<int>(m_historyList.size()); i++) for(int i = m_impl->m_historyPosition + 1; i < static_cast<int>(m_impl->m_historyList.size()); i++)
{ {
forwardhist.push_back(m_historyList[i]); forwardhist.push_back(m_impl->m_historyList[i]);
} }
return forwardhist; return forwardhist;
} }
void wxWebViewIE::GoBack() void wxWebViewIE::GoBack()
{ {
LoadHistoryItem(m_historyList[m_historyPosition - 1]); LoadHistoryItem(m_impl->m_historyList[m_impl->m_historyPosition - 1]);
} }
void wxWebViewIE::GoForward() void wxWebViewIE::GoForward()
{ {
LoadHistoryItem(m_historyList[m_historyPosition + 1]); LoadHistoryItem(m_impl->m_historyList[m_impl->m_historyPosition + 1]);
} }
void wxWebViewIE::Stop() void wxWebViewIE::Stop()
{ {
m_ie.CallMethod("Stop"); m_impl->m_ie.CallMethod("Stop");
} }
void wxWebViewIE::ClearHistory() void wxWebViewIE::ClearHistory()
{ {
m_historyList.clear(); m_impl->m_historyList.clear();
m_historyPosition = -1; m_impl->m_historyPosition = -1;
} }
void wxWebViewIE::EnableHistory(bool enable) void wxWebViewIE::EnableHistory(bool enable)
{ {
m_historyEnabled = enable; m_impl->m_historyEnabled = enable;
m_historyList.clear(); m_impl->m_historyList.clear();
m_historyPosition = -1; m_impl->m_historyPosition = -1;
} }
void wxWebViewIE::Reload(wxWebViewReloadFlags flags) void wxWebViewIE::Reload(wxWebViewReloadFlags flags)
@@ -531,12 +549,12 @@ void wxWebViewIE::Reload(wxWebViewReloadFlags flags)
wxFAIL_MSG("Unexpected reload type"); wxFAIL_MSG("Unexpected reload type");
} }
m_webBrowser->Refresh2(&level); m_impl->m_webBrowser->Refresh2(&level);
} }
bool wxWebViewIE::IsOfflineMode() bool wxWebViewIE::IsOfflineMode()
{ {
wxVariant out = m_ie.GetProperty("Offline"); wxVariant out = m_impl->m_ie.GetProperty("Offline");
wxASSERT(out.GetType() == "bool"); wxASSERT(out.GetType() == "bool");
@@ -548,17 +566,17 @@ void wxWebViewIE::SetOfflineMode(bool offline)
#if wxDEBUG_LEVEL #if wxDEBUG_LEVEL
const HRESULT success = const HRESULT success =
#endif #endif
m_ie.PutProperty("Offline", (offline ? m_impl->m_ie.PutProperty("Offline", (offline ?
VARIANT_TRUE : VARIANT_TRUE :
VARIANT_FALSE)); VARIANT_FALSE));
wxASSERT(SUCCEEDED(success)); wxASSERT(SUCCEEDED(success));
} }
bool wxWebViewIE::IsBusy() const bool wxWebViewIE::IsBusy() const
{ {
if (m_isBusy) return true; if (m_impl->m_isBusy) return true;
wxVariant out = m_ie.GetProperty("Busy"); wxVariant out = m_impl->m_ie.GetProperty("Busy");
wxASSERT(out.GetType() == "bool"); wxASSERT(out.GetType() == "bool");
@@ -567,7 +585,7 @@ bool wxWebViewIE::IsBusy() const
wxString wxWebViewIE::GetCurrentURL() const wxString wxWebViewIE::GetCurrentURL() const
{ {
wxVariant out = m_ie.GetProperty("LocationURL"); wxVariant out = m_impl->m_ie.GetProperty("LocationURL");
wxASSERT(out.GetType() == "string"); wxASSERT(out.GetType() == "string");
return out.GetString(); return out.GetString();
@@ -575,7 +593,7 @@ wxString wxWebViewIE::GetCurrentURL() const
wxString wxWebViewIE::GetCurrentTitle() const wxString wxWebViewIE::GetCurrentTitle() const
{ {
wxCOMPtr<IHTMLDocument2> document(GetDocument()); wxCOMPtr<IHTMLDocument2> document(m_impl->GetDocument());
wxString s; wxString s;
if(document) if(document)
@@ -590,60 +608,65 @@ wxString wxWebViewIE::GetCurrentTitle() const
bool wxWebViewIE::CanCut() const bool wxWebViewIE::CanCut() const
{ {
return CanExecCommand("Cut"); return m_impl->CanExecCommand("Cut");
} }
bool wxWebViewIE::CanCopy() const bool wxWebViewIE::CanCopy() const
{ {
return CanExecCommand("Copy"); return m_impl->CanExecCommand("Copy");
} }
bool wxWebViewIE::CanPaste() const bool wxWebViewIE::CanPaste() const
{ {
return CanExecCommand("Paste"); return m_impl->CanExecCommand("Paste");
} }
void wxWebViewIE::Cut() void wxWebViewIE::Cut()
{ {
ExecCommand("Cut"); m_impl->ExecCommand("Cut");
} }
void wxWebViewIE::Copy() void wxWebViewIE::Copy()
{ {
ExecCommand("Copy"); m_impl->ExecCommand("Copy");
} }
void wxWebViewIE::Paste() void wxWebViewIE::Paste()
{ {
ExecCommand("Paste"); m_impl->ExecCommand("Paste");
} }
bool wxWebViewIE::CanUndo() const bool wxWebViewIE::CanUndo() const
{ {
return CanExecCommand("Undo"); return m_impl->CanExecCommand("Undo");
} }
bool wxWebViewIE::CanRedo() const bool wxWebViewIE::CanRedo() const
{ {
return CanExecCommand("Redo"); return m_impl->CanExecCommand("Redo");
} }
void wxWebViewIE::Undo() void wxWebViewIE::Undo()
{ {
ExecCommand("Undo"); m_impl->ExecCommand("Undo");
} }
void wxWebViewIE::Redo() void wxWebViewIE::Redo()
{ {
ExecCommand("Redo"); m_impl->ExecCommand("Redo");
} }
long wxWebViewIE::Find(const wxString& text, int flags) long wxWebViewIE::Find(const wxString& text, int flags)
{
return m_impl->Find(text, flags);
}
long wxWebViewIEImpl::Find(const wxString& text, int flags)
{ {
//If the text is empty then we clear. //If the text is empty then we clear.
if(text.IsEmpty()) if(text.IsEmpty())
{ {
ClearSelection(); m_webview->ClearSelection();
if(m_findFlags & wxWEBVIEW_FIND_HIGHLIGHT_RESULT) if(m_findFlags & wxWEBVIEW_FIND_HIGHLIGHT_RESULT)
{ {
FindInternal(m_findText, (m_findFlags &~ wxWEBVIEW_FIND_HIGHLIGHT_RESULT), wxWEBVIEW_FIND_REMOVE_HIGHLIGHT); FindInternal(m_findText, (m_findFlags &~ wxWEBVIEW_FIND_HIGHLIGHT_RESULT), wxWEBVIEW_FIND_REMOVE_HIGHLIGHT);
@@ -677,7 +700,7 @@ long wxWebViewIE::Find(const wxString& text, int flags)
} }
//Reset find variables. //Reset find variables.
FindClear(); FindClear();
ClearSelection(); m_webview->ClearSelection();
m_findText = text; m_findText = text;
m_findFlags = flags; m_findFlags = flags;
//find the text and return wxNOT_FOUND if there are no matches. //find the text and return wxNOT_FOUND if there are no matches.
@@ -691,7 +714,7 @@ long wxWebViewIE::Find(const wxString& text, int flags)
void wxWebViewIE::SetEditable(bool enable) void wxWebViewIE::SetEditable(bool enable)
{ {
wxCOMPtr<IHTMLDocument2> document(GetDocument()); wxCOMPtr<IHTMLDocument2> document(m_impl->GetDocument());
if(document) if(document)
{ {
@@ -705,7 +728,7 @@ void wxWebViewIE::SetEditable(bool enable)
bool wxWebViewIE::IsEditable() const bool wxWebViewIE::IsEditable() const
{ {
wxCOMPtr<IHTMLDocument2> document(GetDocument()); wxCOMPtr<IHTMLDocument2> document(m_impl->GetDocument());
if(document) if(document)
{ {
@@ -721,12 +744,12 @@ bool wxWebViewIE::IsEditable() const
void wxWebViewIE::SelectAll() void wxWebViewIE::SelectAll()
{ {
ExecCommand("SelectAll"); m_impl->ExecCommand("SelectAll");
} }
bool wxWebViewIE::HasSelection() const bool wxWebViewIE::HasSelection() const
{ {
wxCOMPtr<IHTMLDocument2> document(GetDocument()); wxCOMPtr<IHTMLDocument2> document(m_impl->GetDocument());
if(document) if(document)
{ {
@@ -749,12 +772,12 @@ bool wxWebViewIE::HasSelection() const
void wxWebViewIE::DeleteSelection() void wxWebViewIE::DeleteSelection()
{ {
ExecCommand("Delete"); m_impl->ExecCommand("Delete");
} }
wxString wxWebViewIE::GetSelectedText() const wxString wxWebViewIE::GetSelectedText() const
{ {
wxCOMPtr<IHTMLDocument2> document(GetDocument()); wxCOMPtr<IHTMLDocument2> document(m_impl->GetDocument());
if(document) if(document)
{ {
@@ -787,7 +810,7 @@ wxString wxWebViewIE::GetSelectedText() const
wxString wxWebViewIE::GetSelectedSource() const wxString wxWebViewIE::GetSelectedSource() const
{ {
wxCOMPtr<IHTMLDocument2> document(GetDocument()); wxCOMPtr<IHTMLDocument2> document(m_impl->GetDocument());
if(document) if(document)
{ {
@@ -820,7 +843,7 @@ wxString wxWebViewIE::GetSelectedSource() const
void wxWebViewIE::ClearSelection() void wxWebViewIE::ClearSelection()
{ {
wxCOMPtr<IHTMLDocument2> document(GetDocument()); wxCOMPtr<IHTMLDocument2> document(m_impl->GetDocument());
if(document) if(document)
{ {
@@ -836,7 +859,7 @@ void wxWebViewIE::ClearSelection()
wxString wxWebViewIE::GetPageText() const wxString wxWebViewIE::GetPageText() const
{ {
wxCOMPtr<IHTMLDocument2> document(GetDocument()); wxCOMPtr<IHTMLDocument2> document(m_impl->GetDocument());
if(document) if(document)
{ {
@@ -903,7 +926,7 @@ bool CallEval(const wxString& code,
bool wxWebViewIE::RunScript(const wxString& javascript, wxString* output) bool wxWebViewIE::RunScript(const wxString& javascript, wxString* output)
{ {
wxCOMPtr<IHTMLDocument2> document(GetDocument()); wxCOMPtr<IHTMLDocument2> document(m_impl->GetDocument());
if ( !document ) if ( !document )
{ {
wxLogWarning(_("Can't run JavaScript script without a valid HTML document")); wxLogWarning(_("Can't run JavaScript script without a valid HTML document"));
@@ -976,7 +999,7 @@ void wxWebViewIE::RegisterHandler(wxSharedPtr<wxWebViewHandler> handler)
{ {
wxFAIL_MSG("Could not register protocol"); wxFAIL_MSG("Could not register protocol");
} }
m_factories.push_back(cf); m_impl->m_factories.push_back(cf);
} }
else else
{ {
@@ -984,7 +1007,12 @@ void wxWebViewIE::RegisterHandler(wxSharedPtr<wxWebViewHandler> handler)
} }
} }
bool wxWebViewIE::CanExecCommand(wxString command) const void* wxWebViewIE::GetNativeBackend() const
{
return m_impl->m_webBrowser;
}
bool wxWebViewIEImpl::CanExecCommand(wxString command) const
{ {
wxCOMPtr<IHTMLDocument2> document(GetDocument()); wxCOMPtr<IHTMLDocument2> document(GetDocument());
@@ -1003,7 +1031,7 @@ bool wxWebViewIE::CanExecCommand(wxString command) const
} }
void wxWebViewIE::ExecCommand(wxString command) void wxWebViewIEImpl::ExecCommand(wxString command)
{ {
wxCOMPtr<IHTMLDocument2> document(GetDocument()); wxCOMPtr<IHTMLDocument2> document(GetDocument());
@@ -1013,7 +1041,7 @@ void wxWebViewIE::ExecCommand(wxString command)
} }
} }
wxCOMPtr<IHTMLDocument2> wxWebViewIE::GetDocument() const wxCOMPtr<IHTMLDocument2> wxWebViewIEImpl::GetDocument() const
{ {
wxCOMPtr<IDispatch> dispatch; wxCOMPtr<IDispatch> dispatch;
wxCOMPtr<IHTMLDocument2> document; wxCOMPtr<IHTMLDocument2> document;
@@ -1026,7 +1054,7 @@ wxCOMPtr<IHTMLDocument2> wxWebViewIE::GetDocument() const
return document; return document;
} }
bool wxWebViewIE::IsElementVisible(wxCOMPtr<IHTMLElement> elm) bool wxWebViewIEImpl::IsElementVisible(wxCOMPtr<IHTMLElement> elm)
{ {
wxCOMPtr<IHTMLElement> elm1 = elm; wxCOMPtr<IHTMLElement> elm1 = elm;
bool is_visible = true; bool is_visible = true;
@@ -1075,7 +1103,7 @@ bool wxWebViewIE::IsElementVisible(wxCOMPtr<IHTMLElement> elm)
return is_visible; return is_visible;
} }
void wxWebViewIE::FindInternal(const wxString& text, int flags, int internal_flag) void wxWebViewIEImpl::FindInternal(const wxString& text, int flags, int internal_flag)
{ {
long find_flag = 0; long find_flag = 0;
wxCOMPtr<wxIMarkupServices> pIMS; wxCOMPtr<wxIMarkupServices> pIMS;
@@ -1150,7 +1178,7 @@ void wxWebViewIE::FindInternal(const wxString& text, int flags, int internal_fla
} }
} }
long wxWebViewIE::FindNext(int direction) long wxWebViewIEImpl::FindNext(int direction)
{ {
//Don't bother if we have no pointers set. //Don't bother if we have no pointers set.
if(m_findPointers.empty()) if(m_findPointers.empty())
@@ -1221,7 +1249,7 @@ long wxWebViewIE::FindNext(int direction)
return ret; return ret;
} }
void wxWebViewIE::FindClear() void wxWebViewIEImpl::FindClear()
{ {
//Reset find variables. //Reset find variables.
m_findText.Empty(); m_findText.Empty();
@@ -1242,7 +1270,7 @@ void wxWebViewIE::FindClear()
m_findPointers.clear(); m_findPointers.clear();
} }
bool wxWebViewIE::EnableControlFeature(long flag, bool enable) bool wxWebViewIEImpl::EnableControlFeature(long flag, bool enable)
{ {
#if wxUSE_DYNLIB_CLASS #if wxUSE_DYNLIB_CLASS
@@ -1282,13 +1310,13 @@ bool wxWebViewIE::EnableControlFeature(long flag, bool enable)
void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt) void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt)
{ {
if (m_webBrowser == NULL) return; if (m_impl->m_webBrowser == NULL) return;
switch (evt.GetDispatchId()) switch (evt.GetDispatchId())
{ {
case DISPID_BEFORENAVIGATE2: case DISPID_BEFORENAVIGATE2:
{ {
m_isBusy = true; m_impl->m_isBusy = true;
wxString url = evt[1].GetString(); wxString url = evt[1].GetString();
wxString target = evt[3].GetString(); wxString target = evt[3].GetString();
@@ -1318,7 +1346,7 @@ void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt)
// and we're not busy, either it was accepted and IWebBrowser2's // and we're not busy, either it was accepted and IWebBrowser2's
// Busy property will be true; so we don't need our override // Busy property will be true; so we don't need our override
// flag anymore. // flag anymore.
m_isBusy = false; m_impl->m_isBusy = false;
break; break;
} }
@@ -1346,7 +1374,7 @@ void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt)
//Only send a complete even if we are actually finished, this brings //Only send a complete even if we are actually finished, this brings
//the event in to line with webkit //the event in to line with webkit
READYSTATE rs; READYSTATE rs;
m_webBrowser->get_ReadyState( &rs ); m_impl->m_webBrowser->get_ReadyState( &rs );
if(rs != READYSTATE_COMPLETE) if(rs != READYSTATE_COMPLETE)
break; break;
@@ -1357,26 +1385,26 @@ void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt)
//We also have to check if we are loading a file:// url, if so we //We also have to check if we are loading a file:// url, if so we
//need to change the comparison as ie passes back a different style //need to change the comparison as ie passes back a different style
//of url //of url
if(m_historyEnabled && !m_historyLoadingFromList && if(m_impl->m_historyEnabled && !m_impl->m_historyLoadingFromList &&
(url == GetCurrentURL() || (url == GetCurrentURL() ||
(GetCurrentURL().substr(0, 4) == "file" && (GetCurrentURL().substr(0, 4) == "file" &&
wxFileName::URLToFileName(GetCurrentURL()).GetFullPath() == url))) wxFileName::URLToFileName(GetCurrentURL()).GetFullPath() == url)))
{ {
//If we are not at the end of the list, then erase everything //If we are not at the end of the list, then erase everything
//between us and the end before adding the new page //between us and the end before adding the new page
if(m_historyPosition != static_cast<int>(m_historyList.size()) - 1) if(m_impl->m_historyPosition != static_cast<int>(m_impl->m_historyList.size()) - 1)
{ {
m_historyList.erase(m_historyList.begin() + m_historyPosition + 1, m_impl->m_historyList.erase(m_impl->m_historyList.begin() + m_impl->m_historyPosition + 1,
m_historyList.end()); m_impl->m_historyList.end());
} }
wxSharedPtr<wxWebViewHistoryItem> item(new wxWebViewHistoryItem(url, GetCurrentTitle())); wxSharedPtr<wxWebViewHistoryItem> item(new wxWebViewHistoryItem(url, GetCurrentTitle()));
m_historyList.push_back(item); m_impl->m_historyList.push_back(item);
m_historyPosition++; m_impl->m_historyPosition++;
} }
//Reset as we are done now //Reset as we are done now
m_historyLoadingFromList = false; m_impl->m_historyLoadingFromList = false;
//Reset the find values. //Reset the find values.
FindClear(); m_impl->FindClear();
// TODO: set target parameter if possible // TODO: set target parameter if possible
wxString target; wxString target;
wxWebViewEvent event(wxEVT_WEBVIEW_LOADED, GetId(), wxWebViewEvent event(wxEVT_WEBVIEW_LOADED, GetId(),