diff --git a/Makefile.in b/Makefile.in index b64aa7b929..865d6a448d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -3336,7 +3336,6 @@ COND_TOOLKIT_MSW_GUI_HDR = \ wx/msw/std.ico @COND_TOOLKIT_MSW@GUI_HDR = $(COND_TOOLKIT_MSW_GUI_HDR) COND_TOOLKIT_OSX_COCOA_GUI_HDR = \ - wx/html/webkit.h \ wx/osx/accel.h \ wx/osx/anybutton.h \ wx/osx/app.h \ @@ -3443,7 +3442,6 @@ COND_TOOLKIT_OSX_COCOA_GUI_HDR = \ wx/osx/datetimectrl.h @COND_TOOLKIT_OSX_COCOA@GUI_HDR = $(COND_TOOLKIT_OSX_COCOA_GUI_HDR) COND_TOOLKIT_OSX_IPHONE_GUI_HDR = \ - wx/html/webkit.h \ wx/osx/accel.h \ wx/osx/anybutton.h \ wx/osx/app.h \ @@ -13228,7 +13226,6 @@ COND_PLATFORM_MACOSX_1___OSX_COMMON_SRC_OBJECTS = \ monodll_textctrl_osx.o \ monodll_tglbtn_osx.o \ monodll_toolbar_osx.o \ - monodll_webkit.o \ monodll_colordlgosx.o \ monodll_fontdlgosx.o \ monodll_osx_accel.o \ @@ -13366,7 +13363,6 @@ COND_PLATFORM_MACOSX_1___OSX_COMMON_SRC_OBJECTS_0 = \ monolib_textctrl_osx.o \ monolib_tglbtn_osx.o \ monolib_toolbar_osx.o \ - monolib_webkit.o \ monolib_colordlgosx.o \ monolib_fontdlgosx.o \ monolib_osx_accel.o \ @@ -13504,7 +13500,6 @@ COND_PLATFORM_MACOSX_1___OSX_COMMON_SRC_OBJECTS_8 = \ coredll_textctrl_osx.o \ coredll_tglbtn_osx.o \ coredll_toolbar_osx.o \ - coredll_webkit.o \ coredll_colordlgosx.o \ coredll_fontdlgosx.o \ coredll_osx_accel.o \ @@ -13642,7 +13637,6 @@ COND_PLATFORM_MACOSX_1___OSX_COMMON_SRC_OBJECTS_9 = \ corelib_textctrl_osx.o \ corelib_tglbtn_osx.o \ corelib_toolbar_osx.o \ - corelib_webkit.o \ corelib_colordlgosx.o \ corelib_fontdlgosx.o \ corelib_osx_accel.o \ @@ -20059,12 +20053,6 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1_WXUNIV_0@monodll_toolbar_osx.o: $(srcdir)/src/osx/toolbar_osx.cpp $(MONODLL_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/toolbar_osx.cpp -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1_WXUNIV_0@monodll_webkit.o: $(srcdir)/src/html/htmlctrl/webkit/webkit.mm $(MONODLL_ODEP) -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_OBJCXXFLAGS) $(srcdir)/src/html/htmlctrl/webkit/webkit.mm - -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1_WXUNIV_0@monodll_webkit.o: $(srcdir)/src/html/htmlctrl/webkit/webkit.mm $(MONODLL_ODEP) -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_OBJCXXFLAGS) $(srcdir)/src/html/htmlctrl/webkit/webkit.mm - @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1_WXUNIV_0@monodll_colordlgosx.o: $(srcdir)/src/osx/carbon/colordlgosx.mm $(MONODLL_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_OBJCXXFLAGS) $(srcdir)/src/osx/carbon/colordlgosx.mm @@ -25327,12 +25315,6 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1_WXUNIV_0@monolib_toolbar_osx.o: $(srcdir)/src/osx/toolbar_osx.cpp $(MONOLIB_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/toolbar_osx.cpp -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1_WXUNIV_0@monolib_webkit.o: $(srcdir)/src/html/htmlctrl/webkit/webkit.mm $(MONOLIB_ODEP) -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_OBJCXXFLAGS) $(srcdir)/src/html/htmlctrl/webkit/webkit.mm - -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1_WXUNIV_0@monolib_webkit.o: $(srcdir)/src/html/htmlctrl/webkit/webkit.mm $(MONOLIB_ODEP) -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_OBJCXXFLAGS) $(srcdir)/src/html/htmlctrl/webkit/webkit.mm - @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1_WXUNIV_0@monolib_colordlgosx.o: $(srcdir)/src/osx/carbon/colordlgosx.mm $(MONOLIB_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_OBJCXXFLAGS) $(srcdir)/src/osx/carbon/colordlgosx.mm @@ -30676,12 +30658,6 @@ coredll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(COREDLL_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1_WXUNIV_0@coredll_toolbar_osx.o: $(srcdir)/src/osx/toolbar_osx.cpp $(COREDLL_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/toolbar_osx.cpp -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1_WXUNIV_0@coredll_webkit.o: $(srcdir)/src/html/htmlctrl/webkit/webkit.mm $(COREDLL_ODEP) -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_OBJCXXFLAGS) $(srcdir)/src/html/htmlctrl/webkit/webkit.mm - -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1_WXUNIV_0@coredll_webkit.o: $(srcdir)/src/html/htmlctrl/webkit/webkit.mm $(COREDLL_ODEP) -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_OBJCXXFLAGS) $(srcdir)/src/html/htmlctrl/webkit/webkit.mm - @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1_WXUNIV_0@coredll_colordlgosx.o: $(srcdir)/src/osx/carbon/colordlgosx.mm $(COREDLL_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_OBJCXXFLAGS) $(srcdir)/src/osx/carbon/colordlgosx.mm @@ -34933,12 +34909,6 @@ corelib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(CORELIB_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1_WXUNIV_0@corelib_toolbar_osx.o: $(srcdir)/src/osx/toolbar_osx.cpp $(CORELIB_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/toolbar_osx.cpp -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1_WXUNIV_0@corelib_webkit.o: $(srcdir)/src/html/htmlctrl/webkit/webkit.mm $(CORELIB_ODEP) -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_OBJCXXFLAGS) $(srcdir)/src/html/htmlctrl/webkit/webkit.mm - -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1_WXUNIV_0@corelib_webkit.o: $(srcdir)/src/html/htmlctrl/webkit/webkit.mm $(CORELIB_ODEP) -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_OBJCXXFLAGS) $(srcdir)/src/html/htmlctrl/webkit/webkit.mm - @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1_WXUNIV_0@corelib_colordlgosx.o: $(srcdir)/src/osx/carbon/colordlgosx.mm $(CORELIB_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_OBJCXXFLAGS) $(srcdir)/src/osx/carbon/colordlgosx.mm @@ -37320,9 +37290,6 @@ OSX_CARBON_DIST: ALL_GUI_DIST $(CP_P) $(MACDIR)/cocoa/*.mm $(DISTDIR)/src/osx/cocoa mkdir $(DISTDIR)/src/osx/iphone $(CP_P) $(MACDIR)/iphone/*.mm $(DISTDIR)/src/osx/iphone - mkdir $(DISTDIR)/src/html/htmlctrl - mkdir $(DISTDIR)/src/html/htmlctrl/webkit - $(CP_P) $(WXDIR)/src/html/htmlctrl/webkit/*.mm $(DISTDIR)/src/html/htmlctrl/webkit mkdir $(DISTDIR)/src/osx/carbon $(CP_P) $(MACDIR)/carbon/*.cpp $(DISTDIR)/src/osx/carbon $(CP_P) $(MACDIR)/carbon/*.mm $(DISTDIR)/src/osx/carbon diff --git a/build/bakefiles/Bakefiles.bkgen b/build/bakefiles/Bakefiles.bkgen index fa1c323e53..de4ba70b07 100644 --- a/build/bakefiles/Bakefiles.bkgen +++ b/build/bakefiles/Bakefiles.bkgen @@ -46,11 +46,6 @@ msvc6prj,msvs2003prj,msvs2005prj,msvs2008prj - - - borland,dmars_smake,dmars,mingw,msvc,msvc6prj,msvs2003prj,msvs2005prj,msvs2008prj,watcom - - autoconf,borland,dmars_smake,dmars,mingw,watcom diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index 6b906206a4..2115d633cd 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -2445,7 +2445,6 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! src/osx/tglbtn_osx.cpp src/osx/toolbar_osx.cpp - src/html/htmlctrl/webkit/webkit.mm src/osx/carbon/colordlgosx.mm src/osx/carbon/fontdlgosx.mm @@ -2496,7 +2495,6 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! - wx/html/webkit.h wx/osx/accel.h wx/osx/anybutton.h diff --git a/build/bakefiles/make_dist.mk b/build/bakefiles/make_dist.mk index 839aa9938f..b7f94629ba 100644 --- a/build/bakefiles/make_dist.mk +++ b/build/bakefiles/make_dist.mk @@ -410,9 +410,6 @@ OSX_CARBON_DIST: ALL_GUI_DIST $(CP_P) $(MACDIR)/cocoa/*.mm $(DISTDIR)/src/osx/cocoa mkdir $(DISTDIR)/src/osx/iphone $(CP_P) $(MACDIR)/iphone/*.mm $(DISTDIR)/src/osx/iphone - mkdir $(DISTDIR)/src/html/htmlctrl - mkdir $(DISTDIR)/src/html/htmlctrl/webkit - $(CP_P) $(WXDIR)/src/html/htmlctrl/webkit/*.mm $(DISTDIR)/src/html/htmlctrl/webkit mkdir $(DISTDIR)/src/osx/carbon $(CP_P) $(MACDIR)/carbon/*.cpp $(DISTDIR)/src/osx/carbon $(CP_P) $(MACDIR)/carbon/*.mm $(DISTDIR)/src/osx/carbon diff --git a/build/cmake/files.cmake b/build/cmake/files.cmake index 8165d51792..1a61380823 100644 --- a/build/cmake/files.cmake +++ b/build/cmake/files.cmake @@ -2323,7 +2323,6 @@ set(OSX_COMMON_SRC src/osx/tglbtn_osx.cpp src/osx/toolbar_osx.cpp # wxWebKit files - src/html/htmlctrl/webkit/webkit.mm # Native color/font dialogs src/osx/carbon/colordlgosx.mm src/osx/carbon/fontdlgosx.mm @@ -2373,7 +2372,6 @@ set(OSX_COMMON_SRC set(OSX_SHARED_HDR # wxWebKit headers - wx/html/webkit.h # other shared headers wx/osx/accel.h wx/osx/anybutton.h diff --git a/build/cmake/lib/core/CMakeLists.txt b/build/cmake/lib/core/CMakeLists.txt index 95be60c49a..e689934198 100644 --- a/build/cmake/lib/core/CMakeLists.txt +++ b/build/cmake/lib/core/CMakeLists.txt @@ -75,7 +75,7 @@ if(WIN32) endif() if(WXOSX_COCOA) wx_lib_link_libraries(wxcore PUBLIC "-framework AudioToolbox") - if(wxUSE_WEBKIT) + if(wxUSE_WEBVIEW) wx_lib_link_libraries(wxcore PUBLIC "-framework WebKit") endif() endif() diff --git a/build/cmake/options.cmake b/build/cmake/options.cmake index 5f0d2dca6d..332cf0e4e5 100644 --- a/build/cmake/options.cmake +++ b/build/cmake/options.cmake @@ -235,9 +235,6 @@ wx_option(wxUSE_AFM_FOR_POSTSCRIPT "in wxPostScriptDC class use AFM (adobe font wx_option(wxUSE_PRINTING_ARCHITECTURE "use printing architecture") wx_option(wxUSE_SVG "use wxSVGFileDC device context") wx_option(wxUSE_WEBVIEW "use wxWebView library") -if(APPLE) - wx_option(wxUSE_WEBKIT "use wxWebKitCtrl (Mac-only, use wxWebView instead)") -endif() # wxDC is implemented in terms of wxGraphicsContext in wxOSX so the latter # can't be disabled, don't even provide an option to do it diff --git a/build/cmake/samples/html.cmake b/build/cmake/samples/html.cmake index 5a5299a020..03097ca497 100644 --- a/build/cmake/samples/html.cmake +++ b/build/cmake/samples/html.cmake @@ -25,8 +25,6 @@ wx_list_add_prefix(HELP_DATA_FILES helpfiles/ ) wx_add_sample(help DATA ${HELP_DATA_FILES} LIBRARIES wxhtml NAME htmlhelp DEPENDS wxUSE_HELP) wx_add_sample(helpview DATA test.zip LIBRARIES wxhtml DEPENDS wxUSE_HELP) -#TODO: htmlctrl sample uses outdated definitions -#wx_add_sample(htmlctrl LIBRARIES wxhtml) wx_add_sample(printing DATA logo6.gif test.htm LIBRARIES wxhtml NAME htmlprinting DEPENDS wxUSE_PRINTING_ARCHITECTURE) wx_add_sample(test diff --git a/build/files b/build/files index 39a49b19c6..db0dc4748c 100644 --- a/build/files +++ b/build/files @@ -2303,8 +2303,6 @@ OSX_COMMON_SRC = src/osx/textctrl_osx.cpp src/osx/tglbtn_osx.cpp src/osx/toolbar_osx.cpp - # wxWebKit files - src/html/htmlctrl/webkit/webkit.mm # Native color/font dialogs src/osx/carbon/colordlgosx.mm src/osx/carbon/fontdlgosx.mm @@ -2351,8 +2349,6 @@ OSX_COMMON_SRC = # Header files like wx/osx/foo.h which include wx/osx/carbon/foo.h OSX_SHARED_HDR = - # wxWebKit headers - wx/html/webkit.h # other shared headers wx/osx/accel.h wx/osx/anybutton.h diff --git a/configure b/configure index af89043a2b..dcd53d458b 100755 --- a/configure +++ b/configure @@ -1228,7 +1228,6 @@ enable_richtext enable_postscript enable_printarch enable_svg -enable_webkit enable_webview enable_graphics_ctx enable_clipboard @@ -2190,7 +2189,6 @@ Optional Features: --enable-postscript use wxPostscriptDC device context (default for gtk+) --enable-printarch use printing architecture --enable-svg use wxSVGFileDC device context - --enable-webkit use wxWebKitCtrl (Mac-only, use wxWebView instead) --enable-webview use wxWebView library --enable-graphics_ctx use graphics context 2D drawing API --enable-clipboard use wxClipboard class @@ -8882,35 +8880,6 @@ fi eval "$wx_cv_use_svg" - enablestring= - defaultval=$wxUSE_ALL_FEATURES - if test -z "$defaultval"; then - if test x"$enablestring" = xdisable; then - defaultval=yes - else - defaultval=no - fi - fi - - # Check whether --enable-webkit was given. -if test "${enable_webkit+set}" = set; then : - enableval=$enable_webkit; - if test "$enableval" = yes; then - wx_cv_use_webkit='wxUSE_WEBKIT=yes' - else - wx_cv_use_webkit='wxUSE_WEBKIT=no' - fi - -else - - wx_cv_use_webkit='wxUSE_WEBKIT=${'DEFAULT_wxUSE_WEBKIT":-$defaultval}" - -fi - - - eval "$wx_cv_use_webkit" - - enablestring= defaultval=$wxUSE_ALL_FEATURES if test -z "$defaultval"; then @@ -36839,18 +36808,6 @@ if test "$wxUSE_HTML" = "yes"; then USE_HTML=1 SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS html html/about html/help html/helpview html/printing html/test html/virtual html/widget html/zip htlbox" fi -if test "$wxUSE_WEBKIT" = "yes"; then - if test "$wxUSE_MAC" = 1 -a "$USE_DARWIN" = 1; then - $as_echo "#define wxUSE_WEBKIT 1" >>confdefs.h - - WEBKIT_LINK="-framework WebKit" - else - wxUSE_WEBKIT=no - fi - if test "$wxUSE_WEBKIT" = "yes"; then - SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS html/htmlctrl" - fi -fi USE_XRC=0 if test "$wxUSE_XRC" = "yes"; then diff --git a/configure.in b/configure.in index 09c87e74a7..495afd25fc 100644 --- a/configure.in +++ b/configure.in @@ -810,7 +810,6 @@ WX_ARG_FEATURE(richtext, [ --enable-richtext use wxRichTextCtrl], wxUS WX_ARG_FEATURE(postscript, [ --enable-postscript use wxPostscriptDC device context (default for gtk+)], wxUSE_POSTSCRIPT) WX_ARG_FEATURE(printarch, [ --enable-printarch use printing architecture], wxUSE_PRINTING_ARCHITECTURE) WX_ARG_FEATURE(svg, [ --enable-svg use wxSVGFileDC device context], wxUSE_SVG) -WX_ARG_FEATURE(webkit, [ --enable-webkit use wxWebKitCtrl (Mac-only, use wxWebView instead)], wxUSE_WEBKIT) WX_ARG_FEATURE(webview, [ --enable-webview use wxWebView library], wxUSE_WEBVIEW) dnl wxDC is implemented in terms of wxGraphicsContext in wxOSX so the latter @@ -7307,17 +7306,6 @@ if test "$wxUSE_HTML" = "yes"; then USE_HTML=1 SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS html html/about html/help html/helpview html/printing html/test html/virtual html/widget html/zip htlbox" fi -if test "$wxUSE_WEBKIT" = "yes"; then - if test "$wxUSE_MAC" = 1 -a "$USE_DARWIN" = 1; then - AC_DEFINE(wxUSE_WEBKIT) - WEBKIT_LINK="-framework WebKit" - else - wxUSE_WEBKIT=no - fi - if test "$wxUSE_WEBKIT" = "yes"; then - SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS html/htmlctrl" - fi -fi USE_XRC=0 if test "$wxUSE_XRC" = "yes"; then diff --git a/include/wx/defs.h b/include/wx/defs.h index 1881ac247f..c4dd777540 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -2790,6 +2790,7 @@ DECLARE_WXCOCOA_OBJC_CLASS(NSRotationGestureRecognizer); DECLARE_WXCOCOA_OBJC_CLASS(NSPressGestureRecognizer); DECLARE_WXCOCOA_OBJC_CLASS(NSTouch); DECLARE_WXCOCOA_OBJC_CLASS(NSPasteboard); +DECLARE_WXCOCOA_OBJC_CLASS(WKWebView); typedef WX_NSWindow WXWindow; typedef WX_NSView WXWidget; @@ -2798,6 +2799,7 @@ typedef WX_NSMenu WXHMENU; typedef WX_NSOpenGLPixelFormat WXGLPixelFormat; typedef WX_NSOpenGLContext WXGLContext; typedef WX_NSPasteboard OSXPasteboard; +typedef WX_WKWebView OSXWebViewPtr; #elif wxOSX_USE_IPHONE @@ -2811,7 +2813,6 @@ DECLARE_WXCOCOA_OBJC_CLASS(UIImage); DECLARE_WXCOCOA_OBJC_CLASS(UIEvent); DECLARE_WXCOCOA_OBJC_CLASS(NSSet); DECLARE_WXCOCOA_OBJC_CLASS(EAGLContext); -DECLARE_WXCOCOA_OBJC_CLASS(UIWebView); DECLARE_WXCOCOA_OBJC_CLASS(UIPasteboard); typedef WX_UIWindow WXWindow; @@ -2820,15 +2821,10 @@ typedef WX_UIImage WXImage; typedef WX_UIMenu WXHMENU; typedef WX_EAGLContext WXGLContext; typedef WX_NSString WXGLPixelFormat; -typedef WX_UIWebView OSXWebViewPtr; typedef WX_UIPasteboard WXOSXPasteboard; #endif -#if wxOSX_USE_COCOA_OR_CARBON -DECLARE_WXCOCOA_OBJC_CLASS(WebView); -typedef WX_WebView OSXWebViewPtr; -#endif #endif /* __WXMAC__ */ diff --git a/include/wx/html/webkit.h b/include/wx/html/webkit.h deleted file mode 100644 index 94f0bfb05f..0000000000 --- a/include/wx/html/webkit.h +++ /dev/null @@ -1,242 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/html/webkit.h -// Purpose: wxWebKitCtrl - embeddable web kit control -// Author: Jethro Grassie / Kevin Ollivier -// Modified by: -// Created: 2004-4-16 -// Copyright: (c) Jethro Grassie / Kevin Ollivier -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_WEBKIT_H -#define _WX_WEBKIT_H - -#if wxUSE_WEBKIT - -#if !defined(__WXMAC__) -#error "wxWebKitCtrl not implemented for this platform" -#endif - -#include "wx/control.h" - -// ---------------------------------------------------------------------------- -// Web Kit Control -// ---------------------------------------------------------------------------- - -extern WXDLLIMPEXP_DATA_CORE(const char) wxWebKitCtrlNameStr[]; - -class WXDLLIMPEXP_CORE wxWebKitCtrl : public wxControl -{ -public: - wxDECLARE_DYNAMIC_CLASS(wxWebKitCtrl); - - wxWebKitCtrl() {} - wxWebKitCtrl(wxWindow *parent, - wxWindowID winID, - const wxString& strURL, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxASCII_STR(wxWebKitCtrlNameStr)) - { - Create(parent, winID, strURL, pos, size, style, validator, name); - } - bool Create(wxWindow *parent, - wxWindowID winID, - const wxString& strURL, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxASCII_STR(wxWebKitCtrlNameStr)); - virtual ~wxWebKitCtrl(); - - void LoadURL(const wxString &url); - - bool CanGoBack(); - bool CanGoForward(); - bool GoBack(); - bool GoForward(); - void Reload(); - void Stop(); - bool CanGetPageSource(); - wxString GetPageSource(); - void SetPageSource(const wxString& source, const wxString& baseUrl = wxEmptyString); - wxString GetPageURL(){ return m_currentURL; } - void SetPageTitle(const wxString& title) { m_pageTitle = title; } - wxString GetPageTitle(){ return m_pageTitle; } - - // since these worked in 2.6, add wrappers - void SetTitle(const wxString& title) { SetPageTitle(title); } - wxString GetTitle() { return GetPageTitle(); } - - wxString GetSelection(); - - bool CanIncreaseTextSize(); - void IncreaseTextSize(); - bool CanDecreaseTextSize(); - void DecreaseTextSize(); - - void Print(bool showPrompt = false); - - void MakeEditable(bool enable = true); - bool IsEditable(); - - wxString RunScript(const wxString& javascript); - - void SetScrollPos(int pos); - int GetScrollPos(); - - // don't hide base class virtuals - virtual void SetScrollPos( int orient, int pos, bool refresh = true ) wxOVERRIDE - { return wxControl::SetScrollPos(orient, pos, refresh); } - virtual int GetScrollPos( int orient ) const wxOVERRIDE - { return wxControl::GetScrollPos(orient); } - - //we need to resize the webview when the control size changes - void OnSize(wxSizeEvent &event); - void OnMove(wxMoveEvent &event); - void OnMouseEvents(wxMouseEvent &event); -protected: - wxDECLARE_EVENT_TABLE(); - void MacVisibilityChanged() wxOVERRIDE; - -private: - wxWindow *m_parent; - wxWindowID m_windowID; - wxString m_currentURL; - wxString m_pageTitle; - - OSXWebViewPtr m_webView; - - WX_NSObject m_frameLoadMonitor; - WX_NSObject m_policyDelegate; - WX_NSObject m_UIDelegate; - - // we may use this later to setup our own mouse events, - // so leave it in for now. - void* m_webKitCtrlEventHandler; -}; - -// ---------------------------------------------------------------------------- -// Web Kit Events -// ---------------------------------------------------------------------------- - -enum { - wxWEBKIT_STATE_START = 1, - wxWEBKIT_STATE_NEGOTIATING = 2, - wxWEBKIT_STATE_REDIRECTING = 4, - wxWEBKIT_STATE_TRANSFERRING = 8, - wxWEBKIT_STATE_STOP = 16, - wxWEBKIT_STATE_FAILED = 32 -}; - -enum { - wxWEBKIT_NAV_LINK_CLICKED = 1, - wxWEBKIT_NAV_BACK_NEXT = 2, - wxWEBKIT_NAV_FORM_SUBMITTED = 4, - wxWEBKIT_NAV_RELOAD = 8, - wxWEBKIT_NAV_FORM_RESUBMITTED = 16, - wxWEBKIT_NAV_OTHER = 32 - -}; - - - -class WXDLLIMPEXP_CORE wxWebKitBeforeLoadEvent : public wxCommandEvent -{ - wxDECLARE_DYNAMIC_CLASS(wxWebKitBeforeLoadEvent); - -public: - bool IsCancelled() { return m_cancelled; } - void Cancel(bool cancel = true) { m_cancelled = cancel; } - wxString GetURL() { return m_url; } - void SetURL(const wxString& url) { m_url = url; } - void SetNavigationType(int navType) { m_navType = navType; } - int GetNavigationType() { return m_navType; } - - wxWebKitBeforeLoadEvent( wxWindow* win = NULL ); - wxEvent *Clone(void) const { return new wxWebKitBeforeLoadEvent(*this); } - -protected: - bool m_cancelled; - wxString m_url; - int m_navType; -}; - -class WXDLLIMPEXP_CORE wxWebKitStateChangedEvent : public wxCommandEvent -{ - wxDECLARE_DYNAMIC_CLASS(wxWebKitStateChangedEvent); - -public: - int GetState() { return m_state; } - void SetState(int state) { m_state = state; } - wxString GetURL() { return m_url; } - void SetURL(const wxString& url) { m_url = url; } - - wxWebKitStateChangedEvent( wxWindow* win = NULL ); - wxEvent *Clone(void) const { return new wxWebKitStateChangedEvent(*this); } - -protected: - int m_state; - wxString m_url; -}; - - -class WXDLLIMPEXP_CORE wxWebKitNewWindowEvent : public wxCommandEvent -{ - wxDECLARE_DYNAMIC_CLASS(wxWebKitNewWindowEvent); -public: - wxString GetURL() const { return m_url; } - void SetURL(const wxString& url) { m_url = url; } - wxString GetTargetName() const { return m_targetName; } - void SetTargetName(const wxString& name) { m_targetName = name; } - - wxWebKitNewWindowEvent( wxWindow* win = (wxWindow*)(NULL)); - wxEvent *Clone(void) const { return new wxWebKitNewWindowEvent(*this); } - -private: - wxString m_url; - wxString m_targetName; -}; - -typedef void (wxEvtHandler::*wxWebKitStateChangedEventFunction)(wxWebKitStateChangedEvent&); -typedef void (wxEvtHandler::*wxWebKitBeforeLoadEventFunction)(wxWebKitBeforeLoadEvent&); -typedef void (wxEvtHandler::*wxWebKitNewWindowEventFunction)(wxWebKitNewWindowEvent&); - -#define wxWebKitStateChangedEventHandler( func ) \ - wxEVENT_HANDLER_CAST( wxWebKitStateChangedEventFunction, func ) - -#define wxWebKitBeforeLoadEventHandler( func ) \ - wxEVENT_HANDLER_CAST( wxWebKitBeforeLoadEventFunction, func ) - -#define wxWebKitNewWindowEventHandler( func ) \ - wxEVENT_HANDLER_CAST( wxWebKitNewWindowEventFunction, func ) - -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_WEBKIT_STATE_CHANGED, wxWebKitStateChangedEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_WEBKIT_BEFORE_LOAD, wxWebKitBeforeLoadEvent ); -wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_WEBKIT_NEW_WINDOW, wxWebKitNewWindowEvent ); - -#define EVT_WEBKIT_STATE_CHANGED(func) \ - wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBKIT_STATE_CHANGED, \ - wxID_ANY, \ - wxID_ANY, \ - wxWebKitStateChangedEventHandler( func ), \ - NULL ), - -#define EVT_WEBKIT_BEFORE_LOAD(func) \ - wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBKIT_BEFORE_LOAD, \ - wxID_ANY, \ - wxID_ANY, \ - wxWebKitBeforeLoadEventHandler( func ), \ - NULL ), - -#define EVT_WEBKIT_NEW_WINDOW(func) \ - wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBKIT_NEW_WINDOW, \ - wxID_ANY, \ - wxID_ANY, \ - wxWebKitNewWindowEventHandler( func ), \ - NULL ), -#endif // wxUSE_WEBKIT - -#endif - // _WX_WEBKIT_H_ diff --git a/include/wx/osx/webview_webkit.h b/include/wx/osx/webview_webkit.h index d7c8a91e5f..2cbf36f489 100644 --- a/include/wx/osx/webview_webkit.h +++ b/include/wx/osx/webview_webkit.h @@ -25,6 +25,8 @@ // Web Kit Control // ---------------------------------------------------------------------------- +WX_DECLARE_STRING_HASH_MAP(wxSharedPtr, wxStringToWebHandlerMap); + class WXDLLIMPEXP_WEBVIEW wxWebViewWebKit : public wxWebView { public: @@ -71,7 +73,7 @@ public: virtual wxWebViewZoomType GetZoomType() const wxOVERRIDE; virtual bool CanSetZoomType(wxWebViewZoomType type) const wxOVERRIDE; - virtual bool IsBusy() const wxOVERRIDE { return m_busy; } + virtual bool IsBusy() const wxOVERRIDE; //History functions virtual void ClearHistory() wxOVERRIDE; @@ -121,54 +123,21 @@ public: virtual void* GetNativeBackend() const wxOVERRIDE { return m_webView; } - // ---- methods not from the parent (common) interface - bool CanGetPageSource() const; - - void SetScrollPos(int pos); - int GetScrollPos(); - - bool CanIncreaseTextSize() const; - void IncreaseTextSize(); - bool CanDecreaseTextSize() const; - void DecreaseTextSize(); - - float GetWebkitZoom() const; - void SetWebkitZoom(float zoom); - - // don't hide base class virtuals - virtual void SetScrollPos( int orient, int pos, bool refresh = true ) wxOVERRIDE - { return wxControl::SetScrollPos(orient, pos, refresh); } - virtual int GetScrollPos( int orient ) const wxOVERRIDE - { return wxControl::GetScrollPos(orient); } - - //we need to resize the webview when the control size changes - void OnSize(wxSizeEvent &event); - void OnMove(wxMoveEvent &event); - void OnMouseEvents(wxMouseEvent &event); - - bool m_busy; - bool m_nextNavigationIsNewWindow; - protected: virtual void DoSetPage(const wxString& html, const wxString& baseUrl) wxOVERRIDE; wxDECLARE_EVENT_TABLE(); - void MacVisibilityChanged() wxOVERRIDE; private: - wxWindow *m_parent; - wxWindowID m_windowID; - wxString m_pageTitle; - OSXWebViewPtr m_webView; + wxStringToWebHandlerMap m_handlers; - WX_NSObject m_loadDelegate; - WX_NSObject m_policyDelegate; + WX_NSObject m_navigationDelegate; WX_NSObject m_UIDelegate; - // we may use this later to setup our own mouse events, - // so leave it in for now. - void* m_webKitCtrlEventHandler; + bool RunScriptSync(const wxString& javascript, wxString* output = NULL); + bool QueryCommandEnabled(const wxString& command) const; + void ExecCommand(const wxString& command); }; class WXDLLIMPEXP_WEBVIEW wxWebViewFactoryWebKit : public wxWebViewFactory diff --git a/interface/wx/html/webkit.h b/interface/wx/html/webkit.h deleted file mode 100644 index 8519661554..0000000000 --- a/interface/wx/html/webkit.h +++ /dev/null @@ -1,152 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/html/webkit.h -// Purpose: wxWebKitCtrl - embeddable web kit control -// Author: Jethro Grassie / Kevin Ollivier -// Modified by: -// Created: 2004-4-16 -// Copyright: (c) Jethro Grassie / Kevin Ollivier -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_WEBKIT_H -#define _WX_WEBKIT_H - -/** - @class wxWebKitCtrl - - This control is a native wrapper around the Safari web browsing - engine. This wrapper differs from the one in wxWebView in that this - version supports functionality specific to WebKit, such as having - RunScript return a value, which is a very critical feature in many web - embedding scenarios. - - This class is only available on macOS. -**/ - -class wxWebKitCtrl : public wxControl -{ -public: - - wxWebKitCtrl(); - wxWebKitCtrl(wxWindow *parent, - wxWindowID winid, - const wxString& strURL, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxWebKitCtrlNameStr); - - bool Create(wxWindow *parent, - wxWindowID winid, - const wxString& strURL, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxWebKitCtrlNameStr); - virtual ~wxWebKitCtrl(); - - void LoadURL(const wxString &url); - - bool CanGoBack(); - bool CanGoForward(); - bool GoBack(); - bool GoForward(); - void Reload(); - void Stop(); - bool CanGetPageSource(); - wxString GetPageSource(); - void SetPageSource(const wxString& source, const wxString& baseUrl = wxEmptyString); - wxString GetPageURL(); - void SetPageTitle(const wxString& title); - wxString GetPageTitle(); - - // since these worked in 2.6, add wrappers - void SetTitle(const wxString& title); - wxString GetTitle(); - - wxString GetSelection(); - - bool CanIncreaseTextSize(); - void IncreaseTextSize(); - bool CanDecreaseTextSize(); - void DecreaseTextSize(); - - void Print(bool showPrompt = false); - - void MakeEditable(bool enable = true); - bool IsEditable(); - - wxString RunScript(const wxString& javascript); - - void SetScrollPos(int pos); - int GetScrollPos(); -}; - -// ---------------------------------------------------------------------------- -// Web Kit Events -// ---------------------------------------------------------------------------- - -enum { - wxWEBKIT_STATE_START = 1, - wxWEBKIT_STATE_NEGOTIATING = 2, - wxWEBKIT_STATE_REDIRECTING = 4, - wxWEBKIT_STATE_TRANSFERRING = 8, - wxWEBKIT_STATE_STOP = 16, - wxWEBKIT_STATE_FAILED = 32 -}; - -enum { - wxWEBKIT_NAV_LINK_CLICKED = 1, - wxWEBKIT_NAV_BACK_NEXT = 2, - wxWEBKIT_NAV_FORM_SUBMITTED = 4, - wxWEBKIT_NAV_RELOAD = 8, - wxWEBKIT_NAV_FORM_RESUBMITTED = 16, - wxWEBKIT_NAV_OTHER = 32 - -}; - - - -class wxWebKitBeforeLoadEvent : public wxCommandEvent -{ -public: - bool IsCancelled(); - void Cancel(bool cancel = true); - wxString GetURL(); - void SetURL(const wxString& url); - void SetNavigationType(int navType); - int GetNavigationType(); - - wxWebKitBeforeLoadEvent( wxWindow* win = 0 ); -}; - -class wxWebKitStateChangedEvent : public wxCommandEvent -{ -public: - int GetState(); - void SetState(int state); - wxString GetURL(); - void SetURL(const wxString& url); - - wxWebKitStateChangedEvent( wxWindow* win = 0 ); -}; - - -class wxWebKitNewWindowEvent : public wxCommandEvent -{ -public: - wxString GetURL() const; - void SetURL(const wxString& url); - wxString GetTargetName() const; - void SetTargetName(const wxString& name); - - wxWebKitNewWindowEvent( wxWindow* win = 0 ); -}; - -wxEventType wxEVT_WEBKIT_STATE_CHANGED; -wxEventType wxEVT_WEBKIT_BEFORE_LOAD; -wxEventType wxEVT_WEBKIT_NEW_WINDOW; - - -#endif - // _WX_WEBKIT_H_ diff --git a/interface/wx/webview.h b/interface/wx/webview.h index a1d1ce04e3..4d01990faf 100644 --- a/interface/wx/webview.h +++ b/interface/wx/webview.h @@ -347,12 +347,13 @@ public: and under Fedora it is webkitgtk4-devel. All wxWEBVIEW_WEBKIT features are supported except for clearing and enabling / disabling the history. - @par wxWEBVIEW_WEBKIT (OSX) + @par wxWEBVIEW_WEBKIT (macOS) The macOS WebKit backend uses Apple's - WebView + WKWebView class. This backend has full support for custom schemes and virtual file - systems. + systems on macOS 10.13+. In order to use handlers two-step creation has to be used + and RegisterHandler() has to be called before Create(). @section async Asynchronous Notifications @@ -565,6 +566,9 @@ public: /** Registers a custom scheme handler. @param handler A shared pointer to a wxWebHandler. + @note On macOS in order to use handlers two-step creation has to be + used and RegisterHandler() has to be called before Create(). + With the other backends it has to be called after Create(). */ virtual void RegisterHandler(wxSharedPtr handler) = 0; @@ -639,6 +643,8 @@ public: Set the editable property of the web control. Enabling allows the user to edit the page even if the @c contenteditable attribute is not set. The exact capabilities vary with the backend being used. + + @note This is not implemented on macOS. */ virtual void SetEditable(bool enable = true) = 0; @@ -769,14 +775,14 @@ public: /** Clear the history, this will also remove the visible page. - @note This is not implemented on the WebKit2GTK+ backend. + @note This is not implemented on the WebKit2GTK+ backend and macOS. */ virtual void ClearHistory() = 0; /** Enable or disable the history. This will also clear the history. - @note This is not implemented on the WebKit2GTK+ backend. + @note This is not implemented on the WebKit2GTK+ backend and macOS. */ virtual void EnableHistory(bool enable = true) = 0; diff --git a/samples/html/htmlctrl/Makefile.in b/samples/html/htmlctrl/Makefile.in deleted file mode 100644 index 5c36aee660..0000000000 --- a/samples/html/htmlctrl/Makefile.in +++ /dev/null @@ -1,191 +0,0 @@ -# ========================================================================= -# This makefile was generated by -# Bakefile 0.2.12 (http://www.bakefile.org) -# Do not modify, all changes will be overwritten! -# ========================================================================= - - -@MAKE_SET@ - -prefix = @prefix@ -exec_prefix = @exec_prefix@ -datarootdir = @datarootdir@ -INSTALL = @INSTALL@ -EXEEXT = @EXEEXT@ -WINDRES = @WINDRES@ -NM = @NM@ -BK_DEPS = @BK_DEPS@ -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -LIBS = @LIBS@ -LDFLAGS_GUI = @LDFLAGS_GUI@ -CXX = @CXX@ -CXXFLAGS = @CXXFLAGS@ -CPPFLAGS = @CPPFLAGS@ -LDFLAGS = @LDFLAGS@ -USE_DPI_AWARE_MANIFEST = @USE_DPI_AWARE_MANIFEST@ -WX_LIB_FLAVOUR = @WX_LIB_FLAVOUR@ -TOOLKIT = @TOOLKIT@ -TOOLKIT_LOWERCASE = @TOOLKIT_LOWERCASE@ -TOOLKIT_VERSION = @TOOLKIT_VERSION@ -TOOLCHAIN_FULLNAME = @TOOLCHAIN_FULLNAME@ -EXTRALIBS = @EXTRALIBS@ -EXTRALIBS_XML = @EXTRALIBS_XML@ -EXTRALIBS_GUI = @EXTRALIBS_GUI@ -WX_CPPFLAGS = @WX_CPPFLAGS@ -WX_CXXFLAGS = @WX_CXXFLAGS@ -WX_LDFLAGS = @WX_LDFLAGS@ -HOST_SUFFIX = @HOST_SUFFIX@ -SAMPLES_RPATH_FLAG = @SAMPLES_RPATH_FLAG@ -SAMPLES_CXXFLAGS = @SAMPLES_CXXFLAGS@ -wx_top_builddir = @wx_top_builddir@ - -### Variables: ### - -DESTDIR = -WX_RELEASE = 3.1 -WX_VERSION = $(WX_RELEASE).5 -LIBDIRNAME = $(wx_top_builddir)/lib -HTMLCTRL_CXXFLAGS = $(WX_CPPFLAGS) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \ - $(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \ - $(__THREAD_DEFINE_p) -I$(srcdir) $(__DLLFLAG_p) \ - -I$(srcdir)/../../../samples $(WX_CXXFLAGS) $(SAMPLES_CXXFLAGS) $(CPPFLAGS) \ - $(CXXFLAGS) -HTMLCTRL_OBJECTS = \ - $(__htmlctrl___win32rc) \ - htmlctrl_htmlctrl.o - -### Conditionally set variables: ### - -@COND_DEPS_TRACKING_0@CXXC = $(CXX) -@COND_DEPS_TRACKING_1@CXXC = $(BK_DEPS) $(CXX) -@COND_USE_GUI_0@PORTNAME = base -@COND_USE_GUI_1@PORTNAME = $(TOOLKIT_LOWERCASE)$(TOOLKIT_VERSION) -@COND_TOOLKIT_MAC@WXBASEPORT = _carbon -@COND_BUILD_debug@WXDEBUGFLAG = d -@COND_UNICODE_1@WXUNICODEFLAG = u -@COND_WXUNIV_1@WXUNIVNAME = univ -@COND_MONOLITHIC_0@EXTRALIBS_FOR_BASE = $(EXTRALIBS) -@COND_MONOLITHIC_1@EXTRALIBS_FOR_BASE = $(EXTRALIBS) \ -@COND_MONOLITHIC_1@ $(EXTRALIBS_XML) $(EXTRALIBS_GUI) -@COND_MONOLITHIC_0@EXTRALIBS_FOR_GUI = $(EXTRALIBS_GUI) -@COND_MONOLITHIC_1@EXTRALIBS_FOR_GUI = -@COND_WXUNIV_1@__WXUNIV_DEFINE_p = -D__WXUNIVERSAL__ -@COND_WXUNIV_1@__WXUNIV_DEFINE_p_1 = --define __WXUNIVERSAL__ -@COND_DEBUG_FLAG_0@__DEBUG_DEFINE_p = -DwxDEBUG_LEVEL=0 -@COND_DEBUG_FLAG_0@__DEBUG_DEFINE_p_1 = --define wxDEBUG_LEVEL=0 -@COND_USE_EXCEPTIONS_0@__EXCEPTIONS_DEFINE_p = -DwxNO_EXCEPTIONS -@COND_USE_EXCEPTIONS_0@__EXCEPTIONS_DEFINE_p_1 = --define wxNO_EXCEPTIONS -@COND_USE_RTTI_0@__RTTI_DEFINE_p = -DwxNO_RTTI -@COND_USE_RTTI_0@__RTTI_DEFINE_p_1 = --define wxNO_RTTI -@COND_USE_THREADS_0@__THREAD_DEFINE_p = -DwxNO_THREADS -@COND_USE_THREADS_0@__THREAD_DEFINE_p_1 = --define wxNO_THREADS -@COND_SHARED_1@__DLLFLAG_p = -DWXUSINGDLL -@COND_SHARED_1@__DLLFLAG_p_1 = --define WXUSINGDLL -@COND_PLATFORM_WIN32_1@__WIN32_DPI_MANIFEST_p = \ -@COND_PLATFORM_WIN32_1@ --define \ -@COND_PLATFORM_WIN32_1@ wxUSE_DPI_AWARE_MANIFEST=$(USE_DPI_AWARE_MANIFEST) -COND_PLATFORM_OS2_1___htmlctrl___os2_emxbindcmd = $(NM) htmlctrl$(EXEEXT) | if \ - grep -q pmwin.763 ; then emxbind -ep htmlctrl$(EXEEXT) ; fi -@COND_PLATFORM_OS2_1@__htmlctrl___os2_emxbindcmd = $(COND_PLATFORM_OS2_1___htmlctrl___os2_emxbindcmd) -@COND_TOOLKIT_MSW@__RCDEFDIR_p = --include-dir \ -@COND_TOOLKIT_MSW@ $(LIBDIRNAME)/wx/include/$(TOOLCHAIN_FULLNAME) -@COND_PLATFORM_WIN32_1@__htmlctrl___win32rc = htmlctrl_sample_rc.o -@COND_PLATFORM_MACOSX_1@__htmlctrl_app_Contents_PkgInfo___depname \ -@COND_PLATFORM_MACOSX_1@ = htmlctrl.app/Contents/PkgInfo -@COND_PLATFORM_MACOSX_1@__htmlctrl_bundle___depname = htmlctrl_bundle -@COND_TOOLKIT_MAC@____htmlctrl_BUNDLE_TGT_REF_DEP = \ -@COND_TOOLKIT_MAC@ $(__htmlctrl_app_Contents_PkgInfo___depname) -@COND_TOOLKIT_OSX_CARBON@____htmlctrl_BUNDLE_TGT_REF_DEP \ -@COND_TOOLKIT_OSX_CARBON@ = $(__htmlctrl_app_Contents_PkgInfo___depname) -@COND_TOOLKIT_OSX_COCOA@____htmlctrl_BUNDLE_TGT_REF_DEP \ -@COND_TOOLKIT_OSX_COCOA@ = $(__htmlctrl_app_Contents_PkgInfo___depname) -@COND_TOOLKIT_OSX_IPHONE@____htmlctrl_BUNDLE_TGT_REF_DEP \ -@COND_TOOLKIT_OSX_IPHONE@ = $(__htmlctrl_app_Contents_PkgInfo___depname) -@COND_TOOLKIT_COCOA@____htmlctrl_BUNDLE_TGT_REF_DEP = \ -@COND_TOOLKIT_COCOA@ $(__htmlctrl_app_Contents_PkgInfo___depname) -COND_MONOLITHIC_0___WXLIB_CORE_p = \ - -lwx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_core-$(WX_RELEASE)$(HOST_SUFFIX) -@COND_MONOLITHIC_0@__WXLIB_CORE_p = $(COND_MONOLITHIC_0___WXLIB_CORE_p) -COND_MONOLITHIC_0___WXLIB_BASE_p = \ - -lwx_base$(WXBASEPORT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX) -@COND_MONOLITHIC_0@__WXLIB_BASE_p = $(COND_MONOLITHIC_0___WXLIB_BASE_p) -COND_MONOLITHIC_1___WXLIB_MONO_p = \ - -lwx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX) -@COND_MONOLITHIC_1@__WXLIB_MONO_p = $(COND_MONOLITHIC_1___WXLIB_MONO_p) -@COND_MONOLITHIC_1_USE_STC_1@__LIB_SCINTILLA_IF_MONO_p \ -@COND_MONOLITHIC_1_USE_STC_1@ = \ -@COND_MONOLITHIC_1_USE_STC_1@ -lwxscintilla$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX) -@COND_USE_GUI_1_wxUSE_LIBTIFF_builtin@__LIB_TIFF_p \ -@COND_USE_GUI_1_wxUSE_LIBTIFF_builtin@ = \ -@COND_USE_GUI_1_wxUSE_LIBTIFF_builtin@ -lwxtiff$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX) -@COND_USE_GUI_1_wxUSE_LIBJPEG_builtin@__LIB_JPEG_p \ -@COND_USE_GUI_1_wxUSE_LIBJPEG_builtin@ = \ -@COND_USE_GUI_1_wxUSE_LIBJPEG_builtin@ -lwxjpeg$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX) -@COND_USE_GUI_1_wxUSE_LIBPNG_builtin@__LIB_PNG_p \ -@COND_USE_GUI_1_wxUSE_LIBPNG_builtin@ = \ -@COND_USE_GUI_1_wxUSE_LIBPNG_builtin@ -lwxpng$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX) -@COND_wxUSE_ZLIB_builtin@__LIB_ZLIB_p = \ -@COND_wxUSE_ZLIB_builtin@ -lwxzlib$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX) -COND_wxUSE_REGEX_builtin___LIB_REGEX_p = \ - -lwxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX) -@COND_wxUSE_REGEX_builtin@__LIB_REGEX_p = $(COND_wxUSE_REGEX_builtin___LIB_REGEX_p) -@COND_wxUSE_EXPAT_builtin@__LIB_EXPAT_p = \ -@COND_wxUSE_EXPAT_builtin@ -lwxexpat$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX) - -### Targets: ### - -all: htmlctrl$(EXEEXT) $(__htmlctrl_bundle___depname) - -install: - -uninstall: - -install-strip: install - -clean: - rm -rf ./.deps ./.pch - rm -f ./*.o - rm -f htmlctrl$(EXEEXT) - rm -rf htmlctrl.app - -distclean: clean - rm -f config.cache config.log config.status bk-deps bk-make-pch shared-ld-sh Makefile - -htmlctrl$(EXEEXT): $(HTMLCTRL_OBJECTS) $(__htmlctrl___win32rc) - $(CXX) -o $@ $(HTMLCTRL_OBJECTS) -L$(LIBDIRNAME) $(LDFLAGS_GUI) $(SAMPLES_RPATH_FLAG) $(LDFLAGS) $(WX_LDFLAGS) $(__WXLIB_CORE_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_SCINTILLA_IF_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) $(EXTRALIBS_FOR_GUI) $(__LIB_ZLIB_p) $(__LIB_REGEX_p) $(__LIB_EXPAT_p) $(EXTRALIBS_FOR_BASE) $(LIBS) - $(__htmlctrl___os2_emxbindcmd) - -@COND_PLATFORM_MACOSX_1@htmlctrl.app/Contents/PkgInfo: htmlctrl$(EXEEXT) $(top_srcdir)/src/osx/carbon/Info.plist.in $(top_srcdir)/src/osx/carbon/wxmac.icns -@COND_PLATFORM_MACOSX_1@ mkdir -p htmlctrl.app/Contents -@COND_PLATFORM_MACOSX_1@ mkdir -p htmlctrl.app/Contents/MacOS -@COND_PLATFORM_MACOSX_1@ mkdir -p htmlctrl.app/Contents/Resources -@COND_PLATFORM_MACOSX_1@ -@COND_PLATFORM_MACOSX_1@ -@COND_PLATFORM_MACOSX_1@ sed -e "s/IDENTIFIER/`echo $(srcdir) | sed -e 's,\.\./,,g' | sed -e 's,/,.,g'`/" \ -@COND_PLATFORM_MACOSX_1@ -e "s/EXECUTABLE/htmlctrl/" \ -@COND_PLATFORM_MACOSX_1@ -e "s/VERSION/$(WX_VERSION)/" \ -@COND_PLATFORM_MACOSX_1@ $(top_srcdir)/src/osx/carbon/Info.plist.in >htmlctrl.app/Contents/Info.plist -@COND_PLATFORM_MACOSX_1@ -@COND_PLATFORM_MACOSX_1@ -@COND_PLATFORM_MACOSX_1@ /bin/echo "APPL????" >htmlctrl.app/Contents/PkgInfo -@COND_PLATFORM_MACOSX_1@ -@COND_PLATFORM_MACOSX_1@ -@COND_PLATFORM_MACOSX_1@ ln -f htmlctrl$(EXEEXT) htmlctrl.app/Contents/MacOS/htmlctrl -@COND_PLATFORM_MACOSX_1@ -@COND_PLATFORM_MACOSX_1@ -@COND_PLATFORM_MACOSX_1@ cp -f $(top_srcdir)/src/osx/carbon/wxmac.icns htmlctrl.app/Contents/Resources/wxmac.icns - -@COND_PLATFORM_MACOSX_1@htmlctrl_bundle: $(____htmlctrl_BUNDLE_TGT_REF_DEP) - -htmlctrl_sample_rc.o: $(srcdir)/../../../samples/sample.rc - $(WINDRES) -i$< -o$@ --define __WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p_1) $(__DEBUG_DEFINE_p_1) $(__EXCEPTIONS_DEFINE_p_1) $(__RTTI_DEFINE_p_1) $(__THREAD_DEFINE_p_1) --include-dir $(srcdir) $(__DLLFLAG_p_1) $(__WIN32_DPI_MANIFEST_p) --include-dir $(srcdir)/../../../samples $(__RCDEFDIR_p) --include-dir $(top_srcdir)/include - -htmlctrl_htmlctrl.o: $(srcdir)/htmlctrl.cpp - $(CXXC) -c -o $@ $(HTMLCTRL_CXXFLAGS) $(srcdir)/htmlctrl.cpp - - -# Include dependency info, if present: -@IF_GNU_MAKE@-include ./.deps/*.d - -.PHONY: all install uninstall clean distclean htmlctrl_bundle diff --git a/samples/html/htmlctrl/htmlctrl.bkl b/samples/html/htmlctrl/htmlctrl.bkl deleted file mode 100644 index f38db09aa8..0000000000 --- a/samples/html/htmlctrl/htmlctrl.bkl +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - htmlctrl.cpp - core - base - - - diff --git a/samples/html/htmlctrl/htmlctrl.cpp b/samples/html/htmlctrl/htmlctrl.cpp deleted file mode 100644 index c70b93a7ce..0000000000 --- a/samples/html/htmlctrl/htmlctrl.cpp +++ /dev/null @@ -1,277 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: htmlctrl.cpp -// Purpose: HtmlCtrl sample -// Author: Julian Smart / Kevin Ollivier -// Modified by: -// Created: 04/16/2004 -// Copyright: (c) Julian Smart / Kevin Ollivier -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx/wx.h". -#include "wx/wxprec.h" - - -// for all others, include the necessary headers (this file is usually all you -// need because it includes almost all "standard" wxWidgets headers) -#ifndef WX_PRECOMP - #include "wx/wx.h" -#endif - -#include "wx/html/webkit.h" - -#ifndef wxHAS_IMAGES_IN_RESOURCES - #include "../../sample.xpm" -#endif - -// ---------------------------------------------------------------------------- -// resources -// ---------------------------------------------------------------------------- - -enum { - ID_BACK = wxID_HIGHEST + 1, - ID_NEXT = wxID_HIGHEST + 2, - ID_RELOAD = wxID_HIGHEST + 3, - ID_URLLIST = wxID_HIGHEST + 4, - ID_STOP = wxID_HIGHEST + 5, - ID_WEBKIT = wxID_HIGHEST + 6, - ID_VIEW_SOURCE = wxID_HIGHEST + 7, - ID_OPEN = wxID_HIGHEST + 8, - ID_SAVE = wxID_HIGHEST + 9, - ID_SET_SOURCE = wxID_HIGHEST + 10 -}; - -// ---------------------------------------------------------------------------- -// private classes -// ---------------------------------------------------------------------------- - -// Define a new application type, each program should derive a class from wxApp -class MyApp : public wxApp -{ -public: - // override base class virtuals - // ---------------------------- - - // this one is called on application startup and is a good place for the app - // initialization (doing it here and not in the ctor allows to have an error - // return: if OnInit() returns false, the application terminates) - virtual bool OnInit() wxOVERRIDE; -}; - -// Define a new frame type: this is going to be our main frame -class MyFrame : public wxFrame -{ -public: - // ctor(s) - MyFrame(const wxString& title); - void OnBackButton(wxCommandEvent& myEvent); - void OnNextButton(wxCommandEvent& myEvent); - void OnURLEnter(wxCommandEvent& myEvent); - void OnStopButton(wxCommandEvent& myEvent); - void OnReloadButton(wxCommandEvent& myEvent); - void OnViewSource(wxCommandEvent& myEvent); - void OnSetSource(wxCommandEvent& myEvent); - void OnStateChanged(wxWebKitStateChangedEvent& myEvent); - wxWebKitCtrl* mySafari; - wxTextCtrl* urlText; -private: - // any class wishing to process wxWidgets events must use this macro - wxDECLARE_EVENT_TABLE(); -}; - -// ---------------------------------------------------------------------------- -// event tables and other macros for wxWidgets -// ---------------------------------------------------------------------------- - -// the event tables connect the wxWidgets events with the functions (event -// handlers) which process them. It can be also done at run-time, but for the -// simple menu events like this the static method is much simpler. -wxBEGIN_EVENT_TABLE(MyFrame, wxFrame) - EVT_BUTTON(ID_BACK, MyFrame::OnBackButton) - EVT_BUTTON(ID_NEXT, MyFrame::OnNextButton) - EVT_BUTTON(ID_STOP, MyFrame::OnStopButton) - EVT_BUTTON(ID_RELOAD, MyFrame::OnReloadButton) - EVT_MENU(ID_VIEW_SOURCE, MyFrame::OnViewSource) - EVT_MENU(ID_SET_SOURCE, MyFrame::OnSetSource) - EVT_TEXT_ENTER(ID_URLLIST, MyFrame::OnURLEnter) - EVT_WEBKIT_STATE_CHANGED(MyFrame::OnStateChanged) - //EVT_MENU(Minimal_Quit, MyFrame::OnQuit) - //EVT_MENU(Minimal_About, MyFrame::OnAbout) -wxEND_EVENT_TABLE() - -// Create a new application object: this macro will allow wxWidgets to create -// the application object during program execution (it's better than using a -// static object for many reasons) and also implements the accessor function -// wxGetApp() which will return the reference of the right type (i.e. MyApp and -// not wxApp) -wxIMPLEMENT_APP(MyApp); - -// ============================================================================ -// implementation -// ============================================================================ - -// ---------------------------------------------------------------------------- -// the application class -// ---------------------------------------------------------------------------- - -// 'Main program' equivalent: the program execution "starts" here -bool MyApp::OnInit() -{ - if ( !wxApp::OnInit() ) - return false; - - // create the main application window - MyFrame *frame = new MyFrame("wxWebKit Sample"); - - // and show it (the frames, unlike simple controls, are not shown when - // created initially) - frame->Show(true); - - // success: wxApp::OnRun() will be called which will enter the main message - // loop and the application will run. If we returned false here, the - // application would exit immediately. - return true; -} - -// ---------------------------------------------------------------------------- -// main frame -// ---------------------------------------------------------------------------- - -// frame constructor -MyFrame::MyFrame(const wxString& title) - : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(500,500)) -{ - SetIcon(wxICON(sample)); - - wxMenuBar* myBar = new wxMenuBar(); - wxMenu* fileMenu = new wxMenu; - fileMenu->Append(ID_OPEN, _("&Open")); - fileMenu->Append(ID_SAVE, _("&Save")); - myBar->Append(fileMenu, _("&File")); - - wxMenu* editMenu = new wxMenu; - editMenu->Append(ID_SET_SOURCE, _("Set Page Source")); - myBar->Append(editMenu, _("&Edit")); - - //wxMenu* viewMenu = new wxMenu(_("View")); - //viewMenu->Append(ID_VIEW_SOURCE, _("View Source")); - //myBar->Append(viewMenu, _("View")); - - SetMenuBar(myBar); - - wxToolBar* myToolbar = CreateToolBar(); - wxButton* btnBack = new wxButton(myToolbar, ID_BACK, _("Back")); - myToolbar->AddControl(btnBack); - myToolbar->AddSeparator(); - wxButton* btnNext = new wxButton(myToolbar, ID_NEXT, _("Next")); - myToolbar->AddControl(btnNext); - myToolbar->AddSeparator(); - wxButton* btnStop = new wxButton(myToolbar, ID_STOP, _("Stop")); - myToolbar->AddControl(btnStop); - myToolbar->AddSeparator(); - wxButton* btnReload = new wxButton(myToolbar, ID_RELOAD, _("Reload")); - myToolbar->AddControl(btnReload); - myToolbar->AddSeparator(); - urlText = new wxTextCtrl(myToolbar, ID_URLLIST, "http://www.wxwidgets.org", wxDefaultPosition, wxSize(220, -1), wxTE_PROCESS_ENTER); - myToolbar->AddControl(urlText); - myToolbar->AddSeparator(); - myToolbar->Realize(); - - // Testing wxWebKitCtrl inside a panel -#if 1 - wxPanel* panel = new wxPanel(this, wxID_ANY); - - wxBoxSizer* boxSizer = new wxBoxSizer(wxVERTICAL); - panel->SetSizer(boxSizer); - - mySafari = new wxWebKitCtrl(panel, ID_WEBKIT, "http://www.wxwidgets.org", wxDefaultPosition, wxSize(200, 200)); - - boxSizer->Add(mySafari, 1, wxEXPAND); - - wxBoxSizer* frameSizer = new wxBoxSizer(wxVERTICAL); - SetSizer(frameSizer); - frameSizer->Add(panel, 1, wxEXPAND); -#else - mySafari = new wxWebKitCtrl(this, ID_WEBKIT, "http://www.wxwidgets.org", wxDefaultPosition, wxSize(200, 200)); -#endif - -#if wxUSE_STATUSBAR - CreateStatusBar(2); -#endif // wxUSE_STATUSBAR -} - -void MyFrame::OnBackButton(wxCommandEvent& WXUNUSED(myEvent)) -{ - if (mySafari->CanGoBack()) - mySafari->GoBack(); -} - -void MyFrame::OnNextButton(wxCommandEvent& WXUNUSED(myEvent)) -{ - if (mySafari->CanGoForward()) - mySafari->GoForward(); -} - -void MyFrame::OnStopButton(wxCommandEvent& WXUNUSED(myEvent)) -{ - mySafari->Stop(); -} - -void MyFrame::OnReloadButton(wxCommandEvent& WXUNUSED(myEvent)) -{ - mySafari->Reload(); -} - -void MyFrame::OnURLEnter(wxCommandEvent& WXUNUSED(myEvent)) -{ - mySafari->LoadURL(urlText->GetValue()); -} - -void MyFrame::OnStateChanged(wxWebKitStateChangedEvent& myEvent) -{ - if (GetStatusBar() != NULL) - { - if (myEvent.GetState() == wxWEBKIT_STATE_NEGOTIATING) - { - GetStatusBar()->SetStatusText(_("Contacting ") + myEvent.GetURL()); - urlText->SetValue(myEvent.GetURL()); - } - else if (myEvent.GetState() == wxWEBKIT_STATE_TRANSFERRING) - { - GetStatusBar()->SetStatusText(_("Loading ") + myEvent.GetURL()); - } - else if (myEvent.GetState() == wxWEBKIT_STATE_STOP) - { - GetStatusBar()->SetStatusText(_("Load complete.")); - SetTitle(mySafari->GetTitle()); - } - else if (myEvent.GetState() == wxWEBKIT_STATE_FAILED) - { - GetStatusBar()->SetStatusText(_("Failed to load ") + myEvent.GetURL()); - } - } - -} - -void MyFrame::OnViewSource(wxCommandEvent& WXUNUSED(myEvent)) -{ - if (mySafari->CanGetPageSource()) - wxMessageBox(mySafari->GetPageSource()); -} - -void MyFrame::OnSetSource(wxCommandEvent& WXUNUSED(myEvent)) -{ - if (mySafari) - { - wxString myText = "

Hello world!

"; - mySafari->SetPageSource(myText); - } -} diff --git a/samples/html/htmlctrl/makefile.unx b/samples/html/htmlctrl/makefile.unx deleted file mode 100644 index bc4620af8e..0000000000 --- a/samples/html/htmlctrl/makefile.unx +++ /dev/null @@ -1,100 +0,0 @@ -# ========================================================================= -# This makefile was generated by -# Bakefile 0.2.12 (http://www.bakefile.org) -# Do not modify, all changes will be overwritten! -# ========================================================================= - - - -# ------------------------------------------------------------------------- -# These are configurable options: -# ------------------------------------------------------------------------- - -# C++ compiler -CXX = `$(WX_CONFIG) --cxx` - -# Standard flags for C++ -CXXFLAGS ?= - -# Standard preprocessor flags (common for CC and CXX) -CPPFLAGS ?= - -# Standard linker flags -LDFLAGS ?= - -# Location and arguments of wx-config script -WX_CONFIG ?= wx-config - -# Port of the wx library to build against [gtk1,gtk2,msw,x11,motif,osx_cocoa,osx_carbon,dfb] -WX_PORT ?= $(shell $(WX_CONFIG) --query-toolkit) - -# Use DLL build of wx library to use? [0,1] -WX_SHARED ?= $(shell if test -z `$(WX_CONFIG) --query-linkage`; then echo 1; else echo 0; fi) - -# Compile Unicode build of wxWidgets? [0,1] -WX_UNICODE ?= $(shell $(WX_CONFIG) --query-chartype | sed 's/unicode/1/;s/ansi/0/') - -# Version of the wx library to build against. -WX_VERSION ?= $(shell $(WX_CONFIG) --query-version | sed -e 's/\([0-9]*\)\.\([0-9]*\)/\1\2/') - - - -# ------------------------------------------------------------------------- -# Do not modify the rest of this file! -# ------------------------------------------------------------------------- - -### Variables: ### - -CPPDEPS = -MT$@ -MF`echo $@ | sed -e 's,\.o$$,.d,'` -MD -MP -WX_VERSION_MAJOR = $(shell echo $(WX_VERSION) | cut -c1,1) -WX_VERSION_MINOR = $(shell echo $(WX_VERSION) | cut -c2,2) -WX_CONFIG_FLAGS = $(WX_CONFIG_UNICODE_FLAG) $(WX_CONFIG_SHARED_FLAG) \ - --toolkit=$(WX_PORT) --version=$(WX_VERSION_MAJOR).$(WX_VERSION_MINOR) -HTMLCTRL_CXXFLAGS = -I. `$(WX_CONFIG) --cxxflags $(WX_CONFIG_FLAGS)` $(CPPFLAGS) \ - $(CXXFLAGS) -HTMLCTRL_OBJECTS = \ - htmlctrl_htmlctrl.o - -### Conditionally set variables: ### - -ifeq ($(WX_UNICODE),0) -WX_CONFIG_UNICODE_FLAG = --unicode=no -endif -ifeq ($(WX_UNICODE),1) -WX_CONFIG_UNICODE_FLAG = --unicode=yes -endif -ifeq ($(WX_SHARED),0) -WX_CONFIG_SHARED_FLAG = --static=yes -endif -ifeq ($(WX_SHARED),1) -WX_CONFIG_SHARED_FLAG = --static=no -endif - - -### Targets: ### - -all: test_for_selected_wxbuild htmlctrl - -install: - -uninstall: - -clean: - rm -f ./*.o - rm -f ./*.d - rm -f htmlctrl - -test_for_selected_wxbuild: - @$(WX_CONFIG) $(WX_CONFIG_FLAGS) - -htmlctrl: $(HTMLCTRL_OBJECTS) - $(CXX) -o $@ $(HTMLCTRL_OBJECTS) $(LDFLAGS) `$(WX_CONFIG) $(WX_CONFIG_FLAGS) --libs core,base` - -htmlctrl_htmlctrl.o: ./htmlctrl.cpp - $(CXX) -c -o $@ $(HTMLCTRL_CXXFLAGS) $(CPPDEPS) $< - -.PHONY: all install uninstall clean - - -# Dependencies tracking: --include ./*.d diff --git a/samples/webview/webview.cpp b/samples/webview/webview.cpp index 6e512cc757..b6902965b3 100644 --- a/samples/webview/webview.cpp +++ b/samples/webview/webview.cpp @@ -383,13 +383,21 @@ WebFrame::WebFrame(const wxString& url) : wxLogMessage("Edge backend not available"); } #endif - m_browser = wxWebView::New(this, wxID_ANY, url, wxDefaultPosition, wxDefaultSize, backend); + m_browser = wxWebView::New(backend); +#ifdef __WXMAC__ + // With WKWebView handlers need to be registered before creation + m_browser->RegisterHandler(wxSharedPtr(new wxWebViewArchiveHandler("wxfs"))); + m_browser->RegisterHandler(wxSharedPtr(new wxWebViewFSHandler("memory"))); +#endif + m_browser->Create(this, wxID_ANY, url, wxDefaultPosition, wxDefaultSize); topsizer->Add(m_browser, wxSizerFlags().Expand().Proportion(1)); +#ifndef __WXMAC__ //We register the wxfs:// protocol for testing purposes m_browser->RegisterHandler(wxSharedPtr(new wxWebViewArchiveHandler("wxfs"))); //And the memory: file system m_browser->RegisterHandler(wxSharedPtr(new wxWebViewFSHandler("memory"))); +#endif SetSizer(topsizer); @@ -819,8 +827,6 @@ void WebFrame::OnNavigationRequest(wxWebViewEvent& evt) wxLogMessage("%s", "Navigation request to '" + evt.GetURL() + "' (target='" + evt.GetTarget() + "')"); - wxASSERT(m_browser->IsBusy()); - //If we don't want to handle navigation then veto the event and navigation //will not take place, we also need to stop the loading animation if(!m_tools_handle_navigation->IsChecked()) diff --git a/src/html/htmlctrl/webkit/webkit.mm b/src/html/htmlctrl/webkit/webkit.mm deleted file mode 100644 index 1052900d6e..0000000000 --- a/src/html/htmlctrl/webkit/webkit.mm +++ /dev/null @@ -1,588 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/html/htmlctrl/webkit/webkit.mm -// Purpose: wxWebKitCtrl - embeddable web kit control -// Author: Jethro Grassie / Kevin Ollivier -// Modified by: -// Created: 2004-4-16 -// Copyright: (c) Jethro Grassie / Kevin Ollivier -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" -#include "wx/splitter.h" - -#ifndef WX_PRECOMP - #include "wx/wx.h" -#endif - -#if wxUSE_WEBKIT - -#include "wx/osx/private.h" - -#include -#if __MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_15 -#include -#include -#endif - -#include "wx/html/webkit.h" - -#define DEBUG_WEBKIT_SIZING 0 - -extern WXDLLEXPORT_DATA(const char) wxWebKitCtrlNameStr[] = "webkitctrl"; - -// ---------------------------------------------------------------------------- -// macros -// ---------------------------------------------------------------------------- - -wxIMPLEMENT_DYNAMIC_CLASS(wxWebKitCtrl, wxControl); - -wxBEGIN_EVENT_TABLE(wxWebKitCtrl, wxControl) -wxEND_EVENT_TABLE() - -// ---------------------------------------------------------------------------- -// wxWebKit Events -// ---------------------------------------------------------------------------- - -wxIMPLEMENT_DYNAMIC_CLASS(wxWebKitStateChangedEvent, wxCommandEvent); - -wxDEFINE_EVENT( wxEVT_WEBKIT_STATE_CHANGED, wxWebKitStateChangedEvent ); - -wxWebKitStateChangedEvent::wxWebKitStateChangedEvent( wxWindow* win ) -{ - SetEventType( wxEVT_WEBKIT_STATE_CHANGED); - if ( win ) - { - SetEventObject( win ); - SetId(win->GetId()); - } -} - -wxIMPLEMENT_DYNAMIC_CLASS(wxWebKitBeforeLoadEvent, wxCommandEvent); - -wxDEFINE_EVENT( wxEVT_WEBKIT_BEFORE_LOAD, wxWebKitBeforeLoadEvent ); - -wxWebKitBeforeLoadEvent::wxWebKitBeforeLoadEvent( wxWindow* win ) -{ - m_cancelled = false; - SetEventType( wxEVT_WEBKIT_BEFORE_LOAD); - if ( win ) - { - SetEventObject( win ); - SetId(win->GetId()); - } -} - - -wxIMPLEMENT_DYNAMIC_CLASS(wxWebKitNewWindowEvent, wxCommandEvent); - -wxDEFINE_EVENT( wxEVT_WEBKIT_NEW_WINDOW, wxWebKitNewWindowEvent ); - -wxWebKitNewWindowEvent::wxWebKitNewWindowEvent( wxWindow* win ) -{ - SetEventType( wxEVT_WEBKIT_NEW_WINDOW); - if ( win ) - { - SetEventObject( win ); - SetId(win->GetId()); - } -} - -inline int wxNavTypeFromWebNavType(int type){ - if (type == WebNavigationTypeLinkClicked) - return wxWEBKIT_NAV_LINK_CLICKED; - - if (type == WebNavigationTypeFormSubmitted) - return wxWEBKIT_NAV_FORM_SUBMITTED; - - if (type == WebNavigationTypeBackForward) - return wxWEBKIT_NAV_BACK_NEXT; - - if (type == WebNavigationTypeReload) - return wxWEBKIT_NAV_RELOAD; - - if (type == WebNavigationTypeFormResubmitted) - return wxWEBKIT_NAV_FORM_RESUBMITTED; - - return wxWEBKIT_NAV_OTHER; -} - -@interface MyFrameLoadMonitor : NSObject -{ - wxWebKitCtrl* webKitWindow; -} - -- (id)initWithWxWindow: (wxWebKitCtrl*)inWindow; - -@end - -@interface MyPolicyDelegate : NSObject -{ - wxWebKitCtrl* webKitWindow; -} - -- (id)initWithWxWindow: (wxWebKitCtrl*)inWindow; - -@end - -@interface MyUIDelegate : NSObject -{ - wxWebKitCtrl* webKitWindow; -} - -- (id)initWithWxWindow: (wxWebKitCtrl*)inWindow; - -@end - -// ---------------------------------------------------------------------------- -// creation/destruction -// ---------------------------------------------------------------------------- - -bool wxWebKitCtrl::Create(wxWindow *parent, - wxWindowID winID, - const wxString& strURL, - const wxPoint& pos, - const wxSize& size, long style, - const wxValidator& validator, - const wxString& name) -{ - m_currentURL = strURL; - //m_pageTitle = _("Untitled Page"); - - //still needed for wxCocoa?? -/* - int width, height; - wxSize sizeInstance; - if (size.x == wxDefaultCoord || size.y == wxDefaultCoord) - { - m_parent->GetClientSize(&width, &height); - sizeInstance.x = width; - sizeInstance.y = height; - } - else - { - sizeInstance.x = size.x; - sizeInstance.y = size.y; - } -*/ - // now create and attach WebKit view... - DontCreatePeer(); - wxControl::Create(parent, winID, pos, size, style , validator , name); - NSRect r = wxOSXGetFrameForControl( this, pos , size ) ; - m_webView = [[WebView alloc] initWithFrame:r frameName:@"webkitFrame" groupName:@"webkitGroup"]; - - SetPeer(new wxWidgetCocoaImpl( this, m_webView )); - MacPostControlCreate(pos, size); - [m_webView setHidden:false]; - - - // Register event listener interfaces - - MyFrameLoadMonitor* myFrameLoadMonitor = [[MyFrameLoadMonitor alloc] initWithWxWindow: this]; - [m_webView setFrameLoadDelegate:myFrameLoadMonitor]; - m_frameLoadMonitor = myFrameLoadMonitor; - - // this is used to veto page loads, etc. - MyPolicyDelegate* myPolicyDelegate = [[MyPolicyDelegate alloc] initWithWxWindow: this]; - [m_webView setPolicyDelegate:myPolicyDelegate]; - m_policyDelegate = myPolicyDelegate; - - // this is used to provide printing support for JavaScript - MyUIDelegate* myUIDelegate = [[MyUIDelegate alloc] initWithWxWindow: this]; - [m_webView setUIDelegate:myUIDelegate]; - m_UIDelegate = myUIDelegate; - - LoadURL(m_currentURL); - return true; -} - -wxWebKitCtrl::~wxWebKitCtrl() -{ - [m_webView setFrameLoadDelegate: nil]; - [m_webView setPolicyDelegate: nil]; - [m_webView setUIDelegate: nil]; - - if (m_frameLoadMonitor) - [m_frameLoadMonitor release]; - - if (m_policyDelegate) - [m_policyDelegate release]; - - if (m_UIDelegate) - [m_UIDelegate release]; -} - -// ---------------------------------------------------------------------------- -// public methods -// ---------------------------------------------------------------------------- - -void wxWebKitCtrl::LoadURL(const wxString &url) -{ - if( !m_webView ) - return; - - [[m_webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:wxNSStringWithWxString(url)]]]; - - m_currentURL = url; -} - -bool wxWebKitCtrl::CanGoBack(){ - if ( !m_webView ) - return false; - - return [m_webView canGoBack]; -} - -bool wxWebKitCtrl::CanGoForward(){ - if ( !m_webView ) - return false; - - return [m_webView canGoForward]; -} - -bool wxWebKitCtrl::GoBack(){ - if ( !m_webView ) - return false; - - bool result = [(WebView*)m_webView goBack]; - return result; -} - -bool wxWebKitCtrl::GoForward(){ - if ( !m_webView ) - return false; - - bool result = [(WebView*)m_webView goForward]; - return result; -} - -void wxWebKitCtrl::Reload(){ - if ( !m_webView ) - return; - - [[m_webView mainFrame] reload]; -} - -void wxWebKitCtrl::Stop(){ - if ( !m_webView ) - return; - - [[m_webView mainFrame] stopLoading]; -} - -bool wxWebKitCtrl::CanGetPageSource(){ - if ( !m_webView ) - return false; - - WebDataSource* dataSource = [[m_webView mainFrame] dataSource]; - return ( [[dataSource representation] canProvideDocumentSource] ); -} - -wxString wxWebKitCtrl::GetPageSource(){ - - if (CanGetPageSource()){ - WebDataSource* dataSource = [[m_webView mainFrame] dataSource]; - return wxStringWithNSString( [[dataSource representation] documentSource] ); - } - - return wxEmptyString; -} - -wxString wxWebKitCtrl::GetSelection(){ - if ( !m_webView ) - return wxEmptyString; - - NSString* selectedText = [[m_webView selectedDOMRange] toString]; - return wxStringWithNSString( selectedText ); -} - -bool wxWebKitCtrl::CanIncreaseTextSize(){ - if ( !m_webView ) - return false; - - if ([m_webView canMakeTextLarger]) - return true; - else - return false; -} - -void wxWebKitCtrl::IncreaseTextSize(){ - if ( !m_webView ) - return; - - if (CanIncreaseTextSize()) - [m_webView makeTextLarger:(WebView*)m_webView]; -} - -bool wxWebKitCtrl::CanDecreaseTextSize(){ - if ( !m_webView ) - return false; - - if ([m_webView canMakeTextSmaller]) - return true; - else - return false; -} - -void wxWebKitCtrl::DecreaseTextSize(){ - if ( !m_webView ) - return; - - if (CanDecreaseTextSize()) - [m_webView makeTextSmaller:(WebView*)m_webView]; -} - -void wxWebKitCtrl::SetPageSource(const wxString& source, const wxString& baseUrl){ - if ( !m_webView ) - return; - - [[m_webView mainFrame] loadHTMLString:(NSString*)wxNSStringWithWxString( source ) baseURL:[NSURL URLWithString:wxNSStringWithWxString( baseUrl )]]; - -} - -void wxWebKitCtrl::Print(bool showPrompt){ - if ( !m_webView ) - return; - - id view = [[[m_webView mainFrame] frameView] documentView]; - NSPrintOperation *op = [NSPrintOperation printOperationWithView:view printInfo: [NSPrintInfo sharedPrintInfo]]; - if (showPrompt){ - [op setShowsPrintPanel: showPrompt]; - // in my tests, the progress bar always freezes and it stops the whole print operation. - // do not turn this to true unless there is a workaround for the bug. - [op setShowsProgressPanel: false]; - } - // Print it. - [op runOperation]; -} - -void wxWebKitCtrl::MakeEditable(bool enable){ - if ( !m_webView ) - return; - - [m_webView setEditable:enable ]; -} - -bool wxWebKitCtrl::IsEditable(){ - if ( !m_webView ) - return false; - - return [m_webView isEditable]; -} - -int wxWebKitCtrl::GetScrollPos(){ - id result = [[m_webView windowScriptObject] evaluateWebScript:@"document.body.scrollTop"]; - return [result intValue]; -} - -void wxWebKitCtrl::SetScrollPos(int pos){ - if ( !m_webView ) - return; - - wxString javascript; - javascript.Printf(wxT("document.body.scrollTop = %d;"), pos); - [[m_webView windowScriptObject] evaluateWebScript:(NSString*)wxNSStringWithWxString( javascript )]; -} - -wxString wxWebKitCtrl::RunScript(const wxString& javascript){ - if ( !m_webView ) - return wxEmptyString; - - id result = [[m_webView windowScriptObject] evaluateWebScript:(NSString*)wxNSStringWithWxString( javascript )]; - - NSString* resultAsString; - if ([result isKindOfClass:[NSNumber class]]){ - // __NSCFBoolean is a subclass of NSNumber - if (strcmp([result objCType], @encode(BOOL)) == 0){ - if ([result boolValue]) - resultAsString = @"true"; - else - resultAsString = @"false"; - } - else - resultAsString = [NSString stringWithFormat:@"%@", result]; - } - else if ([result isKindOfClass:[NSString class]]) - resultAsString = result; - else if ([result isKindOfClass:[WebScriptObject class]]) - resultAsString = [result stringRepresentation]; - else - return wxString(); // This can happen, see e.g. #12361. - - return wxStringWithNSString( resultAsString ); -} - -void wxWebKitCtrl::OnSize(wxSizeEvent &event){ - event.Skip(); -} - -void wxWebKitCtrl::MacVisibilityChanged(){ -} - -//------------------------------------------------------------ -// Listener interfaces -//------------------------------------------------------------ - -// NB: I'm still tracking this down, but it appears the Cocoa window -// still has these events fired on it while the Carbon control is being -// destroyed. Therefore, we must be careful to check both the existence -// of the Carbon control and the event handler before firing events. - -@implementation MyFrameLoadMonitor - -- (id)initWithWxWindow: (wxWebKitCtrl*)inWindow -{ - if ( self = [super init] ) - { - webKitWindow = inWindow; // non retained - } - return self; -} - -- (void)webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame -{ - if (webKitWindow && frame == [sender mainFrame]){ - NSString *url = [[[[frame provisionalDataSource] request] URL] absoluteString]; - wxWebKitStateChangedEvent thisEvent(webKitWindow); - thisEvent.SetState(wxWEBKIT_STATE_NEGOTIATING); - thisEvent.SetURL( wxStringWithNSString( url ) ); - if (webKitWindow->GetEventHandler()) - webKitWindow->GetEventHandler()->ProcessEvent( thisEvent ); - } -} - -- (void)webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame -{ - if (webKitWindow && frame == [sender mainFrame]){ - NSString *url = [[[[frame dataSource] request] URL] absoluteString]; - wxWebKitStateChangedEvent thisEvent(webKitWindow); - thisEvent.SetState(wxWEBKIT_STATE_TRANSFERRING); - thisEvent.SetURL( wxStringWithNSString( url ) ); - if (webKitWindow->GetEventHandler()) - webKitWindow->GetEventHandler()->ProcessEvent( thisEvent ); - } -} - -- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame -{ - if (webKitWindow && frame == [sender mainFrame]){ - NSString *url = [[[[frame dataSource] request] URL] absoluteString]; - wxWebKitStateChangedEvent thisEvent(webKitWindow); - thisEvent.SetState(wxWEBKIT_STATE_STOP); - thisEvent.SetURL( wxStringWithNSString( url ) ); - if (webKitWindow->GetEventHandler()) - webKitWindow->GetEventHandler()->ProcessEvent( thisEvent ); - } -} - -- (void)webView:(WebView *)sender didFailLoadWithError:(NSError*) error forFrame:(WebFrame *)frame -{ - wxUnusedVar(error); - - if (webKitWindow && frame == [sender mainFrame]){ - NSString *url = [[[[frame dataSource] request] URL] absoluteString]; - wxWebKitStateChangedEvent thisEvent(webKitWindow); - thisEvent.SetState(wxWEBKIT_STATE_FAILED); - thisEvent.SetURL( wxStringWithNSString( url ) ); - if (webKitWindow->GetEventHandler()) - webKitWindow->GetEventHandler()->ProcessEvent( thisEvent ); - } -} - -- (void)webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError*) error forFrame:(WebFrame *)frame -{ - wxUnusedVar(error); - - if (webKitWindow && frame == [sender mainFrame]){ - NSString *url = [[[[frame provisionalDataSource] request] URL] absoluteString]; - wxWebKitStateChangedEvent thisEvent(webKitWindow); - thisEvent.SetState(wxWEBKIT_STATE_FAILED); - thisEvent.SetURL( wxStringWithNSString( url ) ); - if (webKitWindow->GetEventHandler()) - webKitWindow->GetEventHandler()->ProcessEvent( thisEvent ); - } -} - -- (void)webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame -{ - if (webKitWindow && frame == [sender mainFrame]){ - webKitWindow->SetPageTitle(wxStringWithNSString( title )); - } -} -@end - -@implementation MyPolicyDelegate - -- (id)initWithWxWindow: (wxWebKitCtrl*)inWindow -{ - if ( self = [super init] ) - { - webKitWindow = inWindow; // non retained - } - return self; -} - -- (void)webView:(WebView *)sender decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id)listener -{ - wxUnusedVar(sender); - wxUnusedVar(frame); - - wxWebKitBeforeLoadEvent thisEvent(webKitWindow); - - // Get the navigation type. - NSNumber *n = [actionInformation objectForKey:WebActionNavigationTypeKey]; - int actionType = [n intValue]; - thisEvent.SetNavigationType( wxNavTypeFromWebNavType(actionType) ); - - NSString *url = [[request URL] absoluteString]; - thisEvent.SetURL( wxStringWithNSString( url ) ); - - if (webKitWindow && webKitWindow->GetEventHandler()) - webKitWindow->GetEventHandler()->ProcessEvent(thisEvent); - - if (thisEvent.IsCancelled()) - [listener ignore]; - else - [listener use]; -} - -- (void)webView:(WebView *)sender decidePolicyForNewWindowAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request newFrameName:(NSString *)frameName decisionListener:(id < WebPolicyDecisionListener >)listener -{ - wxUnusedVar(sender); - wxUnusedVar(actionInformation); - wxWebKitNewWindowEvent thisEvent(webKitWindow); - - NSString *url = [[request URL] absoluteString]; - thisEvent.SetURL( wxStringWithNSString( url ) ); - thisEvent.SetTargetName( wxStringWithNSString( frameName ) ); - - if (webKitWindow && webKitWindow->GetEventHandler()) - webKitWindow->GetEventHandler()->ProcessEvent(thisEvent); - - [listener use]; -} -@end - - -@implementation MyUIDelegate - -- (id)initWithWxWindow: (wxWebKitCtrl*)inWindow -{ - if ( self = [super init] ) - { - webKitWindow = inWindow; // non retained - } - return self; -} - -- (void)webView:(WebView *)sender printFrameView:(WebFrameView *)frameView -{ - wxUnusedVar(sender); - wxUnusedVar(frameView); - - webKitWindow->Print(true); -} -@end - -#endif //wxUSE_WEBKIT diff --git a/src/osx/webview_webkit.mm b/src/osx/webview_webkit.mm index 7cc5c72d79..b1d1205354 100644 --- a/src/osx/webview_webkit.mm +++ b/src/osx/webview_webkit.mm @@ -9,11 +9,11 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -// http://developer.apple.com/mac/library/documentation/Cocoa/Reference/WebKit/Classes/WebView_Class/Reference/Reference.html +// https://developer.apple.com/documentation/webkit/wkwebview #include "wx/osx/webview_webkit.h" -#if wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && defined(__WXOSX__) +#if wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && defined(__WXOSX__) // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -24,20 +24,16 @@ #include "wx/osx/private.h" #include "wx/osx/core/cfref.h" +#include "wx/osx/private/available.h" #include "wx/private/jsscriptwrapper.h" #include "wx/hashmap.h" #include "wx/filesys.h" +#include "wx/msgdlg.h" +#include "wx/textdlg.h" +#include "wx/filedlg.h" -#if wxOSX_USE_IPHONE -#include -#else #include -#if __MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_15 - #include - #include -#endif -#endif #include // using native types to get compile errors and warnings @@ -53,7 +49,16 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxWebViewWebKit, wxWebView); wxBEGIN_EVENT_TABLE(wxWebViewWebKit, wxControl) wxEND_EVENT_TABLE() -@interface WebViewLoadDelegate : NSObject +@interface WXWKWebView: WKWebView +{ + wxWebViewWebKit* m_webView; +} + +- (void)setWebView:(wxWebViewWebKit*)webView; + +@end + +@interface WebViewNavigationDelegate : NSObject { wxWebViewWebKit* webKitWindow; } @@ -62,7 +67,7 @@ wxEND_EVENT_TABLE() @end -@interface WebViewPolicyDelegate : NSObject +@interface WebViewUIDelegate : NSObject { wxWebViewWebKit* webKitWindow; } @@ -71,24 +76,16 @@ wxEND_EVENT_TABLE() @end -@interface WebViewUIDelegate : NSObject +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_13 +@interface WebViewCustomProtocol : NSObject { - wxWebViewWebKit* webKitWindow; + wxWebViewHandler* m_handler; } -- (id)initWithWxWindow: (wxWebViewWebKit*)inWindow; +- (id)initWithHandler:(wxWebViewHandler*) handler; @end - -//We use a hash to map scheme names to wxWebViewHandler -WX_DECLARE_STRING_HASH_MAP(wxSharedPtr, wxStringToWebHandlerMap); - -static wxStringToWebHandlerMap g_stringHandlerMap; - -@interface WebViewCustomProtocol : NSURLProtocol -{ -} -@end +#endif // macOS 10.13+ // ---------------------------------------------------------------------------- // creation/destruction @@ -101,25 +98,30 @@ bool wxWebViewWebKit::Create(wxWindow *parent, const wxSize& size, long style, const wxString& name) { - m_busy = false; - m_nextNavigationIsNewWindow = false; - DontCreatePeer(); wxControl::Create(parent, winID, pos, size, style, wxDefaultValidator, name); -#if wxOSX_USE_IPHONE - CGRect r = wxOSXGetFrameForControl( this, pos , size ) ; - m_webView = [[UIWebView alloc] initWithFrame:r]; - - SetPeer( new wxWidgetIPhoneImpl( this, m_webView ) ); - -#else NSRect r = wxOSXGetFrameForControl( this, pos , size ) ; - m_webView = [[WebView alloc] initWithFrame:r - frameName:@"webkitFrame" - groupName:@"webkitGroup"]; + WKWebViewConfiguration* webViewConfig = [[WKWebViewConfiguration alloc] init]; + if (!m_handlers.empty()) + { +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_13 + if ( WX_IS_MACOS_AVAILABLE(10, 13) ) + { + for (wxStringToWebHandlerMap::iterator it = m_handlers.begin(); it != m_handlers.end(); it++) + { + [webViewConfig setURLSchemeHandler:[[WebViewCustomProtocol alloc] initWithHandler:it->second.get()] + forURLScheme:wxCFStringRef(it->first).AsNSString()]; + } + } + else +#endif // macOS 10.13+ + wxLogDebug("Registering custom wxWebView handlers is not supported under macOS < 10.13"); + } + + m_webView = [[WXWKWebView alloc] initWithFrame:r configuration:webViewConfig]; + [(WXWKWebView*)m_webView setWebView:this]; SetPeer(new wxWidgetCocoaImpl( this, m_webView )); -#endif MacPostControlCreate(pos, size); @@ -127,32 +129,20 @@ bool wxWebViewWebKit::Create(wxWindow *parent, // Register event listener interfaces -#if wxOSX_USE_IPHONE -#else - WebViewLoadDelegate* loadDelegate = - [[WebViewLoadDelegate alloc] initWithWxWindow: this]; + WebViewNavigationDelegate* navDelegate = + [[WebViewNavigationDelegate alloc] initWithWxWindow: this]; + [m_webView addObserver:navDelegate forKeyPath:@"title" options:0 context:this]; - [m_webView setFrameLoadDelegate:loadDelegate]; - - m_loadDelegate = loadDelegate; + [m_webView setNavigationDelegate:navDelegate]; - // this is used to veto page loads, etc. - WebViewPolicyDelegate* policyDelegate = - [[WebViewPolicyDelegate alloc] initWithWxWindow: this]; - - [m_webView setPolicyDelegate:policyDelegate]; - - m_policyDelegate = policyDelegate; + m_navigationDelegate = navDelegate; WebViewUIDelegate* uiDelegate = [[WebViewUIDelegate alloc] initWithWxWindow: this]; [m_webView setUIDelegate:uiDelegate]; - + m_UIDelegate = uiDelegate; -#endif - //Register our own class for custom scheme handling - [NSURLProtocol registerClass:[WebViewCustomProtocol class]]; LoadURL(strURL); return true; @@ -160,16 +150,12 @@ bool wxWebViewWebKit::Create(wxWindow *parent, wxWebViewWebKit::~wxWebViewWebKit() { -#if wxOSX_USE_IPHONE -#else - [m_webView setFrameLoadDelegate: nil]; - [m_webView setPolicyDelegate: nil]; + [m_webView removeObserver:m_navigationDelegate forKeyPath:@"title" context:this]; + [m_webView setNavigationDelegate: nil]; [m_webView setUIDelegate: nil]; - [m_loadDelegate release]; - [m_policyDelegate release]; + [m_navigationDelegate release]; [m_UIDelegate release]; -#endif } // ---------------------------------------------------------------------------- @@ -208,6 +194,11 @@ void wxWebViewWebKit::GoForward() [m_webView goForward]; } +bool wxWebViewWebKit::IsBusy() const +{ + return m_webView.loading ? true : false; +} + void wxWebViewWebKit::Reload(wxWebViewReloadFlags flags) { if ( !m_webView ) @@ -215,14 +206,11 @@ void wxWebViewWebKit::Reload(wxWebViewReloadFlags flags) if (flags & wxWEBVIEW_RELOAD_NO_CACHE) { - // TODO: test this indeed bypasses the cache - [[m_webView preferences] setUsesPageCache:NO]; - [[m_webView mainFrame] reload]; - [[m_webView preferences] setUsesPageCache:YES]; + [m_webView reloadFromOrigin]; } else { - [[m_webView mainFrame] reload]; + [m_webView reload]; } } @@ -231,79 +219,14 @@ void wxWebViewWebKit::Stop() if ( !m_webView ) return; - [[m_webView mainFrame] stopLoading]; -} - -bool wxWebViewWebKit::CanGetPageSource() const -{ - if ( !m_webView ) - return false; - - WebDataSource* dataSource = [[m_webView mainFrame] dataSource]; - return ( [[dataSource representation] canProvideDocumentSource] ); + [m_webView stopLoading]; } wxString wxWebViewWebKit::GetPageSource() const { - - if (CanGetPageSource()) - { - WebDataSource* dataSource = [[m_webView mainFrame] dataSource]; - wxASSERT (dataSource != nil); - - id representation = [dataSource representation]; - wxASSERT (representation != nil); - - NSString* source = [representation documentSource]; - if (source == nil) - { - return wxEmptyString; - } - - return wxCFStringRef::AsString( source ); - } - - return wxEmptyString; -} - -bool wxWebViewWebKit::CanIncreaseTextSize() const -{ - if ( !m_webView ) - return false; - - if ([m_webView canMakeTextLarger]) - return true; - else - return false; -} - -void wxWebViewWebKit::IncreaseTextSize() -{ - if ( !m_webView ) - return; - - if (CanIncreaseTextSize()) - [m_webView makeTextLarger:(WebView*)m_webView]; -} - -bool wxWebViewWebKit::CanDecreaseTextSize() const -{ - if ( !m_webView ) - return false; - - if ([m_webView canMakeTextSmaller]) - return true; - else - return false; -} - -void wxWebViewWebKit::DecreaseTextSize() -{ - if ( !m_webView ) - return; - - if (CanDecreaseTextSize()) - [m_webView makeTextSmaller:(WebView*)m_webView]; + wxString text; + const_cast(this)->RunScript("document.documentElement.outerHTML;", &text); + return text; } void wxWebViewWebKit::Print() @@ -315,9 +238,30 @@ void wxWebViewWebKit::Print() if ( !m_webView ) return; - id view = [[[m_webView mainFrame] frameView] documentView]; - NSPrintOperation *op = [NSPrintOperation printOperationWithView:view - printInfo: [NSPrintInfo sharedPrintInfo]]; + // As of macOS SDK 10.15 no offical printing API is available for WKWebView + // Try if the undocumented printOperationWithPrintInfo: is available and use it + // to create a printing operation + // https://bugs.webkit.org/show_bug.cgi?id=151276 + SEL printSelector = @selector(printOperationWithPrintInfo:); + if (![m_webView respondsToSelector:printSelector]) + printSelector = nil; + + if (!printSelector) + { + wxLogError(_("Printing is not supported by the system web control")); + return; + } + + NSPrintOperation* op = (NSPrintOperation*)[m_webView + performSelector:printSelector + withObject:[NSPrintInfo sharedPrintInfo]]; + if (!op) + { + wxLogError(_("Print operation could not be initialized")); + return; + } + + op.view.frame = m_webView.frame; if (showPrompt) { [op setShowsPrintPanel: showPrompt]; @@ -330,35 +274,25 @@ void wxWebViewWebKit::Print() [op runOperation]; } -void wxWebViewWebKit::SetEditable(bool enable) +void wxWebViewWebKit::SetEditable(bool WXUNUSED(enable)) { - if ( !m_webView ) - return; - - [m_webView setEditable:enable ]; } bool wxWebViewWebKit::IsEditable() const { - if ( !m_webView ) - return false; - - return [m_webView isEditable]; + return false; } void wxWebViewWebKit::SetZoomType(wxWebViewZoomType zoomType) { // there is only one supported zoom type at the moment so this setter // does nothing beyond checking sanity - wxASSERT(zoomType == wxWEBVIEW_ZOOM_TYPE_TEXT); + wxASSERT(zoomType == wxWEBVIEW_ZOOM_TYPE_LAYOUT); } wxWebViewZoomType wxWebViewWebKit::GetZoomType() const { - // for now that's the only one that is supported - // FIXME: does the default zoom type change depending on webkit versions? :S - // Then this will be wrong - return wxWEBVIEW_ZOOM_TYPE_TEXT; + return wxWEBVIEW_ZOOM_TYPE_LAYOUT; } bool wxWebViewWebKit::CanSetZoomType(wxWebViewZoomType type) const @@ -366,9 +300,7 @@ bool wxWebViewWebKit::CanSetZoomType(wxWebViewZoomType type) const switch (type) { // for now that's the only one that is supported - // TODO: I know recent versions of webkit support layout zoom too, - // check if we can support it - case wxWEBVIEW_ZOOM_TYPE_TEXT: + case wxWEBVIEW_ZOOM_TYPE_LAYOUT: return true; default: @@ -376,116 +308,104 @@ bool wxWebViewWebKit::CanSetZoomType(wxWebViewZoomType type) const } } -int wxWebViewWebKit::GetScrollPos() -{ - id result = [[m_webView windowScriptObject] - evaluateWebScript:@"document.body.scrollTop"]; - return [result intValue]; -} - -void wxWebViewWebKit::SetScrollPos(int pos) -{ - if ( !m_webView ) - return; - - wxString javascript; - javascript.Printf(wxT("document.body.scrollTop = %d;"), pos); - [[m_webView windowScriptObject] evaluateWebScript: - wxCFStringRef( javascript ).AsNSString()]; -} - wxString wxWebViewWebKit::GetSelectedText() const { - DOMRange* dr = [m_webView selectedDOMRange]; - if ( !dr ) - return wxString(); + wxString text; + const_cast(this)->RunScript("window.getSelection().toString();", &text); + return text; +} - return wxCFStringRef::AsString([dr toString]); +bool wxWebViewWebKit::RunScriptSync(const wxString& javascript, wxString* output) +{ + __block bool scriptExecuted = false; + __block wxString outputStr; + __block bool scriptSuccess = false; + + // Start script execution + [m_webView evaluateJavaScript:wxCFStringRef(javascript).AsNSString() + completionHandler:^(id _Nullable obj, NSError * _Nullable error) { + if (error) + { + outputStr.assign(wxCFStringRef(error.localizedFailureReason).AsString()); + } + else + { + if ([obj isKindOfClass:[NSNumber class]]) + { + NSNumber* num = (NSNumber*) obj; + CFTypeID numID = CFGetTypeID((__bridge CFTypeRef)(num)); + if (numID == CFBooleanGetTypeID()) + outputStr = num.boolValue ? "true" : "false"; + else + outputStr = wxCFStringRef::AsString(num.stringValue); + } + else if (obj) + outputStr.assign(wxCFStringRef::AsString([NSString stringWithFormat:@"%@", obj])); + + scriptSuccess = true; + } + + scriptExecuted = true; + }]; + + // Wait for script exection + while (!scriptExecuted) + wxYield(); + + if (output) + output->assign(outputStr); + + return scriptSuccess; } bool wxWebViewWebKit::RunScript(const wxString& javascript, wxString* output) { - wxCHECK_MSG( m_webView, false, - wxS("wxWebView must be created before calling RunScript()") ); - wxJSScriptWrapper wrapJS(javascript, &m_runScriptCount); - NSString* result = [m_webView stringByEvaluatingJavaScriptFromString: - wxCFStringRef( wrapJS.GetWrappedCode() ).AsNSString()]; - - wxString err; - if ( result == nil ) + // This string is also used as an error indicator: it's cleared if there is + // no error or used in the warning message below if there is one. + wxString result; + if (RunScriptSync(wrapJS.GetWrappedCode(), &result) + && result == wxS("true")) { - // This is not very informative, but we just don't have any other - // information in this case. - err = _("failed to evaluate"); - } - else if ( [result isEqualToString:@"true"] ) - { - result = [m_webView stringByEvaluatingJavaScriptFromString: - wxCFStringRef( wrapJS.GetOutputCode() ).AsNSString()]; - - [m_webView stringByEvaluatingJavaScriptFromString: - wxCFStringRef( wrapJS.GetCleanUpCode() ).AsNSString()]; - - if ( output != NULL ) + if (RunScriptSync(wrapJS.GetOutputCode() + ";", &result)) { - if ( result ) - *output = wxCFStringRef::AsString(result); - else - err = _("failed to retrieve execution result"); + if (output) + *output = result; + result.clear(); } - } - else // result available but not the expected "true" - { - err = wxCFStringRef::AsString(result); + + RunScriptSync(wrapJS.GetCleanUpCode()); } - if ( !err.empty() ) + if (!result.empty()) { - wxLogWarning(_("Error running JavaScript: %s"), err); + wxLogWarning(_("Error running JavaScript: %s"), result); return false; } return true; } -void wxWebViewWebKit::OnSize(wxSizeEvent &WXUNUSED(event)) -{ -} - -void wxWebViewWebKit::MacVisibilityChanged(){ -} - void wxWebViewWebKit::LoadURL(const wxString& url) { - [[m_webView mainFrame] loadRequest:[NSURLRequest requestWithURL: + [m_webView loadRequest:[NSURLRequest requestWithURL: [NSURL URLWithString:wxCFStringRef(url).AsNSString()]]]; } wxString wxWebViewWebKit::GetCurrentURL() const { - return wxCFStringRef::AsString([m_webView mainFrameURL]); + return wxCFStringRef::AsString(m_webView.URL.absoluteString); } wxString wxWebViewWebKit::GetCurrentTitle() const { - return wxCFStringRef::AsString([m_webView mainFrameTitle]); -} - -float wxWebViewWebKit::GetWebkitZoom() const -{ - return [m_webView textSizeMultiplier]; -} - -void wxWebViewWebKit::SetWebkitZoom(float zoom) -{ - [m_webView setTextSizeMultiplier:zoom]; + return wxCFStringRef::AsString(m_webView.title); } wxWebViewZoom wxWebViewWebKit::GetZoom() const { - float zoom = GetWebkitZoom(); + float zoom = GetZoomFactor(); // arbitrary way to map float zoom to our common zoom enum if (zoom <= 0.55) @@ -516,7 +436,7 @@ wxWebViewZoom wxWebViewWebKit::GetZoom() const float wxWebViewWebKit::GetZoomFactor() const { - return GetWebkitZoom(); + return m_webView.magnification; } void wxWebViewWebKit::SetZoom(wxWebViewZoom zoom) @@ -525,34 +445,33 @@ void wxWebViewWebKit::SetZoom(wxWebViewZoom zoom) switch (zoom) { case wxWEBVIEW_ZOOM_TINY: - SetWebkitZoom(0.4f); + SetZoomFactor(0.4f); break; case wxWEBVIEW_ZOOM_SMALL: - SetWebkitZoom(0.7f); + SetZoomFactor(0.7f); break; case wxWEBVIEW_ZOOM_MEDIUM: - SetWebkitZoom(1.0f); + SetZoomFactor(1.0f); break; case wxWEBVIEW_ZOOM_LARGE: - SetWebkitZoom(1.3); + SetZoomFactor(1.3); break; case wxWEBVIEW_ZOOM_LARGEST: - SetWebkitZoom(1.6); + SetZoomFactor(1.6); break; default: wxASSERT(false); } - } void wxWebViewWebKit::SetZoomFactor(float zoom) { - SetWebkitZoom(zoom); + m_webView.magnification = zoom; } void wxWebViewWebKit::DoSetPage(const wxString& src, const wxString& baseUrl) @@ -560,54 +479,36 @@ void wxWebViewWebKit::DoSetPage(const wxString& src, const wxString& baseUrl) if ( !m_webView ) return; - [[m_webView mainFrame] loadHTMLString:wxCFStringRef( src ).AsNSString() + [m_webView loadHTMLString:wxCFStringRef( src ).AsNSString() baseURL:[NSURL URLWithString: wxCFStringRef( baseUrl ).AsNSString()]]; } void wxWebViewWebKit::Cut() { - if ( !m_webView ) - return; - - [m_webView cut:m_webView]; + ExecCommand("cut"); } void wxWebViewWebKit::Copy() { - if ( !m_webView ) - return; - - [m_webView copy:m_webView]; + ExecCommand("copy"); } void wxWebViewWebKit::Paste() { - if ( !m_webView ) - return; - - [m_webView paste:m_webView]; + ExecCommand("paste"); } void wxWebViewWebKit::DeleteSelection() { - if ( !m_webView ) - return; - - [m_webView deleteSelection]; + ExecCommand("delete"); } bool wxWebViewWebKit::HasSelection() const { - DOMRange* range = [m_webView selectedDOMRange]; - if(!range) - { - return false; - } - else - { - return true; - } + wxString rangeCountStr; + const_cast(this)->RunScript("window.getSelection().rangeCount;", &rangeCountStr); + return rangeCountStr != "0"; } void wxWebViewWebKit::ClearSelection() @@ -623,18 +524,15 @@ void wxWebViewWebKit::SelectAll() wxString wxWebViewWebKit::GetSelectedSource() const { - DOMRange* dr = [m_webView selectedDOMRange]; - if ( !dr ) - return wxString(); - - return wxCFStringRef::AsString([dr markupString]); + // TODO: not implemented in SDK (could probably be implemented by script) + return wxString(); } wxString wxWebViewWebKit::GetPageText() const { - NSString *result = [m_webView stringByEvaluatingJavaScriptFromString: - @"document.body.textContent"]; - return wxCFStringRef::AsString(result); + wxString text; + const_cast(this)->RunScript("document.body.innerText;", &text); + return text; } void wxWebViewWebKit::EnableHistory(bool enable) @@ -642,24 +540,23 @@ void wxWebViewWebKit::EnableHistory(bool enable) if ( !m_webView ) return; - [m_webView setMaintainsBackForwardList:enable]; + // TODO: implement } void wxWebViewWebKit::ClearHistory() { - [m_webView setMaintainsBackForwardList:NO]; - [m_webView setMaintainsBackForwardList:YES]; + // TODO: implement } wxVector > wxWebViewWebKit::GetBackwardHistory() { wxVector > backhist; - WebBackForwardList* history = [m_webView backForwardList]; - int count = [history backListCount]; + WKBackForwardList* history = [m_webView backForwardList]; + int count = history.backList.count; for(int i = -count; i < 0; i++) { - WebHistoryItem* item = [history itemAtIndex:i]; - wxString url = wxCFStringRef::AsString([item URLString]); + WKBackForwardListItem* item = [history itemAtIndex:i]; + wxString url = wxCFStringRef::AsString(item.URL.absoluteString); wxString title = wxCFStringRef::AsString([item title]); wxWebViewHistoryItem* wxitem = new wxWebViewHistoryItem(url, title); wxitem->m_histItem = item; @@ -672,12 +569,12 @@ wxVector > wxWebViewWebKit::GetBackwardHistory wxVector > wxWebViewWebKit::GetForwardHistory() { wxVector > forwardhist; - WebBackForwardList* history = [m_webView backForwardList]; - int count = [history forwardListCount]; + WKBackForwardList* history = [m_webView backForwardList]; + int count = history.forwardList.count; for(int i = 1; i <= count; i++) { - WebHistoryItem* item = [history itemAtIndex:i]; - wxString url = wxCFStringRef::AsString([item URLString]); + WKBackForwardListItem* item = [history itemAtIndex:i]; + wxString url = wxCFStringRef::AsString(item.URL.absoluteString); wxString title = wxCFStringRef::AsString([item title]); wxWebViewHistoryItem* wxitem = new wxWebViewHistoryItem(url, title); wxitem->m_histItem = item; @@ -689,7 +586,7 @@ wxVector > wxWebViewWebKit::GetForwardHistory( void wxWebViewWebKit::LoadHistoryItem(wxSharedPtr item) { - [m_webView goToBackForwardItem:item->m_histItem]; + [m_webView goToBackForwardListItem:item->m_histItem]; } bool wxWebViewWebKit::CanUndo() const @@ -714,22 +611,58 @@ void wxWebViewWebKit::Redo() void wxWebViewWebKit::RegisterHandler(wxSharedPtr handler) { - g_stringHandlerMap[handler->GetName()] = handler; + m_handlers[handler->GetName()] = handler; +} + +bool wxWebViewWebKit::QueryCommandEnabled(const wxString& command) const +{ + wxString resultStr; + const_cast(this)->RunScript( + wxString::Format("function f(){ return document.queryCommandEnabled('%s'); } f();", command), &resultStr); + return resultStr.IsSameAs("true", false); +} + +void wxWebViewWebKit::ExecCommand(const wxString& command) +{ + RunScript(wxString::Format("document.execCommand('%s');", command)); } //------------------------------------------------------------ // Listener interfaces //------------------------------------------------------------ -#if wxOSX_USE_IPHONE -#else - // NB: I'm still tracking this down, but it appears the Cocoa window // still has these events fired on it while the Carbon control is being // destroyed. Therefore, we must be careful to check both the existence // of the Carbon control and the event handler before firing events. -@implementation WebViewLoadDelegate +@implementation WXWKWebView + +- (void)setWebView:(wxWebViewWebKit *)webView +{ + m_webView = webView; +} + +#if !defined(__WXOSX_IPHONE__) +- (void)willOpenMenu:(NSMenu *)menu withEvent:(NSEvent *)event +{ + if (m_webView && !m_webView->IsContextMenuEnabled()) + [menu removeAllItems]; +} + +-(id)validRequestorForSendType:(NSString*)sendType returnType:(NSString*)returnType +{ + if (m_webView && !m_webView->IsContextMenuEnabled()) + return nil; + else + return [super validRequestorForSendType:sendType returnType:returnType]; +} + +#endif + +@end + +@implementation WebViewNavigationDelegate - (id)initWithWxWindow: (wxWebViewWebKit*)inWindow { @@ -740,43 +673,46 @@ void wxWebViewWebKit::RegisterHandler(wxSharedPtr handler) return self; } -- (void)webView:(WebView *)sender - didStartProvisionalLoadForFrame:(WebFrame *)frame +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary*)change context:(void *)context { - wxUnusedVar(sender); - wxUnusedVar(frame); - webKitWindow->m_busy = true; + if (context == webKitWindow) + { + wxWebViewEvent event(wxEVT_WEBVIEW_TITLE_CHANGED, + webKitWindow->GetId(), + webKitWindow->GetCurrentURL(), + ""); + + event.SetString(webKitWindow->GetCurrentTitle()); + + webKitWindow->ProcessWindowEvent(event); + } + else + [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; } -- (void)webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame +- (void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation { - webKitWindow->m_busy = true; - - if (webKitWindow && frame == [sender mainFrame]){ - NSString *url = [[[[frame dataSource] request] URL] absoluteString]; - wxString target = wxCFStringRef::AsString([frame name]); + if (webKitWindow){ + NSString *url = webView.URL.absoluteString; wxWebViewEvent event(wxEVT_WEBVIEW_NAVIGATED, webKitWindow->GetId(), wxCFStringRef::AsString( url ), - target); + ""); if (webKitWindow && webKitWindow->GetEventHandler()) webKitWindow->GetEventHandler()->ProcessEvent(event); } } -- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame +- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation { - webKitWindow->m_busy = false; + if (webKitWindow){ + NSString *url = webView.URL.absoluteString; - if (webKitWindow && frame == [sender mainFrame]){ - NSString *url = [[[[frame dataSource] request] URL] absoluteString]; - - wxString target = wxCFStringRef::AsString([frame name]); wxWebViewEvent event(wxEVT_WEBVIEW_LOADED, webKitWindow->GetId(), wxCFStringRef::AsString( url ), - target); + ""); if (webKitWindow && webKitWindow->GetEventHandler()) webKitWindow->GetEventHandler()->ProcessEvent(event); @@ -857,13 +793,12 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out) return message; } -- (void)webView:(WebView *)sender didFailLoadWithError:(NSError*) error - forFrame:(WebFrame *)frame +- (void)webView:(WKWebView *)webView + didFailNavigation:(WKNavigation *)navigation + withError:(NSError *)error; { - webKitWindow->m_busy = false; - - if (webKitWindow && frame == [sender mainFrame]){ - NSString *url = [[[[frame dataSource] request] URL] absoluteString]; + if (webKitWindow){ + NSString *url = webView.URL.absoluteString; wxWebViewNavigationError type; wxString description = nsErrorToWxHtmlError(error, &type); @@ -881,15 +816,12 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out) } } -- (void)webView:(WebView *)sender - didFailProvisionalLoadWithError:(NSError*)error - forFrame:(WebFrame *)frame +- (void)webView:(WKWebView *)webView + didFailProvisionalNavigation:(WKNavigation *)navigation + withError:(NSError *)error; { - webKitWindow->m_busy = false; - - if (webKitWindow && frame == [sender mainFrame]){ - NSString *url = [[[[frame provisionalDataSource] request] URL] - absoluteString]; + if (webKitWindow){ + NSString *url = webView.URL.absoluteString; wxWebViewNavigationError type; wxString description = nsErrorToWxHtmlError(error, &type); @@ -905,165 +837,54 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out) } } -- (void)webView:(WebView *)sender didReceiveTitle:(NSString *)title - forFrame:(WebFrame *)frame +- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction + decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { - wxUnusedVar(sender); + NSString *url = [[navigationAction.request URL] absoluteString]; + wxWebViewNavigationActionFlags navFlags = + navigationAction.navigationType == WKNavigationTypeLinkActivated ? + wxWEBVIEW_NAV_ACTION_USER : + wxWEBVIEW_NAV_ACTION_OTHER; - wxString target = wxCFStringRef::AsString([frame name]); - wxWebViewEvent event(wxEVT_WEBVIEW_TITLE_CHANGED, + wxWebViewEvent event(wxEVT_WEBVIEW_NAVIGATING, webKitWindow->GetId(), - webKitWindow->GetCurrentURL(), - target); - - event.SetString(wxCFStringRef::AsString(title)); + wxCFStringRef::AsString( url ), "", navFlags); if (webKitWindow && webKitWindow->GetEventHandler()) webKitWindow->GetEventHandler()->ProcessEvent(event); + + decisionHandler(event.IsAllowed() ? WKNavigationActionPolicyAllow : WKNavigationActionPolicyCancel); } + @end -@implementation WebViewPolicyDelegate +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_13 +@implementation WebViewCustomProtocol -- (id)initWithWxWindow: (wxWebViewWebKit*)inWindow +- (id)initWithHandler:(wxWebViewHandler *)handler { - if (self = [super init]) - { - webKitWindow = inWindow; // non retained - } + m_handler = handler; return self; } -- (void)webView:(WebView *)sender - decidePolicyForNavigationAction:(NSDictionary *)actionInformation - request:(NSURLRequest *)request - frame:(WebFrame *)frame - decisionListener:(id)listener +- (void)webView:(WKWebView *)webView startURLSchemeTask:(id)urlSchemeTask +WX_API_AVAILABLE_MACOS(10, 13) { - wxUnusedVar(sender); - wxUnusedVar(actionInformation); - wxUnusedVar(frame); - - NSString *url = [[request URL] absoluteString]; - if (webKitWindow->m_nextNavigationIsNewWindow) - { - // This navigation has been marked as a new window - // cancel the request here and send an apropriate event - // to the application code - webKitWindow->m_nextNavigationIsNewWindow = false; - - wxWebViewEvent event(wxEVT_WEBVIEW_NEWWINDOW, - webKitWindow->GetId(), - wxCFStringRef::AsString( url ), ""); - - if (webKitWindow && webKitWindow->GetEventHandler()) - webKitWindow->GetEventHandler()->ProcessEvent(event); - - [listener ignore]; - return; - } - - webKitWindow->m_busy = true; - wxString target = wxCFStringRef::AsString([frame name]); - wxWebViewEvent event(wxEVT_WEBVIEW_NAVIGATING, - webKitWindow->GetId(), - wxCFStringRef::AsString( url ), target); - - if (webKitWindow && webKitWindow->GetEventHandler()) - webKitWindow->GetEventHandler()->ProcessEvent(event); - - if (!event.IsAllowed()) - { - webKitWindow->m_busy = false; - [listener ignore]; - } - else - { - [listener use]; - } -} - -- (void)webView:(WebView *)sender - decidePolicyForNewWindowAction:(NSDictionary *)actionInformation - request:(NSURLRequest *)request - newFrameName:(NSString *)frameName - decisionListener:(id < WebPolicyDecisionListener >)listener -{ - wxUnusedVar(sender); - wxUnusedVar(frameName); - - NSString *url = [[request URL] absoluteString]; - - wxWebViewNavigationActionFlags flags = wxWEBVIEW_NAV_ACTION_USER; - - int action = [[actionInformation objectForKey:WebActionNavigationTypeKey] intValue]; - if (action == WebNavigationTypeOther) - flags = wxWEBVIEW_NAV_ACTION_OTHER; - - wxWebViewEvent event(wxEVT_WEBVIEW_NEWWINDOW, - webKitWindow->GetId(), - wxCFStringRef::AsString( url ), "", flags); - - if (webKitWindow && webKitWindow->GetEventHandler()) - webKitWindow->GetEventHandler()->ProcessEvent(event); - - [listener ignore]; -} -@end - -#endif - -@implementation WebViewCustomProtocol - -+ (BOOL)canInitWithRequest:(NSURLRequest *)request -{ - NSString *scheme = [[request URL] scheme]; - - wxStringToWebHandlerMap::const_iterator it; - for( it = g_stringHandlerMap.begin(); it != g_stringHandlerMap.end(); ++it ) - { - if(it->first.IsSameAs(wxCFStringRef::AsString(scheme))) - { - return YES; - } - } - - return NO; -} - -+ (NSURLRequest *)canonicalRequestForRequest:(NSURLRequest *)request -{ - //We don't do any processing here as the wxWebViewHandler classes do it - return request; -} - -- (void)startLoading -{ - NSURLRequest *request = [self request]; + NSURLRequest *request = urlSchemeTask.request; NSString* path = [[request URL] absoluteString]; - id client = [self client]; - wxString wxpath = wxCFStringRef::AsString(path); - wxString scheme = wxCFStringRef::AsString([[request URL] scheme]); - - // since canInitRequest has already checked whether this scheme is supported - // the hash map contains this entry, but to satisfy static code analysis - // suspecting nullptr dereference ... -#ifndef __clang_analyzer__ - wxFSFile* file = g_stringHandlerMap[scheme]->GetFile(wxpath); -#else - wxFSFile* file = NULL; -#endif - + + wxFSFile* file = m_handler->GetFile(wxpath); + if (!file) { NSError *error = [[NSError alloc] initWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist userInfo:nil]; - [client URLProtocol:self didFailWithError:error]; - + [urlSchemeTask didFailWithError:error]; + [error release]; return; @@ -1082,27 +903,26 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out) file->GetStream()->Read(buffer, length); NSData *data = [[NSData alloc] initWithBytesNoCopy:buffer length:length]; - //We do not support caching anything yet - [client URLProtocol:self didReceiveResponse:response - cacheStoragePolicy:NSURLCacheStorageNotAllowed]; - //Set the data - [client URLProtocol:self didLoadData:data]; + [urlSchemeTask didReceiveResponse:response]; + [urlSchemeTask didReceiveData:data]; //Notify that we have finished - [client URLProtocolDidFinishLoading:self]; + [urlSchemeTask didFinish]; [data release]; - + [response release]; } -- (void)stopLoading +- (void)webView:(WKWebView *)webView stopURLSchemeTask:(id)urlSchemeTask +WX_API_AVAILABLE_MACOS(10, 13) { } @end +#endif // macOS 10.13+ @implementation WebViewUIDelegate @@ -1116,35 +936,86 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out) return self; } -- (WebView *)webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request +- (WKWebView *)webView:(WKWebView *)webView + createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration + forNavigationAction:(WKNavigationAction *)navigationAction + windowFeatures:(WKWindowFeatures *)windowFeatures { - // This method is called when window.open() is used in javascript with a target != _self - // request is always nil, so it can't be used for event generation - // Mark the next navigation as "new window" - wxUnusedVar(request); - webKitWindow->m_nextNavigationIsNewWindow = true; - return sender; + wxWebViewNavigationActionFlags navFlags = + navigationAction.navigationType == WKNavigationTypeLinkActivated ? + wxWEBVIEW_NAV_ACTION_USER : + wxWEBVIEW_NAV_ACTION_OTHER; + + wxWebViewEvent event(wxEVT_WEBVIEW_NEWWINDOW, + webKitWindow->GetId(), + wxCFStringRef::AsString( navigationAction.request.URL.absoluteString ), + "", navFlags); + + if (webKitWindow && webKitWindow->GetEventHandler()) + webKitWindow->GetEventHandler()->ProcessEvent(event); + + return nil; } -- (void)webView:(WebView *)sender printFrameView:(WebFrameView *)frameView +- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message + initiatedByFrame:(WKFrameInfo *)frame + completionHandler:(void (^)())completionHandler { - wxUnusedVar(sender); - wxUnusedVar(frameView); - - webKitWindow->Print(); + wxMessageDialog dlg(webKitWindow->GetParent(), wxCFStringRef::AsString(message)); + dlg.ShowModal(); + completionHandler(); } -- (NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element - defaultMenuItems:(NSArray *) defaultMenuItems +- (void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(NSString *)message + initiatedByFrame:(WKFrameInfo *)frame + completionHandler:(void (^)(BOOL))completionHandler { - wxUnusedVar(sender); - wxUnusedVar(element); + wxMessageDialog dlg(webKitWindow->GetParent(), wxCFStringRef::AsString(message), + wxMessageBoxCaptionStr, wxOK|wxCANCEL|wxCENTRE); + completionHandler(dlg.ShowModal() == wxID_OK); +} - if(webKitWindow->IsContextMenuEnabled()) - return defaultMenuItems; +- (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt + defaultText:(NSString *)defaultText + initiatedByFrame:(WKFrameInfo *)frame + completionHandler:(void (^)(NSString * _Nullable))completionHandler +{ + wxString resultText; + wxTextEntryDialog dlg(webKitWindow->GetParent(), wxCFStringRef::AsString(prompt), + wxGetTextFromUserPromptStr, wxCFStringRef::AsString(defaultText)); + if (dlg.ShowModal() == wxID_OK) + resultText = dlg.GetValue(); + + completionHandler(wxCFStringRef(resultText).AsNSString()); +} + +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12 +- (void)webView:(WKWebView *)webView runOpenPanelWithParameters:(WKOpenPanelParameters *)parameters + initiatedByFrame:(WKFrameInfo *)frame + completionHandler:(void (^)(NSArray * _Nullable))completionHandler +WX_API_AVAILABLE_MACOS(10, 12) +{ + long style = wxFD_OPEN | wxFD_FILE_MUST_EXIST; + if (parameters.allowsMultipleSelection) + style |= wxFD_MULTIPLE; + + wxFileDialog dlg(webKitWindow->GetParent(), wxFileSelectorPromptStr, "", "", + wxFileSelectorDefaultWildcardStr, style); + if (dlg.ShowModal() == wxID_OK) + { + wxArrayString filePaths; + dlg.GetPaths(filePaths); + NSMutableArray* urls = [[NSMutableArray alloc] init]; + for (wxArrayString::iterator it = filePaths.begin(); it != filePaths.end(); it++) + [urls addObject:[NSURL fileURLWithPath:wxCFStringRef(*it).AsNSString()]]; + completionHandler(urls); + [urls release]; + } else - return nil; + completionHandler(nil); } +#endif // __MAC_OS_X_VERSION_MAX_ALLOWED + @end #endif //wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT diff --git a/tests/controls/webtest.cpp b/tests/controls/webtest.cpp index 1e6a509a06..9f0a57696a 100644 --- a/tests/controls/webtest.cpp +++ b/tests/controls/webtest.cpp @@ -123,7 +123,7 @@ TEST_CASE_METHOD(WebViewTestCase, "WebView", "[wxWebView]") CHECK(m_browser->CanGoForward()); } -#if !wxUSE_WEBVIEW_WEBKIT2 +#if !wxUSE_WEBVIEW_WEBKIT2 && !defined(__WXOSX__) SECTION("HistoryEnable") { LoadUrl(); @@ -139,7 +139,7 @@ TEST_CASE_METHOD(WebViewTestCase, "WebView", "[wxWebView]") } #endif -#if !wxUSE_WEBVIEW_WEBKIT2 +#if !wxUSE_WEBVIEW_WEBKIT2 && !defined(__WXOSX__) SECTION("HistoryClear") { LoadUrl(2); @@ -174,6 +174,7 @@ TEST_CASE_METHOD(WebViewTestCase, "WebView", "[wxWebView]") CHECK(m_browser->GetBackwardHistory().size() == 2); } +#if !defined(__WXOSX__) SECTION("Editable") { CHECK(!m_browser->IsEditable()); @@ -186,6 +187,7 @@ TEST_CASE_METHOD(WebViewTestCase, "WebView", "[wxWebView]") CHECK(!m_browser->IsEditable()); } +#endif SECTION("Selection") { @@ -207,6 +209,7 @@ TEST_CASE_METHOD(WebViewTestCase, "WebView", "[wxWebView]") CHECK(m_browser->HasSelection()); CHECK(m_browser->GetSelectedText() == "Some strong text"); +#if !defined(__WXOSX__) // The web engine doesn't necessarily represent the HTML in the same way as // we used above, e.g. IE uses upper case for all the tags while WebKit // under OS X inserts plenty of its own tags, so don't test for @@ -218,6 +221,7 @@ TEST_CASE_METHOD(WebViewTestCase, "WebView", "[wxWebView]") ("Unexpected selection source: \"%s\"", selSource), selSource.Lower().Matches("*some**text*") ); +#endif // !defined(__WXOSX__) m_browser->ClearSelection(); CHECK(!m_browser->HasSelection());