Skip to content

LibWeb; Handle calculated number values for stroke-width and stroke-dashoffset - #10953

Merged
kalenikaliaksandr merged 4 commits into
LadybirdBrowser:masterfrom
Calme1709:calculated-number-stroke-width-crash
Aug 2, 2026
Merged

LibWeb; Handle calculated number values for stroke-width and stroke-dashoffset#10953
kalenikaliaksandr merged 4 commits into
LadybirdBrowser:masterfrom
Calme1709:calculated-number-stroke-width-crash

Conversation

@Calme1709

Copy link
Copy Markdown
Member

Previously we only checked for literal <number> values and fell back to storing calculated number values within a LengthPercentage which subsequently crashed when resolving the value.

We also introduce a VERIFY to ensure calculated values in a LengthPercentage resolve to a length.

Fixes #10909

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cfb38b94-e01e-43e2-a1ff-739327e31917

📥 Commits

Reviewing files that changed from the base of the PR and between e0a652b and 0672f9b.

📒 Files selected for processing (8)
  • Libraries/LibWeb/CSS/ComputedProperties.cpp
  • Libraries/LibWeb/CSS/ComputedProperties.h
  • Libraries/LibWeb/CSS/ComputedValues.cpp
  • Libraries/LibWeb/CSS/PercentageOr.h
  • Tests/LibWeb/Crash/CSS/calculated-number-border-image-outset.html
  • Tests/LibWeb/Crash/CSS/calculated-number-border-image-width.html
  • Tests/LibWeb/Crash/CSS/calculated-number-stroke-dashoffset.html
  • Tests/LibWeb/Crash/CSS/calculated-number-stroke-width.html
🚧 Files skipped from review as they are similar to previous changes (8)
  • Libraries/LibWeb/CSS/ComputedValues.cpp
  • Tests/LibWeb/Crash/CSS/calculated-number-stroke-dashoffset.html
  • Tests/LibWeb/Crash/CSS/calculated-number-border-image-width.html
  • Libraries/LibWeb/CSS/PercentageOr.h
  • Tests/LibWeb/Crash/CSS/calculated-number-border-image-outset.html
  • Tests/LibWeb/Crash/CSS/calculated-number-stroke-width.html
  • Libraries/LibWeb/CSS/ComputedProperties.h
  • Libraries/LibWeb/CSS/ComputedProperties.cpp

📝 Walkthrough

Walkthrough

SVG stroke width and dash offset now use shared computed-property accessors. Numeric calculated values convert to pixel lengths. Length-percentage parsing rejects calculated values that do not resolve to lengths. Border image widths and outsets accept calculated numeric values.

Changes

SVG stroke conversion

Layer / File(s) Summary
Stroke accessors and value validation
Libraries/LibWeb/CSS/ComputedProperties.h, Libraries/LibWeb/CSS/ComputedProperties.cpp, Libraries/LibWeb/CSS/PercentageOr.h
Added stroke_width() and stroke_dashoffset(). Numeric calculated values convert to pixel lengths. LengthPercentage accepts calculated values only when they resolve to lengths.
ComputedValues integration and regression coverage
Libraries/LibWeb/CSS/ComputedValues.cpp, Tests/LibWeb/Crash/CSS/calculated-number-stroke-width.html, Tests/LibWeb/Crash/CSS/calculated-number-stroke-dashoffset.html
Replaced inline stroke conversion with the new accessors. Added crash tests for calculated numeric stroke values.
Border image calculated-value conversion
Libraries/LibWeb/CSS/ComputedProperties.cpp, Tests/LibWeb/Crash/CSS/calculated-number-border-image-width.html, Tests/LibWeb/Crash/CSS/calculated-number-border-image-outset.html
Border image width and outset conversion now handles calculated values that resolve to numbers. Added crash coverage.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The border-image-width and border-image-outset changes are not required by linked issue #10909, which concerns SVG stroke properties. Remove the unrelated border-image changes and tests, or link an issue that requires calculated border-image width and outset support.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The description directly explains the calculated-number crash fix and the added LengthPercentage verification.
Linked Issues check ✅ Passed The changes address issue #10909 by handling calculated SVG stroke-width and stroke-dashoffset values and adding regression tests.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Libraries/LibWeb/CSS/PercentageOr.h`:
- Line 99: Update the LengthPercentage handling near the shown VERIFY and the
ComputedProperties::border_image() path to recognize calculated values that
resolve to numbers before enforcing the length/percentage invariant, routing
them through the existing numeric BorderImageWidthValue branch. Preserve literal
number handling and add a regression test covering border-image-width: calc(1).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e16288c6-ea59-4bcf-a54a-9d9f0d4b367e

📥 Commits

Reviewing files that changed from the base of the PR and between 1dcc606 and 48f179f.

📒 Files selected for processing (6)
  • Libraries/LibWeb/CSS/ComputedProperties.cpp
  • Libraries/LibWeb/CSS/ComputedProperties.h
  • Libraries/LibWeb/CSS/ComputedValues.cpp
  • Libraries/LibWeb/CSS/PercentageOr.h
  • Tests/LibWeb/Crash/CSS/calculated-number-stroke-dashoffset.html
  • Tests/LibWeb/Crash/CSS/calculated-number-stroke-width.html

Comment thread Libraries/LibWeb/CSS/PercentageOr.h

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Tests/LibWeb/Crash/CSS/calculated-number-border-image-width.html`:
- Around line 4-7: Add a valid border-image-source referencing a reusable image,
and set non-zero border widths on the test element so painting enters
paint_border_image() and resolves border-image-width: calc(42) through
resolve_border_image_geometry().
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7081d5de-edb3-4b92-8dec-9f2e16f7bb36

📥 Commits

Reviewing files that changed from the base of the PR and between 48f179f and 0a6f089.

📒 Files selected for processing (2)
  • Libraries/LibWeb/CSS/ComputedProperties.cpp
  • Tests/LibWeb/Crash/CSS/calculated-number-border-image-width.html
🚧 Files skipped from review as they are similar to previous changes (1)
  • Libraries/LibWeb/CSS/ComputedProperties.cpp

Comment thread Tests/LibWeb/Crash/CSS/calculated-number-border-image-width.html
Previously we only checked for literal `<number>` values and fell back
to storing calculated number values within a `LengthPercentage` which
subsequently crashed when resolving the value.

We also introduce a `VERIFY` to ensure calculated values in a
`LengthPercentage` resolve to a length.

Fixes LadybirdBrowser#10909
Previously we only checked for literal `<number>` values and fell back
to storing calculated number values within a `LengthPercentage` which
subsequently crashed when resolving the value.
Previously we only checked for literal `<number>` values and fell back
to storing calculated number values within a `LengthPercentage` which
subsequently crashed when resolving the value.
Previously we only checked for literal `<number>` values and fell back
to resolving calculated number values as a `Length` which crashed
@Calme1709
Calme1709 force-pushed the calculated-number-stroke-width-crash branch from e0a652b to 0672f9b Compare August 1, 2026 00:41
@Calme1709

Copy link
Copy Markdown
Member Author

Changes:

  • Added the equivalent fixes for border-image-width and border-image-outset.
  • Rebased to fix CI build errors.

Comment thread Libraries/LibWeb/CSS/PercentageOr.h
@kalenikaliaksandr
kalenikaliaksandr merged commit 12176d0 into LadybirdBrowser:master Aug 2, 2026
15 checks passed
@Calme1709
Calme1709 deleted the calculated-number-stroke-width-crash branch August 2, 2026 00:21
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.

Crash: Cockpit (server admin web interface) crashes tab; SVG stroke-width percentage resolution

3 participants