RESOLVED FIXED 46496
calcReplacedWidthUsing has wrong containing block width.
https://bugs.webkit.org/show_bug.cgi?id=46496
Summary calcReplacedWidthUsing has wrong containing block width.
Dave Hyatt
Reported 2010-09-24 12:25:11 PDT
calcReplacedWidthUsing has wrong containing block width. The width used has to match the block-flow directionality of the replaced element and not of the containing block.
Attachments
Patch (19.67 KB, patch)
2014-02-04 00:40 PST, Yuki Sekiguchi
no flags
Patch (4.83 KB, patch)
2021-10-16 04:30 PDT, Rob Buis
no flags
Patch (5.00 KB, patch)
2021-10-16 13:22 PDT, Rob Buis
no flags
Patch (5.97 KB, patch)
2021-10-19 09:08 PDT, Rob Buis
no flags
Yuki Sekiguchi
Comment 1 2014-02-04 00:40:20 PST
Darin Adler
Comment 2 2016-03-09 09:16:39 PST
Dave, would you review+ or review- please?
David Kilzer (:ddkilzer)
Comment 3 2016-06-21 11:38:07 PDT
Comment on attachment 223081 [details] Patch Clearing review? flag on old patch that no longer applies to trunk.
Rob Buis
Comment 4 2021-10-16 04:30:17 PDT
Rob Buis
Comment 5 2021-10-16 13:22:05 PDT
Rob Buis
Comment 6 2021-10-19 09:08:25 PDT
Darin Adler
Comment 7 2021-10-19 09:28:08 PDT
Comment on attachment 441735 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=441735&action=review > Source/WebCore/rendering/RenderBox.cpp:3334 > + LayoutUnit containerWidth; > + if (isOutOfFlowPositioned()) > + containerWidth = containingBlockLogicalWidthForPositioned(downcast<RenderBoxModelObject>(*container())); > + else if (isHorizontalWritingMode() == containingBlock()->isHorizontalWritingMode()) > + containerWidth = containingBlockLogicalWidthForContent(); > + else > + containerWidth = perpendicularContainingBlockLogicalHeight(); I’ve been noticing something like this, perhaps if not exactly the same, as a repeated idiom in patches recently correcting orthogonal flow behavior. Is there a way to add another function to help us get the repeated pattern right, without the code having an if statement like this in the middle or hurting efficiency? Or maybe it’s not repeated often enough.
Rob Buis
Comment 8 2021-10-19 12:23:20 PDT
Comment on attachment 441735 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=441735&action=review >> Source/WebCore/rendering/RenderBox.cpp:3334 >> + containerWidth = perpendicularContainingBlockLogicalHeight(); > > I’ve been noticing something like this, perhaps if not exactly the same, as a repeated idiom in patches recently correcting orthogonal flow behavior. Is there a way to add another function to help us get the repeated pattern right, without the code having an if statement like this in the middle or hurting efficiency? Or maybe it’s not repeated often enough. I checked but I do not see it repeated enough. I do think we can provide something for the frequent "isHorizontalWritingMode() == containingBlock()->isHorizontalWritingMode()" like checks, but that sounds like a different bug.
zalan
Comment 9 2021-10-19 13:57:30 PDT
Comment on attachment 441735 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=441735&action=review >>> Source/WebCore/rendering/RenderBox.cpp:3334 >>> + containerWidth = perpendicularContainingBlockLogicalHeight(); >> >> I’ve been noticing something like this, perhaps if not exactly the same, as a repeated idiom in patches recently correcting orthogonal flow behavior. Is there a way to add another function to help us get the repeated pattern right, without the code having an if statement like this in the middle or hurting efficiency? Or maybe it’s not repeated often enough. > > I checked but I do not see it repeated enough. I do think we can provide something for the frequent "isHorizontalWritingMode() == containingBlock()->isHorizontalWritingMode()" like checks, but that sounds like a different bug. I always get confused when I see code like this sine the writing-direction defines (at least the part that's relevant here) the block direction for the content. Now the block level child box's writing direction (replaced box in this case) should have nothing to do with how we get the available width constraint from the containing block. It's only the containing block's writing direction that rules the logical width/height for its content (again, replaced box in this case). When the containing block has horizontal writing mode, the available width for its block level boxes matches its "physical" width, while with vertical direction the available width becomes its "physical" height so that the box level child boxes grow vertically with their widths. i.e. when you call containingBlockLogicalWidthForContent() it shouldn't matter whether _this_ box is horizontal or vertical in the context of finding the available width for the child box. I know this code copies the logic from computeReplacedLogicalHeightUsing, but we either do yet another flip somewhere to have correct final values or simply the functions/variable names don't mean logical values.
zalan
Comment 10 2021-10-19 14:28:48 PDT
or put it simply: when the child box ask “how much I can grow (logical)horizontally in this containing block”, the child box's writing direction is irrelevant.
Sergio Villar Senin
Comment 11 2021-10-20 04:21:28 PDT
Comment on attachment 441735 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=441735&action=review >>>> Source/WebCore/rendering/RenderBox.cpp:3334 >>>> + containerWidth = perpendicularContainingBlockLogicalHeight(); >>> >>> I’ve been noticing something like this, perhaps if not exactly the same, as a repeated idiom in patches recently correcting orthogonal flow behavior. Is there a way to add another function to help us get the repeated pattern right, without the code having an if statement like this in the middle or hurting efficiency? Or maybe it’s not repeated often enough. >> >> I checked but I do not see it repeated enough. I do think we can provide something for the frequent "isHorizontalWritingMode() == containingBlock()->isHorizontalWritingMode()" like checks, but that sounds like a different bug. > > I always get confused when I see code like this sine the writing-direction defines (at least the part that's relevant here) the block direction for the content. > Now the block level child box's writing direction (replaced box in this case) should have nothing to do with how we get the available width constraint from the containing block. It's only the containing block's writing direction that rules the logical width/height for its content (again, replaced box in this case). > When the containing block has horizontal writing mode, the available width for its block level boxes matches its "physical" width, while with vertical direction the available width becomes its "physical" height so that the box level child boxes grow vertically with their widths. i.e. when you call containingBlockLogicalWidthForContent() it shouldn't matter whether _this_ box is horizontal or vertical in the context of finding the available width for the child box. I know this code copies the logic from computeReplacedLogicalHeightUsing, but we either do yet another flip somewhere to have correct final values or simply the functions/variable names don't mean logical values. I agree it's confusing but I don't think there is a problem with the code. In this case we're interested in the size of the container in the inline size of the child. If both are parallel then we need the inline size of the container, otherwise we are looking for the block size of the container. So we do need to check whether or not they're orthogonal. The question is I guess whether we do it in the caller does or the callee. BTW orthogonal to this bug, should we push for using Inline/Block instead of LogicalWidth/LogicalHeight ?
EWS
Comment 12 2021-10-20 10:35:25 PDT
Committed r284548 (243290@main): <https://commits.webkit.org/243290@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 441735 [details].
Radar WebKit Bug Importer
Comment 13 2021-10-20 10:36:20 PDT
Note You need to log in before you can comment on or make changes to this bug.