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: margin auto resolve rule #1331

Merged
merged 12 commits into from
Apr 18, 2022
Merged

fix: margin auto resolve rule #1331

merged 12 commits into from
Apr 18, 2022

Conversation

temper357
Copy link
Contributor

@temper357 temper357 commented Apr 14, 2022

Closes #1283
Closes #1284

  • 按照 W3C spec 的规则 https://www.w3.org/TR/css-position-3/#abs-non-replaced-width 重构 position element 的定位逻辑 。
  • 修复 margin auto 在 positioned element 定位中的解析规则与浏览器不一致。
    • 如果 margin-left 为 auto,margin-right 不为 auto 时,margin-left 的值需要根据等式计算 left + margin-left + width + margin-right + right = width of containing block。(纵向的 margin 逻辑一样)
    • 对于横轴与纵轴方向的 margin 均为 auto 且根据等式计算出 margin auto 的剩余空间为负值的 case 下,横轴与纵轴的逻辑并不一致,对于纵轴来说会对 margin-top 和 margin-bottom 对半划分剩余的负值 space,对于横轴来说 margin-left 设为 0,margin-right 设为剩余的负值 space。
  • 修复 positioned element 相对 overflow auto/scroll 容器定位不对的问题,由于双层 repaintBoundary 的引入,positioned element 的定位是相对于外层的 renderBox 定位,而在 renderBox 层的 offset 又是相对于内层的 scrollingContentBox,因此在定位计算完需要减去 scrollingContentBox 与外层 renderBox 的 offset 差(包含 border 与 padding 的值)。

@temper357 temper357 changed the title [WIP] fix: margin auto resolve rule fix: margin auto resolve rule Apr 15, 2022
@@ -1,6 +1,7 @@
/*auto generated*/
describe('clip-004', () => {
it('ref', async () => {
// @TODO: disable for opacity render delay.
xit('ref', async () => {
Copy link
Member

Choose a reason for hiding this comment

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

为啥这个关了

Copy link
Contributor Author

Choose a reason for hiding this comment

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

opacity 渲染有延迟,CI 经常过不了 #459

Copy link
Member

Choose a reason for hiding this comment

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

我改成 0.5 之后貌似好很多了, 当然 BUG 还是存在的

@wssgcg1213 wssgcg1213 merged commit 87121c6 into main Apr 18, 2022
@wssgcg1213 wssgcg1213 deleted the fix/margin-auto branch April 18, 2022 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants