Jasonmel Online

Enter 過後:瀏覽器渲染頁面

編輯這份文件——整條管線都是從它算出來的

這支腳本不會被執行。第七段的旁白講的是這四個改動,引擎是把它們套到上面的 HTML 再跑一次管線,來驗證哪幾段真的要重做。

步驟 0/96相對模擬成本 0.00 ms / 17.06 ms

總覽:尚未選擇步驟

① HTML 解析成 DOM② CSS 解析成 CSSOM③ Style 合成 render tree④ Layout 算出每個盒子⑤ Paint 產生繪製指令⑥ Composite 分層與合成⑦ 改變之後重跑哪幾段INDEX.HTMLDOM TREECSSOM TREERENDER TREE版面視窗1<!DOCTYPE html>2<title>Rendering</title>3<link rel="stylesheet" href="/style.css">4 5<h1>Pixels</h1>6 7<p>A browser turns your <em>markup and style</em> into pixels, one stage at a time.</p>8 9<div class="card">10 Bare text, in no element of its own.11 <p class="note">Layout runs before paint, and paint before composite.</p>12</div>13 14<p class="shifted">Moved after layout.</p>15<p class="ghost">Laid out, never painted.</p>16<p class="gone">Never laid out.</p>17 18<script defer src="/later.js"></script>19<script src="/app.js"></script>20 #document<!DOCTYPE>html解析器補的head解析器補的title"Rendering"linkbody解析器補的h1"Pixels"""p"A browser turns y…"A browser turns your"em"markup and styl…"markup and style""into pixels, one …"into pixels, one stag…"""div.card"Bare text, in no …"Bare text, in no elem…"p.note"Layout runs bef…"Layout runs before pa…"+15CSSOMdocument.styleSheetsStyleSheetList1 sheetCSSStyleSheet · style.csscssRules · CSSRuleList11/11CSSStyleRule · body0-0-1style · CSSStylePropertiesfont-family:system-uicolor:#1f2937margin-top:14pxmargin-right:14pxmargin-bottom:14pxmargin-left:14pxCSSStyleRule · .card0-1-0style · CSSStylePropertiescolor:#075985background-color:#e0f2feborder-width:2pxborder-color:#38bdf8border-radius:6pxpadding-top:10pxpadding-right:10pxpadding-bottom:10pxpadding-left:10pxwill-change:transformcssRules · CSSRuleList1CSSStyleRule · & > .note0-2-0matches · .card > .notestyle · CSSStyleProperties+44htmlcomputed styledisplay: blockcolor: #0f172afont-size: 16pxbodycomputed styledisplay: blockcolor: #1f2937↑ font-size: 16pxh1computed styledisplay: block↑ color: #1f2937font-size: 24px"Pixels"pcomputed styledisplay: block↑ color: #1f2937↑ font-size: 16px↑ 從 DOM 父元素繼承+32320 × 330 CSS pxPixelsA browser turns your markup andstyle into pixels, one stage at atime.Bare text, in no element of itsown.Layout runs before paint, and paintbefore composite.Moved after layout.

DOM tree、CSSOM tree 與 render tree

HTML 會串流建立 DOM,CSS 同時形成 CSSOM;Style 把目前可用的內容合成概念性的 render tree,Layout 產生盒子,Paint 記錄指令,Raster 填成像素,最後 Composite 組成畫面。瀏覽器能在完整文件到齊前漸進式渲染:要完成的是當下那一幀所需內容的相關階段,不是整頁每個節點。按播放,或點上方階段對照各種結構。

空白鍵播放/暫停,← → 逐步。