|
|
Chromium Code Reviews|
Created:
3 years, 8 months ago by Sunghoon Kim Modified:
3 years, 8 months ago CC:
blink-reviews, blink-reviews-layout_chromium.org, chromium-reviews, eae+blinkwatch, jchaffraix+rendering, leviw+renderwatch, pdr+renderingwatchlist_chromium.org, szager+layoutwatch_chromium.org, zoltan1 Target Ref:
refs/heads/master Project:
chromium Visibility:
Public. |
DescriptionAdd NeedsPreferredWidthsRecalculation() for block
In the case the block has relative height and width is auto and
it has an image which should keep the aspect ratio,
it needs preferred width recalculation if the parent changes the height.
To cover this, add NeedsPreferredWidthsRecalculation() for LayoutBlock.
BUG=707151, 514663, 709233
Review-Url: https://codereview.chromium.org/2828453002
Cr-Commit-Position: refs/heads/master@{#466934}
Committed: https://chromium.googlesource.com/chromium/src/+/76e307f44292b2999535aa8c5605cfd9129e9c12
Patch Set 1 #Patch Set 2 : Make inline-block container's width update #
Total comments: 1
Patch Set 3 : Make inline-block container's width update #Patch Set 4 : change commit message #
Total comments: 4
Patch Set 5 : Add NeedsPreferredWidthRecalculation() for block #Patch Set 6 : rebased code and added tc #
Total comments: 3
Patch Set 7 : Add NeedsPreferredWidthsRecalculation() for block #
Messages
Total messages: 24 (11 generated)
shoon.kim@lge.com changed reviewers: + fs@opera.com, schenney@chromium.org
Could you please to review this? Thanks.
fs@opera.com changed reviewers: + mstensho@opera.com
+mstensho
robhogan@gmail.com changed reviewers: + robhogan@gmail.com
https://codereview.chromium.org/2828453002/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp (right): https://codereview.chromium.org/2828453002/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp:2942: child.SetPreferredLogicalWidthsDirty(kMarkContainerChain); If someone called SetPreferredLogicalWidthsDirty on child, why didn't they mark it with kMarkContainerChain at the time? I think that's the place to investigate.
If the block is inline-block and the preferred width of child needs to be recalculated, the preferred width of inline-block also should be recalculated. So, I changed the code as you commented. Thanks.
Description was changed from ========== Make inline-block container's width update Make inline-block container's preferred width update if its child's preferred width needs to be recalculated. BUG=707151, 692874 ========== to ========== Make inline-block container's width update Make inline-block container's preferred width update if its child's preferred width needs to be recalculated. BUG=707151, 514663 ==========
https://codereview.chromium.org/2828453002/diff/60001/third_party/WebKit/Layo... File third_party/WebKit/LayoutTests/fast/inline-block/inline-block-update-width.html (right): https://codereview.chromium.org/2828453002/diff/60001/third_party/WebKit/Layo... third_party/WebKit/LayoutTests/fast/inline-block/inline-block-update-width.html:13: width: auto; width and height are initially auto, so no need to be explicit about it. https://codereview.chromium.org/2828453002/diff/60001/third_party/WebKit/Layo... third_party/WebKit/LayoutTests/fast/inline-block/inline-block-update-width.html:31: <script src="../../resources/check-layout.js"></script> Please consider using testharness when writing check-layout tests. I.e. include the following scripts instead: <script src="../../resources/testharness.js"></script> <script src="../../resources/testharnessreport.js"></script> <script src="../../resources/check-layout-th.js"></script> That will eliminate the need for the -expected.txt counterpart. https://codereview.chromium.org/2828453002/diff/60001/third_party/WebKit/Layo... third_party/WebKit/LayoutTests/fast/inline-block/inline-block-update-width.html:34: function runTest() { Seems that you can just do all these things right away, rather than hooking them on an onload event. So no need for the wrapper function. https://codereview.chromium.org/2828453002/diff/60001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/layout/LayoutBlock.cpp (right): https://codereview.chromium.org/2828453002/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/core/layout/LayoutBlock.cpp:610: IsInlineBlockOrInlineTable() ? kMarkContainerChain : kMarkOnlyThis); Marking the container chain during layout seems wrong. This situation needs to be detected at the beginning of layout of the shrink-to-fit container, not when laying out its children. Furthermore: 1. The inline-block may not be the immediate parent of the child that NeedsPreferredWidthsRecalculation(). And: 2. inline-block isn't the only characteristic we should check for. Floats with auto width will have similar issues. Table cells too, probably. And possibly more. Here's a test that demonstrates both #1 and #2. The suggested CL doesn't fix it: <!DOCTYPE html> <p>No red should be seen.</p> <div id="parent" style="height:300px; background:green;"> <div id="stf" style="float:left; height:100%; background:red;"> <div id="middle" style="height:100%;"> <img style="display:block; height:100%; background:yellow;" src='data:image/svg+xml;utf8,<svg height="2px" width="1px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"></svg>'></img> </div> </div> </div> <script> document.body.offsetTop; document.getElementById("parent").style.height = "150px"; </script> The object that needs to have its preferred logical widths marked dirty is #stf (it's a float, not an inline-block). The parent of the object that NeedsPreferredWidthsRecalculation() is #middle.
What about inline-flex(-webkit-inline-box) or inline-grid?
Description was changed from ========== Make inline-block container's width update Make inline-block container's preferred width update if its child's preferred width needs to be recalculated. BUG=707151, 514663 ========== to ========== Add NeedsPreferredWidthRecalculation() for block In the case the block has relative height and width is auto and it has an mage which should keep the aspect ratio, it needs preferred width recalculation if the parent changes the height. To cover this, add NeedsPreferredWidthRecalculation() for LayoutBlock. BUG=707151, 514663 ==========
The problem was, i think, the block which has relative height and width auto was not resized when the parent changed its height if the child of the block had changed its size. Here, override NeedsPreferredWidthCalculation() and make preferred width to be recalculated when the block has relative height and width auto like LayoutReplaced. Could you review this CL? Thanks.
This looks like an excellent solution! Before landing, though: Could you proof-read the commit message? It's not called "NeedsPreferredWidthRecalculation()", but rather "NeedsPreferredWidthsRecalculation()". Also, "mage" -> "image" Could you also add another, slightly more evil, test, which uses nested blocks with percentage height, e.g. like in my example in #msg9 .
Description was changed from ========== Add NeedsPreferredWidthRecalculation() for block In the case the block has relative height and width is auto and it has an mage which should keep the aspect ratio, it needs preferred width recalculation if the parent changes the height. To cover this, add NeedsPreferredWidthRecalculation() for LayoutBlock. BUG=707151, 514663 ========== to ========== Add NeedsPreferredWidthsRecalculation() for block In the case the block has relative height and width is auto and it has an image which should keep the aspect ratio, it needs preferred width recalculation if the parent changes the height. To cover this, add NeedsPreferredWidthsRecalculation() for LayoutBlock. BUG=707151, 514663 ==========
Thanks for your review. I added nested block case in the tc and tc moved to fast/block. Also, i modified the commit message as you commented. Any other comments are welcome.
Description was changed from ========== Add NeedsPreferredWidthsRecalculation() for block In the case the block has relative height and width is auto and it has an image which should keep the aspect ratio, it needs preferred width recalculation if the parent changes the height. To cover this, add NeedsPreferredWidthsRecalculation() for LayoutBlock. BUG=707151, 514663 ========== to ========== Add NeedsPreferredWidthsRecalculation() for block In the case the block has relative height and width is auto and it has an image which should keep the aspect ratio, it needs preferred width recalculation if the parent changes the height. To cover this, add NeedsPreferredWidthsRecalculation() for LayoutBlock. BUG=707151, 514663, 709233 ==========
lgtm with nits. https://codereview.chromium.org/2828453002/diff/100001/third_party/WebKit/Lay... File third_party/WebKit/LayoutTests/fast/block/block-width-recalc-with-relative-height.html (right): https://codereview.chromium.org/2828453002/diff/100001/third_party/WebKit/Lay... third_party/WebKit/LayoutTests/fast/block/block-width-recalc-with-relative-height.html:28: <img src='data:image/svg+xml;utf8,<svg height="2px" width="1px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"></svg>'></img> IMG doesn't need an end tag. https://codereview.chromium.org/2828453002/diff/100001/third_party/WebKit/Lay... third_party/WebKit/LayoutTests/fast/block/block-width-recalc-with-relative-height.html:36: <img src='data:image/svg+xml;utf8,<svg height="2px" width="1px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"></svg>'></img> Ditto. https://codereview.chromium.org/2828453002/diff/100001/third_party/WebKit/Lay... third_party/WebKit/LayoutTests/fast/block/block-width-recalc-with-relative-height.html:54: checkLayout("#middle", results); You can omit this. checkLayout() processes the entire subtree, so #middle is already tested as part of testing #stylefloat.
Thanks for review. Ran CQ.
The CQ bit was checked by shoon.kim@lge.com
The patchset sent to the CQ was uploaded after l-g-t-m from mstensho@opera.com Link to the patchset: https://codereview.chromium.org/2828453002/#ps120001 (title: "Add NeedsPreferredWidthsRecalculation() for block")
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch.
Bot data: {"patchset_id": 120001, "attempt_start_ts": 1493107627800340,
"parent_rev": "9e8f21af25c5425136583d7658850e4a7db2146e", "commit_rev":
"76e307f44292b2999535aa8c5605cfd9129e9c12"}
Message was sent while issue was closed.
Description was changed from ========== Add NeedsPreferredWidthsRecalculation() for block In the case the block has relative height and width is auto and it has an image which should keep the aspect ratio, it needs preferred width recalculation if the parent changes the height. To cover this, add NeedsPreferredWidthsRecalculation() for LayoutBlock. BUG=707151, 514663, 709233 ========== to ========== Add NeedsPreferredWidthsRecalculation() for block In the case the block has relative height and width is auto and it has an image which should keep the aspect ratio, it needs preferred width recalculation if the parent changes the height. To cover this, add NeedsPreferredWidthsRecalculation() for LayoutBlock. BUG=707151, 514663, 709233 Review-Url: https://codereview.chromium.org/2828453002 Cr-Commit-Position: refs/heads/master@{#466934} Committed: https://chromium.googlesource.com/chromium/src/+/76e307f44292b2999535aa8c5605... ==========
Message was sent while issue was closed.
Committed patchset #7 (id:120001) as https://chromium.googlesource.com/chromium/src/+/76e307f44292b2999535aa8c5605... |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
