New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: flex stretch height when positioned child exists #1004
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…od in flex layout
temper357
changed the title
[WIP] fix: flex stretch height when positioned child exists
fix: flex stretch height when positioned child exists
Dec 24, 2021
temper357
requested review from
andycall,
answershuto,
wssgcg1213 and
yuanyan
December 24, 2021 07:47
answershuto
reviewed
Dec 24, 2021
yuanyan
approved these changes
Dec 27, 2021
answershuto
approved these changes
Dec 28, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #1003
修复当无高度的 flex 布局下有 position absolute 的 image 时高度不应该由 image 撑开。
问题:Flex layout 原来的布局逻辑是先 layout placeholder(当 position absolute 的元素未指定 top/left 需要使用占位的 offset),再 layout 在文档流的 renderBox,但是 placeholder 的 layout 时同样会设置容器 size,当 flex 未设置 height 时这导致容器高度由 image 的高度撑开。
fix: 将 placeholder 的 layout 阶段放在正常文档流 renderBox 的 layout 阶段之后,保证 placeholder layout 时容器 size 已确定能正常定位(之前这里也有 bug),同时 placeholder 的 layout 阶段只做 layout 与 set offset,不需要对容器 set size。
另外,对于 flex 与 flow layout 代码进行了整体的重构,目标是让代码更可读易维护,包含以下一些手段: