Dillo v3.1.1-111-gd4f56d0d
Loading...
Searching...
No Matches
html.cc File Reference

Dillo HTML parsing routines. More...

#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include "bw.h"
#include "msg.h"
#include "binaryconst.h"
#include "colors.h"
#include "html_charrefs.h"
#include "utf8.hh"
#include "misc.h"
#include "uicmd.hh"
#include "history.h"
#include "menu.hh"
#include "prefs.h"
#include "capi.h"
#include "html.hh"
#include "html_common.hh"
#include "form.hh"
#include "table.hh"
#include "dw/textblock.hh"
#include "dw/bullet.hh"
#include "dw/listitem.hh"
#include "dw/image.hh"
#include "dw/ruler.hh"
Include dependency graph for html.cc:

Go to the source code of this file.

Macros

#define SGML_SPCDEL   0
 
#define TAB_SIZE   8
 
#define NTAGS   (sizeof(Tags)/sizeof(Tags[0]))
 

Typedefs

typedef void(* TagOpenFunct) (DilloHtml *html, const char *tag, int tagsize)
 
typedef void(* TagCloseFunct) (DilloHtml *html)
 

Enumerations

enum  DilloHtmlTagParsingState {
  SEEK_ATTR_START , MATCH_ATTR_NAME , SEEK_TOKEN_START , SEEK_VALUE_START ,
  SKIP_VALUE , GET_VALUE , FINISHED
}
 
enum  DilloHtmlTagParsingFlags { HTML_LeftTrim = 1 << 0 , HTML_RightTrim = 1 << 1 , HTML_ParseEntities = 1 << 2 }
 

Functions

void * a_Html_text (const char *Type, void *P, CA_Callback_t *Call, void **Data)
 Set callback function and callback data for the "html/text" MIME type.
 
static int Html_write_raw (DilloHtml *html, char *buf, int bufsize, int Eof)
 Here's where we parse the html and put it into the Textblock structure.
 
static bool Html_load_image (BrowserWindow *bw, DilloUrl *url, const DilloUrl *requester, DilloImage *Image)
 Tell cache to retrieve image.
 
static void Html_callback (int Op, CacheClient_t *Client)
 Dispatch the apropriate function for 'Op'.
 
static void Html_tag_cleanup_at_close (DilloHtml *html, int new_idx)
 Conditional cleanup of the stack, called before closing any tag.
 
int a_Html_tag_index (const char *tag)
 Get 'tag' index.
 
DilloUrla_Html_url_new (DilloHtml *html, const char *url_str, const char *base_url, int use_base_url)
 Wrapper for a_Url_new that adds an error detection message.
 
static void Html_free (void *data)
 
void a_Html_load_images (void *v_html, DilloUrl *pattern)
 Used by the "Load images" page menuitem.
 
static bool Html_contains_form (DilloHtml *html, void *v_form)
 Search for form.
 
void a_Html_form_submit (void *v_html, void *v_form)
 Used by the "Submit form" form menuitem.
 
void a_Html_form_reset (void *v_html, void *v_form)
 Used by the "Reset form" form menuitem.
 
void a_Html_form_display_hiddens (void *v_html, void *v_form, bool_t display)
 Used by the "Show/Hide hiddens" form menuitem.
 
static void Html_set_link_coordinates (DilloHtml *html, int link, int x, int y)
 Set the URL data for image maps.
 
static int Html_set_new_link (DilloHtml *html, DilloUrl **url)
 Create a new link, set it as the url's parent and return the index.
 
void a_Html_tag_set_align_attr (DilloHtml *html, const char *tag, int tagsize)
 Evaluates the ALIGN attribute (left|center|right|justify) and sets the style at the top of the stack.
 
bool a_Html_tag_set_valign_attr (DilloHtml *html, const char *tag, int tagsize)
 Evaluates the VALIGN attribute (top|bottom|middle|baseline) and sets the style in style_attrs.
 
static void Html_add_textblock (DilloHtml *html, bool addBreaks, int breakSpace, bool addBreakOpt)
 Create and add a new Textblock to the current Textblock.
 
static bool Html_must_add_breaks (DilloHtml *html)
 
void a_Html_stash_init (DilloHtml *html)
 Initialize the stash buffer.
 
static int Html_ms_stupid_quotes_2ucs (int codepoint)
 This is M$ non-standard "smart quotes" (w1252).
 
static const char * Html_parse_numeric_charref (DilloHtml *html, char *tok, bool_t is_attr, int *entsize)
 Parse a numeric character reference (e.g., "&#47;" or "&#x2F;").
 
static int Html_charref_comp (const void *a, const void *b)
 Comparison function for binary search.
 
static Charref_tHtml_charref_search (char *key)
 Binary search of 'key' in charref list.
 
static const char * Html_parse_named_charref (DilloHtml *html, char *tok, bool_t is_attr, int *entsize)
 Parse a named character reference (e.g., "&amp;" or "&hellip;").
 
static const char * Html_parse_entity (DilloHtml *html, const char *token, int toksize, int *entsize, bool_t is_attr)
 Given an entity, return the corresponding string.
 
char * a_Html_parse_entities (DilloHtml *html, const char *token, int toksize)
 Parse all the entities in a token.
 
static void Html_process_space_pre_line (DilloHtml *html, const char *space, int spacesize)
 For white-space: pre-line, we must break the line if encountering a newline.
 
static void Html_process_space (DilloHtml *html, const char *space, int spacesize)
 Parse spaces.
 
static void Html_process_word (DilloHtml *html, const char *word, int size)
 Handles putting the word into its proper place.
 
static bool Html_match_tag (const char *tagstr, char *tag, int tagsize)
 Does the tag in tagstr (e.g.
 
static void Html_eventually_pop_dw (DilloHtml *html, bool hand_over_break)
 This function is called after popping the stack, to handle nested Textblock widgets.
 
static void Html_push_tag (DilloHtml *html, int tag_idx)
 Push the tag (copying attributes from the top of the stack)
 
static void Html_force_push_tag (DilloHtml *html, int tag_idx)
 Push the tag (used to force en element with optional open into the stack).
 
static void Html_real_pop_tag (DilloHtml *html)
 Pop the top tag in the stack.
 
static CssLength Html_parse_length_or_multi_length (const char *attr, char **endptr)
 
CssLength a_Html_parse_length (DilloHtml *html, const char *attr)
 Returns a length or a percentage, or UNDEF_LENGTH in case of an error, or if attr is NULL.
 
int32_t a_Html_color_parse (DilloHtml *html, const char *str, int32_t default_color)
 Parse a color attribute.
 
static int Html_check_name_val (DilloHtml *html, const char *val, const char *attrname)
 Check that 'val' is composed of characters inside [A-Za-z0-9:_.
 
static void Html_parse_doctype (DilloHtml *html, const char *tag, int tagsize)
 Handle DOCTYPE declaration.
 
static void Html_tag_open_html (DilloHtml *html, const char *tag, int tagsize)
 Handle open HTML element.
 
static void Html_tag_close_html (DilloHtml *html)
 Handle close HTML element.
 
static void Html_tag_open_head (DilloHtml *html, const char *tag, int tagsize)
 Handle open HEAD element.
 
static void Html_tag_close_head (DilloHtml *html)
 Handle close HEAD element.
 
static void Html_tag_open_title (DilloHtml *html, const char *tag, int tagsize)
 Handle open TITLE.
 
static void Html_tag_close_title (DilloHtml *html)
 Handle close TITLE.
 
static void Html_tag_open_script (DilloHtml *html, const char *tag, int tagsize)
 Handle open SCRIPT.
 
static void Html_tag_close_script (DilloHtml *html)
 Handle close SCRIPT.
 
static void Html_tag_open_style (DilloHtml *html, const char *tag, int tagsize)
 Handle open STYLE.
 
static void Html_tag_close_style (DilloHtml *html)
 Handle close STYLE.
 
static void Html_tag_open_body (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_close_body (DilloHtml *html)
 
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)
 
static void Html_tag_content_frame (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_content_frameset (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_open_h (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_content_br (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_open_font (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_open_abbr (DilloHtml *html, const char *tag, int tagsize)
 
void a_Html_common_image_attrs (DilloHtml *html, const char *tag, int tagsize)
 Read image-associated tag attributes and create new image.
 
DilloImagea_Html_image_new (DilloHtml *html, const char *tag, int tagsize)
 
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)
 Create a new Image struct and request the image-url to the cache.
 
static void Html_tag_content_map (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_close_map (DilloHtml *html)
 Handle close <MAP>.
 
static misc::SimpleVector< int > * Html_read_coords (DilloHtml *html, const char *str)
 Read coords in a string, returning a vector of ints.
 
static void Html_tag_content_area (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_open_object (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_content_object (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_open_video (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_open_audio (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_open_source (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_content_source (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_close_media (DilloHtml *html)
 Media (AUDIO/VIDEO) close function.
 
static void Html_tag_open_embed (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_content_embed (DilloHtml *html, const char *tag, int tagsize)
 
static const char * Html_get_javascript_link (DilloHtml *html)
 Test and extract the link from a javascript instruction.
 
static void Html_add_anchor (DilloHtml *html, const char *name)
 Register an anchor for this page.
 
static void Html_tag_open_a (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_close_a (DilloHtml *html)
 
static void Html_tag_open_blockquote (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_open_q (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_close_q (DilloHtml *html)
 
static void Html_tag_open_ul (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_open_dir (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_open_menu (DilloHtml *html, const char *tag, int tagsize)
 
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)
 
static void Html_tag_close_li (DilloHtml *html)
 
static void Html_tag_open_hr (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_content_hr (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_open_dl (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_open_dt (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_open_dd (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_open_pre (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_close_pre (DilloHtml *html)
 
static int Html_tag_pre_excludes (DilloHtml *html, int tag_idx)
 Check whether a tag is in the "excluding" element set for PRE.
 
static void Html_update_content_type (DilloHtml *html, const char *content)
 Update the document's content type information based on meta tag data.
 
static void Html_tag_open_meta (DilloHtml *html, const char *tag, int tagsize)
 Handle META We do not support http-equiv=refresh with delay>0 because it's non standard, (the HTML 4.01 SPEC recommends explicitly to avoid it).
 
static void Html_css_load_callback (int Op, CacheClient_t *Client)
 Called by the network engine when a stylesheet has new data.
 
void a_Html_load_stylesheet (DilloHtml *html, DilloUrl *url)
 Tell cache to retrieve a stylesheet.
 
static void Html_tag_open_link (DilloHtml *html, const char *tag, int tagsize)
 Parse the LINK element (Only CSS stylesheets by now).
 
static void Html_tag_open_base (DilloHtml *html, const char *tag, int tagsize)
 Set the Document Base URI.
 
static void Html_tag_open_default (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_open_span (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_open_sectioning (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_open_div (DilloHtml *html, const char *tag, int tagsize)
 
static void Html_tag_close_par (DilloHtml *html)
 Default close for paragraph tags - pop the stack and break.
 
static void Html_tag_content_wbr (DilloHtml *html, const char *tag, int tagsize)
 
static int Html_tag_compare (const char *p1, const char *p2)
 
static int Html_triggers_optional_close (int old_idx, int cur_idx)
 For elements with optional close, check whether is time to close, by also following Firefox's de facto rules.
 
static int Html_forbids_cross_nesting (const int InFlags, const int new_idx)
 Check nesting and cross-nesting between BUTTON, SELECT, TEXTAREA and A.
 
static void Html_tag_cleanup_to_idx (DilloHtml *html, int s_idx, int new_idx, int fi, char op)
 Cleanup the stack to a given index.
 
static void Html_stack_cleanup_at_open (DilloHtml *html, int ni)
 Conditional cleanup of the stack (at open time).
 
static void Html_test_section (DilloHtml *html, int new_idx, int IsCloseTag)
 HTML, HEAD and BODY elements have optional open and close tags.
 
static void Html_parse_common_attrs (DilloHtml *html, char *tag, int tagsize)
 Parse attributes that can appear on any tag.
 
static void Html_check_html5_obsolete (DilloHtml *html, int ni)
 Warn when encountering elements that are obsolete in HTML5.
 
static void Html_display_block (DilloHtml *html)
 
static void Html_display_inline_block (DilloHtml *html)
 
static void Html_display_listitem (DilloHtml *html)
 
static void Html_process_tag (DilloHtml *html, char *tag, int tagsize)
 Process a tag, given as 'tag' and 'tagsize'.
 
static const char * Html_get_attr2 (DilloHtml *html, const char *tag, int tagsize, const char *attrname, int tag_parsing_flags)
 Get attribute value for 'attrname' and return it.
 
const char * a_Html_get_attr (DilloHtml *html, const char *tag, int tagsize, const char *attrname)
 Call Html_get_attr2 telling it to parse entities and strip the result.
 
char * a_Html_get_attr_wdef (DilloHtml *html, const char *tag, int tagsize, const char *attrname, const char *def)
 "a_Html_get_attr with default" Call a_Html_get_attr() and dStrdup() the returned string.
 

Variables

static int i_A = a_Html_tag_index("a")
 
static int i_BODY = a_Html_tag_index("body")
 
static int i_BUTTON = a_Html_tag_index("button")
 
static int i_DD = a_Html_tag_index("dd")
 
static int i_DT = a_Html_tag_index("dt")
 
static int i_HTML = a_Html_tag_index("html")
 
static int i_HR = a_Html_tag_index("hr")
 
static int i_LI = a_Html_tag_index("li")
 
static int i_OPTGROUP = a_Html_tag_index("optgroup")
 
static int i_OPTION = a_Html_tag_index("option")
 
static int i_P = a_Html_tag_index("p")
 
static int i_SELECT = a_Html_tag_index("select")
 
static int i_TEXTAREA = a_Html_tag_index("textarea")
 
static int i_TD = a_Html_tag_index("td")
 
static int i_TR = a_Html_tag_index("tr")
 
static int i_TBODY = a_Html_tag_index("tbody")
 
static int i_TH = a_Html_tag_index("th")
 
static const TagInfo Tags []
 Function index for the open, content, and close functions for each tag.
 

Detailed Description

Dillo HTML parsing routines.

Definition in file html.cc.

Macro Definition Documentation

◆ NTAGS

#define NTAGS   (sizeof(Tags)/sizeof(Tags[0]))

Definition at line 3582 of file html.cc.

◆ SGML_SPCDEL

#define SGML_SPCDEL   0

Definition at line 56 of file html.cc.

◆ TAB_SIZE

#define TAB_SIZE   8

Definition at line 58 of file html.cc.

Typedef Documentation

◆ TagCloseFunct

typedef void(* TagCloseFunct) (DilloHtml *html)

Definition at line 74 of file html.cc.

◆ TagOpenFunct

typedef void(* TagOpenFunct) (DilloHtml *html, const char *tag, int tagsize)

Definition at line 73 of file html.cc.

Enumeration Type Documentation

◆ DilloHtmlTagParsingFlags

Enumerator
HTML_LeftTrim 
HTML_RightTrim 
HTML_ParseEntities 

Definition at line 86 of file html.cc.

◆ DilloHtmlTagParsingState

Enumerator
SEEK_ATTR_START 
MATCH_ATTR_NAME 
SEEK_TOKEN_START 
SEEK_VALUE_START 
SKIP_VALUE 
GET_VALUE 
FINISHED 

Definition at line 76 of file html.cc.

Function Documentation

◆ a_Html_color_parse()

int32_t a_Html_color_parse ( DilloHtml html,
const char *  str,
int32_t  default_color 
)

Parse a color attribute.

Return value: parsed color, or default_color (+ error msg) on error.

Definition at line 1458 of file html.cc.

References a_Color_parse(), and BUG_MSG.

Referenced by Html_tag_open_body(), Html_tag_open_font(), Html_tag_open_table(), Html_tag_open_table_cell(), and Html_tag_open_tr().

◆ a_Html_common_image_attrs()

◆ a_Html_form_display_hiddens()

void a_Html_form_display_hiddens ( void *  v_html,
void *  v_form,
bool_t  display 
)

Used by the "Show/Hide hiddens" form menuitem.

Definition at line 279 of file html.cc.

References a_Html_form_display_hiddens2(), and Html_contains_form().

Referenced by Menu_form_hiddens_cb().

◆ a_Html_form_reset()

void a_Html_form_reset ( void *  v_html,
void *  v_form 
)

Used by the "Reset form" form menuitem.

Definition at line 266 of file html.cc.

References a_Html_form_reset2(), and Html_contains_form().

Referenced by Menu_form_reset_cb().

◆ a_Html_form_submit()

void a_Html_form_submit ( void *  v_html,
void *  v_form 
)

Used by the "Submit form" form menuitem.

Definition at line 253 of file html.cc.

References a_Html_form_submit2(), and Html_contains_form().

Referenced by Menu_form_submit_cb().

◆ a_Html_get_attr()

◆ a_Html_get_attr_wdef()

char * a_Html_get_attr_wdef ( DilloHtml html,
const char *  tag,
int  tagsize,
const char *  attrname,
const char *  def 
)

"a_Html_get_attr with default" Call a_Html_get_attr() and dStrdup() the returned string.

If the attribute isn't found a copy of 'def' is returned.

Definition at line 4281 of file html.cc.

References a_Html_get_attr(), and dStrdup().

Referenced by a_Html_common_image_attrs(), a_Html_image_new(), Html_tag_open_button(), Html_tag_open_hr(), Html_tag_open_input(), Html_tag_open_optgroup(), Html_tag_open_option(), and Html_tag_open_select().

◆ a_Html_image_new()

◆ a_Html_load_images()

void a_Html_load_images ( void *  v_html,
DilloUrl pattern 
)

Used by the "Load images" page menuitem.

Definition at line 230 of file html.cc.

References DilloHtml::loadImages().

Referenced by Menu_imgload_toggle_cb(), and Menu_load_images_cb().

◆ a_Html_load_stylesheet()

◆ a_Html_parse_entities()

char * a_Html_parse_entities ( DilloHtml html,
const char *  token,
int  toksize 
)

Parse all the entities in a token.

Takes the token and its length, and returns a newly allocated string.

Definition at line 1070 of file html.cc.

References dStr_append(), dStr_append_c(), dStr_append_l(), dStr_free(), dStr_sized_new(), dStrndup(), FALSE, Html_parse_entity(), and Dstr::str.

Referenced by Html_process_word(), and Html_tag_close_textarea().

◆ a_Html_parse_length()

CssLength a_Html_parse_length ( DilloHtml html,
const char *  attr 
)

Returns a length or a percentage, or UNDEF_LENGTH in case of an error, or if attr is NULL.

Definition at line 1433 of file html.cc.

References _MSG, BUG_MSG, CSS_CREATE_LENGTH(), CSS_LENGTH_TYPE(), CSS_LENGTH_TYPE_AUTO, CSS_LENGTH_TYPE_RELATIVE, CSS_LENGTH_VALUE(), and Html_parse_length_or_multi_length().

Referenced by a_Html_common_image_attrs(), Html_tag_open_hr(), Html_tag_open_table(), and Html_tag_open_table_cell().

◆ a_Html_stash_init()

◆ a_Html_tag_index()

int a_Html_tag_index ( const char *  tag)

◆ a_Html_tag_set_align_attr()

◆ a_Html_tag_set_valign_attr()

bool a_Html_tag_set_valign_attr ( DilloHtml html,
const char *  tag,
int  tagsize 
)

◆ a_Html_text()

void * a_Html_text ( const char *  type,
void *  P,
CA_Callback_t Call,
void **  Data 
)

Set callback function and callback data for the "html/text" MIME type.

Function prototypes defined elsewhere.

Definition at line 211 of file html.cc.

References _DilloWeb::bw, DilloHtml::dw, Html_callback(), and _DilloWeb::url.

Referenced by a_Mime_init().

◆ a_Html_url_new()

DilloUrl * a_Html_url_new ( DilloHtml html,
const char *  url_str,
const char *  base_url,
int  use_base_url 
)

◆ Html_add_anchor()

static void Html_add_anchor ( DilloHtml html,
const char *  name 
)
static

Register an anchor for this page.

Definition at line 2675 of file html.cc.

References _MSG, BUG_MSG, HT2TB, and DilloHtml::style().

Referenced by Html_process_tag(), and Html_tag_open_a().

◆ Html_add_textblock()

static void Html_add_textblock ( DilloHtml html,
bool  addBreaks,
int  breakSpace,
bool  addBreakOpt 
)
static

◆ Html_callback()

static void Html_callback ( int  Op,
CacheClient_t Client 
)
static

Dispatch the apropriate function for 'Op'.

This function is a Cache client and gets called whenever new data arrives

Parameters
Opoperation to perform.
CbDataa pointer to a DilloHtml structure
Bufa pointer to new data
BufSizenew data size (in bytes)

Definition at line 4300 of file html.cc.

References CacheClient::Buf, CacheClient::BufSize, CacheClient::CbData, DilloHtml::finishParsing(), CacheClient::Key, and DilloHtml::write().

Referenced by a_Html_text().

◆ Html_charref_comp()

static int Html_charref_comp ( const void *  a,
const void *  b 
)
static

Comparison function for binary search.

Definition at line 958 of file html.cc.

Referenced by Html_charref_search().

◆ Html_charref_search()

static Charref_t * Html_charref_search ( char *  key)
static

Binary search of 'key' in charref list.

Definition at line 966 of file html.cc.

References Charrefs, Html_charref_comp(), NumRef, and Charref_t::ref.

Referenced by Html_parse_named_charref().

◆ Html_check_html5_obsolete()

static void Html_check_html5_obsolete ( DilloHtml html,
int  ni 
)
static

Warn when encountering elements that are obsolete in HTML5.

This list was from the "W3C Candidate Recommendation 6 August 2013".

Definition at line 3952 of file html.cc.

References a_Html_tag_index(), BUG_MSG, and Tags.

Referenced by Html_process_tag().

◆ Html_check_name_val()

static int Html_check_name_val ( DilloHtml html,
const char *  val,
const char *  attrname 
)
static

Check that 'val' is composed of characters inside [A-Za-z0-9:_.

-]. Note: ID can't have entities, but this check is enough (no '&'). Return value: 1 if OK, 0 otherwise.

Definition at line 1476 of file html.cc.

References BUG_MSG, d_isascii, DilloHtml::DocType, DilloHtml::DocTypeVersion, and DT_HTML.

Referenced by Html_parse_common_attrs(), and Html_tag_open_a().

◆ Html_contains_form()

static bool Html_contains_form ( DilloHtml html,
void *  v_form 
)
static

◆ Html_css_load_callback()

static void Html_css_load_callback ( int  Op,
CacheClient_t Client 
)
static

Called by the network engine when a stylesheet has new data.

Definition at line 3233 of file html.cc.

References _MSG, a_UIcmd_repush(), DilloHtml::bw, BrowserWindow::NumPendingStyleSheets, and CacheClient::Web.

Referenced by a_Html_load_stylesheet().

◆ Html_display_block()

static void Html_display_block ( DilloHtml html)
static

Definition at line 3975 of file html.cc.

References Html_add_textblock(), and Html_must_add_breaks().

Referenced by Html_process_tag().

◆ Html_display_inline_block()

static void Html_display_inline_block ( DilloHtml html)
static

Definition at line 3981 of file html.cc.

References Html_add_textblock().

Referenced by Html_process_tag().

◆ Html_display_listitem()

◆ Html_eventually_pop_dw()

static void Html_eventually_pop_dw ( DilloHtml html,
bool  hand_over_break 
)
static

This function is called after popping the stack, to handle nested Textblock widgets.

Definition at line 1336 of file html.cc.

References DilloHtml::dw, HT2TB, S_TOP, and DilloHtml::style().

Referenced by Html_real_pop_tag().

◆ Html_forbids_cross_nesting()

static int Html_forbids_cross_nesting ( const int  InFlags,
const int  new_idx 
)
inlinestatic

Check nesting and cross-nesting between BUTTON, SELECT, TEXTAREA and A.

The cleanup process will close any of them before opening another. This is not an HTML SPEC restriction , but it avoids lots of trouble inside dillo (concurrent inputs), and makes almost no sense to have. return: index of the open element, -1 if none.

Definition at line 3676 of file html.cc.

References i_A, i_BUTTON, i_SELECT, i_TEXTAREA, IN_A, IN_BUTTON, IN_SELECT, IN_TEXTAREA, and DilloHtml::InFlags.

Referenced by Html_stack_cleanup_at_open().

◆ Html_force_push_tag()

static void Html_force_push_tag ( DilloHtml html,
int  tag_idx 
)
static

Push the tag (used to force en element with optional open into the stack).

Note: now it's the same as Html_push_tag(), but things may change...

Definition at line 1366 of file html.cc.

References Html_push_tag(), and DilloHtml::startElement().

Referenced by Html_test_section().

◆ Html_free()

static void Html_free ( void *  data)
static

Definition at line 222 of file html.cc.

Referenced by DilloHtml::DilloHtml().

◆ Html_get_attr2()

static const char * Html_get_attr2 ( DilloHtml html,
const char *  tag,
int  tagsize,
const char *  attrname,
int  tag_parsing_flags 
)
static

Get attribute value for 'attrname' and return it.

Tags start with '<' and end with a '>' (Ex: "<P align=center>") tagsize = strlen(tag) from '<' to '>', inclusive.

Returns one of the following:

  • The value of the attribute.
  • An empty string if the attribute exists but has no value.
  • NULL if the attribute doesn't exist.

Definition at line 4164 of file html.cc.

References DilloHtml::attr_data, D_ASCII_TOLOWER, dReturn_val_if_fail, dStr_append(), dStr_append_c(), dStr_erase(), dStr_truncate(), FINISHED, GET_VALUE, HTML_LeftTrim, Html_parse_entity(), HTML_ParseEntities, HTML_RightTrim, Dstr::len, MATCH_ATTR_NAME, SEEK_ATTR_START, SEEK_TOKEN_START, SEEK_VALUE_START, SKIP_VALUE, Dstr::str, and TRUE.

Referenced by a_Html_get_attr().

◆ Html_get_javascript_link()

static const char * Html_get_javascript_link ( DilloHtml html)
static

Test and extract the link from a javascript instruction.

Definition at line 2652 of file html.cc.

References DilloHtml::attr_data, BUG_MSG, dStr_erase(), dStr_truncate(), dStrnAsciiCasecmp(), and Dstr::str.

Referenced by Html_tag_open_a().

◆ Html_load_image()

static bool Html_load_image ( BrowserWindow bw,
DilloUrl url,
const DilloUrl requester,
DilloImage image 
)
static

◆ Html_match_tag()

static bool Html_match_tag ( const char *  tagstr,
char *  tag,
int  tagsize 
)
static

Does the tag in tagstr (e.g.

"p") match the tag in the tag, tagsize structure, with the initial < skipped over (e.g. "P align=center>")?

Definition at line 1318 of file html.cc.

References D_ASCII_TOLOWER.

Referenced by Html_write_raw().

◆ Html_ms_stupid_quotes_2ucs()

static int Html_ms_stupid_quotes_2ucs ( int  codepoint)
static

This is M$ non-standard "smart quotes" (w1252).

Now even deprecated by them!

SGML for HTML4.01 defines c >= 128 and c <= 159 as UNUSED. TODO: Probably I should remove this hack. –Jcid

Definition at line 856 of file html.cc.

Referenced by Html_parse_numeric_charref().

◆ Html_must_add_breaks()

static bool Html_must_add_breaks ( DilloHtml html)
static

Definition at line 424 of file html.cc.

References HT2TB, and DilloHtml::style().

Referenced by Html_display_block().

◆ Html_parse_common_attrs()

static void Html_parse_common_attrs ( DilloHtml html,
char *  tag,
int  tagsize 
)
static

◆ Html_parse_doctype()

static void Html_parse_doctype ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

Handle DOCTYPE declaration.

Follows the convention that HTML 4.01 doctypes which include a full w3c DTD url are treated as standards-compliant, but 4.01 without the url and HTML 4.0 and earlier are not. XHTML doctypes are always standards-compliant whether or not an url is present.

Note: I'm not sure about this convention. The W3C validator recognizes the "HTML Level" with or without the URL. The convention comes from mozilla (see URLs below), but Dillo doesn't have the same rendering modes, so it may be better to chose another behaviour. –Jcid

http://www.mozilla.org/docs/web-developer/quirks/doctypes.html http://lists.dillo.org/pipermail/dillo-dev/2004-October/002300.html

This is not a full DOCTYPE parser, just enough for what Dillo uses.

Definition at line 1520 of file html.cc.

References _MSG, BUG_MSG, dFree(), DilloHtml::DocType, DilloHtml::DocTypeVersion, dStrAsciiCasecmp(), dStriAsciiStr(), dStrnAsciiCasecmp(), dStrndup(), DT_HTML, DT_NONE, DT_UNRECOGNIZED, and DT_XHTML.

Referenced by Html_process_tag().

◆ Html_parse_entity()

static const char * Html_parse_entity ( DilloHtml html,
const char *  token,
int  toksize,
int *  entsize,
bool_t  is_attr 
)
static

Given an entity, return the corresponding string.

Returns NULL if not a valid entity.

The first character *token is assumed to be == '&'

For valid entities, *entsize is set to the length of the parsed entity.

Definition at line 1035 of file html.cc.

References BUG_MSG, dFree(), DilloHtml::DocType, DilloHtml::DocTypeVersion, dStrndup(), DT_HTML, Html_parse_named_charref(), Html_parse_numeric_charref(), prefs, and DilloPrefs::show_extra_warnings.

Referenced by a_Html_parse_entities(), and Html_get_attr2().

◆ Html_parse_length_or_multi_length()

static CssLength Html_parse_length_or_multi_length ( const char *  attr,
char **  endptr 
)
static

◆ Html_parse_named_charref()

static const char * Html_parse_named_charref ( DilloHtml html,
char *  tok,
bool_t  is_attr,
int *  entsize 
)
static

Parse a named character reference (e.g., "&amp;" or "&hellip;").

The "&" has already been consumed.

Definition at line 979 of file html.cc.

References BUG_MSG, DilloHtml::DocType, DilloHtml::DocTypeVersion, DT_HTML, DT_XHTML, Charref_t::html4_str, Charref_t::html5_str, Html_charref_search(), prefs, and DilloPrefs::show_extra_warnings.

Referenced by Html_parse_entity().

◆ Html_parse_numeric_charref()

static const char * Html_parse_numeric_charref ( DilloHtml html,
char *  tok,
bool_t  is_attr,
int *  entsize 
)
static

Parse a numeric character reference (e.g., "&#47;" or "&#x2F;").

The "&#" has already been consumed.

Definition at line 876 of file html.cc.

References a_Utf8_encode(), BUG_MSG, DilloHtml::DocType, DilloHtml::DocTypeVersion, DT_HTML, DT_XHTML, Html_ms_stupid_quotes_2ucs(), prefs, and DilloPrefs::show_extra_warnings.

Referenced by Html_parse_entity().

◆ Html_process_space()

◆ Html_process_space_pre_line()

static void Html_process_space_pre_line ( DilloHtml html,
const char *  space,
int  spacesize 
)
static

For white-space: pre-line, we must break the line if encountering a newline.

Otherwise, collapse whitespace as usual.

Definition at line 1108 of file html.cc.

References HT2TB, DilloHtml::PrevWasCR, and DilloHtml::wordStyle().

Referenced by Html_process_space().

◆ Html_process_tag()

static void Html_process_tag ( DilloHtml html,
char *  tag,
int  tagsize 
)
static

Process a tag, given as 'tag' and 'tagsize'.

– tagsize is [1 based] ('tag' must include the enclosing angle brackets) This function calls the right open or close function for the tag.

Definition at line 4024 of file html.cc.

References _MSG, a_Html_tag_index(), BUG_MSG, DILLO_HTML_PARSE_MODE_PRE, DILLO_HTML_PARSE_MODE_VERBATIM, dw::core::style::StyleAttrs::display, dw::core::style::DISPLAY_BLOCK, dw::core::style::DISPLAY_INLINE, dw::core::style::DISPLAY_INLINE_BLOCK, dw::core::style::DISPLAY_LIST_ITEM, dw::core::style::DISPLAY_NONE, DilloHtml::DocType, DilloHtml::DocTypeVersion, dReturn_if, dStrnAsciiCasecmp(), DT_HTML, dw::core::style::FLOAT_NONE, StyleEngine::getId(), Html_add_anchor(), Html_check_html5_obsolete(), Html_display_block(), Html_display_inline_block(), Html_display_listitem(), Html_parse_common_attrs(), Html_parse_doctype(), Html_push_tag(), Html_stack_cleanup_at_open(), Html_tag_cleanup_at_close(), Html_tag_pre_excludes(), Html_test_section(), i_HTML, IN_BODY, IN_HTML, IN_PRE, DilloHtml::InFlags, DilloHtml::pre_column, DilloHtml::PreFirstChar, DilloHtml::PrevWasBodyClose, DilloHtml::PrevWasHtmlClose, DilloHtml::ReqTagClose, S_TOP, lout::misc::SimpleVector< T >::size(), DilloHtml::stack, DilloHtml::startElement(), DilloHtml::stop_parser, DilloHtml::style(), DilloHtml::styleEngine, Tags, dw::core::style::StyleAttrs::vloat, dw::core::style::WHITE_SPACE_PRE, dw::core::style::WHITE_SPACE_PRE_WRAP, and dw::core::style::StyleAttrs::whiteSpace.

Referenced by Html_write_raw().

◆ Html_process_word()

static void Html_process_word ( DilloHtml html,
const char *  word,
int  size 
)
static

Handles putting the word into its proper place.

  • STASH and VERBATIM --> html->Stash
  • otherwise it goes through addText()

Entities are parsed (or not) according to parse_mode. 'word' is a '\0'-terminated string.

Definition at line 1216 of file html.cc.

References a_Html_parse_entities(), a_Utf8_ideographic(), BUG_MSG, dFree(), DILLO_HTML_PARSE_MODE_PRE, DILLO_HTML_PARSE_MODE_STASH, DILLO_HTML_PARSE_MODE_STASH_AND_BODY, DILLO_HTML_PARSE_MODE_VERBATIM, dStr_append(), dStr_append_c(), dStr_append_l(), HT2TB, Html_process_space(), DilloHtml::pre_column, DilloHtml::PreFirstChar, DilloHtml::PrevWasBodyClose, DilloHtml::PrevWasHtmlClose, S_TOP, DilloHtml::Stash, DilloHtml::StashSpace, utf8_zero_width_space, and DilloHtml::wordStyle().

Referenced by Html_write_raw().

◆ Html_push_tag()

static void Html_push_tag ( DilloHtml html,
int  tag_idx 
)
static

◆ Html_read_coords()

static misc::SimpleVector< int > * Html_read_coords ( DilloHtml html,
const char *  str 
)
static

Read coords in a string, returning a vector of ints.

Definition at line 2366 of file html.cc.

References BUG_MSG, lout::misc::SimpleVector< T >::increase(), lout::misc::SimpleVector< T >::set(), and lout::misc::SimpleVector< T >::size().

Referenced by Html_tag_content_area().

◆ Html_real_pop_tag()

static void Html_real_pop_tag ( DilloHtml html)
static

◆ Html_set_link_coordinates()

static void Html_set_link_coordinates ( DilloHtml html,
int  link,
int  x,
int  y 
)
static

Set the URL data for image maps.

Definition at line 292 of file html.cc.

References a_Url_set_ismap_coords(), lout::misc::SimpleVector< T >::get(), and DilloHtml::links.

Referenced by DilloHtml::HtmlLinkReceiver::click(), and DilloHtml::HtmlLinkReceiver::enter().

◆ Html_set_new_link()

static int Html_set_new_link ( DilloHtml html,
DilloUrl **  url 
)
static

◆ Html_stack_cleanup_at_open()

static void Html_stack_cleanup_at_open ( DilloHtml html,
int  ni 
)
static

Conditional cleanup of the stack (at open time).

Handles:

  • Forbidden cross nesting (a BUG).
  • Block elements inside non block containers (a BUG).
  • Elements with "optional" close tag (OK).

This function is called before opening/pushing a new tag into the stack. 'ni' is the new tag's index in Tags[].

Definition at line 3747 of file html.cc.

References BUG_MSG, DilloHtml::DocTypeVersion, lout::misc::SimpleVector< T >::getRef(), Html_forbids_cross_nesting(), Html_tag_cleanup_to_idx(), Html_triggers_optional_close(), i_A, i_HR, IN_PRE, DilloHtml::InFlags, lout::misc::SimpleVector< T >::size(), DilloHtml::stack, DilloHtmlState::tag_idx, Tags, and DilloHtml::TagSoup.

Referenced by Html_process_tag().

◆ Html_tag_cleanup_at_close()

static void Html_tag_cleanup_at_close ( DilloHtml html,
int  new_idx 
)
static

Conditional cleanup of the stack, called before closing any tag.

There are several ways of doing it. Considering the HTML 4.01 spec which defines optional close tags, and the will to deliver useful diagnose messages for bad-formed HTML, it'll go as follows:

  1. Search the stack for a matching tag by closing elements that: have optional close | are inline in a block container | force closing.
  2. If it exists, clean all the tags in between.
  3. Cleanup the matching tag. (on error, give a warning message)

Definition at line 3797 of file html.cc.

References BUG_MSG, lout::misc::SimpleVector< T >::getRef(), Html_tag_cleanup_to_idx(), i_A, i_BUTTON, i_SELECT, i_TEXTAREA, IN_A, IN_BUTTON, IN_SELECT, IN_TEXTAREA, DilloHtml::InFlags, lout::misc::SimpleVector< T >::size(), DilloHtml::stack, DilloHtmlState::tag_idx, and Tags.

Referenced by DilloHtml::finishParsing(), Html_process_tag(), and Html_test_section().

◆ Html_tag_cleanup_to_idx()

static void Html_tag_cleanup_to_idx ( DilloHtml html,
int  s_idx,
int  new_idx,
int  fi,
char  op 
)
static

Cleanup the stack to a given index.

's_idx' stack index to clean up to. 'new_idx' is the tag index that triggered the cleanup. 'fi' forbidden tag index. -1 if allowed (most of the time). 'op' cleanup operation. {'o' = open, 'c' = close}.

Definition at line 3695 of file html.cc.

References _MSG, BUG_MSG, Html_real_pop_tag(), i_BODY, IN_EOF, DilloHtml::InFlags, DilloHtml::PrevWasBodyClose, DilloHtml::PrevWasHtmlClose, DilloHtml::ReqTagClose, S_TOP, lout::misc::SimpleVector< T >::size(), DilloHtml::stack, and Tags.

Referenced by Html_stack_cleanup_at_open(), and Html_tag_cleanup_at_close().

◆ Html_tag_close_a()

static void Html_tag_close_a ( DilloHtml html)
static

Definition at line 2764 of file html.cc.

References DilloHtml::InFlags, and DilloHtml::InVisitedLink.

◆ Html_tag_close_body()

static void Html_tag_close_body ( DilloHtml html)
static

Definition at line 1889 of file html.cc.

References _MSG, and DilloHtml::Num_BODY.

◆ Html_tag_close_head()

static void Html_tag_close_head ( DilloHtml html)
static

Handle close HEAD element.

Note: HEAD is parsed once completely got.

Definition at line 1662 of file html.cc.

References a_Html_load_stylesheet(), BUG_MSG, DilloHtml::cssUrls, lout::misc::SimpleVector< T >::get(), IN_HEAD, DilloHtml::InFlags, DilloHtml::Num_HEAD, DilloHtml::Num_TITLE, and lout::misc::SimpleVector< T >::size().

◆ Html_tag_close_html()

static void Html_tag_close_html ( DilloHtml html)
static

Handle close HTML element.

Definition at line 1625 of file html.cc.

References _MSG, and DilloHtml::Num_HTML.

◆ Html_tag_close_li()

static void Html_tag_close_li ( DilloHtml html)
static

Definition at line 2943 of file html.cc.

References DilloHtml::dw, and DilloHtml::InFlags.

◆ Html_tag_close_map()

◆ Html_tag_close_media()

static void Html_tag_close_media ( DilloHtml html)
static

Media (AUDIO/VIDEO) close function.

Definition at line 2614 of file html.cc.

References DilloHtml::InFlags.

◆ Html_tag_close_par()

static void Html_tag_close_par ( DilloHtml html)
static

Default close for paragraph tags - pop the stack and break.

Definition at line 3428 of file html.cc.

References HT2TB, and DilloHtml::wordStyle().

◆ Html_tag_close_pre()

static void Html_tag_close_pre ( DilloHtml html)
static

Definition at line 3062 of file html.cc.

References DilloHtml::InFlags.

◆ Html_tag_close_q()

static void Html_tag_close_q ( DilloHtml html)
static

Definition at line 2797 of file html.cc.

References HT2TB, and DilloHtml::wordStyle().

◆ Html_tag_close_script()

static void Html_tag_close_script ( DilloHtml html)
static

Handle close SCRIPT.

Definition at line 1735 of file html.cc.

◆ Html_tag_close_style()

static void Html_tag_close_style ( DilloHtml html)
static

◆ Html_tag_close_title()

static void Html_tag_close_title ( DilloHtml html)
static

Handle close TITLE.

set page-title in the browser window and in the history.

Definition at line 1708 of file html.cc.

References a_History_set_title_by_url(), a_UIcmd_set_page_title(), DilloHtml::bw, IN_HEAD, DilloHtml::InFlags, DilloHtml::Num_TITLE, DilloHtml::page_url, DilloHtml::Stash, and Dstr::str.

◆ Html_tag_compare()

static int Html_tag_compare ( const char *  p1,
const char *  p2 
)
static

Definition at line 3595 of file html.cc.

References D_ASCII_TOLOWER.

Referenced by a_Html_tag_index().

◆ Html_tag_content_area()

◆ Html_tag_content_br()

static void Html_tag_content_br ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

Definition at line 2008 of file html.cc.

References HT2TB, and DilloHtml::wordStyle().

◆ Html_tag_content_embed()

static void Html_tag_content_embed ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

Definition at line 2643 of file html.cc.

References a_Html_get_attr(), HT2TB, and DilloHtml::wordStyle().

◆ Html_tag_content_frame()

static void Html_tag_content_frame ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

◆ Html_tag_content_frameset()

static void Html_tag_content_frameset ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

Definition at line 1985 of file html.cc.

References HT2TB, Html_add_textblock(), and DilloHtml::wordStyle().

◆ Html_tag_content_hr()

static void Html_tag_content_hr ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

◆ Html_tag_content_img()

static void Html_tag_content_img ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

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)

Definition at line 2269 of file html.cc.

References _MSG, a_Html_get_attr(), a_Html_image_new(), a_Html_url_new(), a_Url_free(), DilloHtml::base_url, HT2TB, DilloHtml::maps, dw::Image::setIsMap(), dw::Image::setUseMap(), DilloHtml::style(), URL_FLAGS, URL_SpamSafe, URL_STR, and dw::core::style::StyleAttrs::x_link.

◆ Html_tag_content_map()

static void Html_tag_content_map ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

◆ Html_tag_content_object()

static void Html_tag_content_object ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

Definition at line 2500 of file html.cc.

References a_Html_get_attr(), HT2TB, and DilloHtml::wordStyle().

◆ Html_tag_content_source()

static void Html_tag_content_source ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

Definition at line 2604 of file html.cc.

References a_Html_get_attr(), HT2TB, IN_MEDIA, DilloHtml::InFlags, and DilloHtml::wordStyle().

◆ Html_tag_content_wbr()

static void Html_tag_content_wbr ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

Definition at line 3436 of file html.cc.

References HT2TB, and DilloHtml::wordStyle().

◆ Html_tag_open_a()

◆ Html_tag_open_abbr()

static void Html_tag_open_abbr ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

◆ Html_tag_open_audio()

◆ Html_tag_open_base()

static void Html_tag_open_base ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

◆ Html_tag_open_blockquote()

static void Html_tag_open_blockquote ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

Definition at line 2773 of file html.cc.

References Html_add_textblock().

◆ Html_tag_open_body()

◆ Html_tag_open_dd()

static void Html_tag_open_dd ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

Definition at line 3043 of file html.cc.

References Html_add_textblock().

◆ Html_tag_open_default()

static void Html_tag_open_default ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

Definition at line 3378 of file html.cc.

References StyleEngine::inheritBackgroundColor(), and DilloHtml::styleEngine.

◆ Html_tag_open_dir()

static void Html_tag_open_dir ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

◆ Html_tag_open_div()

static void Html_tag_open_div ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

Definition at line 3419 of file html.cc.

References a_Html_tag_set_align_attr(), and Html_tag_open_sectioning().

◆ Html_tag_open_dl()

static void Html_tag_open_dl ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

◆ Html_tag_open_dt()

static void Html_tag_open_dt ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

◆ Html_tag_open_embed()

◆ Html_tag_open_font()

◆ Html_tag_open_frame()

◆ Html_tag_open_h()

static void Html_tag_open_h ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

◆ Html_tag_open_head()

static void Html_tag_open_head ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

Handle open HEAD element.

Definition at line 1637 of file html.cc.

References BUG_MSG, IN_BODY, IN_HEAD, DilloHtml::InFlags, DilloHtml::Num_HEAD, and DilloHtml::ReqTagClose.

◆ Html_tag_open_hr()

◆ Html_tag_open_html()

static void Html_tag_open_html ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

Handle open HTML element.

Definition at line 1606 of file html.cc.

References BUG_MSG, IN_HTML, DilloHtml::InFlags, DilloHtml::Num_HTML, and DilloHtml::ReqTagClose.

◆ Html_tag_open_img()

◆ Html_tag_open_li()

◆ Html_tag_open_link()

static void Html_tag_open_link ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

Parse the LINK element (Only CSS stylesheets by now).

(If it either hits or misses, is not relevant here; that's up to the cache functions)

TODO: How will we know when to use "handheld"? Ask the html->bw->ui for screen dimensions, or a dillorc preference.

Definition at line 3299 of file html.cc.

References _MSG, a_Html_get_attr(), a_Html_url_new(), a_Url_free(), DilloHtml::addCssUrl(), DilloHtml::base_url, BUG_MSG, DilloHtml::DocType, DilloHtml::DocTypeVersion, dReturn_if, dReturn_if_fail, dStrAsciiCasecmp(), dStriAsciiStr(), DT_HTML, IN_HEAD, DilloHtml::InFlags, DilloPrefs::load_stylesheets, prefs, URL_FLAGS, URL_SpamSafe, and URL_STR.

◆ Html_tag_open_menu()

static void Html_tag_open_menu ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

Definition at line 2857 of file html.cc.

References DilloHtml::DocType, DilloHtml::DocTypeVersion, DT_HTML, and Html_tag_open_dir().

◆ Html_tag_open_meta()

static void Html_tag_open_meta ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

Handle META We do not support http-equiv=refresh with delay>0 because it's non standard, (the HTML 4.01 SPEC recommends explicitly to avoid it).

More info at: http://lists.w3.org/Archives/Public/www-html/2000Feb/thread.html#msg232 Instant client-side redirects (delay=0) are supported: http://www.w3.org/TR/2008/NOTE-WCAG20-TECHS-20081211/H76.html

TODO: Note that we're sending custom HTML while still IN_HEAD. This is a hackish way to put the message. A much cleaner approach is to build a custom widget for it.

Definition at line 3120 of file html.cc.

References _MSG, a_Capi_dpi_verify_request(), a_Html_get_attr(), a_Html_url_new(), a_UIcmd_redirection0(), a_UIcmd_set_msg(), a_Url_cmp(), a_Url_free(), DilloHtml::base_url, BUG_MSG, DilloHtml::bw, DilloHtml::charset, dFree(), DilloHtml::DocType, DilloHtml::DocTypeVersion, dStr_free(), dStr_sized_new(), dStr_sprintf(), dStrAsciiCasecmp(), dStrconcat(), dStrdup(), dStriAsciiStr(), dStrndup(), DT_HTML, Html_update_content_type(), Html_write_raw(), IN_BODY, IN_HEAD, IN_META_HACK, DilloHtml::InFlags, Dstr::len, DilloHtml::stop_parser, Dstr::str, DilloHtml::TagSoup, URL_FLAGS, URL_SpamSafe, and URL_STR.

◆ Html_tag_open_object()

◆ Html_tag_open_ol()

◆ Html_tag_open_p()

static void Html_tag_open_p ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

Definition at line 1903 of file html.cc.

References a_Html_tag_set_align_attr().

◆ Html_tag_open_pre()

static void Html_tag_open_pre ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

◆ Html_tag_open_q()

static void Html_tag_open_q ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

◆ Html_tag_open_script()

static void Html_tag_open_script ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

Handle open SCRIPT.

initializes stash, where the embedded code will be stored. MODE_VERBATIM is used because MODE_STASH catches entities.

Definition at line 1726 of file html.cc.

References a_Html_stash_init(), DILLO_HTML_PARSE_MODE_VERBATIM, and S_TOP.

◆ Html_tag_open_sectioning()

static void Html_tag_open_sectioning ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

◆ Html_tag_open_source()

◆ Html_tag_open_span()

static void Html_tag_open_span ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

◆ Html_tag_open_style()

static void Html_tag_open_style ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

Handle open STYLE.

Store contents in the stash where the style sheet interpreter can get it.

Definition at line 1744 of file html.cc.

References a_Html_get_attr(), a_Html_stash_init(), BUG_MSG, DILLO_HTML_PARSE_MODE_VERBATIM, DilloHtml::DocType, DilloHtml::DocTypeVersion, dStrAsciiCasecmp(), dStriAsciiStr(), DT_HTML, DilloHtml::loadCssFromStash, and S_TOP.

◆ Html_tag_open_title()

static void Html_tag_open_title ( DilloHtml html,
const char *  tag,
int  tagsize 
)
static

Handle open TITLE.

calls stash init, where the title string will be stored

Definition at line 1688 of file html.cc.

References a_Html_stash_init(), BUG_MSG, IN_HEAD, DilloHtml::InFlags, and DilloHtml::Num_TITLE.

◆ Html_tag_open_ul()

◆ Html_tag_open_video()

◆ Html_tag_pre_excludes()

static int Html_tag_pre_excludes ( DilloHtml html,
int  tag_idx 
)
static

Check whether a tag is in the "excluding" element set for PRE.

Excl. Set = {IMG, OBJECT, APPLET, BIG, SMALL, SUB, SUP, FONT, BASEFONT}

Definition at line 3071 of file html.cc.

References a_Html_tag_index(), DilloHtml::DocType, DilloHtml::DocTypeVersion, and DT_HTML.

Referenced by Html_process_tag().

◆ Html_test_section()

static void Html_test_section ( DilloHtml html,
int  new_idx,
int  IsCloseTag 
)
static

HTML, HEAD and BODY elements have optional open and close tags.

Handle this "magic" here.

Definition at line 3844 of file html.cc.

References _MSG, a_Html_tag_index(), BUG_MSG, DilloHtml::DocType, DT_NONE, Html_force_push_tag(), Html_tag_cleanup_at_close(), IN_HEAD, IN_HTML, DilloHtml::InFlags, DilloHtml::Num_HEAD, lout::misc::SimpleVector< T >::size(), DilloHtml::stack, and Tags.

Referenced by Html_process_tag().

◆ Html_triggers_optional_close()

static int Html_triggers_optional_close ( int  old_idx,
int  cur_idx 
)
static

For elements with optional close, check whether is time to close, by also following Firefox's de facto rules.

Called at open time.

Return value: (1: Close, 0: Don't close) –tuned for speed.

Definition at line 3637 of file html.cc.

References i_DD, i_DT, i_LI, i_OPTGROUP, i_OPTION, i_P, i_TBODY, i_TD, i_TH, i_TR, and Tags.

Referenced by Html_stack_cleanup_at_open().

◆ Html_update_content_type()

static void Html_update_content_type ( DilloHtml html,
const char *  content 
)
static

Update the document's content type information based on meta tag data.

Definition at line 3094 of file html.cc.

References a_Capi_set_content_type(), a_Misc_content_type_cmp(), a_UIcmd_repush(), DilloHtml::bw, DilloHtml::content_type, DilloHtml::page_url, and DilloHtml::stop_parser.

Referenced by Html_tag_open_meta().

◆ Html_write_raw()

static int Html_write_raw ( DilloHtml html,
char *  buf,
int  bufsize,
int  Eof 
)
static

Here's where we parse the html and put it into the Textblock structure.

Return value: number of bytes parsed

Definition at line 4316 of file html.cc.

References bufsize, BUG_MSG, DilloHtml::CurrOfs, dFree(), DILLO_HTML_PARSE_MODE_VERBATIM, dStr_append(), dStrndup(), HT2TB, Html_match_tag(), Html_process_space(), Html_process_tag(), Html_process_word(), S_TOP, DilloHtml::Start_Ofs, DilloHtml::Stash, DilloHtml::stop_parser, and Tags.

Referenced by Html_tag_open_meta(), and DilloHtml::write().

Variable Documentation

◆ i_A

◆ i_BODY

int i_BODY = a_Html_tag_index("body")
static

Definition at line 126 of file html.cc.

Referenced by Html_tag_cleanup_to_idx().

◆ i_BUTTON

int i_BUTTON = a_Html_tag_index("button")
static

Definition at line 127 of file html.cc.

Referenced by Html_forbids_cross_nesting(), and Html_tag_cleanup_at_close().

◆ i_DD

int i_DD = a_Html_tag_index("dd")
static

Definition at line 128 of file html.cc.

Referenced by Html_triggers_optional_close().

◆ i_DT

int i_DT = a_Html_tag_index("dt")
static

Definition at line 129 of file html.cc.

Referenced by Html_triggers_optional_close().

◆ i_HR

int i_HR = a_Html_tag_index("hr")
static

Definition at line 131 of file html.cc.

Referenced by Html_stack_cleanup_at_open().

◆ i_HTML

int i_HTML = a_Html_tag_index("html")
static

Definition at line 130 of file html.cc.

Referenced by Html_process_tag().

◆ i_LI

int i_LI = a_Html_tag_index("li")
static

Definition at line 132 of file html.cc.

Referenced by Html_triggers_optional_close().

◆ i_OPTGROUP

int i_OPTGROUP = a_Html_tag_index("optgroup")
static

Definition at line 133 of file html.cc.

Referenced by Html_triggers_optional_close().

◆ i_OPTION

int i_OPTION = a_Html_tag_index("option")
static

Definition at line 134 of file html.cc.

Referenced by Html_triggers_optional_close().

◆ i_P

int i_P = a_Html_tag_index("p")
static

Definition at line 135 of file html.cc.

Referenced by Html_triggers_optional_close().

◆ i_SELECT

int i_SELECT = a_Html_tag_index("select")
static

Definition at line 136 of file html.cc.

Referenced by Html_forbids_cross_nesting(), and Html_tag_cleanup_at_close().

◆ i_TBODY

int i_TBODY = a_Html_tag_index("tbody")
static

Definition at line 140 of file html.cc.

Referenced by Html_triggers_optional_close().

◆ i_TD

int i_TD = a_Html_tag_index("td")
static

Definition at line 138 of file html.cc.

Referenced by Html_triggers_optional_close().

◆ i_TEXTAREA

int i_TEXTAREA = a_Html_tag_index("textarea")
static

Definition at line 137 of file html.cc.

Referenced by Html_forbids_cross_nesting(), and Html_tag_cleanup_at_close().

◆ i_TH

int i_TH = a_Html_tag_index("th")
static

Definition at line 141 of file html.cc.

Referenced by Html_triggers_optional_close().

◆ i_TR

int i_TR = a_Html_tag_index("tr")
static

Definition at line 139 of file html.cc.

Referenced by Html_triggers_optional_close().

◆ Tags

const TagInfo Tags[]
static

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: many tags don't need a content function (e.g. <div>, <span>, ...).

Explanation for the 'Flags' field:

*   {"address", B8(01110), ...}
*                  |||||
*                  ||||`-- inline/block element (1/0 resp.)
*                  |||`--- inline container
*                  ||`---- block container
*                  |`----- body element
*                  `------ head element
* 

Notes:

  • The upper two bits are not used yet.
  • Empty elements have both inline and block container clear. (flow have both set)

Definition at line 3469 of file html.cc.

Referenced by a_Html_tag_index(), Html_check_html5_obsolete(), Html_process_tag(), Html_stack_cleanup_at_open(), Html_tag_cleanup_at_close(), Html_tag_cleanup_to_idx(), Html_test_section(), Html_triggers_optional_close(), and Html_write_raw().