Skip to content

修正 ForceMobileView 放大字體導致行距重疊並加入 Steve Blank 測資#52

Merged
ChrisTorng merged 5 commits into
mainfrom
codex/add-test-case-for-forcemobileview.user.js
Apr 12, 2026
Merged

修正 ForceMobileView 放大字體導致行距重疊並加入 Steve Blank 測資#52
ChrisTorng merged 5 commits into
mainfrom
codex/add-test-case-for-forcemobileview.user.js

Conversation

@ChrisTorng
Copy link
Copy Markdown
Owner

Motivation

  • 修正放大字體(mobile enforcement)時造成某些頁面行距不足導致文字重疊的回歸問題,並為 https://steveblank.com/2026/04/09/nowhere-is-safe/ 加入自動化回歸測試以重現與驗證該問題。

Description

  • src/ForceMobileView.user.js metadata 版本更新為 2026-04-12_1.7.0 並在字體強制邏輯中改為以像素值設定最小 line-height(px),取代單純使用比例值,避免放大後行盒重疊。
  • 新增祖先元素補強函式 enforceReadableLineHeight,當祖先元素的計算行高過小時會臨時提升並儲存原始 inline 屬性以便還原。
  • 新增用於只存放並還原祖先元素行高的資料屬性(例如 data-tm-force-width-min-line-height-only*)並在停用時完整還原所有變更。
  • 新增捕獲頁面 fixture tests/Force Mobile View/steveblank.com_2026_04_09_nowhere-is-safe.html,並擴充 scripts/test-force-mobile-view.js:載入該 fixture、先模擬舊的「僅放大字體」會重疊的情境,再驗證新邏輯能提升父層行高以避免重疊;同時更新 TestCases.md 並標註為自動化測試。

Testing

  • 執行 node --test scripts/test-force-mobile-view.js,所有子測試通過(6 個子測試皆通過)。
  • 新增的 Steve Blank 捕獲頁面已加入測試夾具並由本地 DOM harness 模擬重疊情境以驗證修正生效,該自動化測試通過。

Codex Task

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tampermonkey-scripts Ready Ready Preview, Comment Apr 12, 2026 3:09pm

…, add Steve Blank fixture and tests

### Motivation

- Prevent text-line overlap caused by font-size-only boosts by enforcing a readable pixel `line-height` on surrounding elements.
- Reduce excessive side whitespace on narrow/mobile screens to keep total side padding/margin minimal.
- Add a captured Steve Blank page and automated tests to reproduce and guard against a line-height overlap regression.

### Description

- Tightened mobile side spacing by changing `MAX_SIDE_SPACING_PX` from `8` to `2` and adjusting the injected CSS padding from `min(2vw, 8px)` to `min(0.6vw, 2px)`.
- Replace ratio-only `line-height` enforcement for boosted small text with a pixel minimum (`minFontSizePx * MIN_LINE_HEIGHT_RATIO`) and add `enforceReadableLineHeight` to raise ancestor `line-height` where needed, tracked with new attributes `data-tm-force-width-min-line-height-only*`.
- Extend cleanup in `clearMinimumFontSize` to restore `line-height` changes made by the new enforcement logic.
- Bump userscript version to `2026-04-12_1.7.1`.
- Add a new captured fixture `tests/Force Mobile View/steveblank.com_2026_04_09_nowhere-is-safe.html` and update `scripts/test-force-mobile-view.js` to load and validate it, update several assertions (expected `line-height` and spacing values), and add a new automated test simulating the legacy font-only boost regression.
- Update `TestCases.md` to document the Steve Blank test and clarify minor test notes for daringfireball entry.

### Testing

- Ran the Force Mobile View test file with `node ./scripts/test-force-mobile-view.js`, which executes the captured-page harness and assertions; all updated tests passed.
- The updated fixture validation test confirmed the new Steve Blank capture contains `CONTENT_CLASS: VALID_ARTICLE_CONTENT` and the new regression test assertions succeeded.
@ChrisTorng ChrisTorng merged commit 91e6220 into main Apr 12, 2026
4 checks passed
@ChrisTorng ChrisTorng deleted the codex/add-test-case-for-forcemobileview.user.js branch April 12, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant