summaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2011-06-28 20:17:39 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2011-06-28 20:17:39 +0000
commit3128ecf2a5c94102e0e1659f947a345d36750afe (patch)
treea744c73c5464360bbddd1de5a4c83907abbc0048 /render
parent4d19457c59fa911743137277d312ac2935293f8b (diff)
downloadnetsurf-3128ecf2a5c94102e0e1659f947a345d36750afe.tar.gz
netsurf-3128ecf2a5c94102e0e1659f947a345d36750afe.tar.bz2
Unify content_redraw params in content_redraw_data struct. Core and RISC OS content handlers updated.
svn path=/trunk/netsurf/; revision=12529
Diffstat (limited to 'render')
-rw-r--r--render/html_internal.h6
-rw-r--r--render/html_redraw.c88
-rw-r--r--render/textplain.c45
3 files changed, 73 insertions, 66 deletions
diff --git a/render/html_internal.h b/render/html_internal.h
index f9d116348..a177e3999 100644
--- a/render/html_internal.h
+++ b/render/html_internal.h
@@ -103,10 +103,8 @@ bool html_fetch_object(html_content *c, const char *url, struct box *box,
void html_set_status(html_content *c, const char *extra);
/* in render/html_redraw.c */
-bool html_redraw(struct content *c, int x, int y,
- int width, int height, const struct rect *clip,
- float scale, colour background_colour,
- bool repeat_x, bool repeat_y);
+bool html_redraw(struct content *c, struct content_redraw_data *data,
+ const struct rect *clip);
/* in render/html_interaction.c */
void html_mouse_track(struct content *c, struct browser_window *bw,
diff --git a/render/html_redraw.c b/render/html_redraw.c
index 8913711ba..3cd297238 100644
--- a/render/html_redraw.c
+++ b/render/html_redraw.c
@@ -97,23 +97,16 @@ bool html_redraw_debug = false;
/**
* Draw a CONTENT_HTML using the current set of plotters (plot).
*
- * \param c content of type CONTENT_HTML
- * \param x coordinate for top-left of redraw
- * \param y coordinate for top-left of redraw
- * \param width available width (not used for HTML redraw)
- * \param height available height (not used for HTML redraw)
- * \param clip clip rectangle
- * \param scale scale for redraw
- * \param background_colour the background colour
+ * \param c content of type CONTENT_HTML
+ * \param data redraw data for this content redraw
+ * \param clip current clip region
* \return true if successful, false otherwise
*
* x, y, clip_[xy][01] are in target coordinates.
*/
-bool html_redraw(struct content *c, int x, int y,
- int width, int height, const struct rect *clip,
- float scale, colour background_colour,
- bool repeat_x, bool repeat_y)
+bool html_redraw(struct content *c, struct content_redraw_data *data,
+ const struct rect *clip)
{
html_content *html = (html_content *) c;
struct box *box;
@@ -121,7 +114,7 @@ bool html_redraw(struct content *c, int x, int y,
bool select, select_only;
plot_style_t pstyle_fill_bg = {
.fill_type = PLOT_OP_TYPE_SOLID,
- .fill_colour = background_colour,
+ .fill_colour = data->background_colour,
};
box = html->layout;
@@ -138,8 +131,8 @@ bool html_redraw(struct content *c, int x, int y,
select = true;
/* check if the redraw rectangle is completely inside of the
select menu */
- select_only = form_clip_inside_select_menu(control, scale,
- clip);
+ select_only = form_clip_inside_select_menu(control,
+ data->scale, clip);
}
if (!select_only) {
@@ -152,8 +145,8 @@ bool html_redraw(struct content *c, int x, int y,
result &= plot.rectangle(clip->x0, clip->y0, clip->x1, clip->y1,
&pstyle_fill_bg);
- result &= html_redraw_box(html, box, x, y, clip,
- scale, pstyle_fill_bg.fill_colour);
+ result &= html_redraw_box(html, box, data->x, data->y, clip,
+ data->scale, pstyle_fill_bg.fill_colour);
}
if (select) {
@@ -165,8 +158,8 @@ bool html_redraw(struct content *c, int x, int y,
menu_y += box->height + box->border[BOTTOM].width +
box->padding[BOTTOM] + box->padding[TOP];
result &= form_redraw_select_menu(html->visible_select_menu,
- x + menu_x, y + menu_y,
- current_redraw_browser->scale, clip);
+ data->x + menu_x, data->y + menu_y,
+ data->scale, clip);
}
return result;
@@ -650,14 +643,21 @@ bool html_redraw_box(html_content *html, struct box *box,
return false;
if (box->object && width != 0 && height != 0) {
+ struct content_redraw_data obj_data;
+
x_scrolled = x - scrollbar_get_offset(box->scroll_x) * scale;
y_scrolled = y - scrollbar_get_offset(box->scroll_y) * scale;
- if (!content_redraw(box->object,
- x_scrolled + padding_left,
- y_scrolled + padding_top,
- width, height, &r, scale,
- current_background_color,
- false, false))
+
+ obj_data.x = x_scrolled + padding_left;
+ obj_data.y = y_scrolled + padding_top;
+ obj_data.width = width;
+ obj_data.height = height;
+ obj_data.background_colour = current_background_color;
+ obj_data.scale = scale;
+ obj_data.repeat_x = false;
+ obj_data.repeat_y = false;
+
+ if (!content_redraw(box->object, &obj_data, &r))
return false;
} else if (box->iframe) {
@@ -2182,14 +2182,22 @@ bool html_redraw_background(int x, int y, struct box *box, float scale,
}
/* valid clipping rectangles only */
if ((r.x0 < r.x1) && (r.y0 < r.y1)) {
+ struct content_redraw_data bg_data;
+
if (!plot.clip(&r))
return false;
- if (!content_redraw(
- background->background, x, y,
- ceilf(width * scale),
- ceilf(height * scale), &r,
- scale, *background_colour,
- repeat_x, repeat_y))
+
+ bg_data.x = x;
+ bg_data.y = y;
+ bg_data.width = ceilf(width * scale);
+ bg_data.height = ceilf(height * scale);
+ bg_data.background_colour = *background_colour;
+ bg_data.scale = scale;
+ bg_data.repeat_x = repeat_x;
+ bg_data.repeat_y = repeat_y;
+
+ if (!content_redraw(background->background,
+ &bg_data, &r))
return false;
}
}
@@ -2323,13 +2331,21 @@ bool html_redraw_inline_background(int x, int y, struct box *box, float scale,
}
/* valid clipping rectangles only */
if ((r.x0 < r.x1) && (r.y0 < r.y1)) {
+ struct content_redraw_data bg_data;
+
if (!plot.clip(&r))
return false;
- if (!content_redraw(box->background, x, y,
- ceilf(width * scale),
- ceilf(height * scale), &r,
- scale, *background_colour,
- repeat_x, repeat_y))
+
+ bg_data.x = x;
+ bg_data.y = y;
+ bg_data.width = ceilf(width * scale);
+ bg_data.height = ceilf(height * scale);
+ bg_data.background_colour = *background_colour;
+ bg_data.scale = scale;
+ bg_data.repeat_x = repeat_x;
+ bg_data.repeat_y = repeat_y;
+
+ if (!content_redraw(box->background, &bg_data, &r))
return false;
}
}
diff --git a/render/textplain.c b/render/textplain.c
index 8f5b80bff..5859ebd43 100644
--- a/render/textplain.c
+++ b/render/textplain.c
@@ -102,10 +102,8 @@ static void textplain_mouse_action(struct content *c, struct browser_window *bw,
browser_mouse_state mouse, int x, int y);
static void textplain_reformat(struct content *c, int width, int height);
static void textplain_destroy(struct content *c);
-static bool textplain_redraw(struct content *c, int x, int y,
- int width, int height, const struct rect *clip,
- float scale, colour background_colour,
- bool redraw_x, bool redraw_y);
+static bool textplain_redraw(struct content *c, struct content_redraw_data *data,
+ const struct rect *clip);
static nserror textplain_clone(const struct content *old,
struct content **newc);
static content_type textplain_content_type(lwc_string *mime_type);
@@ -668,33 +666,28 @@ void textplain_mouse_action(struct content *c, struct browser_window *bw,
/**
* Draw a CONTENT_TEXTPLAIN using the current set of plotters (plot).
*
- * \param c content of type CONTENT_TEXTPLAIN
- * \param x coordinate for top-left of redraw
- * \param y coordinate for top-left of redraw
- * \param width available width
- * \param height available height
- * \param clip clip rectangle
- * \param scale scale for redraw
- * \param background_colour the background colour
+ * \param c content of type CONTENT_TEXTPLAIN
+ * \param data redraw data for this content redraw
+ * \param clip current clip region
* \return true if successful, false otherwise
*
* x, y, clip_[xy][01] are in target coordinates.
*/
-bool textplain_redraw(struct content *c, int x, int y,
- int width, int height, const struct rect *clip,
- float scale, colour background_colour,
- bool repeat_x, bool repeat_y)
+bool textplain_redraw(struct content *c, struct content_redraw_data *data,
+ const struct rect *clip)
{
textplain_content *text = (textplain_content *) c;
struct browser_window *bw = current_redraw_browser;
char *utf8_data = text->utf8_data;
long lineno;
+ int x = data->x;
+ int y = data->y;
unsigned long line_count = text->physical_line_count;
float line_height = textplain_line_height();
- float scaled_line_height = line_height * scale;
- long line0 = (clip->y0 - y * scale) / scaled_line_height - 1;
- long line1 = (clip->y1 - y * scale) / scaled_line_height + 1;
+ float scaled_line_height = line_height * data->scale;
+ long line0 = (clip->y0 - y * data->scale) / scaled_line_height - 1;
+ long line1 = (clip->y1 - y * data->scale) / scaled_line_height + 1;
struct textplain_line *line = text->physical_line;
size_t length;
plot_style_t *plot_style_highlight;
@@ -718,19 +711,19 @@ bool textplain_redraw(struct content *c, int x, int y,
return true;
/* choose a suitable background colour for any highlighted text */
- if ((background_colour & 0x808080) == 0x808080)
+ if ((data->background_colour & 0x808080) == 0x808080)
plot_style_highlight = plot_style_fill_black;
else
plot_style_highlight = plot_style_fill_white;
/* Set up font plot style */
- textplain_style.background = background_colour;
+ textplain_style.background = data->background_colour;
- x = (x + MARGIN) * scale;
- y = (y + MARGIN) * scale;
+ x = (x + MARGIN) * data->scale;
+ y = (y + MARGIN) * data->scale;
for (lineno = line0; lineno != line1; lineno++) {
const char *text = utf8_data + line[lineno].start;
- int tab_width = textplain_tab_width * scale;
+ int tab_width = textplain_tab_width * data->scale;
size_t offset = 0;
int tx = x;
@@ -752,7 +745,7 @@ bool textplain_redraw(struct content *c, int x, int y,
line[lineno].start + offset, 0,
&textplain_style,
tx, y + (lineno * scaled_line_height),
- clip, line_height, scale, false))
+ clip, line_height, data->scale, false))
return false;
if (next_offset >= length)
@@ -761,7 +754,7 @@ bool textplain_redraw(struct content *c, int x, int y,
/* locate end of string and align to next tab position */
if (nsfont.font_width(&textplain_style, &text[offset],
next_offset - offset, &width))
- tx += (int)(width * scale);
+ tx += (int)(width * data->scale);
ntx = x + ((1 + (tx - x) / tab_width) * tab_width);