Subversion Repositories Kolibri OS

Rev

Rev 4821 | Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Copyright 2004 James Bursa <bursa@users.sourceforge.net>
  3.  *
  4.  * This file is part of NetSurf, http://www.netsurf-browser.org/
  5.  *
  6.  * NetSurf is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; version 2 of the License.
  9.  *
  10.  * NetSurf is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17.  */
  18.  
  19. /** \file
  20.  * Content for text/html (interface).
  21.  *
  22.  * These functions should in general be called via the content interface.
  23.  */
  24.  
  25. #ifndef _NETSURF_RENDER_HTML_H_
  26. #define _NETSURF_RENDER_HTML_H_
  27.  
  28. #include <stdbool.h>
  29.  
  30. #include <dom/dom.h>
  31. #include <libdom/bindings/hubbub/parser.h>
  32. #include "content/content_type.h"
  33. #include "css/css.h"
  34. #include "desktop/mouse.h"
  35. #include "desktop/plot_style.h"
  36. #include "desktop/frame_types.h"
  37.  
  38. struct fetch_multipart_data;
  39. struct box;
  40. struct rect;
  41. struct browser_window;
  42. struct content;
  43. struct hlcache_handle;
  44. struct http_parameter;
  45. struct imagemap;
  46. struct object_params;
  47. struct plotters;
  48. struct scrollbar;
  49. struct scrollbar_msg_data;
  50. struct search_context;
  51.  
  52. /**
  53.  * Container for stylesheets used by an HTML document
  54.  */
  55. struct html_stylesheet {
  56.         /** Type of sheet */
  57.         enum { HTML_STYLESHEET_EXTERNAL, HTML_STYLESHEET_INTERNAL } type;
  58.         union {
  59.                 struct hlcache_handle *external;
  60.                 struct content_css_data *internal;
  61.         } data; /**< Sheet data */
  62. };
  63.  
  64. /**
  65.  * Container for scripts used by an HTML document
  66.  */
  67. struct html_script {
  68.         /** Type of script */
  69.         enum html_script_type { HTML_SCRIPT_INLINE,
  70.                                 HTML_SCRIPT_SYNC,
  71.                                 HTML_SCRIPT_DEFER,
  72.                                 HTML_SCRIPT_ASYNC } type;
  73.         union {
  74.                 struct hlcache_handle *handle;
  75.                 struct dom_string *string;
  76.         } data; /**< Script data */
  77.         struct dom_string *mimetype;
  78.         struct dom_string *encoding;
  79.         bool already_started;
  80.         bool parser_inserted;
  81.         bool force_async;
  82.         bool ready_exec;
  83.         bool async;
  84.         bool defer;
  85. };
  86.  
  87.  
  88. /** An object (<img>, <object>, etc.) in a CONTENT_HTML document. */
  89. struct content_html_object {
  90.         struct content *parent;         /**< Parent document */
  91.         struct content_html_object *next; /**< Next in chain */
  92.  
  93.         struct hlcache_handle *content;  /**< Content, or 0. */
  94.         struct box *box;  /**< Node in box tree containing it. */
  95.         /** Bitmap of acceptable content types */
  96.         content_type permitted_types;
  97.         bool background;  /**< This object is a background image. */
  98. };
  99.  
  100. struct html_scrollbar_data {
  101.         struct content *c;
  102.         struct box *box;
  103. };
  104.  
  105. /** Frame tree (<frameset>, <frame>) */
  106. struct content_html_frames {
  107.         int cols;       /** number of columns in frameset */
  108.         int rows;       /** number of rows in frameset */
  109.  
  110.         struct frame_dimension width;   /** frame width */
  111.         struct frame_dimension height;  /** frame width */
  112.         int margin_width;       /** frame margin width */
  113.         int margin_height;      /** frame margin height */
  114.  
  115.         char *name;     /** frame name (for targetting) */
  116.         nsurl *url;     /** frame url */
  117.  
  118.         bool no_resize; /** frame is not resizable */
  119.         frame_scrolling scrolling;      /** scrolling characteristics */
  120.         bool border;    /** frame has a border */
  121.         colour border_colour;   /** frame border colour */
  122.  
  123.         struct content_html_frames *children; /** [cols * rows] children */
  124. };
  125.  
  126. /** Inline frame list (<iframe>) */
  127. struct content_html_iframe {
  128.         struct box *box;
  129.  
  130.         int margin_width;       /** frame margin width */
  131.         int margin_height;      /** frame margin height */
  132.  
  133.         char *name;     /** frame name (for targetting) */
  134.         nsurl *url;     /** frame url */
  135.  
  136.         frame_scrolling scrolling;      /** scrolling characteristics */
  137.         bool border;    /** frame has a border */
  138.         colour border_colour;   /** frame border colour */
  139.  
  140.         struct content_html_iframe *next;
  141. };
  142.  
  143. /* entries in stylesheet_content */
  144. #define STYLESHEET_BASE         0       /* base style sheet */
  145. #define STYLESHEET_QUIRKS       1       /* quirks mode stylesheet */
  146. #define STYLESHEET_ADBLOCK      2       /* adblocking stylesheet */
  147. #define STYLESHEET_USER         3       /* user stylesheet */
  148. #define STYLESHEET_START        4       /* start of document stylesheets */
  149.  
  150. /** Render padding and margin box outlines in html_redraw(). */
  151. extern bool html_redraw_debug;
  152.  
  153. nserror html_init(void);
  154.  
  155. void html_redraw_a_box(struct hlcache_handle *h, struct box *box);
  156.  
  157. void html_overflow_scroll_drag_end(struct scrollbar *scrollbar,
  158.                 browser_mouse_state mouse, int x, int y);
  159.  
  160. bool text_redraw(const char *utf8_text, size_t utf8_len,
  161.                 size_t offset, int space,
  162.                 const plot_font_style_t *fstyle,
  163.                 int x, int y,
  164.                 const struct rect *clip,
  165.                 int height,
  166.                 float scale,
  167.                 bool excluded,
  168.                 struct content *c,
  169.                 const struct selection *sel,
  170.                 struct search_context *search,
  171.                 const struct redraw_context *ctx);
  172.  
  173. dom_document *html_get_document(struct hlcache_handle *h);
  174. struct box *html_get_box_tree(struct hlcache_handle *h);
  175. const char *html_get_encoding(struct hlcache_handle *h);
  176. dom_hubbub_encoding_source html_get_encoding_source(struct hlcache_handle *h);
  177. struct content_html_frames *html_get_frameset(struct hlcache_handle *h);
  178. struct content_html_iframe *html_get_iframe(struct hlcache_handle *h);
  179. nsurl *html_get_base_url(struct hlcache_handle *h);
  180. const char *html_get_base_target(struct hlcache_handle *h);
  181. struct html_stylesheet *html_get_stylesheets(struct hlcache_handle *h,
  182.                 unsigned int *n);
  183. struct content_html_object *html_get_objects(struct hlcache_handle *h,
  184.                 unsigned int *n);
  185. bool html_get_id_offset(struct hlcache_handle *h, lwc_string *frag_id,
  186.                 int *x, int *y);
  187.  
  188. #endif
  189.