RESOLVED FIXED Bug 81809
percentage height/width values in quirks mode are incorrectly resolved in flexbox children
https://bugs.webkit.org/show_bug.cgi?id=81809
Summary percentage height/width values in quirks mode are incorrectly resolved in fle...
Tony Chang
Reported 2012-03-21 11:35:19 PDT
When computing min/max-height/width and height/width of flex children, we resolve percentage values by only looking at the flexbox size. In quirks mode, if the flexbox size is auto, we should check parents for a definite value.
Attachments
testcase (1.42 KB, text/html)
2012-08-06 13:48 PDT, Ojan Vafai
no flags
Patch (17.26 KB, patch)
2012-08-07 14:23 PDT, Ojan Vafai
tony: review+
SravanKumar S(:sravan)
Comment 1 2012-03-22 07:29:36 PDT
Hi Tony, can you please elaborate?. Are you speaking about RenderFlexibleBox?
Tony Chang
Comment 2 2012-03-22 09:51:17 PDT
(In reply to comment #1) > Hi Tony, can you please elaborate?. > Are you speaking about RenderFlexibleBox? Yes, this is in RenderFlexibleBox.cpp.
Tony Chang
Comment 3 2012-03-22 10:48:38 PDT
Demo in the URL. This may actually just work (the above test case with min-height seems to). We should add tests for this.
Ojan Vafai
Comment 5 2012-08-06 13:48:08 PDT
Ugh. All of these are invalid due to renaming flexbox to flex. Uploading a valid test case. Still, we seem to get the height right.
Ojan Vafai
Comment 6 2012-08-06 13:48:20 PDT
Created attachment 156758 [details] testcase
Tony Chang
Comment 7 2012-08-06 14:07:05 PDT
(In reply to comment #5) > Ugh. All of these are invalid due to renaming flexbox to flex. Uploading a valid test case. Still, we seem to get the height right. Yeah, I think we just need to add some layout tests.
Ojan Vafai
Comment 8 2012-08-06 14:15:21 PDT
(In reply to comment #7) > (In reply to comment #5) > > Ugh. All of these are invalid due to renaming flexbox to flex. Uploading a valid test case. Still, we seem to get the height right. > > Yeah, I think we just need to add some layout tests. I've found at least one bug as I've been trying to understand this. I'll post an update once I feel that I've found all the relevant bugs.
Ojan Vafai
Comment 9 2012-08-06 17:07:51 PDT
I've found a few bugs and will post a patch soon. Having some weird issues with my fix. :(
Ojan Vafai
Comment 10 2012-08-07 14:23:49 PDT
Elliott Sprehn
Comment 11 2012-08-07 14:41:08 PDT
Comment on attachment 157004 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=157004&action=review > Source/WebCore/rendering/RenderBox.cpp:2064 > +LayoutUnit RenderBox::computeLogicalClientHeight(SizeType heightType, const Length& height) Tony originally said this didn't make sense here because it's not useful for things outside new Flexbox. What's different now? > Source/WebCore/rendering/RenderFlexibleBox.cpp:817 > + return minSize; The -1 check seems bad. Negative min/max height are illegal, so it shouldn't even be isSpecified() if it's negative. Is that a bug?
Ojan Vafai
Comment 12 2012-08-07 15:02:29 PDT
Comment on attachment 157004 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=157004&action=review >> Source/WebCore/rendering/RenderBox.cpp:2064 >> +LayoutUnit RenderBox::computeLogicalClientHeight(SizeType heightType, const Length& height) > > Tony originally said this didn't make sense here because it's not useful for things outside new Flexbox. What's different now? I'm thinking ahead to Grid, which will need this same logic for restricting to min/max sizes. The alternative for this patch would have been to pass in the RenderBox to use, which is fine (we'd pass in "this" everwhere except in the three cases where we'd pass in the flex item). But given the Grid need, I went with the simpler patch. I'm a little wary of all these methods with very similar sounding names, but I couldn't think of a great solution. >> Source/WebCore/rendering/RenderFlexibleBox.cpp:817 >> + return minSize; > > The -1 check seems bad. Negative min/max height are illegal, so it shouldn't even be isSpecified() if it's negative. Is that a bug? computePercentageLogicalHeight can return -1 in some cases depending on the state of the containingBlock (e.g. in standards mode if the containing block is height:auto).
Tony Chang
Comment 13 2012-08-07 18:27:18 PDT
Comment on attachment 157004 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=157004&action=review > Source/WebCore/rendering/RenderFlexibleBox.cpp:407 > + if (isColumnFlow()) > + return child->computeLogicalClientHeight(sizeType, size); > + return child->computeContentBoxLogicalWidth(valueForLength(size, availableSize, view())); This looks wrong for orthogonal flows, but I guess it's what we had before. >>> Source/WebCore/rendering/RenderFlexibleBox.cpp:817 >>> + return minSize; >> >> The -1 check seems bad. Negative min/max height are illegal, so it shouldn't even be isSpecified() if it's negative. Is that a bug? > > computePercentageLogicalHeight can return -1 in some cases depending on the state of the containingBlock (e.g. in standards mode if the containing block is height:auto). I wonder if we can remove the isSpecified() check. I don't have a strong preference one way or another. > Source/WebCore/rendering/RenderFlexibleBox.h:88 > + LayoutUnit computeMainAxisSizeForChild(RenderBox* child, SizeType, const Length& size, LayoutUnit availableSize); Nit: I think we normally use Extent instead of Size for lengths. I don't feel strongly about this. > LayoutTests/css3/flexbox/percentage-sizes-quirks.html:37 > +<script> > +if (window.testRunner) > + testRunner.dumpAsText(); > +</script> Nit: I would probably print document.compatMode somewhere just to be sure.
Ojan Vafai
Comment 14 2012-08-08 10:58:41 PDT
Comment on attachment 157004 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=157004&action=review >> Source/WebCore/rendering/RenderFlexibleBox.cpp:407 >> + return child->computeContentBoxLogicalWidth(valueForLength(size, availableSize, view())); > > This looks wrong for orthogonal flows, but I guess it's what we had before. Good catch. Adding a FIXME for now. >>>> Source/WebCore/rendering/RenderFlexibleBox.cpp:817 >>>> + return minSize; >>> >>> The -1 check seems bad. Negative min/max height are illegal, so it shouldn't even be isSpecified() if it's negative. Is that a bug? >> >> computePercentageLogicalHeight can return -1 in some cases depending on the state of the containingBlock (e.g. in standards mode if the containing block is height:auto). > > I wonder if we can remove the isSpecified() check. I don't have a strong preference one way or another. Seems fine to me. I suppose the minSize != -1 is redundant with the childSize<minSize check since childSize is at least 0 (but the -1 check is definitely needed for maxSize). This just means we'll need to check of the auto case first since we want that to go down a special code path for flexitems. >> Source/WebCore/rendering/RenderFlexibleBox.h:88 >> + LayoutUnit computeMainAxisSizeForChild(RenderBox* child, SizeType, const Length& size, LayoutUnit availableSize); > > Nit: I think we normally use Extent instead of Size for lengths. I don't feel strongly about this. Yeah, I thought about it after the fact and was too lazy to change it. :) But you're right, I should be consistent. >> LayoutTests/css3/flexbox/percentage-sizes-quirks.html:37 >> +</script> > > Nit: I would probably print document.compatMode somewhere just to be sure. makes sense
Ojan Vafai
Comment 15 2012-08-08 11:17:51 PDT
Comment on attachment 157004 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=157004&action=review >>>>> Source/WebCore/rendering/RenderFlexibleBox.cpp:817 >>>>> + return minSize; >>>> >>>> The -1 check seems bad. Negative min/max height are illegal, so it shouldn't even be isSpecified() if it's negative. Is that a bug? >>> >>> computePercentageLogicalHeight can return -1 in some cases depending on the state of the containingBlock (e.g. in standards mode if the containing block is height:auto). >> >> I wonder if we can remove the isSpecified() check. I don't have a strong preference one way or another. > > Seems fine to me. I suppose the minSize != -1 is redundant with the childSize<minSize check since childSize is at least 0 (but the -1 check is definitely needed for maxSize). > > This just means we'll need to check of the auto case first since we want that to go down a special code path for flexitems. Actually, on closer look, the valueForLength functions all ASSERT_NOT_REACHED for intrinsic values other than FillAvailable and Auto. So, we should probably keep the checks in place.
Ojan Vafai
Comment 16 2012-08-08 11:29:11 PDT
Note You need to log in before you can comment on or make changes to this bug.