Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 629122 | Differences between
and this patch

Collapse All | Expand All

(-)a/Makefile.in (-19 / +69 lines)
Line 924 MONODLL_CFLAGS = $(__monodll_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \ Link Here
924
	-DwxUSE_BASE=1 -DWXMAKINGDLL $(PIC_FLAG) $(CPPFLAGS) $(CFLAGS)
924
	-DwxUSE_BASE=1 -DWXMAKINGDLL $(__webviewdll_ext_dir_define_p) $(PIC_FLAG) \
925
	$(CPPFLAGS) $(CFLAGS)
Lines 933-934 MONODLL_CXXFLAGS = $(__monodll_PCH_INC) -D__WX$(TOOLKIT)__ \ Link Here
933
	-DwxUSE_BASE=1 -DWXMAKINGDLL $(PIC_FLAG) $(CXXWARNINGS) $(CPPFLAGS) \
934
	-DwxUSE_BASE=1 -DWXMAKINGDLL $(__webviewdll_ext_dir_define_p) $(PIC_FLAG) \
934
	$(CXXFLAGS)
935
	$(CXXWARNINGS) $(CPPFLAGS) $(CXXFLAGS)
Line 943 MONODLL_OBJCXXFLAGS = $(__monodll_PCH_INC) -D__WX$(TOOLKIT)__ \ Link Here
943
	-DwxUSE_BASE=1 -DWXMAKINGDLL $(PIC_FLAG) $(CPPFLAGS) $(OBJCXXFLAGS)
944
	-DwxUSE_BASE=1 -DWXMAKINGDLL $(__webviewdll_ext_dir_define_p) $(PIC_FLAG) \
945
	$(CPPFLAGS) $(OBJCXXFLAGS)
Line 1063 MONOLIB_CFLAGS = $(__monolib_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \ Link Here
1063
	-DwxUSE_BASE=1 $(CPPFLAGS) $(CFLAGS)
1065
	-DwxUSE_BASE=1 $(__webviewdll_ext_dir_define_p) $(CPPFLAGS) $(CFLAGS)
Line 1072 MONOLIB_CXXFLAGS = $(__monolib_PCH_INC) -D__WX$(TOOLKIT)__ \ Link Here
1072
	-DwxUSE_BASE=1 $(CXXWARNINGS) $(CPPFLAGS) $(CXXFLAGS)
1074
	-DwxUSE_BASE=1 $(__webviewdll_ext_dir_define_p) $(CXXWARNINGS) $(CPPFLAGS) \
1075
	$(CXXFLAGS)
Line 1081 MONOLIB_OBJCXXFLAGS = $(__monolib_PCH_INC) -D__WX$(TOOLKIT)__ \ Link Here
1081
	-DwxUSE_BASE=1 $(CPPFLAGS) $(OBJCXXFLAGS)
1084
	-DwxUSE_BASE=1 $(__webviewdll_ext_dir_define_p) $(CPPFLAGS) $(OBJCXXFLAGS)
Line 1658 WEBVIEWDLL_CXXFLAGS = $(__webviewdll_PCH_INC) -D__WX$(TOOLKIT)__ \ Link Here
1658
	$(PIC_FLAG) $(CXXWARNINGS) $(CPPFLAGS) $(CXXFLAGS)
1661
	$(__webviewdll_ext_dir_define_p) $(PIC_FLAG) $(CXXWARNINGS) $(CPPFLAGS) \
1662
	$(CXXFLAGS)
Line 1664 WEBVIEWDLL_OBJCXXFLAGS = $(__webviewdll_PCH_INC) -D__WX$(TOOLKIT)__ \ Link Here
1664
	$(PIC_FLAG) $(CPPFLAGS) $(OBJCXXFLAGS)
1668
	$(__webviewdll_ext_dir_define_p) $(PIC_FLAG) $(CPPFLAGS) $(OBJCXXFLAGS)
Line 2080 SOUND_SDL_OBJECTS = \ Link Here
2085
WEBKIT2_EXT_CXXFLAGS = -DWXUSINGDLL -DwxUSE_GUI=0 $(PIC_FLAG) $(CPPFLAGS) \
2086
	$(CXXFLAGS)
2087
WEBKIT2_EXT_OBJECTS =  \
2088
	webkit2_ext_webview_webkit2_extension.o
Line 6756 COND_TOOLKIT_X11___ADVANCED_PLATFORM_SRC_OBJECTS_1 = \ Link Here
6756
@COND_TOOLKIT_GTK@	monodll_gtk_webview_webkit.o
6764
@COND_TOOLKIT_GTK@	monodll_gtk_webview_webkit.o monodll_webview_webkit2.o
Line 9011 COND_TOOLKIT_X11___ADVANCED_PLATFORM_SRC_OBJECTS_3 = \ Link Here
9011
@COND_TOOLKIT_GTK@	monolib_gtk_webview_webkit.o
9019
@COND_TOOLKIT_GTK@	monolib_gtk_webview_webkit.o monolib_webview_webkit2.o
Line 13767 COND_USE_SOVERSOLARIS_1___webviewdll___so_symlinks_uninst_cmd = rm -f \ Link Here
13767
@COND_TOOLKIT_GTK@	webviewdll_gtk_webview_webkit.o
13775
@COND_TOOLKIT_GTK@	webviewdll_gtk_webview_webkit.o \
13776
@COND_TOOLKIT_GTK@	webviewdll_webview_webkit2.o
Line 13786 COND_MONOLITHIC_0_SHARED_0_USE_GUI_1_USE_WEBVIEW_1___webviewlib___depname = \ Link Here
13786
@COND_TOOLKIT_GTK@	webviewlib_gtk_webview_webkit.o
13795
@COND_TOOLKIT_GTK@	webviewlib_gtk_webview_webkit.o \
13796
@COND_TOOLKIT_GTK@	webviewlib_webview_webkit2.o
Line 14588 COND_WITH_PLUGIN_SDL_1___sound_sdl___depname = \ Link Here
14599
COND_USE_WEBVIEW_WEBKIT2_1___webkit2_ext___depname = \
14600
	$(DLLPREFIX_MODULE)webkit2_ext$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(PLUGVERDELIM)$(PLUGIN_VERSION0)$(WXCOMPILER).$(SO_SUFFIX_MODULE)
14601
@COND_USE_WEBVIEW_WEBKIT2_1@__webkit2_ext___depname = $(COND_USE_WEBVIEW_WEBKIT2_1___webkit2_ext___depname)
14602
@COND_USE_WEBVIEW_WEBKIT2_1@__install_webkit2_ext___depname \
14603
@COND_USE_WEBVIEW_WEBKIT2_1@	= install_webkit2_ext
14604
@COND_USE_WEBVIEW_WEBKIT2_1@__uninstall_webkit2_ext___depname \
14605
@COND_USE_WEBVIEW_WEBKIT2_1@	= uninstall_webkit2_ext
Line 14743 COND_PLATFORM_UNIX_1___ADVANCED_GTK_PLATFORM_SRC_OBJECTS = \ Link Here
14761
COND_USE_WEBVIEW_WEBKIT2_1___webviewdll_ext_dir_define_p_0 = --define \
14762
	WX_WEB_EXTENSIONS_DIRECTORY=\"$(PLUGINS_INST_DIR)/web-extensions\"
14763
@COND_USE_WEBVIEW_WEBKIT2_1@__webviewdll_ext_dir_define_p_0 = $(COND_USE_WEBVIEW_WEBKIT2_1___webviewdll_ext_dir_define_p_0)
Line 14890 COND_PLATFORM_UNIX_1___ADVANCED_GTK_PLATFORM_SRC_OBJECTS_17 = \ Link Here
14911
@COND_USE_WEBVIEW_WEBKIT2_1@__webviewdll_ext_dir_define_p \
14912
@COND_USE_WEBVIEW_WEBKIT2_1@	= \
14913
@COND_USE_WEBVIEW_WEBKIT2_1@	-DWX_WEB_EXTENSIONS_DIRECTORY=\"$(PLUGINS_INST_DIR)/web-extensions\"
Line 15258 COND_wxUSE_REGEX_builtin___LIB_REGEX_p = \ Link Here
15258
all: $(__wxregex___depname) $(__wxzlib___depname) $(__wxpng___depname) $(__wxjpeg___depname) $(__wxtiff___depname) $(__wxexpat___depname) $(__wxscintilla___depname) $(__monodll___depname) $(__monolib___depname) $(__basedll___depname) $(__baselib___depname) $(__netdll___depname) $(__netlib___depname) $(__coredll___depname) $(__corelib___depname) $(__advdll___depname) $(__advlib___depname) $(__mediadll___depname) $(__medialib___depname) $(__htmldll___depname) $(__htmllib___depname) $(__webviewdll___depname) $(__webviewlib___depname) $(__qadll___depname) $(__qalib___depname) $(__xmldll___depname) $(__xmllib___depname) $(__xrcdll___depname) $(__xrclib___depname) $(__auidll___depname) $(__auilib___depname) $(__ribbondll___depname) $(__ribbonlib___depname) $(__propgriddll___depname) $(__propgridlib___depname) $(__richtextdll___depname) $(__richtextlib___depname) $(__stcdll___depname) $(__stclib___depname) $(__gldll___depname) $(__gllib___depname) $(__sound_sdl___depname) $(__wxrc___depname) $(__cocoa_res___depname)
15281
all: $(__wxregex___depname) $(__wxzlib___depname) $(__wxpng___depname) $(__wxjpeg___depname) $(__wxtiff___depname) $(__wxexpat___depname) $(__wxscintilla___depname) $(__monodll___depname) $(__monolib___depname) $(__basedll___depname) $(__baselib___depname) $(__netdll___depname) $(__netlib___depname) $(__coredll___depname) $(__corelib___depname) $(__advdll___depname) $(__advlib___depname) $(__mediadll___depname) $(__medialib___depname) $(__htmldll___depname) $(__htmllib___depname) $(__webviewdll___depname) $(__webviewlib___depname) $(__qadll___depname) $(__qalib___depname) $(__xmldll___depname) $(__xmllib___depname) $(__xrcdll___depname) $(__xrclib___depname) $(__auidll___depname) $(__auilib___depname) $(__ribbondll___depname) $(__ribbonlib___depname) $(__propgriddll___depname) $(__propgridlib___depname) $(__richtextdll___depname) $(__richtextlib___depname) $(__stcdll___depname) $(__stclib___depname) $(__gldll___depname) $(__gllib___depname) $(__sound_sdl___depname) $(__webkit2_ext___depname) $(__wxrc___depname) $(__cocoa_res___depname)
Line 15260 all: $(__wxregex___depname) $(__wxzlib___depname) $(__wxpng___depname) $(__wxjpe Link Here
15260
install: $(__install_wxregex___depname) $(__install_wxzlib___depname) $(__install_wxpng___depname) $(__install_wxjpeg___depname) $(__install_wxtiff___depname) $(__install_wxexpat___depname) $(__install_wxscintilla___depname) $(__install_monodll___depname) $(__install_monolib___depname) $(__install_basedll___depname) $(__install_baselib___depname) $(__install_netdll___depname) $(__install_netlib___depname) $(__install_coredll___depname) $(__install_corelib___depname) $(__install_advdll___depname) $(__install_advlib___depname) $(__install_mediadll___depname) $(__install_medialib___depname) $(__install_htmldll___depname) $(__install_htmllib___depname) $(__install_webviewdll___depname) $(__install_webviewlib___depname) $(__install_qadll___depname) $(__install_qalib___depname) $(__install_xmldll___depname) $(__install_xmllib___depname) $(__install_xrcdll___depname) $(__install_xrclib___depname) $(__install_auidll___depname) $(__install_auilib___depname) $(__install_ribbondll___depname) $(__install_ribbonlib___depname) $(__install_propgriddll___depname) $(__install_propgridlib___depname) $(__install_richtextdll___depname) $(__install_richtextlib___depname) $(__install_stcdll___depname) $(__install_stclib___depname) $(__install_gldll___depname) $(__install_gllib___depname) $(__install_sound_sdl___depname) $(__install_wxrc___depname) install-wxconfig locale_install locale_msw_install $(__cocoa_res_install___depname)
15283
install: $(__install_wxregex___depname) $(__install_wxzlib___depname) $(__install_wxpng___depname) $(__install_wxjpeg___depname) $(__install_wxtiff___depname) $(__install_wxexpat___depname) $(__install_wxscintilla___depname) $(__install_monodll___depname) $(__install_monolib___depname) $(__install_basedll___depname) $(__install_baselib___depname) $(__install_netdll___depname) $(__install_netlib___depname) $(__install_coredll___depname) $(__install_corelib___depname) $(__install_advdll___depname) $(__install_advlib___depname) $(__install_mediadll___depname) $(__install_medialib___depname) $(__install_htmldll___depname) $(__install_htmllib___depname) $(__install_webviewdll___depname) $(__install_webviewlib___depname) $(__install_qadll___depname) $(__install_qalib___depname) $(__install_xmldll___depname) $(__install_xmllib___depname) $(__install_xrcdll___depname) $(__install_xrclib___depname) $(__install_auidll___depname) $(__install_auilib___depname) $(__install_ribbondll___depname) $(__install_ribbonlib___depname) $(__install_propgriddll___depname) $(__install_propgridlib___depname) $(__install_richtextdll___depname) $(__install_richtextlib___depname) $(__install_stcdll___depname) $(__install_stclib___depname) $(__install_gldll___depname) $(__install_gllib___depname) $(__install_sound_sdl___depname) $(__install_webkit2_ext___depname) $(__install_wxrc___depname) install-wxconfig locale_install locale_msw_install $(__cocoa_res_install___depname)
Line 15296 install: $(__install_wxregex___depname) $(__install_wxzlib___depname) $(__instal Link Here
15296
uninstall: $(__uninstall_wxregex___depname) $(__uninstall_wxzlib___depname) $(__uninstall_wxpng___depname) $(__uninstall_wxjpeg___depname) $(__uninstall_wxtiff___depname) $(__uninstall_wxexpat___depname) $(__uninstall_wxscintilla___depname) $(__uninstall_monodll___depname) $(__uninstall_monolib___depname) $(__uninstall_basedll___depname) $(__uninstall_baselib___depname) $(__uninstall_netdll___depname) $(__uninstall_netlib___depname) $(__uninstall_coredll___depname) $(__uninstall_corelib___depname) $(__uninstall_advdll___depname) $(__uninstall_advlib___depname) $(__uninstall_mediadll___depname) $(__uninstall_medialib___depname) $(__uninstall_htmldll___depname) $(__uninstall_htmllib___depname) $(__uninstall_webviewdll___depname) $(__uninstall_webviewlib___depname) $(__uninstall_qadll___depname) $(__uninstall_qalib___depname) $(__uninstall_xmldll___depname) $(__uninstall_xmllib___depname) $(__uninstall_xrcdll___depname) $(__uninstall_xrclib___depname) $(__uninstall_auidll___depname) $(__uninstall_auilib___depname) $(__uninstall_ribbondll___depname) $(__uninstall_ribbonlib___depname) $(__uninstall_propgriddll___depname) $(__uninstall_propgridlib___depname) $(__uninstall_richtextdll___depname) $(__uninstall_richtextlib___depname) $(__uninstall_stcdll___depname) $(__uninstall_stclib___depname) $(__uninstall_gldll___depname) $(__uninstall_gllib___depname) $(__uninstall_sound_sdl___depname) locale_uninstall locale_msw_uninstall
15319
uninstall: $(__uninstall_wxregex___depname) $(__uninstall_wxzlib___depname) $(__uninstall_wxpng___depname) $(__uninstall_wxjpeg___depname) $(__uninstall_wxtiff___depname) $(__uninstall_wxexpat___depname) $(__uninstall_wxscintilla___depname) $(__uninstall_monodll___depname) $(__uninstall_monolib___depname) $(__uninstall_basedll___depname) $(__uninstall_baselib___depname) $(__uninstall_netdll___depname) $(__uninstall_netlib___depname) $(__uninstall_coredll___depname) $(__uninstall_corelib___depname) $(__uninstall_advdll___depname) $(__uninstall_advlib___depname) $(__uninstall_mediadll___depname) $(__uninstall_medialib___depname) $(__uninstall_htmldll___depname) $(__uninstall_htmllib___depname) $(__uninstall_webviewdll___depname) $(__uninstall_webviewlib___depname) $(__uninstall_qadll___depname) $(__uninstall_qalib___depname) $(__uninstall_xmldll___depname) $(__uninstall_xmllib___depname) $(__uninstall_xrcdll___depname) $(__uninstall_xrclib___depname) $(__uninstall_auidll___depname) $(__uninstall_auilib___depname) $(__uninstall_ribbondll___depname) $(__uninstall_ribbonlib___depname) $(__uninstall_propgriddll___depname) $(__uninstall_propgridlib___depname) $(__uninstall_richtextdll___depname) $(__uninstall_richtextlib___depname) $(__uninstall_stcdll___depname) $(__uninstall_stclib___depname) $(__uninstall_gldll___depname) $(__uninstall_gllib___depname) $(__uninstall_sound_sdl___depname) $(__uninstall_webkit2_ext___depname) locale_uninstall locale_msw_uninstall
Line 15324 install-strip: install Link Here
15348
	$(STRIP) $(DESTDIR)$(PLUGINS_INST_DIR)/web-extensions/$(DLLPREFIX_MODULE)webkit2_ext$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(PLUGVERDELIM)$(PLUGIN_VERSION0)$(WXCOMPILER).$(SO_SUFFIX_MODULE)
Line 15404 clean: $(__clean_wxrc___depname) Link Here
15429
	rm -f $(DLLPREFIX_MODULE)webkit2_ext$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(PLUGVERDELIM)$(PLUGIN_VERSION0)$(WXCOMPILER).$(SO_SUFFIX_MODULE)
Line 16132 distclean: clean Link Here
16158
@COND_USE_WEBVIEW_WEBKIT2_1@$(DLLPREFIX_MODULE)webkit2_ext$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(PLUGVERDELIM)$(PLUGIN_VERSION0)$(WXCOMPILER).$(SO_SUFFIX_MODULE): $(WEBKIT2_EXT_OBJECTS)
16159
@COND_USE_WEBVIEW_WEBKIT2_1@	$(SHARED_LD_MODULE_CXX) $@ $(WEBKIT2_EXT_OBJECTS)  $(LDFLAGS)  $(EXTRALIBS_WEBVIEW) $(LIBS)
16160
16161
@COND_USE_WEBVIEW_WEBKIT2_1@install_webkit2_ext: $(__webkit2_ext___depname)
16162
@COND_USE_WEBVIEW_WEBKIT2_1@	$(INSTALL_DIR) $(DESTDIR)$(PLUGINS_INST_DIR)/web-extensions
16163
@COND_USE_WEBVIEW_WEBKIT2_1@	$(INSTALL_PROGRAM) $(DLLPREFIX_MODULE)webkit2_ext$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(PLUGVERDELIM)$(PLUGIN_VERSION0)$(WXCOMPILER).$(SO_SUFFIX_MODULE) $(DESTDIR)$(PLUGINS_INST_DIR)/web-extensions
16164
16165
@COND_USE_WEBVIEW_WEBKIT2_1@uninstall_webkit2_ext: 
16166
@COND_USE_WEBVIEW_WEBKIT2_1@	rm -f $(DESTDIR)$(PLUGINS_INST_DIR)/web-extensions/$(DLLPREFIX_MODULE)webkit2_ext$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(PLUGVERDELIM)$(PLUGIN_VERSION0)$(WXCOMPILER).$(SO_SUFFIX_MODULE)
16167
Line 18565 monodll_gtk_webview_webkit.o: $(srcdir)/src/gtk/webview_webkit.cpp $(MONODLL_ODE Link Here
18601
monodll_webview_webkit2.o: $(srcdir)/src/gtk/webview_webkit2.cpp $(MONODLL_ODEP)
18602
	$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/gtk/webview_webkit2.cpp
18603
Line 22800 monodll_version_rc.o: $(srcdir)/src/msw/version.rc $(MONODLL_ODEP) Link Here
22800
	$(WINDRES) -i$< -o$@    --define __WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p_67) $(__DEBUG_DEFINE_p_66)  $(__EXCEPTIONS_DEFINE_p_65) $(__RTTI_DEFINE_p_65) $(__THREAD_DEFINE_p_65)   --define WXBUILDING --define WXDLLNAME=$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG) $(__RCDEFDIR_p) --include-dir $(top_srcdir)/include $(__INC_TIFF_BUILD_p_66) $(__INC_TIFF_p_66) $(__INC_JPEG_p_66) $(__INC_PNG_p_65) $(__INC_ZLIB_p_67) $(__INC_REGEX_p_65) $(__INC_EXPAT_p_65) --include-dir $(top_srcdir)/src/stc/scintilla/include --include-dir $(top_srcdir)/src/stc/scintilla/lexlib --include-dir $(top_srcdir)/src/stc/scintilla/src --define __WX__ --define SCI_LEXER --define LINK_LEXERS --define wxUSE_BASE=1 --define WXMAKINGDLL
22838
	$(WINDRES) -i$< -o$@    --define __WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p_67) $(__DEBUG_DEFINE_p_66)  $(__EXCEPTIONS_DEFINE_p_65) $(__RTTI_DEFINE_p_65) $(__THREAD_DEFINE_p_65)   --define WXBUILDING --define WXDLLNAME=$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG) $(__RCDEFDIR_p) --include-dir $(top_srcdir)/include $(__INC_TIFF_BUILD_p_66) $(__INC_TIFF_p_66) $(__INC_JPEG_p_66) $(__INC_PNG_p_65) $(__INC_ZLIB_p_67) $(__INC_REGEX_p_65) $(__INC_EXPAT_p_65) --include-dir $(top_srcdir)/src/stc/scintilla/include --include-dir $(top_srcdir)/src/stc/scintilla/lexlib --include-dir $(top_srcdir)/src/stc/scintilla/src --define __WX__ --define SCI_LEXER --define LINK_LEXERS --define wxUSE_BASE=1 --define WXMAKINGDLL $(__webviewdll_ext_dir_define_p_0)
Line 24442 monolib_gtk_webview_webkit.o: $(srcdir)/src/gtk/webview_webkit.cpp $(MONOLIB_ODE Link Here
24481
monolib_webview_webkit2.o: $(srcdir)/src/gtk/webview_webkit2.cpp $(MONOLIB_ODEP)
24482
	$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/gtk/webview_webkit2.cpp
24483
Line 39795 webviewdll_version_rc.o: $(srcdir)/src/msw/version.rc $(WEBVIEWDLL_ODEP) Link Here
39795
	$(WINDRES) -i$< -o$@    --define __WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p_67) $(__DEBUG_DEFINE_p_66)  $(__EXCEPTIONS_DEFINE_p_65) $(__RTTI_DEFINE_p_65) $(__THREAD_DEFINE_p_65)   --define WXBUILDING --define WXDLLNAME=$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_webview$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG) $(__RCDEFDIR_p) --include-dir $(top_srcdir)/include $(__INC_TIFF_BUILD_p_66) $(__INC_TIFF_p_66) $(__INC_JPEG_p_66) $(__INC_PNG_p_65) $(__INC_ZLIB_p_67) $(__INC_REGEX_p_65) $(__INC_EXPAT_p_65) --define WXUSINGDLL --define WXMAKINGDLL_WEBVIEW
39836
	$(WINDRES) -i$< -o$@    --define __WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p_67) $(__DEBUG_DEFINE_p_66)  $(__EXCEPTIONS_DEFINE_p_65) $(__RTTI_DEFINE_p_65) $(__THREAD_DEFINE_p_65)   --define WXBUILDING --define WXDLLNAME=$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_webview$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG) $(__RCDEFDIR_p) --include-dir $(top_srcdir)/include $(__INC_TIFF_BUILD_p_66) $(__INC_TIFF_p_66) $(__INC_JPEG_p_66) $(__INC_PNG_p_65) $(__INC_ZLIB_p_67) $(__INC_REGEX_p_65) $(__INC_EXPAT_p_65) --define WXUSINGDLL --define WXMAKINGDLL_WEBVIEW $(__webviewdll_ext_dir_define_p_0)
Line 39802 webviewdll_gtk_webview_webkit.o: $(srcdir)/src/gtk/webview_webkit.cpp $(WEBVIEWD Link Here
39844
webviewdll_webview_webkit2.o: $(srcdir)/src/gtk/webview_webkit2.cpp $(WEBVIEWDLL_ODEP)
39845
	$(CXXC) -c -o $@ $(WEBVIEWDLL_CXXFLAGS) $(srcdir)/src/gtk/webview_webkit2.cpp
39846
Line 39820 webviewlib_gtk_webview_webkit.o: $(srcdir)/src/gtk/webview_webkit.cpp $(WEBVIEWL Link Here
39865
webviewlib_webview_webkit2.o: $(srcdir)/src/gtk/webview_webkit2.cpp $(WEBVIEWLIB_ODEP)
39866
	$(CXXC) -c -o $@ $(WEBVIEWLIB_CXXFLAGS) $(srcdir)/src/gtk/webview_webkit2.cpp
39867
Line 40660 sound_sdl_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp Link Here
40708
webkit2_ext_webview_webkit2_extension.o: $(srcdir)/src/gtk/webview_webkit2_extension.cpp
40709
	$(CXXC) -c -o $@ $(WEBKIT2_EXT_CXXFLAGS) $(srcdir)/src/gtk/webview_webkit2_extension.cpp
40710
Line 41572 win-dist: MSW_ZIP_TEXT_DIST SAMPLES_DIST DEMOS_DIST UTILS_DIST MISC_DIST INTL_DI Link Here
41572
	samples
41622
	install_webkit2_ext uninstall_webkit2_ext samples
(-)a/autoconf_inc.m4 (+6 lines)
Line 1090 dnl ### begin block 20_COND_USE_THREADS_1[../../demos/bombs/bombs.bkl,../../demo Link Here
1091
dnl ### begin block 20_COND_USE_WEBVIEW_WEBKIT2_1[../../demos/bombs/bombs.bkl,../../demos/forty/forty.bkl,../../demos/fractal/fractal.bkl,../../demos/life/life.bkl,../../demos/poem/poem.bkl,../../samples/access/access.bkl,../../samples/animate/anitest.bkl,../../samples/artprov/artprov.bkl,../../samples/aui/auidemo.bkl,../../samples/calendar/calendar.bkl,../../samples/caret/caret.bkl,../../samples/clipboard/clipboard.bkl,../../samples/collpane/collpane.bkl,../../samples/combo/combo.bkl,../../samples/config/config.bkl,../../samples/console/console.bkl,../../samples/controls/controls.bkl,../../samples/dataview/dataview.bkl,../../samples/debugrpt/debugrpt.bkl,../../samples/dialogs/dialogs.bkl,../../samples/dialup/dialup.bkl,../../samples/display/display.bkl,../../samples/dll/dll.bkl,../../samples/dnd/dnd.bkl,../../samples/docview/docview.bkl,../../samples/dragimag/dragimag.bkl,../../samples/drawing/drawing.bkl,../../samples/erase/erase.bkl,../../samples/event/event.bkl,../../samples/except/except.bkl,../../samples/exec/exec.bkl,../../samples/font/font.bkl,../../samples/fswatcher/fswatcher.bkl,../../samples/grid/grid.bkl,../../samples/help/help.bkl,../../samples/htlbox/htlbox.bkl,../../samples/html/about/about.bkl,../../samples/html/help/help.bkl,../../samples/html/helpview/helpview.bkl,../../samples/html/htmlctrl/htmlctrl.bkl,../../samples/html/printing/printing.bkl,../../samples/html/test/test.bkl,../../samples/html/virtual/virtual.bkl,../../samples/html/widget/widget.bkl,../../samples/html/zip/zip.bkl,../../samples/image/image.bkl,../../samples/internat/internat.bkl,../../samples/ipc/ipc.bkl,../../samples/joytest/joytest.bkl,../../samples/keyboard/keyboard.bkl,../../samples/layout/layout.bkl,../../samples/listctrl/listctrl.bkl,../../samples/mdi/mdi.bkl,../../samples/mediaplayer/mediaplayer.bkl,../../samples/memcheck/memcheck.bkl,../../samples/menu/menu.bkl,../../samples/minimal/minimal.bkl,../../samples/nativdlg/nativdlg.bkl,../../samples/notebook/notebook.bkl,../../samples/oleauto/oleauto.bkl,../../samples/opengl/cube/cube.bkl,../../samples/opengl/isosurf/isosurf.bkl,../../samples/opengl/penguin/penguin.bkl,../../samples/ownerdrw/ownerdrw.bkl,../../samples/popup/popup.bkl,../../samples/power/power.bkl,../../samples/preferences/preferences.bkl,../../samples/printing/printing.bkl,../../samples/propgrid/propgrid.bkl,../../samples/regtest/regtest.bkl,../../samples/render/render.bkl,../../samples/ribbon/ribbon.bkl,../../samples/richtext/richtext.bkl,../../samples/sashtest/sashtest.bkl,../../samples/scroll/scroll.bkl,../../samples/shaped/shaped.bkl,../../samples/sockets/sockets.bkl,../../samples/sound/sound.bkl,../../samples/splash/splash.bkl,../../samples/splitter/splitter.bkl,../../samples/statbar/statbar.bkl,../../samples/stc/stctest.bkl,../../samples/svg/svgtest.bkl,../../samples/taborder/taborder.bkl,../../samples/taskbar/taskbar.bkl,../../samples/text/text.bkl,../../samples/thread/thread.bkl,../../samples/toolbar/toolbar.bkl,../../samples/treectrl/treectrl.bkl,../../samples/treelist/treelist.bkl,../../samples/typetest/typetest.bkl,../../samples/uiaction/uiaction.bkl,../../samples/validate/validate.bkl,../../samples/vscroll/vscroll.bkl,../../samples/webview/webview.bkl,../../samples/widgets/widgets.bkl,../../samples/wizard/wizard.bkl,../../samples/wrapsizer/wrapsizer.bkl,../../samples/xrc/xrcdemo.bkl,../../samples/xti/xti.bkl,../../tests/benchmarks/bench.bkl,../../tests/test.bkl,../../utils/emulator/src/emulator.bkl,../../utils/execmon/execmon.bkl,../../utils/helpview/src/helpview.bkl,../../utils/hhp2cached/hhp2cached.bkl,../../utils/ifacecheck/src/ifacecheck.bkl,../../utils/screenshotgen/src/screenshotgen.bkl,../../utils/wxrc/wxrc.bkl,wx.bkl] ###
1092
    COND_USE_WEBVIEW_WEBKIT2_1="#"
1093
    if test "x$USE_WEBVIEW_WEBKIT2" = "x1" ; then
1094
        COND_USE_WEBVIEW_WEBKIT2_1=""
1095
    fi
1096
    AC_SUBST(COND_USE_WEBVIEW_WEBKIT2_1)
(-)a/build/bakefiles/common.bkl (+5 lines)
Line 832 $(TAB)$(VC_COMPILER) /EP /nologo "$(DOLLAR)(InputPath)" > "$(SETUPHDIR)\wx\msw\r Link Here
833
    <set var="webviewdll_ext_dir_define">
834
        <if cond="FORMAT=='autoconf' and USE_WEBVIEW_WEBKIT2=='1'">WX_WEB_EXTENSIONS_DIRECTORY=\"$(PLUGINS_INST_DIR)/web-extensions\"</if>
835
    </set>
836
837
(-)a/build/bakefiles/config.bkl (+1 lines)
Line 431 to run the tests, include CppUnit library here. Link Here
432
        <option name="USE_WEBVIEW_WEBKIT2"/>
(-)a/build/bakefiles/files.bkl (-1 / +8 lines)
Line 3420 IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! Link Here
3420
    <if cond="TOOLKIT=='GTK'">src/gtk/webview_webkit.cpp</if>
3420
    <if cond="TOOLKIT=='GTK'">
3421
        src/gtk/webview_webkit.cpp
3422
        src/gtk/webview_webkit2.cpp
3423
    </if>
Line 3451 IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! Link Here
3455
<set var="WEBVIEW_WEBKIT2_EXTENSION_SRC" hints="files">
3456
    src/gtk/webview_webkit2_extension.cpp
3457
</set>
3458
(-)a/build/bakefiles/monolithic.bkl (+2 lines)
Line 24 Link Here
25
        <define>$(webviewdll_ext_dir_define)</define>
Line 34 Link Here
36
        <define>$(webviewdll_ext_dir_define)</define>
(-)a/build/bakefiles/multilib.bkl (+1 lines)
Line 182 Link Here
183
        <define>$(webviewdll_ext_dir_define)</define>
(-)a/build/bakefiles/plugins.bkl (+7 lines)
Line 13 Link Here
14
    <if cond="FORMAT=='autoconf'">
15
        <wx-base-plugin id="webkit2_ext" cond="USE_WEBVIEW_WEBKIT2=='1'">
16
            <sources>$(WEBVIEW_WEBKIT2_EXTENSION_SRC)</sources>
17
            <ldlibs>$(EXTRALIBS_WEBVIEW)</ldlibs>
18
            <install-to>$(PLUGINS_INST_DIR)/web-extensions</install-to>
19
        </wx-base-plugin>
20
    </if>
(-)a/configure (-7 / +101 lines)
Line 677 COND_USE_XRC_1 Link Here
678
COND_USE_WEBVIEW_WEBKIT2_1
Line 37297 if test "$wxUSE_WEBVIEW" = "yes"; then Link Here
37299
    USE_WEBVIEW_WEBKIT2=0
Line 37300 if test "$wxUSE_WEBVIEW" = "yes"; then Link Here
37300
            webkitgtk=webkit-1.0
Line 37302 if test "$wxUSE_WEBVIEW" = "yes"; then Link Here
37302
                webkitgtk=webkitgtk-3.0
37303
37304
pkg_failed=no
37305
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for WEBKIT" >&5
37306
$as_echo_n "checking for WEBKIT... " >&6; }
37307
37308
if test -n "$PKG_CONFIG"; then
37309
    if test -n "$WEBKIT_CFLAGS"; then
37310
        pkg_cv_WEBKIT_CFLAGS="$WEBKIT_CFLAGS"
37311
    else
37312
        if test -n "$PKG_CONFIG" && \
37313
    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"webkit2gtk-4.0\""; } >&5
37314
  ($PKG_CONFIG --exists --print-errors "webkit2gtk-4.0") 2>&5
37315
  ac_status=$?
37316
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
37317
  test $ac_status = 0; }; then
37318
  pkg_cv_WEBKIT_CFLAGS=`$PKG_CONFIG --cflags "webkit2gtk-4.0" 2>/dev/null`
37319
else
37320
  pkg_failed=yes
37321
fi
37322
    fi
37323
else
37324
	pkg_failed=untried
37325
fi
37326
if test -n "$PKG_CONFIG"; then
37327
    if test -n "$WEBKIT_LIBS"; then
37328
        pkg_cv_WEBKIT_LIBS="$WEBKIT_LIBS"
37329
    else
37330
        if test -n "$PKG_CONFIG" && \
37331
    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"webkit2gtk-4.0\""; } >&5
37332
  ($PKG_CONFIG --exists --print-errors "webkit2gtk-4.0") 2>&5
37333
  ac_status=$?
37334
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
37335
  test $ac_status = 0; }; then
37336
  pkg_cv_WEBKIT_LIBS=`$PKG_CONFIG --libs "webkit2gtk-4.0" 2>/dev/null`
37337
else
37338
  pkg_failed=yes
37339
fi
37340
    fi
37341
else
37342
	pkg_failed=untried
37343
fi
37344
37345
37346
37347
if test $pkg_failed = yes; then
37348
37349
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
37350
        _pkg_short_errors_supported=yes
37351
else
37352
        _pkg_short_errors_supported=no
37353
fi
37354
        if test $_pkg_short_errors_supported = yes; then
37355
	        WEBKIT_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "webkit2gtk-4.0"`
37356
        else
37357
	        WEBKIT_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "webkit2gtk-4.0"`
37358
        fi
37359
	# Put the nasty error message in config.log where it belongs
37360
	echo "$WEBKIT_PKG_ERRORS" >&5
37361
37362
37363
                                    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: webkit2gtk not found, falling back to webkitgtk" >&5
37364
$as_echo "$as_me: WARNING: webkit2gtk not found, falling back to webkitgtk" >&2;}
37365
37366
elif test $pkg_failed = untried; then
37367
37368
                                    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: webkit2gtk not found, falling back to webkitgtk" >&5
37369
$as_echo "$as_me: WARNING: webkit2gtk not found, falling back to webkitgtk" >&2;}
37370
37371
else
37372
	WEBKIT_CFLAGS=$pkg_cv_WEBKIT_CFLAGS
37373
	WEBKIT_LIBS=$pkg_cv_WEBKIT_LIBS
37374
        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
37375
$as_echo "yes" >&6; }
37376
37377
                                    USE_WEBVIEW_WEBKIT2=1
37378
                                    CPPFLAGS="$CPPFLAGS $WEBKIT_CFLAGS"
37379
                                    EXTRALIBS_WEBVIEW="$WEBKIT_LIBS"
37380
37381
fi
Line 37303 if test "$wxUSE_WEBVIEW" = "yes"; then Link Here
37383
            if test "$USE_WEBVIEW_WEBKIT2" = 0; then
37384
                webkitgtk=webkit-1.0
37385
                if test "$WXGTK3" = 1; then
37386
                    webkitgtk=webkitgtk-3.0
37387
                fi
Line 37364 fi Link Here
37364
                                { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: webkitgtk not found." >&5
37448
                                    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: webkitgtk not found." >&5
Line 37369 elif test $pkg_failed = untried; then Link Here
37369
                                { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: webkitgtk not found." >&5
37453
                                    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: webkitgtk not found." >&5
Lines 37378-37380 $as_echo "yes" >&6; } Link Here
37378
                                USE_WEBVIEW_WEBKIT=1
37462
                                    USE_WEBVIEW_WEBKIT=1
37379
                                CPPFLAGS="$CPPFLAGS $WEBKIT_CFLAGS"
37463
                                    CPPFLAGS="$CPPFLAGS $WEBKIT_CFLAGS"
37380
                                EXTRALIBS_WEBVIEW="$WEBKIT_LIBS"
37464
                                    EXTRALIBS_WEBVIEW="$WEBKIT_LIBS"
Line 37382 fi Link Here
37467
            fi
Line 37413 fi Link Here
37499
        elif test "$USE_WEBVIEW_WEBKIT2" = 1; then
37500
            wxUSE_WEBVIEW="yes"
37501
            $as_echo "#define wxUSE_WEBVIEW_WEBKIT2 1" >>confdefs.h
37502
Line 41667 EOF Link Here
41757
    COND_USE_WEBVIEW_WEBKIT2_1="#"
41758
    if test "x$USE_WEBVIEW_WEBKIT2" = "x1" ; then
41759
        COND_USE_WEBVIEW_WEBKIT2_1=""
41760
    fi
41761
(-)a/configure.in (-12 / +30 lines)
Line 7254 if test "$wxUSE_WEBVIEW" = "yes"; then Link Here
7255
    USE_WEBVIEW_WEBKIT2=0
Line 7257 if test "$wxUSE_WEBVIEW" = "yes"; then Link Here
7257
            webkitgtk=webkit-1.0
Line 7259 if test "$wxUSE_WEBVIEW" = "yes"; then Link Here
7259
                webkitgtk=webkitgtk-3.0
7259
                PKG_CHECK_MODULES([WEBKIT],
7260
                                  [webkit2gtk-4.0],
7261
                                  [
7262
                                    USE_WEBVIEW_WEBKIT2=1
7263
                                    CPPFLAGS="$CPPFLAGS $WEBKIT_CFLAGS"
7264
                                    EXTRALIBS_WEBVIEW="$WEBKIT_LIBS"
7265
                                  ],
7266
                                  [
7267
                                    AC_MSG_WARN([webkit2gtk not found, falling back to webkitgtk])
7268
                                  ])
7269
            fi
7270
            if test "$USE_WEBVIEW_WEBKIT2" = 0; then
7271
                webkitgtk=webkit-1.0
7272
                if test "$WXGTK3" = 1; then
7273
                    webkitgtk=webkitgtk-3.0
7274
                fi
7275
                PKG_CHECK_MODULES([WEBKIT],
7276
                                  [$webkitgtk >= 1.3.1],
7277
                                  [
7278
                                    USE_WEBVIEW_WEBKIT=1
7279
                                    CPPFLAGS="$CPPFLAGS $WEBKIT_CFLAGS"
7280
                                    EXTRALIBS_WEBVIEW="$WEBKIT_LIBS"
7281
                                  ],
7282
                                  [
7283
                                    AC_MSG_WARN([webkitgtk not found.])
7284
                                  ])
Lines 7261-7270 if test "$wxUSE_WEBVIEW" = "yes"; then Link Here
7261
            PKG_CHECK_MODULES([WEBKIT],
7262
                              [$webkitgtk >= 1.3.1],
7263
                              [
7264
                                USE_WEBVIEW_WEBKIT=1
7265
                                CPPFLAGS="$CPPFLAGS $WEBKIT_CFLAGS"
7266
                                EXTRALIBS_WEBVIEW="$WEBKIT_LIBS"
7267
                              ],
7268
                              [
7269
                                AC_MSG_WARN([webkitgtk not found.])
7270
                              ])
Line 7296 if test "$wxUSE_WEBVIEW" = "yes"; then Link Here
7312
        elif test "$USE_WEBVIEW_WEBKIT2" = 1; then
7313
            wxUSE_WEBVIEW="yes"
7314
            AC_DEFINE(wxUSE_WEBVIEW_WEBKIT2)
(-)a/docs/changes.txt (+12 lines)
Line 582 Major new features in this release Link Here
583
3.0.4: (released 2017-??-??)
584
----------------------------
585
586
All (GUI):
587
588
- Fix wxListbook::GetPageImage() to not always return -1 (Kinaou Hervé).
589
590
wxGTK:
591
592
- Allow using more recent WebKit2GTK+ in wxWebView (Scott Talbert).
593
594
(-)a/include/wx/android/setup.h (-1 / +12 lines)
Line 729 Link Here
729
#if defined(__WXGTK__) || defined(__WXOSX__)
729
#if (defined(__WXGTK__) && !defined(__WXGTK3__)) || defined(__WXOSX__)
Line 734 Link Here
735
// Use the WebKit2 wxWebView backend
736
//
737
// Default is 1 on GTK3
738
//
739
// Recommended setting: 1
740
#if defined(__WXGTK3__)
741
#define wxUSE_WEBVIEW_WEBKIT2 1
742
#else
743
#define wxUSE_WEBVIEW_WEBKIT2 0
744
#endif
745
(-)a/include/wx/chkconf.h (-1 / +1 lines)
Line 2193 Link Here
2193
#if wxUSE_WEBVIEW && !(wxUSE_WEBVIEW_WEBKIT || wxUSE_WEBVIEW_IE)
2193
#if wxUSE_WEBVIEW && !(wxUSE_WEBVIEW_WEBKIT || wxUSE_WEBVIEW_WEBKIT2 || wxUSE_WEBVIEW_IE)
(-)a/include/wx/gtk/private/webview_webkit2_extension.h (+15 lines)
Line 0 Link Here
1
/////////////////////////////////////////////////////////////////////////////
2
// Name:        include/wx/gtk/private/webview_webkit2_extension.h
3
// Purpose:     Common elements for webview webkit2 extension
4
// Author:      Scott Talbert
5
// Copyright:   (c) 2017 Scott Talbert
6
// Licence:     wxWindows licence
7
/////////////////////////////////////////////////////////////////////////////
8
9
#ifndef _WX_GTK_PRIVATE_WEBVIEW_WEBKIT2_EXTENSION_H_
10
#define _WX_GTK_PRIVATE_WEBVIEW_WEBKIT2_EXTENSION_H_
11
12
#define WXGTK_WEB_EXTENSION_OBJECT_PATH "/org/wxwidgets/wxGTK/WebExtension"
13
#define WXGTK_WEB_EXTENSION_INTERFACE   "org.wxwidgets.wxGTK.WebExtension"
14
15
#endif // _WX_GTK_PRIVATE_WEBVIEW_WEBKIT2_EXTENSION_H_
(-)a/include/wx/gtk/webview_webkit.h (-1 / +17 lines)
Line 14 Link Here
14
#if wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && defined(__WXGTK__)
14
// NOTE: this header is used for both the WebKit1 and WebKit2 implementations
15
#if wxUSE_WEBVIEW && (wxUSE_WEBVIEW_WEBKIT || wxUSE_WEBVIEW_WEBKIT2) && defined(__WXGTK__)
Line 17 Link Here
19
#if wxUSE_WEBVIEW_WEBKIT2
20
#include <glib.h>
21
#include <gio/gio.h>
22
#endif
Line 154 private: Link Here
160
#if wxUSE_WEBVIEW_WEBKIT2
161
    bool CanExecuteEditingCommand(const gchar* command) const;
162
    void SetupWebExtensionServer();
163
#endif
164
Line 165 private: Link Here
176
#if wxUSE_WEBVIEW_WEBKIT2
177
    //Used for webkit2 extension
178
    GDBusServer *m_dbusServer;
179
    GDBusProxy *m_extension;
180
#endif
181
(-)a/include/wx/gtk/webviewhistoryitem_webkit.h (-1 / +1 lines)
Line 14 Link Here
14
#if wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && defined(__WXGTK__)
14
#if wxUSE_WEBVIEW && (wxUSE_WEBVIEW_WEBKIT || wxUSE_WEBVIEW_WEBKIT2) && defined(__WXGTK__)
(-)a/include/wx/html/htmlcell.h (-4 / +4 lines)
Line 659 public: Link Here
659
          { m_Href = m_Target = wxEmptyString; m_Event = NULL, m_Cell = NULL; }
659
          { m_Href = m_Target = wxEmptyString; m_Event = NULL; m_Cell = NULL; }
Line 661 public: Link Here
661
          { m_Href = href; m_Target = target; m_Event = NULL, m_Cell = NULL; }
661
          { m_Href = href; m_Target = target; m_Event = NULL; m_Cell = NULL; }
Line 663 public: Link Here
663
          { m_Href = l.m_Href, m_Target = l.m_Target, m_Event = l.m_Event;
663
          { m_Href = l.m_Href; m_Target = l.m_Target; m_Event = l.m_Event;
Line 666 public: Link Here
666
          { m_Href = l.m_Href, m_Target = l.m_Target, m_Event = l.m_Event;
666
          { m_Href = l.m_Href; m_Target = l.m_Target; m_Event = l.m_Event;
(-)a/include/wx/mousestate.h (-1 / +1 lines)
Line 113 public: Link Here
113
    void SetPosition(wxPoint pos) { m_x = pos.x, m_y = pos.y; }
113
    void SetPosition(wxPoint pos) { m_x = pos.x; m_y = pos.y; }
(-)a/include/wx/setup_inc.h (-1 / +12 lines)
Line 744 Link Here
744
#if defined(__WXGTK__) || defined(__WXOSX__)
744
#if (defined(__WXGTK__) && !defined(__WXGTK3__)) || defined(__WXOSX__)
Line 749 Link Here
750
// Use the WebKit2 wxWebView backend
751
//
752
// Default is 1 on GTK3
753
//
754
// Recommended setting: 1
755
#if defined(__WXGTK3__)
756
#define wxUSE_WEBVIEW_WEBKIT2 1
757
#else
758
#define wxUSE_WEBVIEW_WEBKIT2 0
759
#endif
760
(-)a/interface/wx/webview.h (+4 lines)
Line 573 public: Link Here
574
575
        @note This is not implemented on the WebKit2GTK+ backend.
Line 578 public: Link Here
581
582
        @note This is not implemented on the WebKit2GTK+ backend.
(-)a/samples/webview/webview.cpp (-1 / +1 lines)
Line 24 Link Here
24
#if !wxUSE_WEBVIEW_WEBKIT && !wxUSE_WEBVIEW_IE
24
#if !wxUSE_WEBVIEW_WEBKIT && !wxUSE_WEBVIEW_WEBKIT2 && !wxUSE_WEBVIEW_IE
(-)a/setup.h.in (-1 / +7 lines)
Line 343 Link Here
343
#if defined(__WXGTK__) || defined(__WXOSX__)
343
#if (defined(__WXGTK__) && !defined(__WXGTK3__)) || defined(__WXOSX__)
Line 348 Link Here
349
#if defined(__WXGTK3__)
350
#define wxUSE_WEBVIEW_WEBKIT2 0
351
#else
352
#define wxUSE_WEBVIEW_WEBKIT2 0
353
#endif
354
(-)a/src/common/appbase.cpp (+4 lines)
Line 640 void wxAppConsoleBase::OnUnhandledException() Link Here
641
#ifdef wxNO_RTTI
642
        what.Printf("std::exception, what() = \"%s\"", e.what());
643
#else
Line 642 void wxAppConsoleBase::OnUnhandledException() Link Here
646
#endif
(-)a/src/generic/listbkg.cpp (+1 lines)
Line 242 int wxListbook::GetPageImage(size_t n) const Link Here
243
    item.SetMask(wxLIST_MASK_IMAGE);
(-)a/src/gtk/webview_webkit.cpp (+1 lines)
Line 446 bool wxWebViewWebKit::Create(wxWindow *parent, Link Here
447
    m_web_view = NULL;
(-)a/src/gtk/webview_webkit2.cpp (+1262 lines)
Line 0 Link Here
1
/////////////////////////////////////////////////////////////////////////////
2
// Name:        src/gtk/webview_webkit2.cpp
3
// Purpose:     GTK WebKit2 backend for web view component
4
// Author:      Scott Talbert
5
// Copyright:   (c) 2017 Scott Talbert
6
// Licence:     wxWindows licence
7
/////////////////////////////////////////////////////////////////////////////
8
9
// For compilers that support precompilation, includes "wx.h".
10
#include "wx/wxprec.h"
11
12
#if wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT2
13
14
#include "wx/stockitem.h"
15
#include "wx/gtk/webview_webkit.h"
16
#include "wx/gtk/control.h"
17
#include "wx/gtk/private.h"
18
#include "wx/filesys.h"
19
#include "wx/base64.h"
20
#include "wx/log.h"
21
#include "wx/gtk/private/webview_webkit2_extension.h"
22
#include <webkit2/webkit2.h>
23
24
// ----------------------------------------------------------------------------
25
// GTK callbacks
26
// ----------------------------------------------------------------------------
27
28
extern "C"
29
{
30
31
static void
32
wxgtk_webview_webkit_load_changed(GtkWidget *,
33
                                  WebKitLoadEvent load_event,
34
                                  wxWebViewWebKit *webKitCtrl)
35
{
36
    wxString url = webKitCtrl->GetCurrentURL();
37
38
    wxString target; // TODO: get target (if possible)
39
40
    if (load_event == WEBKIT_LOAD_FINISHED)
41
    {
42
        webKitCtrl->m_busy = false;
43
        wxWebViewEvent event(wxEVT_WEBVIEW_LOADED,
44
                             webKitCtrl->GetId(),
45
                             url, target);
46
47
        if (webKitCtrl && webKitCtrl->GetEventHandler())
48
            webKitCtrl->GetEventHandler()->ProcessEvent(event);
49
    }
50
    else if (load_event == WEBKIT_LOAD_COMMITTED)
51
    {
52
        webKitCtrl->m_busy = true;
53
        wxWebViewEvent event(wxEVT_WEBVIEW_NAVIGATED,
54
                             webKitCtrl->GetId(),
55
                             url, target);
56
57
        if (webKitCtrl && webKitCtrl->GetEventHandler())
58
            webKitCtrl->GetEventHandler()->ProcessEvent(event);
59
    }
60
}
61
62
static gboolean
63
wxgtk_webview_webkit_navigation(WebKitWebView *web_view,
64
                                WebKitPolicyDecision *decision,
65
                                wxWebViewWebKit *webKitCtrl)
66
{
67
    WebKitNavigationPolicyDecision* navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION(decision);
68
    WebKitNavigationAction* action = webkit_navigation_policy_decision_get_navigation_action(navigation_decision);
69
    WebKitURIRequest* request = webkit_navigation_action_get_request(action);
70
    const gchar* uri = webkit_uri_request_get_uri(request);
71
    wxString target = webkit_navigation_policy_decision_get_frame_name(navigation_decision);
72
    
73
    //If m_creating is true then we are the result of a new window
74
    //and so we need to send the event and veto the load
75
    if(webKitCtrl->m_creating)
76
    {
77
        webKitCtrl->m_creating = false;
78
        wxWebViewEvent event(wxEVT_WEBVIEW_NEWWINDOW,
79
                             webKitCtrl->GetId(),
80
                             wxString(uri, wxConvUTF8),
81
                             target);
82
83
        if(webKitCtrl && webKitCtrl->GetEventHandler())
84
            webKitCtrl->GetEventHandler()->ProcessEvent(event);
85
        
86
        webkit_policy_decision_ignore(decision);
87
        return TRUE;
88
    }
89
90
    if(webKitCtrl->m_guard)
91
    {
92
        webKitCtrl->m_guard = false;
93
        //We set this to make sure that we don't try to load the page again from
94
        //the resource request callback
95
        webKitCtrl->m_vfsurl = webkit_web_view_get_uri(web_view);
96
        webkit_policy_decision_use(decision);
97
        return FALSE;
98
    }
99
100
    webKitCtrl->m_busy = true;
101
102
    wxWebViewEvent event(wxEVT_WEBVIEW_NAVIGATING,
103
                         webKitCtrl->GetId(),
104
                         wxString( uri, wxConvUTF8 ),
105
                         target);
106
107
    if (webKitCtrl && webKitCtrl->GetEventHandler())
108
        webKitCtrl->GetEventHandler()->ProcessEvent(event);
109
110
    if (!event.IsAllowed())
111
    {
112
        webKitCtrl->m_busy = false;
113
        webkit_policy_decision_ignore(decision);
114
        return TRUE;
115
    }
116
    else
117
    {
118
        wxString wxuri = uri;
119
        wxSharedPtr<wxWebViewHandler> handler;
120
        wxVector<wxSharedPtr<wxWebViewHandler> > handlers = webKitCtrl->GetHandlers();
121
        //We are not vetoed so see if we match one of the additional handlers
122
        for(wxVector<wxSharedPtr<wxWebViewHandler> >::iterator it = handlers.begin();
123
            it != handlers.end(); ++it)
124
        {
125
            if(wxuri.substr(0, (*it)->GetName().length()) == (*it)->GetName())
126
            {
127
                handler = (*it);
128
            }
129
        }
130
        //If we found a handler we can then use it to load the file directly
131
        //ourselves
132
        if(handler)
133
        {
134
            webKitCtrl->m_guard = true;
135
            wxFSFile* file = handler->GetFile(wxuri);
136
            if(file)
137
            {
138
                webKitCtrl->SetPage(*file->GetStream(), wxuri);
139
            }
140
            //We need to throw some sort of error here if file is NULL
141
            webkit_policy_decision_ignore(decision);
142
            return TRUE;
143
        }
144
        return FALSE;
145
    }
146
}
147
148
static gboolean
149
wxgtk_webview_webkit_load_failed(WebKitWebView *,
150
                                 WebKitLoadEvent,
151
                                 gchar *uri,
152
                                 GError *error,
153
                                 wxWebViewWebKit* webKitWindow)
154
{
155
    webKitWindow->m_busy = false;
156
    wxWebViewNavigationError type = wxWEBVIEW_NAV_ERR_OTHER;
157
158
    wxString description(error->message, wxConvUTF8);
159
160
    if (strcmp(g_quark_to_string(error->domain), "soup_http_error_quark") == 0)
161
    {
162
        switch (error->code)
163
        {
164
            case SOUP_STATUS_CANCELLED:
165
                type = wxWEBVIEW_NAV_ERR_USER_CANCELLED;
166
                break;
167
168
            case SOUP_STATUS_CANT_RESOLVE:
169
            case SOUP_STATUS_NOT_FOUND:
170
                type = wxWEBVIEW_NAV_ERR_NOT_FOUND;
171
                break;
172
173
            case SOUP_STATUS_CANT_RESOLVE_PROXY:
174
            case SOUP_STATUS_CANT_CONNECT:
175
            case SOUP_STATUS_CANT_CONNECT_PROXY:
176
            case SOUP_STATUS_SSL_FAILED:
177
            case SOUP_STATUS_IO_ERROR:
178
                type = wxWEBVIEW_NAV_ERR_CONNECTION;
179
                break;
180
181
            case SOUP_STATUS_MALFORMED:
182
                type = wxWEBVIEW_NAV_ERR_REQUEST;
183
                break;
184
185
            case SOUP_STATUS_BAD_REQUEST:
186
                type = wxWEBVIEW_NAV_ERR_REQUEST;
187
                break;
188
189
            case SOUP_STATUS_UNAUTHORIZED:
190
            case SOUP_STATUS_FORBIDDEN:
191
                type = wxWEBVIEW_NAV_ERR_AUTH;
192
                break;
193
194
            case SOUP_STATUS_METHOD_NOT_ALLOWED:
195
            case SOUP_STATUS_NOT_ACCEPTABLE:
196
                type = wxWEBVIEW_NAV_ERR_SECURITY;
197
                break;
198
199
            case SOUP_STATUS_PROXY_AUTHENTICATION_REQUIRED:
200
                type = wxWEBVIEW_NAV_ERR_AUTH;
201
                break;
202
203
            case SOUP_STATUS_REQUEST_TIMEOUT:
204
                type = wxWEBVIEW_NAV_ERR_CONNECTION;
205
                break;
206
207
            case SOUP_STATUS_REQUEST_ENTITY_TOO_LARGE:
208
            case SOUP_STATUS_REQUEST_URI_TOO_LONG:
209
            case SOUP_STATUS_UNSUPPORTED_MEDIA_TYPE:
210
                type = wxWEBVIEW_NAV_ERR_REQUEST;
211
                break;
212
213
            case SOUP_STATUS_BAD_GATEWAY:
214
            case SOUP_STATUS_SERVICE_UNAVAILABLE:
215
            case SOUP_STATUS_GATEWAY_TIMEOUT:
216
                type = wxWEBVIEW_NAV_ERR_CONNECTION;
217
                break;
218
219
            case SOUP_STATUS_HTTP_VERSION_NOT_SUPPORTED:
220
                type = wxWEBVIEW_NAV_ERR_REQUEST;
221
                break;
222
        }
223
    }
224
    else if (strcmp(g_quark_to_string(error->domain),
225
                    "webkit-network-error-quark") == 0)
226
    {
227
        switch (error->code)
228
        {
229
            case WEBKIT_NETWORK_ERROR_UNKNOWN_PROTOCOL:
230
                type = wxWEBVIEW_NAV_ERR_REQUEST;
231
                break;
232
233
            case WEBKIT_NETWORK_ERROR_CANCELLED:
234
                type = wxWEBVIEW_NAV_ERR_USER_CANCELLED;
235
                break;
236
237
            case WEBKIT_NETWORK_ERROR_FILE_DOES_NOT_EXIST:
238
                type = wxWEBVIEW_NAV_ERR_NOT_FOUND;
239
                break;
240
        }
241
    }
242
    else if (strcmp(g_quark_to_string(error->domain),
243
                    "webkit-policy-error-quark") == 0)
244
    {
245
        switch (error->code)
246
        {
247
            case WEBKIT_POLICY_ERROR_CANNOT_USE_RESTRICTED_PORT:
248
                type = wxWEBVIEW_NAV_ERR_SECURITY;
249
                break;
250
        }
251
    }
252
253
    wxWebViewEvent event(wxEVT_WEBVIEW_ERROR,
254
                         webKitWindow->GetId(),
255
                         uri, "");
256
    event.SetString(description);
257
    event.SetInt(type);
258
259
    if (webKitWindow && webKitWindow->GetEventHandler())
260
    {
261
        webKitWindow->GetEventHandler()->ProcessEvent(event);
262
    }
263
264
    return FALSE;
265
}
266
267
static gboolean
268
wxgtk_webview_webkit_new_window(WebKitPolicyDecision *decision,
269
                                wxWebViewWebKit *webKitCtrl)
270
{
271
    WebKitNavigationPolicyDecision* navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION(decision);
272
    WebKitNavigationAction* action = webkit_navigation_policy_decision_get_navigation_action(navigation_decision);
273
    WebKitURIRequest* request = webkit_navigation_action_get_request(action);
274
    const gchar* uri = webkit_uri_request_get_uri(request);
275
276
    wxString target = webkit_navigation_policy_decision_get_frame_name(navigation_decision);
277
    wxWebViewEvent event(wxEVT_WEBVIEW_NEWWINDOW,
278
                                       webKitCtrl->GetId(),
279
                                       wxString( uri, wxConvUTF8 ),
280
                                       target);
281
282
    if (webKitCtrl && webKitCtrl->GetEventHandler())
283
        webKitCtrl->GetEventHandler()->ProcessEvent(event);
284
285
    //We always want the user to handle this themselves
286
    webkit_policy_decision_ignore(decision);
287
    return TRUE;
288
}
289
290
static gboolean
291
wxgtk_webview_webkit_decide_policy(WebKitWebView *web_view,
292
                                   WebKitPolicyDecision *decision,
293
                                   WebKitPolicyDecisionType type,
294
                                   wxWebViewWebKit *webKitCtrl)
295
{
296
    switch (type)
297
    {
298
        case WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION:
299
            return wxgtk_webview_webkit_navigation(web_view, decision, webKitCtrl);
300
        case WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION:
301
            return wxgtk_webview_webkit_new_window(decision, webKitCtrl);
302
        default:
303
            return FALSE;
304
    }
305
}
306
307
static void
308
wxgtk_webview_webkit_title_changed(GtkWidget* widget,
309
                                   GParamSpec *,
310
                                   wxWebViewWebKit *webKitCtrl)
311
{
312
    gchar *title;
313
    g_object_get(G_OBJECT(widget), "title", &title, NULL);
314
315
    wxWebViewEvent event(wxEVT_WEBVIEW_TITLE_CHANGED,
316
                         webKitCtrl->GetId(),
317
                         webKitCtrl->GetCurrentURL(),
318
                         "");
319
    event.SetString(wxString(title, wxConvUTF8));
320
321
    if (webKitCtrl && webKitCtrl->GetEventHandler())
322
        webKitCtrl->GetEventHandler()->ProcessEvent(event);
323
324
    g_free(title);
325
}
326
327
static void
328
wxgtk_webview_webkit_resource_req(WebKitWebView *,
329
                                  WebKitWebResource *,
330
                                  WebKitURIRequest *request,
331
                                  wxWebViewWebKit *webKitCtrl)
332
{
333
    wxString uri = webkit_uri_request_get_uri(request);
334
335
    wxSharedPtr<wxWebViewHandler> handler;
336
    wxVector<wxSharedPtr<wxWebViewHandler> > handlers = webKitCtrl->GetHandlers();
337
338
    //We are not vetoed so see if we match one of the additional handlers
339
    for(wxVector<wxSharedPtr<wxWebViewHandler> >::iterator it = handlers.begin();
340
        it != handlers.end(); ++it)
341
    {
342
        if(uri.substr(0, (*it)->GetName().length()) == (*it)->GetName())
343
        {
344
            handler = (*it);
345
        }
346
    }
347
    //If we found a handler we can then use it to load the file directly
348
    //ourselves
349
    if(handler)
350
    {
351
        //If it is requsting the page itself then return as we have already
352
        //loaded it from the archive
353
        if(webKitCtrl->m_vfsurl == uri)
354
            return;
355
356
        wxFSFile* file = handler->GetFile(uri);
357
        if(file)
358
        {
359
            //We load the data into a data url to save it being written out again
360
            size_t size = file->GetStream()->GetLength();
361
            char *buffer = new char[size];
362
            file->GetStream()->Read(buffer, size);
363
            wxString data = wxBase64Encode(buffer, size);
364
            delete[] buffer;
365
            wxString mime = file->GetMimeType();
366
            wxString path = "data:" + mime + ";base64," + data;
367
            //Then we can redirect the call
368
            webkit_uri_request_set_uri(request, path.utf8_str());
369
        }
370
371
    }
372
}
373
374
static gboolean
375
wxgtk_webview_webkit_context_menu(WebKitWebView *,
376
                                  WebKitContextMenu *,
377
                                  GdkEvent *,
378
                                  WebKitHitTestResult *,
379
                                  wxWebViewWebKit *webKitCtrl)
380
{
381
    if(webKitCtrl->IsContextMenuEnabled())
382
        return FALSE;
383
    else
384
        return TRUE;
385
}
386
387
static WebKitWebView*
388
wxgtk_webview_webkit_create_webview(WebKitWebView *web_view,
389
                                    WebKitNavigationAction *,
390
                                    wxWebViewWebKit *webKitCtrl)
391
{
392
    //As we do not know the uri being loaded at this point allow the load to
393
    //continue and catch it in navigation-policy-decision-requested
394
    webKitCtrl->m_creating = true;
395
    return web_view;
396
}
397
398
static void
399
wxgtk_webview_webkit_counted_matches(WebKitFindController *,
400
                                     guint match_count,
401
                                     int *findCount)
402
{
403
    *findCount = match_count;
404
}
405
406
static void
407
wxgtk_initialize_web_extensions(WebKitWebContext *context,
408
                                GDBusServer *dbusServer)
409
{
410
    const char *address = g_dbus_server_get_client_address(dbusServer);
411
    GVariant *user_data = g_variant_new("(s)", address);
412
    webkit_web_context_set_web_extensions_directory(context,
413
                                                    WX_WEB_EXTENSIONS_DIRECTORY);
414
    webkit_web_context_set_web_extensions_initialization_user_data(context,
415
                                                                   user_data);
416
}
417
418
static gboolean
419
wxgtk_new_connection_cb(GDBusServer *,
420
                        GDBusConnection *connection,
421
                        GDBusProxy **proxy)
422
{
423
    GError *error = NULL;
424
    GDBusProxyFlags flags = static_cast<GDBusProxyFlags>(static_cast<int>(G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES) | static_cast<int>(G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS));
425
    *proxy = g_dbus_proxy_new_sync(connection,
426
                                   flags,
427
                                   NULL,
428
                                   NULL,
429
                                   WXGTK_WEB_EXTENSION_OBJECT_PATH,
430
                                   WXGTK_WEB_EXTENSION_INTERFACE,
431
                                   NULL,
432
                                   &error);
433
    if (error)
434
    {
435
        g_warning("Failed to create dbus proxy: %s", error->message);
436
        g_error_free(error);
437
    }
438
439
    return TRUE;
440
}
441
442
gboolean
443
wxgtk_dbus_peer_is_authorized(GCredentials *peer_credentials)
444
{
445
    static GCredentials *own_credentials = g_credentials_new();
446
    GError *error = NULL;
447
448
    if (peer_credentials && g_credentials_is_same_user(peer_credentials, own_credentials, &error))
449
    {
450
        return TRUE;
451
    }
452
453
    if (error)
454
    {
455
        g_warning("Failed to authorize web extension connection: %s", error->message);
456
        g_error_free(error);
457
    }
458
    return FALSE;
459
}
460
461
static gboolean
462
wxgtk_authorize_authenticated_peer_cb(GDBusAuthObserver *,
463
                                      GIOStream *,
464
                                      GCredentials *credentials,
465
                                      wxWebViewWebKit *)
466
{
467
    return wxgtk_dbus_peer_is_authorized(credentials);
468
}
469
470
} // extern "C"
471
472
//-----------------------------------------------------------------------------
473
// wxWebViewWebKit
474
//-----------------------------------------------------------------------------
475
476
wxIMPLEMENT_DYNAMIC_CLASS(wxWebViewWebKit, wxWebView);
477
478
wxWebViewWebKit::wxWebViewWebKit()
479
{
480
    m_web_view = NULL;
481
    m_dbusServer = NULL;
482
    m_extension = NULL;
483
}
484
485
bool wxWebViewWebKit::Create(wxWindow *parent,
486
                      wxWindowID id,
487
                      const wxString &url,
488
                      const wxPoint& pos,
489
                      const wxSize& size,
490
                      long style,
491
                      const wxString& name)
492
{
493
    m_web_view = NULL;
494
    m_dbusServer = NULL;
495
    m_extension = NULL;
496
    m_busy = false;
497
    m_guard = false;
498
    m_creating = false;
499
    FindClear();
500
501
    // We currently unconditionally impose scrolling in both directions as it's
502
    // necessary to show arbitrary pages.
503
    style |= wxHSCROLL | wxVSCROLL;
504
505
    if (!PreCreation( parent, pos, size ) ||
506
        !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
507
    {
508
        wxFAIL_MSG( wxT("wxWebViewWebKit creation failed") );
509
        return false;
510
    }
511
512
    SetupWebExtensionServer();
513
    g_signal_connect_after(webkit_web_context_get_default(),
514
                           "initialize-web-extensions",
515
                           G_CALLBACK(wxgtk_initialize_web_extensions),
516
                           m_dbusServer);
517
518
    m_web_view = WEBKIT_WEB_VIEW(webkit_web_view_new());
519
    GTKCreateScrolledWindowWith(GTK_WIDGET(m_web_view));
520
    g_object_ref(m_widget);
521
522
    g_signal_connect_after(m_web_view, "decide-policy",
523
                           G_CALLBACK(wxgtk_webview_webkit_decide_policy),
524
                           this);
525
526
    g_signal_connect_after(m_web_view, "load-failed",
527
                           G_CALLBACK(wxgtk_webview_webkit_load_failed), this);
528
529
    g_signal_connect_after(m_web_view, "notify::title",
530
                           G_CALLBACK(wxgtk_webview_webkit_title_changed), this);
531
532
    g_signal_connect_after(m_web_view, "resource-load-started",
533
                           G_CALLBACK(wxgtk_webview_webkit_resource_req), this);
534
535
    g_signal_connect_after(m_web_view, "context-menu",
536
                           G_CALLBACK(wxgtk_webview_webkit_context_menu), this);
537
538
    g_signal_connect_after(m_web_view, "create",
539
                           G_CALLBACK(wxgtk_webview_webkit_create_webview), this);
540
541
    WebKitFindController* findctrl = webkit_web_view_get_find_controller(m_web_view);
542
    g_signal_connect_after(findctrl, "counted-matches",
543
                           G_CALLBACK(wxgtk_webview_webkit_counted_matches),
544
                           &m_findCount);
545
546
    m_parent->DoAddChild( this );
547
548
    PostCreation(size);
549
550
    /* Open a webpage */
551
    webkit_web_view_load_uri(m_web_view, url.utf8_str());
552
553
    // last to avoid getting signal too early
554
    g_signal_connect_after(m_web_view, "load-changed",
555
                           G_CALLBACK(wxgtk_webview_webkit_load_changed),
556
                           this);
557
558
    return true;
559
}
560
561
wxWebViewWebKit::~wxWebViewWebKit()
562
{
563
    if (m_web_view)
564
        GTKDisconnect(m_web_view);
565
    if (m_dbusServer)
566
        g_dbus_server_stop(m_dbusServer);
567
    g_clear_object(&m_dbusServer);
568
    g_clear_object(&m_extension);
569
}
570
571
bool wxWebViewWebKit::Enable( bool enable )
572
{
573
    if (!wxControl::Enable(enable))
574
        return false;
575
576
    gtk_widget_set_sensitive(gtk_bin_get_child(GTK_BIN(m_widget)), enable);
577
578
    return true;
579
}
580
581
GdkWindow*
582
wxWebViewWebKit::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
583
{
584
    GdkWindow* window = gtk_widget_get_parent_window(m_widget);
585
    return window;
586
}
587
588
void wxWebViewWebKit::ZoomIn()
589
{
590
    SetWebkitZoom(GetWebkitZoom() + 0.1);
591
}
592
593
void wxWebViewWebKit::ZoomOut()
594
{
595
    SetWebkitZoom(GetWebkitZoom() - 0.1);
596
}
597
598
void wxWebViewWebKit::SetWebkitZoom(float level)
599
{
600
    webkit_web_view_set_zoom_level(m_web_view, level);
601
}
602
603
float wxWebViewWebKit::GetWebkitZoom() const
604
{
605
    return webkit_web_view_get_zoom_level(m_web_view);
606
}
607
608
void wxWebViewWebKit::Stop()
609
{
610
     webkit_web_view_stop_loading(m_web_view);
611
}
612
613
void wxWebViewWebKit::Reload(wxWebViewReloadFlags flags)
614
{
615
    if (flags & wxWEBVIEW_RELOAD_NO_CACHE)
616
    {
617
        webkit_web_view_reload_bypass_cache(m_web_view);
618
    }
619
    else
620
    {
621
        webkit_web_view_reload(m_web_view);
622
    }
623
}
624
625
void wxWebViewWebKit::LoadURL(const wxString& url)
626
{
627
    webkit_web_view_load_uri(m_web_view, wxGTK_CONV(url));
628
}
629
630
631
void wxWebViewWebKit::GoBack()
632
{
633
    webkit_web_view_go_back(m_web_view);
634
}
635
636
void wxWebViewWebKit::GoForward()
637
{
638
    webkit_web_view_go_forward(m_web_view);
639
}
640
641
642
bool wxWebViewWebKit::CanGoBack() const
643
{
644
    return webkit_web_view_can_go_back(m_web_view);
645
}
646
647
648
bool wxWebViewWebKit::CanGoForward() const
649
{
650
    return webkit_web_view_can_go_forward(m_web_view);
651
}
652
653
void wxWebViewWebKit::ClearHistory()
654
{
655
    // In WebKit2GTK+, the BackForwardList can't be cleared so do nothing.
656
}
657
658
void wxWebViewWebKit::EnableHistory(bool)
659
{
660
    // In WebKit2GTK+, history can't be disabled so do nothing here.
661
}
662
663
wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewWebKit::GetBackwardHistory()
664
{
665
    wxVector<wxSharedPtr<wxWebViewHistoryItem> > backhist;
666
    WebKitBackForwardList* history =
667
        webkit_web_view_get_back_forward_list(m_web_view);
668
    GList* list = webkit_back_forward_list_get_back_list(history);
669
    //We need to iterate in reverse to get the order we desire
670
    for(int i = g_list_length(list) - 1; i >= 0 ; i--)
671
    {
672
        WebKitBackForwardListItem* gtkitem = (WebKitBackForwardListItem*)g_list_nth_data(list, i);
673
        wxWebViewHistoryItem* wxitem = new wxWebViewHistoryItem(
674
                              webkit_back_forward_list_item_get_uri(gtkitem),
675
                              webkit_back_forward_list_item_get_title(gtkitem));
676
        wxitem->m_histItem = gtkitem;
677
        wxSharedPtr<wxWebViewHistoryItem> item(wxitem);
678
        backhist.push_back(item);
679
    }
680
    return backhist;
681
}
682
683
wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewWebKit::GetForwardHistory()
684
{
685
    wxVector<wxSharedPtr<wxWebViewHistoryItem> > forwardhist;
686
    WebKitBackForwardList* history =
687
        webkit_web_view_get_back_forward_list(m_web_view);
688
    GList* list = webkit_back_forward_list_get_forward_list(history);
689
    for(guint i = 0; i < g_list_length(list); i++)
690
    {
691
        WebKitBackForwardListItem* gtkitem = (WebKitBackForwardListItem*)g_list_nth_data(list, i);
692
        wxWebViewHistoryItem* wxitem = new wxWebViewHistoryItem(
693
                              webkit_back_forward_list_item_get_uri(gtkitem),
694
                              webkit_back_forward_list_item_get_title(gtkitem));
695
        wxitem->m_histItem = gtkitem;
696
        wxSharedPtr<wxWebViewHistoryItem> item(wxitem);
697
        forwardhist.push_back(item);
698
    }
699
    return forwardhist;
700
}
701
702
void wxWebViewWebKit::LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem> item)
703
{
704
    WebKitBackForwardListItem* gtkitem = (WebKitBackForwardListItem*)item->m_histItem;
705
    if(gtkitem)
706
    {
707
        webkit_web_view_go_to_back_forward_list_item(m_web_view,
708
                                                     WEBKIT_BACK_FORWARD_LIST_ITEM(gtkitem));
709
    }
710
}
711
712
static void wxgtk_can_execute_editing_command_cb(WebKitWebView *,
713
                                                 GAsyncResult *res,
714
                                                 GAsyncResult **res_out)
715
{
716
    *res_out = (GAsyncResult*)g_object_ref(res);
717
}
718
719
bool wxWebViewWebKit::CanExecuteEditingCommand(const gchar* command) const
720
{
721
    GAsyncResult *result = NULL;
722
    webkit_web_view_can_execute_editing_command(m_web_view,
723
                                                command,
724
                                                NULL,
725
                                                (GAsyncReadyCallback)wxgtk_can_execute_editing_command_cb,
726
                                                &result);
727
728
    GMainContext *main_context = g_main_context_get_thread_default();
729
    while (!result)
730
    {
731
        g_main_context_iteration(main_context, TRUE);
732
    }
733
734
    gboolean can_execute = webkit_web_view_can_execute_editing_command_finish(m_web_view,
735
                                                                              result,
736
                                                                              NULL);
737
    g_object_unref(result);
738
739
    return can_execute;
740
}
741
742
bool wxWebViewWebKit::CanCut() const
743
{
744
    return CanExecuteEditingCommand(WEBKIT_EDITING_COMMAND_CUT);
745
}
746
747
bool wxWebViewWebKit::CanCopy() const
748
{
749
    return CanExecuteEditingCommand(WEBKIT_EDITING_COMMAND_COPY);
750
}
751
752
bool wxWebViewWebKit::CanPaste() const
753
{
754
    return CanExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE);
755
}
756
757
void wxWebViewWebKit::Cut()
758
{
759
    webkit_web_view_execute_editing_command(m_web_view,
760
                                            WEBKIT_EDITING_COMMAND_CUT);
761
}
762
763
void wxWebViewWebKit::Copy()
764
{
765
    webkit_web_view_execute_editing_command(m_web_view,
766
                                            WEBKIT_EDITING_COMMAND_COPY);
767
}
768
769
void wxWebViewWebKit::Paste()
770
{
771
    webkit_web_view_execute_editing_command(m_web_view,
772
                                            WEBKIT_EDITING_COMMAND_PASTE);
773
}
774
775
bool wxWebViewWebKit::CanUndo() const
776
{
777
    return CanExecuteEditingCommand(WEBKIT_EDITING_COMMAND_UNDO);
778
}
779
780
bool wxWebViewWebKit::CanRedo() const
781
{
782
    return CanExecuteEditingCommand(WEBKIT_EDITING_COMMAND_REDO);
783
}
784
785
void wxWebViewWebKit::Undo()
786
{
787
    webkit_web_view_execute_editing_command(m_web_view,
788
                                            WEBKIT_EDITING_COMMAND_UNDO);
789
}
790
791
void wxWebViewWebKit::Redo()
792
{
793
    webkit_web_view_execute_editing_command(m_web_view,
794
                                            WEBKIT_EDITING_COMMAND_REDO);
795
}
796
797
wxString wxWebViewWebKit::GetCurrentURL() const
798
{
799
    // FIXME: check which encoding the web kit control uses instead of
800
    // assuming UTF8 (here and elsewhere too)
801
    return wxString::FromUTF8(webkit_web_view_get_uri(m_web_view));
802
}
803
804
805
wxString wxWebViewWebKit::GetCurrentTitle() const
806
{
807
    return wxString::FromUTF8(webkit_web_view_get_title(m_web_view));
808
}
809
810
811
static void wxgtk_web_resource_get_data_cb(WebKitWebResource *,
812
                                           GAsyncResult *res,
813
                                           GAsyncResult **res_out)
814
{
815
    *res_out = (GAsyncResult*)g_object_ref(res);
816
}
817
818
wxString wxWebViewWebKit::GetPageSource() const
819
{
820
    WebKitWebResource *resource = webkit_web_view_get_main_resource(m_web_view);
821
    if (!resource)
822
    {
823
        return wxString();
824
    }
825
826
    GAsyncResult *result = NULL;
827
    webkit_web_resource_get_data(resource, NULL,
828
                                 (GAsyncReadyCallback)wxgtk_web_resource_get_data_cb,
829
                                 &result);
830
831
    GMainContext *main_context = g_main_context_get_thread_default();
832
    while (!result)
833
    {
834
        g_main_context_iteration(main_context, TRUE);
835
    }
836
837
    guchar *source = webkit_web_resource_get_data_finish(resource, result,
838
                                                         NULL, NULL);
839
    if (result)
840
    {
841
        g_object_unref(result);
842
    }
843
844
    if (source)
845
    {
846
        wxString wxs = wxString(source, wxConvUTF8);
847
        free(source);
848
        return wxs;
849
    }
850
    return wxString();
851
}
852
853
854
wxWebViewZoom wxWebViewWebKit::GetZoom() const
855
{
856
    float zoom = GetWebkitZoom();
857
858
    // arbitrary way to map float zoom to our common zoom enum
859
    if (zoom <= 0.65)
860
    {
861
        return wxWEBVIEW_ZOOM_TINY;
862
    }
863
    else if (zoom > 0.65 && zoom <= 0.90)
864
    {
865
        return wxWEBVIEW_ZOOM_SMALL;
866
    }
867
    else if (zoom > 0.90 && zoom <= 1.15)
868
    {
869
        return wxWEBVIEW_ZOOM_MEDIUM;
870
    }
871
    else if (zoom > 1.15 && zoom <= 1.45)
872
    {
873
        return wxWEBVIEW_ZOOM_LARGE;
874
    }
875
    else if (zoom > 1.45)
876
    {
877
        return wxWEBVIEW_ZOOM_LARGEST;
878
    }
879
880
    // to shut up compilers, this can never be reached logically
881
    wxFAIL;
882
    return wxWEBVIEW_ZOOM_MEDIUM;
883
}
884
885
886
void wxWebViewWebKit::SetZoom(wxWebViewZoom zoom)
887
{
888
    // arbitrary way to map our common zoom enum to float zoom
889
    switch (zoom)
890
    {
891
        case wxWEBVIEW_ZOOM_TINY:
892
            SetWebkitZoom(0.6f);
893
            break;
894
895
        case wxWEBVIEW_ZOOM_SMALL:
896
            SetWebkitZoom(0.8f);
897
            break;
898
899
        case wxWEBVIEW_ZOOM_MEDIUM:
900
            SetWebkitZoom(1.0f);
901
            break;
902
903
        case wxWEBVIEW_ZOOM_LARGE:
904
            SetWebkitZoom(1.3);
905
            break;
906
907
        case wxWEBVIEW_ZOOM_LARGEST:
908
            SetWebkitZoom(1.6);
909
            break;
910
911
        default:
912
            wxFAIL;
913
    }
914
}
915
916
void wxWebViewWebKit::SetZoomType(wxWebViewZoomType type)
917
{
918
    WebKitSettings* settings = webkit_web_view_get_settings(m_web_view);
919
    webkit_settings_set_zoom_text_only(settings,
920
                                       (type == wxWEBVIEW_ZOOM_TYPE_TEXT ?
921
                                       TRUE : FALSE));
922
}
923
924
wxWebViewZoomType wxWebViewWebKit::GetZoomType() const
925
{
926
    WebKitSettings* settings = webkit_web_view_get_settings(m_web_view);
927
    gboolean tozoom = webkit_settings_get_zoom_text_only(settings);
928
929
    if (tozoom)
930
        return wxWEBVIEW_ZOOM_TYPE_TEXT;
931
    else
932
        return wxWEBVIEW_ZOOM_TYPE_LAYOUT;
933
}
934
935
bool wxWebViewWebKit::CanSetZoomType(wxWebViewZoomType) const
936
{
937
    // this port supports all zoom types
938
    return true;
939
}
940
941
void wxWebViewWebKit::DoSetPage(const wxString& html, const wxString& baseUri)
942
{
943
    webkit_web_view_load_html(m_web_view,
944
                              html.mb_str(wxConvUTF8),
945
                              baseUri.mb_str(wxConvUTF8));
946
}
947
948
void wxWebViewWebKit::Print()
949
{
950
    WebKitPrintOperation* printop = webkit_print_operation_new(m_web_view);
951
    webkit_print_operation_run_dialog(printop, NULL);
952
    g_object_unref(printop);
953
}
954
955
956
bool wxWebViewWebKit::IsBusy() const
957
{
958
    return m_busy;
959
}
960
961
void wxWebViewWebKit::SetEditable(bool enable)
962
{
963
    webkit_web_view_set_editable(m_web_view, enable);
964
}
965
966
bool wxWebViewWebKit::IsEditable() const
967
{
968
    gboolean editable;
969
    g_object_get(m_web_view, "editable", &editable, NULL);
970
    return editable;
971
}
972
973
void wxWebViewWebKit::DeleteSelection()
974
{
975
    if (m_extension)
976
    {
977
        guint64 page_id = webkit_web_view_get_page_id(m_web_view);
978
        GVariant *retval = g_dbus_proxy_call_sync(m_extension,
979
                                                  "DeleteSelection",
980
                                                  g_variant_new("(t)", page_id),
981
                                                  G_DBUS_CALL_FLAGS_NONE, -1,
982
                                                  NULL, NULL);
983
        if (retval)
984
        {
985
            g_variant_unref(retval);
986
        }
987
    }
988
}
989
990
bool wxWebViewWebKit::HasSelection() const
991
{
992
    if (m_extension)
993
    {
994
        guint64 page_id = webkit_web_view_get_page_id(m_web_view);
995
        GVariant *retval = g_dbus_proxy_call_sync(m_extension,
996
                                                  "HasSelection",
997
                                                  g_variant_new("(t)", page_id),
998
                                                  G_DBUS_CALL_FLAGS_NONE, -1,
999
                                                  NULL, NULL);
1000
        if (retval)
1001
	{
1002
            gboolean has_selection = FALSE;
1003
            g_variant_get(retval, "(b)", &has_selection);
1004
            g_variant_unref(retval);
1005
            return has_selection;
1006
        }
1007
    }
1008
    return false;
1009
}
1010
1011
void wxWebViewWebKit::SelectAll()
1012
{
1013
    webkit_web_view_execute_editing_command(m_web_view,
1014
                                            WEBKIT_EDITING_COMMAND_SELECT_ALL);
1015
}
1016
1017
wxString wxWebViewWebKit::GetSelectedText() const
1018
{
1019
    if (m_extension)
1020
    {
1021
        guint64 page_id = webkit_web_view_get_page_id(m_web_view);
1022
        GVariant *retval = g_dbus_proxy_call_sync(m_extension,
1023
                                                  "GetSelectedText",
1024
                                                  g_variant_new("(t)", page_id),
1025
                                                  G_DBUS_CALL_FLAGS_NONE, -1,
1026
                                                  NULL, NULL);
1027
        if (retval)
1028
	{
1029
            char *text;
1030
            g_variant_get(retval, "(s)", &text);
1031
            g_variant_unref(retval);
1032
            return wxString(text, wxConvUTF8);
1033
        }
1034
    }
1035
    return wxString();
1036
}
1037
1038
wxString wxWebViewWebKit::GetSelectedSource() const
1039
{
1040
    if (m_extension)
1041
    {
1042
        guint64 page_id = webkit_web_view_get_page_id(m_web_view);
1043
        GVariant *retval = g_dbus_proxy_call_sync(m_extension,
1044
                                                  "GetSelectedSource",
1045
                                                  g_variant_new("(t)", page_id),
1046
                                                  G_DBUS_CALL_FLAGS_NONE, -1,
1047
                                                  NULL, NULL);
1048
        if (retval)
1049
	{
1050
            char *source;
1051
            g_variant_get(retval, "(s)", &source);
1052
            g_variant_unref(retval);
1053
            return wxString(source, wxConvUTF8);
1054
        }
1055
    }
1056
    return wxString();
1057
}
1058
1059
void wxWebViewWebKit::ClearSelection()
1060
{
1061
    if (m_extension)
1062
    {
1063
        guint64 page_id = webkit_web_view_get_page_id(m_web_view);
1064
        GVariant *retval = g_dbus_proxy_call_sync(m_extension,
1065
                                                  "ClearSelection",
1066
                                                  g_variant_new("(t)", page_id),
1067
                                                  G_DBUS_CALL_FLAGS_NONE, -1,
1068
                                                  NULL, NULL);
1069
        if (retval)
1070
        {
1071
            g_variant_unref(retval);
1072
        }
1073
    }
1074
}
1075
1076
wxString wxWebViewWebKit::GetPageText() const
1077
{
1078
    if (m_extension)
1079
    {
1080
        guint64 page_id = webkit_web_view_get_page_id(m_web_view);
1081
        GVariant *retval = g_dbus_proxy_call_sync(m_extension,
1082
                                                  "GetPageText",
1083
                                                  g_variant_new("(t)", page_id),
1084
                                                  G_DBUS_CALL_FLAGS_NONE, -1,
1085
                                                  NULL, NULL);
1086
        if (retval)
1087
	{
1088
            char *text;
1089
            g_variant_get(retval, "(s)", &text);
1090
            g_variant_unref(retval);
1091
            return wxString(text, wxConvUTF8);
1092
        }
1093
    }
1094
    return wxString();
1095
}
1096
1097
void wxWebViewWebKit::RunScript(const wxString& javascript)
1098
{
1099
    webkit_web_view_run_javascript(m_web_view,
1100
                                   javascript.mb_str(wxConvUTF8),
1101
                                   NULL,
1102
                                   NULL,
1103
                                   NULL);
1104
}
1105
1106
void wxWebViewWebKit::RegisterHandler(wxSharedPtr<wxWebViewHandler> handler)
1107
{
1108
    m_handlerList.push_back(handler);
1109
}
1110
1111
void wxWebViewWebKit::EnableContextMenu(bool enable)
1112
{
1113
    wxWebView::EnableContextMenu(enable);
1114
}
1115
1116
long wxWebViewWebKit::Find(const wxString& text, int flags)
1117
{
1118
    WebKitFindController* findctrl = webkit_web_view_get_find_controller(m_web_view);
1119
    bool newSearch = false;
1120
    if(text != m_findText || 
1121
       (flags & wxWEBVIEW_FIND_MATCH_CASE) != (m_findFlags & wxWEBVIEW_FIND_MATCH_CASE))
1122
    {
1123
        newSearch = true;
1124
        //If it is a new search we need to clear existing highlights
1125
        webkit_find_controller_search_finish(findctrl);
1126
    }
1127
1128
    m_findFlags = flags;
1129
    m_findText = text;
1130
1131
    //If the search string is empty then we clear any selection and highlight
1132
    if(text.empty())
1133
    {
1134
        webkit_find_controller_search_finish(findctrl);
1135
        ClearSelection();
1136
        return wxNOT_FOUND;
1137
    }
1138
1139
    bool wrap = false, forward = true;
1140
    guint32 options = WEBKIT_FIND_OPTIONS_NONE;
1141
    if(flags & wxWEBVIEW_FIND_WRAP)
1142
    {
1143
        wrap = true;
1144
        options |= WEBKIT_FIND_OPTIONS_WRAP_AROUND;
1145
    }
1146
    if(!(flags & wxWEBVIEW_FIND_MATCH_CASE))
1147
    {
1148
        options |= WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE;
1149
    }
1150
    if(flags & wxWEBVIEW_FIND_BACKWARDS)
1151
    {
1152
        forward = false;
1153
        options |= WEBKIT_FIND_OPTIONS_BACKWARDS;
1154
    }
1155
1156
    if(newSearch)
1157
    {
1158
        //Initially we count the matches to know how many we have
1159
        m_findCount = -1;
1160
        webkit_find_controller_count_matches(findctrl,
1161
                                             wxGTK_CONV(text),
1162
                                             options,
1163
                                             G_MAXUINT);
1164
        GMainContext *main_context = g_main_context_get_thread_default();
1165
        while (m_findCount == -1)
1166
        {
1167
            g_main_context_iteration(main_context, TRUE);
1168
        }
1169
        //Highlight them if needed
1170
        if(flags & wxWEBVIEW_FIND_HIGHLIGHT_RESULT)
1171
        {
1172
            webkit_find_controller_search(findctrl,
1173
                                          wxGTK_CONV(text),
1174
                                          options,
1175
                                          G_MAXUINT);
1176
        }
1177
        //In this case we return early to match IE behaviour
1178
        m_findPosition = -1;
1179
        return m_findCount;
1180
    }
1181
    else
1182
    {
1183
        if(forward)
1184
            m_findPosition++;
1185
        else
1186
            m_findPosition--;
1187
        if(m_findPosition < 0)
1188
            m_findPosition += m_findCount;
1189
        if(m_findPosition > m_findCount)
1190
            m_findPosition -= m_findCount;
1191
    }
1192
1193
    if(forward)
1194
    {
1195
        webkit_find_controller_search_next(findctrl);
1196
        if(m_findPosition == m_findCount && !wrap)
1197
        {
1198
            return wxNOT_FOUND;
1199
        }
1200
    }
1201
    else
1202
    {
1203
        webkit_find_controller_search_previous(findctrl);
1204
        if(m_findPosition == -1 && !wrap)
1205
        {
1206
            return wxNOT_FOUND;
1207
        }
1208
    }
1209
1210
    return newSearch ? m_findCount : m_findPosition;
1211
}
1212
1213
void wxWebViewWebKit::FindClear()
1214
{
1215
    m_findCount = 0;
1216
    m_findFlags = 0;
1217
    m_findText.clear();
1218
    m_findPosition = -1;
1219
}
1220
1221
// static
1222
wxVisualAttributes
1223
wxWebViewWebKit::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
1224
{
1225
     return GetDefaultAttributesFromGTKWidget(webkit_web_view_new());
1226
}
1227
1228
void wxWebViewWebKit::SetupWebExtensionServer()
1229
{
1230
    char *address = g_strdup_printf("unix:tmpdir=%s", g_get_tmp_dir());
1231
    char *guid = g_dbus_generate_guid();
1232
    GDBusAuthObserver *observer = g_dbus_auth_observer_new();
1233
    GError *error = NULL;
1234
1235
    g_signal_connect(observer, "authorize-authenticated-peer",
1236
                     G_CALLBACK(wxgtk_authorize_authenticated_peer_cb), this);
1237
1238
    m_dbusServer = g_dbus_server_new_sync(address,
1239
                                          G_DBUS_SERVER_FLAGS_NONE,
1240
                                          guid,
1241
                                          observer,
1242
                                          NULL,
1243
                                          &error);
1244
1245
    if (error)
1246
    {
1247
        g_warning("Failed to start web extension server on %s: %s", address, error->message);
1248
        g_error_free(error);
1249
    }
1250
    else
1251
    {
1252
        g_signal_connect(m_dbusServer, "new-connection",
1253
                         G_CALLBACK(wxgtk_new_connection_cb), &m_extension);
1254
        g_dbus_server_start(m_dbusServer);
1255
    }
1256
1257
    g_free(address);
1258
    g_free(guid);
1259
    g_object_unref(observer);
1260
}
1261
1262
#endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT2
(-)a/src/gtk/webview_webkit2_extension.cpp (+421 lines)
Line 0 Link Here
1
/////////////////////////////////////////////////////////////////////////////
2
// Name:        src/gtk/webview_webkit2_extension.cpp
3
// Purpose:     GTK WebKit2 extension for web view component
4
// Author:      Scott Talbert
5
// Copyright:   (c) 2017 Scott Talbert
6
// Licence:     wxWindows licence
7
/////////////////////////////////////////////////////////////////////////////
8
9
#include "wx/defs.h"
10
#include "wx/gtk/private/webview_webkit2_extension.h"
11
#include <webkit2/webkit-web-extension.h>
12
#define WEBKIT_DOM_USE_UNSTABLE_API
13
#include <webkitdom/WebKitDOMDOMSelection.h>
14
#include <webkitdom/WebKitDOMDOMWindowUnstable.h>
15
16
static const char introspection_xml[] =
17
  "<node>"
18
  " <interface name='org.wxwidgets.wxGTK.WebExtension'>"
19
  "  <method name='ClearSelection'>"
20
  "   <arg type='t' name='page_id' direction='in'/>"
21
  "  </method>"
22
  "  <method name='DeleteSelection'>"
23
  "   <arg type='t' name='page_id' direction='in'/>"
24
  "  </method>"
25
  "  <method name='GetPageSource'>"
26
  "   <arg type='t' name='page_id' direction='in'/>"
27
  "   <arg type='s' name='source' direction='out'/>"
28
  "  </method>"
29
  "  <method name='GetPageText'>"
30
  "   <arg type='t' name='page_id' direction='in'/>"
31
  "   <arg type='s' name='text' direction='out'/>"
32
  "  </method>"
33
  "  <method name='GetSelectedSource'>"
34
  "   <arg type='t' name='page_id' direction='in'/>"
35
  "   <arg type='s' name='source' direction='out'/>"
36
  "  </method>"
37
  "  <method name='GetSelectedText'>"
38
  "   <arg type='t' name='page_id' direction='in'/>"
39
  "   <arg type='s' name='text' direction='out'/>"
40
  "  </method>"
41
  "  <method name='HasSelection'>"
42
  "   <arg type='t' name='page_id' direction='in'/>"
43
  "   <arg type='b' name='has_selection' direction='out'/>"
44
  "  </method>"
45
  " </interface>"
46
  "</node>";
47
48
class wxWebViewWebKitExtension;
49
50
static gboolean
51
wxgtk_webview_authorize_authenticated_peer_cb(GDBusAuthObserver *observer,
52
                                              GIOStream *stream,
53
                                              GCredentials *credentials,
54
                                              wxWebViewWebKitExtension *extension);
55
static void
56
wxgtk_webview_dbus_connection_created_cb(GObject *source_object,
57
                                         GAsyncResult *result,
58
                                         wxWebViewWebKitExtension *extension);
59
60
static wxWebViewWebKitExtension *gs_extension = NULL;
61
62
class wxWebViewWebKitExtension
63
{
64
public:
65
    wxWebViewWebKitExtension(WebKitWebExtension *webkit_extension, const char* server_address);
66
    void ClearSelection(GVariant *parameters, GDBusMethodInvocation *invocation);
67
    void DeleteSelection(GVariant *parameters, GDBusMethodInvocation *invocation);
68
    void GetPageSource(GVariant *parameters, GDBusMethodInvocation *invocation);
69
    void GetPageText(GVariant *parameters, GDBusMethodInvocation *invocation);
70
    void GetSelectedSource(GVariant *parameters, GDBusMethodInvocation *invocation);
71
    void GetSelectedText(GVariant *parameters, GDBusMethodInvocation *invocation);
72
    void HasSelection(GVariant *parameters, GDBusMethodInvocation *invocation);
73
    void SetDBusConnection(GDBusConnection *dbusConnection);
74
75
private:
76
    WebKitWebPage* GetWebPageOrReturnError(GVariant *parameters, GDBusMethodInvocation *invocation);
77
    void ReturnDBusStringValue(GDBusMethodInvocation *invocation, gchar *value);
78
79
    GDBusConnection *m_dbusConnection;
80
    WebKitWebExtension *m_webkitExtension;
81
};
82
83
wxWebViewWebKitExtension::wxWebViewWebKitExtension(WebKitWebExtension *extension, const char* server_address)
84
{
85
    m_webkitExtension = (WebKitWebExtension*)g_object_ref(extension);
86
87
    GDBusAuthObserver *observer = g_dbus_auth_observer_new();
88
    g_signal_connect(observer, "authorize-authenticated-peer",
89
                     G_CALLBACK(wxgtk_webview_authorize_authenticated_peer_cb),
90
                     this);
91
92
    g_dbus_connection_new_for_address(server_address,
93
                                      G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
94
                                      observer,
95
                                      NULL,
96
                                      (GAsyncReadyCallback)wxgtk_webview_dbus_connection_created_cb,
97
                                      this);
98
    g_object_unref(observer);
99
}
100
101
WebKitWebPage* wxWebViewWebKitExtension::GetWebPageOrReturnError(GVariant *parameters, GDBusMethodInvocation *invocation)
102
{
103
    guint64 page_id;
104
    g_variant_get(parameters, "(t)", &page_id);
105
    WebKitWebPage *web_page = webkit_web_extension_get_page(m_webkitExtension,
106
                                                            page_id);
107
    if (!web_page)
108
    {
109
        g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR,
110
                                              G_DBUS_ERROR_INVALID_ARGS,
111
                                              "Invalid page ID: %" G_GUINT64_FORMAT, page_id);
112
    }
113
    return web_page;
114
}
115
116
void wxWebViewWebKitExtension::GetSelectedSource(GVariant *parameters,
117
                                                 GDBusMethodInvocation *invocation)
118
{
119
    WebKitWebPage *web_page = GetWebPageOrReturnError(parameters, invocation);
120
    if (!web_page)
121
    {
122
        return;
123
    }
124
125
    WebKitDOMDocument *doc = webkit_web_page_get_dom_document(web_page);
126
    WebKitDOMDOMWindow *win = webkit_dom_document_get_default_view(doc);
127
    WebKitDOMDOMSelection *sel = webkit_dom_dom_window_get_selection(win);
128
    g_object_unref(win);
129
    if (!sel)
130
    {
131
        ReturnDBusStringValue(invocation, NULL);
132
        return;
133
    }
134
    WebKitDOMRange *range = webkit_dom_dom_selection_get_range_at(sel, 0, NULL);
135
    if (!range)
136
    {
137
        ReturnDBusStringValue(invocation, NULL);
138
        return;
139
    }
140
    WebKitDOMElement *div = webkit_dom_document_create_element(doc, "div",
141
                                                               NULL);
142
    WebKitDOMDocumentFragment *clone = webkit_dom_range_clone_contents(range,
143
                                                                       NULL);
144
    webkit_dom_node_append_child(&div->parent_instance,
145
                                 &clone->parent_instance, NULL);
146
    WebKitDOMElement *html = (WebKitDOMElement*)div;
147
    gchar *text = webkit_dom_element_get_inner_html(html);
148
    g_object_unref(range);
149
150
    ReturnDBusStringValue(invocation, text);
151
}
152
153
void wxWebViewWebKitExtension::GetPageSource(GVariant *parameters,
154
                                             GDBusMethodInvocation *invocation)
155
{
156
    WebKitWebPage *web_page = GetWebPageOrReturnError(parameters, invocation);
157
    if (!web_page)
158
    {
159
        return;
160
    }
161
162
    WebKitDOMDocument *doc = webkit_web_page_get_dom_document(web_page);
163
    WebKitDOMElement *body = webkit_dom_document_get_document_element(doc);
164
    gchar *source = webkit_dom_element_get_outer_html(body);
165
    g_dbus_method_invocation_return_value(invocation,
166
                                          g_variant_new("(s)", source ? source : ""));
167
}
168
169
void wxWebViewWebKitExtension::GetPageText(GVariant *parameters,
170
                                           GDBusMethodInvocation *invocation)
171
{
172
    WebKitWebPage *web_page = GetWebPageOrReturnError(parameters, invocation);
173
    if (!web_page)
174
    {
175
        return;
176
    }
177
178
    WebKitDOMDocument *doc = webkit_web_page_get_dom_document(web_page);
179
    WebKitDOMHTMLElement *body = webkit_dom_document_get_body(doc);
180
    gchar *text = webkit_dom_html_element_get_inner_text(body);
181
    g_dbus_method_invocation_return_value(invocation,
182
                                          g_variant_new("(s)", text));
183
}
184
185
void wxWebViewWebKitExtension::GetSelectedText(GVariant *parameters,
186
                                               GDBusMethodInvocation *invocation)
187
{
188
    WebKitWebPage *web_page = GetWebPageOrReturnError(parameters, invocation);
189
    if (!web_page)
190
    {
191
        return;
192
    }
193
194
    WebKitDOMDocument *doc = webkit_web_page_get_dom_document(web_page);
195
    WebKitDOMDOMWindow *win = webkit_dom_document_get_default_view(doc);
196
    WebKitDOMDOMSelection *sel = webkit_dom_dom_window_get_selection(win);
197
    g_object_unref(win);
198
    if (!sel)
199
    {
200
        ReturnDBusStringValue(invocation, NULL);
201
        return;
202
    }
203
    WebKitDOMRange *range = webkit_dom_dom_selection_get_range_at(sel, 0, NULL);
204
    if (!range)
205
    {
206
        ReturnDBusStringValue(invocation, NULL);
207
        return;
208
    }
209
    gchar *text = webkit_dom_range_get_text(range);
210
    g_object_unref(range);
211
212
    ReturnDBusStringValue(invocation, text);
213
}
214
215
void wxWebViewWebKitExtension::ClearSelection(GVariant *parameters,
216
                                              GDBusMethodInvocation *invocation)
217
{
218
    WebKitWebPage *web_page = GetWebPageOrReturnError(parameters, invocation);
219
    if (!web_page)
220
    {
221
        return;
222
    }
223
224
    WebKitDOMDocument *doc = webkit_web_page_get_dom_document(web_page);
225
    WebKitDOMDOMWindow *win = webkit_dom_document_get_default_view(doc);
226
    WebKitDOMDOMSelection *sel = webkit_dom_dom_window_get_selection(win);
227
    g_object_unref(win);
228
    if (sel)
229
    {
230
        webkit_dom_dom_selection_remove_all_ranges(sel);
231
    }
232
233
    g_dbus_method_invocation_return_value(invocation, NULL);
234
}
235
236
void wxWebViewWebKitExtension::HasSelection(GVariant *parameters,
237
                                            GDBusMethodInvocation *invocation)
238
{
239
    WebKitWebPage *web_page = GetWebPageOrReturnError(parameters, invocation);
240
    if (!web_page)
241
    {
242
        return;
243
    }
244
245
    WebKitDOMDocument *doc = webkit_web_page_get_dom_document(web_page);
246
    WebKitDOMDOMWindow *win = webkit_dom_document_get_default_view(doc);
247
    WebKitDOMDOMSelection *sel = webkit_dom_dom_window_get_selection(win);
248
    g_object_unref(win);
249
    gboolean has_selection = FALSE;
250
    if (WEBKIT_DOM_IS_DOM_SELECTION(sel))
251
    {
252
        if (!webkit_dom_dom_selection_get_is_collapsed(sel))
253
        {
254
            has_selection = TRUE;
255
        }
256
    }
257
    g_dbus_method_invocation_return_value(invocation,
258
                                          g_variant_new("(b)", has_selection));
259
}
260
261
void wxWebViewWebKitExtension::DeleteSelection(GVariant *parameters,
262
                                               GDBusMethodInvocation *invocation)
263
{
264
    WebKitWebPage *web_page = GetWebPageOrReturnError(parameters, invocation);
265
    if (!web_page)
266
    {
267
        return;
268
    }
269
270
    WebKitDOMDocument *doc = webkit_web_page_get_dom_document(web_page);
271
    WebKitDOMDOMWindow *win = webkit_dom_document_get_default_view(doc);
272
    WebKitDOMDOMSelection *sel = webkit_dom_dom_window_get_selection(win);
273
    g_object_unref(win);
274
    if (sel)
275
    {
276
        webkit_dom_dom_selection_delete_from_document(sel);
277
    }
278
279
    g_dbus_method_invocation_return_value(invocation, NULL);
280
}
281
282
void wxWebViewWebKitExtension::ReturnDBusStringValue(GDBusMethodInvocation *invocation, gchar *value)
283
{
284
    g_dbus_method_invocation_return_value(invocation,
285
                                          g_variant_new("(s)", value ? value : ""));
286
}
287
288
void wxWebViewWebKitExtension::SetDBusConnection(GDBusConnection *dbusConnection)
289
{
290
    m_dbusConnection = dbusConnection;
291
}
292
293
static void
294
wxgtk_webview_handle_method_call(GDBusConnection *connection,
295
                                 const char *sender,
296
                                 const char *object_path,
297
                                 const char *interface_name,
298
                                 const char *method_name,
299
                                 GVariant *parameters,
300
                                 GDBusMethodInvocation *invocation,
301
                                 gpointer user_data)
302
{
303
    if (g_strcmp0(interface_name, WXGTK_WEB_EXTENSION_INTERFACE) != 0)
304
    {
305
        return;
306
    }
307
308
    wxWebViewWebKitExtension *extension = (wxWebViewWebKitExtension*)user_data;
309
310
    if (g_strcmp0(method_name, "ClearSelection") == 0)
311
    {
312
        extension->ClearSelection(parameters, invocation);
313
    }
314
    else if (g_strcmp0(method_name, "DeleteSelection") == 0)
315
    {
316
        extension->DeleteSelection(parameters, invocation);
317
    }
318
    else if (g_strcmp0(method_name, "GetPageSource") == 0)
319
    {
320
        extension->GetPageSource(parameters, invocation);
321
    }
322
    else if (g_strcmp0(method_name, "GetPageText") == 0)
323
    {
324
        extension->GetPageText(parameters, invocation);
325
    }
326
    else if (g_strcmp0(method_name, "GetSelectedSource") == 0)
327
    {
328
        extension->GetSelectedSource(parameters, invocation);
329
    }
330
    else if (g_strcmp0(method_name, "GetSelectedText") == 0)
331
    {
332
        extension->GetSelectedText(parameters, invocation);
333
    }
334
    else if (g_strcmp0(method_name, "HasSelection") == 0)
335
    {
336
        extension->HasSelection(parameters, invocation);
337
    }
338
}
339
340
static const GDBusInterfaceVTable interface_vtable = {
341
    wxgtk_webview_handle_method_call,
342
    NULL,
343
    NULL
344
};
345
346
gboolean
347
wxgtk_webview_dbus_peer_is_authorized(GCredentials *peer_credentials)
348
{
349
    static GCredentials *own_credentials = g_credentials_new();
350
    GError *error = NULL;
351
352
    if (peer_credentials && g_credentials_is_same_user(peer_credentials, own_credentials, &error))
353
    {
354
        return TRUE;
355
    }
356
357
    if (error)
358
    {
359
        g_warning("Failed to authorize web extension connection: %s", error->message);
360
        g_error_free(error);
361
    }
362
    return FALSE;
363
}
364
365
static gboolean
366
wxgtk_webview_authorize_authenticated_peer_cb(GDBusAuthObserver *observer,
367
                                              GIOStream *stream,
368
                                              GCredentials *credentials,
369
                                              wxWebViewWebKitExtension *extension)
370
{
371
    return wxgtk_webview_dbus_peer_is_authorized(credentials);
372
}
373
374
static void
375
wxgtk_webview_dbus_connection_created_cb(GObject *source_object,
376
                                         GAsyncResult *result,
377
                                         wxWebViewWebKitExtension *extension)
378
{
379
    static GDBusNodeInfo *introspection_data =
380
        g_dbus_node_info_new_for_xml(introspection_xml, NULL);
381
382
    GError *error = NULL;
383
    GDBusConnection *connection =
384
        g_dbus_connection_new_for_address_finish(result, &error);
385
    if (error)
386
    {
387
        g_warning("Failed to connect to UI process: %s", error->message);
388
        g_error_free(error);
389
        return;
390
    }
391
392
    guint registration_id =
393
        g_dbus_connection_register_object(connection,
394
                                          WXGTK_WEB_EXTENSION_OBJECT_PATH,
395
                                          introspection_data->interfaces[0],
396
                                          &interface_vtable,
397
                                          extension,
398
                                          NULL,
399
                                          &error);
400
    if (!registration_id)
401
    {
402
        g_warning ("Failed to register web extension object: %s\n", error->message);
403
        g_error_free (error);
404
        g_object_unref (connection);
405
        return;
406
    }
407
408
    extension->SetDBusConnection(connection);
409
}
410
411
extern "C" WXEXPORT void
412
webkit_web_extension_initialize_with_user_data (WebKitWebExtension *webkit_extension,
413
                                                GVariant           *user_data)
414
{
415
    const char *server_address;
416
417
    g_variant_get (user_data, "(&s)", &server_address);
418
419
    gs_extension = new wxWebViewWebKitExtension(webkit_extension,
420
                                                server_address);
421
}

Return to bug 629122