refactor: 元素分類單一入口 finder.category + ResizeObserver 派發序不變量確認

承階段二之兩件收尾:確認 lineedge 雙 ResizeObserver 之派發序(審計唯一未闭環項),並把散落
各遍歷原語之元素分類優先序收斂為單一 finder.category。

ResizeObserver 派發序——**確認為非缺陷**(Chrome headless 實測):resize 時回調按 observer
**創建順序**派發(ResizeObserver 規範遍歷 observers 之插入序,非 observe 序;實測 seq=12——
反向 observe 仍按創建序)。lineEdgePass(order 90)之 observer 先於 gapTrimPass(order 92)建、
故每次 resize 皆先派發,gapTrim 之行末去隙判定恆基於 lineEdge **已套用**之半形版面(非陳舊態)。
以註解鎖為不變量(勿調換兩 pass 之 order/創建序),不需改碼。

元素分類單一入口:新增 `Finder.category(el): InlineCategory`——一元素恰屬 avoid/pill/isolate/
block/transparent/opaque 之一,優先序 `avoid > pill > isolate > block > transparent > opaque`
集中一處(原散落 collectRuns/jiyaAdjacency/canSplit/isTransparent 各自短路、易漂移)。
・isTransparent = `category === "transparent"`;collectRuns/jiyaAdjacency 改 `switch(category)`;
  canSplit = `SPLITTABLE ∩ transparent`(結構切分為獨立層、白名單更窄)。
・行為等價(121 全綠);多命中優先序(data-jz-skip pill→avoid、pill+isolate→pill、未知行內
  →opaque 邊界)由既有行為測試覆蓋。
・README 三分類要點+ARCHITECTURE §4.1 補優先序與 category 說明。
This commit is contained in:
2026-07-07 21:45:06 +08:00
parent 3e57c2c2cf
commit 4f84d31785
9 changed files with 271 additions and 143 deletions
+5 -4
View File
@@ -38,14 +38,15 @@ interface Point
offset: number;
}
/** 元素是否可克隆切分(純樣式行內標籤、無 id、非 pill/isolateavoid 邊界)。 */
/** 元素是否可克隆切分 SPLITTABLE 白名單(結構切分安全,排除 <a>ABBRRUBY/帶 id 等)
* ∩ transparent(非 avoidpillisolateblock 邊界)。SPLITTABLE ⊂ styleInlines,故命中白名單
* 且 category 為 transparent 者即可切;為邊界者(含消費端自 styleInlines 移出之標籤)不可切、
* 退化整綁。結構切分為獨立層、白名單較邏輯透明更窄(見 finder.category)。 */
function canSplit(el: Element, finder: Finder): boolean
{
return SPLITTABLE.has(el.nodeName)
&& !el.hasAttribute("id")
&& !finder.pillMatches(el)
&& !finder.isolateMatches(el)
&& !finder.avoidsSelf(el);
&& finder.category(el) === "transparent";
}
/** el 內**首**個非空文本節點(僅下探可切標籤;遇非可切元素回 null=放棄切分)。 */