简体   繁体   English

在解析/渲染过程中的什么时候,HTML 元素被分配了一个盒子 model?

[英]At what point in the parsing/rendering process do HTML elements get assigned a box model?

Is it during the construction of the CSSOM (where possibly default padding/border/margin is applied to all nodes)?是在 CSSOM 的构建过程中吗(默认填充/边框/边距可能应用于所有节点)?

An element's box is (re)calculated in what is called the " update layout " phase, which is currently specified* as happening (at least) inside the next "update the rendering" step of the event-loop, at sub-step 14:一个元素的盒子在所谓的“更新布局”阶段被(重新)计算,目前指定*发生(至少)在事件循环的下一个“更新渲染”步骤中,在子步骤 14 :

  1. For each fully active Document doc in docs:对于文档中的每个完全活动的文档文档:
  • Recalculate styles and update layout for doc重新计算 styles 并更新文档布局

but it can also be forced synchronously when calling some getters .但也可以在调用一些 getters时同步强制。

* Though this is a quite recent addition to the specs and not all browsers do follow it exactly, for instance I know from experience that to do this layout update Safari will not wait for the next "painting frame", but just some idle time. *虽然这是最近对规范的补充,但并非所有浏览器都完全遵循它,例如我从经验中知道,要执行此布局更新 Safari 不会等待下一个“绘画框架”,而只是等待一些空闲时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM