Bug 18347 - Absolutely positioned image percentage width does not respect container's padding
Summary: Absolutely positioned image percentage width does not respect container's pad...
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.5
: P2 Trivial
Assignee: Nobody
Depends on:
Reported: 2008-04-07 14:02 PDT by Andrew Watt
Modified: 2008-05-01 16:58 PDT (History)
2 users (show)

See Also:

Test case (3.85 KB, text/html)
2008-04-07 14:06 PDT, Andrew Watt
no flags Details
Test case (updated) (967 bytes, text/html)
2008-04-13 20:02 PDT, Anatoli Papirovski
no flags Details
patch (12.44 KB, patch)
2008-04-13 20:09 PDT, Anatoli Papirovski
no flags Details | Formatted Diff | Diff
patch (updated) (12.42 KB, patch)
2008-04-19 13:59 PDT, Anatoli Papirovski
no flags Details | Formatted Diff | Diff
patch (updated 2) (12.44 KB, patch)
2008-04-21 07:36 PDT, Anatoli Papirovski
hyatt: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Watt 2008-04-07 14:02:41 PDT
An absolutely positioned replaced element with a percentage width should scale in respect to its containing block's width, including padding.  Instead, it seems that the padding is not taken into account, and only the content width is used.

I believe the relevant part of the CSS 2.1 spec is <http://www.w3.org/TR/CSS21/visudet.html#the-width-property>: For absolutely positioned elements whose containing block is based on a block-level element, the percentage is calculated with respect to the width of the padding box of that element. This is a change from CSS1, where the percentage width was always calculated with respect to the content box of the parent element.
Comment 1 Andrew Watt 2008-04-07 14:06:57 PDT
Created attachment 20388 [details]
Test case

The gradient image should be as wide as the blue box.
Comment 2 Anatoli Papirovski 2008-04-13 20:02:44 PDT
Created attachment 20514 [details]
Test case (updated)

An improved test case, which makes it a little clearer with the standardized green for pass and red for fail.
Comment 3 Anatoli Papirovski 2008-04-13 20:09:25 PDT
Created attachment 20515 [details]

I went over the specs and seems to me like the test case was correct, not to mention that webkit was already doing the correct thing for the height, just not for the width.

This is my first patch, I tried my best, but I'm sure there's bound to be errors... also, I made sure to run the webkit tests and found no regressions. I'm new to this whole thing, so I appreciate any tips or corrections.
Comment 4 Anatoli Papirovski 2008-04-19 13:59:55 PDT
Created attachment 20692 [details]
patch (updated)

Updated the patch to remove "tabs" from the ChangeLogs as not to break the script.
Comment 5 Anatoli Papirovski 2008-04-21 07:36:21 PDT
Created attachment 20723 [details]
patch (updated 2)

Removed tabs from the test case too, just in case that would break anything.
Comment 6 Eric Seidel (no email) 2008-04-30 23:57:25 PDT
This looks right to me, but hyatt is really the expert here.
Comment 7 Dave Hyatt 2008-05-01 02:31:22 PDT
Comment on attachment 20723 [details]
patch (updated 2)

Comment 8 mitz 2008-05-01 16:58:41 PDT
Landed in <http://trac.webkit.org/changeset/32784> with tiny tweaks to the change logs.