Skip to content

feat(rules): mobile/input-zoom reports form fields under 16px that make iOS Safari zoom (#708) - #897

Merged
nc9 merged 8 commits into
mainfrom
feat/708-mobile-input-zoom
Oct 17, 2026
Merged

nc9 merged 8 commits into
mainfrom
feat/708-mobile-input-zoom

Conversation

@nc9

@nc9 nc9 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Closes #708

What

New rule mobile/input-zoom: on an iPhone, focusing a text field, select or textarea under 16px makes Safari zoom the page in. The rule reports those fields, one finding per page, each with its size and where the size came from.

  • Fields checked: select, textarea, and every input that opens a keyboard or picker. Skipped: hidden/checkbox/radio/range/color/file and the button types, plus fields a visitor cannot focus (disabled, disabled fieldset, hidden/inert ancestors, inline display:none, closed <dialog>/<details>, <template>/<noscript>) and, as a precaution, aria-hidden spam traps (Mailchimp's embed).
  • Sizes come from inline style and <style> blocks, applied in cascade order (!important inline, !important rules, inline, plain rules; per-declaration !important; last declaration wins). rem resolves against the root size from the same cascade on <html>.
  • Unstyled fields: WebKit's iOS stylesheet sets font: 11px system-ui on input, textarea and select, and the focus zoom scale is 16 / fontSize (WKWebViewIOS.mm). So a field nothing on the page sizes zooms too, and on a page with no external stylesheet it is reported as 11px (iOS default).
  • Never guessed: a field is counted as not read (info, not warn) when an external stylesheet or CSS nesting means unseen rules may outrank a <style> size or the default, when the deciding rule is inside @media/@supports/@layer or a <style media> block, when matching rules disagree, when the size is relative (em, %, var(), calc(), font: inherit, all), when a font shorthand is outside the narrow grammar the rule parses, when a selector uses a state the engine cannot run (:focus, :hover, :scope, also inside :not()), when a <style> rule hides the field, or past the reading budgets (see the bounded-work section below). Inline sizes are still judged with an external stylesheet present.
  • A zoom-blocking viewport (maximum-scale=1, user-scalable=no) still gets the warning, and the message names the workaround.
  • Solution text recommends 16px fields (Tailwind text-base md:text-sm) and never disabling zoom.

content/hidden-text.ts: only exports parseRules and RawRule for reuse. Reviewing it turned up a pre-existing comment-handling miss in its parseDeclarations, filed as #896 (not changed here).

Bounded work on hostile pages (untrusted-input self-audit)

Every loop over page-controlled input has a hard cap, and no path skips it. The rule never fetches or reads an external stylesheet, and never expands @import; it only notes that one exists.

Input Cap
Fields 2,000 checked for focus, 200 judged, the rest counted as not read; a field nested more than 128 deep is not read
<style> text 400,000 chars, 4,000 rules, 256 blocks; past any of them every field is not read
@media / @supports / @layer nesting read in one linear pass (parseRules depth counter), no recursion
Selectors 256 chars max (a longer one makes the sheet not read); prepared once per page
Inline style 4,096 chars (a field: not read; a wrapper: the field is not read)
font shorthand 1,000 chars
Selector tests one shared budget of 10,000 tests or 250 ms, whichever runs out first. The clock catches what the count cannot: a descendant selector on a deep field, or a :has()
Hiding rules tested once per element (memoised), not once per field and ancestor
Output 20 items, additional past that; attribute values and selectors in an item cut to 80 chars

Regexes on page strings were checked for backtracking: the number patterns (\d*\.?\d+) were quadratic on a long digit run and are now \d+(?:\.\d+)?|\.\d+; the rest are linear or run only on capped strings.

Measured before the caps, the security flag was right: a 1 MB wrapper style or 3,000 hiding rules over a deep wrapper ran past 45 s, a 300 KB selector took 4.5 s, and 500 KB field styles took 5 s. After the caps, the rule's own time (page parse excluded) is 1 to 260 ms on every case. input-zoom-708.test.ts has a hostile-page suite asserting under 1,000 ms and bounded output: 50,000 inputs, a 5 MB stylesheet, 20,000 nested @media, fields 3,000 deep, 3,000 hiding rules, 1,400 rules with 250-char selectors, 3,000 descendant selectors on 120-deep fields, 3,000 :has() selectors over a 20,000-element form, a 100,000-digit size, a 300 KB selector, a 1 MB wrapper style, 500 KB field styles, 20,000 style blocks, a 100,000-token shorthand, and a 1 MB name attribute.

Checks

  • bun test input-zoom, hidden-text, rule-verdict-scope, template-verdict-*, docs-category-table, meta-string-limits, noindex-skip, max-rules-limit, private-target-skip: 974 pass, 0 fail
  • packages/rules typecheck (tsgo): clean
  • canonical golden: rule tally pin 308 -> 309; bun run test:engine: 209 pass / 1 skip / 0 fail
  • oxfmt / oxlint on changed files: clean (two pre-existing oxlint findings in hidden-text.ts untouched)
  • docs: check-links + tangly check --strict: pass
  • Smoke on 10 real pages: HN login and httpbin forms warn at 11px (iOS default); GitHub, Wikipedia, gov.uk, DuckDuckGo, lobste.rs and BBC report their fields as not read; no false warnings. Same results after the caps, 1 to 9 ms per page.

Docs and skills

Docs: new docs/rules/mobile/input-zoom.mdx, nav entry, Mobile index card, Mobile rule count 7 -> 8 in docs/rules/index.mdx and docs/rules/seo/index.mdx, viewport-zoom related link, the rule-count comment in packages/utils/src/constants.ts. CHANGELOG Unreleased entry. The rule is verdictScope: "page" and listed under varyingRules in template-invariance-measured.json.

Agent skill (squirrelscan/skills): no change needed; the skills name no individual rules and their "260+ rules" count stays true.

Private follow-up in the next gitlink bump: regenerate the rule catalog (apps/api: bun run generate:rule-catalog) and bump totalRules in apps/web/src/components/rules.tsx to 309.

@nc9
nc9 marked this pull request as ready for review October 16, 2026 22:45
@claude

claude Bot commented Oct 16, 2026

Copy link
Copy Markdown

Review of mobile/input-zoom. I read the full diff and input-zoom.ts. I did not run the tests.

The design is conservative: it reports a field as not read when it can't tell, instead of guessing. Match budgets cap the work on hostile stylesheets. The docs, changelog and golden-test updates are consistent with each other.

  • (low) packages/rules/src/mobile/input-zoom.ts (field collection loop): once fields.length >= MAX_FIELDS, overCap++ runs before the canFocus(el) check. Past the cap, disabled, hidden or inert fields are counted as "not read". Below the cap they are skipped. A page with more than 200 inputs, some of them unfocusable, reports an inflated notRead and fields total. This could flip a pass to info. Running canFocus before counting overflow would make the two paths consistent.
  • (low) input-zoom.ts (the c === null branch of judgeField): a field that no readable rule sizes is reported as 11px (iOS default) and produces a warning. This is the one place the rule asserts something it did not read. The PR cites WKWebViewIOS.mm and the smoke test on HN and httpbin looks right. Still, the claim depends on WebKit internals and on class-based or inherited sizing being absent. I'd name the assumption in the rule's message or doc text, or add a test pinning it.
  • (nit) packages/audit-engine/tests/streaming-rules-canonical-golden.test.ts: the diff re-indents about 280 lines, apparently from the formatter. That makes it hard to see that the real change is the 308 → 309 pin and one comment line. It's probably unavoidable. A note in the PR description saying so would help reviewers.
  • (nit) input-zoom.ts imports parseRules from ../content/hidden-text, so a mobile rule now depends on a content rule's module. skipComment, skipString and stepBlocks already live in shared/css-tokens. Moving parseRules there later would remove the cross-rule coupling. This is fine as a follow-up, and the issue you filed (content/hidden-text misses display:none when a CSS comment precedes the property #896) already touches that code.
  • (nit) The docs list the exact size keyword conversions (small = 13px and so on). They match the code, but they will drift if the table changes. A one-line comment next to SIZE_KEYWORDS pointing at the docs page would help.

Test coverage: input-zoom-708.test.ts has 350 lines and covers the cascade, the skip lists and the not-read paths. I'd add cases for the over-cap behaviour in the first finding and for a <style media="screen"> block, which the code treats as unconditional.

No critical or high-severity issues found.

@nc9

nc9 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

Review triage at 38f4927:

  • (low) over-cap counting: fixed. Unfocusable fields are now skipped past the cap as below it; focusability is checked on the first 2,000 text fields, the rest are counted as not read unchecked. Test added (205 focusable + 10 disabled -> fields: 205, notRead: 5).
  • (low) the 11px iOS default: kept. This one is read, not guessed: WebKit's iOS stylesheet (Source/WebCore/css/html.css) sets font: 11px system-ui on input, textarea and select (iOS always uses the menulist select), and WKWebViewIOS.mm zooms to 16 / fontSize. It applies only when no <style> rule or inline style sizes the field and the page has no external stylesheet and no CSS nesting, so class-based sizing from an unseen sheet always reads as not read. The assumption is named in the item label (11px (iOS default)), the docs paragraph ("Fields do not take the page's font size...", with the WebKit source in References), the constant's comment, and pinned by the test "an unstyled field on a page with no external CSS gets iOS's own 11px and is reported".
  • (nit) golden re-indent: fixed. That was formatter churn, not needed: the golden test and hidden-text.ts are back to main plus the real edits (tally pin 308 -> 309 with its comment; export on parseRules / RawRule).
  • (nit) parseRules coupling: agreed as a follow-up. Moving it into shared/css-tokens now would collide with open fix(rules): hidden-text applies a style rule with a comment in its selector #684 #874, which edits parseRules; it fits with content/hidden-text misses display:none when a CSS comment precedes the property #896.
  • (nit) size keyword table drift: the docs do not list the conversions (they say "small, medium and so on are converted to px"), so there is nothing to drift.
  • Tests: added the over-cap case and <style media="screen"> / "all" applying like a plain block.

Gates at this sha: input-zoom + hidden-text tests 173 pass; rules typecheck clean; bun run test:engine 211 pass / 1 skip / 0 fail; docs check-links + tangly check --strict pass; oxfmt check + oxlint clean on the new files.

@claude

claude Bot commented Oct 16, 2026

Copy link
Copy Markdown

Reviewed the diff for mobile/input-zoom. I read it but did not run the tests or CI.

Findings

  • (low) docs/rules/seo/index.mdx:39 still says Mobile has "7 rules". docs/rules/index.mdx was updated to 8 in this PR, so the two pages now disagree.
  • (low) packages/utils/src/constants.ts:476 has a comment saying "currently 308 enabled rules". It is now 309. This is only a comment, but it will go stale.
  • (nit) packages/rules/src/mobile/input-zoom.ts, canFocus: readDeclarations is re-parsed for every ancestor's inline style on every field. The scan is capped at 2,000 fields, so this is cheap. You could skip the parse when the style string has no display or visibility.
  • (nit) matchSelector's mentions() fallback treats any selector containing [ or * as possibly matching. That is safe, because it only turns a field into "not read", but a short comment saying so would help the next reader.

What looks good

  • The conservative "not read" design avoids false positives.
  • Budgets cap input size, rule count and selector-match calls.
  • The tests are extensive.
  • The golden rule count is bumped.
  • Exporting parseRules and RawRule from hidden-text is a minimal change.

I found no correctness or security problems.

@nc9

nc9 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

Round 2 triage at 3e462fa:

  • (low) SEO index Mobile count: fixed, docs/rules/seo/index.mdx now says 8 rules.
  • (low) constants.ts comment: fixed, "currently 309 enabled rules".
  • (nit) canFocus re-parse: done, an ancestor's style is parsed only when it mentions display or visibility.
  • (nit) mentions() comment: added: a yes only turns the field into "not read", so [ and * are always a yes.
  • CLI tests failure on 38f4927: the rule declared verdictScope: "template", which the template-invariance measurement does not support (it reads each page's own fields). Now verdictScope: "page", and the rule is listed under varyingRules for both measured corpora in template-invariance-measured.json, as security/token-storage was when it was added after the 2026-09-08 measurement. rule-verdict-scope, template-verdict-page-independence, template-verdict-inputs and the input-zoom tests: 446 pass. bun run test:engine at this sha: 209 pass / 1 skip / 0 fail (two fewer parametrised cases, one per template rule).

@claude

claude Bot commented Oct 16, 2026

Copy link
Copy Markdown

Review of mobile/input-zoom: the rule is conservative by design (it reports a field as 'not read' rather than guessing), it bounds its work (field, style, rule and selector-match caps), and it has a sizeable test file. I found no blocking problems.

  • (low) input-zoom.ts cascade(): when a field has an inline non-!important size and a stylesheet is linked, the inline size is returned as read. An external !important rule could still override it, so this could produce a false warning. This is rare, but it goes against the rule's 'never wrong, only missed' claim. Consider returning unseen-css in that case, or note the limit in the docs.
  • (low) input-zoom.ts judgeField(): a field that no rule sizes, on a page with no external CSS, is reported at the 11px iOS default. This depends on WebKit's UA stylesheet. A test that pins the behaviour (it may already exist) and a doc note would help if WebKit changes.
  • (nit) mentions() uses substring matching (lower.includes(tagName), selector.includes('.'+cls)). It can over-match, for example .form-input-lg against class form-input. The effect is only a larger 'not read' count, so this is harmless.
  • (nit) parseRules is now exported from content/hidden-text.ts, which couples two rules. It would be cleaner in shared/, next to css-tokens.
  • (nit) CI checks were still pending when I reviewed, so I could not confirm that tests, lint and the docs build pass. I did not run the tests locally.

@nc9

nc9 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

Round 3 triage at 8bd44d1:

  • (low) inline size next to an external sheet: kept, and now named in the docs as the rule's one accepted limit: an unseen rule can beat an inline size only with !important on a field's font size, which is rare. Treating every inline size as not read whenever a stylesheet is linked would leave the rule reading nothing on almost every real site.
  • (low) the 11px iOS default: already pinned and documented: test "an unstyled field on a page with no external CSS gets iOS's own 11px and is reported", the docs paragraph "Fields do not take the page's font size...", and the WebKit html.css link in References.
  • (nit) mentions() substring over-match: intended; it only grows the not-read count (comment added in the previous round).
  • (nit) parseRules in shared/: follow-up, after open fix(rules): hidden-text applies a style rule with a comment in its selector #684 #874 (which edits parseRules) lands; fits with content/hidden-text misses display:none when a CSS comment precedes the property #896.
  • CI on 3e462fa was green, CLI tests included. This push is a docs-only wording change; docs check-links + tangly check --strict pass.

@claude

claude Bot commented Oct 16, 2026

Copy link
Copy Markdown

Review of #897 (mobile/input-zoom)

I read the diff of input-zoom.ts and the hidden-text.ts export change. I did not run the tests or the smoke pages. The rule is conservative by design: it reports "not read" instead of guessing, and the budgets and caps look sound. I found nothing that should block the merge.

  • (low) input-zoom.ts viewportBlocksZoom and the warning message: the text says maximum-scale=1 or user-scalable=no "hides the zoom on iOS". Since iOS 10, Safari ignores user-scalable=no. maximum-scale=1 has historically suppressed the focus zoom. Consider narrowing the wording to maximum-scale. It is only message text.
  • (low) readStyleRules: a <style media="print"> block is treated as conditional, so a matching rule there makes the field "not read". That is safe, but a print-only sheet cannot affect phone zoom, so ignoring it would cut some false "not read" results.
  • (low) <style> blocks inside <noscript> or <template> are read as live rules. The effect is conservative, but excluding them would be more accurate.
  • (nit) mentions() does a substring match on the tag name, so input also matches .input-group. It only widens to "unsupported", so it is harmless, but a comment saying so would help.
  • (nit) The IOS_DEFAULT_FIELD_PX = 11 assumption is the main behavioural bet, because every unstyled field on a page with no external CSS becomes a warning. A link to the WebKit source in the code comment or docs would help future maintainers re-verify it.
  • (nit) Tests: consider regression cases for the MAX_SCANNED_FIELDS overflow path and the truncated budget path, if they are not already covered.

Overall this is well documented and the changes outside the rule are small.

@nc9

nc9 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

Round 4 triage at 4d67860 (final round from my side unless something blocking comes up):

  • (low) user-scalable=no wording: kept. iOS 10+ ignores the viewport limits for pinch zoom only. The focus zoom reads them: WKContentViewInteraction.mm calls _zoomToFocusRect with maximumScale: maximumScaleFactorIgnoringAlwaysScalable and allowScaling: allowsUserScalingIgnoringAlwaysScalable, so both maximum-scale=1 and user-scalable=no suppress it, which is what the message says.
  • (low) <style media="print">: fixed, skipped rather than treated as conditional.
  • (low) <style> inside <noscript> / <template>: fixed, skipped. Docs updated.
  • (nit) mentions() comment: already there (added in round 2).
  • (nit) WebKit link: added next to IOS_DEFAULT_FIELD_PX; the docs References already carried it.
  • (nit) tests: added the 2,000-field scan cap case and the print/noscript/template cases; the truncated budget path is the existing "a hostile stylesheet stays within budget" test (5,000 rules, past the 4,000-rule budget).

Gates at this sha: input-zoom + verdict-scope + template-verdict tests 448 pass; rules typecheck clean; bun run test:engine 209 pass / 1 skip / 0 fail; docs check-links + tangly check --strict pass; oxfmt check + oxlint clean.

@claude

claude Bot commented Oct 16, 2026

Copy link
Copy Markdown

Review of mobile/input-zoom. I read packages/rules/src/mobile/input-zoom.ts closely. I only skimmed the hidden-text.ts change, the tests, the docs and the golden/fixture updates, and I did not run the suite.

The design is conservative: anything it can't resolve becomes "not read" instead of a guess, and every scan has a budget. I found no merge-blocking problems.

  • (medium) input-zoom.ts judgeField: a field that nothing on the page sizes is reported as 11px (iOS default) when the page has no external CSS. This rests on one reading of WebKit's UA stylesheet. If that default is wrong for some iOS versions, every unstyled form on a CSS-free page becomes a false warning. I'd suggest the following:
    • Keep the source link in the docs.
    • Consider reporting this case at info severity, or phrasing it as "unstyled, iOS default", until it has been checked on a device.
  • (medium) input-zoom.ts NO_KEYBOARD_TYPES / isTextEntry: the denylist treats date, time, datetime-local, month and week as zooming. Those open a native picker, and on current iOS I believe they don't zoom the same way. <select> also opens a wheel picker. The PR description says "keyboard or picker", but I'm not sure pickers zoom. Please verify and add these types to the skip list if they don't.
  • (low) input-zoom.ts cascade: an inline non-!important size is returned even when unseenCss is true. An external !important rule could override it, so the "inline sizes are still judged" behaviour can produce a false warning in that case. It is rare, and a one-line comment would cover it.
  • (low) input-zoom.ts imports parseRules from ../content/hidden-text, a different rule's module. If parseRules is a general CSS helper, move it to shared/css-tokens so rules don't depend on each other.
  • (low) input-zoom.ts matchSelector: the :not(...) handling only covers one level of nesting ([^()]*). Deeper nesting falls into the "unsupported" branch, which is safe. Please confirm a test covers that path.
  • (nit) input-zoom.ts: splitSelectorList, fontShorthandSize and sizeToPx are exported, presumably for tests. A /** @internal */ tag would make that clear.
  • (nit) The ctx.parsed.document?.querySelector('meta[name="viewport"]') lookup is repeated per page. This is negligible.
  • (nit) canFocus calls readDeclarations on each ancestor's inline style. The /display|visibility/i pre-check keeps this cheap, and the 2,000-field cap bounds the cost.

Security and performance: I saw no ReDoS risk. The FONT_SHORTHAND regex is anchored, and MAX_STYLE_CHARS, MAX_STYLE_RULES and MAX_MATCH_CALLS bound hostile input.

Test coverage looks broad (input-zoom-708.test.ts, about 400 lines). I'd like to see a test that pins down the 11px (iOS default) behaviour and one for date/time input types, once those decisions are made.

@nc9
nc9 force-pushed the feat/708-mobile-input-zoom branch from 4d67860 to 9a7bab1 Compare October 17, 2026 00:30
@claude

claude Bot commented Oct 17, 2026

Copy link
Copy Markdown

Reviewed mobile/input-zoom (rule, docs, tests, golden bump). The design is careful: it never guesses, every loop over page input is capped, and the docs match the code. Findings below, none blocking.

  • (medium) packages/rules/src/mobile/input-zoom.ts (spend, MAX_MATCH_MS = 250): the budget has a wall-clock deadline, so the verdict depends on machine load. The same page can come back as warn on a quiet machine and as info (not read) on a loaded CI runner. That is safe for the never-wrong, only-missed goal, but results are not reproducible, which sits oddly with verdictScope: "page" and the template-invariance fixtures. Consider gating normal pages on the call count only and keeping the clock as a last-resort backstop, or document the variance.
  • (low) cascade(): a non-!important inline font-size is returned as the winner even when unseenCss is true. An external !important rule can beat it, so this can give a false warn or pass. Rare, but it breaks the never-guess rule.
  • (low) el.matches is only bounded between calls. A single pathological :has() or deep descendant selector can overrun the 250 ms budget, since the clock is checked only before each test. The other caps bound this in practice; a comment saying so would help.
  • (low) packages/rules/tests/input-zoom-708.test.ts: the wall-clock assertions (toBeLessThan(5000) and toBeLessThan(1000)) can flake on slow shared runners. Consider asserting on the capped outputs (item count, notRead) instead.
  • (nit) readDeclarations and splitSelectorList overlap with scanning logic in content/hidden-text.ts. Keep them in sync when content/hidden-text misses display:none when a CSS comment precedes the property #896 is fixed.
  • (nit) judgeField takes work and then aliases it as budget; passing it once would be tidier.

Test coverage is good: 29 cases, including hostile-input and cap tests. I could not run the suite here, so I am relying on the PR's reported results.

@nc9

nc9 commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

Triage of the review at 9a7bab1 (no further push planned for these; none is blocking):

  • (medium) the 250 ms clock makes results machine-dependent: by design, as a backstop only. The call count (10,000) is the gate on ordinary pages; the clock trips only on a page whose selector tests are already pathological (deep descendant chains, :has() over a large form). On the 10 real pages smoked, the whole rule takes 1 to 9 ms, so the clock sits 25x+ above them. When it does trip, fields become "not read" (info), never a different warn. The runner's own per-rule time budget already makes every rule time-bounded the same way. The docs list it with the other reading budgets.
  • (low) inline size next to an external !important: the documented accepted limit (see the docs bullet and the round-3 reply above).
  • (low) a single matches() can overrun the clock: one test is bounded by the other caps: a selector of at most 256 chars on an element at most 128 deep. A :has() scans the form's subtree, which is bounded by the page. The hostile :has() case over a 20,000-element form finishes in about 260 ms total.
  • (low) wall-clock test assertions: the bounds are loose on purpose (1,000 ms against a 250 ms deadline; 5,000 ms on the older case), and each case also asserts the capped outputs (notRead, fields, item count), so a slow runner fails only if the caps stop working.
  • (nit) readDeclarations / splitSelectorList vs hidden-text: noted on content/hidden-text misses display:none when a CSS comment precedes the property #896.
  • (nit) work / budget alias in judgeField: cosmetic, left as is.

nc9 added 7 commits October 17, 2026 12:06
…ke iOS Safari zoom (#708)

New page rule. Reads field sizes from inline styles and <style> blocks in cascade order; an unstyled field on a page with no external CSS gets iOS's own 11px. A size unseen rules may outrank, or that comes from a media query, a relative unit, an unrunnable selector or a hiding rule, is counted as not read, never guessed. A zoom-blocking viewport still gets the warning and the message names the workaround. Docs page, nav, counts, CHANGELOG; canonical golden tally 308 -> 309.

Signed-off-by: Nik Cubrilovic <[email protected]>
…p formatter churn (#708)

Past 200 fields, unfocusable ones are skipped as below the cap (scan capped at 2,000). Restores hidden-text.ts and the canonical golden test to main plus the intended export and tally edits. Tests for the cap and <style media=screen|all>.

Signed-off-by: Nik Cubrilovic <[email protected]>
…unt comment, cheaper focus walk (#708)

Signed-off-by: Nik Cubrilovic <[email protected]>
…te (#708)

It reads each page's own fields and style blocks, so pages of one template can differ. Listed as varying in the template-invariance measurement for both corpora, as security/token-storage was, since the measured crawls predate the rule.

Signed-off-by: Nik Cubrilovic <[email protected]>
… next to an external sheet (#708)

Signed-off-by: Nik Cubrilovic <[email protected]>
#708)

None of them styles the live screen. Tests for that and for the 2,000-field scan cap; WebKit source linked next to the 11px default.

Signed-off-by: Nik Cubrilovic <[email protected]>
Field depth 128, selector length 256, inline style 4,096 chars, 256 style blocks, a font shorthand 1,000 chars, and a shared budget of 10,000 selector tests or 250 ms. Selectors are prepared once per page; a hiding rule is tested once per element, not per field and ancestor. Item text is cut to 80 chars. Number patterns no longer backtrack quadratically. Hostile-page tests: 50k inputs, a 5 MB sheet, 20k nested @media, 3,000-deep fields, deep descendant and :has() selectors, a 300 KB selector, 1 MB styles and attributes, 20k style blocks, a 100k-digit size.

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the feat/708-mobile-input-zoom branch from 9a7bab1 to 775491b Compare October 17, 2026 01:06
@claude

claude Bot commented Oct 17, 2026

Copy link
Copy Markdown

Review of mobile/input-zoom (#708)

I read the rule implementation in input-zoom.ts (lines 1–440 of 803). I did not read the rest of the file, the tests or the docs, and I did not run anything. CI was still pending when I looked.

Findings

  • (low) input-zoom.ts:65: MAX_MATCH_MS = 250 is a wall-clock budget (performance.now()), so the same page can give different results on a slow or loaded CI machine. Fields past the deadline fall into budget (not read), which is safe. It does make output non-deterministic near the limit, so confirm the tests and golden fixtures never get close to it.
  • (nit) input-zoom.ts:353: the :not() widening regex [^()]* only handles one level of nesting. Deeper cases fall through to the unrunnable flag, which is the safe direction. A short comment saying so would help.
  • (nit) input-zoom.ts:159: splitSelectorList, fontShorthandSize and sizeToPx are exported, and parseRules is imported from content/hidden-text. That couples this rule to another rule's module. Consider moving it to shared/, next to css-tokens.

Overall

Nothing blocking in the part I read. The design is conservative: anything it cannot read statically becomes info (not read) instead of a warning, and the work is bounded by limits on characters, rules, blocks, depth and time. Check that the new tests cover these cases:

  • budget exhaustion
  • !important ordering
  • font shorthand
  • rem against the root size

@claude

claude Bot commented Oct 17, 2026

Copy link
Copy Markdown

Reviewed mobile/input-zoom (rule, hidden-text exports, docs, tests). The design is careful: it only judges sizes it can read, every limit has a cap, and the not-read path is conservative. I found no blocking problems. CI was still pending when I looked, so I haven't seen test results.

  • (low) packages/rules/src/mobile/input-zoom.ts:64-65,385 — MAX_MATCH_MS uses performance.now(), so the verdict depends on machine speed and load. The same page can report a field as budget (not read) on a slow runner and as 11px (iOS default) on a fast one, which cuts against the golden and template-invariance fixtures. The call-count cap alone is deterministic; consider keeping the clock only as a backstop and documenting it as best-effort.
  • (low) input-zoom.ts:553 — an inline plain font-size is returned even when unseenCss is true. An external !important rule could outrank it, giving a false positive. The PR says this is intentional, but it contradicts the header comment's "never wrong ones". Soften the comment or add a test documenting the trade-off.
  • (low) input-zoom.ts:652 — unstyled fields are reported as 11px (iOS default) whenever there is no external CSS. That matches WebKit's UA stylesheet, but it turns many plain pages into warnings, so make sure the docs say so clearly.
  • (nit) input-zoom.ts:506 — the loop variable text shadows the outer const text at line 494. Rename it.
  • (nit) input-zoom.ts:629-636 — judgeField aliases work as const budget = work. Pass work through directly.
  • (nit) mentions() (:335) treats any selector with [ or * as a possible match when the engine throws. A short comment on which selectors the engine fails on would help.
  • (nit) Tests are broad. Consider adding a case for an external !important plus an inline size, and one with the time budget forced to 0.

@nc9
nc9 merged commit 6acc5cf into main Oct 17, 2026
15 checks passed
@nc9
nc9 deleted the feat/708-mobile-input-zoom branch October 17, 2026 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New rule: form fields under 16px that make iOS Safari zoom on focus

1 participant