From ddeadd1c02880367ad786b113d352a519f45ec73 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Thu, 23 Jul 2009 23:05:34 +0000 Subject: Merge LibCSS port to trunk. svn path=/trunk/netsurf/; revision=8752 --- !NetSurf/Resources/Quirks,f79 | 14 + Makefile | 31 +- Makefile.sources | 34 +- amiga/context_menu.c | 2 +- amiga/font.c | 10 +- amiga/gui.c | 7 +- amiga/resources/quirks.css | 1 + amiga/save_complete.c | 11 +- beos/beos_font.cpp | 4 - beos/beos_gui.cpp | 12 +- beos/res/quirks.css | 1 + content/content.c | 11 +- content/content.h | 3 +- content/fetchcache.c | 7 +- css/Makefile | 44 - css/css.c | 3464 +++------------------------------------ css/css.h | 705 +------- css/css_enums | 29 - css/dump.c | 1791 ++++++++++++++++++++ css/dump.h | 26 + css/internal.c | 82 + css/internal.h | 27 + css/makeenum | 46 - css/parser.y | 441 ----- css/ruleset.c | 3152 ----------------------------------- css/scanner.l | 112 -- css/select.c | 1981 ++++++++++++++++++++++ css/select.h | 51 + css/testcss.c | 181 -- css/utils.c | 124 ++ css/utils.h | 44 + desktop/browser.c | 171 +- desktop/plot_style.c | 2 +- desktop/plot_style.h | 11 + desktop/print.c | 64 +- desktop/print.h | 4 +- desktop/save_pdf/font_haru.c | 6 +- desktop/save_pdf/pdf_plotters.c | 19 +- desktop/save_text.c | 4 +- desktop/textarea.c | 16 +- desktop/textarea.h | 4 +- framebuffer/fbtk.c | 2 +- framebuffer/gui.c | 4 + framebuffer/res/quirks.css | 1 + gtk/font_pango.c | 12 +- gtk/gtk_gui.c | 5 + gtk/gtk_print.c | 6 +- gtk/gtk_scaffolding.c | 7 +- gtk/res/quirks.css | 1 + image/bmp.c | 3 +- image/bmp.h | 3 +- image/gif.c | 3 +- image/gif.h | 3 +- image/ico.c | 3 +- image/ico.h | 3 +- image/mng.c | 3 +- image/mng.h | 3 +- image/png.c | 3 +- image/png.h | 5 +- image/rsvg.c | 3 +- image/rsvg.h | 3 +- image/svg.c | 2 +- image/svg.h | 3 +- render/box.c | 39 +- render/box.h | 22 +- render/box_construct.c | 997 ++++------- render/box_normalise.c | 637 ++++--- render/directory.c | 5 +- render/directory.h | 3 +- render/font.c | 48 +- render/font.h | 2 +- render/html.c | 191 ++- render/html.h | 18 +- render/html_redraw.c | 349 ++-- render/hubbub_binding.c | 21 +- render/layout.c | 1558 +++++++++++------- render/list.c | 49 +- render/list.h | 10 +- render/loosen.c | 501 ------ render/loosen.h | 35 - render/parser_binding.h | 8 +- render/table.c | 892 ++++++++-- render/table.h | 2 +- render/textplain.c | 9 +- render/textplain.h | 3 +- riscos/font.c | 19 +- riscos/gui.c | 9 +- riscos/image.h | 2 +- riscos/plugin.c | 3 +- riscos/plugin.h | 3 +- riscos/save.c | 6 +- riscos/save_complete.c | 11 +- riscos/textselection.c | 3 +- riscos/window.c | 4 +- utils/config.h | 15 + utils/utils.c | 183 ++- utils/utils.h | 4 - 97 files changed, 7703 insertions(+), 10788 deletions(-) create mode 100644 !NetSurf/Resources/Quirks,f79 create mode 120000 amiga/resources/quirks.css create mode 120000 beos/res/quirks.css delete mode 100644 css/Makefile delete mode 100644 css/css_enums create mode 100644 css/dump.c create mode 100644 css/dump.h create mode 100644 css/internal.c create mode 100644 css/internal.h delete mode 100755 css/makeenum delete mode 100644 css/parser.y delete mode 100644 css/ruleset.c delete mode 100644 css/scanner.l create mode 100644 css/select.c create mode 100644 css/select.h delete mode 100644 css/testcss.c create mode 100644 css/utils.c create mode 100644 css/utils.h create mode 120000 framebuffer/res/quirks.css create mode 120000 gtk/res/quirks.css delete mode 100644 render/loosen.c delete mode 100644 render/loosen.h diff --git a/!NetSurf/Resources/Quirks,f79 b/!NetSurf/Resources/Quirks,f79 new file mode 100644 index 000000000..2f0f9f369 --- /dev/null +++ b/!NetSurf/Resources/Quirks,f79 @@ -0,0 +1,14 @@ +/* Quirks mode stylesheet for NetSurf */ + +/** + * Netscape/IE 4 compatibility. + * + * See https://developer.mozilla.org/en/Fixing_Table_Inheritance_in_Quirks_Mode + */ +table { + /* Reset font properties (except family) */ + font-size: medium; + font-style: normal; + font-variant: normal; + font-weight: normal; +} diff --git a/Makefile b/Makefile index 373ae05e8..3336e253b 100644 --- a/Makefile +++ b/Makefile @@ -254,9 +254,10 @@ CFLAGS += -DNETSURF_HOMEPAGE=\"$(NETSURF_HOMEPAGE)\" ifeq ($(TARGET),riscos) ifeq ($(HOST),riscos) LDFLAGS += -Xlinker -symbols=$(OBJROOT)/sym -lxml2 -lz -lm -lcurl -lcares - LDFLAGS += -lssl -lcrypto -lhubbub -lparserutils + LDFLAGS += -lssl -lcrypto -lhubbub -lcss -lparserutils -lwapcaplet else - LDFLAGS += $(shell $(PKG_CONFIG) --libs libxml-2.0 libcurl libhubbub openssl) + LDFLAGS += $(shell $(PKG_CONFIG) --libs libxml-2.0 libcurl openssl) + LDFLAGS += $(shell $(PKG_CONFIG) --libs libhubbub libcss) endif $(eval $(call feature_enabled,NSSVG,-DWITH_NS_SVG,-lsvgtiny,SVG rendering)) @@ -289,9 +290,7 @@ ifeq ($(TARGET),riscos) CFLAGS += -I$(GCCSDK_INSTALL_ENV)/include \ -I$(GCCSDK_INSTALL_ENV)/include/libxml2 \ - -I$(GCCSDK_INSTALL_ENV)/include/libmng \ - -I$(GCCSDK_INSTALL_ENV)/include/hubbub0 \ - -I$(GCCSDK_INSTALL_ENV)/include/parserutils0 + -I$(GCCSDK_INSTALL_ENV)/include/libmng ifeq ($(HOST),riscos) CFLAGS += -I -mthrowback endif @@ -322,7 +321,7 @@ ifeq ($(TARGET),beos) LDFLAGS += -L/boot/common/lib # some people do *not* have libm... LDFLAGS += -lxml2 -lcurl -liconv - LDFLAGS += -lssl -lcrypto -lhubbub -lparserutils + LDFLAGS += -lssl -lcrypto -lhubbub -lcss -lparserutils -lwapcaplet CFLAGS += -I. -O $(WARNFLAGS) -Dnsbeos \ -D_BSD_SOURCE -D_POSIX_C_SOURCE \ @@ -345,8 +344,9 @@ ifeq ($(TARGET),beos) CFLAGS += -I/boot/home/config/include \ -I/boot/home/config/include/libxml2 \ -I/boot/home/config/include/libmng \ - -I/boot/home/config/include/hubbub0 \ - -I/boot/home/config/include/parserutils0 + -I/boot/home/config/include/hubbub \ + -I/boot/home/config/include/libcss \ + -I/boot/home/config/include/parserutils ifneq ($(wildcard /boot/develop/lib/*/libzeta.so),) LDFLAGS += -lzeta endif @@ -355,8 +355,9 @@ ifeq ($(TARGET),beos) CFLAGS += -I/boot/common/include \ -I/boot/common/include/libxml2 \ -I/boot/common/include/libmng \ - -I/boot/common/include/hubbub0 \ - -I/boot/common/include/parserutils0 + -I/boot/common/include/hubbub \ + -I/boot/common/include/libcss \ + -I/boot/common/include/parserutils NETLDFLAGS := -lnetwork else ifneq ($(wildcard /boot/develop/lib/*/libbind.so),) @@ -377,16 +378,13 @@ ifeq ($(TARGET),beos) ifeq ($(HOST),beos) CFLAGS += -I$(PREFIX)/include LDFLAGS += -L$(PREFIX)/lib - $(eval $(call feature_enabled,HUBBUB,-DWITH_HUBBUB,-lhubbub-debug -lparserutils-debug,Hubbub HTML parser)) $(eval $(call feature_enabled,BMP,-DWITH_BMP,-lnsbmp,NetSurf BMP decoder)) $(eval $(call feature_enabled,GIF,-DWITH_GIF,-lnsgif,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,Hubbub HTML parser)) $(eval $(call pkg_config_find_and_add,BMP,libnsbmp,NetSurf BMP decoder)) $(eval $(call pkg_config_find_and_add,GIF,libnsgif,NetSurf GIF decoder)) $(eval $(call pkg_config_find_and_add,PNG,libpng,PNG support)) @@ -399,6 +397,7 @@ endif ifeq ($(TARGET),gtk) LDFLAGS += $(shell $(PKG_CONFIG) --libs libxml-2.0 libcurl libhubbub openssl) + LDFLAGS += $(shell $(PKG_CONFIG) --libs libcss) # define additional CFLAGS and LDFLAGS requirements for pkg-configed libs here NETSURF_FEATURE_RSVG_CFLAGS := -DWITH_RSVG @@ -460,7 +459,7 @@ ifeq ($(TARGET),amiga) CFLAGS += -D__USE_INLINE__ -std=c99 -I . -Dnsamiga LDFLAGS += -lxml2 -lcurl -lpthread -lregex -lauto - LDFLAGS += -lssl -lcrypto -lhubbub -lparserutils + LDFLAGS += -lssl -lcrypto -lhubbub -lcss -lparserutils -lwapcaplet ifeq ($(NETSURF_AMIGA_USE_CAIRO),YES) CFLAGS += -DNS_AMIGA_CAIRO -I SDK:local/common/include/cairo @@ -503,10 +502,12 @@ ifeq ($(TARGET),framebuffer) -D_POSIX_C_SOURCE=200112L \ $(shell $(PKG_CONFIG) --cflags libnsfb) \ $(shell $(PKG_CONFIG) --cflags libhubbub libcurl openssl) \ + $(shell $(PKG_CONFIG) --cflags libcss) \ $(shell xml2-config --cflags) LDFLAGS += -Wl,--whole-archive $(shell $(PKG_CONFIG) --libs libnsfb) -Wl,--no-whole-archive LDFLAGS += $(shell $(PKG_CONFIG) --libs libxml-2.0 libcurl libhubbub openssl) + LDFLAGS += $(shell $(PKG_CONFIG) --libs libcss) endif @@ -634,7 +635,7 @@ DEPFILES := # 3 = obj filename, no prefix define dependency_generate_c DEPFILES += $(2) -$$(DEPROOT)/$(2): $$(DEPROOT)/created $(1) css/css_enum.h css/parser.h Makefile.config +$$(DEPROOT)/$(2): $$(DEPROOT)/created $(1) Makefile.config endef diff --git a/Makefile.sources b/Makefile.sources index e3404739d..2ffe1e7f4 100644 --- a/Makefile.sources +++ b/Makefile.sources @@ -7,10 +7,10 @@ S_CONTENT := content.c fetch.c fetchcache.c urldb.c \ fetchers/fetch_curl.c fetchers/fetch_data.c -S_CSS := css.c css_enum.c parser.c ruleset.c scanner.c +S_CSS := css.c dump.c internal.c select.c utils.c S_RENDER := box.c box_construct.c box_normalise.c directory.c \ font.c form.c html.c html_redraw.c hubbub_binding.c imagemap.c \ - layout.c list.c loosen.c table.c textplain.c + layout.c list.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 textarea.c \ @@ -102,38 +102,14 @@ endif S_FRAMEBUFFER := $(addprefix framebuffer/,$(S_FRAMEBUFFER)) -# Some extra rules for building the scanner etc. -css/css_enum.c css/css_enum.h: css/css_enums css/makeenum - $(VQ)echo "MAKEENUM: css" - $(Q)$(PERL) css/makeenum css/css_enum < css/css_enums +# Some extra rules for building the transliteration table. ifeq ($(HOST),riscos) -css/parser.c css/parser.h: css/parser.y - $(VQ)echo " LEMON: css/parser.y" - $(Q)dir css - $(Q)-lemon parser.y - $(Q)dir ^ - $(Q)touch css/parser.c css/parser.h -css/scanner.c: css/scanner.l - $(VQ)echo " RE2C: css/scanner.l" - $(Q)dir css - $(Q)re2c -s scanner.l > scanner.c - $(Q)dir ^ utils/translit.c: transtab $(VQ)echo "TRANSTAB: utils/translit.c" $(Q)dir utils $(Q)$(PERL) tt2code < transtab > translit.c $(Q)dir ^ else -css/parser.c css/parser.h: css/parser.y - $(VQ)echo " LEMON: css/parser.y" - $(Q)# If lemon really fails hard, we'll never know, sorry - $(Q)cd css; lemon parser.y || true - $(Q)# Unfortunately if the output hasn't changed, lemon doesn't - $(Q)# alter the file and thus make gets confused. - $(Q)touch css/parser.c css/parser.h -css/scanner.c: css/scanner.l - $(VQ)echo " RE2C: css/scanner.l" - $(Q)cd css; re2c -s scanner.l > scanner.c utils/translit.c: transtab $(VQ)echo "TRANSTAB: utils/translit.c" $(Q)cd utils; $(PERL) tt2code < transtab > translit.c @@ -141,9 +117,7 @@ endif clean-intermediates: $(VQ)echo " CLEAN: intermediates" - $(Q)$(RM) css/css_enum.c css/css_enum.h css/parser.c \ - css/parser.out css/parser.h - $(Q)$(RM) css/scanner.c utils/translit.c + $(Q)$(RM) utils/translit.c CLEANS += clean-intermediates diff --git a/amiga/context_menu.c b/amiga/context_menu.c index 7f60d4963..24dd90f2b 100755 --- a/amiga/context_menu.c +++ b/amiga/context_menu.c @@ -92,7 +92,7 @@ void ami_context_menu_show(struct gui_window_2 *gwin,int x,int y) while(curbox = box_at_point(curbox,x,y,&box_x,&box_y,&cc)) { - if (curbox->style && curbox->style->visibility == CSS_VISIBILITY_HIDDEN) continue; + if (curbox->style && css_computed_visibility(curbox->style) == CSS_VISIBILITY_HIDDEN) continue; if(curbox->href) { diff --git a/amiga/font.c b/amiga/font.c index cd7d834e2..5c694c199 100644 --- a/amiga/font.c +++ b/amiga/font.c @@ -237,7 +237,7 @@ struct OutlineFont *ami_open_outline_font(const plot_font_style_t *fstyle) { struct OutlineFont *ofont; char *fontname; - WORD ysize; + ULONG ysize; int tstyle = 0; if ((fstyle->flags & FONTF_ITALIC) || (fstyle->flags & FONTF_OBLIQUE)) @@ -268,14 +268,12 @@ struct OutlineFont *ami_open_outline_font(const plot_font_style_t *fstyle) break; } - ysize = fstyle->size; - - if(ysize < (option_font_min_size / 10) * FONT_SIZE_SCALE) - ysize = (option_font_min_size / 10) * FONT_SIZE_SCALE; + /* Scale to 16.16 fixed point */ + ysize = fstyle->size * ((1 << 16) / FONT_SIZE_SCALE); if(ESetInfo(&ofont->olf_EEngine, OT_DeviceDPI,(72<<16) | 72, - OT_PointHeight,(ysize<<16)/FONT_SIZE_SCALE, + OT_PointHeight,ysize, TAG_END) == OTERR_Success) { return ofont; diff --git a/amiga/gui.c b/amiga/gui.c index f36f4a5df..62e98afdf 100755 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -27,6 +27,7 @@ #include "amiga/schedule.h" #include #include "content/urldb.h" +#include "css/utils.h" #include #include "desktop/history_core.h" #include @@ -105,6 +106,7 @@ #include char *default_stylesheet_url; +char *quirks_stylesheet_url; char *adblock_stylesheet_url; struct MsgPort *appport; @@ -324,6 +326,7 @@ void gui_init(int argc, char** argv) messages_load(lang); default_stylesheet_url = "file:///PROGDIR:Resources/amiga.css"; + quirks_stylesheet_url = "file:///PROGDIR:Resources/quirks.css"; adblock_stylesheet_url = "file:///PROGDIR:Resources/adblock.css"; if(hubbub_initialise("PROGDIR:Resources/Aliases",myrealloc,NULL) != HUBBUB_OK) @@ -331,7 +334,7 @@ void gui_init(int argc, char** argv) die(messages_get("NoMemory")); } - css_screen_dpi = 72; + nscss_screen_dpi = INTTOFIX(72); css_scrollbar_fg_colour = 0x00aaaaaa; css_scrollbar_bg_colour = 0x00833c3c; css_scrollbar_arrow_colour = 0x00d6d6d6; @@ -1303,7 +1306,7 @@ void ami_handle_appmsg(void) box = content->data.html.layout; while ((box = box_at_point(box, x, y, &box_x, &box_y, &content))) { - if (box->style && box->style->visibility == CSS_VISIBILITY_HIDDEN) continue; + if (box->style && css_computed_visibility(box->style) == CSS_VISIBILITY_HIDDEN) continue; if (box->gadget) { diff --git a/amiga/resources/quirks.css b/amiga/resources/quirks.css new file mode 120000 index 000000000..d9fb80334 --- /dev/null +++ b/amiga/resources/quirks.css @@ -0,0 +1 @@ +../../!NetSurf/Resources/Quirks,f79 \ No newline at end of file diff --git a/amiga/save_complete.c b/amiga/save_complete.c index 26b55adf5..2f5ebd584 100755 --- a/amiga/save_complete.c +++ b/amiga/save_complete.c @@ -120,17 +120,20 @@ bool save_complete_html(struct content *c, const char *path, bool index) return true; /* save stylesheets, ignoring the base and adblocking sheets */ - for (i = STYLESHEET_STYLE; i != c->data.html.stylesheet_count; i++) { + for (i = STYLESHEET_START; i != c->data.html.stylesheet_count; i++) { struct content *css = c->data.html.stylesheet_content[i]; char *source; int source_len; + bool is_style; if (!css) continue; if (save_complete_list_check(css)) continue; - if (i != STYLESHEET_STYLE) { + is_style = (strcmp(css->url, c->data.html.base_url) == 0); + + if (is_style == false) { if (!save_complete_list_add(css)) { warn_user("NoMemory", 0); return false; @@ -140,7 +143,7 @@ bool save_complete_html(struct content *c, const char *path, bool index) if (!save_imported_sheets(css, path)) return false; - if (i == STYLESHEET_STYLE) + if (is_style) continue; /* don't save