mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-23 23:09:39 +03:00
Simplify debug outline calculations and avoid fp maths when scale is 1.0. Comment some border stuff.
svn path=/trunk/netsurf/; revision=8514
This commit is contained in:
parent
8365d46eb7
commit
08fc83b189
@ -311,22 +311,38 @@ bool html_redraw_box(struct box *box,
|
|||||||
|
|
||||||
/* dotted debug outlines */
|
/* dotted debug outlines */
|
||||||
if (html_redraw_debug) {
|
if (html_redraw_debug) {
|
||||||
|
int margin_left, margin_right;
|
||||||
|
int margin_top, margin_bottom;
|
||||||
|
if (scale == 1.0) {
|
||||||
|
/* avoid trivial fp maths */
|
||||||
|
margin_left = box->margin[LEFT];
|
||||||
|
margin_top = box->margin[TOP];
|
||||||
|
margin_right = box->margin[RIGHT];
|
||||||
|
margin_bottom = box->margin[BOTTOM];
|
||||||
|
} else {
|
||||||
|
margin_left = box->margin[LEFT] * scale;
|
||||||
|
margin_top = box->margin[TOP] * scale;
|
||||||
|
margin_right = box->margin[RIGHT] * scale;
|
||||||
|
margin_bottom = box->margin[BOTTOM] * scale;
|
||||||
|
}
|
||||||
if (!plot.rectangle(x, y,
|
if (!plot.rectangle(x, y,
|
||||||
x + padding_width, y + padding_height,
|
x + padding_width, y + padding_height,
|
||||||
plot_style_stroke_red))
|
plot_style_stroke_red))
|
||||||
return false;
|
return false;
|
||||||
if (!plot.rectangle(x + padding_left,
|
if (!plot.rectangle(x + padding_left,
|
||||||
y + padding_top,
|
y + padding_top,
|
||||||
x + padding_left + width,
|
x + padding_left + width,
|
||||||
y + padding_top + height,
|
y + padding_top + height,
|
||||||
plot_style_stroke_blue))
|
plot_style_stroke_blue))
|
||||||
return false;
|
return false;
|
||||||
if (!plot.rectangle(
|
if (!plot.rectangle(
|
||||||
x - (box->border[LEFT] + box->margin[LEFT]) * scale,
|
x - border_left - margin_left,
|
||||||
y - (box->border[TOP] + box->margin[TOP]) * scale,
|
y - border_top - margin_top,
|
||||||
(x - (box->border[LEFT] + box->margin[LEFT]) * scale) + (padding_width + (box->border[LEFT] + box->margin[LEFT] + box->border[RIGHT] + box->margin[RIGHT]) * scale),
|
x + padding_width + border_right +
|
||||||
(y - (box->border[TOP] + box->margin[TOP]) * scale) + (padding_height + (box->border[TOP] + box->margin[TOP] + box->border[BOTTOM] + box->margin[BOTTOM]) * scale),
|
margin_right,
|
||||||
plot_style_stroke_yellow))
|
y + padding_height + border_bottom +
|
||||||
|
margin_bottom,
|
||||||
|
plot_style_stroke_yellow))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1130,7 +1146,7 @@ bool html_redraw_border_plot(int i, int *p, colour c,
|
|||||||
switch (style) {
|
switch (style) {
|
||||||
case CSS_BORDER_STYLE_DOTTED:
|
case CSS_BORDER_STYLE_DOTTED:
|
||||||
plot_style_bdr.stroke_type = PLOT_OP_TYPE_DOT;
|
plot_style_bdr.stroke_type = PLOT_OP_TYPE_DOT;
|
||||||
|
/* fall through */
|
||||||
case CSS_BORDER_STYLE_DASHED:
|
case CSS_BORDER_STYLE_DASHED:
|
||||||
if (!plot.line((p[i * 4 + 0] + p[i * 4 + 2]) / 2,
|
if (!plot.line((p[i * 4 + 0] + p[i * 4 + 2]) / 2,
|
||||||
(p[i * 4 + 1] + p[i * 4 + 3]) / 2,
|
(p[i * 4 + 1] + p[i * 4 + 3]) / 2,
|
||||||
@ -1141,6 +1157,7 @@ bool html_redraw_border_plot(int i, int *p, colour c,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CSS_BORDER_STYLE_SOLID:
|
case CSS_BORDER_STYLE_SOLID:
|
||||||
|
/* fall through to default */
|
||||||
default:
|
default:
|
||||||
if (!plot.polygon(p + i * 4, 4, &plot_style_fillbdr))
|
if (!plot.polygon(p + i * 4, 4, &plot_style_fillbdr))
|
||||||
return false;
|
return false;
|
||||||
@ -1171,7 +1188,9 @@ bool html_redraw_border_plot(int i, int *p, colour c,
|
|||||||
|
|
||||||
case CSS_BORDER_STYLE_GROOVE:
|
case CSS_BORDER_STYLE_GROOVE:
|
||||||
light = 3 - light;
|
light = 3 - light;
|
||||||
|
/* fall through */
|
||||||
case CSS_BORDER_STYLE_RIDGE:
|
case CSS_BORDER_STYLE_RIDGE:
|
||||||
|
/* choose correct colours for each part of the border line */
|
||||||
if (light <= 1) {
|
if (light <= 1) {
|
||||||
plot_style_bdr_in = &plot_style_fillbdr_dark;
|
plot_style_bdr_in = &plot_style_fillbdr_dark;
|
||||||
plot_style_bdr_out = &plot_style_fillbdr_light;
|
plot_style_bdr_out = &plot_style_fillbdr_light;
|
||||||
@ -1199,7 +1218,9 @@ bool html_redraw_border_plot(int i, int *p, colour c,
|
|||||||
|
|
||||||
case CSS_BORDER_STYLE_INSET:
|
case CSS_BORDER_STYLE_INSET:
|
||||||
light = (light + 2) % 4;
|
light = (light + 2) % 4;
|
||||||
|
/* fall through */
|
||||||
case CSS_BORDER_STYLE_OUTSET:
|
case CSS_BORDER_STYLE_OUTSET:
|
||||||
|
/* choose correct colours for each part of the border line */
|
||||||
switch (light) {
|
switch (light) {
|
||||||
case 0:
|
case 0:
|
||||||
plot_style_bdr_in = &plot_style_fillbdr_light;
|
plot_style_bdr_in = &plot_style_fillbdr_light;
|
||||||
@ -1279,8 +1300,8 @@ bool html_redraw_checkbox(int x, int y, int width, int height,
|
|||||||
if (width < 12 || height < 12) {
|
if (width < 12 || height < 12) {
|
||||||
/* render a solid box instead of a tick */
|
/* render a solid box instead of a tick */
|
||||||
if (!plot.rectangle(x + z + z, y + z + z,
|
if (!plot.rectangle(x + z + z, y + z + z,
|
||||||
x + width - z, y + height - z,
|
x + width - z, y + height - z,
|
||||||
plot_style_fill_wblobc))
|
plot_style_fill_wblobc))
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
/* render a tick, as it'll fit comfortably */
|
/* render a tick, as it'll fit comfortably */
|
||||||
@ -1290,7 +1311,7 @@ bool html_redraw_checkbox(int x, int y, int width, int height,
|
|||||||
y + height - z,
|
y + height - z,
|
||||||
plot_style_stroke_wblobc) &&
|
plot_style_stroke_wblobc) &&
|
||||||
|
|
||||||
plot.line(x + (z * 3),
|
plot.line(x + (z * 3),
|
||||||
y + height - z,
|
y + height - z,
|
||||||
x + z + z,
|
x + z + z,
|
||||||
y + (height / 2),
|
y + (height / 2),
|
||||||
@ -1317,35 +1338,35 @@ bool html_redraw_radio(int x, int y, int width, int height,
|
|||||||
{
|
{
|
||||||
/* plot background of radio button */
|
/* plot background of radio button */
|
||||||
if (!plot.disc(x + width * 0.5,
|
if (!plot.disc(x + width * 0.5,
|
||||||
y + height * 0.5,
|
y + height * 0.5,
|
||||||
width * 0.5 - 1,
|
width * 0.5 - 1,
|
||||||
plot_style_fill_wbasec))
|
plot_style_fill_wbasec))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* plot dark arc */
|
/* plot dark arc */
|
||||||
if (!plot.arc(x + width * 0.5,
|
if (!plot.arc(x + width * 0.5,
|
||||||
y + height * 0.5,
|
y + height * 0.5,
|
||||||
width * 0.5 - 1,
|
width * 0.5 - 1,
|
||||||
45,
|
45,
|
||||||
225,
|
225,
|
||||||
plot_style_fill_darkwbasec))
|
plot_style_fill_darkwbasec))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* plot light arc */
|
/* plot light arc */
|
||||||
if (!plot.arc(x + width * 0.5,
|
if (!plot.arc(x + width * 0.5,
|
||||||
y + height * 0.5,
|
y + height * 0.5,
|
||||||
width * 0.5 - 1,
|
width * 0.5 - 1,
|
||||||
225,
|
225,
|
||||||
45,
|
45,
|
||||||
plot_style_fill_lightwbasec))
|
plot_style_fill_lightwbasec))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (selected) {
|
if (selected) {
|
||||||
/* plot selection blob */
|
/* plot selection blob */
|
||||||
if (!plot.disc(x + width * 0.5,
|
if (!plot.disc(x + width * 0.5,
|
||||||
y + height * 0.5,
|
y + height * 0.5,
|
||||||
width * 0.3 - 1,
|
width * 0.3 - 1,
|
||||||
plot_style_fill_wblobc))
|
plot_style_fill_wblobc))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user