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: reposition children when position changed #1033

Merged
merged 11 commits into from
Dec 30, 2021

Conversation

temper357
Copy link
Contributor

@temper357 temper357 commented Dec 29, 2021

Closes #1029

  • 增加当 element 的 position 在 static 与非 static 之间转换时,对底下的 children 重新定位的逻辑,之前这块逻辑缺失。
  • 当 position 在 static 与 relative 之间转换时,renderObject 的位置没变,不需要进行 detach 与 attach 到 containing block 的操作,可以提前返回,减少无必要的性能损耗。
  • 重构 element 操作 renderBoxModel 相关的代码,将这些代码从 element 移到 box_model.dart 中,让架构的分层更清晰。

@temper357 temper357 changed the title [WIP] fix: reposition children when position changed fix: reposition children when position changed Dec 30, 2021
void _updateRenderBoxModelWithPosition() {
RenderBoxModel _renderBoxModel = renderBoxModel!;
CSSPositionType currentPosition = renderStyle.position;
// Find all the nested positioned absolute children.
Copy link
Contributor

Choose a reason for hiding this comment

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

注释里可以描述下场景,什么场景需要用

Copy link
Contributor

@yuanyan yuanyan Dec 30, 2021

Choose a reason for hiding this comment

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

如果有 renderStyle 树,是不是也可以在 renderStyle 找,这样可以把样式相关都解耦 element

Copy link
Contributor Author

Choose a reason for hiding this comment

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

注释已补充,renderStyle 目前并不是完整的 tree 没有 children,而且这个方法需要返回 element 数组以便后续执行添加到 containing block 的操作,所以目前在 element tree 上找也是合理的。

@andycall andycall merged commit 67d3786 into main Dec 30, 2021
@andycall andycall deleted the fix/reposition-children-when-position-changed branch December 30, 2021 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

改变 element position 定位时 children 未重新定位
4 participants