Files
codex-bot 2b3b3a1ae4
Verify and deploy Tabularium / verify-and-deploy (push) Successful in 5m47s
Expand document collections with Pretext tutorial and simplify library navigation
2026-10-28 13:42:51 +08:00

2.8 KiB
Raw Permalink Blame History

第十一章:按什么顺序读源码

不要从庞大的规则数据开始。先建立主流程,再读会影响这个流程的细节。

顺序 文件与函数 阅读时要回答的问题
1 layout.ts:prepareInternal、prepare、layout 两个阶段分别接收什么、返回什么?
2 line-break.ts:PreparedLineBreakData 布局真正需要哪些提前准备的数据?
3 同文件:countPreparedLines 普通文本怎样被一个循环计数?
4 analysis.ts:analyzeText 空白、语言与引擎怎样影响分段?
5 prepare.ts:measureAnalysis 宽度、适配数据与快路径标志在哪里建立?
6 measurement.ts:getFontMeasurement、getSegmentMetrics、getContext 命中缓存时到底跳过哪些浏览器工作?
7 同文件:getSegmentFit、measureFitAdvances 一个放不下的词怎样预先准备拆分信息?
8 line-text.ts 与 layoutWithLines 哪些成本只在要文字时出现?
9 stepPreparedSimpleLineGeometry、walkPreparedComplexLines 按行输出和复杂规则怎样衔接?
10 line-breaks.ts、gecko-line-breaks.ts、graphemes.ts 扫描器怎样使用表和状态?
11 rich-inline.ts item 与整段文本的映射怎样建立?
12 RESEARCH.md 的 Keeping Work Bounded、Evaluation Traps 与 Decisions Log 哪些看似更简单的实现被测过,又为何没保留?

做一个小练习:对 hello world 写下你认为需要的 prepared 数据,然后依次改变宽度、字体和 whiteSpace,判断哪些数据能保留。能解释这些变化,就已经掌握主设计,不需要先记住所有 Unicode 规则。