Skip to content

select: computed: Fix lost unit in relative position offset derivation - #31

Closed
metan-ucw wants to merge 1 commit into
netsurf-browser:masterfrom
metan-ucw:master
Closed

select: computed: Fix lost unit in relative position offset derivation#31
metan-ucw wants to merge 1 commit into
netsurf-browser:masterfrom
metan-ucw:master

Conversation

@metan-ucw

Copy link
Copy Markdown

css_computed_{top,right,bottom,left} derive the used value of an unspecified offset from the opposite side (§9.4.3, e.g. left = -right), taking the unit from get_bits(style) >> 2. But get_bits returns only the two type bits (bits & 0x3), so the >> 2 is always 0 and the derived offset silently becomes CSS_UNIT_PX. A relatively positioned box with right: 1in and auto left thus computed left as -1px instead of -96px.

Read the opposite side's unit through its full accessor instead.

css_computed_{top,right,bottom,left} derive the used value of an
unspecified offset from the opposite side (§9.4.3, e.g. left = -right),
taking the unit from get_<side>_bits(style) >> 2.  But get_<side>_bits
returns only the two type bits (bits & 0x3), so the >> 2 is always 0 and
the derived offset silently becomes CSS_UNIT_PX.  A relatively positioned
box with `right: 1in` and auto left thus computed left as -1px instead of
-96px.

Read the opposite side's unit through its full accessor instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Cyril Hrubis <metan@ucw.cz>
@tlsa

tlsa commented Jul 26, 2026

Copy link
Copy Markdown
Member

Thanks for reporting this issue. I confirmed it and spotted another issue with the handling of over-constrained bottom.

This PR wouldn't compile due a bunch of olength/ounit may be used uninitialized warnings. (We build with -Werror.)

I've fixed it in #33.

Thanks again!

@tlsa tlsa closed this Jul 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants