summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@netsurf-browser.org>2018-05-10 11:34:26 +0100
committerVincent Sanders <vince@kyllikki.org>2018-05-10 13:37:02 +0100
commit2a03ea30490892ac52b3da325ab78e1aa888f83e (patch)
treed041e4a2aab3b224ad41612d47ea2119895e27ac
parent1b892391d7859398c212b9fda5b532308fa6e8fd (diff)
downloadnetsurf-2a03ea30490892ac52b3da325ab78e1aa888f83e.tar.gz
netsurf-2a03ea30490892ac52b3da325ab78e1aa888f83e.tar.bz2
move html and text content handlers where they belong
-rw-r--r--Makefile4
-rw-r--r--content/handlers/Makefile11
-rw-r--r--content/handlers/html/Makefile7
-rw-r--r--content/handlers/html/box.c (renamed from render/box.c)23
-rw-r--r--content/handlers/html/box.h (renamed from render/box.h)9
-rw-r--r--content/handlers/html/box_construct.c (renamed from render/box_construct.c)27
-rw-r--r--content/handlers/html/box_normalise.c (renamed from render/box_normalise.c)47
-rw-r--r--content/handlers/html/box_textarea.c (renamed from render/box_textarea.c)10
-rw-r--r--content/handlers/html/box_textarea.h (renamed from render/box_textarea.h)13
-rw-r--r--content/handlers/html/font.c (renamed from render/font.c)12
-rw-r--r--content/handlers/html/font.h (renamed from render/font.h)15
-rw-r--r--content/handlers/html/form.c (renamed from render/form.c)180
-rw-r--r--content/handlers/html/form_internal.h (renamed from render/form_internal.h)8
-rw-r--r--content/handlers/html/html.c (renamed from render/html.c)91
-rw-r--r--content/handlers/html/html.h (renamed from render/html.h)30
-rw-r--r--content/handlers/html/html_css.c (renamed from render/html_css.c)13
-rw-r--r--content/handlers/html/html_css_fetcher.c (renamed from render/html_css_fetcher.c)42
-rw-r--r--content/handlers/html/html_forms.c (renamed from render/html_forms.c)12
-rw-r--r--content/handlers/html/html_interaction.c (renamed from render/html_interaction.c)54
-rw-r--r--content/handlers/html/html_internal.h (renamed from render/html_internal.h)31
-rw-r--r--content/handlers/html/html_object.c (renamed from render/html_object.c)69
-rw-r--r--content/handlers/html/html_redraw.c (renamed from render/html_redraw.c)50
-rw-r--r--content/handlers/html/html_redraw_border.c (renamed from render/html_redraw_border.c)4
-rw-r--r--content/handlers/html/html_script.c (renamed from render/html_script.c)13
-rw-r--r--content/handlers/html/imagemap.c (renamed from render/imagemap.c)13
-rw-r--r--content/handlers/html/imagemap.h (renamed from render/imagemap.h)9
-rw-r--r--content/handlers/html/layout.c (renamed from render/layout.c)24
-rw-r--r--content/handlers/html/layout.h (renamed from render/layout.h)6
-rw-r--r--content/handlers/html/search.c (renamed from render/search.c)22
-rw-r--r--content/handlers/html/search.h (renamed from render/search.h)9
-rw-r--r--content/handlers/html/table.c (renamed from render/table.c)72
-rw-r--r--content/handlers/html/table.h (renamed from render/table.h)9
-rw-r--r--content/handlers/javascript/duktape/Document.bnd2
-rw-r--r--content/handlers/javascript/duktape/Window.bnd4
-rw-r--r--content/handlers/text/Makefile3
-rw-r--r--content/handlers/text/textplain.c (renamed from render/textplain.c)269
-rw-r--r--content/handlers/text/textplain.h (renamed from render/textplain.h)6
-rw-r--r--desktop/browser.c6
-rw-r--r--desktop/frames.c4
-rw-r--r--desktop/netsurf.c4
-rw-r--r--desktop/print.c2
-rw-r--r--desktop/save_complete.c4
-rw-r--r--desktop/save_text.c4
-rw-r--r--desktop/selection.c8
-rw-r--r--desktop/textinput.c6
-rw-r--r--frontends/amiga/dt_sound.c2
-rw-r--r--render/Makefile10
47 files changed, 758 insertions, 515 deletions
diff --git a/Makefile b/Makefile
index 52f55d52a..3109a771c 100644
--- a/Makefile
+++ b/Makefile
@@ -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) \
diff --git a/content/handlers/Makefile b/content/handlers/Makefile
index 2f2da3aed..ea9d0c84d 100644
--- a/content/handlers/Makefile
+++ b/content/handlers/Makefile
@@ -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
diff --git a/content/handlers/html/Makefile b/content/handlers/html/Makefile
new file mode 100644
index 000000000..afefba27d
--- /dev/null
+++ b/content/handlers/html/Makefile
@@ -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
diff --git a/render/box.c b/content/handlers/html/box.c
index c97e8982b..52cf12413 100644
--- a/render/box.c
+++ b/content/handlers/html/box.c
@@ -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)
@@ -62,7 +62,7 @@ static int box_talloc_destructor(struct box *b)
css_computed_style_destroy(b->style);
b->style = NULL;
}
-
+
if (b->styles != NULL) {
css_select_results_destroy(b->styles);
b->styles = NULL;
@@ -112,7 +112,7 @@ static int box_talloc_destructor(struct box *b)
*/
struct box * box_create(css_select_results *styles, css_computed_style *style,
- bool style_owned, nsurl *href, const char *target,
+ bool style_owned, nsurl *href, const char *target,
const char *title, lwc_string *id, void *context)
{
unsigned int i;
@@ -448,7 +448,7 @@ static bool box_contains_point(
*physically = true;
return true;
}
- if ((box->style && css_computed_overflow_x(box->style) ==
+ if ((box->style && css_computed_overflow_x(box->style) ==
CSS_OVERFLOW_VISIBLE) || !box->style) {
if (box->descendant_x0 <= x &&
x < box->descendant_x1) {
@@ -456,7 +456,7 @@ static bool box_contains_point(
return true;
}
}
- if ((box->style && css_computed_overflow_y(box->style) ==
+ if ((box->style && css_computed_overflow_y(box->style) ==
CSS_OVERFLOW_VISIBLE) || !box->style) {
if (box->descendant_y0 <= y &&
y < box->descendant_y1) {
@@ -981,7 +981,7 @@ struct box *box_find_by_id(struct box *box, lwc_string *id)
bool box_visible(struct box *box)
{
/* visibility: hidden */
- if (box->style && css_computed_visibility(box->style) ==
+ if (box->style && css_computed_visibility(box->style) ==
CSS_VISIBILITY_HIDDEN)
return false;
@@ -1040,7 +1040,7 @@ void box_dump(FILE *stream, struct box *box, unsigned int depth, bool style)
if (box->space)
fprintf(stream, "space ");
if (box->object) {
- fprintf(stream, "(object '%s') ",
+ fprintf(stream, "(object '%s') ",
nsurl_access(hlcache_handle_get_url(box->object)));
}
if (box->iframe) {
@@ -1206,10 +1206,10 @@ bool box_handle_scrollbars(struct content *c, struct box *box,
visible_width, full_width);
}
}
-
+
if (right && bottom)
scrollbar_make_pair(box->scroll_x, box->scroll_y);
-
+
return true;
}
@@ -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;
}
-
diff --git a/render/box.h b/content/handlers/html/box.h
index 1af0a8b73..f096b6714 100644
--- a/render/box.h
+++ b/content/handlers/html/box.h
@@ -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>
@@ -321,7 +322,7 @@ extern const char *TARGET_BLANK;
struct box * box_create(css_select_results *styles, css_computed_style *style,
- bool style_owned, struct nsurl *href, const char *target,
+ bool style_owned, struct nsurl *href, const char *target,
const char *title, lwc_string *id, void *context);
void box_add_child(struct box *parent, struct box *child);
void box_insert_sibling(struct box *box, struct box *new_box);
diff --git a/render/box_construct.c b/content/handlers/html/box_construct.c
index 1aa99e2d1..9c19391de 100644
--- a/render/box_construct.c
+++ b/content/handlers/html/box_construct.c
@@ -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
@@ -751,8 +751,8 @@ bool box_construct_element(struct box_construct_ctx *ctx,
if (props.containing_block != NULL) {
/* In case the containing block is a pre block, we clear
- * the PRE_STRIP flag since it is not used if we follow
- * the pre with a tag */
+ * the PRE_STRIP flag since it is not used if we follow
+ * the pre with a tag */
props.containing_block->flags &= ~PRE_STRIP;
}
@@ -2068,9 +2068,9 @@ bool box_create_frameset(struct content_html_frames *f, dom_node *n,
/* common extension: frameborder="yes|no" to control all children */
err = dom_element_get_attribute(n, corestring_dom_frameborder, &s);
if (err == DOM_NO_ERR && s != NULL) {
- if (dom_string_caseless_lwc_isequal(s,
- corestring_lwc_no) == 0)
- default_border = false;
+ if (dom_string_caseless_lwc_isequal(s,
+ corestring_lwc_no) == 0)
+ default_border = false;
dom_string_unref(s);
}
@@ -2214,8 +2214,8 @@ bool box_create_frameset(struct content_html_frames *f, dom_node *n,
/* copy url */
if (url != NULL) {
- /* no self-references */
- if (nsurl_compare(content->base_url, url,
+ /* no self-references */
+ if (nsurl_compare(content->base_url, url,
NSURL_COMPLETE) == false)
frame->url = url;
url = NULL;
@@ -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;
}
-
-
-
diff --git a/render/box_normalise.c b/content/handlers/html/box_normalise.c
index 8da245754..7155cb722 100644
--- a/render/box_normalise.c
+++ b/content/handlers/html/box_normalise.c
@@ -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
@@ -76,7 +77,7 @@ static bool box_normalise_table_spans(
html_content *c);
static bool box_normalise_table_row_group(
struct box *row_group,
- const struct box *root,
+ const struct box *root,
struct columns *col_info,
html_content *c);
static bool box_normalise_table_row(
@@ -460,7 +461,7 @@ bool box_normalise_table_spans(
/* Clear span data */
memset(spans, 0, table->columns * sizeof(struct span_info));
- /* Scan table, filling in width and height of table cells with
+ /* Scan table, filling in width and height of table cells with
* colspan = 0 and rowspan = 0. Also generate empty cells */
for (table_row_group = table->children;
table_row_group != NULL;
@@ -509,34 +510,34 @@ bool box_normalise_table_spans(
css_computed_style *style;
struct box *cell, *prev;
- /* If it's already zero, then we need
- * to generate an empty cell for the
- * gap in the row that spans as many
- * columns as remain blank.
+ /* If it's already zero, then we need
+ * to generate an empty cell for the
+ * gap in the row that spans as many
+ * columns as remain blank.
*/
assert(table_row->style != NULL);
/* Find width of gap */
while (col < table->columns &&
- spans[col].row_span ==
+ spans[col].row_span ==
0) {
col++;
}
ctx.ctx = c->select_ctx;
- ctx.quirks = (c->quirks ==
+ ctx.quirks = (c->quirks ==
DOM_DOCUMENT_QUIRKS_MODE_FULL);
ctx.base_url = c->base_url;
ctx.universal = c->universal;
- style = nscss_get_blank_style(&ctx,
+ style = nscss_get_blank_style(&ctx,
table_row->style);
if (style == NULL)
return false;
- cell = box_create(NULL, style, true,
- table_row->href,
- table_row->target,
+ cell = box_create(NULL, style, true,
+ table_row->href,
+ table_row->target,
NULL, NULL, c->bctx);
if (cell == NULL) {
css_computed_style_destroy(
@@ -553,8 +554,8 @@ bool box_normalise_table_spans(
for (prev = table_row->children;
prev != NULL;
prev = prev->next) {
- if (prev->start_column +
- prev->columns ==
+ if (prev->start_column +
+ prev->columns ==
start)
break;
if (prev->next == NULL)
@@ -569,7 +570,7 @@ bool box_normalise_table_spans(
else
table_row->last = cell;
- cell->next =
+ cell->next =
table_row->children;
table_row->children = cell;
} else {
@@ -867,7 +868,7 @@ bool box_normalise_table_row(
/* Update row spanning details for all columns */
for (i = 0; i < col_info->num_columns; i++) {
- if (col_info->spans[i].row_span != 0 &&
+ if (col_info->spans[i].row_span != 0 &&
col_info->spans[i].auto_row == false) {
/* This cell spans rows, and is not an auto row.
* Reduce number of rows left to span */
@@ -926,12 +927,12 @@ bool calculate_table_row(struct columns *col_info,
* No other browser supports colspan=0, anyway. */
if (col_span == 0)
col_span = 1;
-
+
cell_end_col = cell_start_col + col_span;
if (col_info->num_columns < cell_end_col) {
/* It appears that this row has more columns than
- * the maximum recorded for the table so far.
+ * the maximum recorded for the table so far.
* Allocate more span records. */
spans = realloc(col_info->spans,
sizeof *spans * (cell_end_col + 1));
@@ -946,7 +947,7 @@ bool calculate_table_row(struct columns *col_info,
col_info->spans[cell_end_col].auto_row = false;
}
- /* This cell may span multiple columns. If it also wants to span
+ /* This cell may span multiple columns. If it also wants to span
* multiple rows, temporarily assume it spans 1 row only. This will
* be fixed up in box_normalise_table_spans() */
for (i = cell_start_col; i < cell_end_col; i++) {
diff --git a/render/box_textarea.c b/content/handlers/html/box_textarea.c
index a60984235..abd28fb86 100644
--- a/render/box_textarea.c
+++ b/content/handlers/html/box_textarea.c
@@ -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;
}
-
diff --git a/render/box_textarea.h b/content/handlers/html/box_textarea.h
index a7a377076..e2b02e811 100644
--- a/render/box_textarea.h
+++ b/content/handlers/html/box_textarea.h
@@ -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;
diff --git a/render/font.c b/content/handlers/html/font.c
index a769b476f..9dbf5922b 100644
--- a/render/font.c
+++ b/content/handlers/html/font.c
@@ -19,23 +19,23 @@
/**
* \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
*
- * \param css Generic CSS font family
+ * \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,
diff --git a/render/font.h b/content/handlers/html/font.h
index 52f5a62c2..5f69ee7d3 100644
--- a/render/font.h
+++ b/content/handlers/html/font.h
@@ -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,9 +36,8 @@ 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,
- const css_computed_style *css,
- struct plot_font_style *fstyle);
+void font_plot_style_from_css(const nscss_len_ctx *len_ctx,
+ const css_computed_style *css,
+ struct plot_font_style *fstyle);
#endif
diff --git a/render/form.c b/content/handlers/html/form.c
index 432002564..9fe2e771a 100644
--- a/render/form.c
+++ b/content/handlers/html/form.c
@@ -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,9 +96,9 @@ 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 */
-struct form *form_new(void *node, const char *action, const char *target,
- form_method method, const char *charset,
+/* 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)
{
struct form *form;
@@ -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)
@@ -347,7 +347,7 @@ bool form_successful_controls_dom(struct form *_form,
last_success = &sentinel;
sentinel.next = NULL;
-
+
/** \todo Replace this call with something DOMish */
charset = form_acceptable_charset(_form);
if (charset == NULL) {
@@ -361,22 +361,22 @@ bool form_successful_controls_dom(struct form *_form,
form_encode_item(dom_string_data(i), dom_string_byte_length(i), \
charset, _form->document_charset) \
))
-
+
err = dom_html_form_element_get_elements(form, &form_elements);
-
+
if (err != DOM_NO_ERR) {
NSLOG(netsurf, INFO, "Could not get form elements");
goto dom_no_memory;
}
-
-
+
+
err = dom_html_collection_get_length(form_elements, &element_count);
-
+
if (err != DOM_NO_ERR) {
NSLOG(netsurf, INFO, "Could not get form element count");
goto dom_no_memory;
}
-
+
for (index = 0; index < element_count; index++) {
if (form_element != NULL) {
dom_node_unref(form_element);
@@ -501,7 +501,7 @@ bool form_successful_controls_dom(struct form *_form,
continue;
if (inputname == NULL)
continue;
-
+
if (dom_string_isequal(nodename, corestring_dom_TEXTAREA)) {
err = dom_html_text_area_element_get_value(
(dom_html_text_area_element *)form_element,
@@ -565,17 +565,17 @@ bool form_successful_controls_dom(struct form *_form,
"Could not get option value");
goto dom_no_memory;
}
-
+
success_new = calloc(1, sizeof(*success_new));
if (success_new == NULL) {
NSLOG(netsurf, INFO,
"Could not allocate data for option");
goto dom_no_memory;
}
-
+
last_success->next = success_new;
last_success = success_new;
-
+
success_new->name = ENCODE_ITEM(inputname);
if (success_new->name == NULL) {
NSLOG(netsurf, INFO,
@@ -668,7 +668,7 @@ bool form_successful_controls_dom(struct form *_form,
if ((dom_node *)submit_button !=
(dom_node *)form_element)
continue;
-
+
err = dom_node_get_user_data(
form_element,
corestring_dom___ns_key_image_coords_node_data,
@@ -683,9 +683,9 @@ bool form_successful_controls_dom(struct form *_form,
"No XY data on the image input");
goto dom_no_memory;
}
-
+
basename = ENCODE_ITEM(inputname);
-
+
success_new = calloc(1, sizeof(*success_new));
if (success_new == NULL) {
free(basename);
@@ -693,10 +693,10 @@ bool form_successful_controls_dom(struct form *_form,
"Could not allocate data for image.x");
goto dom_no_memory;
}
-
+
last_success->next = success_new;
last_success = success_new;
-
+
success_new->name = malloc(strlen(basename) + 3);
if (success_new->name == NULL) {
free(basename);
@@ -713,7 +713,7 @@ bool form_successful_controls_dom(struct form *_form,
}
sprintf(success_new->name, "%s.x", basename);
sprintf(success_new->value, "%d", coords->x);
-
+
success_new = calloc(1, sizeof(*success_new));
if (success_new == NULL) {
free(basename);
@@ -721,10 +721,10 @@ bool form_successful_controls_dom(struct form *_form,
"Could not allocate data for image.y");
goto dom_no_memory;
}
-
+
last_success->next = success_new;
last_success = success_new;
-
+
success_new->name = malloc(strlen(basename) + 3);
if (success_new->name == NULL) {
free(basename);
@@ -820,17 +820,17 @@ bool form_successful_controls_dom(struct form *_form,
/* Fall out to the allocation */
}
}
-
+
success_new = calloc(1, sizeof(*success_new));
if (success_new == NULL) {
NSLOG(netsurf, INFO,
"Could not allocate data for generic");
goto dom_no_memory;
}
-
+
last_success->next = success_new;
last_success = success_new;
-
+
success_new->name = ENCODE_ITEM(inputname);
if (success_new->name == NULL) {
NSLOG(netsurf, INFO,
@@ -849,7 +849,7 @@ bool form_successful_controls_dom(struct form *_form,
rawfile_temp = NULL;
}
}
-
+
free(charset);
if (form_element != NULL) {
@@ -889,13 +889,13 @@ bool form_successful_controls_dom(struct form *_form,
}
*successful_controls = sentinel.next;
-
+
return true;
-
+
dom_no_memory:
free(charset);
fetch_multipart_data_destroy(sentinel.next);
-
+
if (form_elements != NULL)
dom_html_collection_unref(form_elements);
if (form_element != NULL)
@@ -914,7 +914,7 @@ dom_no_memory:
dom_string_unref(inputtype);
if (rawfile_temp != NULL)
free(rawfile_temp);
-
+
return false;
}
#undef ENCODE_ITEM
@@ -1091,7 +1091,7 @@ char *form_encode_item(const char *item, uint32_t len, const char *charset,
if (err == NSERROR_BAD_ENCODING) {
/* nope, try fallback charset (if any) */
if (fallback) {
- snprintf(cset, sizeof cset,
+ snprintf(cset, sizeof cset,
"%s//TRANSLIT", fallback);
err = utf8_to_enc(item, cset, 0, &ret);
@@ -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,
@@ -1179,7 +1179,7 @@ bool form_open_select_menu(void *client_data,
menu->callback = callback;
if (scrollbar_create(false,
menu->height,
- total_height,
+ total_height,
menu->height,
control,
form_select_menu_scroll_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)
@@ -1229,24 +1229,24 @@ bool form_redraw_select_menu(struct form_control *control, int x, int y,
nserror res;
box = control->box;
-
+
x_cp = x;
y_cp = y;
width = menu->width;
height = menu->height;
line_height = menu->line_height;
-
+
line_height_with_spacing = line_height +
line_height * SELECT_LINE_SPACING;
scroll = scrollbar_get_offset(menu->scrollbar);
-
+
if (scale != 1.0) {
x *= scale;
y *= scale;
width *= scale;
height *= scale;
scrollbar_width *= scale;
-
+
i = scroll / line_height_with_spacing;
scroll -= i * line_height_with_spacing;
line_height *= scale;
@@ -1254,8 +1254,8 @@ bool form_redraw_select_menu(struct form_control *control, int x, int y,
scroll *= scale;
scroll += i * line_height_with_spacing;
}
-
-
+
+
x0 = x;
y0 = y;
x1 = x + width - 1;
@@ -1302,7 +1302,7 @@ bool form_redraw_select_menu(struct form_control *control, int x, int y,
option = control->data.select.items;
item_y = line_height_with_spacing;
-
+
while (item_y < scroll) {
option = option->next;
item_y += line_height_with_spacing;
@@ -1311,14 +1311,14 @@ bool form_redraw_select_menu(struct form_control *control, int x, int y,
text_pos_offset = y - scroll +
(int) (line_height * (0.75 + SELECT_LINE_SPACING));
text_x = x + (box->border[LEFT].width + box->padding[LEFT]) * scale;
-
+
plot_fstyle_entry.size = menu->f_size;
-
+
while (option && item_y - scroll < height) {
- if (option->selected) {
- y2 = y + item_y - scroll;
- y3 = y + item_y + line_height_with_spacing - scroll;
+ if (option->selected) {
+ y2 = y + item_y - scroll;
+ y3 = y + item_y + line_height_with_spacing - scroll;
rect.x0 = x0;
rect.y0 = y0 > y2 ? y0 : y2;
@@ -1328,7 +1328,7 @@ bool form_redraw_select_menu(struct form_control *control, int x, int y,
if (res != NSERROR_OK) {
return false;
}
- }
+ }
y2 = text_pos_offset + item_y;
res = ctx->plot->text(ctx,
@@ -1368,16 +1368,16 @@ bool form_clip_inside_select_menu(struct form_control *control, float scale,
{
struct form_select_menu *menu = control->data.select.menu;
int width, height;
-
+
width = menu->width;
height = menu->height;
-
+
if (scale != 1.0) {
width *= scale;
height *= scale;
}
-
+
if (clip->x0 >= 0 && clip->x1 <= width &&
clip->y0 >= 0 && clip->y1 <= height)
return true;
@@ -1509,26 +1509,26 @@ nserror form_control_bounding_rect(struct form_control *control, struct rect *r)
/**
* Handle a click on the area of the currently opened select menu.
- *
+ *
* \param control the select menu which received the click
* \param x X coordinate of click
* \param y Y coordinate of click
*/
void form_select_menu_clicked(struct form_control *control, int x, int y)
-{
+{
struct form_select_menu *menu = control->data.select.menu;
struct form_option *option;
html_content *html = (html_content *)menu->c;
- int line_height, line_height_with_spacing;
+ int line_height, line_height_with_spacing;
int item_bottom_y;
int scroll, i;
-
+
scroll = scrollbar_get_offset(menu->scrollbar);
-
+
line_height = menu->line_height;
line_height_with_spacing = line_height +
line_height * SELECT_LINE_SPACING;
-
+
option = control->data.select.items;
item_bottom_y = line_height_with_spacing;
i = 0;
@@ -1537,11 +1537,11 @@ void form_select_menu_clicked(struct form_control *control, int x, int y)
option = option->next;
i++;
}
-
+
if (option != NULL) {
form__select_process_selection(html, control, i);
}
-
+
menu->callback(menu->client_data, 0, 0, menu->width, menu->height);
}
@@ -1553,7 +1553,7 @@ void form_select_menu_clicked(struct form_control *control, int x, int y)
* \param x X coordinate of click
* \param y Y coordinate of click
* \return text for the browser status bar or NULL if the menu has
- * to be closed
+ * to be closed
*/
const char *form_select_mouse_action(struct form_control *control,
browser_mouse_state mouse, int x, int y)
@@ -1562,13 +1562,13 @@ const char *form_select_mouse_action(struct form_control *control,
int x0, y0, x1, y1, scrollbar_x;
const char *status = NULL;
bool multiple = control->data.select.multiple;
-
+
x0 = 0;
y0 = 0;
x1 = menu->width;
y1 = menu->height;
scrollbar_x = x1 - SCROLLBAR_WIDTH;
-
+
if (menu->scroll_capture ||
(x > scrollbar_x && x < x1 && y > y0 && y < y1)) {
/* The scroll is currently capturing all events or the mouse
@@ -1579,25 +1579,25 @@ const char *form_select_mouse_action(struct form_control *control,
scrollbar_mouse_action(menu->scrollbar,
mouse, x, y));
}
-
-
+
+
if (x > x0 && x < scrollbar_x && y > y0 && y < y1) {
/* over option area */
-
+
if (mouse & (BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_CLICK_2))
/* button 1 or 2 click */
form_select_menu_clicked(control, x, y);
-
+
if (!(mouse & BROWSER_MOUSE_CLICK_1 && !multiple))
/* anything but a button 1 click over a single select
menu */
status = messages_get(control->data.select.multiple ?
"SelectMClick" : "SelectClick");
-
+
} else if (!(mouse & (BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_CLICK_2)))
/* if not a button 1 or 2 click*/
status = messages_get("SelectClose");
-
+
return status;
}
@@ -1634,13 +1634,13 @@ void form_select_mouse_drag_end(struct form_control *control,
scrollbar_mouse_drag_end(menu->scrollbar, mouse, x, y);
return;
}
-
+
x0 = 0;
y0 = 0;
x1 = menu->width;
y1 = menu->height;
-
-
+
+
if (x > x0 && x < x1 - SCROLLBAR_WIDTH && y > y0 && y < y1)
/* handle drag end above the option area like a regular click */
form_select_menu_clicked(control, x, y);
@@ -1655,13 +1655,13 @@ void form_select_menu_scroll_callback(void *client_data,
struct form_control *control = client_data;
struct form_select_menu *menu = control->data.select.menu;
html_content *html = (html_content *)menu->c;
-
+
switch (scrollbar_data->msg) {
case SCROLLBAR_MSG_MOVED:
menu->callback(menu->client_data,
- 0, 0,
+ 0, 0,
menu->width,
- menu->height);
+ menu->height);
break;
case SCROLLBAR_MSG_SCROLL_START:
{
@@ -1712,10 +1712,10 @@ void form_select_menu_callback(void *client_data,
html_content *html = client_data;
int menu_x, menu_y;
struct box *box;
-
+
box = html->visible_select_menu->box;
box_coords(box, &menu_x, &menu_y);
-
+
menu_x -= box->border[LEFT].width;
menu_y += box->height + box->border[BOTTOM].width +
box->padding[BOTTOM] +
@@ -1802,7 +1802,7 @@ void form_submit(nsurl *page_url, struct browser_window *target,
}
/* Replace query segment */
- error = nsurl_replace_query(action_url, data, &action_query);
+ error = nsurl_replace_query(action_url, data, &action_query);
if (error != NSERROR_OK) {
nsurl_unref(action_query);
free(data);
@@ -1842,12 +1842,12 @@ void form_submit(nsurl *page_url, struct browser_window *target,
break;
case method_POST_MULTIPART:
- browser_window_navigate(target,
- action_url,
+ browser_window_navigate(target,
+ action_url,
page_url,
BW_NAVIGATE_HISTORY,
- NULL,
- success,
+ NULL,
+ success,
NULL);
break;
diff --git a/render/form_internal.h b/content/handlers/html/form_internal.h
index 0ffb6b46c..a77e823b3 100644
--- a/render/form_internal.h
+++ b/content/handlers/html/form_internal.h
@@ -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>
@@ -229,7 +229,7 @@ bool form_successful_controls_dom(struct form *form,
bool form_open_select_menu(void *client_data,
struct form_control *control,
select_menu_redraw_callback redraw_callback,
- struct content *c);
+ struct content *c);
void form_select_menu_callback(void *client_data,
diff --git a/render/html.c b/content/handlers/html/html.c
index b7d7aa313..18c1a7afb 100644
--- a/render/html.c
+++ b/content/handlers/html/html.c
@@ -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
@@ -139,7 +139,7 @@ static void html_box_convert_done(html_content *c, bool success)
exc = dom_document_get_document_element(c->document, (void *) &html);
if ((exc != DOM_NO_ERR) || (html == NULL)) {
/** @todo should this call html_object_free_objects(c);
- * like the other error paths
+ * like the other error paths
*/
NSLOG(netsurf, INFO, "error retrieving html element from dom");
content_broadcast_errorcode(&c->base, NSERROR_DOM);
@@ -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;
@@ -998,8 +998,8 @@ html_create(const content_handler *handler,
static nserror
-html_process_encoding_change(struct content *c,
- const char *data,
+html_process_encoding_change(struct content *c,
+ const char *data,
unsigned int size)
{
html_content *html = (html_content *) c;
@@ -1010,7 +1010,7 @@ html_process_encoding_change(struct content *c,
unsigned long source_size;
/* Retrieve new encoding */
- encoding = dom_hubbub_parser_get_encoding(html->parser,
+ encoding = dom_hubbub_parser_get_encoding(html->parser,
&html->encoding_source);
if (encoding == NULL) {
return NSERROR_NOMEM;
@@ -1070,10 +1070,10 @@ html_process_encoding_change(struct content *c,
/* Reprocess all the data. This is safe because
* the encoding is now specified at parser start which means
- * it cannot be changed again.
+ * it cannot be changed again.
*/
- error = dom_hubbub_parser_parse_chunk(html->parser,
- (const uint8_t *)source_data,
+ error = dom_hubbub_parser_parse_chunk(html->parser,
+ (const uint8_t *)source_data,
source_size);
return libdom_hubbub_error_to_nserror(error);
@@ -1091,8 +1091,8 @@ html_process_data(struct content *c, const char *data, unsigned int size)
dom_hubbub_error dom_ret;
nserror err = NSERROR_OK; /* assume its all going to be ok */
- dom_ret = dom_hubbub_parser_parse_chunk(html->parser,
- (const uint8_t *) data,
+ dom_ret = dom_hubbub_parser_parse_chunk(html->parser,
+ (const uint8_t *) data,
size);
err = libdom_hubbub_error_to_nserror(dom_ret);
@@ -1108,7 +1108,7 @@ html_process_data(struct content *c, const char *data, unsigned int size)
return false;
}
- return true;
+ return true;
}
@@ -1188,14 +1188,14 @@ html_begin_conversion(html_content *htmlc)
dom_string *node_name = NULL;
dom_hubbub_error error;
- /* The act of completing the parse can result in additional data
- * being flushed through the parser. This may result in new style or
- * script nodes, upon which the conversion depends. Thus, once we
- * have completed the parse, we must check again to see if we can
- * begin the conversion. If we can't, we must stop and wait for the
+ /* The act of completing the parse can result in additional data
+ * being flushed through the parser. This may result in new style or
+ * script nodes, upon which the conversion depends. Thus, once we
+ * have completed the parse, we must check again to see if we can
+ * begin the conversion. If we can't, we must stop and wait for the
* new styles/scripts to be processed. Once they have been processed,
- * we will be called again to begin the conversion for real. Thus,
- * we must also ensure that we don't attempt to complete the parse
+ * we will be called again to begin the conversion for real. Thus,
+ * we must also ensure that we don't attempt to complete the parse
* multiple times, so store a flag to indicate that parsing is
* complete to avoid repeating the completion pointlessly.
*/
@@ -1205,8 +1205,8 @@ html_begin_conversion(html_content *htmlc)
error = dom_hubbub_parser_completed(htmlc->parser);
if (error != DOM_HUBBUB_OK) {
NSLOG(netsurf, INFO, "Parsing failed");
-
- content_broadcast_errorcode(&htmlc->base,
+
+ content_broadcast_errorcode(&htmlc->base,
libdom_hubbub_error_to_nserror(error));
return false;
@@ -1243,14 +1243,14 @@ html_begin_conversion(html_content *htmlc)
encoding = dom_hubbub_parser_get_encoding(htmlc->parser,
&htmlc->encoding_source);
if (encoding == NULL) {
- content_broadcast_errorcode(&htmlc->base,
+ content_broadcast_errorcode(&htmlc->base,
NSERROR_NOMEM);
return false;
}
htmlc->encoding = strdup(encoding);
if (htmlc->encoding == NULL) {
- content_broadcast_errorcode(&htmlc->base,
+ content_broadcast_errorcode(&htmlc->base,
NSERROR_NOMEM);
return false;
}
@@ -1268,7 +1268,7 @@ html_begin_conversion(html_content *htmlc)
if ((exc != DOM_NO_ERR) ||
(node_name == NULL) ||
(!dom_string_caseless_lwc_isequal(node_name,
- corestring_lwc_html))) {
+ corestring_lwc_html))) {
NSLOG(netsurf, INFO, "root element not html");
content_broadcast_errorcode(&htmlc->base, NSERROR_DOM);
dom_node_unref(html);
@@ -1287,11 +1287,11 @@ html_begin_conversion(html_content *htmlc)
/* HTML5 4.10.22.3 step 9 */
nsurl *doc_addr = content_get_url(&htmlc->base);
ns_error = nsurl_join(htmlc->base_url,
- nsurl_access(doc_addr),
+ nsurl_access(doc_addr),
&action);
} else {
- ns_error = nsurl_join(htmlc->base_url,
- f->action,
+ ns_error = nsurl_join(htmlc->base_url,
+ f->action,
&action);
}
@@ -1306,7 +1306,7 @@ html_begin_conversion(html_content *htmlc)
f->action = strdup(nsurl_access(action));
nsurl_unref(action);
if (f->action == NULL) {
- content_broadcast_errorcode(&htmlc->base,
+ content_broadcast_errorcode(&htmlc->base,
NSERROR_NOMEM);
dom_node_unref(html);
@@ -1317,7 +1317,7 @@ html_begin_conversion(html_content *htmlc)
if (f->document_charset == NULL) {
f->document_charset = strdup(htmlc->encoding);
if (f->document_charset == NULL) {
- content_broadcast_errorcode(&htmlc->base,
+ content_broadcast_errorcode(&htmlc->base,
NSERROR_NOMEM);
dom_node_unref(html);
return false;
@@ -1363,7 +1363,7 @@ static void html_stop(struct content *c)
html_object_abort_objects(htmlc);
/* If there are no further active fetches and we're still
- * in the READY state, transition to the DONE state. */
+ * in the READY state, transition to the DONE state. */
if (c->status == CONTENT_STATUS_READY && c->active == 0) {
content_set_done(c);
}
@@ -1493,8 +1493,8 @@ static void html_destroy_frameset(struct content_html_frames *frameset)
nsurl_unref(frameset->children[i].url);
frameset->children[i].url = NULL;
}
- if (frameset->children[i].children)
- html_destroy_frameset(&frameset->children[i]);
+ if (frameset->children[i].children)
+ html_destroy_frameset(&frameset->children[i]);
}
talloc_free(frameset->children);
frameset->children = NULL;
@@ -1522,7 +1522,7 @@ static void html_free_layout(html_content *htmlc)
{
if (htmlc->bctx != NULL) {
/* freeing talloc context should let the entire box
- * set be destroyed
+ * set be destroyed
*/
talloc_free(htmlc->bctx);
}
@@ -1577,8 +1577,8 @@ static void html_destroy(struct content *c)
/* Free base target */
if (html->base_target != NULL) {
- free(html->base_target);
- html->base_target = NULL;
+ free(html->base_target);
+ html->base_target = NULL;
}
/* Free frameset */
@@ -1947,9 +1947,9 @@ static void html__set_file_gadget_filename(struct content *c,
NSLOG(netsurf, INFO,
"utf8 to local encoding conversion failed");
/* Load was for us - just no memory */
- return;
+ return;
}
-
+
form_gadget_update_value(gadget, utf8_fn);
/* corestring_dom___ns_key_file_name_node_data */
@@ -1962,7 +1962,7 @@ static void html__set_file_gadget_filename(struct content *c,
}
/* Redraw box. */
- html__redraw_a_box(html, file_box);
+ html__redraw_a_box(html, file_box);
}
void html_set_file_gadget_filename(struct hlcache_handle *hl,
@@ -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)
{
diff --git a/render/html.h b/content/handlers/html/html.h
index 30219a3bd..691e969a5 100644
--- a/render/html.h
+++ b/content/handlers/html/html.h
@@ -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 */
@@ -128,7 +131,7 @@ struct content_html_frames {
/** Inline frame list (iframe tag) */
struct content_html_iframe {
- struct box *box;
+ struct box *box;
int margin_width; /** frame margin width */
int margin_height; /** frame margin height */
@@ -140,7 +143,7 @@ struct content_html_iframe {
bool border; /** frame has a border */
colour border_colour; /** frame border colour */
- struct content_html_iframe *next;
+ struct content_html_iframe *next;
};
/* entries in stylesheet_content */
@@ -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);
diff --git a/render/html_css.c b/content/handlers/html/html_css.c
index 45bc16f56..b67d19af6 100644
--- a/render/html_css.c
+++ b/content/handlers/html/html_css.c
@@ -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;
diff --git a/render/html_css_fetcher.c b/content/handlers/html/html_css_fetcher.c
index 0f8809a42..7987ea094 100644
--- a/render/html_css_fetcher.c
+++ b/content/handlers/html/html_css_fetcher.c
@@ -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;
@@ -51,7 +56,7 @@ typedef struct html_css_fetcher_context {
bool aborted;
bool locked;
-
+
struct html_css_fetcher_context *r_next, *r_prev;
} html_css_fetcher_context;
@@ -86,7 +91,7 @@ static void *html_css_fetcher_setup(struct fetch *parent_fetch, nsurl *url,
lwc_string *path;
uint32_t key;
html_css_fetcher_item *item, *found = NULL;
-
+
/* format of a x-ns-css URL is:
* x-ns-url:<key>
* Where key is an unsigned 32bit integer
@@ -131,7 +136,7 @@ static void *html_css_fetcher_setup(struct fetch *parent_fetch, nsurl *url,
ctx->item = found;
RING_INSERT(ring, ctx);
-
+
return ctx;
}
@@ -160,14 +165,14 @@ static void html_css_fetcher_abort(void *ctx)
html_css_fetcher_context *c = ctx;
/* To avoid the poll loop having to deal with the fetch context
- * disappearing from under it, we simply flag the abort here.
+ * disappearing from under it, we simply flag the abort here.
* The poll loop itself will perform the appropriate cleanup.
*/
c->aborted = true;
}
-static void html_css_fetcher_send_callback(const fetch_msg *msg,
- html_css_fetcher_context *c)
+static void html_css_fetcher_send_callback(const fetch_msg *msg,
+ html_css_fetcher_context *c)
{
c->locked = true;
fetch_send_callback(msg, c->parent_fetch);
@@ -178,16 +183,16 @@ static void html_css_fetcher_poll(lwc_string *scheme)
{
fetch_msg msg;
html_css_fetcher_context *c, *next;
-
+
if (ring == NULL) return;
-
+
/* Iterate over ring, processing each pending fetch */
c = ring;
do {
/* Ignore fetches that have been flagged as locked.
* This allows safe re-entrant calls to this function.
* Re-entrancy can occur if, as a result of a callback,
- * the interested party causes fetch_poll() to be called
+ * the interested party causes fetch_poll() to be called
* again.
*/
if (c->locked == true) {
@@ -213,26 +218,26 @@ static void html_css_fetcher_poll(lwc_string *scheme)
msg.type = FETCH_HEADER;
msg.data.header_or_data.buf = (const uint8_t *) header;
msg.data.header_or_data.len = strlen(header);
- html_css_fetcher_send_callback(&msg, c);
+ html_css_fetcher_send_callback(&msg, c);
if (c->aborted == false) {
- snprintf(header, sizeof header,
+ snprintf(header, sizeof header,
"Content-Length: %"PRIsizet,
dom_string_byte_length(c->item->data));
msg.type = FETCH_HEADER;
- msg.data.header_or_data.buf =
+ msg.data.header_or_data.buf =
(const uint8_t *) header;
msg.data.header_or_data.len = strlen(header);
html_css_fetcher_send_callback(&msg, c);
}
if (c->aborted == false) {
- snprintf(header, sizeof header,
+ snprintf(header, sizeof header,
"X-NS-Base: %.*s",
(int) nsurl_length(c->item->base_url),
nsurl_access(c->item->base_url));
msg.type = FETCH_HEADER;
- msg.data.header_or_data.buf =
+ msg.data.header_or_data.buf =
(const uint8_t *) header;
msg.data.header_or_data.len = strlen(header);
html_css_fetcher_send_callback(&msg, c);
@@ -240,8 +245,8 @@ static void html_css_fetcher_poll(lwc_string *scheme)
if (c->aborted == false) {
msg.type = FETCH_DATA;
- msg.data.header_or_data.buf =
- (const uint8_t *)
+ msg.data.header_or_data.buf =
+ (const uint8_t *)
dom_string_data(c->item->data);
msg.data.header_or_data.len =
dom_string_byte_length(c->item->data);
@@ -256,7 +261,7 @@ static void html_css_fetcher_poll(lwc_string *scheme)
NSLOG(netsurf, INFO, "Processing of %s failed!",
nsurl_access(c->url));
- /* Ensure that we're unlocked here. If we aren't,
+ /* Ensure that we're unlocked here. If we aren't,
* then html_css_fetcher_process() is broken.
*/
assert(c->locked == false);
@@ -318,4 +323,3 @@ html_css_fetcher_add_item(dom_string *data, nsurl *base_url, uint32_t *key)
return NSERROR_OK;
}
-
diff --git a/render/html_forms.c b/content/handlers/html/html_forms.c
index 39bc690d9..915eb002f 100644
--- a/render/html_forms.c
+++ b/content/handlers/html/html_forms.c
@@ -16,14 +16,19 @@
* 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
*/
static struct form *
@@ -572,4 +577,3 @@ struct form_control *html_forms_get_control_for_node(struct form *forms,
return ctl;
}
-
diff --git a/render/html_interaction.c b/content/handlers/html/html_interaction.c
index 2d14ed2ae..898f55bc2 100644
--- a/render/html_interaction.c
+++ b/content/handlers/html/html_interaction.c
@@ -2,7 +2,7 @@
* Copyright 2006 James Bursa <bursa@users.sourceforge.net>
* Copyright 2006 Richard Wilson <info@tinct.net>
* Copyright 2008 Michael Drake <tlsa@netsurf-browser.org>
- * Copyright 2009 Paul Blokus <paul_pl@users.sourceforge.net>
+ * Copyright 2009 Paul Blokus <paul_pl@users.sourceforge.net>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -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
@@ -505,7 +505,7 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
assert(html->drag_type == HTML_DRAG_NONE);
/* search the box tree for a link, imagemap, form control, or
- * box with scrollbars
+ * box with scrollbars
*/
box = html->layout;
@@ -515,7 +515,7 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
box_y = box->margin[TOP];
/* descend through visible boxes setting more specific values for:
- * box - deepest box at point
+ * box - deepest box at point
* html_object_box - html object
* html_object_pos_x - html object
* html_object_pos_y - html object
@@ -540,13 +540,13 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
* scrollbar - inside padding box stops decent
* scroll_mouse_x - inside padding box stops decent
* scroll_mouse_y - inside padding box stops decent
- *
+ *
* text_box - text box
* text_box_x - text_box
*/
do {
- if ((box->style != NULL) &&
- (css_computed_visibility(box->style) ==
+ if ((box->style != NULL) &&
+ (css_computed_visibility(box->style) ==
CSS_VISIBILITY_HIDDEN)) {
continue;
}
@@ -598,8 +598,8 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
}
pointer = get_pointer_shape(box, false);
-
- if ((box->scroll_x != NULL) ||
+
+ if ((box->scroll_x != NULL) ||
(box->scroll_y != NULL)) {
if (drag_candidate == NULL) {
@@ -614,29 +614,29 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
scrollbar_get_offset(box->scroll_y);
padding_bottom = padding_top + box->padding[TOP] +
box->height + box->padding[BOTTOM];
-
- if ((x > padding_left) &&
+
+ if ((x > padding_left) &&
(x < padding_right) &&
- (y > padding_top) &&
+ (y > padding_top) &&
(y < padding_bottom)) {
/* mouse inside padding box */
-
- if ((box->scroll_y != NULL) &&
+
+ if ((box->scroll_y != NULL) &&
(x > (padding_right -
SCROLLBAR_WIDTH))) {
/* mouse above vertical box scroll */
-
+
scrollbar = box->scroll_y;
scroll_mouse_x = x - (padding_right -
SCROLLBAR_WIDTH);
scroll_mouse_y = y - padding_top;
break;
-
+
} else if ((box->scroll_x != NULL) &&
(y > (padding_bottom -
- SCROLLBAR_WIDTH))) {
+ SCROLLBAR_WIDTH))) {
/* mouse above horizontal box scroll */
-
+
scrollbar = box->scroll_x;
scroll_mouse_x = x - padding_left;
scroll_mouse_y = y - (padding_bottom -
@@ -894,7 +894,7 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
/* if clicking in the main page, remove the selection from any
* text areas */
if (!done) {
-
+
if (click && html->focus_type != HTML_FOCUS_SELF) {
union html_focus_owner fo;
fo.self = true;
@@ -1190,7 +1190,7 @@ void html_overflow_scroll_callback(void *client_data,
union content_msg_data msg_data;
html_drag_type drag_type;
union html_drag_owner drag_owner;
-
+
switch(scrollbar_data->msg) {
case SCROLLBAR_MSG_MOVED:
diff --git a/render/html_internal.h b/content/handlers/html/html_internal.h
index 66ecb2b36..b9eca663e 100644
--- a/render/html_internal.h
+++ b/content/handlers/html/html_internal.h
@@ -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;
@@ -113,7 +114,7 @@ typedef struct html_content {
/* Title element node */
dom_node *title;
- /** A talloc context purely for the render box tree */
+ /** A talloc context purely for the render box tree */
int *bctx;
/** Box tree, or NULL. */
struct box *layout;
@@ -157,7 +158,7 @@ typedef struct html_content {
/** Inline frame information */
struct content_html_iframe *iframe;
- /** Content of type CONTENT_HTML containing this, or NULL if not an
+ /** Content of type CONTENT_HTML containing this, or NULL if not an
* object within a page. */
struct html_content *page;
@@ -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
-
-
diff --git a/render/html_object.c b/content/handlers/html/html_object.c
index 74e4bf0f3..c8715e3fb 100644
--- a/render/html_object.c
+++ b/content/handlers/html/html_object.c
@@ -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);
@@ -450,40 +451,40 @@ html_object_callback(hlcache_handle *object,
}
if (c->base.status == CONTENT_STATUS_READY &&
- c->base.active == 0 &&
- (event->type == CONTENT_MSG_LOADING ||
- event->type == CONTENT_MSG_DONE ||
- event->type == CONTENT_MSG_ERROR ||
- event->type == CONTENT_MSG_ERRORCODE)) {
+ c->base.active == 0 &&
+ (event->type == CONTENT_MSG_LOADING ||
+ event->type == CONTENT_MSG_DONE ||
+ event->type == CONTENT_MSG_ERROR ||
+ event->type == CONTENT_MSG_ERRORCODE)) {
/* all objects have arrived */
content__reformat(&c->base, false, c->base.available_width,
c->base.height);
content_set_done(&c->base);
} else if (nsoption_bool(incremental_reflow) &&
- event->type == CONTENT_MSG_DONE &&
- box != NULL &&
- !(box->flags & REPLACE_DIM) &&
- (c->base.status == CONTENT_STATUS_READY ||
- c->base.status == CONTENT_STATUS_DONE)) {
- /* 1) the configuration option to reflow pages while
- * objects are fetched is set
- * 2) an object is newly fetched & converted,
- * 3) the box's dimensions need to change due to being replaced
- * 4) the object's parent HTML is ready for reformat,
- */
- uint64_t ms_now;
- nsu_getmonotonic_ms(&ms_now);
- if (ms_now > c->base.reformat_time) {
- /* The time since the previous reformat is
- * more than the configured minimum time
- * between reformats so reformat the page to
- * display newly fetched objects
- */
- content__reformat(&c->base,
- false,
- c->base.available_width,
- c->base.height);
- }
+ event->type == CONTENT_MSG_DONE &&
+ box != NULL &&
+ !(box->flags & REPLACE_DIM) &&
+ (c->base.status == CONTENT_STATUS_READY ||
+ c->base.status == CONTENT_STATUS_DONE)) {
+ /* 1) the configuration option to reflow pages while
+ * objects are fetched is set
+ * 2) an object is newly fetched & converted,
+ * 3) the box's dimensions need to change due to being replaced
+ * 4) the object's parent HTML is ready for reformat,
+ */
+ uint64_t ms_now;
+ nsu_getmonotonic_ms(&ms_now);
+ if (ms_now > c->base.reformat_time) {
+ /* The time since the previous reformat is
+ * more than the configured minimum time
+ * between reformats so reformat the page to
+ * display newly fetched objects
+ */
+ content__reformat(&c->base,
+ false,
+ c->base.available_width,
+ c->base.height);
+ }
}
return NSERROR_OK;
@@ -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,
@@ -710,7 +711,7 @@ bool html_fetch_object(html_content *c, nsurl *url, struct box *box,
content_get_url(&c->base), NULL,
html_object_callback, object, &child,
object->permitted_types, &object->content);
- if (error != NSERROR_OK) {
+ if (error != NSERROR_OK) {
free(object);
return error != NSERROR_NOMEM;
}
diff --git a/render/html_redraw.c b/content/handlers/html/html_redraw.c
index 9a97e5ec5..d05df8753 100644
--- a/render/html_redraw.c
+++ b/content/handlers/html/html_redraw.c
@@ -5,7 +5,7 @@
* Copyright 2005-2006 Adrian Lees <adrianl@users.sourceforge.net>
* Copyright 2006 Rob Kendrick <rjek@netsurf-browser.org>
* Copyright 2008 Michael Drake <tlsa@netsurf-browser.org>
- * Copyright 2009 Paul Blokus <paul_pl@users.sourceforge.net>
+ * Copyright 2009 Paul Blokus <paul_pl@users.sourceforge.net>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -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,
@@ -401,7 +401,7 @@ static bool html_redraw_checkbox(int x, int y, int width, int height,
return false;
}
- /* light line across bottom */
+ /* light line across bottom */
rect.x0 = x;
rect.y0 = y + height;
res = ctx->plot->line(ctx, plot_style_stroke_lightwbasec, &rect);
@@ -661,7 +661,7 @@ static bool html_redraw_background(int x, int y, struct box *box, float scale,
css_computed_background_position(background->style,
&hpos, &hunit, &vpos, &vunit);
if (hunit == CSS_UNIT_PCT) {
- x += (width -
+ x += (width -
content_get_width(background->background)) *
scale * FIXTOFLT(hpos) / 100.;
} else {
@@ -670,7 +670,7 @@ static bool html_redraw_background(int x, int y, struct box *box, float scale,
}
if (vunit == CSS_UNIT_PCT) {
- y += (height -
+ y += (height -
content_get_height(background->background)) *
scale * FIXTOFLT(vpos) / 100.;
} else {
@@ -724,10 +724,10 @@ static bool html_redraw_background(int x, int y, struct box *box, float scale,
/* if the background content is opaque there
* is no need to plot underneath it.
*/
- if ((r.x0 >= r.x1) ||
+ if ((r.x0 >= r.x1) ||
(r.y0 >= r.y1) ||
(nscss_color_is_transparent(bgcol) == false) ||
- ((clip_box->background != NULL) &&
+ ((clip_box->background != NULL) &&
content_get_opaque(clip_box->background)))
continue;
}
@@ -843,7 +843,7 @@ static bool html_redraw_inline_background(int x, int y, struct box *box,
case CSS_BACKGROUND_REPEAT_REPEAT:
repeat_x = repeat_y = true;
/* optimisation: only plot the colour if
- * bitmap is not opaque
+ * bitmap is not opaque
*/
plot_colour = !content_get_opaque(box->background);
break;
@@ -868,10 +868,10 @@ static bool html_redraw_inline_background(int x, int y, struct box *box,
&hpos, &hunit, &vpos, &vunit);
if (hunit == CSS_UNIT_PCT) {
x += (b.x1 - b.x0 -
- content_get_width(box->background) *
+ content_get_width(box->background) *
scale) * FIXTOFLT(hpos) / 100.;
- if (!repeat_x && ((hpos < 2 && !first) ||
+ if (!repeat_x && ((hpos < 2 && !first) ||
(hpos > 98 && !last))){
plot_content = false;
}
@@ -1082,7 +1082,7 @@ static bool html_redraw_text_decoration(struct box *box,
if (!box->inline_end)
return true;
for (i = 0; i != NOF_ELEMENTS(decoration); i++)
- if (css_computed_text_decoration(box->style) &
+ if (css_computed_text_decoration(box->style) &
decoration[i])
if (!html_redraw_text_decoration_inline(box,
x_parent, y_parent, scale,
@@ -1090,7 +1090,7 @@ static bool html_redraw_text_decoration(struct box *box,
return false;
} else {
for (i = 0; i != NOF_ELEMENTS(decoration); i++)
- if (css_computed_text_decoration(box->style) &
+ if (css_computed_text_decoration(box->style) &
decoration[i])
if (!html_redraw_text_decoration_block(box,
x_parent + box->x,
@@ -1365,7 +1365,7 @@ bool html_redraw_box(const html_content *html, struct box *box,
}
/* if visibility is hidden render children only */
- if (box->style && css_computed_visibility(box->style) ==
+ if (box->style && css_computed_visibility(box->style) ==
CSS_VISIBILITY_HIDDEN) {
if ((ctx->plot->group_start) &&
(ctx->plot->group_start(ctx, "hidden box") != NSERROR_OK))
@@ -1855,11 +1855,11 @@ bool html_redraw_box(const html_content *html, struct box *box,
if (!box_handle_scrollbars((struct content *)html,
box, has_x_scroll, has_y_scroll))
return false;
-
+
if (box->scroll_x != NULL)
scrollbar_redraw(box->scroll_x,
x_parent + box->x,
- y_parent + box->y + box->padding[TOP] +
+ y_parent + box->y + box->padding[TOP] +
box->height + box->padding[BOTTOM] -
SCROLLBAR_WIDTH, clip, scale, ctx);
if (box->scroll_y != NULL)
@@ -1919,16 +1919,16 @@ bool html_redraw(struct content *c, struct content_redraw_data *data,
select_only = form_clip_inside_select_menu(control,
data->scale, clip);
}
-
+
if (!select_only) {
/* clear to background colour */
result = (ctx->plot->clip(ctx, clip) == NSERROR_OK);
-
+
if (html->background_colour != NS_TRANSPARENT)
pstyle_fill_bg.fill_colour = html->background_colour;
result &= (ctx->plot->rectangle(ctx, &pstyle_fill_bg, clip) == NSERROR_OK);
-
+
result &= html_redraw_box(html, box, data->x, data->y, clip,
data->scale, pstyle_fill_bg.fill_colour, ctx);
}
@@ -1937,7 +1937,7 @@ bool html_redraw(struct content *c, struct content_redraw_data *data,
int menu_x, menu_y;
box = html->visible_select_menu->box;
box_coords(box, &menu_x, &menu_y);
-
+
menu_x -= box->border[LEFT].width;
menu_y += box->height + box->border[BOTTOM].width +
box->padding[BOTTOM] + box->padding[TOP];
diff --git a/render/html_redraw_border.c b/content/handlers/html/html_redraw_border.c
index 07c503c41..2a849e853 100644
--- a/render/html_redraw_border.c
+++ b/content/handlers/html/html_redraw_border.c
@@ -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 = {
diff --git a/render/html_script.c b/content/handlers/html/html_script.c
index c73a4806d..e18a0caa0 100644
--- a/render/html_script.c
+++ b/content/handlers/html/html_script.c
@@ -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;
diff --git a/render/imagemap.c b/content/handlers/html/imagemap.c
index 0d3b42a1b..5f4dd54b3 100644
--- a/render/imagemap.c
+++ b/content/handlers/html/imagemap.c
@@ -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 */
diff --git a/render/imagemap.h b/content/handlers/html/imagemap.h
index 3ae6819da..8e189a072 100644
--- a/render/imagemap.h
+++ b/content/handlers/html/imagemap.h
@@ -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>
diff --git a/render/layout.c b/content/handlers/html/layout.c
index 121137adc..6941d6759 100644
--- a/render/layout.c
+++ b/content/handlers/html/layout.c
@@ -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
@@ -2188,7 +2188,7 @@ static bool layout_table(struct box *table, int available_width,
/* calculate width required by cells */
for (i = 0; i != columns; i++) {
- NSLOG(layout, DEBUG,
+ NSLOG(layout, DEBUG,
"table %p, column %u: type %s, width %i, min %i, max %i",
table,
i,
@@ -2225,7 +2225,7 @@ static bool layout_table(struct box *table, int available_width,
required_width += (columns + 1 - positioned_columns) *
border_spacing_h;
- NSLOG(layout, DEBUG,
+ NSLOG(layout, DEBUG,
"width %i, min %i, max %i, auto %i, required %i", table_width,
table->min_width, table->max_width, auto_width, required_width);
@@ -3124,7 +3124,7 @@ layout_line(struct box *first,
const struct gui_layout_table *font_func = content->font_func;
plot_font_style_t fstyle;
- NSLOG(layout, DEBUG,
+ NSLOG(layout, DEBUG,
"first %p, first->text '%.*s', width %i, y %i, cx %i, cy %i",
first,
(int)first->length,
@@ -3653,7 +3653,7 @@ layout_line(struct box *first,
used_height = 0;
if (left) {
- NSLOG(layout, DEBUG,
+ NSLOG(layout, DEBUG,
"cy %i, left->y %i, left->height %i",
cy,
left->y,
@@ -3848,7 +3848,7 @@ static bool layout_inline_container(struct box *inline_container, int width,
assert(inline_container->type == BOX_INLINE_CONTAINER);
- NSLOG(layout, DEBUG,
+ NSLOG(layout, DEBUG,
"inline_container %p, width %i, cont %p, cx %i, cy %i",
inline_container,
width,
@@ -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;
diff --git a/render/layout.h b/content/handlers/html/layout.h
index cd5ddd77f..0811e81de 100644
--- a/render/layout.h
+++ b/content/handlers/html/layout.h
@@ -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;
diff --git a/render/search.c b/content/handlers/html/search.c
index ca9520165..9ba2957e4 100644
--- a/render/search.c
+++ b/content/handlers/html/search.c
@@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
+
/**
* \file
* Free text search (core)
@@ -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)))
@@ -128,7 +128,7 @@ static void free_matches(struct search_context *context)
{
struct list_entry *a;
struct list_entry *b;
-
+
a = context->found->next;
/* empty the list before clearing and deleting the
@@ -179,11 +179,11 @@ static const char *find_pattern(const char *string, int s_len,
if (p < pattern || *p == '*') {
char ch;
- /* skip any further asterisks; one is the same as many
+ /* skip any further asterisks; one is the same as many
*/
do p++; while (p < ep && *p == '*');
- /* if we're at the end of the pattern, yes, it matches
+ /* if we're at the end of the pattern, yes, it matches
*/
if (p >= ep) break;
@@ -193,7 +193,7 @@ static const char *find_pattern(const char *string, int s_len,
ch = *p;
if (ch != '#') {
- /* scan forwards until we find a match for
+ /* scan forwards until we find a match for
this char */
if (!case_sens) ch = toupper(ch);
while (s < es) {
@@ -206,7 +206,7 @@ static const char *find_pattern(const char *string, int s_len,
}
if (s < es) {
- /* remember where we are in case the match
+ /* remember where we are in case the match
fails; we may then resume */
if (top < (int)NOF_ELEMENTS(context)) {
context[top].ss = ss;
diff --git a/render/search.h b/content/handlers/html/search.h
index 79d1ee3d3..5c9408e3e 100644
--- a/render/search.h
+++ b/content/handlers/html/search.h
@@ -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>
diff --git a/render/table.c b/content/handlers/html/table.c
index 08a2e805c..5609e8f29 100644
--- a/render/table.c
+++ b/content/handlers/html/table.c
@@ -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
@@ -130,9 +131,9 @@ bool table_calculate_column_types(
continue;
i = cell->start_column;
- if (css_computed_position(cell->style) !=
+ if (css_computed_position(cell->style) !=
CSS_POSITION_ABSOLUTE &&
- css_computed_position(cell->style) !=
+ css_computed_position(cell->style) !=
CSS_POSITION_FIXED) {
col[i].positioned = false;
}
@@ -181,7 +182,7 @@ bool table_calculate_column_types(
for (j = i; j < i + cell->columns; j++) {
col[j].positioned = false;
}
-
+
/* count column types in spanned cells */
for (j = 0; j != cell->columns; j++) {
if (col[i + j].type == COLUMN_WIDTH_FIXED) {
@@ -208,7 +209,7 @@ bool table_calculate_column_types(
fixed_columns + unknown_columns ==
cell->columns) {
int width = (FIXTOFLT(nscss_len2px(len_ctx, value, unit,
- cell->style)) - fixed_width) /
+ cell->style)) - fixed_width) /
unknown_columns;
if (width < 0)
width = 0;
@@ -274,48 +275,48 @@ void table_used_border_for_cell(
assert(cell->type == BOX_TABLE_CELL);
- if (css_computed_border_collapse(cell->style) ==
+ if (css_computed_border_collapse(cell->style) ==
CSS_BORDER_COLLAPSE_SEPARATE) {
css_fixed width = 0;
css_unit unit = CSS_UNIT_PX;
/* Left border */
- cell->border[LEFT].style =
+ cell->border[LEFT].style =
css_computed_border_left_style(cell->style);
css_computed_border_left_color(cell->style,
&cell->border[LEFT].c);
css_computed_border_left_width(cell->style, &width, &unit);
- cell->border[LEFT].width =
+ cell->border[LEFT].width =
FIXTOINT(nscss_len2px(len_ctx,
width, unit, cell->style));
/* Top border */
- cell->border[TOP].style =
+ cell->border[TOP].style =
css_computed_border_top_style(cell->style);
css_computed_border_top_color(cell->style,
&cell->border[TOP].c);
css_computed_border_top_width(cell->style, &width, &unit);
- cell->border[TOP].width =
+ cell->border[TOP].width =
FIXTOINT(nscss_len2px(len_ctx,
width, unit, cell->style));
/* Right border */
- cell->border[RIGHT].style =
+ cell->border[RIGHT].style =
css_computed_border_right_style(cell->style);
css_computed_border_right_color(cell->style,
&cell->border[RIGHT].c);
css_computed_border_right_width(cell->style, &width, &unit);
- cell->border[RIGHT].width =
+ cell->border[RIGHT].width =
FIXTOINT(nscss_len2px(len_ctx,
width, unit, cell->style));
/* Bottom border */
- cell->border[BOTTOM].style =
+ cell->border[BOTTOM].style =
css_computed_border_bottom_style(cell->style);
css_computed_border_bottom_color(cell->style,
&cell->border[BOTTOM].c);
css_computed_border_bottom_width(cell->style, &width, &unit);
- cell->border[BOTTOM].width =
+ cell->border[BOTTOM].width =
FIXTOINT(nscss_len2px(len_ctx,
width, unit, cell->style));
} else {
@@ -332,11 +333,11 @@ void table_used_border_for_cell(
table_used_bottom_border_for_cell(len_ctx, cell);
}
- /* Finally, ensure that any borders configured as
+ /* Finally, ensure that any borders configured as
* hidden or none have zero width. (c.f. layout_find_dimensions) */
for (side = 0; side != 4; side++) {
if (cell->border[side].style == CSS_BORDER_STYLE_HIDDEN ||
- cell->border[side].style ==
+ cell->border[side].style ==
CSS_BORDER_STYLE_NONE)
cell->border[side].width = 0;
}
@@ -378,10 +379,10 @@ void table_used_left_border_for_cell(
/* Spanned from a previous row in current row group */
for (row = cell->parent; row != NULL; row = row->prev) {
- for (prev = row->children; prev != NULL;
+ for (prev = row->children; prev != NULL;
prev = prev->next) {
- if (prev->start_column +
- prev->columns ==
+ if (prev->start_column +
+ prev->columns ==
cell->start_column)
break;
}
@@ -444,7 +445,7 @@ void table_used_left_border_for_cell(
b.width = nscss_len2px(len_ctx, b.width, b.unit, group->style);
b.unit = CSS_UNIT_PX;
b_src = BOX_TABLE_ROW_GROUP;
-
+
if (table_border_is_more_eyecatching(len_ctx,
&a, a_src, &b, b_src)) {
a = b;
@@ -458,7 +459,7 @@ void table_used_left_border_for_cell(
b.width = nscss_len2px(len_ctx, b.width, b.unit, table->style);
b.unit = CSS_UNIT_PX;
b_src = BOX_TABLE;
-
+
if (table_border_is_more_eyecatching(len_ctx,
&a, a_src, &b, b_src)) {
a = b;
@@ -594,7 +595,7 @@ void table_used_right_border_for_cell(
a.unit = CSS_UNIT_PX;
a_src = BOX_TABLE_CELL;
- if (cell->next != NULL || cell->start_column + cell->columns !=
+ if (cell->next != NULL || cell->start_column + cell->columns !=
cell->parent->parent->parent->columns) {
/* Cell is not at right edge of table -- no right border */
a.style = CSS_BORDER_STYLE_NONE;
@@ -638,7 +639,7 @@ void table_used_right_border_for_cell(
b.width = nscss_len2px(len_ctx, b.width, b.unit, group->style);
b.unit = CSS_UNIT_PX;
b_src = BOX_TABLE_ROW_GROUP;
-
+
if (table_border_is_more_eyecatching(len_ctx,
&a, a_src, &b, b_src)) {
a = b;
@@ -648,12 +649,12 @@ void table_used_right_border_for_cell(
/* The table itself -- consider its right border */
b.style = css_computed_border_right_style(table->style);
b.color = css_computed_border_right_color(table->style, &b.c);
- css_computed_border_right_width(table->style,
+ css_computed_border_right_width(table->style,
&b.width, &b.unit);
b.width = nscss_len2px(len_ctx, b.width, b.unit, table->style);
b.unit = CSS_UNIT_PX;
b_src = BOX_TABLE;
-
+
if (table_border_is_more_eyecatching(len_ctx,
&a, a_src, &b, b_src)) {
a = b;
@@ -714,7 +715,7 @@ void table_used_bottom_border_for_cell(
b.width = nscss_len2px(len_ctx, b.width, b.unit, row->style);
b.unit = CSS_UNIT_PX;
b_src = BOX_TABLE_ROW;
-
+
if (table_border_is_more_eyecatching(len_ctx,
&a, a_src, &b, b_src)) {
a = b;
@@ -724,12 +725,12 @@ void table_used_bottom_border_for_cell(
/* Row group -- consider its bottom border */
b.style = css_computed_border_bottom_style(group->style);
b.color = css_computed_border_bottom_color(group->style, &b.c);
- css_computed_border_bottom_width(group->style,
+ css_computed_border_bottom_width(group->style,
&b.width, &b.unit);
b.width = nscss_len2px(len_ctx, b.width, b.unit, group->style);
b.unit = CSS_UNIT_PX;
b_src = BOX_TABLE_ROW_GROUP;
-
+
if (table_border_is_more_eyecatching(len_ctx,
&a, a_src, &b, b_src)) {
a = b;
@@ -739,12 +740,12 @@ void table_used_bottom_border_for_cell(
/* The table itself -- consider its bottom border */
b.style = css_computed_border_bottom_style(table->style);
b.color = css_computed_border_bottom_color(table->style, &b.c);
- css_computed_border_bottom_width(table->style,
+ css_computed_border_bottom_width(table->style,
&b.width, &b.unit);
b.width = nscss_len2px(len_ctx, b.width, b.unit, table->style);
b.unit = CSS_UNIT_PX;
b_src = BOX_TABLE;
-
+
if (table_border_is_more_eyecatching(len_ctx,
&a, a_src, &b, b_src)) {
a = b;
@@ -790,7 +791,7 @@ bool table_border_is_more_eyecatching(
return true;
/* 3a -- wider borders beat narrow ones */
- /* The widths must be absolute, which will be the case
+ /* The widths must be absolute, which will be the case
* if they've come from a computed style. */
assert(a->unit != CSS_UNIT_EM && a->unit != CSS_UNIT_EX);
assert(b->unit != CSS_UNIT_EM && b->unit != CSS_UNIT_EX);
@@ -1027,7 +1028,7 @@ bool table_cell_top_process_row(
return false;
} else {
- /* Process cells that are directly above the cell being
+ /* Process cells that are directly above the cell being
* considered. They may not be in this row, but in one of the
* rows above it in the case where rowspan > 1. */
struct box *c;
@@ -1077,4 +1078,3 @@ bool table_cell_top_process_row(
return true;
}
-
diff --git a/render/table.h b/content/handlers/html/table.h
index 2eeffe699..11ab653c6 100644
--- a/render/table.h
+++ b/content/handlers/html/table.h
@@ -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>
diff --git a/content/handlers/javascript/duktape/Document.bnd b/content/handlers/javascript/duktape/Document.bnd
index ece417d0d..5de724538 100644
--- a/content/handlers/javascript/duktape/Document.bnd
+++ b/content/handlers/javascript/duktape/Document.bnd
@@ -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)
diff --git a/content/handlers/javascript/duktape/Window.bnd b/content/handlers/javascript/duktape/Window.bnd
index 3f680d47d..f647fd147 100644
--- a/content/handlers/javascript/duktape/Window.bnd
+++ b/content/handlers/javascript/duktape/Window.bnd
@@ -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"
%};
};
diff --git a/content/handlers/text/Makefile b/content/handlers/text/Makefile
new file mode 100644
index 000000000..83d5dbd1e
--- /dev/null
+++ b/content/handlers/text/Makefile
@@ -0,0 +1,3 @@
+# text content handler sources
+
+S_TEXT := textplain.c
diff --git a/render/textplain.c b/content/handlers/text/textplain.c
index 0036eb5c0..e6d167bc2 100644
--- a/render/textplain.c
+++ b/content/handlers/text/textplain.c
@@ -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;
@@ -812,6 +810,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).
*
* x, y, clip_[xy][01] are in target coordinates.
@@ -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;
diff --git a/render/textplain.h b/content/handlers/text/textplain.h
index 0f0128e56..23917fb6c 100644
--- a/render/textplain.h
+++ b/content/handlers/text/textplain.h
@@ -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"
@@ -103,7 +103,7 @@ char *textplain_get_line(struct content *c, unsigned lineno,
/**
* Find line number of byte in text
- *
+ *
* Given a byte offset within the text, return the line number
* of the line containing that offset.
*
diff --git a/desktop/browser.c b/desktop/browser.c
index 88d78ba95..589016216 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -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"
diff --git a/desktop/frames.c b/desktop/frames.c
index e22287630..ebc54c6d5 100644
--- a/desktop/frames.c
+++ b/desktop/frames.c
@@ -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"
diff --git a/desktop/netsurf.c b/desktop/netsurf.c
index 8aa949a5a..76ff4b19a 100644
--- a/desktop/netsurf.c
+++ b/desktop/netsurf.c
@@ -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"
diff --git a/desktop/print.c b/desktop/print.c
index 5c0333a96..de579dcf2 100644
--- a/desktop/print.c
+++ b/desktop/print.c
@@ -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"
diff --git a/desktop/save_complete.c b/desktop/save_complete.c
index 9a88ad180..cd4ab30cf 100644
--- a/desktop/save_complete.c
+++ b/desktop/save_complete.c
@@ -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"
diff --git a/desktop/save_text.c b/desktop/save_text.c
index 791ae9201..c4abb16f1 100644
--- a/desktop/save_text.c
+++ b/desktop/save_text.c
@@ -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"
diff --git a/desktop/selection.c b/desktop/selection.c
index 5cb43b8c3..35eabb2a9 100644
--- a/desktop/selection.c
+++ b/desktop/selection.c
@@ -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"
diff --git a/desktop/textinput.c b/desktop/textinput.c
index c0e0ba8f7..7fc95f792 100644
--- a/desktop/textinput.c
+++ b/desktop/textinput.c
@@ -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"
diff --git a/frontends/amiga/dt_sound.c b/frontends/amiga/dt_sound.c
index e0f48da83..ae313bb51 100644
--- a/frontends/amiga/dt_sound.c
+++ b/frontends/amiga/dt_sound.c
@@ -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"
diff --git a/render/Makefile b/render/Makefile
deleted file mode 100644
index dc2e31c9e..000000000
--- a/render/Makefile
+++ /dev/null
@@ -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))