Subversion Repositories Kolibri OS

Rev

Rev 4364 | 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 <bindings/hubbub/parser.h>
  32.  
  33. #include "content/content_type.h"
  34. #include "css/css.h"
  35. #include "desktop/mouse.h"
  36. #include "desktop/plot_style.h"
  37. #include "desktop/frame_types.h"
  38.  
  39. struct fetch_multipart_data;
  40. struct box;
  41. struct rect;
  42. struct browser_window;
  43. struct content;
  44. struct hlcache_handle;
  45. struct http_parameter;
  46. struct imagemap;
  47. struct object_params;
  48. struct plotters;
  49. struct scrollbar;
  50. struct scrollbar_msg_data;
  51. struct search_context;
  52.  
  53. /**
  54.  * Container for stylesheets used by an HTML document
  55.  */
  56. struct html_stylesheet {
  57.         /** Type of sheet */
  58.         enum { HTML_STYLESHEET_EXTERNAL, HTML_STYLESHEET_INTERNAL } type;
  59.         union {
  60.                 struct hlcache_handle *external;
  61.                 struct content_css_data *internal;
  62.         } data; /**< Sheet data */
  63. };
  64.  
  65. /**
  66.  * Container for scripts used by an HTML document
  67.  */
  68. struct html_script {
  69.         /** Type of script */
  70.         enum html_script_type { HTML_SCRIPT_INLINE,
  71.                                 HTML_SCRIPT_SYNC,
  72.                                 HTML_SCRIPT_DEFER,
  73.                                 HTML_SCRIPT_ASYNC } type;
  74.         union {
  75.                 struct hlcache_handle *handle;
  76.                 struct dom_string *string;
  77.         } data; /**< Script data */
  78.         struct dom_string *mimetype;
  79.         struct dom_string *encoding;
  80.         bool already_started;
  81.         bool parser_inserted;
  82.         bool force_async;
  83.         bool ready_exec;
  84.         bool async;
  85.         bool defer;
  86. };
  87.  
  88.  
  89. /** An object (<img>, <object>, etc.) in a CONTENT_HTML document. */
  90. struct content_html_object {
  91.         struct content *parent;         /**< Parent document */
  92.         struct content_html_object *next; /**< Next in chain */
  93.  
  94.         struct hlcache_handle *content;  /**< Content, or 0. */
  95.         struct box *box;  /**< Node in box tree containing it. */
  96.         /** Bitmap of acceptable content types */
  97.         content_type permitted_types;
  98.         bool background;  /**< This object is a background image. */
  99. };
  100.  
  101. struct html_scrollbar_data {
  102.         struct content *c;
  103.         struct box *box;
  104. };
  105.  
  106. /** Frame tree (<frameset>, <frame>) */
  107. struct content_html_frames {
  108.         int cols;       /** number of columns in frameset */
  109.         int rows;       /** number of rows in frameset */
  110.  
  111.         struct frame_dimension width;   /** frame width */
  112.         struct frame_dimension height;  /** frame width */
  113.         int margin_width;       /** frame margin width */
  114.         int margin_height;      /** frame margin height */
  115.  
  116.         char *name;     /** frame name (for targetting) */
  117.         nsurl *url;     /** frame url */
  118.  
  119.         bool no_resize; /** frame is not resizable */
  120.         frame_scrolling scrolling;      /** scrolling characteristics */
  121.         bool border;    /** frame has a border */
  122.         colour border_colour;   /** frame border colour */
  123.  
  124.         struct content_html_frames *children; /** [cols * rows] children */
  125. };
  126.  
  127. /** Inline frame list (<iframe>) */
  128. struct content_html_iframe {
  129.         struct box *box;
  130.  
  131.         int margin_width;       /** frame margin width */
  132.         int margin_height;      /** frame margin height */
  133.  
  134.         char *name;     /** frame name (for targetting) */
  135.         nsurl *url;     /** frame url */
  136.  
  137.         frame_scrolling scrolling;      /** scrolling characteristics */
  138.         bool border;    /** frame has a border */
  139.         colour border_colour;   /** frame border colour */
  140.  
  141.         struct content_html_iframe *next;
  142. };
  143.  
  144. /* entries in stylesheet_content */
  145. #define STYLESHEET_BASE         0       /* base style sheet */
  146. #define STYLESHEET_QUIRKS       1       /* quirks mode stylesheet */
  147. #define STYLESHEET_ADBLOCK      2       /* adblocking stylesheet */
  148. #define STYLESHEET_USER         3       /* user stylesheet */
  149. #define STYLESHEET_START        4       /* start of document stylesheets */
  150.  
  151. /** Render padding and margin box outlines in html_redraw(). */
  152. extern bool html_redraw_debug;
  153.  
  154. nserror html_init(void);
  155.  
  156. void html_redraw_a_box(struct hlcache_handle *h, struct box *box);
  157.  
  158. void html_overflow_scroll_drag_end(struct scrollbar *scrollbar,
  159.                 browser_mouse_state mouse, int x, int y);
  160.  
  161. bool text_redraw(const char *utf8_text, size_t utf8_len,
  162.                 size_t offset, int space,
  163.                 const plot_font_style_t *fstyle,
  164.                 int x, int y,
  165.                 const struct rect *clip,
  166.                 int height,
  167.                 float scale,
  168.                 bool excluded,
  169.                 struct content *c,
  170.                 const struct selection *sel,
  171.                 struct search_context *search,
  172.                 const struct redraw_context *ctx);
  173.  
  174. dom_document *html_get_document(struct hlcache_handle *h);
  175. struct box *html_get_box_tree(struct hlcache_handle *h);
  176. const char *html_get_encoding(struct hlcache_handle *h);
  177. dom_hubbub_encoding_source html_get_encoding_source(struct hlcache_handle *h);
  178. struct content_html_frames *html_get_frameset(struct hlcache_handle *h);
  179. struct content_html_iframe *html_get_iframe(struct hlcache_handle *h);
  180. nsurl *html_get_base_url(struct hlcache_handle *h);
  181. const char *html_get_base_target(struct hlcache_handle *h);
  182. struct html_stylesheet *html_get_stylesheets(struct hlcache_handle *h,
  183.                 unsigned int *n);
  184. struct content_html_object *html_get_objects(struct hlcache_handle *h,
  185.                 unsigned int *n);
  186. bool html_get_id_offset(struct hlcache_handle *h, lwc_string *frag_id,
  187.                 int *x, int *y);
  188.  
  189. #endif
  190.