summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--css/ruleset.c18
-rw-r--r--render/html_redraw.c17
2 files changed, 25 insertions, 10 deletions
diff --git a/css/ruleset.c b/css/ruleset.c
index c09bd0d1c..54d7ff87d 100644
--- a/css/ruleset.c
+++ b/css/ruleset.c
@@ -1085,7 +1085,9 @@ bool css_background_position_parse(const struct css_node **node,
{
const struct css_node *v = *node;
const struct css_node *w = v->next;
- struct css_background_entry *bg = 0, *bg2 = 0;
+ const struct css_node *n_temp = 0;
+ struct css_background_entry *bg = 0, *bg2 = 0, *b_temp = 0;
+ bool switched = false;
if (v->type == CSS_NODE_IDENT)
bg = css_background_lookup(v);
@@ -1151,6 +1153,14 @@ bool css_background_position_parse(const struct css_node **node,
*node = w->next;
return true;
}
+
+ /* reverse specifiers such that idents are places in h, v order */
+ if ((v->type == CSS_NODE_IDENT && bg && bg->vertical) ||
+ (w->type == CSS_NODE_IDENT && bg2 && bg2->horizontal)) {
+ n_temp = v; v = w; w = n_temp;
+ b_temp = bg; bg = bg2; bg2 = b_temp;
+ switched = true;
+ }
if (v->type == CSS_NODE_IDENT) { /* horizontal value */
if (!bg || bg->vertical)
@@ -1185,6 +1195,12 @@ bool css_background_position_parse(const struct css_node **node,
vert->pos = CSS_BACKGROUND_POSITION_LENGTH;
}
+ /* undo any switching we did */
+ if (switched) {
+ n_temp = v; v = w; w = n_temp;
+ b_temp = bg; bg = bg2; bg2 = b_temp;
+ }
+
*node = w->next;
return true;
}
diff --git a/render/html_redraw.c b/render/html_redraw.c
index f0b8d54be..2fc4a5bfd 100644
--- a/render/html_redraw.c
+++ b/render/html_redraw.c
@@ -701,7 +701,6 @@ bool html_redraw_file(int x, int y, int width, int height,
bool html_redraw_background(int x, int y,
struct box *box, float scale, colour background_colour)
{
- int image_width, image_height;
bool repeat_x = false;
bool repeat_y = false;
@@ -718,10 +717,6 @@ bool html_redraw_background(int x, int y,
else if (!option_background_images)
return true;*/
- /* get the image dimensions for our positioning and scaling */
- image_width = box->background->width * scale;
- image_height = box->background->height * scale;
-
/* handle background-repeat */
switch (box->style->background_repeat) {
case CSS_BACKGROUND_REPEAT_REPEAT:
@@ -743,7 +738,8 @@ bool html_redraw_background(int x, int y,
switch (box->style->background_position.horz.pos) {
case CSS_BACKGROUND_POSITION_PERCENT:
x += (box->padding[LEFT] + box->width +
- box->padding[RIGHT] - image_width) *
+ box->padding[RIGHT] -
+ box->background->width) * scale *
box->style->background_position.horz.
value.percent / 100;
break;
@@ -758,12 +754,13 @@ bool html_redraw_background(int x, int y,
switch (box->style->background_position.vert.pos) {
case CSS_BACKGROUND_POSITION_PERCENT:
y += (box->padding[TOP] + box->height +
- box->padding[BOTTOM] - image_height) *
+ box->padding[BOTTOM] -
+ box->background->height) * scale *
box->style->background_position.vert.
value.percent / 100;
break;
case CSS_BACKGROUND_POSITION_LENGTH:
- y -= (int) (css_len2px(&box->style->background_position.
+ y += (int) (css_len2px(&box->style->background_position.
vert.value.length, box->style) * scale);
break;
default:
@@ -771,7 +768,9 @@ bool html_redraw_background(int x, int y,
}
/* and plot the image */
- return plot.bitmap_tile(x, y, image_width, image_height,
+ return plot.bitmap_tile(x, y,
+ box->background->width * scale,
+ box->background->height * scale,
box->background->bitmap,
background_colour,
repeat_x, repeat_y);