aboutsummaryrefslogtreecommitdiff
path: root/src/html.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/html.cc')
-rw-r--r--src/html.cc414
1 files changed, 228 insertions, 186 deletions
diff --git a/src/html.cc b/src/html.cc
index f740a77e..6622d1d0 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -119,6 +119,7 @@ typedef struct {
char EndTag; /* Is it Required, Optional or Forbidden */
uchar_t TagLevel; /* Used to heuristically parse bad HTML */
TagOpenFunct open; /* Open function */
+ TagOpenFunct content; /* Content function */
TagCloseFunct close; /* Close function */
} TagInfo;
extern const TagInfo Tags[];
@@ -284,23 +285,6 @@ static int Html_set_new_link(DilloHtml *html, DilloUrl **url)
}
/*
- * Add a new image to our list.
- * image is NULL if dillo will try to load the image immediately.
- */
-static void Html_add_new_htmlimage(DilloHtml *html,
- DilloUrl **url, DilloImage *image)
-{
- DilloHtmlImage *hi = dNew(DilloHtmlImage, 1);
- hi->url = *url;
- hi->image = image;
- a_Image_ref(image);
-
- int n = html->images->size();
- html->images->increase();
- html->images->set(n, hi);
-}
-
-/*
* Evaluates the ALIGN attribute (left|center|right|justify) and
* sets the style at the top of the stack.
*/
@@ -430,6 +414,7 @@ DilloHtml::DilloHtml(BrowserWindow *p_bw, const DilloUrl *url,
stack->getRef(0)->table_mode = DILLO_HTML_TABLE_MODE_NONE;
stack->getRef(0)->table_border_mode = DILLO_HTML_TABLE_BORDER_SEPARATE;
stack->getRef(0)->cell_text_align_set = false;
+ stack->getRef(0)->display_none = false;
stack->getRef(0)->list_type = HTML_LIST_NONE;
stack->getRef(0)->list_number = 0;
stack->getRef(0)->tag_idx = -1; /* MUST not be used */
@@ -1058,7 +1043,9 @@ static void Html_process_space(DilloHtml *html, const char *space,
int i, offset;
DilloHtmlParseMode parse_mode = S_TOP(html)->parse_mode;
- if (parse_mode == DILLO_HTML_PARSE_MODE_STASH) {
+ if (S_TOP(html)->display_none) {
+ /* do nothing */
+ } else if (parse_mode == DILLO_HTML_PARSE_MODE_STASH) {
html->StashSpace = (html->Stash->len > 0);
} else if (parse_mode == DILLO_HTML_PARSE_MODE_VERBATIM) {
@@ -1143,6 +1130,9 @@ static void Html_process_word(DilloHtml *html, const char *word, int size)
char *Pword;
DilloHtmlParseMode parse_mode = S_TOP(html)->parse_mode;
+ if (S_TOP(html)->display_none)
+ return;
+
if (parse_mode == DILLO_HTML_PARSE_MODE_STASH ||
parse_mode == DILLO_HTML_PARSE_MODE_STASH_AND_BODY) {
if (html->StashSpace) {
@@ -1314,7 +1304,8 @@ static void Html_tag_cleanup_to_idx(DilloHtml *html, int idx)
if (s_sz > idx + 1 && toptag.EndTag != 'O')
BUG_MSG(" - forcing close of open tag: <%s>\n", toptag.name);
_MSG("Close: %*s%s\n", size," ", toptag.name);
- toptag.close(html, toptag_idx);
+ if (toptag.close)
+ toptag.close(html, toptag_idx);
Html_real_pop_tag(html);
}
}
@@ -1815,8 +1806,6 @@ static void Html_tag_open_p(DilloHtml *html, const char *tag, int tagsize)
CssPropertyList props;
a_Html_tag_set_align_attr (html, tag, tagsize);
- html->styleEngine->inheritBackgroundColor ();
- HT2TB(html)->addParbreak (9, html->styleEngine->wordStyle ());
}
/*
@@ -1827,22 +1816,15 @@ static void Html_tag_open_p(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_open_frame (DilloHtml *html, const char *tag, int tagsize)
{
const char *attrbuf;
- char *src;
DilloUrl *url;
- Textblock *textblock;
- Widget *bullet;
CssPropertyList props;
- textblock = HT2TB(html);
-
if (!(attrbuf = a_Html_get_attr(html, tag, tagsize, "src")))
return;
if (!(url = a_Html_url_new(html, attrbuf, NULL, 0)))
return;
- src = dStrdup(attrbuf);
-
if (a_Capi_get_flags_with_redirection(url) & CAPI_IsCached) {
/* visited frame */
html->styleEngine->setPseudoVisited ();
@@ -1853,6 +1835,21 @@ static void Html_tag_open_frame (DilloHtml *html, const char *tag, int tagsize)
html->styleEngine->setNonCssHint (PROPERTY_X_LINK, CSS_TYPE_INTEGER,
Html_set_new_link(html,&url));
+}
+
+static void Html_tag_content_frame (DilloHtml *html, const char *tag, int tagsize)
+{
+ const char *attrbuf;
+ char *src;
+ Textblock *textblock;
+ Widget *bullet;
+
+ textblock = HT2TB(html);
+
+ if (!(attrbuf = a_Html_get_attr(html, tag, tagsize, "src")))
+ return;
+
+ src = dStrdup(attrbuf);
textblock->addParbreak (5, html->styleEngine->wordStyle ());
@@ -1885,7 +1882,7 @@ static void Html_tag_open_frame (DilloHtml *html, const char *tag, int tagsize)
* TODO: This is just a temporary fix while real frame support
* isn't finished. Imitates lynx/w3m's frames.
*/
-static void Html_tag_open_frameset (DilloHtml *html,
+static void Html_tag_content_frameset (DilloHtml *html,
const char *tag, int tagsize)
{
HT2TB(html)->addParbreak (9, html->styleEngine->wordStyle ());
@@ -1898,11 +1895,8 @@ static void Html_tag_open_frameset (DilloHtml *html,
*/
static void Html_tag_open_h(DilloHtml *html, const char *tag, int tagsize)
{
- html->styleEngine->inheritBackgroundColor ();
a_Html_tag_set_align_attr (html, tag, tagsize);
- HT2TB(html)->addParbreak (9, html->styleEngine->wordStyle ());
-
a_Html_stash_init(html);
S_TOP(html)->parse_mode =
DILLO_HTML_PARSE_MODE_STASH_AND_BODY;
@@ -1911,7 +1905,7 @@ static void Html_tag_open_h(DilloHtml *html, const char *tag, int tagsize)
/*
* <BR>
*/
-static void Html_tag_open_br(DilloHtml *html, const char *tag, int tagsize)
+static void Html_tag_content_br(DilloHtml *html, const char *tag, int tagsize)
{
HT2TB(html)->addLinebreak (html->styleEngine->wordStyle ());
}
@@ -1964,37 +1958,11 @@ static void Html_tag_open_abbr(DilloHtml *html, const char *tag, int tagsize)
}
/*
- * <CENTER>
- */
-static void Html_tag_open_center(DilloHtml *html, const char *tag, int tagsize)
-{
html->styleEngine->inheritBackgroundColor ();
- HT2TB(html)->addParbreak (0, html->styleEngine->wordStyle ());
-}
-
-/*
- * </CENTER>, also used for </TABLE>
- */
-static void Html_tag_close_center(DilloHtml *html, int TagIdx)
-{
- HT2TB(html)->addParbreak (0, html->styleEngine->wordStyle ());
-}
-
-/*
- * <ADDRESS>
- */
-static void Html_tag_open_address(DilloHtml *html,
- const char *tag, int tagsize)
-{
html->styleEngine->inheritBackgroundColor ();
- HT2TB(html)->addParbreak (9, html->styleEngine->wordStyle ());
-}
-
-/*
* Read image-associated tag attributes and create new image.
*/
-DilloImage *a_Html_image_new(DilloHtml *html, const char *tag,
- int tagsize, DilloUrl *url)
+void a_Html_image_new(DilloHtml *html, const char *tag, int tagsize)
{
DilloImage *Image;
char *width_ptr, *height_ptr, *alt_ptr;
@@ -2002,7 +1970,6 @@ DilloImage *a_Html_image_new(DilloHtml *html, const char *tag,
CssLength l_w = CSS_CREATE_LENGTH(0.0, CSS_LENGTH_TYPE_AUTO);
CssLength l_h = CSS_CREATE_LENGTH(0.0, CSS_LENGTH_TYPE_AUTO);
int space, border, w = 0, h = 0;
- bool load_now;
if (prefs.show_tooltip &&
(attrbuf = a_Html_get_attr(html, tag, tagsize, "title"))) {
@@ -2114,23 +2081,41 @@ DilloImage *a_Html_image_new(DilloHtml *html, const char *tag,
html->styleEngine->setNonCssHint (PROPERTY_X_IMG, CSS_TYPE_INTEGER,
html->images->size());
- /* Add a new image widget to this page */
Image = a_Image_new(alt_ptr, 0);
if (HT2TB(html)->getBgColor())
Image->bg_color = HT2TB(html)->getBgColor()->getColor();
- load_now = prefs.load_images ||
- !dStrAsciiCasecmp(URL_SCHEME(url), "data") ||
- (a_Capi_get_flags_with_redirection(url) & CAPI_IsCached);
- bool loading = false;
- if (load_now)
- loading = Html_load_image(html->bw, url, html->page_url, Image);
- Html_add_new_htmlimage(html, &url, loading ? NULL : Image);
+ DilloHtmlImage *hi = dNew(DilloHtmlImage, 1);
+ hi->url = NULL;
+ hi->image = Image;
+ a_Image_ref(Image);
+
+ int n = html->images->size();
+ html->images->increase();
+ html->images->set(n, hi);
dFree(width_ptr);
dFree(height_ptr);
dFree(alt_ptr);
- return Image;
+}
+
+DilloImage *a_Html_image_add(DilloHtml *html, DilloUrl *url)
+{
+ bool load_now;
+ int image_index = html->styleEngine->style()->x_img;
+ DilloHtmlImage *hi = html->images->get(image_index);
+ DilloImage *image = hi->image;
+
+ hi->url = url;
+
+ load_now = prefs.load_images ||
+ !dStrAsciiCasecmp(URL_SCHEME(url), "data") ||
+ (a_Capi_get_flags_with_redirection(url) & CAPI_IsCached);
+
+ if (load_now && Html_load_image(html->bw, url, html->page_url, image))
+ hi->image = NULL;
+
+ return image;
}
/*
@@ -2154,12 +2139,17 @@ static bool Html_load_image(BrowserWindow *bw, DilloUrl *url,
return ClientKey != 0;
}
+static void Html_tag_open_img(DilloHtml *html, const char *tag, int tagsize)
+{
+ a_Html_image_new(html, tag, tagsize);
+}
+
/*
* Create a new Image struct and request the image-url to the cache
* (If it either hits or misses, is not relevant here; that's up to the
* cache functions)
*/
-static void Html_tag_open_img(DilloHtml *html, const char *tag, int tagsize)
+static void Html_tag_content_img(DilloHtml *html, const char *tag, int tagsize)
{
DilloImage *Image;
DilloUrl *url, *usemap_url;
@@ -2178,7 +2168,8 @@ static void Html_tag_open_img(DilloHtml *html, const char *tag, int tagsize)
/* TODO: usemap URLs outside of the document are not used. */
usemap_url = a_Html_url_new(html, attrbuf, NULL, 0);
- Image = a_Html_image_new(html, tag, tagsize, url);
+ Image = a_Html_image_add(html, url);
+
HT2TB(html)->addWidget((Widget*)Image->dw, html->styleEngine->style());
/* Image maps */
@@ -2202,7 +2193,7 @@ static void Html_tag_open_img(DilloHtml *html, const char *tag, int tagsize)
/*
* <map>
*/
-static void Html_tag_open_map(DilloHtml *html, const char *tag, int tagsize)
+static void Html_tag_content_map(DilloHtml *html, const char *tag, int tagsize)
{
char *hash_name;
const char *attrbuf;
@@ -2276,7 +2267,7 @@ misc::SimpleVector<int> *Html_read_coords(DilloHtml *html, const char *str)
/*
* <AREA>
*/
-static void Html_tag_open_area(DilloHtml *html, const char *tag, int tagsize)
+static void Html_tag_content_area(DilloHtml *html, const char *tag, int tagsize)
{
enum types {UNKNOWN, RECTANGLE, CIRCLE, POLYGON, BACKGROUND};
types type;
@@ -2436,7 +2427,7 @@ static void Html_tag_open_a(DilloHtml *html, const char *tag, int tagsize)
/* TODO: add support for MAP with A HREF */
if (html->InFlags & IN_MAP)
- Html_tag_open_area(html, tag, tagsize);
+ Html_tag_content_area(html, tag, tagsize);
if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "href"))) {
/* if it's a javascript link, extract the reference. */
@@ -2562,8 +2553,6 @@ static void Html_tag_open_ul(DilloHtml *html, const char *tag, int tagsize)
CSS_TYPE_ENUM, list_style_type);
}
- Html_add_textblock(html, 9);
-
S_TOP(html)->list_type = HTML_LIST_UNORDERED;
S_TOP(html)->list_number = 0;
S_TOP(html)->ref_list_item = NULL;
@@ -2620,8 +2609,6 @@ static void Html_tag_open_ol(DilloHtml *html, const char *tag, int tagsize)
CSS_TYPE_ENUM, listStyleType);
}
- Html_add_textblock(html, 9);
-
S_TOP(html)->list_type = HTML_LIST_ORDERED;
if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "start")) &&
@@ -2639,12 +2626,8 @@ static void Html_tag_open_ol(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_open_li(DilloHtml *html, const char *tag, int tagsize)
{
Style *style = html->styleEngine->style ();
- Style *wordStyle = html->styleEngine->wordStyle ();
- Widget **ref_list_item;
- ListItem *list_item;
int *list_number;
const char *attrbuf;
- char buf[16];
if (S_TOP(html)->list_type == HTML_LIST_NONE)
BUG_MSG("<li> outside <ul> or <ol>\n");
@@ -2653,30 +2636,14 @@ static void Html_tag_open_li(DilloHtml *html, const char *tag, int tagsize)
/* Get our parent tag's variables (used as state storage) */
list_number = &html->stack->getRef(html->stack->size()-2)->list_number;
- ref_list_item = &html->stack->getRef(html->stack->size()-2)->ref_list_item;
-
- HT2TB(html)->addParbreak (0, wordStyle);
-
- list_item = new ListItem ((ListItem*)*ref_list_item,prefs.limit_text_width);
- HT2TB(html)->addWidget (list_item, style);
- HT2TB(html)->addParbreak (0, wordStyle);
- *ref_list_item = list_item;
- S_TOP(html)->textblock = html->dw = list_item;
- if (style->listStyleType == LIST_STYLE_TYPE_NONE) {
- // none
- } else if (style->listStyleType >= LIST_STYLE_TYPE_DECIMAL) {
+ if (style->listStyleType >= LIST_STYLE_TYPE_DECIMAL) {
// ordered
if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "value")) &&
(*list_number = strtol(attrbuf, NULL, 10)) < 0) {
BUG_MSG("illegal negative LIST VALUE attribute; Starting from 0\n");
*list_number = 0;
}
- numtostr((*list_number)++, buf, 16, style->listStyleType);
- list_item->initWithText (buf, wordStyle);
- } else {
- // unordered
- list_item->initWithWidget (new Bullet(), wordStyle);
}
}
@@ -2694,7 +2661,6 @@ static void Html_tag_close_li(DilloHtml *html, int TagIdx)
*/
static void Html_tag_open_hr(DilloHtml *html, const char *tag, int tagsize)
{
- Widget *hruler;
char *width_ptr;
const char *attrbuf;
int32_t size = 0;
@@ -2742,6 +2708,11 @@ static void Html_tag_open_hr(DilloHtml *html, const char *tag, int tagsize)
size_bottom);
}
+}
+
+static void Html_tag_content_hr(DilloHtml *html, const char *tag, int tagsize)
+{
+ Widget *hruler;
HT2TB(html)->addParbreak (5, html->styleEngine->wordStyle ());
hruler = new Ruler();
@@ -2794,7 +2765,6 @@ static void Html_tag_open_pre(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_close_pre(DilloHtml *html, int TagIdx)
{
html->InFlags &= ~IN_PRE;
- HT2TB(html)->addParbreak (9, html->styleEngine->wordStyle ());
}
/*
@@ -3084,14 +3054,6 @@ static void Html_tag_open_default(DilloHtml *html,const char *tag,int tagsize)
static void Html_tag_open_div(DilloHtml *html, const char *tag, int tagsize)
{
a_Html_tag_set_align_attr (html, tag, tagsize);
- Html_add_textblock(html, 0);
-}
-
-/*
- * Default close for most tags.
- */
-static void Html_tag_close_default(DilloHtml *html, int TagIdx)
-{
}
/*
@@ -3104,8 +3066,13 @@ static void Html_tag_close_par(DilloHtml *html, int TagIdx)
/*
- * Function index for the open and close functions for each tag
- * (Alphabetically sorted for a binary search)
+ * Function index for the open, content, and close functions for each tag
+ * (Alphabetically sorted for a binary search).
+ * The open and close functions are always called. They are used for style
+ * handling and HTML bug reporting.
+ * Content creation (e.g. adding new widgets or text) is done in the content
+ * function, which is not called in the display:none case.
+ * Note, that many tags don't need a content function (e.g. <div>, <span>, ...).
*
* Explanation for the 'Flags' field:
*
@@ -3122,102 +3089,115 @@ static void Html_tag_close_par(DilloHtml *html, int TagIdx)
* - Empty elements have both inline and block container clear.
* (flow have both set)
*/
+ TagOpenFunct content;
const TagInfo Tags[] = {
- {"a", B8(010101),'R',2, Html_tag_open_a, Html_tag_close_a},
- {"abbr", B8(010101),'R',2, Html_tag_open_abbr, Html_tag_close_default},
+ {"a", B8(010101),'R',2, Html_tag_open_a, NULL, Html_tag_close_a},
+ {"abbr", B8(010101),'R',2, Html_tag_open_abbr, NULL, NULL},
/* acronym 010101 */
- {"address", B8(010110),'R',2, Html_tag_open_address, Html_tag_close_par},
- {"area", B8(010001),'F',0, Html_tag_open_area, Html_tag_close_default},
- {"b", B8(010101),'R',2, Html_tag_open_default, Html_tag_close_default},
- {"base", B8(100001),'F',0, Html_tag_open_base, Html_tag_close_default},
+ {"address", B8(010110),'R',2, Html_tag_open_default, NULL, Html_tag_close_par},
+ {"area", B8(010001),'F',0, Html_tag_open_default, Html_tag_content_area,
+ NULL},
+ {"b", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
+ {"base", B8(100001),'F',0, Html_tag_open_base, NULL, NULL},
/* basefont 010001 */
/* bdo 010101 */
- {"big", B8(010101),'R',2, Html_tag_open_default, Html_tag_close_default},
- {"blockquote", B8(011110),'R',2, Html_tag_open_blockquote,
- Html_tag_close_default},
- {"body", B8(011110),'O',1, Html_tag_open_body, Html_tag_close_body},
- {"br", B8(010001),'F',0, Html_tag_open_br, Html_tag_close_default},
- {"button", B8(011101),'R',2, Html_tag_open_button, Html_tag_close_button},
+ {"big", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
+ {"blockquote", B8(011110),'R',2, Html_tag_open_blockquote, NULL,
+ NULL},
+ {"body", B8(011110),'O',1, Html_tag_open_body, NULL, Html_tag_close_body},
+ {"br", B8(010001),'F',0, Html_tag_open_default, Html_tag_content_br,
+ NULL},
+ {"button", B8(011101),'R',2, Html_tag_open_button, NULL, Html_tag_close_button},
/* caption */
- {"center", B8(011110),'R',2, Html_tag_open_center, Html_tag_close_center},
- {"cite", B8(010101),'R',2, Html_tag_open_default, Html_tag_close_default},
- {"code", B8(010101),'R',2, Html_tag_open_default, Html_tag_close_default},
+ {"center", B8(011110),'R',2, Html_tag_open_default, NULL, NULL},
+ {"cite", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
+ {"code", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
/* col 010010 'F' */
/* colgroup */
- {"dd", B8(011110),'O',1, Html_tag_open_dd, Html_tag_close_default},
- {"del", B8(011101),'R',2, Html_tag_open_default, Html_tag_close_default},
- {"dfn", B8(010101),'R',2, Html_tag_open_default, Html_tag_close_default},
- {"dir", B8(011010),'R',2, Html_tag_open_dir, Html_tag_close_par},
+ {"dd", B8(011110),'O',1, Html_tag_open_dd, NULL, NULL},
+ {"del", B8(011101),'R',2, Html_tag_open_default, NULL, NULL},
+ {"dfn", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
+ {"dir", B8(011010),'R',2, Html_tag_open_dir, NULL, Html_tag_close_par},
/* TODO: complete <div> support! */
- {"div", B8(011110),'R',2, Html_tag_open_div, Html_tag_close_default},
- {"dl", B8(011010),'R',2, Html_tag_open_dl, Html_tag_close_par},
- {"dt", B8(010110),'O',1, Html_tag_open_dt, Html_tag_close_par},
- {"em", B8(010101),'R',2, Html_tag_open_default, Html_tag_close_default},
+ {"div", B8(011110),'R',2, Html_tag_open_div, NULL, NULL},
+ {"dl", B8(011010),'R',2, Html_tag_open_dl, NULL, Html_tag_close_par},
+ {"dt", B8(010110),'O',1, Html_tag_open_dt, NULL, Html_tag_close_par},
+ {"em", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
/* fieldset */
- {"font", B8(010101),'R',2, Html_tag_open_font, Html_tag_close_default},
- {"form", B8(011110),'R',2, Html_tag_open_form, Html_tag_close_form},
- {"frame", B8(010010),'F',0, Html_tag_open_frame, Html_tag_close_default},
- {"frameset", B8(011110),'R',2,Html_tag_open_frameset, Html_tag_close_default},
- {"h1", B8(010110),'R',2, Html_tag_open_h, Html_tag_close_par},
- {"h2", B8(010110),'R',2, Html_tag_open_h, Html_tag_close_par},
- {"h3", B8(010110),'R',2, Html_tag_open_h, Html_tag_close_par},
- {"h4", B8(010110),'R',2, Html_tag_open_h, Html_tag_close_par},
- {"h5", B8(010110),'R',2, Html_tag_open_h, Html_tag_close_par},
- {"h6", B8(010110),'R',2, Html_tag_open_h, Html_tag_close_par},
- {"head", B8(101101),'O',1, Html_tag_open_head, Html_tag_close_head},
- {"hr", B8(010010),'F',0, Html_tag_open_hr, Html_tag_close_default},
- {"html", B8(001110),'O',1, Html_tag_open_html, Html_tag_close_html},
- {"i", B8(010101),'R',2, Html_tag_open_default, Html_tag_close_default},
- {"iframe", B8(011110),'R',2, Html_tag_open_frame, Html_tag_close_default},
- {"img", B8(010001),'F',0, Html_tag_open_img, Html_tag_close_default},
- {"input", B8(010001),'F',0, Html_tag_open_input, Html_tag_close_default},
+ {"font", B8(010101),'R',2, Html_tag_open_font, NULL, NULL},
+ {"form", B8(011110),'R',2, Html_tag_open_form, NULL, Html_tag_close_form},
+ {"frame", B8(010010),'F',0, Html_tag_open_frame, Html_tag_content_frame,
+ NULL},
+ {"frameset", B8(011110),'R',2, Html_tag_open_default, Html_tag_content_frameset,
+ NULL},
+ {"h1", B8(010110),'R',2, Html_tag_open_h, NULL, NULL},
+ {"h2", B8(010110),'R',2, Html_tag_open_h, NULL, NULL},
+ {"h3", B8(010110),'R',2, Html_tag_open_h, NULL, NULL},
+ {"h4", B8(010110),'R',2, Html_tag_open_h, NULL, NULL},
+ {"h5", B8(010110),'R',2, Html_tag_open_h, NULL, NULL},
+ {"h6", B8(010110),'R',2, Html_tag_open_h, NULL, NULL},
+ {"head", B8(101101),'O',1, Html_tag_open_head, NULL, Html_tag_close_head},
+ {"hr", B8(010010),'F',0, Html_tag_open_hr, Html_tag_content_hr,
+ NULL},
+ {"html", B8(001110),'O',1, Html_tag_open_html, NULL, Html_tag_close_html},
+ {"i", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
+ {"iframe", B8(011110),'R',2, Html_tag_open_frame, NULL, NULL},
+ {"img", B8(010001),'F',0, Html_tag_open_img, Html_tag_content_img,
+ NULL},
+ {"input", B8(010001),'F',0, Html_tag_open_input, NULL, NULL},
/* ins */
- {"isindex", B8(110001),'F',0, Html_tag_open_isindex, Html_tag_close_default},
- {"kbd", B8(010101),'R',2, Html_tag_open_default, Html_tag_close_default},
+ {"isindex", B8(110001),'F',0, Html_tag_open_isindex, NULL, NULL},
+ {"kbd", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
/* label 010101 */
/* legend 01?? */
- {"li", B8(011110),'O',1, Html_tag_open_li, Html_tag_close_li},
- {"link", B8(100001),'F',0, Html_tag_open_link, Html_tag_close_default},
- {"map", B8(011001),'R',2, Html_tag_open_map, Html_tag_close_map},
+ {"li", B8(011110),'O',1, Html_tag_open_li, NULL, Html_tag_close_li},
+ {"link", B8(100001),'F',0, Html_tag_open_link, NULL, NULL},
+ {"map", B8(011001),'R',2, Html_tag_open_default, Html_tag_content_map,
+ Html_tag_close_map},
/* menu 1010 -- TODO: not exactly 1010, it can contain LI and inline */
- {"menu", B8(011010),'R',2, Html_tag_open_menu, Html_tag_close_par},
- {"meta", B8(100001),'F',0, Html_tag_open_meta, Html_tag_close_default},
+ {"menu", B8(011010),'R',2, Html_tag_open_menu, NULL, Html_tag_close_par},
+ {"meta", B8(100001),'F',0, Html_tag_open_meta, NULL, NULL},
/* noframes 1011 */
/* noscript 1011 */
- {"object", B8(111101),'R',2, Html_tag_open_object, Html_tag_close_default},
- {"ol", B8(011010),'R',2, Html_tag_open_ol, Html_tag_close_default},
+ {"object", B8(111101),'R',2, Html_tag_open_object, NULL, NULL},
+ {"ol", B8(011010),'R',2, Html_tag_open_ol, NULL, NULL},
/* optgroup */
- {"option", B8(010001),'O',1, Html_tag_open_option, Html_tag_close_default},
- {"p", B8(010110),'O',1, Html_tag_open_p, Html_tag_close_par},
+ {"option", B8(010001),'O',1, Html_tag_open_option, NULL, NULL},
+ {"p", B8(010110),'O',1, Html_tag_open_p, NULL, NULL},
/* param 010001 'F' */
- {"pre", B8(010110),'R',2, Html_tag_open_pre, Html_tag_close_pre},
- {"q", B8(010101),'R',2, Html_tag_open_q, Html_tag_close_q},
- {"s", B8(010101),'R',2, Html_tag_open_default, Html_tag_close_default},
- {"samp", B8(010101),'R',2, Html_tag_open_default, Html_tag_close_default},
- {"script", B8(111001),'R',2, Html_tag_open_script, Html_tag_close_script},
- {"select", B8(010101),'R',2, Html_tag_open_select, Html_tag_close_select},
- {"small", B8(010101),'R',2, Html_tag_open_default, Html_tag_close_default},
- {"span", B8(010101),'R',2, Html_tag_open_default, Html_tag_close_default},
- {"strike", B8(010101),'R',2, Html_tag_open_default, Html_tag_close_default},
- {"strong", B8(010101),'R',2, Html_tag_open_default, Html_tag_close_default},
- {"style", B8(100101),'R',2, Html_tag_open_style, Html_tag_close_style},
- {"sub", B8(010101),'R',2, Html_tag_open_default, Html_tag_close_default},
- {"sup", B8(010101),'R',2, Html_tag_open_default, Html_tag_close_default},
- {"table", B8(011010),'R',5, Html_tag_open_table, Html_tag_close_center},
+ {"pre", B8(010110),'R',2, Html_tag_open_pre, NULL, Html_tag_close_pre},
+ {"q", B8(010101),'R',2, Html_tag_open_q, NULL, Html_tag_close_q},
+ {"s", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
+ {"samp", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
+ {"script", B8(111001),'R',2, Html_tag_open_script, NULL, Html_tag_close_script},
+ {"select", B8(010101),'R',2, Html_tag_open_select, NULL, Html_tag_close_select},
+ {"small", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
+ {"span", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
+ {"strike", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
+ {"strong", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
+ {"style", B8(100101),'R',2, Html_tag_open_style, NULL, Html_tag_close_style},
+ {"sub", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
+ {"sup", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
+ {"table", B8(011010),'R',5, Html_tag_open_table, Html_tag_content_table,
+ NULL},
/* tbody */
- {"td", B8(011110),'O',3, Html_tag_open_td, Html_tag_close_default},
- {"textarea", B8(010101),'R',2,Html_tag_open_textarea,Html_tag_close_textarea},
+ {"td", B8(011110),'O',3, Html_tag_open_td, Html_tag_content_td,
+ NULL},
+ {"textarea", B8(010101),'R',2,Html_tag_open_textarea, Html_tag_content_textarea,
+ Html_tag_close_textarea},
/* tfoot */
- {"th", B8(011110),'O',1, Html_tag_open_th, Html_tag_close_default},
+ {"th", B8(011110),'O',1, Html_tag_open_th, Html_tag_content_th,
+ NULL},
/* thead */
- {"title", B8(100101),'R',2, Html_tag_open_title, Html_tag_close_title},
- {"tr", B8(011010),'O',4, Html_tag_open_tr, Html_tag_close_default},
- {"tt", B8(010101),'R',2, Html_tag_open_default, Html_tag_close_default},
- {"u", B8(010101),'R',2, Html_tag_open_default, Html_tag_close_default},
- {"ul", B8(011010),'R',2, Html_tag_open_ul, Html_tag_close_default},
- {"var", B8(010101),'R',2, Html_tag_open_default, Html_tag_close_default}
+ {"title", B8(100101),'R',2, Html_tag_open_title, NULL, Html_tag_close_title},
+ {"tr", B8(011010),'O',4, Html_tag_open_tr, Html_tag_content_tr,
+ NULL},
+ {"tt", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
+ {"u", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
+ {"ul", B8(011010),'R',2, Html_tag_open_ul, NULL, NULL},
+ {"var", B8(010101),'R',2, Html_tag_open_default, NULL, NULL}
};
#define NTAGS (sizeof(Tags)/sizeof(Tags[0]))
@@ -3457,6 +3437,45 @@ static void Html_parse_common_attrs(DilloHtml *html, char *tag, int tagsize)
}
+static void Html_display_block(DilloHtml *html)
+{
+ //HT2TB(html)->addParbreak (5, html->styleEngine->wordStyle ());
+ Html_add_textblock(html, 0);
+}
+
+static void Html_display_listitem(DilloHtml *html)
+{
+ Style *style = html->styleEngine->style ();
+ Style *wordStyle = html->styleEngine->wordStyle ();
+ Widget **ref_list_item;
+ ListItem *list_item;
+ int *list_number;
+ char buf[16];
+
+ /* Get our parent tag's variables (used as state storage) */
+ list_number = &html->stack->getRef(html->stack->size()-2)->list_number;
+ ref_list_item = &html->stack->getRef(html->stack->size()-2)->ref_list_item;
+
+ HT2TB(html)->addParbreak (0, wordStyle);
+
+ list_item = new ListItem ((ListItem*)*ref_list_item,prefs.limit_text_width);
+ HT2TB(html)->addWidget (list_item, style);
+ HT2TB(html)->addParbreak (0, wordStyle);
+ *ref_list_item = list_item;
+ S_TOP(html)->textblock = html->dw = list_item;
+
+ if (style->listStyleType == LIST_STYLE_TYPE_NONE) {
+ // none
+ } else if (style->listStyleType >= LIST_STYLE_TYPE_DECIMAL) {
+ // ordered
+ numtostr((*list_number)++, buf, 16, style->listStyleType);
+ list_item->initWithText (buf, wordStyle);
+ } else {
+ // unordered
+ list_item->initWithWidget (new Bullet(), wordStyle);
+ }
+}
+
/*
* Process a tag, given as 'tag' and 'tagsize'. -- tagsize is [1 based]
* ('tag' must include the enclosing angle brackets)
@@ -3513,6 +3532,29 @@ static void Html_process_tag(DilloHtml *html, char *tag, int tagsize)
/* Call the open function for this tag */
_MSG("Open : %s\n", Tags[ni].name);
Tags[ni].open (html, tag, tagsize);
+
+ if (! S_TOP(html)->display_none) {
+ switch (html->styleEngine->style ()->display) {
+ case DISPLAY_BLOCK:
+ Html_display_block(html);
+ break;
+ case DISPLAY_LIST_ITEM:
+ Html_display_listitem(html);
+ break;
+ case DISPLAY_NONE:
+ S_TOP(html)->display_none = true;
+ break;
+ case DISPLAY_INLINE:
+ case DISPLAY_INLINE_BLOCK: // TODO: implement inline-block
+ default:
+ break;
+ }
+
+ if (Tags[ni].content && ! S_TOP(html)->display_none) {
+ Tags[ni].content (html, tag, tagsize);
+ }
+ }
+
if (html->stop_parser)
break;