mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-24 04:56:50 +03:00
Background area extends to border edge.
svn path=/trunk/netsurf/; revision=3780
This commit is contained in:
parent
b2b6fa0f10
commit
f5d07c4988
@ -208,11 +208,11 @@ bool html_redraw_box(struct box *box,
|
||||
if ((plot.group_start) && (!plot.group_start("hidden box")))
|
||||
return false;
|
||||
visible = false;
|
||||
} else {
|
||||
} else {
|
||||
if ((plot.group_start) && (!plot.group_start("vis box")))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* dotted debug outlines */
|
||||
if (html_redraw_debug && visible) {
|
||||
if (!plot.rectangle(x, y, padding_width, padding_height,
|
||||
@ -269,7 +269,7 @@ bool html_redraw_box(struct box *box,
|
||||
x1 = clip_x1;
|
||||
y1 = clip_y1;
|
||||
}
|
||||
|
||||
|
||||
/* hidden elements */
|
||||
if (!visible) {
|
||||
if (!html_redraw_box_children(box, x_parent, y_parent,
|
||||
@ -284,29 +284,29 @@ bool html_redraw_box(struct box *box,
|
||||
/* background colour and image */
|
||||
|
||||
/* Thanks to backwards compatibility, CSS defines the following:
|
||||
*
|
||||
*
|
||||
* + If the box is for the root element and it has a background,
|
||||
* use that (and then process the body box with no special case)
|
||||
* + If the box is for the root element and it has no background,
|
||||
* then use the background (if any) from the body element as if
|
||||
* it were specified on the root. Then, when the box for the body
|
||||
* then use the background (if any) from the body element as if
|
||||
* it were specified on the root. Then, when the box for the body
|
||||
* element is processed, ignore the background.
|
||||
* + For any other box, just use its own styling.
|
||||
*/
|
||||
if (!box->parent) {
|
||||
/* Root box */
|
||||
if (box->style &&
|
||||
if (box->style &&
|
||||
(box->style->background_color != TRANSPARENT ||
|
||||
box->background)) {
|
||||
/* With its own background */
|
||||
bg_box = box;
|
||||
} else if (!box->style ||
|
||||
} else if (!box->style ||
|
||||
(box->style->background_color == TRANSPARENT &&
|
||||
!box->background)) {
|
||||
/* Without its own background */
|
||||
if (box->children && box->children->style &&
|
||||
(box->children->style->background_color !=
|
||||
TRANSPARENT ||
|
||||
(box->children->style->background_color !=
|
||||
TRANSPARENT ||
|
||||
box->children->background)) {
|
||||
/* But body has one, so use that */
|
||||
bg_box = box->children;
|
||||
@ -314,13 +314,13 @@ bool html_redraw_box(struct box *box,
|
||||
}
|
||||
} else if (box->parent && !box->parent->parent) {
|
||||
/* Body box */
|
||||
if (box->style &&
|
||||
(box->style->background_color != TRANSPARENT ||
|
||||
if (box->style &&
|
||||
(box->style->background_color != TRANSPARENT ||
|
||||
box->background)) {
|
||||
/* With a background */
|
||||
if (box->parent->style &&
|
||||
(box->parent->style->background_color !=
|
||||
TRANSPARENT ||
|
||||
(box->parent->style->background_color !=
|
||||
TRANSPARENT ||
|
||||
box->parent->background)) {
|
||||
/* Root has own background; process normally */
|
||||
bg_box = box;
|
||||
@ -331,20 +331,24 @@ bool html_redraw_box(struct box *box,
|
||||
bg_box = box;
|
||||
}
|
||||
|
||||
/* bg_box == NULL implies that this box should not have
|
||||
/* bg_box == NULL implies that this box should not have
|
||||
* its background rendered. Otherwise filter out linebreaks,
|
||||
* optimize away non-differing inlines and ensure the bg_box
|
||||
* optimize away non-differing inlines and ensure the bg_box
|
||||
* has something worth rendering */
|
||||
if (bg_box && (bg_box->style && bg_box->type != BOX_BR &&
|
||||
if (bg_box && (bg_box->style && bg_box->type != BOX_BR &&
|
||||
(bg_box->type != BOX_INLINE ||
|
||||
bg_box->style != bg_box->parent->parent->style)) &&
|
||||
((bg_box->style->background_color != TRANSPARENT) ||
|
||||
((bg_box->style->background_color != TRANSPARENT) ||
|
||||
(bg_box->background))) {
|
||||
/* find intersection of clip box and padding box */
|
||||
int px0 = x < x0 ? x0 : x;
|
||||
int py0 = y < y0 ? y0 : y;
|
||||
int px1 = x + padding_width < x1 ? x + padding_width : x1;
|
||||
int py1 = y + padding_height < y1 ? y + padding_height : y1;
|
||||
int px0 = (x - box->border[LEFT]) < x0 ?
|
||||
x0 : (x - box->border[LEFT]);
|
||||
int py0 = (y - box->border[TOP]) < y0 ?
|
||||
y0 : (y - box->border[TOP]);
|
||||
int px1 = x + padding_width + box->border[RIGHT] < x1 ?
|
||||
x + padding_width + box->border[RIGHT] : x1;
|
||||
int py1 = y + padding_height + box->border[BOTTOM] < y1 ? y +
|
||||
padding_height + box->border[BOTTOM] : y1;
|
||||
|
||||
/* valid clipping rectangles only */
|
||||
if ((px0 < px1) && (py0 < py1)) {
|
||||
@ -1162,7 +1166,7 @@ bool html_redraw_file(int x, int y, int width, int height,
|
||||
* \return true if successful, false otherwise
|
||||
*
|
||||
* The reason for the presence of ::background is the backwards compatibility
|
||||
* mess that is backgrounds on <body>. The background will be drawn relative
|
||||
* mess that is backgrounds on <body>. The background will be drawn relative
|
||||
* to ::box, using the background information contained within ::background.
|
||||
*/
|
||||
|
||||
@ -1187,7 +1191,7 @@ bool html_redraw_background(int x, int y, struct box *box, float scale,
|
||||
switch (background->style->background_repeat) {
|
||||
case CSS_BACKGROUND_REPEAT_REPEAT:
|
||||
repeat_x = repeat_y = true;
|
||||
/* optimisation: only plot the colour if
|
||||
/* optimisation: only plot the colour if
|
||||
* bitmap is not opaque */
|
||||
if (background->background->bitmap)
|
||||
plot_colour = !bitmap_get_opaque(
|
||||
@ -1216,7 +1220,7 @@ bool html_redraw_background(int x, int y, struct box *box, float scale,
|
||||
break;
|
||||
case CSS_BACKGROUND_POSITION_LENGTH:
|
||||
x += (int) (css_len2px(&background->style->
|
||||
background_position.horz.value.length,
|
||||
background_position.horz.value.length,
|
||||
background->style) * scale);
|
||||
break;
|
||||
default:
|
||||
@ -1233,7 +1237,7 @@ bool html_redraw_background(int x, int y, struct box *box, float scale,
|
||||
break;
|
||||
case CSS_BACKGROUND_POSITION_LENGTH:
|
||||
y += (int) (css_len2px(&background->style->
|
||||
background_position.vert.value.length,
|
||||
background_position.vert.value.length,
|
||||
background->style) * scale);
|
||||
break;
|
||||
default:
|
||||
@ -1241,15 +1245,15 @@ bool html_redraw_background(int x, int y, struct box *box, float scale,
|
||||
}
|
||||
}
|
||||
|
||||
/* special case for table rows as their background needs
|
||||
/* special case for table rows as their background needs
|
||||
* to be clipped to all the cells */
|
||||
if (box->type == BOX_TABLE_ROW) {
|
||||
for (parent = box->parent;
|
||||
for (parent = box->parent;
|
||||
((parent) && (parent->type != BOX_TABLE));
|
||||
parent = parent->parent);
|
||||
assert(parent && (parent->style));
|
||||
|
||||
clip_to_children =
|
||||
clip_to_children =
|
||||
(parent->style->border_spacing.horz.value > 0) ||
|
||||
(parent->style->border_spacing.vert.value > 0);
|
||||
|
||||
@ -1266,10 +1270,10 @@ bool html_redraw_background(int x, int y, struct box *box, float scale,
|
||||
clip_x0 = ox + (clip_box->x * scale);
|
||||
clip_y0 = oy + (clip_box->y * scale);
|
||||
clip_x1 = clip_x0 + (clip_box->padding[LEFT] +
|
||||
clip_box->width +
|
||||
clip_box->width +
|
||||
clip_box->padding[RIGHT]) * scale;
|
||||
clip_y1 = clip_y0 + (clip_box->padding[TOP] +
|
||||
clip_box->height +
|
||||
clip_box->height +
|
||||
clip_box->padding[BOTTOM]) * scale;
|
||||
|
||||
if (clip_x0 < px0) clip_x0 = px0;
|
||||
@ -1279,7 +1283,7 @@ bool html_redraw_background(int x, int y, struct box *box, float scale,
|
||||
|
||||
/* <td> attributes override <tr> */
|
||||
if ((clip_x0 >= clip_x1) || (clip_y0 >= clip_y1) ||
|
||||
(clip_box->style->background_color !=
|
||||
(clip_box->style->background_color !=
|
||||
TRANSPARENT) ||
|
||||
(clip_box->background &&
|
||||
clip_box->background->bitmap &&
|
||||
@ -1290,10 +1294,10 @@ bool html_redraw_background(int x, int y, struct box *box, float scale,
|
||||
|
||||
/* plot the background colour */
|
||||
if (background->style->background_color != TRANSPARENT) {
|
||||
*background_colour =
|
||||
*background_colour =
|
||||
background->style->background_color;
|
||||
if (plot_colour)
|
||||
if (!plot.fill(clip_x0, clip_y0,
|
||||
if (!plot.fill(clip_x0, clip_y0,
|
||||
clip_x1, clip_y1, *background_colour))
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user