summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-04-17 00:54:27 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-04-17 00:54:27 +0000
commitdaf7a52dd67e7ac2149dba337cc156c9ba308987 (patch)
tree7514c0aaccc3c1ec2fc4b8b348e3249a043a6ff4
parent5ae689a29633afc64474c414541c56a98a3876cf (diff)
downloadnetsurf-daf7a52dd67e7ac2149dba337cc156c9ba308987.tar.gz
netsurf-daf7a52dd67e7ac2149dba337cc156c9ba308987.tar.bz2
Hubbub is no longer optional.
Remove libxml2 parser binding. svn path=/trunk/netsurf/; revision=7115
-rw-r--r--Makefile175
-rw-r--r--Makefile.defaults16
-rw-r--r--Makefile.sources2
-rwxr-xr-xamiga/gui.c10
-rw-r--r--beos/beos_gui.cpp10
-rw-r--r--framebuffer/fb_gui.c8
-rw-r--r--gtk/gtk_gui.c8
-rw-r--r--render/box_construct.c264
-rw-r--r--render/directory.c4
-rw-r--r--render/html.c4
-rw-r--r--render/hubbub_binding.c4
-rw-r--r--render/libxml_binding.c312
-rw-r--r--render/parser_binding.h2
-rw-r--r--riscos/gui.c8
-rw-r--r--utils/utf8.c190
15 files changed, 84 insertions, 933 deletions
diff --git a/Makefile b/Makefile
index 578aece44..85d33fcf1 100644
--- a/Makefile
+++ b/Makefile
@@ -248,15 +248,15 @@ CFLAGS += -DNETSURF_UA_FORMAT_STRING=\"$(NETSURF_UA_FORMAT_STRING)\"
CFLAGS += -DNETSURF_HOMEPAGE=\"$(NETSURF_HOMEPAGE)\"
# ----------------------------------------------------------------------------
-# RISC OS host flag setup
+# RISC OS target setup
# ----------------------------------------------------------------------------
ifeq ($(TARGET),riscos)
ifeq ($(HOST),riscos)
LDFLAGS += -Xlinker -symbols=$(OBJROOT)/sym -lxml2 -lz -lm -lcurl -lcares
- LDFLAGS += -lssl -lcrypto
+ LDFLAGS += -lssl -lcrypto -lhubbub0 -lparserutils0
else
- LDFLAGS += $(shell $(PKG_CONFIG) --libs libxml-2.0 libcurl)
+ LDFLAGS += $(shell $(PKG_CONFIG) --libs libxml-2.0 libcurl libhubbub-0)
endif
$(eval $(call feature_enabled,NSSVG,-DWITH_NS_SVG,-lsvgtiny,SVG rendering))
@@ -265,102 +265,32 @@ ifeq ($(TARGET),riscos)
$(eval $(call feature_enabled,ARTWORKS,-DWITH_ARTWORKS,,ArtWorks rendering))
$(eval $(call feature_enabled,PLUGINS,-DWITH_PLUGIN,,Plugin protocol support))
ifeq ($(HOST),riscos)
- $(eval $(call feature_enabled,HUBBUB,-DWITH_HUBBUB,-lhubbub0 -lparserutils0,Hubbub HTML parser))
$(eval $(call feature_enabled,BMP,-DWITH_BMP,-lnsbmp0,NetSurf BMP decoder))
$(eval $(call feature_enabled,GIF,-DWITH_GIF,-lnsgif0,NetSurf GIF decoder))
$(eval $(call feature_enabled,PNG,-DWITH_PNG,-lpng,PNG support))
else
- NETSURF_FEATURE_HUBBUB_CFLAGS := -DWITH_HUBBUB
NETSURF_FEATURE_BMP_CFLAGS := -DWITH_BMP
NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF
NETSURF_FEATURE_PNG_CFLAGS := -DWITH_PNG
- $(eval $(call pkg_config_find_and_add,HUBBUB,libhubbub-0,Hubbub HTML parser))
$(eval $(call pkg_config_find_and_add,BMP,libnsbmp-0,NetSurf BMP decoder))
$(eval $(call pkg_config_find_and_add,GIF,libnsgif-0,NetSurf GIF decoder))
$(eval $(call pkg_config_find_and_add,PNG,libpng,PNG support))
endif
-endif
-
-# ----------------------------------------------------------------------------
-# BeOS flag setup
-# ----------------------------------------------------------------------------
-
-ifeq ($(HOST),beos)
- $(eval $(call feature_enabled,PNG,-DWITH_PNG,-lpng,PNG support))
-
- LDFLAGS += -L/boot/home/config/lib
- # for Haiku
- LDFLAGS += -L/boot/common/lib
- # some people do *not* have libm...
- LDFLAGS += -lxml2 -lz -lcurl -liconv
- LDFLAGS += -lssl -lcrypto
-endif
-
-# ----------------------------------------------------------------------------
-# GTK flag setup (using pkg-config)
-# ----------------------------------------------------------------------------
-
-ifeq ($(TARGET),gtk)
- LDFLAGS += $(shell $(PKG_CONFIG) --libs libxml-2.0 libcurl)
-
- # define additional CFLAGS and LDFLAGS requirements for pkg-configed libs here
- NETSURF_FEATURE_RSVG_CFLAGS := -DWITH_RSVG
- NETSURF_FEATURE_ROSPRITE_CFLAGS := -DWITH_NSSPRITE
- NETSURF_FEATURE_HUBBUB_CFLAGS := -DWITH_HUBBUB
- NETSURF_FEATURE_BMP_CFLAGS := -DWITH_BMP
- NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF
- NETSURF_FEATURE_PNG_CFLAGS := -DWITH_PNG
-
- # add a line similar to below for each optional pkg-configed lib here
- $(eval $(call pkg_config_find_and_add,RSVG,librsvg-2.0,SVG rendering))
- $(eval $(call pkg_config_find_and_add,ROSPRITE,librosprite,RISC OS sprite rendering))
- $(eval $(call pkg_config_find_and_add,HUBBUB,libhubbub-0,Hubbub HTML parser))
- $(eval $(call pkg_config_find_and_add,BMP,libnsbmp-0,NetSurf BMP decoder))
- $(eval $(call pkg_config_find_and_add,GIF,libnsgif-0,NetSurf GIF decoder))
- $(eval $(call pkg_config_find_and_add,PNG,libpng,PNG support))
- GTKCFLAGS := -std=c99 -Dgtk -Dnsgtk \
- -DGTK_DISABLE_DEPRECATED \
- -D_BSD_SOURCE \
- -D_XOPEN_SOURCE=600 \
- -D_POSIX_C_SOURCE=200112L \
- -D_NETBSD_SOURCE \
- -DGTK_RESPATH=\"$(NETSURF_GTK_RESOURCES)\" \
- $(WARNFLAGS) -I. -g \
- $(shell $(PKG_CONFIG) --cflags libglade-2.0 gtk+-2.0) \
- $(shell xml2-config --cflags)
-
- GTKLDFLAGS := $(shell $(PKG_CONFIG) --cflags --libs libglade-2.0 gtk+-2.0 gthread-2.0 gmodule-2.0 lcms)
-
- CFLAGS += $(GTKCFLAGS)
- LDFLAGS += $(GTKLDFLAGS)
-
- # ----------------------------------------------------------------------------
- # Windows flag setup
- # ----------------------------------------------------------------------------
-
- ifeq ($(HOST),Windows_NT)
- CFLAGS += -U__STRICT_ANSI__
- endif
-endif
-
-# ----------------------------------------------------------------------------
-# RISC OS target flag setup
-# ----------------------------------------------------------------------------
-
-ifeq ($(TARGET),riscos)
TPD_RISCOS = $(foreach TPL,$(notdir $(TPL_RISCOS)), \
!NetSurf/Resources/$(TPL)/Templates$(TPLEXT))
RESOURCES = $(TPD_RISCOS)
- CFLAGS += -I. $(WARNFLAGS) -Driscos \
+ CFLAGS += -I. $(WARNFLAGS) -Driscos \
-std=c99 -D_BSD_SOURCE -D_POSIX_C_SOURCE \
-mpoke-function-name
CFLAGS += -I$(GCCSDK_INSTALL_ENV)/include \
-I$(GCCSDK_INSTALL_ENV)/include/libxml2 \
- -I$(GCCSDK_INSTALL_ENV)/include/libmng
+ -I$(GCCSDK_INSTALL_ENV)/include/libmng \
+ -I$(GCCSDK_INSTALL_ENV)/include/hubbub0 \
+ -I$(GCCSDK_INSTALL_ENV)/include/parserutils0
ifeq ($(HOST),riscos)
CFLAGS += -I<OSLib$$Dir> -mthrowback
endif
@@ -380,10 +310,19 @@ ifeq ($(TARGET),riscos)
endif
# ----------------------------------------------------------------------------
-# BeOS target flag setup
+# BeOS target setup
# ----------------------------------------------------------------------------
ifeq ($(TARGET),beos)
+ $(eval $(call feature_enabled,PNG,-DWITH_PNG,-lpng,PNG support))
+
+ LDFLAGS += -L/boot/home/config/lib
+ # for Haiku
+ LDFLAGS += -L/boot/common/lib
+ # some people do *not* have libm...
+ LDFLAGS += -lxml2 -lcurl -liconv
+ LDFLAGS += -lssl -lcrypto -lhubbub0 -lparserutils0
+
CFLAGS += -I. -O $(WARNFLAGS) -Dnsbeos \
-D_BSD_SOURCE -D_POSIX_C_SOURCE \
-Drestrict="" -Wno-multichar
@@ -404,7 +343,9 @@ ifeq ($(TARGET),beos)
ifeq ($(HOST),beos)
CFLAGS += -I/boot/home/config/include \
-I/boot/home/config/include/libxml2 \
- -I/boot/home/config/include/libmng
+ -I/boot/home/config/include/libmng \
+ -I/boot/home/config/include/hubbub0 \
+ -I/boot/home/config/include/parserutils0
ifneq ($(wildcard /boot/develop/lib/*/libzeta.so),)
LDFLAGS += -lzeta
endif
@@ -412,7 +353,9 @@ ifeq ($(TARGET),beos)
# Haiku
CFLAGS += -I/boot/common/include \
-I/boot/common/include/libxml2 \
- -I/boot/common/include/libmng
+ -I/boot/common/include/libmng \
+ -I/boot/common/include/hubbub0 \
+ -I/boot/common/include/parserutils0
NETLDFLAGS := -lnetwork
else
ifneq ($(wildcard /boot/develop/lib/*/libbind.so),)
@@ -431,19 +374,64 @@ ifeq ($(TARGET),beos)
endif
# ----------------------------------------------------------------------------
+# GTK flag setup (using pkg-config)
+# ----------------------------------------------------------------------------
+
+ifeq ($(TARGET),gtk)
+ LDFLAGS += $(shell $(PKG_CONFIG) --libs libxml-2.0 libcurl libhubbub-0)
+
+ # define additional CFLAGS and LDFLAGS requirements for pkg-configed libs here
+ NETSURF_FEATURE_RSVG_CFLAGS := -DWITH_RSVG
+ NETSURF_FEATURE_ROSPRITE_CFLAGS := -DWITH_NSSPRITE
+ NETSURF_FEATURE_BMP_CFLAGS := -DWITH_BMP
+ NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF
+ NETSURF_FEATURE_PNG_CFLAGS := -DWITH_PNG
+
+ # add a line similar to below for each optional pkg-configed lib here
+ $(eval $(call pkg_config_find_and_add,RSVG,librsvg-2.0,SVG rendering))
+ $(eval $(call pkg_config_find_and_add,ROSPRITE,librosprite,RISC OS sprite rendering))
+ $(eval $(call pkg_config_find_and_add,BMP,libnsbmp-0,NetSurf BMP decoder))
+ $(eval $(call pkg_config_find_and_add,GIF,libnsgif-0,NetSurf GIF decoder))
+ $(eval $(call pkg_config_find_and_add,PNG,libpng,PNG support))
+
+ GTKCFLAGS := -std=c99 -Dgtk -Dnsgtk \
+ -DGTK_DISABLE_DEPRECATED \
+ -D_BSD_SOURCE \
+ -D_XOPEN_SOURCE=600 \
+ -D_POSIX_C_SOURCE=200112L \
+ -D_NETBSD_SOURCE \
+ -DGTK_RESPATH=\"$(NETSURF_GTK_RESOURCES)\" \
+ $(WARNFLAGS) -I. -g \
+ $(shell $(PKG_CONFIG) --cflags libglade-2.0 gtk+-2.0) \
+ $(shell $(PKG_CONFIG) --cflags libhubbub-0) \
+ $(shell xml2-config --cflags)
+
+ GTKLDFLAGS := $(shell $(PKG_CONFIG) --cflags --libs libglade-2.0 gtk+-2.0 gthread-2.0 gmodule-2.0 lcms)
+
+ CFLAGS += $(GTKCFLAGS)
+ LDFLAGS += $(GTKLDFLAGS)
+
+ # ----------------------------------------------------------------------------
+ # Windows flag setup
+ # ----------------------------------------------------------------------------
+
+ ifeq ($(HOST),Windows_NT)
+ CFLAGS += -U__STRICT_ANSI__
+ endif
+endif
+
+# ----------------------------------------------------------------------------
# Amiga target setup
# ----------------------------------------------------------------------------
ifeq ($(TARGET),amiga)
NETSURF_FEATURE_ROSPRITE_CFLAGS := -DWITH_NSSPRITE
- NETSURF_FEATURE_HUBBUB_CFLAGS := -DWITH_HUBBUB
NETSURF_FEATURE_BMP_CFLAGS := -DWITH_BMP
NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF
NETSURF_FEATURE_PNG_CFLAGS := -DWITH_PNG
NETSURF_FEATURE_NSSVG_CFLAGS := -DWITH_NS_SVG
$(eval $(call feature_enabled,ROSPRITE,-DWITH_NSSPRITE,-lrosprite,RISC OS Sprite decoder))
- $(eval $(call feature_enabled,HUBBUB,-DWITH_HUBBUB,-lhubbub0,Hubbub HTML parser))
$(eval $(call feature_enabled,BMP,-DWITH_BMP,-lnsbmp0,NetSurf BMP decoder))
$(eval $(call feature_enabled,GIF,-DWITH_GIF,-lnsgif0,NetSurf GIF decoder))
$(eval $(call feature_enabled,PNG,-DWITH_PNG,-lpng,PNG support))
@@ -451,8 +439,8 @@ ifeq ($(TARGET),amiga)
$(eval $(call feature_enabled,MNG,,-llcms -ljpeg,libmng extras))
CFLAGS += -D__USE_INLINE__ -std=c99 -I . -Dnsamiga
- LDFLAGS += -lxml2 -lcurl -lpthread -lregex -lauto -lparserutils0
- LDFLAGS += -lssl -lcrypto
+ LDFLAGS += -lxml2 -lcurl -lpthread -lregex -lauto
+ LDFLAGS += -lssl -lcrypto -lhubbub0 -lparserutils0
ifeq ($(NETSURF_AMIGA_USE_CAIRO),YES)
CFLAGS += -DNS_AMIGA_CAIRO -I SDK:local/common/include/cairo
@@ -476,7 +464,6 @@ ifeq ($(TARGET),framebuffer)
# define additional CFLAGS and LDFLAGS requirements for pkg-configed libs here
NETSURF_FEATURE_RSVG_CFLAGS := -DWITH_RSVG
NETSURF_FEATURE_ROSPRITE_CFLAGS := -DWITH_NSSPRITE
- NETSURF_FEATURE_HUBBUB_CFLAGS := -DWITH_HUBBUB
NETSURF_FEATURE_BMP_CFLAGS := -DWITH_BMP
NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF
@@ -486,40 +473,39 @@ ifeq ($(TARGET),framebuffer)
ifeq ($(NETSURF_FB_FRONTEND),linux)
$(eval $(call pkg_config_find_and_add,RSVG,librsvg-2.0,SVG rendering))
$(eval $(call pkg_config_find_and_add,ROSPRITE,librosprite,RISC OS sprite rendering))
- $(eval $(call pkg_config_find_and_add,HUBBUB,libhubbub-0,Hubbub HTML parser))
$(eval $(call pkg_config_find_and_add,BMP,libnsbmp-0,NetSurf BMP decoder))
$(eval $(call pkg_config_find_and_add,GIF,libnsgif-0,NetSurf GIF decoder))
CFLAGS += -std=c99 -g -I. -Dsmall $(WARNFLAGS) \
+ $(shell $(PKG_CONFIG) --cflags libhubbub-0) \
$(shell xml2-config --cflags) \
-D_BSD_SOURCE \
-D_XOPEN_SOURCE=600 \
-D_POSIX_C_SOURCE=200112L
LDFLAGS += -lxml2 -lz -ljpeg -lcurl -lm
- LDFLAGS += $(shell $(PKG_CONFIG) --libs libxml-2.0 libcurl)
+ LDFLAGS += $(shell $(PKG_CONFIG) --libs libxml-2.0 libcurl libhubbub-0)
SUBTARGET := -linux
endif
ifeq ($(NETSURF_FB_FRONTEND),able)
- $(eval $(call feature_enabled,GIF,-DWITH_GIF,-lnsgif-0,NetSurf GIF decoder))
- $(eval $(call feature_enabled,HUBBUB,-DWITH_HUBBUB,-lhubbub-0,Hubbub))
+ $(eval $(call feature_enabled,GIF,-DWITH_GIF,-lnsgif0,NetSurf GIF decoder))
CC=arm-able-gcc
CFLAGS += -std=c99 -I. -I/usr/lib/able/include -Dsmall $(WARNFLAGS)
- LDFLAGS += -lxml2 -lz -ljpeg -lcurl -lm
+ LDFLAGS += -lxml2 -lz -ljpeg -lcurl -lm -lhubbub0 -lparserutils0
SUBTARGET := -able
endif
ifeq ($(NETSURF_FB_FRONTEND),dummy)
$(eval $(call pkg_config_find_and_add,RSVG,librsvg-2.0,SVG rendering))
$(eval $(call pkg_config_find_and_add,ROSPRITE,librosprite,RISC OS sprite rendering))
- $(eval $(call pkg_config_find_and_add,HUBBUB,libhubbub-0,Hubbub HTML parser))
$(eval $(call pkg_config_find_and_add,BMP,libnsbmp-0,NetSurf BMP decoder))
$(eval $(call pkg_config_find_and_add,GIF,libnsgif-0,NetSurf GIF decoder))
CFLAGS += -std=c99 -g -I. $(WARNFLAGS) \
+ $(shell $(PKG_CONFIG) --cflags libhubbub-0) \
$(shell xml2-config --cflags) \
-D_BSD_SOURCE \
-D_XOPEN_SOURCE=600 \
@@ -527,19 +513,20 @@ ifeq ($(TARGET),framebuffer)
LDFLAGS += -lxml2 -lz -ljpeg -lcurl -lm
LDFLAGS += $(shell $(PKG_CONFIG) --libs libxml-2.0 libcurl openssl)
+ LDFLAGS += $(shell $(PKG_CONFIG) --libs libhubbub-0)
SUBTARGET := -dummy
endif
ifeq ($(NETSURF_FB_FRONTEND),sdl)
$(eval $(call pkg_config_find_and_add,RSVG,librsvg-2.0,SVG rendering))
$(eval $(call pkg_config_find_and_add,ROSPRITE,librosprite,RISC OS sprite rendering))
- $(eval $(call pkg_config_find_and_add,HUBBUB,libhubbub-0,Hubbub HTML parser))
$(eval $(call pkg_config_find_and_add,BMP,libnsbmp-0,NetSurf BMP decoder))
$(eval $(call pkg_config_find_and_add,GIF,libnsgif-0,NetSurf GIF decoder))
# $(eval $(call pkg_config_find_and_add,SDL,libSDL,SDL Library))
CFLAGS += -std=c99 -g -I. $(WARNFLAGS) \
+ $(shell $(PKG_CONFIG) --cflags libhubbub-0) \
$(shell xml2-config --cflags) \
-D_BSD_SOURCE \
-D_XOPEN_SOURCE=600 \
@@ -547,19 +534,20 @@ ifeq ($(TARGET),framebuffer)
LDFLAGS += -lxml2 -lz -ljpeg -lcurl -lm -lSDL
LDFLAGS += $(shell $(PKG_CONFIG) --libs libxml-2.0 libcurl openssl)
+ LDFLAGS += $(shell $(PKG_CONFIG) --libs libhubbub-0)
SUBTARGET := -sdl
endif
ifeq ($(NETSURF_FB_FRONTEND),vnc)
$(eval $(call pkg_config_find_and_add,RSVG,librsvg-2.0,SVG rendering))
$(eval $(call pkg_config_find_and_add,ROSPRITE,librosprite,RISC OS sprite rendering))
- $(eval $(call pkg_config_find_and_add,HUBBUB,libhubbub-0,Hubbub HTML parser))
$(eval $(call pkg_config_find_and_add,BMP,libnsbmp-0,NetSurf BMP decoder))
$(eval $(call pkg_config_find_and_add,GIF,libnsgif-0,NetSurf GIF decoder))
# $(eval $(call pkg_config_find_and_add,VNCSERVER,libvncserver,VNC server))
CFLAGS += -std=c99 -g -I. $(WARNFLAGS) \
+ $(shell $(PKG_CONFIG) --cflags libhubbub-0) \
$(shell xml2-config --cflags) \
-D_BSD_SOURCE \
-D_XOPEN_SOURCE=600 \
@@ -567,6 +555,7 @@ ifeq ($(TARGET),framebuffer)
LDFLAGS += -lxml2 -lz -ljpeg -lcurl -lm -lvncserver
LDFLAGS += $(shell $(PKG_CONFIG) --libs libxml-2.0 libcurl openssl)
+ LDFLAGS += $(shell $(PKG_CONFIG) --libs libhubbub-0)
SUBTARGET := -vnc
endif
diff --git a/Makefile.defaults b/Makefile.defaults
index 29cce88f3..e3dffc5e8 100644
--- a/Makefile.defaults
+++ b/Makefile.defaults
@@ -78,10 +78,6 @@ CFLAGS :=
# ----------------------------------------------------------------------------
ifeq ($(TARGET),riscos)
- # Enable NetSurf's use of Hubbub to parse HTML, rather than libxml2
- # Valid options: YES, NO (highly recommended)
- NETSURF_USE_HUBBUB := YES
-
# Enable NetSurf's use of libsvgtiny for displaying SVGs
# Valid options: YES, NO
NETSURF_USE_NSSVG := YES
@@ -119,10 +115,6 @@ ifeq ($(TARGET),gtk)
# Where to install the netsurf binary
NETSURF_GTK_BIN := /usr/local/bin/
- # Enable NetSurf's use of Hubbub to parse HTML, rather than libxml2
- # Valid options: YES, NO, AUTO (highly recommended)
- NETSURF_USE_HUBBUB := AUTO
-
# Enable NetSurf's use of librsvg in conjunction with Cairo to display SVGs
# Valid options: YES, NO, AUTO
NETSURF_USE_RSVG := AUTO
@@ -173,10 +165,6 @@ ifeq ($(TARGET),amiga)
# Valid options: YES, NO, AUTO
NETSURF_USE_ROSPRITE := YES
- # Enable NetSurf's use of Hubbub to parse HTML rather, than libxml2
- # Valid options: YES, NO, AUTO (highly recommended)
- NETSURF_USE_HUBBUB := YES
-
# Enable NetSurf's use of libsvgtiny for displaying SVGs
# (NB: Requires NETSURF_AMIGA_USE_CAIRO)
# Valid options: YES, NO
@@ -214,10 +202,6 @@ ifeq ($(TARGET),framebuffer)
# Valid values are: linux, sdl, vnc, able
NETSURF_FB_FRONTEND := linux
- # Enable NetSurf's use of Hubbub to parse HTML rather, than libxml2
- # Valid options: YES, NO, AUTO (highly recommended)
- NETSURF_USE_HUBBUB := AUTO
-
# Use libharu to enable PDF export and GTK printing support.
# Valid options: YES, NO
NETSURF_USE_HARU_PDF := NO
diff --git a/Makefile.sources b/Makefile.sources
index b794310f3..fdf151008 100644
--- a/Makefile.sources
+++ b/Makefile.sources
@@ -10,7 +10,7 @@ S_CONTENT := content.c fetch.c fetchcache.c urldb.c \
S_CSS := css.c css_enum.c parser.c ruleset.c scanner.c
S_RENDER := box.c box_construct.c box_normalise.c directory.c \
form.c html.c html_redraw.c hubbub_binding.c imagemap.c \
- layout.c libxml_binding.c list.c loosen.c table.c textplain.c
+ layout.c list.c loosen.c table.c textplain.c
S_UTILS := base64.c filename.c hashtable.c locale.c messages.c talloc.c \
url.c utf8.c utils.c useragent.c
S_DESKTOP := knockout.c options.c print.c tree.c version.c
diff --git a/amiga/gui.c b/amiga/gui.c
index caf7fb784..64aa06162 100755
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -78,9 +78,7 @@
#ifdef NS_AMIGA_CAIRO
#include <cairo/cairo-amigaos.h>
#endif
-#ifdef WITH_HUBBUB
#include <hubbub/hubbub.h>
-#endif
#include <proto/window.h>
#include <proto/layout.h>
@@ -178,9 +176,7 @@ void ami_scroller_hook(struct Hook *,Object *,struct IntuiMessage *);
uint32 ami_popup_hook(struct Hook *hook,Object *item,APTR reserved);
void ami_init_mouse_pointers(void);
void ami_switch_tab(struct gui_window_2 *gwin,bool redraw);
-#ifdef WITH_HUBBUB
static void *myrealloc(void *ptr, size_t len, void *pw);
-#endif
void gui_init(int argc, char** argv)
{
@@ -282,12 +278,10 @@ void gui_init(int argc, char** argv)
default_stylesheet_url = "file:///PROGDIR:Resources/amiga.css";
adblock_stylesheet_url = "file:///PROGDIR:Resources/adblock.css";
-#ifdef WITH_HUBBUB
if(hubbub_initialise("PROGDIR:Resources/Aliases",myrealloc,NULL) != HUBBUB_OK)
{
die(messages_get("NoMemory"));
}
-#endif
css_screen_dpi = 72;
css_scrollbar_fg_colour = 0x00aaaaaa;
@@ -1425,9 +1419,7 @@ void gui_quit(void)
ami_cookies_free();
ami_global_history_free();
-#ifdef WITH_HUBBUB
hubbub_finalise(myrealloc,NULL);
-#endif
ami_arexx_cleanup();
@@ -2852,9 +2844,7 @@ void gui_cert_verify(struct browser_window *bw, struct content *c,
{
}
-#ifdef WITH_HUBBUB
static void *myrealloc(void *ptr, size_t len, void *pw)
{
return realloc(ptr, len);
}
-#endif
diff --git a/beos/beos_gui.cpp b/beos/beos_gui.cpp
index 83f0d88b5..866c73023 100644
--- a/beos/beos_gui.cpp
+++ b/beos/beos_gui.cpp
@@ -43,9 +43,7 @@
extern "C" {
-#ifdef WITH_HUBBUB
#include <hubbub/hubbub.h>
-#endif
#include "content/content.h"
#include "content/fetch.h"
@@ -84,9 +82,7 @@ extern "C" {
#include "beos/beos_scaffolding.h"
-#ifdef WITH_HUBBUB
static void *myrealloc(void *ptr, size_t len, void *pw);
-#endif
/* Where to search for shared resources. Must have trailing / */
@@ -578,14 +574,12 @@ void gui_init(int argc, char** argv)
#endif
LOG(("Using '%s' as AdBlock CSS URL", adblock_stylesheet_url));
-#ifdef WITH_HUBBUB
find_resource(buf, "Aliases", "./beos/res/Aliases");
LOG(("Using '%s' as aliases file", buf));
if(hubbub_initialise(buf,myrealloc,NULL) != HUBBUB_OK)
{
die(messages_get("NoMemory"));
}
-#endif
urldb_load(option_url_file);
urldb_load_cookies(option_cookie_file);
@@ -742,9 +736,7 @@ void gui_quit(void)
CALLED();
urldb_save_cookies(option_cookie_jar);
urldb_save(option_url_file);
-#ifdef WITH_HUBBUB
hubbub_finalise(myrealloc,NULL);
-#endif
//options_save_tree(hotlist,option_hotlist_file,messages_get("TreeHotlist"));
free(default_stylesheet_url);
@@ -1147,9 +1139,7 @@ bool cookies_update(const char *domain, const struct cookie_data *data)
return true;
}
-#ifdef WITH_HUBBUB
static void *myrealloc(void *ptr, size_t len, void *pw)
{
return realloc(ptr, len);
}
-#endif
diff --git a/framebuffer/fb_gui.c b/framebuffer/fb_gui.c
index 82a66ba4c..c7809dd39 100644
--- a/framebuffer/fb_gui.c
+++ b/framebuffer/fb_gui.c
@@ -24,9 +24,7 @@
#include <unistd.h>
#include <string.h>
-#ifdef WITH_HUBBUB
#include <hubbub/hubbub.h>
-#endif
#include "desktop/gui.h"
#include "desktop/plotters.h"
@@ -276,12 +274,10 @@ fb_browser_window_redraw(fbtk_widget_t *widget, void *pw)
return 0;
}
-#ifdef WITH_HUBBUB
static void *myrealloc(void *ptr, size_t len, void *pw)
{
return realloc(ptr, len);
}
-#endif
void gui_init(int argc, char** argv)
{
@@ -289,13 +285,11 @@ void gui_init(int argc, char** argv)
LOG(("argc %d, argv %p", argc, argv));
-#ifdef WITH_HUBBUB
fb_find_resource(buf, "Aliases", "./framebuffer/res/Aliases");
LOG(("Using '%s' as Aliases file", buf));
if (hubbub_initialise(buf, myrealloc, NULL) !=
HUBBUB_OK)
die("Unable to initialise HTML parsing library.\n");
-#endif
/* load browser messages */
fb_find_resource(buf, "messages", "./framebuffer/res/messages");
@@ -390,10 +384,8 @@ void gui_quit(void)
{
LOG(("gui_quit"));
fb_os_quit(framebuffer);
-#ifdef WITH_HUBBUB
/* We don't care if this fails as we're about to die, anyway */
hubbub_finalise(myrealloc, NULL);
-#endif
}
/* called back when click in browser window */
diff --git a/gtk/gtk_gui.c b/gtk/gtk_gui.c
index 4d6487b42..763898186 100644
--- a/gtk/gtk_gui.c
+++ b/gtk/gtk_gui.c
@@ -31,9 +31,7 @@
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
-#ifdef WITH_HUBBUB
#include <hubbub/hubbub.h>
-#endif
#include "content/content.h"
#include "content/fetch.h"
#include "content/fetchers/fetch_curl.h"
@@ -181,12 +179,10 @@ static void check_homedir(void)
}
}
-#ifdef WITH_HUBBUB
static void *myrealloc(void *ptr, size_t len, void *pw)
{
return realloc(ptr, len);
}
-#endif
void gui_init(int argc, char** argv)
{
@@ -204,12 +200,10 @@ void gui_init(int argc, char** argv)
LOG(("Using '%s' as Resources directory", buf));
res_dir_location = strdup(buf);
-#ifdef WITH_HUBBUB
find_resource(buf, "Aliases", "./gtk/res/Aliases");
LOG(("Using '%s' as Aliases file", buf));
if (hubbub_initialise(buf, myrealloc, NULL) != HUBBUB_OK)
die("Unable to initialise HTML parsing library.\n");
-#endif
glade_init();
gladeWindows = glade_xml_new(glade_file_location, NULL, NULL);
@@ -427,10 +421,8 @@ void gui_quit(void)
free(option_cookie_jar);
free(print_options_file_location);
gtk_fetch_filetype_fin();
-#ifdef WITH_HUBBUB
/* We don't care if this fails as we're about to die, anyway */
hubbub_finalise(myrealloc, NULL);
-#endif
}
diff --git a/render/box_construct.c b/render/box_construct.c
index dc354586e..f31b51538 100644
--- a/render/box_construct.c
+++ b/render/box_construct.c
@@ -140,9 +140,6 @@ static bool box_a(BOX_SPECIAL_PARAMS);
static bool box_body(BOX_SPECIAL_PARAMS);
static bool box_br(BOX_SPECIAL_PARAMS);
static bool box_image(BOX_SPECIAL_PARAMS);
-#ifndef WITH_HUBBUB
-static bool box_form(BOX_SPECIAL_PARAMS);
-#endif
static bool box_textarea(BOX_SPECIAL_PARAMS);
static bool box_select(BOX_SPECIAL_PARAMS);
static bool box_input(BOX_SPECIAL_PARAMS);
@@ -176,9 +173,6 @@ static const struct element_entry element_table[] = {
{"br", box_br},
{"button", box_button},
{"embed", box_embed},
-#ifndef WITH_HUBBUB
- {"form", box_form},
-#endif
{"frameset", box_frameset},
{"iframe", box_iframe},
{"image", box_image},
@@ -2162,78 +2156,6 @@ bool box_iframe(BOX_SPECIAL_PARAMS)
}
-#ifndef WITH_HUBBUB
-/**
- * Interactive form [17.3].
- */
-
-bool box_form(BOX_SPECIAL_PARAMS)
-{
- char *xmlaction, *action, *method, *enctype, *charset, *target;
- form_method fmethod;
- struct form *form;
- url_func_result result;
-
- if (!(xmlaction = (char *)
- xmlGetProp(n, (const xmlChar *) "action"))) {
- /* the action attribute is required, but many forms fail to
- * specify it. In the case where it is _not_ specified,
- * follow other browsers and make the form action the URI of
- * the page the form is contained in. */
- action = strdup(content->data.html.base_url);
- } else {
- result = url_join(xmlaction, content->data.html.base_url,
- &action);
-
- xmlFree(xmlaction);
-
- if (result != URL_FUNC_OK)
- return false;
- }
-
- if (!action)
- return false;
-
- fmethod = method_GET;
- if ((method = (char *) xmlGetProp(n, (const xmlChar *) "method"))) {
- if (strcasecmp(method, "post") == 0) {
- fmethod = method_POST_URLENC;
- if ((enctype = (char *) xmlGetProp(n,
- (const xmlChar *) "enctype"))) {
- if (strcasecmp(enctype,
- "multipart/form-data") == 0)
- fmethod = method_POST_MULTIPART;
- xmlFree(enctype);
- }
- }
- xmlFree(method);
- }
-
- /* acceptable encoding(s) for form data */
- charset = (char *) xmlGetProp(n, (const xmlChar *) "accept-charset");
-
- /* target for form data */
- target = (char *) xmlGetProp(n, (const xmlChar *) "target");
-
- form = form_new(n, action, target, fmethod, charset,
- content->data.html.encoding);
-
- free(action);
- if (charset)
- xmlFree(charset);
- if (target)
- xmlFree(target);
-
- if (!form)
- return false;
-
- form->prev = content->data.html.forms;
- content->data.html.forms = form;
-
- return true;
-}
-#endif
-
/**
* Form control [17.4].
*/
@@ -2246,67 +2168,24 @@ bool box_input(BOX_SPECIAL_PARAMS)
type = (char *) xmlGetProp(n, (const xmlChar *) "type");
-#ifdef WITH_HUBBUB
gadget = binding_get_control_for_node(content->data.html.parser_binding,
n);
if (!gadget)
goto no_memory;
box->gadget = gadget;
gadget->box = box;
-#endif
if (type && strcasecmp(type, "password") == 0) {
if (!box_input_text(n, content, box, 0, markup_track, author,
true))
goto no_memory;
-#ifndef WITH_HUBBUB
- gadget = box->gadget;
- gadget->box = box;
-#endif
} else if (type && strcasecmp(type, "file") == 0) {
box->type = BOX_INLINE_BLOCK;
-#ifndef WITH_HUBBUB
- box->gadget = gadget = form_new_control(n, GADGET_FILE);
- if (!gadget)
- goto no_memory;
- gadget->box = box;
-#endif
} else if (type && strcasecmp(type, "hidden") == 0) {
/* no box for hidden inputs */
box->style->display = CSS_DISPLAY_NONE;
-#ifndef WITH_HUBBUB
- gadget = form_new_control(n, GADGET_HIDDEN);
- if (!gadget)
- goto no_memory;
-
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "value"))) {
- gadget->value = strdup(s);
- xmlFree(s);
- if (!gadget->value)
- goto no_memory;
- gadget->length = strlen(gadget->value);
- }
-#endif
} else if (type && (strcasecmp(type, "checkbox") == 0 ||
strcasecmp(type, "radio") == 0)) {
-#ifndef WITH_HUBBUB
- box->gadget = gadget = form_new_control(n, type[0] == 'c' ||
- type[0] == 'C' ? GADGET_CHECKBOX :
- GADGET_RADIO);
- if (!gadget)
- goto no_memory;
- gadget->box = box;
-
- gadget->selected = xmlHasProp(n, (const xmlChar *) "checked");
-
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "value"))) {
- gadget->value = strdup(s);
- xmlFree(s);
- if (!gadget->value)
- goto no_memory;
- gadget->length = strlen(gadget->value);
- }
-#endif
} else if (type && (strcasecmp(type, "submit") == 0 ||
strcasecmp(type, "reset") == 0 ||
strcasecmp(type, "button") == 0)) {
@@ -2339,12 +2218,6 @@ bool box_input(BOX_SPECIAL_PARAMS)
box_add_child(inline_container, inline_box);
box_add_child(box, inline_container);
} else if (type && strcasecmp(type, "image") == 0) {
-#ifndef WITH_HUBBUB
- box->gadget = gadget = form_new_control(n, GADGET_IMAGE);
- if (!gadget)
- goto no_memory;
- gadget->box = box;
-#endif
gadget->type = GADGET_IMAGE;
if (box->style && box->style->display != CSS_DISPLAY_NONE) {
@@ -2378,39 +2251,17 @@ bool box_input(BOX_SPECIAL_PARAMS)
if (!box_input_text(n, content, box, 0, markup_track, author,
false))
goto no_memory;
-#ifndef WITH_HUBBUB
- gadget = box->gadget;
- gadget->box = box;
-#endif
}
if (type)
xmlFree(type);
-#ifndef WITH_HUBBUB
- if (gadget) {
- if (content->data.html.forms)
- form_add_control(content->data.html.forms, gadget);
- s = (char *) xmlGetProp(n, (const xmlChar *) "name");
- if (s) {
- gadget->name = strdup(s);
- xmlFree(s);
- if (!gadget->name)
- goto no_memory;
- }
- }
-#endif
-
*convert_children = false;
return true;
no_memory:
if (type)
xmlFree(type);
-#ifndef WITH_HUBBUB
- if (gadget)
- form_free_control(gadget);
-#endif
return false;
}
@@ -2421,37 +2272,9 @@ no_memory:
bool box_input_text(BOX_SPECIAL_PARAMS, bool password)
{
-#ifndef WITH_HUBBUB
- char *s;
-#endif
struct box *inline_container, *inline_box;
box->type = BOX_INLINE_BLOCK;
-#ifndef WITH_HUBBUB
- box->gadget = form_new_control(n, (password) ? GADGET_PASSWORD :
- GADGET_TEXTBOX);
- if (!box->gadget)
- return false;
- box->gadget->box = box;
-
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "maxlength"))) {
- if (s[0] != '\0')
- box->gadget->maxlength = atoi(s);
- xmlFree(s);
- }
-
- s = (char *) xmlGetProp(n, (const xmlChar *) "value");
- box->gadget->value = strdup((s != NULL) ? s : "");
- box->gadget->initial_value = strdup((box->gadget->value != NULL) ?
- box->gadget->value : "");
- if (s)
- xmlFree(s);
- if (box->gadget->value == NULL || box->gadget->initial_value == NULL) {
- box_free(box);
- return false;
- }
- box->gadget->length = strlen(box->gadget->value);
-#endif
inline_container = box_create(0, 0, 0, 0, 0, content);
if (!inline_container)
@@ -2494,41 +2317,6 @@ bool box_input_text(BOX_SPECIAL_PARAMS, bool password)
bool box_button(BOX_SPECIAL_PARAMS)
{
-#ifndef WITH_HUBBUB
- xmlChar *s;
- char *type = (char *) xmlGetProp(n, (const xmlChar *) "type");
-
- if (!type || strcasecmp(type, "submit") == 0) {
- box->gadget = form_new_control(n, GADGET_SUBMIT);
- } else if (strcasecmp(type, "reset") == 0) {
- box->gadget = form_new_control(n, GADGET_RESET);
- } else {
- box->gadget = form_new_control(n, GADGET_BUTTON);
- }
-
- if (type)
- xmlFree(type);
-
- if (!box->gadget)
- return false;
-
- if (content->data.html.forms)
- form_add_control(content->data.html.forms, box->gadget);
- box->gadget->box = box;
-
- if ((s = xmlGetProp(n, (const xmlChar *) "name")) != NULL) {
- box->gadget->name = strdup((char *) s);
- xmlFree(s);
- if (!box->gadget->name)
- return false;
- }
- if ((s = xmlGetProp(n, (const xmlChar *) "value")) != NULL) {
- box->gadget->value = strdup((char *) s);
- xmlFree(s);
- if (!box->gadget->value)
- return false;
- }
-#else
struct form_control *gadget;
gadget = binding_get_control_for_node(content->data.html.parser_binding,
@@ -2538,7 +2326,7 @@ bool box_button(BOX_SPECIAL_PARAMS)
box->gadget = gadget;
gadget->box = box;
-#endif
+
box->type = BOX_INLINE_BLOCK;
/* Just render the contents */
@@ -2556,25 +2344,13 @@ bool box_select(BOX_SPECIAL_PARAMS)
struct box *inline_container;
struct box *inline_box;
struct form_control *gadget;
-#ifndef WITH_HUBBUB
- char *s;
-#endif
xmlNode *c, *c2;
-#ifndef WITH_HUBBUB
- gadget = form_new_control(n, GADGET_SELECT);
-#else
gadget = binding_get_control_for_node(content->data.html.parser_binding,
n);
-#endif
if (!gadget)
return false;
-#ifndef WITH_HUBBUB
- gadget->data.select.multiple =
- xmlHasProp(n, (const xmlChar *) "multiple");
-#endif
-
for (c = n->children; c; c = c->next) {
if (strcmp((const char *) c->name, "option") == 0) {
if (!box_select_add_option(gadget, c))
@@ -2592,21 +2368,9 @@ bool box_select(BOX_SPECIAL_PARAMS)
if (gadget->data.select.num_items == 0) {
/* no options: ignore entire select */
-#ifndef WITH_HUBBUB
- form_free_control(gadget);
-#endif
return true;
}
-#ifndef WITH_HUBBUB
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "name"))) {
- gadget->name = strdup(s);
- xmlFree(s);
- if (!gadget->name)
- goto no_memory;
- }
-#endif
-
box->type = BOX_INLINE_BLOCK;
box->gadget = gadget;
gadget->box = box;
@@ -2644,18 +2408,10 @@ bool box_select(BOX_SPECIAL_PARAMS)
inline_box->length = strlen(inline_box->text);
-#ifndef WITH_HUBBUB
- if (content->data.html.forms)
- form_add_control(content->data.html.forms, box->gadget);
-#endif
-
*convert_children = false;
return true;
no_memory:
-#ifndef WITH_HUBBUB
- form_free_control(gadget);
-#endif
return false;
}
@@ -2736,25 +2492,12 @@ bool box_textarea(BOX_SPECIAL_PARAMS)
size_t len;
box->type = BOX_INLINE_BLOCK;
-#ifndef WITH_HUBBUB
- box->gadget = form_new_control(n, GADGET_TEXTAREA);
-#else
box->gadget = binding_get_control_for_node(
content->data.html.parser_binding, n);
-#endif
if (!box->gadget)
return false;
box->gadget->box = box;
-#ifndef WITH_HUBBUB
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "name"))) {
- box->gadget->name = strdup(s);
- xmlFree(s);
- if (!box->gadget->name)
- return false;
- }
-#endif
-
inline_container = box_create(0, 0, 0, box->title, 0, content);
if (!inline_container)
return false;
@@ -2843,11 +2586,6 @@ bool box_textarea(BOX_SPECIAL_PARAMS)
xmlFree(string);
xmlBufferFree(buf);
-#ifndef WITH_HUBBUB
- if (content->data.html.forms)
- form_add_control(content->data.html.forms, box->gadget);
-#endif
-
*convert_children = false;
return true;
}
diff --git a/render/directory.c b/render/directory.c
index 7fa5cb2dd..7360c4086 100644
--- a/render/directory.c
+++ b/render/directory.c
@@ -28,10 +28,6 @@
#include <stdlib.h>
#include <sys/stat.h>
#include <time.h>
-#ifdef WITH_HUBBUB
-#include <hubbub/parser.h>
-#endif
-#include <libxml/HTMLparser.h>
#include "content/content.h"
#include "render/directory.h"
#include "render/html.h"
diff --git a/render/html.c b/render/html.c
index 7e7070613..729a10cee 100644
--- a/render/html.c
+++ b/render/html.c
@@ -297,9 +297,7 @@ bool html_convert(struct content *c, int width, int height)
xmlNode *html, *head;
union content_msg_data msg_data;
unsigned int time_before, time_taken;
-#ifdef WITH_HUBBUB
struct form *f;
-#endif
/* finish parsing */
if (c->source_size == 0) {
@@ -401,7 +399,6 @@ bool html_convert(struct content *c, int width, int height)
if (!html_find_stylesheets(c, html))
return false;
-#ifdef WITH_HUBBUB
/* Retrieve forms from parser */
c->data.html.forms = binding_get_forms(c->data.html.parser_binding);
for (f = c->data.html.forms; f != NULL; f = f->prev) {
@@ -430,7 +427,6 @@ bool html_convert(struct content *c, int width, int height)
}
}
}
-#endif
/* convert xml tree to box tree */
LOG(("XML to box"));
diff --git a/render/hubbub_binding.c b/render/hubbub_binding.c
index a99bcf7cb..279dd9933 100644
--- a/render/hubbub_binding.c
+++ b/render/hubbub_binding.c
@@ -17,8 +17,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifdef WITH_HUBBUB
-
#define _GNU_SOURCE /* for strndup */
#include <assert.h>
#include <stdbool.h>
@@ -1023,5 +1021,3 @@ struct form_control *parse_textarea_element(xmlNode *node)
return control;
}
-#endif
-
diff --git a/render/libxml_binding.c b/render/libxml_binding.c
index fdff19b70..e69de29bb 100644
--- a/render/libxml_binding.c
+++ b/render/libxml_binding.c
@@ -1,312 +0,0 @@
-/*
- * Copyright 2007 James Bursa <bursa@users.sourceforge.net>
- * Copyright 2008 John-Mark Bell <jmb@netsurf-browser.org>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef WITH_HUBBUB
-
-#include <stdbool.h>
-#include <string.h>
-
-#include <libxml/HTMLparser.h>
-#include <libxml/HTMLtree.h>
-#include <libxml/parser.h>
-#include <libxml/parserInternals.h>
-
-#include "render/parser_binding.h"
-
-#include "utils/log.h"
-#include "utils/talloc.h"
-
-typedef struct libxml_ctx {
- htmlParserCtxt *parser;
-
- /** HTML parser encoding handler. */
- xmlCharEncodingHandler *encoding_handler;
-
- const char *encoding;
- binding_encoding_source encoding_source;
-
- bool getenc;
-} libxml_ctx;
-
-static bool set_parser_encoding(libxml_ctx *c, const char *encoding);
-static const char *detect_encoding(const char **data, size_t *size);
-
-binding_error binding_create_tree(void *arena, const char *charset, void **ctx)
-{
- libxml_ctx *c;
-
- c = malloc(sizeof(libxml_ctx));
- if (c == NULL)
- return BINDING_NOMEM;
-
- c->parser = NULL;
- c->encoding_handler = NULL;
- c->encoding = charset;
- c->encoding_source = ENCODING_SOURCE_HEADER;
- c->getenc = true;
-
- c->parser = htmlCreatePushParserCtxt(0, 0, "", 0, 0,
- XML_CHAR_ENCODING_NONE);
- if (c->parser == NULL) {
- free(c);
- return BINDING_NOMEM;
- }
-
- if (c->encoding != NULL && !set_parser_encoding(c, charset)) {
- if (c->parser->myDoc != NULL)
- xmlFreeDoc(c->parser->myDoc);
- htmlFreeParserCtxt(c->parser);
- free(c);
- return BINDING_BADENCODING;
- }
-
- *ctx = (void *) c;
-
- return BINDING_OK;
-}
-
-binding_error binding_destroy_tree(void *ctx)
-{
- libxml_ctx *c = (libxml_ctx *) ctx;
-
- if (ctx == NULL)
- return BINDING_OK;
-
- if (c->parser->myDoc != NULL)
- xmlFreeDoc(c->parser->myDoc);
-
- if (c->parser != NULL)
- htmlFreeParserCtxt(c->parser);
-
- c->parser = NULL;
- c->encoding = NULL;
-
- free(c);
-
- return BINDING_OK;
-}
-
-binding_error binding_parse_chunk(void *ctx, const uint8_t *data, size_t len)
-{
- libxml_ctx *c = (libxml_ctx *) ctx;
-
- if (c->getenc) {
- /* No encoding was specified in the Content-Type header.
- * Attempt to detect if the encoding is not 8-bit. If the
- * encoding is 8-bit, leave the parser unchanged, so that it
- * searches for a <meta http-equiv="content-type"
- * content="text/html; charset=...">. */
- const char *encoding;
- encoding = detect_encoding((const char **) (void *) &data,
- &len);
- if (encoding) {
- if (!set_parser_encoding(c, encoding))
- return BINDING_NOMEM;
- c->encoding = encoding;
- c->encoding_source = ENCODING_SOURCE_DETECTED;
- }
- c->getenc = false;
-
- /* The data we received may have solely consisted of a BOM.
- * If so, it will have been stripped by html_detect_encoding.
- * Therefore, we'll have nothing to do in that case. */
- if (len == 0)
- return BINDING_OK;
- }
-
- htmlParseChunk(c->parser, (const char *) data, len, 0);
- /** \todo error handling */
-
- if (!c->encoding && c->parser->input->encoding) {
- /* The encoding was not in headers or detected,
- * and the parser found a <meta http-equiv="content-type"
- * content="text/html; charset=...">. */
-
- /* However, if that encoding is non-ASCII-compatible,
- * ignore it, as it can't possibly be correct */
- if (strncasecmp((const char *) c->parser->input->encoding,
- "UTF-16", 6) == 0 || /* UTF-16(LE|BE)? */
- strncasecmp((const char *) c->parser->input->encoding,
- "UTF-32", 6) == 0) { /* UTF-32(LE|BE)? */
- c->encoding = "ISO-8859-1";
- c->encoding_source = ENCODING_SOURCE_DETECTED;
- } else {
- c->encoding = (const char *) c->parser->input->encoding;
- c->encoding_source = ENCODING_SOURCE_META;
- }
-
- if (!c->encoding)
- return BINDING_NOMEM;
-
- /* have the encoding; don't attempt to detect it */
- c->getenc = false;
-
- return BINDING_ENCODINGCHANGE;
- }
-
- return BINDING_OK;
-}
-
-binding_error binding_parse_completed(void *ctx)
-{
- libxml_ctx *c = (libxml_ctx *) ctx;
-
- htmlParseChunk(c->parser, "", 0, 1);
- /** \todo error handling */
-
- return BINDING_OK;
-}
-
-const char *binding_get_encoding(void *ctx, binding_encoding_source *source)
-{
- libxml_ctx *c = (libxml_ctx *) ctx;
-
- *source = c->encoding_source;
-
- return c->encoding;
-}
-
-xmlDocPtr binding_get_document(void *ctx)
-{
- libxml_ctx *c = (libxml_ctx *) ctx;
- xmlDocPtr doc = c->parser->myDoc;
-
- c->parser->myDoc = NULL;
-
- return doc;
-}
-
-/******************************************************************************/
-
-/**
- * Set the HTML parser character encoding.
- *
- * \param c context
- * \param encoding name of encoding
- * \return true on success, false on error and error reported
- */
-bool set_parser_encoding(libxml_ctx *c, const char *encoding)
-{
- xmlError *error;
-
- c->encoding_handler = xmlFindCharEncodingHandler(encoding);
- if (!c->encoding_handler) {
- /* either out of memory, or no handler available */
- /* assume no handler available, which is not a fatal error */
- LOG(("no encoding handler for \"%s\"", encoding));
- /* \todo warn user and ask them to install iconv? */
- return true;
- }
-
- xmlCtxtResetLastError(c->parser);
- if (xmlSwitchToEncoding(c->parser, c->encoding_handler)) {
- error = xmlCtxtGetLastError(c->parser);
- LOG(("xmlSwitchToEncoding(): %s",
- error ? error->message : "failed"));
- return false;
- }
-
- /* Dirty hack to get around libxml oddness:
- * 1) When creating a push parser context, the input flow's encoding
- * string is not set (whether an encoding is specified or not)
- * 2) When switching encoding (as above), the input flow's encoding
- * string is never changed
- * 3) When handling a meta charset, the input flow's encoding string
- * is checked to determine if an encoding has already been set.
- * If it has been set, then the meta charset is ignored.
- *
- * The upshot of this is that, if we don't explicitly set the input
- * flow's encoding string here, any meta charset in the document
- * will override our setting, which is incorrect behaviour.
- *
- * Ideally, this would be fixed in libxml, but that requires rather
- * more knowledge than I currently have of what libxml is doing.
- */
- if (!c->parser->input->encoding)
- c->parser->input->encoding =
- xmlStrdup((const xmlChar *) encoding);
-
- /* Ensure noone else attempts to reset the encoding */
- c->getenc = false;
-
- return true;
-}
-
-/**
- * Attempt to detect the encoding of some HTML data.
- *
- * \param data Pointer to HTML source data
- * \param size Pointer to length of data
- * \return a constant string giving the encoding, or 0 if the encoding
- * appears to be some 8-bit encoding
- *
- * If a BOM is encountered, *data and *size will be modified to skip over it
- */
-
-const char *detect_encoding(const char **data, size_t *size)
-{
- const unsigned char *d = (const unsigned char *) *data;
-
- /* this detection assumes that the first two characters are <= 0xff */
- if (*size < 4)
- return 0;
-
- if (d[0] == 0x00 && d[1] == 0x00 &&
- d[2] == 0xfe && d[3] == 0xff) { /* BOM 00 00 fe ff */
- *data += 4;
- *size -= 4;
- return "UTF-32BE";
- } else if (d[0] == 0xff && d[1] == 0xfe &&
- d[2] == 0x00 && d[3] == 0x00) { /* BOM ff fe 00 00 */
- *data += 4;
- *size -= 4;
- return "UTF-32LE";
- }
- else if (d[0] == 0x00 && d[1] != 0x00 &&
- d[2] == 0x00 && d[3] != 0x00) /* 00 xx 00 xx */
- return "UTF-16BE";
- else if (d[0] != 0x00 && d[1] == 0x00 &&
- d[2] != 0x00 && d[3] == 0x00) /* xx 00 xx 00 */
- return "UTF-16LE";
- else if (d[0] == 0x00 && d[1] == 0x00 &&
- d[2] == 0x00 && d[3] != 0x00) /* 00 00 00 xx */
- return "ISO-10646-UCS-4";
- else if (d[0] != 0x00 && d[1] == 0x00 &&
- d[2] == 0x00 && d[3] == 0x00) /* xx 00 00 00 */
- return "ISO-10646-UCS-4";
- else if (d[0] == 0xfe && d[1] == 0xff) { /* BOM fe ff */
- *data += 2;
- *size -= 2;
- return "UTF-16BE";
- } else if (d[0] == 0xff && d[1] == 0xfe) { /* BOM ff fe */
- *data += 2;
- *size -= 2;
- return "UTF-16LE";
- } else if (d[0] == 0xef && d[1] == 0xbb &&
- d[2] == 0xbf) { /* BOM ef bb bf */
- *data += 3;
- *size -= 3;
- return "UTF-8";
- }
-
- return 0;
-}
-
-#endif
-
diff --git a/render/parser_binding.h b/render/parser_binding.h
index d23b79359..d50b4e3b9 100644
--- a/render/parser_binding.h
+++ b/render/parser_binding.h
@@ -48,10 +48,8 @@ binding_error binding_parse_completed(void *ctx);
const char *binding_get_encoding(void *ctx, binding_encoding_source *source);
xmlDocPtr binding_get_document(void *ctx);
-#ifdef WITH_HUBBUB
struct form *binding_get_forms(void *ctx);
struct form_control *binding_get_control_for_node(void *ctx, xmlNodePtr node);
-#endif
#endif
diff --git a/riscos/gui.c b/riscos/gui.c
index ced9cfa14..5d70a0d8f 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -33,9 +33,7 @@
#include <features.h>
#include <unixlib/local.h>
#include <curl/curl.h>
-#ifdef WITH_HUBBUB
#include <hubbub/hubbub.h>
-#endif
#include "oslib/font.h"
#include "oslib/help.h"
#include "oslib/hourglass.h"
@@ -271,12 +269,10 @@ static void ro_msg_save_desktop(wimp_message *message);
static void ro_msg_window_info(wimp_message *message);
static void ro_gui_view_source_bounce(wimp_message *message);
-#ifdef WITH_HUBBUB
static void *myrealloc(void *ptr, size_t len, void *pw)
{
return realloc(ptr, len);
}
-#endif
/**
* Initialise the gui (RISC OS specific part).
@@ -317,11 +313,9 @@ void gui_init(int argc, char** argv)
ro_plot_patterned_lines = false;
}
-#ifdef WITH_HUBBUB
if (hubbub_initialise("NetSurf:Resources.Aliases", myrealloc, NULL) !=
HUBBUB_OK)
die("Failed to initialise HTML parsing library.");
-#endif
/* Read in the options */
options_read("NetSurf:Choices");
@@ -778,10 +772,8 @@ void gui_quit(void)
xwimp_close_down(task_handle);
free(default_stylesheet_url);
free(adblock_stylesheet_url);
-#ifdef WITH_HUBBUB
/* We don't care if this fails */
hubbub_finalise(myrealloc, NULL);
-#endif
xhourglass_off();
}
diff --git a/utils/utf8.c b/utils/utf8.c
index fae9ccc30..f866562e1 100644
--- a/utils/utf8.c
+++ b/utils/utf8.c
@@ -28,37 +28,12 @@
#include <strings.h>
#include <iconv.h>
-/** \todo Once we can enable hubbub on all platforms, these ifdefs must go */
-#ifdef WITH_HUBBUB
#include <parserutils/charset/utf8.h>
-#endif
#include "utils/config.h"
#include "utils/log.h"
#include "utils/utf8.h"
-#ifndef WITH_HUBBUB
-/** Number of continuation bytes for a given start byte */
-static const uint8_t numContinuations[256] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5,
-};
-#endif
-
static utf8_convert_ret utf8_convert(const char *string, size_t len,
const char *from, const char *to, char **result);
@@ -74,7 +49,6 @@ static utf8_convert_ret utf8_convert(const char *string, size_t len,
*/
uint32_t utf8_to_ucs4(const char *s_in, size_t l)
{
-#ifdef WITH_HUBBUB
uint32_t ucs4;
size_t len;
parserutils_error perror;
@@ -85,66 +59,6 @@ uint32_t utf8_to_ucs4(const char *s_in, size_t l)
ucs4 = 0xfffd;
return ucs4;
-#else
- const uint8_t *s = (const uint8_t *) s_in;
- uint32_t c, min;
- uint8_t n;
- uint8_t i;
-
- assert(s != NULL && l > 0);
-
- c = s[0];
-
- if (c < 0x80) {
- n = 1;
- min = 0;
- } else if ((c & 0xE0) == 0xC0) {
- c &= 0x1F;
- n = 2;
- min = 0x80;
- } else if ((c & 0xF0) == 0xE0) {
- c &= 0x0F;
- n = 3;
- min = 0x800;
- } else if ((c & 0xF8) == 0xF0) {
- c &= 0x07;
- n = 4;
- min = 0x10000;
- } else if ((c & 0xFC) == 0xF8) {
- c &= 0x03;
- n = 5;
- min = 0x200000;
- } else if ((c & 0xFE) == 0xFC) {
- c &= 0x01;
- n = 6;
- min = 0x4000000;
- } else {
- assert(0);
- }
-
- if (l < n) {
- return 0xfffd;
- }
-
- for (i = 1; i < n; i++) {
- uint32_t t = s[i];
-
- if ((t & 0xC0) != 0x80) {
- return 0xfffd;
- }
-
- c <<= 6;
- c |= t & 0x3F;
- }
-
- /* Detect overlong sequences, surrogates and fffe/ffff */
- if (c < min || (c >= 0xD800 && c <= 0xDFFF) ||
- c == 0xFFFE || c == 0xFFFF) {
- c = 0xfffd;
- }
-
- return c;
-#endif
}
/**
@@ -159,7 +73,6 @@ uint32_t utf8_to_ucs4(const char *s_in, size_t l)
*/
size_t utf8_from_ucs4(uint32_t c, char *s)
{
-#ifdef WITH_HUBBUB
uint8_t *in = (uint8_t *) s;
size_t len = 6;
parserutils_error perror;
@@ -173,44 +86,6 @@ size_t utf8_from_ucs4(uint32_t c, char *s)
}
return 6 - len;
-#else
- uint8_t *buf;
- uint8_t l = 0;
-
- assert(s != NULL);
-
- if (c < 0x80) {
- l = 1;
- } else if (c < 0x800) {
- l = 2;
- } else if (c < 0x10000) {
- l = 3;
- } else if (c < 0x200000) {
- l = 4;
- } else if (c < 0x4000000) {
- l = 5;
- } else if (c <= 0x7FFFFFFF) {
- l = 6;
- } else {
- assert(0);
- }
-
- buf = (uint8_t *) s;
-
- if (l == 1) {
- buf[0] = (uint8_t) c;
- } else {
- uint8_t i;
-
- for (i = l; i > 1; i--) {
- buf[i - 1] = 0x80 | (c & 0x3F);
- c >>= 6;
- }
- buf[0] = ~((1 << (8 - l)) - 1) | c;
- }
-
- return l;
-#endif
}
/**
@@ -233,7 +108,6 @@ size_t utf8_length(const char *s)
*/
size_t utf8_bounded_length(const char *s, size_t l)
{
-#ifdef WITH_HUBBUB
size_t len;
parserutils_error perror;
@@ -242,37 +116,6 @@ size_t utf8_bounded_length(const char *s, size_t l)
return 0;
return len;
-#else
- const uint8_t *p = (const uint8_t *) s;
- const uint8_t *end = p + l;
- size_t len = 0;
-
- assert(s != NULL);
-
- while (p < end) {
- uint32_t c = p[0];
-
- if ((c & 0x80) == 0x00)
- p += 1;
- else if ((c & 0xE0) == 0xC0)
- p += 2;
- else if ((c & 0xF0) == 0xE0)
- p += 3;
- else if ((c & 0xF8) == 0xF0)
- p += 4;
- else if ((c & 0xFC) == 0xF8)
- p += 5;
- else if ((c & 0xFE) == 0xFC)
- p += 6;
- else {
- assert(0);
- }
-
- len++;
- }
-
- return len;
-#endif
}
/**
@@ -283,7 +126,6 @@ size_t utf8_bounded_length(const char *s, size_t l)
*/
size_t utf8_char_byte_length(const char *s)
{
-#ifdef WITH_HUBBUB
size_t len;
parserutils_error perror;
@@ -292,12 +134,6 @@ size_t utf8_char_byte_length(const char *s)
assert(perror == PARSERUTILS_OK);
return len;
-#else
- const uint8_t *p = (const uint8_t *) s;
- assert(s != NULL);
-
- return numContinuations[p[0]] + 1 /* Start byte */;
-#endif
}
/**
@@ -309,7 +145,6 @@ size_t utf8_char_byte_length(const char *s)
*/
size_t utf8_prev(const char *s, size_t o)
{
-#ifdef WITH_HUBBUB
uint32_t prev;
parserutils_error perror;
@@ -317,16 +152,6 @@ size_t utf8_prev(const char *s, size_t o)
assert(perror == PARSERUTILS_OK);
return prev;
-#else
- const uint8_t *p = (const uint8_t *) s;
-
- assert(s != NULL);
-
- while (o != 0 && (p[--o] & 0xC0) == 0x80)
- /* do nothing */;
-
- return o;
-#endif
}
/**
@@ -339,7 +164,6 @@ size_t utf8_prev(const char *s, size_t o)
*/
size_t utf8_next(const char *s, size_t l, size_t o)
{
-#ifdef WITH_HUBBUB
uint32_t next;
parserutils_error perror;
@@ -348,20 +172,6 @@ size_t utf8_next(const char *s, size_t l, size_t o)
assert(perror == PARSERUTILS_OK);
return next;
-#else
- const uint8_t *p = (const uint8_t *) s;
-
- assert(s != NULL && o < l);
-
- /* Skip current start byte (if present - may be mid-sequence) */
- if (p[o] < 0x80 || (p[o] & 0xC0) == 0xC0)
- o++;
-
- while (o < l && (p[o] & 0xC0) == 0x80)
- o++;
-
- return o;
-#endif
}
/* Cache of previous iconv conversion descriptor used by utf8_convert */