diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2010-08-20 23:24:19 +0200 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2010-08-20 23:24:19 +0200 |
commit | f5c598b518d1f906148534d015f50075d3e8242d (patch) | |
tree | 21dd70add5b366c3dd80641b77f6b18e0baa009e /src/html_common.hh | |
parent | e98d02a01ffeb18ede86af025e51ae1ec011c75a (diff) | |
parent | 5f0fc0e48b8cbee7e1795935da0abff6627fd498 (diff) |
merge
Diffstat (limited to 'src/html_common.hh')
-rw-r--r-- | src/html_common.hh | 86 |
1 files changed, 34 insertions, 52 deletions
diff --git a/src/html_common.hh b/src/html_common.hh index c694123e..3cca82de 100644 --- a/src/html_common.hh +++ b/src/html_common.hh @@ -13,12 +13,14 @@ #include "form.hh" +#include "styleengine.hh" + /* - * Macros + * Macros */ -// Dw to Textblock -#define DW2TB(dw) ((Textblock*)dw) +// "html struct" to Textblock +#define HT2TB(html) ((Textblock*)(html->dw)) // "html struct" to "Layout" #define HT2LT(html) ((Layout*)html->bw->render_layout) // "Image" to "Dw Widget" @@ -33,32 +35,15 @@ } D_STMT_END /* - * Change one toplevel attribute. var should be an identifier. val is - * only evaluated once, so you can safely use a function call for it. + * Typedefs */ -#define HTML_SET_TOP_ATTR(html, var, val) \ - do { \ - StyleAttrs style_attrs; \ - Style *old_style; \ - \ - old_style = S_TOP(html)->style; \ - style_attrs = *old_style; \ - style_attrs.var = (val); \ - S_TOP(html)->style = \ - Style::create (HT2LT(html), &style_attrs); \ - old_style->unref (); \ - } while (FALSE) -/* - * Typedefs - */ - -typedef struct _DilloLinkImage DilloLinkImage; +typedef struct _DilloHtmlImage DilloHtmlImage; typedef struct _DilloHtmlState DilloHtmlState; typedef enum { - DT_NONE, - DT_HTML, + DT_NONE, + DT_HTML, DT_XHTML } DilloHtmlDocumentType; @@ -100,16 +85,16 @@ typedef enum { } DilloHtmlProcessingState; /* - * Data Structures + * Data Structures */ -struct _DilloLinkImage { +struct _DilloHtmlImage { DilloUrl *url; DilloImage *image; }; struct _DilloHtmlState { - dw::core::style::Style *style, *table_cell_style; + CssPropertyList *table_cell_props; DilloHtmlParseMode parse_mode; DilloHtmlTableMode table_mode; bool cell_text_align_set; @@ -124,10 +109,6 @@ struct _DilloHtmlState { /* This is used to align list items (especially in enumerated lists) */ dw::core::Widget *ref_list_item; - /* This makes image processing faster than a function - a_Dw_widget_get_background_color. */ - int32_t current_bg_color; - /* This is used for list items etc; if it is set to TRUE, breaks have to be "handed over" (see Html_add_indented and Html_eventually_pop_dw). */ @@ -135,12 +116,12 @@ struct _DilloHtmlState { }; /* - * Classes + * Classes */ class DilloHtml { private: - class HtmlLinkReceiver: public dw::core::Widget::LinkReceiver { + class HtmlLinkReceiver: public dw::core::Layout::LinkReceiver { public: DilloHtml *html; @@ -161,7 +142,6 @@ public: //BUG: for now everything is public /* -------------------------------------------------------------------*/ /* Variables required at parsing time */ /* -------------------------------------------------------------------*/ - size_t Buf_Consumed; /* amount of source from cache consumed */ char *Start_Buf; int Start_Ofs; char *content_type, *charset; @@ -173,7 +153,11 @@ public: //BUG: for now everything is public DilloHtmlDocumentType DocType; /* as given by DOCTYPE tag */ float DocTypeVersion; /* HTML or XHTML version number */ + /* vector of remote CSS resources, as given by the LINK element */ + lout::misc::SimpleVector<DilloUrl*> *cssUrls; + lout::misc::SimpleVector<DilloHtmlState> *stack; + StyleEngine *styleEngine; int InFlags; /* tracks which elements we are in */ @@ -184,33 +168,30 @@ public: //BUG: for now everything is public bool PreFirstChar; /* used to skip the first CR or CRLF in PRE tags */ bool PrevWasCR; /* Flag to help parsing of "\r\n" in PRE tags */ bool PrevWasOpenTag; /* Flag to help deferred parsing of white space */ - bool PrevWasSPC; /* Flag to help handling collapsing white space */ bool InVisitedLink; /* used to 'contrast_visited_colors' */ bool ReqTagClose; /* Flag to help handling bad-formed HTML */ - bool CloseOneTag; /* Flag to help Html_tag_cleanup_at_close() */ - bool WordAfterLI; /* Flag to help ignoring the 1st <P> after <LI> */ bool TagSoup; /* Flag to enable the parser's cleanup functions */ - char *NameVal; /* used for validation of "NAME" and "ID" in <A> */ + bool loadCssFromStash; /* current stash content should be loaded as CSS */ /* element counters: used for validation purposes */ uchar_t Num_HTML, Num_HEAD, Num_BODY, Num_TITLE; Dstr *attr_data; /* Buffer for attribute value */ + int32_t non_css_link_color; /* as provided by link attribute in BODY */ + int32_t non_css_visited_color; /* as provided by vlink attribute in BODY */ + int32_t visited_color; /* as computed according to CSS */ + /* -------------------------------------------------------------------*/ /* Variables required after parsing (for page functionality) */ /* -------------------------------------------------------------------*/ lout::misc::SimpleVector<DilloHtmlForm*> *forms; lout::misc::SimpleVector<DilloHtmlInput*> *inputs_outside_form; lout::misc::SimpleVector<DilloUrl*> *links; - lout::misc::SimpleVector<DilloLinkImage*> *images; + lout::misc::SimpleVector<DilloHtmlImage*> *images; dw::ImageMapsList maps; - int32_t link_color; - int32_t visited_color; - private: - bool parse_finished; void freeParseData(); void initDw(); /* Used by the constructor */ @@ -227,12 +208,15 @@ public: DilloHtmlForm *getCurrentForm (); bool_t unloadedImages(); void loadImages (const DilloUrl *pattern); + void addCssUrl(const DilloUrl *url); }; /* - * Parser functions + * Parser functions */ +int a_Html_tag_index(const char *tag); + const char *a_Html_get_attr(DilloHtml *html, const char *tag, int tagsize, @@ -248,10 +232,8 @@ DilloUrl *a_Html_url_new(DilloHtml *html, const char *url_str, const char *base_url, int use_base_url); -DilloImage *a_Html_add_new_image(DilloHtml *html, const char *tag, - int tagsize, DilloUrl *url, - dw::core::style::StyleAttrs *style_attrs, - bool add); +DilloImage *a_Html_image_new(DilloHtml *html, const char *tag, + int tagsize, DilloUrl *url); char *a_Html_parse_entities(DilloHtml *html, const char *token, int toksize); void a_Html_pop_tag(DilloHtml *html, int TagIdx); @@ -260,12 +242,12 @@ int32_t a_Html_color_parse(DilloHtml *html, const char *subtag, int32_t default_color); dw::core::style::Length a_Html_parse_length (DilloHtml *html, const char *attr); -void a_Html_tag_set_align_attr(DilloHtml *html, +void a_Html_tag_set_align_attr(DilloHtml *html, CssPropertyList *props, const char *tag, int tagsize); bool a_Html_tag_set_valign_attr(DilloHtml *html, const char *tag, int tagsize, - dw::core::style::StyleAttrs *style_attrs); -void a_Html_set_top_font(DilloHtml *html, const char *name, int size, - int BI, int BImask); + CssPropertyList *props); + +void a_Html_load_stylesheet(DilloHtml *html, DilloUrl *url); #endif /* __HTML_COMMON_HH__ */ |