Skip to content
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: main axis auto size not including margin #702

Merged
merged 2 commits into from Sep 26, 2021

Conversation

temper357
Copy link
Contributor

@temper357 temper357 commented Sep 23, 2021

Closes #689

修复 flex-grow/flex-shrink 存在时计算 flex item size 时因 automatic minimum size 未包含 margin 导致 flex item 宽度计算偏小。

  • 原因:issue 中第二层 div 默认 flex-shrink 为 1,因此会按照 flexible length 算法计算最终 size,最终 size 不能小于 element 自身 automatic minimum size ,有 children 的情况下最小 size 为 children 的 size,kraken 原逻辑未包含 children 的 margin 导致计算出的 size 偏小。

@temper357 temper357 added this to the 0.9 milestone Sep 23, 2021
@temper357 temper357 added this to In Progress in Browser Features via automation Sep 23, 2021
@temper357 temper357 changed the title [WIP] fix: main axis auto size not including margin fix: main axis auto size not including margin Sep 24, 2021
@@ -1818,6 +1818,16 @@ class RenderFlexLayout extends RenderLayoutBox {
? child.autoMinWidth
: child.autoMinHeight;
}
// Should add main axis margin of child to the main axis auto size of parent.
if (child is RenderBoxModel) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看起来 child 不太可能既是 RenderTextBox 又是 RenderBoxModel ,所以这里使用 else if 应该会更好

@@ -1174,6 +1174,12 @@ class RenderFlowLayout extends RenderLayoutBox {
if (runChild is RenderTextBox) {
runChildMainSize = runChild.autoMinWidth;
}
// Should add horizontal margin of child to the main axis auto size of parent.
if (runChild is RenderBoxModel) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

@answershuto answershuto merged commit e9ef6c4 into main Sep 26, 2021
@answershuto answershuto deleted the fix/main-axis-auto-size branch September 26, 2021 11:34
Browser Features automation moved this from In Progress to Done Sep 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

flex排版嵌套 横向尺寸计算错误 导致子元素缩小
4 participants