WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
9493
Percentage width replaced element in zero percent/fixed width container block incorrectly rendered.
https://bugs.webkit.org/show_bug.cgi?id=9493
Summary
Percentage width replaced element in zero percent/fixed width container block...
Sam Weinig
Reported
2006-06-18 06:26:32 PDT
Due to special casing in the layout code, if a container block has a 0px width, children with percentage widths will still be rendered even though they should be 0px wide.
Attachments
test case
(405 bytes, text/html)
2006-06-18 06:26 PDT
,
Sam Weinig
no flags
Details
Patch
(5.67 KB, patch)
2012-07-08 09:31 PDT
,
Pravin D
no flags
Details
Formatted Diff
Diff
Patch
(6.04 KB, patch)
2012-07-09 13:21 PDT
,
Pravin D
no flags
Details
Formatted Diff
Diff
Patch
(5.10 KB, patch)
2012-07-10 21:26 PDT
,
Pravin D
no flags
Details
Formatted Diff
Diff
Patch
(6.40 KB, patch)
2012-07-11 03:44 PDT
,
Pravin D
no flags
Details
Formatted Diff
Diff
Patch
(5.90 KB, patch)
2012-07-12 04:57 PDT
,
Pravin D
no flags
Details
Formatted Diff
Diff
Show Obsolete
(4)
View All
Add attachment
proposed patch, testcase, etc.
Sam Weinig
Comment 1
2006-06-18 06:26:59 PDT
Created
attachment 8900
[details]
test case
Pravin D
Comment 2
2012-07-08 09:31:22 PDT
Created
attachment 151163
[details]
Patch
Andy Estes
Comment 3
2012-07-09 11:19:25 PDT
Comment on
attachment 151163
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=151163&action=review
> Source/WebCore/ChangeLog:9 > + The width of a replaced element with percent width is governed by the width of its container. When the width of the container is > + zero percent/fixed value then the width of the replaced element must also be zero.
Is there a similar issue with 0-height containers? Do we already handle that correctly?
> Source/WebCore/rendering/RenderBox.cpp:2199 > + Length ContainerLogicalWidth = containingBlock()->style()->logicalWidth();
This variable should be named containerLogicalWidth (note the lowercase c).
> Source/WebCore/rendering/RenderBox.cpp:2200 > + // FIXME: Handle cases when containing block width is calculated or View port percent.
viewport should be one word, with no capital v.
> LayoutTests/fast/css/percent-width-img-inside-zero-percent-and-fixed-container-expected.txt:10 > +The test case checks if the calculated width of an Image with percent width inside a zero percent/fixed container is zero. > + > +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". > + > +PASS fixedContainerImage.getBoundingClientRect().width is 0 > +PASS percentContainerImage.getBoundingClientRect().width is 0 > +PASS successfullyParsed is true > + > +TEST COMPLETE > +
It seems strange write a dumpAsText test that prints values from the render tree. Why not make this test just dump the render tree? Your test would be much simpler since it wouldn't need all the JavaScript.
Pravin D
Comment 4
2012-07-09 12:01:37 PDT
(In reply to
comment #3
)
> (From update of
attachment 151163
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=151163&action=review
> > > Source/WebCore/ChangeLog:9 > > + The width of a replaced element with percent width is governed by the width of its container. When the width of the container is > > + zero percent/fixed value then the width of the replaced element must also be zero. > > Is there a similar issue with 0-height containers? Do we already handle that correctly? >
I'm not sure... need to check...
> > Source/WebCore/rendering/RenderBox.cpp:2199 > > + Length ContainerLogicalWidth = containingBlock()->style()->logicalWidth(); > > This variable should be named containerLogicalWidth (note the lowercase c). > > > Source/WebCore/rendering/RenderBox.cpp:2200 > > + // FIXME: Handle cases when containing block width is calculated or View port percent. > > viewport should be one word, with no capital v. >
Will do it...
> > LayoutTests/fast/css/percent-width-img-inside-zero-percent-and-fixed-container-expected.txt:10 > > +The test case checks if the calculated width of an Image with percent width inside a zero percent/fixed container is zero. > > + > > +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". > > + > > +PASS fixedContainerImage.getBoundingClientRect().width is 0 > > +PASS percentContainerImage.getBoundingClientRect().width is 0 > > +PASS successfullyParsed is true > > + > > +TEST COMPLETE > > + > > It seems strange write a dumpAsText test that prints values from the render tree. Why not make this test just dump the render tree? Your test would be much simpler since it wouldn't need all the JavaScript. >
Need to check... Seemed more informative to use dumpAsText()... Otherwise I need to remove all the text from the test case to make it platform independent...
Sam Weinig
Comment 5
2012-07-09 12:14:07 PDT
(In reply to
comment #3
)
> > LayoutTests/fast/css/percent-width-img-inside-zero-percent-and-fixed-container-expected.txt:10 > > +The test case checks if the calculated width of an Image with percent width inside a zero percent/fixed container is zero. > > + > > +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". > > + > > +PASS fixedContainerImage.getBoundingClientRect().width is 0 > > +PASS percentContainerImage.getBoundingClientRect().width is 0 > > +PASS successfullyParsed is true > > + > > +TEST COMPLETE > > + > > It seems strange write a dumpAsText test that prints values from the render tree. Why not make this test just dump the render tree? Your test would be much simpler since it wouldn't need all the JavaScript.
Better yet, make it a ref test?
Sam Weinig
Comment 6
2012-07-09 12:15:24 PDT
Comment on
attachment 151163
[details]
Patch r-ing based on Andy's review. It will probably need another round. Thanks for working on this. It is fun to see bugs I filed 6 years ago getting some traction :).
Pravin D
Comment 7
2012-07-09 13:10:53 PDT
(In reply to
comment #3
)
> (From update of
attachment 151163
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=151163&action=review
>
> It seems strange write a dumpAsText test that prints values from the render tree. Why not make this test just dump the render tree? Your test would be much simpler since it wouldn't need all the JavaScript. >
I tried to make dump the render tree rather than using JS to calculate the width. It makes the expected file platform specific(at least qt port does it) even though the width of the IMG must be zero. (In reply to
comment #5
)
> Better yet, make it a ref test? >
Ref might be in my opinion a over kill (As this not being a paint level fix). Anyways Im uploading a patch the suggest changes by Andy (including the dumping the render tree). Please let me know your opinions
Pravin D
Comment 8
2012-07-09 13:21:31 PDT
Created
attachment 151307
[details]
Patch
Pravin D
Comment 9
2012-07-09 13:22:46 PDT
(In reply to
comment #6
)
> (From update of
attachment 151163
[details]
) > r-ing based on Andy's review. It will probably need another round. Thanks for working on this. It is fun to see bugs I filed 6 years ago getting some traction :).
>
Your welcome... but I wonder why no one had picked this bug earlier !!!
Sam Weinig
Comment 10
2012-07-09 13:40:29 PDT
(In reply to
comment #9
)
> (In reply to
comment #6
) > > (From update of
attachment 151163
[details]
[details]) > > r-ing based on Andy's review. It will probably need another round. Thanks for working on this. It is fun to see bugs I filed 6 years ago getting some traction :). > > > > > Your welcome... but I wonder why no one had picked this bug earlier !!!
Or why I didn't just fix it when I filed it...6 years is long time to remember such things.
Pravin D
Comment 11
2012-07-09 13:42:47 PDT
(In reply to
comment #10
)
> (In reply to
comment #9
) > > (In reply to
comment #6
) > > > (From update of
attachment 151163
[details]
[details] [details]) > > > r-ing based on Andy's review. It will probably need another round. Thanks for working on this. It is fun to see bugs I filed 6 years ago getting some traction :). > > > > > > > > > Your welcome... but I wonder why no one had picked this bug earlier !!! > > Or why I didn't just fix it when I filed it...6 years is long time to remember such things.
>
:) What do think abt the patch... should we go with the current test case or the previous ??
Pravin D
Comment 12
2012-07-10 04:35:14 PDT
Will EFL bot ever finish ?!!
Robert Hogan
Comment 13
2012-07-10 12:07:39 PDT
Comment on
attachment 151307
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=151307&action=review
> Source/WebCore/rendering/RenderBox.cpp:2201 > + if (cw > 0 || (!cw && (containerLogicalWidth.isFixed() || containerLogicalWidth.isPercent())))
could you not just say: else if (!cw && (containerLogicalWidth.isFixed() || containerLogicalWidth.isPercent()) return 0; This would avoid the need to compute the width when we know the result we want.
Andy Estes
Comment 14
2012-07-10 16:42:42 PDT
(In reply to
comment #7
)
> (In reply to
comment #5
) > > > Better yet, make it a ref test? > > > Ref might be in my opinion a over kill (As this not being a paint level fix).
> I actually agree with Sam that a reftest would be the best option here. You avoid both platform-dependent expected results and having to add script to your test. I'd like to see you go one more round and add a reftest. It should be pretty easy: the reference document could just be the zero-width containers without the replaced children.
Andy Estes
Comment 15
2012-07-10 16:42:53 PDT
Comment on
attachment 151307
[details]
Patch I like this test better, although Sam correctly pointed out that a ref test would
Pravin D
Comment 16
2012-07-10 16:51:48 PDT
(In reply to
comment #14
)
> (In reply to
comment #7
) > > (In reply to
comment #5
) > > > > > Better yet, make it a ref test? > > > > > Ref might be in my opinion a over kill (As this not being a paint level fix). > > > > I actually agree with Sam that a reftest would be the best option here. You avoid both platform-dependent expected results and having to add script to your test. > > I'd like to see you go one more round and add a reftest. It should be pretty easy: the reference document could just be the zero-width containers without the replaced children. >
Sure... I'll add a ref test n upload another patch... Apart from the test cases, whats your opinion of the fix? PS: I'm a little confused with test case preference thou :( I was of thought that a dumpAsText() is better than a refTest(coz of the pixel test overhead) than a dumpRenderTree test (coz its highly platform senstivity). How wud one go about choosing the correct type of test case??
Pravin D
Comment 17
2012-07-10 17:15:46 PDT
(In reply to
comment #13
)
> (From update of
attachment 151307
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=151307&action=review
> > > Source/WebCore/rendering/RenderBox.cpp:2201 > > + if (cw > 0 || (!cw && (containerLogicalWidth.isFixed() || containerLogicalWidth.isPercent()))) > > could you not just say: > > else if (!cw && (containerLogicalWidth.isFixed() || containerLogicalWidth.isPercent()) > return 0; > > This would avoid the need to compute the width when we know the result we want. >
I don't think thts entirely right. Correct me if I'm wrong :) If you see the function minimumValueForLength(logicalWidth, cw) when logicalWidth is percent, the its return value is zero if cw is zero(taken). However, if logicalWidth is calculated, I was not sure if it will always eval to zero . Im not very familar with calculated value type but I'd expect calculated values can also be some kind expression that can be evaluated based on the seed value that is passed to it. If its true (calc value can be expressions) then its not proper to always ret zero... Let me know ur opinion...
Andy Estes
Comment 18
2012-07-10 18:00:34 PDT
(In reply to
comment #16
)
> (In reply to
comment #14
) > > (In reply to
comment #7
) > > > (In reply to
comment #5
) > > > > > > > Better yet, make it a ref test? > > > > > > > Ref might be in my opinion a over kill (As this not being a paint level fix). > > > > > > > I actually agree with Sam that a reftest would be the best option here. You avoid both platform-dependent expected results and having to add script to your test. > > > > I'd like to see you go one more round and add a reftest. It should be pretty easy: the reference document could just be the zero-width containers without the replaced children. > > > > Sure... I'll add a ref test n upload another patch... > Apart from the test cases, whats your opinion of the fix?
The fix ok to me, and it doesn't seem to break any tests according to the EWS bots. I'd probably want a layout expert to review it, though.
> > PS: > I'm a little confused with test case preference thou :( > I was of thought that a dumpAsText() is better than a refTest(coz of the pixel test overhead) than a dumpRenderTree test (coz its highly platform senstivity).
You aren't considering the complexity of the test itself. A dumpAsText test is an awkward choice for testing layout metrics, as you can see by comparing the complexity of your first test to that of your second. Reference tests and non-dumpAsText tests exist to regression test changes to layout and rendering, so it makes sense to use them here.
Pravin D
Comment 19
2012-07-10 20:46:29 PDT
(In reply to
comment #18
)
> (In reply to
comment #16
) > > (In reply to
comment #14
) > > > (In reply to
comment #7
) > > > > (In reply to
comment #5
) > > > > > > > > > Better yet, make it a ref test? > > > > > > > > > Ref might be in my opinion a over kill (As this not being a paint level fix). > > > > > > > > > > I actually agree with Sam that a reftest would be the best option here. You avoid both platform-dependent expected results and having to add script to your test. > > > > > > I'd like to see you go one more round and add a reftest. It should be pretty easy: the reference document could just be the zero-width containers without the replaced children. > > > > > > > Sure... I'll add a ref test n upload another patch... > > Apart from the test cases, whats your opinion of the fix? > > The fix ok to me, and it doesn't seem to break any tests according to the EWS bots. I'd probably want a layout expert to review it, though. >
ok...
> > > > PS: > > I'm a little confused with test case preference thou :( > > I was of thought that a dumpAsText() is better than a refTest(coz of the pixel test overhead) than a dumpRenderTree test (coz its highly platform senstivity). > > You aren't considering the complexity of the test itself. A dumpAsText test is an awkward choice for testing layout metrics, as you can see by comparing the complexity of your first test to that of your second. Reference tests and non-dumpAsText tests exist to regression test changes to layout and rendering, so it makes sense to use them here. >
maybe...
Pravin D
Comment 20
2012-07-10 21:26:57 PDT
Created
attachment 151589
[details]
Patch
Pravin D
Comment 21
2012-07-10 21:28:24 PDT
(In reply to
comment #20
)
> Created an attachment (id=151589) [details] > Patch >
Patch with refTest cases as suggested by Sam and Andy.
Pravin D
Comment 22
2012-07-11 03:44:53 PDT
Created
attachment 151670
[details]
Patch
Pravin D
Comment 23
2012-07-11 03:46:45 PDT
(In reply to
comment #22
)
> Created an attachment (id=151670) [details] > Patch >
Sorry!!! I had missed a Img resource file in the previous patch.
Andy Estes
Comment 24
2012-07-11 13:12:32 PDT
Comment on
attachment 151670
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=151670&action=review
I like the ref test. r=me. Two nits about the image resource: the '-jpeg' in the filename is redundant, and the resource would likely be smaller as a PNG.
> Source/WebCore/ChangeLog:15 > + The containing block is float or positioned in which case the width of the replace child element must be its instrinsic width.
floated, not float. replaced, not replace.
> Source/WebCore/ChangeLog:17 > + replace elment must be zero.
replaced, not replace.
> Source/WebCore/rendering/RenderBox.cpp:2200 > + // FIXME: Handle cases when containing block width is calculated or viewport percent.
Please file a bug and mention it here.
Pravin D
Comment 25
2012-07-12 04:57:21 PDT
Created
attachment 151911
[details]
Patch
WebKit Review Bot
Comment 26
2012-07-12 13:48:55 PDT
Comment on
attachment 151911
[details]
Patch Clearing flags on attachment: 151911 Committed
r122501
: <
http://trac.webkit.org/changeset/122501
>
WebKit Review Bot
Comment 27
2012-07-12 13:49:09 PDT
All reviewed patches have been landed. Closing bug.
Pravin D
Comment 28
2012-07-12 15:15:04 PDT
Thanks for ur time and review Andy :)
Julien Chaffraix
Comment 29
2012-09-05 14:52:11 PDT
This change caused
bug 95892
.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug