move html and text content handlers where they belong

This commit is contained in:
Vincent Sanders 2018-05-10 11:34:26 +01:00 committed by Vincent Sanders
parent 1b892391d7
commit 2a03ea3049
47 changed files with 758 additions and 515 deletions

View File

@ -617,9 +617,6 @@ include frontends/Makefile
# Content sources
include content/Makefile
# render sources
include render/Makefile
# utility sources
include utils/Makefile
@ -636,7 +633,6 @@ include desktop/Makefile
S_COMMON := \
$(S_CONTENT) \
$(S_FETCHERS) \
$(S_RENDER) \
$(S_UTILS) \
$(S_HTTP) \
$(S_NSURL) \

View File

@ -13,4 +13,15 @@ include content/handlers/javascript/Makefile
S_CONTENT += $(addprefix handlers/javascript/,$(S_JAVASCRIPT))
# HTML content handler sources
include content/handlers/html/Makefile
S_CONTENT += $(addprefix handlers/html/,$(S_HTML))
# Text content handler sources
include content/handlers/text/Makefile
S_CONTENT += $(addprefix handlers/text/,$(S_TEXT))
# extend the include search path
INCLUDE_DIRS += content/handlers

View File

@ -0,0 +1,7 @@
# HTML content handler sources
S_HTML := box.c box_construct.c box_normalise.c box_textarea.c \
font.c form.c imagemap.c layout.c search.c table.c \
html.c html_css.c html_css_fetcher.c html_script.c \
html_interaction.c html_redraw.c html_redraw_border.c \
html_forms.c html_object.c

View File

@ -41,9 +41,9 @@
#include "desktop/scrollbar.h"
#include "desktop/gui_internal.h"
#include "render/box.h"
#include "render/form_internal.h"
#include "render/html_internal.h"
#include "html/box.h"
#include "html/form_internal.h"
#include "html/html_internal.h"
#define box_is_float(box) (box->type == BOX_FLOAT_LEFT || \
box->type == BOX_FLOAT_RIGHT)
@ -1239,4 +1239,3 @@ bool box_hscrollbar_present(const struct box * const box)
return box->padding[LEFT] + box->width + box->padding[RIGHT] +
box->border[RIGHT].width < box->descendant_x1;
}

View File

@ -17,7 +17,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file
/**
* \file
* Box tree construction and manipulation (interface).
*
* This stage of rendering converts a tree of dom_nodes (produced by libdom)
@ -83,8 +84,8 @@
* \endcode
*/
#ifndef _NETSURF_RENDER_BOX_H_
#define _NETSURF_RENDER_BOX_H_
#ifndef NETSURF_HTML_BOX_H
#define NETSURF_HTML_BOX_H
#include <limits.h>
#include <stdbool.h>

View File

@ -49,10 +49,10 @@
#include "css/utils.h"
#include "desktop/gui_internal.h"
#include "render/box.h"
#include "render/box_textarea.h"
#include "render/form_internal.h"
#include "render/html_internal.h"
#include "html/box.h"
#include "html/box_textarea.h"
#include "html/form_internal.h"
#include "html/html_internal.h"
/**
* Context for box tree construction
@ -3064,7 +3064,7 @@ bool box_get_attribute(dom_node *n, const char *attribute,
}
/* exported function documented in render/box.h */
/* exported function documented in html/box.h */
bool
box_extract_link(const html_content *content,
const dom_string *dsrel,
@ -3132,6 +3132,3 @@ box_extract_link(const html_content *content,
return true;
}

View File

@ -19,7 +19,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file
/**
* \file
* Box tree normalisation (implementation).
*/
@ -31,9 +32,9 @@
#include "utils/errors.h"
#include "css/select.h"
#include "render/box.h"
#include "render/html_internal.h"
#include "render/table.h"
#include "html/box.h"
#include "html/html_internal.h"
#include "html/table.h"
/* Define to enable box normalise debug */
#undef BOX_NORMALISE_DEBUG

View File

@ -16,7 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file
/**
* \file
* Box tree treeview box replacement (implementation).
*/
@ -27,9 +28,9 @@
#include "netsurf/keypress.h"
#include "desktop/textarea.h"
#include "render/box_textarea.h"
#include "render/font.h"
#include "render/form_internal.h"
#include "html/box_textarea.h"
#include "html/font.h"
#include "html/form_internal.h"
bool box_textarea_keypress(html_content *html, struct box *box, uint32_t key)
@ -347,4 +348,3 @@ bool box_textarea_create_textarea(html_content *html,
return true;
}

View File

@ -16,18 +16,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file
/**
* \file
* Box tree treeview box replacement (interface).
*/
#ifndef NETSURF_HTML_BOX_TEXTAREA_H
#define NETSURF_HTML_BOX_TEXTAREA_H
#ifndef _NETSURF_RENDER_BOX_TEXTAREA_H_
#define _NETSURF_RENDER_BOX_TEXTAREA_H_
#include "render/box.h"
#include "render/html_internal.h"
#include "html/box.h"
#include "html/html_internal.h"
struct dom_node;

View File

@ -19,14 +19,14 @@
/**
* \file
*
* Renderer internal font handling implementation.
* HTML internal font handling implementation.
*/
#include "utils/nsoption.h"
#include "netsurf/plot_style.h"
#include "css/utils.h"
#include "render/font.h"
#include "html/font.h"
/**
* Map a generic CSS font family to a generic plot font family
@ -34,8 +34,8 @@
* \param css Generic CSS font family
* \return Plot font family
*/
static plot_font_generic_family_t plot_font_generic_family(
enum css_font_family_e css)
static plot_font_generic_family_t
plot_font_generic_family(enum css_font_family_e css)
{
plot_font_generic_family_t plot;
@ -131,7 +131,7 @@ static plot_font_flags_t plot_font_flags(enum css_font_style_e style,
}
/* exported function documented in render/font.h */
/* exported function documented in html/font.h */
void font_plot_style_from_css(
const nscss_len_ctx *len_ctx,
const css_computed_style *css,

View File

@ -16,16 +16,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file
*
/**
* \file
* Internal font handling interfaces.
*
* These functions provide font related services. They all work on
* UTF-8 strings with lengths given.
*/
#ifndef _NETSURF_RENDER_FONT_H_
#define _NETSURF_RENDER_FONT_H_
#ifndef NETSURF_HTML_FONT_H
#define NETSURF_HTML_FONT_H
struct plot_font_style;
@ -36,8 +36,7 @@ struct plot_font_style;
* \param css Computed style to consider
* \param fstyle Font style to populate
*/
void font_plot_style_from_css(
const nscss_len_ctx *len_ctx,
void font_plot_style_from_css(const nscss_len_ctx *len_ctx,
const css_computed_style *css,
struct plot_font_style *fstyle);

View File

@ -52,12 +52,12 @@
#include "desktop/textarea.h"
#include "desktop/gui_internal.h"
#include "render/box.h"
#include "render/font.h"
#include "render/form_internal.h"
#include "render/html.h"
#include "render/html_internal.h"
#include "render/layout.h"
#include "html/box.h"
#include "html/font.h"
#include "html/form_internal.h"
#include "html/html.h"
#include "html/html_internal.h"
#include "html/layout.h"
#define MAX_SELECT_HEIGHT 210
#define SELECT_LINE_SPACING 0.2
@ -96,7 +96,7 @@ static void form_select_menu_clicked(struct form_control *control,
static void form_select_menu_scroll_callback(void *client_data,
struct scrollbar_msg_data *scrollbar_data);
/* exported interface documented in render/form_internal.h */
/* exported interface documented in html/form_internal.h */
struct form *form_new(void *node, const char *action, const char *target,
form_method method, const char *charset,
const char *doc_charset)
@ -146,7 +146,7 @@ struct form *form_new(void *node, const char *action, const char *target,
}
/* exported interface documented in render/form_internal.h */
/* exported interface documented in html/form_internal.h */
void form_free(struct form *form)
{
struct form_control *c, *d;
@ -165,7 +165,7 @@ void form_free(struct form *form)
free(form);
}
/* exported interface documented in render/form_internal.h */
/* exported interface documented in html/form_internal.h */
struct form_control *form_new_control(void *node, form_control_type type)
{
struct form_control *control;
@ -327,7 +327,7 @@ bool form_add_option(struct form_control *control, char *value, char *text,
}
/* exported interface documented in render/form_internal.h */
/* exported interface documented in html/form_internal.h */
bool form_successful_controls_dom(struct form *_form,
struct form_control *_submit_button,
struct fetch_multipart_data **successful_controls)
@ -1122,7 +1122,7 @@ char *form_encode_item(const char *item, uint32_t len, const char *charset,
return ret;
}
/* exported interface documented in render/form_internal.h */
/* exported interface documented in html/form_internal.h */
bool form_open_select_menu(void *client_data,
struct form_control *control,
select_menu_redraw_callback callback,
@ -1197,7 +1197,7 @@ bool form_open_select_menu(void *client_data,
}
/* exported interface documented in render/form_internal.h */
/* exported interface documented in html/form_internal.h */
void form_free_select_menu(struct form_control *control)
{
if (control->data.select.menu->scrollbar != NULL)
@ -1207,7 +1207,7 @@ void form_free_select_menu(struct form_control *control)
}
/* exported interface documented in render/form_internal.h */
/* exported interface documented in html/form_internal.h */
bool form_redraw_select_menu(struct form_control *control, int x, int y,
float scale, const struct rect *clip,
const struct redraw_context *ctx)

View File

@ -18,11 +18,11 @@
/**
* \file
* Interface to form handling functions internal to render.
* Interface to form handling functions internal to HTML content handler.
*/
#ifndef _NETSURF_RENDER_FORM_INTERNAL_H_
#define _NETSURF_RENDER_FORM_INTERNAL_H_
#ifndef NETSURF_HTML_FORM_INTERNAL_H
#define NETSURF_HTML_FORM_INTERNAL_H
#include <stdbool.h>

View File

@ -19,7 +19,7 @@
/**
* \file
* Content for text/html (implementation).
* Implementation of HTML content handling.
*/
#include <assert.h>
@ -54,12 +54,12 @@
#include "javascript/js.h"
#include "desktop/gui_internal.h"
#include "render/box.h"
#include "render/form_internal.h"
#include "render/html_internal.h"
#include "render/imagemap.h"
#include "render/layout.h"
#include "render/search.h"
#include "html/box.h"
#include "html/form_internal.h"
#include "html/html_internal.h"
#include "html/imagemap.h"
#include "html/layout.h"
#include "html/search.h"
#define CHUNK 4096
@ -568,7 +568,7 @@ static bool html_process_img(html_content *c, dom_node *node)
return success;
}
/* exported function documented in render/html_internal.h */
/* exported function documented in html/html_internal.h */
void html_finish_conversion(html_content *htmlc)
{
union content_msg_data msg_data;
@ -2260,7 +2260,8 @@ dom_document *html_get_document(hlcache_handle *h)
* \param h HTML content to retrieve tree from
* \return Pointer to box tree
*
* \todo This API must die, as must all use of the box tree outside render/
* \todo This API must die, as must all use of the box tree outside of
* HTML content handler
*/
struct box *html_get_box_tree(hlcache_handle *h)
{

View File

@ -16,14 +16,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file
* Content for text/html (interface).
/**
* \file
* Interface to text/html content handler.
*
* These functions should in general be called via the content interface.
*/
#ifndef _NETSURF_RENDER_HTML_H_
#define _NETSURF_RENDER_HTML_H_
#ifndef NETSURF_HTML_HTML_H
#define NETSURF_HTML_HTML_H
#include <stdbool.h>
@ -88,7 +89,9 @@ struct html_script {
};
/** An object (img, object, etc. tag) in a CONTENT_HTML document. */
/**
* An object (img, object, etc. tag) in a CONTENT_HTML document.
*/
struct content_html_object {
struct content *parent; /**< Parent document */
struct content_html_object *next; /**< Next in chain */
@ -157,19 +160,6 @@ void html_redraw_a_box(struct hlcache_handle *h, struct box *box);
void html_overflow_scroll_drag_end(struct scrollbar *scrollbar,
browser_mouse_state mouse, int x, int y);
bool text_redraw(const char *utf8_text, size_t utf8_len,
size_t offset, int space,
const struct plot_font_style *fstyle,
int x, int y,
const struct rect *clip,
int height,
float scale,
bool excluded,
struct content *c,
const struct selection *sel,
struct search_context *search,
const struct redraw_context *ctx);
dom_document *html_get_document(struct hlcache_handle *h);
struct box *html_get_box_tree(struct hlcache_handle *h);
struct content_html_frames *html_get_frameset(struct hlcache_handle *h);

View File

@ -16,7 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file
/**
* \file
* Processing for html content css operations.
*/
@ -37,7 +38,7 @@
#include "css/css.h"
#include "desktop/gui_internal.h"
#include "render/html_internal.h"
#include "html/html_internal.h"
static nsurl *html_default_stylesheet_url;
static nsurl *html_adblock_stylesheet_url;
@ -472,7 +473,7 @@ no_memory:
return false;
}
/* exported interface documented in render/html.h */
/* exported interface documented in html/html.h */
struct html_stylesheet *html_get_stylesheets(hlcache_handle *h, unsigned int *n)
{
html_content *c = (html_content *) hlcache_handle_get_content(h);
@ -486,7 +487,7 @@ struct html_stylesheet *html_get_stylesheets(hlcache_handle *h, unsigned int *n)
}
/* exported interface documented in render/html_internal.h */
/* exported interface documented in html/html_internal.h */
nserror html_css_free_stylesheets(html_content *html)
{
unsigned int i;
@ -506,7 +507,7 @@ nserror html_css_free_stylesheets(html_content *html)
return NSERROR_OK;
}
/* exported interface documented in render/html_internal.h */
/* exported interface documented in html/html_internal.h */
nserror html_css_quirks_stylesheets(html_content *c)
{
nserror ns_error = NSERROR_OK;
@ -534,7 +535,7 @@ nserror html_css_quirks_stylesheets(html_content *c)
return ns_error;
}
/* exported interface documented in render/html_internal.h */
/* exported interface documented in html/html_internal.h */
nserror html_css_new_stylesheets(html_content *c)
{
nserror ns_error;

View File

@ -17,6 +17,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file
* HTML fetcher for CSS objects
*/
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
@ -33,7 +38,7 @@
#include "content/fetch.h"
#include "content/fetchers.h"
#include "render/html_internal.h"
#include "html/html_internal.h"
typedef struct html_css_fetcher_item {
uint32_t key;
@ -318,4 +323,3 @@ html_css_fetcher_add_item(dom_string *data, nsurl *base_url, uint32_t *key)
return NSERROR_OK;
}

View File

@ -16,12 +16,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file
* HTML form handling implementation
*/
#include "utils/config.h"
#include "utils/corestrings.h"
#include "utils/log.h"
#include "render/form_internal.h"
#include "render/html_internal.h"
#include "html/form_internal.h"
#include "html/html_internal.h"
/**
* process form element from dom
@ -572,4 +577,3 @@ struct form_control *html_forms_get_control_for_node(struct form *forms,
return ctl;
}

View File

@ -21,7 +21,7 @@
/**
* \file
* User interaction with a CONTENT_HTML (implementation).
* implementation of user interaction with a CONTENT_HTML.
*/
#include <assert.h>
@ -48,13 +48,13 @@
#include "javascript/js.h"
#include "desktop/gui_internal.h"
#include "render/box.h"
#include "render/box_textarea.h"
#include "render/font.h"
#include "render/form_internal.h"
#include "render/html_internal.h"
#include "render/imagemap.h"
#include "render/search.h"
#include "html/box.h"
#include "html/box_textarea.h"
#include "html/font.h"
#include "html/form_internal.h"
#include "html/html_internal.h"
#include "html/imagemap.h"
#include "html/search.h"
/**
* Get pointer shape for given box

View File

@ -18,18 +18,19 @@
/**
* \file
* Content for text/html (private data).
* Private data for text/html content.
*/
#ifndef NETSURF_RENDER_HTML_INTERNAL_H_
#define NETSURF_RENDER_HTML_INTERNAL_H_
#ifndef NETSURF_HTML_HTML_INTERNAL_H
#define NETSURF_HTML_HTML_INTERNAL_H
#include <libcss/libcss.h>
#include "content/handlers/css/utils.h"
#include "content/content_protected.h"
#include "desktop/selection.h"
#include "render/html.h"
#include "html/html.h"
struct gui_layout_table;
@ -258,11 +259,11 @@ bool html_can_begin_conversion(html_content *htmlc);
*/
bool html_begin_conversion(html_content *htmlc);
/* in render/html_redraw.c */
/* in html/html_redraw.c */
bool html_redraw(struct content *c, struct content_redraw_data *data,
const struct rect *clip, const struct redraw_context *ctx);
/* in render/html_redraw_border.c */
/* in html/html_redraw_border.c */
bool html_redraw_borders(struct box *box, int x_parent, int y_parent,
int p_width, int p_height, const struct rect *clip, float scale,
const struct redraw_context *ctx);
@ -271,7 +272,7 @@ bool html_redraw_inline_borders(struct box *box, struct rect b,
const struct rect *clip, float scale, bool first, bool last,
const struct redraw_context *ctx);
/* in render/html_interaction.c */
/* in html/html_interaction.c */
void html_mouse_track(struct content *c, struct browser_window *bw,
browser_mouse_state mouse, int x, int y);
void html_mouse_action(struct content *c, struct browser_window *bw,
@ -284,7 +285,7 @@ void html_search(struct content *c, void *context,
void html_search_clear(struct content *c);
/* in render/html_script.c */
/* in html/html_script.c */
dom_hubbub_error html_process_script(void *ctx, dom_node *node);
/**
@ -314,12 +315,12 @@ nserror html_script_free(html_content *htmlc);
*/
nserror html_script_invalidate_ctx(html_content *htmlc);
/* in render/html_forms.c */
/* in html/html_forms.c */
struct form *html_forms_get_forms(const char *docenc, dom_html_document *doc);
struct form_control *html_forms_get_control_for_node(struct form *forms,
dom_node *node);
/* in render/html_css.c */
/* in html/html_css.c */
nserror html_css_init(void);
void html_css_fini(void);
@ -340,7 +341,7 @@ bool html_css_update_style(html_content *c, dom_node *style);
nserror html_css_new_selection_context(html_content *c,
css_select_ctx **ret_select_ctx);
/* in render/html_css_fetcher.c */
/* in html/html_css_fetcher.c */
/**
* Register the fetcher for the pseudo x-ns-css scheme.
*
@ -350,7 +351,7 @@ nserror html_css_fetcher_register(void);
nserror html_css_fetcher_add_item(dom_string *data, nsurl *base_url,
uint32_t *key);
/* in render/html_object.c */
/* in html/html_object.c */
/**
* Start a fetch for an object required by a page.
@ -406,5 +407,3 @@ extern struct dom_string *html_dom_string_type;
extern struct dom_string *html_dom_string_src;
#endif

View File

@ -16,7 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file
/**
* \file
* Processing for html content object operations.
*/
@ -39,8 +40,8 @@
#include "desktop/scrollbar.h"
#include "desktop/gui_internal.h"
#include "render/box.h"
#include "render/html_internal.h"
#include "html/box.h"
#include "html/html_internal.h"
/* break reference loop */
static void html_object_refresh(void *p);
@ -676,7 +677,7 @@ nserror html_object_free_objects(html_content *html)
/* exported interface documented in render/html_internal.h */
/* exported interface documented in html/html_internal.h */
bool html_fetch_object(html_content *c, nsurl *url, struct box *box,
content_type permitted_types,
int available_width, int available_height,

View File

@ -53,12 +53,12 @@
#include "desktop/textarea.h"
#include "desktop/gui_internal.h"
#include "render/box.h"
#include "render/font.h"
#include "render/form_internal.h"
#include "render/html_internal.h"
#include "render/layout.h"
#include "render/search.h"
#include "html/box.h"
#include "html/font.h"
#include "html/form_internal.h"
#include "html/html_internal.h"
#include "html/layout.h"
#include "html/search.h"
bool html_redraw_debug = false;
@ -150,7 +150,7 @@ static struct box *html_redraw_find_bg_box(struct box *box)
* \return true iff successful and redraw should proceed
*/
bool
static bool
text_redraw(const char *utf8_text,
size_t utf8_len,
size_t offset,

View File

@ -29,8 +29,8 @@
#include "netsurf/plotters.h"
#include "netsurf/css.h"
#include "render/box.h"
#include "render/html_internal.h"
#include "html/box.h"
#include "html/html_internal.h"
static plot_style_t plot_style_bdr = {

View File

@ -16,8 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file
* Content for text/html scripts (implementation).
/**
* \file
* implementation of content handling for text/html scripts.
*/
#include <assert.h>
@ -38,7 +39,7 @@
#include "content/fetch.h"
#include "content/hlcache.h"
#include "render/html_internal.h"
#include "html/html_internal.h"
typedef bool (script_handler_t)(struct jscontext *jscontext, const char *data, size_t size) ;
@ -52,7 +53,7 @@ static script_handler_t *select_script_handler(content_type ctype)
}
/* exported internal interface documented in render/html_internal.h */
/* exported internal interface documented in html/html_internal.h */
nserror html_script_exec(html_content *c)
{
unsigned int i;
@ -568,7 +569,7 @@ html_process_script(void *ctx, dom_node *node)
return err;
}
/* exported internal interface documented in render/html_internal.h */
/* exported internal interface documented in html/html_internal.h */
nserror html_script_free(html_content *html)
{
unsigned int i;
@ -595,7 +596,7 @@ nserror html_script_free(html_content *html)
return NSERROR_OK;
}
/* exported internal interface documented in render/html_internal.h */
/* exported internal interface documented in html/html_internal.h */
nserror html_script_invalidate_ctx(html_content *htmlc)
{
htmlc->jscontext = NULL;

View File

@ -16,8 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Much of this shamelessly copied from utils/messages.c
/**
* \file
* Implementation of HTML image maps
*
* \todo should this should use the general hashmap instead of its own
*/
#include <assert.h>
@ -32,9 +35,9 @@
#include "content/content_protected.h"
#include "content/hlcache.h"
#include "render/box.h"
#include "render/html_internal.h"
#include "render/imagemap.h"
#include "html/box.h"
#include "html/html_internal.h"
#include "html/imagemap.h"
#define HASH_SIZE 31 /* fixed size hash table */

View File

@ -16,8 +16,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _NETSURF_RENDER_IMAGEMAP_H_
#define _NETSURF_RENDER_IMAGEMAP_H_
/**
* \file
* Interface to HTML imagemap
*/
#ifndef NETSURF_HTML_IMAGEMAP_H
#define NETSURF_HTML_IMAGEMAP_H
#include <dom/dom.h>

View File

@ -56,12 +56,12 @@
#include "desktop/scrollbar.h"
#include "desktop/textarea.h"
#include "render/box.h"
#include "render/font.h"
#include "render/form_internal.h"
#include "render/html_internal.h"
#include "render/layout.h"
#include "render/table.h"
#include "html/box.h"
#include "html/font.h"
#include "html/form_internal.h"
#include "html/html_internal.h"
#include "html/layout.h"
#include "html/table.h"
#define AUTO INT_MIN
@ -5381,7 +5381,7 @@ static void layout_calculate_descendant_bboxes(
}
/* exported function documented in render/layout.h */
/* exported function documented in html/layout.h */
bool layout_document(html_content *content, int width, int height)
{
bool ret;

View File

@ -18,15 +18,15 @@
/**
* \file
* HTML layout (interface).
* interface to HTML layout.
*
* The main interface to the layout code is layout_document(), which takes a
* normalized box tree and assigns coordinates and dimensions to the boxes, and
* also adds boxes to the tree (eg. when formatting lines of text).
*/
#ifndef _NETSURF_RENDER_LAYOUT_H_
#define _NETSURF_RENDER_LAYOUT_H_
#ifndef NETSURF_HTML_LAYOUT_H
#define NETSURF_HTML_LAYOUT_H
struct box;
struct html_content;

View File

@ -38,11 +38,11 @@
#include "netsurf/misc.h"
#include "desktop/gui_internal.h"
#include "render/box.h"
#include "render/html.h"
#include "render/html_internal.h"
#include "render/search.h"
#include "render/textplain.h"
#include "text/textplain.h"
#include "html/box.h"
#include "html/html.h"
#include "html/html_internal.h"
#include "html/search.h"
#ifndef NOF_ELEMENTS
#define NOF_ELEMENTS(array) (sizeof(array)/sizeof(*(array)))

View File

@ -16,8 +16,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _NETSURF_RENDER_SEARCH_H_
#define _NETSURF_RENDER_SEARCH_H_
/**
* \file
* Interface to HTML searching.
*/
#ifndef NETSURF_HTML_SEARCH_H
#define NETSURF_HTML_SEARCH_H
#include <ctype.h>
#include <string.h>

View File

@ -17,8 +17,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file
* Table processing and layout (implementation).
/**
* \file
* implementation of HTML table processing and layout.
*/
#include <assert.h>
@ -28,8 +29,8 @@
#include "utils/talloc.h"
#include "css/utils.h"
#include "render/box.h"
#include "render/table.h"
#include "html/box.h"
#include "html/table.h"
/* Define to enable verbose table debug */
#undef TABLE_DEBUG
@ -1077,4 +1078,3 @@ bool table_cell_top_process_row(
return true;
}

View File

@ -17,12 +17,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file
* Table processing and layout (interface).
/**
* \file
* Interface to HTML table processing and layout.
*/
#ifndef _NETSURF_RENDER_TABLE_H_
#define _NETSURF_RENDER_TABLE_H_
#ifndef NETSURF_HTML_TABLE_H
#define NETSURF_HTML_TABLE_H
#include <stdbool.h>

View File

@ -14,7 +14,7 @@ prologue Document()
#include "utils/libdom.h"
#include "utils/utils.h"
#include "content/hlcache.h"
#include "render/html_internal.h"
#include "html/html_internal.h"
#include "content/urldb.h"
#define HANDLER_MAGIC MAGIC(HANDLER_MAP)

View File

@ -15,8 +15,8 @@ class Window {
#include "utils/nsurl.h"
#include "netsurf/browser_window.h"
#include "content/hlcache.h"
#include "render/html.h"
#include "render/html_internal.h"
#include "html/html.h"
#include "html/html_internal.h"
%};
};

View File

@ -0,0 +1,3 @@
# text content handler sources
S_TEXT := textplain.c

View File

@ -52,10 +52,8 @@
#include "desktop/selection.h"
#include "desktop/gui_internal.h"
#include "render/search.h"
#include "render/textplain.h"
#include "render/html.h"
#include "render/search.h"
#include "html/search.h"
#include "text/textplain.h"
struct textplain_line {
size_t start;
@ -811,6 +809,223 @@ static void textplain_search(struct content *c, void *gui_data,
}
/**
* Redraw a text string with highlighting
* (for selection/search)
*
* \param utf8_text pointer to UTF-8 text string
* \param utf8_len length of string, in bytes
* \param offset byte offset within textual representation
* \param x x ordinate at which to plot text
* \param y y ordinate at which to plot text
* \param clip pointer to current clip rectangle
* \param height height of text string
* \param scale current display scale (1.0 = 100%)
* \param text Content being redrawn.
* \param sel Selection context
* \param search Search context
* \param ctx current redraw context
* \return true iff successful and redraw should proceed
*/
static bool
text_draw(const char *utf8_text,
size_t utf8_len,
size_t offset,
int x,
int y,
const struct rect *clip,
int height,
float scale,
textplain_content *text,
const struct selection *sel,
struct search_context *search,
const struct redraw_context *ctx)
{
bool highlighted = false;
plot_font_style_t plot_fstyle;
nserror res;
/* Need scaled text size to pass to plotters */
plot_fstyle = textplain_style;
plot_fstyle.size *= scale;
/* is this box part of a selection? */
if (ctx->interactive == true) {
unsigned len = utf8_len;
unsigned start_idx;
unsigned end_idx;
/* first try the browser window's current selection */
if (selection_defined(sel) &&
selection_highlighted(sel,
offset,
offset + len,
&start_idx,
&end_idx)) {
highlighted = true;
}
/* what about the current search operation, if any? */
if (!highlighted &&
(search != NULL) &&
search_term_highlighted((struct content *)text,
offset,
offset + len,
&start_idx,
&end_idx,
search)) {
highlighted = true;
}
/* \todo make search terms visible within selected text */
if (highlighted) {
struct rect r;
unsigned endtxt_idx = end_idx;
bool clip_changed = false;
bool text_visible = true;
int startx, endx;
plot_style_t pstyle_fill_hback = *plot_style_fill_white;
plot_font_style_t fstyle_hback = plot_fstyle;
if (end_idx > utf8_len) {
/* adjust for trailing space, not present in
* utf8_text
*/
assert(end_idx == utf8_len + 1);
endtxt_idx = utf8_len;
}
res = guit->layout->width(&textplain_style,
utf8_text,
start_idx,
&startx);
if (res != NSERROR_OK) {
startx = 0;
}
res = guit->layout->width(&textplain_style,
utf8_text,
endtxt_idx,
&endx);
if (res != NSERROR_OK) {
endx = 0;
}
if (scale != 1.0) {
startx *= scale;
endx *= scale;
}
/* draw any text preceding highlighted portion */
if (start_idx > 0) {
res = ctx->plot->text(ctx,
&plot_fstyle,
x,
y + (int)(height * 0.75 * scale),
utf8_text,
start_idx);
if (res != NSERROR_OK) {
return false;
}
}
pstyle_fill_hback.fill_colour = textplain_style.foreground;
/* highlighted portion */
r.x0 = x + startx;
r.y0 = y;
r.x1 = x + endx;
r.y1 = y + height * scale;
res = ctx->plot->rectangle(ctx, &pstyle_fill_hback, &r);
if (res != NSERROR_OK) {
return false;
}
if (start_idx > 0) {
int px0 = max(x + startx, clip->x0);
int px1 = min(x + endx, clip->x1);
if (px0 < px1) {
r.x0 = px0;
r.y0 = clip->y0;
r.x1 = px1;
r.y1 = clip->y1;
res = ctx->plot->clip(ctx, &r);
if (res != NSERROR_OK) {
return false;
}
clip_changed = true;
} else {
text_visible = false;
}
}
fstyle_hback.background =
pstyle_fill_hback.fill_colour;
fstyle_hback.foreground = colour_to_bw_furthest(
pstyle_fill_hback.fill_colour);
if (text_visible &&
(ctx->plot->text(ctx,
&fstyle_hback,
x,
y + (int)(height * 0.75 * scale),
utf8_text,
endtxt_idx) != NSERROR_OK)) {
return false;
}
/* draw any text succeeding highlighted portion */
if (endtxt_idx < utf8_len) {
int px0 = max(x + endx, clip->x0);
if (px0 < clip->x1) {
r.x0 = px0;
r.y0 = clip->y0;
r.x1 = clip->x1;
r.y1 = clip->y1;
res = ctx->plot->clip(ctx, &r);
if (res != NSERROR_OK) {
return false;
}
clip_changed = true;
res = ctx->plot->text(ctx,
&plot_fstyle,
x,
y + (int)(height * 0.75 * scale),
utf8_text,
utf8_len);
if (res != NSERROR_OK) {
return false;
}
}
}
if (clip_changed &&
(ctx->plot->clip(ctx, clip) != NSERROR_OK)) {
return false;
}
}
}
if (!highlighted) {
res = ctx->plot->text(ctx,
&plot_fstyle,
x,
y + (int) (height * 0.75 * scale),
utf8_text,
utf8_len);
if (res != NSERROR_OK) {
return false;
}
}
return true;
}
/**
* Draw a CONTENT_TEXTPLAIN using the current set of plotters (plot).
*
@ -892,17 +1107,27 @@ textplain_redraw(struct content *c,
int ntx;
nserror res;
while (next_offset < length && text_d[next_offset] != '\t')
next_offset = utf8_next(text_d, length, next_offset);
while ((next_offset < length) &&
(text_d[next_offset] != '\t')) {
next_offset = utf8_next(text_d,
length,
next_offset);
}
if (!text_redraw(text_d + offset, next_offset - offset,
line[lineno].start + offset, 0,
&textplain_style,
tx, y + (lineno * scaled_line_height),
clip, line_height, data->scale, false,
(struct content *)text, &text->sel,
text->search, ctx))
if (!text_draw(text_d + offset,
next_offset - offset,
line[lineno].start + offset,
tx,
y + (lineno * scaled_line_height),
clip,
line_height,
data->scale,
text,
&text->sel,
text->search,
ctx)) {
return false;
}
if (next_offset >= length)
break;
@ -1087,7 +1312,7 @@ static const content_handler textplain_content_handler = {
};
/* exported interface documented in render/textplain.h */
/* exported interface documented in html/textplain.h */
nserror textplain_init(void)
{
lwc_error lerror;
@ -1110,7 +1335,7 @@ nserror textplain_init(void)
}
/* exported interface documented in render/textplain.h */
/* exported interface documented in html/textplain.h */
unsigned long textplain_line_count(struct content *c)
{
textplain_content *text = (textplain_content *) c;
@ -1121,7 +1346,7 @@ unsigned long textplain_line_count(struct content *c)
}
/* exported interface documented in render/textplain.h */
/* exported interface documented in html/textplain.h */
size_t textplain_size(struct content *c)
{
textplain_content *text = (textplain_content *) c;
@ -1132,7 +1357,7 @@ size_t textplain_size(struct content *c)
}
/* exported interface documented in render/textplain.h */
/* exported interface documented in html/textplain.h */
size_t textplain_offset_from_coords(struct content *c, int x, int y, int dir)
{
textplain_content *textc = (textplain_content *) c;
@ -1207,7 +1432,7 @@ size_t textplain_offset_from_coords(struct content *c, int x, int y, int dir)
}
/* exported interface documented in render/textplain.h */
/* exported interface documented in html/textplain.h */
void
textplain_coords_from_range(struct content *c,
unsigned start,
@ -1261,7 +1486,7 @@ textplain_coords_from_range(struct content *c,
}
/* exported interface documented in render/textplain.h */
/* exported interface documented in html/textplain.h */
char *
textplain_get_line(struct content *c,
unsigned lineno,
@ -1283,7 +1508,7 @@ textplain_get_line(struct content *c,
}
/* exported interface documented in render/textplain.h */
/* exported interface documented in html/textplain.h */
int textplain_find_line(struct content *c, unsigned offset)
{
textplain_content *text = (textplain_content *) c;
@ -1312,7 +1537,7 @@ int textplain_find_line(struct content *c, unsigned offset)
}
/* exported interface documented in render/textplain.h */
/* exported interface documented in html/textplain.h */
char *
textplain_get_raw_data(struct content *c,
unsigned start,
@ -1339,7 +1564,7 @@ textplain_get_raw_data(struct content *c,
}
/* exported interface documented in render/textplain.h */
/* exported interface documented in html/textplain.h */
struct browser_window *textplain_get_browser_window(struct content *c)
{
textplain_content *text = (textplain_content *) c;

View File

@ -23,8 +23,8 @@
* Interface to content handler for plain text.
*/
#ifndef NETSURF_RENDER_TEXTPLAIN_H
#define NETSURF_RENDER_TEXTPLAIN_H
#ifndef NETSURF_HTML_TEXTPLAIN_H
#define NETSURF_HTML_TEXTPLAIN_H
#include <stddef.h>
#include "netsurf/mouse.h"

View File

@ -56,9 +56,9 @@
#include "content/hlcache.h"
#include "content/urldb.h"
#include "css/utils.h"
#include "render/form_internal.h"
#include "render/html.h"
#include "render/box.h"
#include "html/form_internal.h"
#include "html/html.h"
#include "html/box.h"
#include "javascript/js.h"
#include "desktop/browser_history.h"

View File

@ -33,8 +33,8 @@
#include "utils/utils.h"
#include "netsurf/content.h"
#include "content/hlcache.h"
#include "render/html.h"
#include "render/box.h"
#include "html/html.h"
#include "html/box.h"
#include "desktop/browser_private.h"
#include "desktop/frames.h"

View File

@ -41,8 +41,8 @@
#include "image/image.h"
#include "image/image_cache.h"
#include "javascript/js.h"
#include "render/html.h"
#include "render/textplain.h"
#include "html/html.h"
#include "text/textplain.h"
#include "netsurf/browser_window.h"
#include "desktop/system_colour.h"

View File

@ -34,7 +34,7 @@
#include "netsurf/plotters.h"
#include "content/hlcache.h"
#include "css/utils.h"
#include "render/box.h"
#include "html/box.h"
#include "desktop/print.h"
#include "desktop/printer.h"

View File

@ -43,8 +43,8 @@
#include "netsurf/content.h"
#include "content/hlcache.h"
#include "css/css.h"
#include "render/box.h"
#include "render/html.h"
#include "html/box.h"
#include "html/html.h"
#include "netsurf/misc.h"
#include "desktop/gui_internal.h"

View File

@ -32,8 +32,8 @@
#include "utils/utf8.h"
#include "utils/utils.h"
#include "netsurf/content.h"
#include "render/box.h"
#include "render/html.h"
#include "html/box.h"
#include "html/html.h"
#include "netsurf/utf8.h"
#include "desktop/gui_internal.h"

View File

@ -32,10 +32,10 @@
#include "utils/utf8.h"
#include "utils/utils.h"
#include "netsurf/form.h"
#include "render/box.h"
#include "render/html_internal.h"
#include "render/font.h"
#include "render/textplain.h"
#include "html/box.h"
#include "html/html_internal.h"
#include "html/font.h"
#include "text/textplain.h"
#include "netsurf/mouse.h"
#include "desktop/browser_private.h"

View File

@ -37,9 +37,9 @@
#include "netsurf/form.h"
#include "netsurf/window.h"
#include "netsurf/keypress.h"
#include "render/box.h"
#include "render/html_internal.h"
#include "render/layout.h"
#include "html/box.h"
#include "html/html_internal.h"
#include "html/layout.h"
#include "desktop/browser_private.h"
#include "desktop/textinput.h"

View File

@ -33,7 +33,7 @@
#include "utils/messages.h"
#include "netsurf/plotters.h"
#include "netsurf/content.h"
#include "render/box.h"
#include "html/box.h"
#include "content/llcache.h"
#include "content/content_protected.h"

View File

@ -1,10 +0,0 @@
# Render sources
S_RENDER := box.c box_construct.c box_normalise.c box_textarea.c \
font.c form.c imagemap.c layout.c search.c table.c textplain.c \
html.c html_css.c html_css_fetcher.c html_script.c \
html_interaction.c html_redraw.c html_redraw_border.c \
html_forms.c html_object.c
S_RENDER := $(addprefix render/,$(S_RENDER))