[SVG][Media Fragments] Parse spatial media fragments in SVGImage [chromium/src : main]

1 view
Skip to first unread message

Divyansh Mangal (Gerrit)

unread,
Mar 18, 2026, 12:17:08 PMMar 18
to Chromium LUCI CQ, Menard, Alexis, chromium...@chromium.org, Dirk Schulze, Fredrik Söderquist, Olga Gerchikov, Stephen Chenney, blink-revie...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, feature-me...@chromium.org, fmalit...@chromium.org, kouhe...@chromium.org, pdr+svgw...@chromium.org
Attention needed from Divyansh Mangal

Message from Divyansh Mangal

Set Ready For Review

Open in Gerrit

Related details

Attention is currently required from:
  • Divyansh Mangal
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I906358afc719255004fb51f957458152aca1422b
Gerrit-Change-Number: 7675457
Gerrit-PatchSet: 3
Gerrit-Owner: Divyansh Mangal <dma...@microsoft.com>
Gerrit-Reviewer: Divyansh Mangal <dma...@microsoft.com>
Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
Gerrit-CC: Fredrik Söderquist <f...@opera.com>
Gerrit-CC: Menard, Alexis <alexis...@intel.com>
Gerrit-CC: Olga Gerchikov <gerc...@microsoft.com>
Gerrit-CC: Stephen Chenney <sche...@chromium.org>
Gerrit-Attention: Divyansh Mangal <dma...@microsoft.com>
Gerrit-Comment-Date: Wed, 18 Mar 2026 16:16:34 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Divyansh Mangal (Gerrit)

unread,
Apr 1, 2026, 1:37:43 AM (12 days ago) Apr 1
to AyeAye, Virali Purbey, Vinay Singh, Ragvesh Sharma, Dileep Maurya, Gaurav Kumar, Sejal Anand, Chromium LUCI CQ, Menard, Alexis, chromium...@chromium.org, Dirk Schulze, Fredrik Söderquist, Olga Gerchikov, Stephen Chenney, blink-rev...@chromium.org, kinuko...@chromium.org, jmedle...@chromium.org, blink-revie...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, feature-me...@chromium.org, fmalit...@chromium.org, kouhe...@chromium.org, pdr+svgw...@chromium.org
Attention needed from Divyansh Mangal, Vinay Singh and Virali Purbey

Message from Divyansh Mangal

Set Ready For Review

Open in Gerrit

Related details

Attention is currently required from:
  • Divyansh Mangal
  • Vinay Singh
  • Virali Purbey
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I906358afc719255004fb51f957458152aca1422b
Gerrit-Change-Number: 7675457
Gerrit-PatchSet: 7
Gerrit-Owner: Divyansh Mangal <dma...@microsoft.com>
Gerrit-Reviewer: Divyansh Mangal <dma...@microsoft.com>
Gerrit-Reviewer: Vinay Singh <vinay...@microsoft.com>
Gerrit-Reviewer: Virali Purbey <virali...@microsoft.com>
Gerrit-CC: Dileep Maurya <dileep...@microsoft.com>
Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
Gerrit-CC: Fredrik Söderquist <f...@opera.com>
Gerrit-CC: Gaurav Kumar <gaur...@microsoft.com>
Gerrit-CC: Menard, Alexis <alexis...@intel.com>
Gerrit-CC: Olga Gerchikov <gerc...@microsoft.com>
Gerrit-CC: Ragvesh Sharma <rags...@microsoft.com>
Gerrit-CC: Sejal Anand <sejal...@microsoft.com>
Gerrit-CC: Stephen Chenney <sche...@chromium.org>
Gerrit-Attention: Vinay Singh <vinay...@microsoft.com>
Gerrit-Attention: Virali Purbey <virali...@microsoft.com>
Gerrit-Attention: Divyansh Mangal <dma...@microsoft.com>
Gerrit-Comment-Date: Wed, 01 Apr 2026 05:37:12 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Vinay Singh (Gerrit)

unread,
Apr 1, 2026, 4:25:14 PM (12 days ago) Apr 1
to Divyansh Mangal, AyeAye, Virali Purbey, Ragvesh Sharma, Dileep Maurya, Gaurav Kumar, Sejal Anand, Chromium LUCI CQ, Menard, Alexis, chromium...@chromium.org, Dirk Schulze, Fredrik Söderquist, Olga Gerchikov, Stephen Chenney, blink-rev...@chromium.org, kinuko...@chromium.org, jmedle...@chromium.org, blink-revie...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, feature-me...@chromium.org, fmalit...@chromium.org, kouhe...@chromium.org, pdr+svgw...@chromium.org
Attention needed from Divyansh Mangal and Virali Purbey

Vinay Singh added 7 comments

File third_party/blink/renderer/core/html/media/media_fragment_uri_parser.h
Line 86, Patchset 7 (Latest): bool is_valid_ = true;
Vinay Singh . unresolved

Why would `MediaFragmentURIParser` have a field `is_valid_`?
It is sort of giving an impression as if the parser can be valid or invalid.

`is_url_valid_` probably might be a better choice.

Line 50, Patchset 7 (Latest): gfx::Rect GetRect() const { return rect; }
Vinay Singh . unresolved

`rect` is public already. Either make it private or remove this function and access directly.

File third_party/blink/renderer/core/html/media/media_fragment_uri_parser_test.cc
Line 219, Patchset 7 (Latest):TEST(MediaFragmentURIParserTest, FragmentConstructorParsesTime) {
MediaFragmentURIParser parser(StringView("t=5,10"));
EXPECT_DOUBLE_EQ(parser.StartTime(), 5.0);
EXPECT_DOUBLE_EQ(parser.EndTime(), 10.0);
}
Vinay Singh . unresolved
```suggestion
TEST(MediaFragmentURIParserTest, FragmentConstructorParsesTime) {
MediaFragmentURIParser parser(StringView("t=5,10"));
EXPECT_DOUBLE_EQ(parser.StartTime(), 5.0);
EXPECT_DOUBLE_EQ(parser.EndTime(), 10.0);
}
TEST(MediaFragmentURIParserTest, FragmentConstructorParsesSpatial) {
MediaFragmentURIParser parser(StringView("xywh=10,20,30,40"));
SpatialClip clip = parser.SpatialFragment();
EXPECT_TRUE(clip.IsValid());
EXPECT_EQ(clip.rect, gfx::Rect(10, 20, 30, 40));
EXPECT_EQ(clip.unit, SpatialClip::Unit::kPixel);
}
```

We are not testing the primary functionality of this CL. This additional test should be helpful.

File third_party/blink/renderer/core/svg/graphics/svg_image.cc
Line 205, Patchset 7 (Latest): if (RuntimeEnabledFeatures::SvgSupportMediaFragmentsEnabled()) {
Vinay Singh . unresolved

``&& fragment.Contains("xywh")`` or something similar??

I guess this will make for an early return sparing initialization of MediaFragmentURIParser for all the non-`xywh` cases which I'm assuming must be in majority.

Line 215, Patchset 7 (Latest): gfx::SizeF svg_size(SizeWithConfig(SizeConfig()));
Vinay Singh . unresolved

Consider `SizeWithConfigAsFloat`

SizeWithConfig truncates the fraction as it returns back a RoundedSize which can be a bit premature at this point and may result into pixel errors.

File third_party/blink/web_tests/external/wpt/svg/linking/reftests/media-fragment-spatial-overflow-clamped.html
Line 13, Patchset 7 (Latest): background-image: url("reference/green-100x100.svg#xywh=0,0,200,200");
Vinay Singh . unresolved

Same here.

Wouldn't this produce the same 100x100 green image anyway regardless of the fragment?
Please correct me if I'm wrong.

File third_party/blink/web_tests/external/wpt/svg/linking/reftests/media-fragment-spatial-percent-full.html
Line 11, Patchset 7 (Latest): background-image: url("reference/green-100x100.svg#xywh=percent:0,0,100,100");
Vinay Singh . unresolved

Wouldn't this produce the same 100x100 green image regardless of the fragment?
Please correct me if I'm wrong.

Open in Gerrit

Related details

Attention is currently required from:
  • Divyansh Mangal
  • Virali Purbey
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Gerrit-Attention: Virali Purbey <virali...@microsoft.com>
    Gerrit-Attention: Divyansh Mangal <dma...@microsoft.com>
    Gerrit-Comment-Date: Wed, 01 Apr 2026 20:24:34 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Divyansh Mangal (Gerrit)

    unread,
    Apr 5, 2026, 5:57:37 AM (8 days ago) Apr 5
    to AyeAye, Virali Purbey, Vinay Singh, Ragvesh Sharma, Dileep Maurya, Gaurav Kumar, Sejal Anand, Chromium LUCI CQ, Menard, Alexis, chromium...@chromium.org, Dirk Schulze, Fredrik Söderquist, Olga Gerchikov, Stephen Chenney, blink-rev...@chromium.org, kinuko...@chromium.org, jmedle...@chromium.org, blink-revie...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, feature-me...@chromium.org, fmalit...@chromium.org, kouhe...@chromium.org, pdr+svgw...@chromium.org
    Attention needed from Vinay Singh and Virali Purbey

    Divyansh Mangal added 4 comments

    File third_party/blink/renderer/core/html/media/media_fragment_uri_parser.h
    Line 86, Patchset 7: bool is_valid_ = true;
    Vinay Singh . resolved

    Why would `MediaFragmentURIParser` have a field `is_valid_`?
    It is sort of giving an impression as if the parser can be valid or invalid.

    `is_url_valid_` probably might be a better choice.

    Divyansh Mangal

    Done

    Line 50, Patchset 7: gfx::Rect GetRect() const { return rect; }
    Vinay Singh . resolved

    `rect` is public already. Either make it private or remove this function and access directly.

    Divyansh Mangal

    Removed the function

    File third_party/blink/renderer/core/html/media/media_fragment_uri_parser_test.cc
    Line 219, Patchset 7:TEST(MediaFragmentURIParserTest, FragmentConstructorParsesTime) {

    MediaFragmentURIParser parser(StringView("t=5,10"));
    EXPECT_DOUBLE_EQ(parser.StartTime(), 5.0);
    EXPECT_DOUBLE_EQ(parser.EndTime(), 10.0);
    }
    Vinay Singh . resolved
    ```suggestion
    TEST(MediaFragmentURIParserTest, FragmentConstructorParsesTime) {
    MediaFragmentURIParser parser(StringView("t=5,10"));
    EXPECT_DOUBLE_EQ(parser.StartTime(), 5.0);
    EXPECT_DOUBLE_EQ(parser.EndTime(), 10.0);
    }
    TEST(MediaFragmentURIParserTest, FragmentConstructorParsesSpatial) {
    MediaFragmentURIParser parser(StringView("xywh=10,20,30,40"));
    SpatialClip clip = parser.SpatialFragment();
    EXPECT_TRUE(clip.IsValid());
    EXPECT_EQ(clip.rect, gfx::Rect(10, 20, 30, 40));
    EXPECT_EQ(clip.unit, SpatialClip::Unit::kPixel);
    }
    ```

    We are not testing the primary functionality of this CL. This additional test should be helpful.

    Divyansh Mangal

    Done

    File third_party/blink/renderer/core/svg/graphics/svg_image.cc
    Line 215, Patchset 7: gfx::SizeF svg_size(SizeWithConfig(SizeConfig()));
    Vinay Singh . resolved

    Consider `SizeWithConfigAsFloat`

    SizeWithConfig truncates the fraction as it returns back a RoundedSize which can be a bit premature at this point and may result into pixel errors.

    Divyansh Mangal

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Vinay Singh
    • Virali Purbey
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I906358afc719255004fb51f957458152aca1422b
    Gerrit-Change-Number: 7675457
    Gerrit-PatchSet: 8
    Gerrit-Owner: Divyansh Mangal <dma...@microsoft.com>
    Gerrit-Reviewer: Divyansh Mangal <dma...@microsoft.com>
    Gerrit-Reviewer: Vinay Singh <vinay...@microsoft.com>
    Gerrit-Reviewer: Virali Purbey <virali...@microsoft.com>
    Gerrit-CC: Dileep Maurya <dileep...@microsoft.com>
    Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
    Gerrit-CC: Fredrik Söderquist <f...@opera.com>
    Gerrit-CC: Gaurav Kumar <gaur...@microsoft.com>
    Gerrit-CC: Menard, Alexis <alexis...@intel.com>
    Gerrit-CC: Olga Gerchikov <gerc...@microsoft.com>
    Gerrit-CC: Ragvesh Sharma <rags...@microsoft.com>
    Gerrit-CC: Sejal Anand <sejal...@microsoft.com>
    Gerrit-CC: Stephen Chenney <sche...@chromium.org>
    Gerrit-Attention: Vinay Singh <vinay...@microsoft.com>
    Gerrit-Attention: Virali Purbey <virali...@microsoft.com>
    Gerrit-Comment-Date: Sun, 05 Apr 2026 09:56:53 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Vinay Singh <vinay...@microsoft.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Divyansh Mangal (Gerrit)

    unread,
    Apr 5, 2026, 6:05:19 AM (8 days ago) Apr 5
    to AyeAye, Virali Purbey, Vinay Singh, Ragvesh Sharma, Dileep Maurya, Gaurav Kumar, Sejal Anand, Chromium LUCI CQ, Menard, Alexis, chromium...@chromium.org, Dirk Schulze, Fredrik Söderquist, Olga Gerchikov, Stephen Chenney, blink-rev...@chromium.org, kinuko...@chromium.org, jmedle...@chromium.org, blink-revie...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, feature-me...@chromium.org, fmalit...@chromium.org, kouhe...@chromium.org, pdr+svgw...@chromium.org
    Attention needed from Vinay Singh and Virali Purbey

    Divyansh Mangal added 3 comments

    File third_party/blink/renderer/core/svg/graphics/svg_image.cc
    Line 205, Patchset 7: if (RuntimeEnabledFeatures::SvgSupportMediaFragmentsEnabled()) {
    Vinay Singh . unresolved

    ``&& fragment.Contains("xywh")`` or something similar??

    I guess this will make for an early return sparing initialization of MediaFragmentURIParser for all the non-`xywh` cases which I'm assuming must be in majority.

    Divyansh Mangal

    `ParseFragments` in `MediaFragmentURIParser` handles this much more gracefully, so such an early out is not needed in my opinion. (Also, we would have to decode the fragment first too before applying such checks)

    File third_party/blink/web_tests/external/wpt/svg/linking/reftests/media-fragment-spatial-overflow-clamped.html
    Line 13, Patchset 7: background-image: url("reference/green-100x100.svg#xywh=0,0,200,200");
    Vinay Singh . unresolved

    Same here.

    Wouldn't this produce the same 100x100 green image anyway regardless of the fragment?
    Please correct me if I'm wrong.

    Divyansh Mangal

    Thats the expectation, we actually want to see the entire image itself, even if we give out of bounds spatial fragment per spec.

    File third_party/blink/web_tests/external/wpt/svg/linking/reftests/media-fragment-spatial-percent-full.html
    Line 11, Patchset 7: background-image: url("reference/green-100x100.svg#xywh=percent:0,0,100,100");
    Vinay Singh . unresolved

    Wouldn't this produce the same 100x100 green image regardless of the fragment?
    Please correct me if I'm wrong.

    Divyansh Mangal

    Yes, but what we want to check here is that the entire image is indeed getting correctly displayed with 100% of the bounds, so that's the expectation.

    Gerrit-Comment-Date: Sun, 05 Apr 2026 10:04:34 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Virali Purbey (Gerrit)

    unread,
    Apr 6, 2026, 6:45:18 AM (7 days ago) Apr 6
    to Divyansh Mangal, AyeAye, Vinay Singh, Ragvesh Sharma, Dileep Maurya, Gaurav Kumar, Sejal Anand, Chromium LUCI CQ, Menard, Alexis, chromium...@chromium.org, Dirk Schulze, Fredrik Söderquist, Olga Gerchikov, Stephen Chenney, blink-rev...@chromium.org, kinuko...@chromium.org, jmedle...@chromium.org, blink-revie...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, feature-me...@chromium.org, fmalit...@chromium.org, kouhe...@chromium.org, pdr+svgw...@chromium.org
    Attention needed from Divyansh Mangal and Vinay Singh

    Virali Purbey added 12 comments

    Patchset-level comments
    File-level comment, Patchset 8 (Latest):
    Virali Purbey . unresolved

    Please consider adding WPTs for:

    1. SVG without explicit width/height (viewBox-only). We are explicitly handling the `svg_size.IsEmpty()` case, we should test it.
    2. `<img>` element with percent fragment: Currently only pixel-mode is tested via <img>.
    3. Non-square SVG with percent clip: verifies the x/y scaling applies independently.

    File third_party/blink/renderer/core/html/media/media_fragment_uri_parser.h
    Line 85, Patchset 8 (Latest): bool is_url_valid_ = true;
    Virali Purbey . unresolved

    The name `is_url_valid_` is misleading for the StringView constructor path, where there's no URL involved at all, true just means "parsing should proceed." Consider renaming to `is_valid_` or `should_parse_` to avoid confusion.

    Line 57, Patchset 8 (Latest):// TODO(dmangal): Move MediaFragmentURIParser to a shared location since it is
    // now used by both HTML media and SVG.
    Virali Purbey . unresolved

    Can you file a separate tracking bug for this layering issue? Now that SVG depends on a parser in `//core/html/media/`, it's a real cross-component dependency that should be tracked explicitly rather than relying on a TODO comment.

    File third_party/blink/renderer/core/html/media/media_fragment_uri_parser_test.cc
    Line 231, Patchset 8 (Latest):}
    Virali Purbey . unresolved

    Good, these verify the new StringView constructor.

    Can we consider also adding a test that the StringView constructor correctly handles an empty string (to match the `InvalidUrlYieldsNaN` semantics for the `KURL` constructor).

    File third_party/blink/renderer/core/svg/graphics/svg_image.cc
    Line 205, Patchset 8 (Latest): if (RuntimeEnabledFeatures::SvgSupportMediaFragmentsEnabled()) {
    Virali Purbey . unresolved

    This block adds ~55 lines to `CreateViewInfo`. Can we consider extracting the media-fragment logic into a private helper (e.g., `CreateViewInfoFromSpatialFragment(const String& fragment))` to keep the two code paths easy to follow.

    Line 212, Patchset 8 (Latest): const SpatialClip spatial_clip = media_parser.SpatialFragment();
    Virali Purbey . unresolved

    `SpatialClip::rect` is `gfx::Rect (integer)`, so by this point any fractional values from the fragment string have already been truncated. The conversion to `gfx::RectF` on the next line and the subsequent `Scale()` for percent mode operate on pre-truncated ints. For pixel mode this is fine, but for percent mode with a non-power-of-100 SVG size, the early truncation can produce off-by-one results. Can we consider changing `SpatialClip::rect` to `gfx::RectF`?

    Line 252, Patchset 8 (Latest): /*target*/ nullptr);
    Virali Purbey . unresolved

    nit: Per Chromium style, named parameter comments should use =: `/*target=*/nullptr` (no space before nullptr).

    Line 242, Patchset 8 (Latest): if (!clip_rect.IsEmpty()) {
    spatial_view_spec = SVGViewSpec::CreateFromSpatialFragment(
    MakeGarbageCollected<SVGRect>(clip_rect.x(), clip_rect.y(),
    clip_rect.width(),
    clip_rect.height()));
    }
    }

    if (spatial_view_spec) {
    return MakeGarbageCollected<SVGImageViewInfo>(spatial_view_spec,
    /*target*/ nullptr);
    }
    Virali Purbey . unresolved

    What happens when the URL contains both `xywh=...` and `svgView(viewBox(...))`? Currently the spatial fragment takes absolute priority and the `svgView()` is silently ignored. Is this intentional? The SVG 2 spec doesn't clearly define this interaction.

    Please add a comment documenting the intended precedence and ideally add a test for the combined case `(e.g., #svgView(viewBox(0,0,50,50))&xywh=10,10,20,20)`.

    File third_party/blink/renderer/core/svg/svg_view_spec.cc
    Line 80, Patchset 8 (Latest):const SVGViewSpec* SVGViewSpec::CreateFromSpatialFragment(const SVGRect* rect) {
    if (!rect) {
    return nullptr;
    }
    SVGViewSpec* view_spec = MakeGarbageCollected<SVGViewSpec>();
    view_spec->view_box_ = rect;
    return view_spec;
    }
    Virali Purbey . unresolved

    This sets `view_box_` but leaves `preserve_aspect_ratio_` as nullptr. When `PreserveAspectRatio()` returns null, the SVG element's own `preserveAspectRatio` attribute is used. If the source SVG has `preserveAspectRatio="none"`, a non-square spatial clip (e.g., `xywh=0,0,100,50`) rendered into a square CSS box will get stretched, which is unlikely to be what we would expect.

    Consider explicitly setting `preserveAspectRatio` to `xMidYMid meet` (the SVG default) on the view spec to ensure consistent behavior regardless of what the SVG element declares.

    File third_party/blink/web_tests/external/wpt/svg/linking/reftests/media-fragment-spatial-decimal-values.html
    Line 10, Patchset 8 (Latest): background-image: url("reference/green-100x100.svg#xywh=0.0,0.0,100.0,100.0");
    Virali Purbey . unresolved

    This doesn't actually test decimal value handling, it's again a full-extent clip on a solid-green SVG. To test that decimal values parse correctly, use a case where truncation/rounding would produce a visibly different result, e.g., a clip that selects a sub-region of the two-tone SVG.

    Also note: the parser uses `gfx::Rect` (integers), so 0.0 is truncated to 0, this test won't catch regressions if decimal handling changes. Perhaps worth noting this limitation in the test title.

    File third_party/blink/web_tests/external/wpt/svg/linking/reftests/media-fragment-spatial-overflow-clamped.html
    Line 13, Patchset 7: background-image: url("reference/green-100x100.svg#xywh=0,0,200,200");
    Vinay Singh . unresolved

    Same here.

    Wouldn't this produce the same 100x100 green image anyway regardless of the fragment?
    Please correct me if I'm wrong.

    Divyansh Mangal

    Thats the expectation, we actually want to see the entire image itself, even if we give out of bounds spatial fragment per spec.

    Virali Purbey

    Acknowledged, showing the full image is the correct expected result here.

    The concern is discriminating power: this test produces the same green `100×100` output whether the fragment is parsed and clamped correctly, completely ignored, or fails to parse entirely. So it can't catch a regression in the clamping codepath.

    Could you add a companion test with a non-zero origin? e.g., `red-green-200x200.svg#xywh=50,50,300,300` → clamped to `50,50,150,150`. That way the clamped clip selects a visible sub-region that differs from "no fragment," and the test actually exercises the clamping logic. This test can stay as-is for spec-behavior documentation.

    File third_party/blink/web_tests/external/wpt/svg/linking/reftests/media-fragment-spatial-percent-full.html
    Line 11, Patchset 7: background-image: url("reference/green-100x100.svg#xywh=percent:0,0,100,100");
    Vinay Singh . unresolved

    Wouldn't this produce the same 100x100 green image regardless of the fragment?
    Please correct me if I'm wrong.

    Divyansh Mangal

    Yes, but what we want to check here is that the entire image is indeed getting correctly displayed with 100% of the bounds, so that's the expectation.

    Virali Purbey

    Same concern as the `overflow-clamped test` - `percent:0,0,100,100` resolves to the full image, so this passes identically with or without fragment support. I note that `spatial-percent.html` already meaningfully tests a sub-region percent clip, so coverage exists. Still, consider either making this test non-trivial (e.g., a sub-region on the two-tone SVG), or adding a comment in the test noting it intentionally verifies that a full-extent percent clip renders identically to no fragment.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Divyansh Mangal
    • Vinay Singh
    Gerrit-Attention: Divyansh Mangal <dma...@microsoft.com>
    Gerrit-Comment-Date: Mon, 06 Apr 2026 10:44:40 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Vinay Singh <vinay...@microsoft.com>
    Comment-In-Reply-To: Divyansh Mangal <dma...@microsoft.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Virali Purbey (Gerrit)

    unread,
    Apr 6, 2026, 6:46:40 AM (7 days ago) Apr 6
    to Divyansh Mangal, AyeAye, Vinay Singh, Ragvesh Sharma, Dileep Maurya, Gaurav Kumar, Sejal Anand, Chromium LUCI CQ, Menard, Alexis, chromium...@chromium.org, Dirk Schulze, Fredrik Söderquist, Olga Gerchikov, Stephen Chenney, blink-rev...@chromium.org, kinuko...@chromium.org, jmedle...@chromium.org, blink-revie...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, feature-me...@chromium.org, fmalit...@chromium.org, kouhe...@chromium.org, pdr+svgw...@chromium.org
    Attention needed from Divyansh Mangal and Vinay Singh

    Virali Purbey added 1 comment

    Commit Message
    Line 30, Patchset 8 (Latest):Bug: 40362942, 495475010
    Virali Purbey . unresolved

    Can you please verify why the `mac-rel` policy is failing and if there is anything missing?

    Gerrit-Comment-Date: Mon, 06 Apr 2026 10:46:00 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Divyansh Mangal (Gerrit)

    unread,
    Apr 7, 2026, 11:46:09 AM (6 days ago) Apr 7
    to AyeAye, Virali Purbey, Vinay Singh, Ragvesh Sharma, Dileep Maurya, Gaurav Kumar, Sejal Anand, Chromium LUCI CQ, Menard, Alexis, chromium...@chromium.org, Dirk Schulze, Fredrik Söderquist, Olga Gerchikov, Stephen Chenney, blink-rev...@chromium.org, kinuko...@chromium.org, jmedle...@chromium.org, blink-revie...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, feature-me...@chromium.org, fmalit...@chromium.org, kouhe...@chromium.org, pdr+svgw...@chromium.org
    Attention needed from Vinay Singh and Virali Purbey

    Divyansh Mangal added 5 comments

    Commit Message
    Line 30, Patchset 8:Bug: 40362942, 495475010
    Virali Purbey . resolved

    Can you please verify why the `mac-rel` policy is failing and if there is anything missing?

    Divyansh Mangal

    Just an infra, resolved in the next run by itself, not an all related to the CL.

    File third_party/blink/renderer/core/html/media/media_fragment_uri_parser.h
    Line 85, Patchset 8: bool is_url_valid_ = true;
    Virali Purbey . unresolved

    The name `is_url_valid_` is misleading for the StringView constructor path, where there's no URL involved at all, true just means "parsing should proceed." Consider renaming to `is_valid_` or `should_parse_` to avoid confusion.

    Divyansh Mangal

    Please see the reasoning for this name per comment https://chromium-review.googlesource.com/c/chromium/src/+/7675457/comment/30a18874_ce599c87/

    I am ok with `should_parse_`, but maybe need more inputs from an owner as well before we change it again

    Line 57, Patchset 8:// TODO(dmangal): Move MediaFragmentURIParser to a shared location since it is

    // now used by both HTML media and SVG.
    Virali Purbey . resolved

    Can you file a separate tracking bug for this layering issue? Now that SVG depends on a parser in `//core/html/media/`, it's a real cross-component dependency that should be tracked explicitly rather than relying on a TODO comment.

    Divyansh Mangal

    Done

    File third_party/blink/renderer/core/html/media/media_fragment_uri_parser_test.cc
    Line 231, Patchset 8:}
    Virali Purbey . resolved

    Good, these verify the new StringView constructor.

    Can we consider also adding a test that the StringView constructor correctly handles an empty string (to match the `InvalidUrlYieldsNaN` semantics for the `KURL` constructor).

    Divyansh Mangal

    Done

    File third_party/blink/renderer/core/svg/graphics/svg_image.cc
    Line 252, Patchset 8: /*target*/ nullptr);
    Virali Purbey . resolved

    nit: Per Chromium style, named parameter comments should use =: `/*target=*/nullptr` (no space before nullptr).

    Divyansh Mangal

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Vinay Singh
    • Virali Purbey
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I906358afc719255004fb51f957458152aca1422b
    Gerrit-Change-Number: 7675457
    Gerrit-PatchSet: 10
    Gerrit-Owner: Divyansh Mangal <dma...@microsoft.com>
    Gerrit-Reviewer: Divyansh Mangal <dma...@microsoft.com>
    Gerrit-Reviewer: Vinay Singh <vinay...@microsoft.com>
    Gerrit-Reviewer: Virali Purbey <virali...@microsoft.com>
    Gerrit-CC: Dileep Maurya <dileep...@microsoft.com>
    Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
    Gerrit-CC: Fredrik Söderquist <f...@opera.com>
    Gerrit-CC: Gaurav Kumar <gaur...@microsoft.com>
    Gerrit-CC: Menard, Alexis <alexis...@intel.com>
    Gerrit-CC: Olga Gerchikov <gerc...@microsoft.com>
    Gerrit-CC: Ragvesh Sharma <rags...@microsoft.com>
    Gerrit-CC: Sejal Anand <sejal...@microsoft.com>
    Gerrit-CC: Stephen Chenney <sche...@chromium.org>
    Gerrit-Attention: Vinay Singh <vinay...@microsoft.com>
    Gerrit-Attention: Virali Purbey <virali...@microsoft.com>
    Gerrit-Comment-Date: Tue, 07 Apr 2026 15:45:35 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Virali Purbey <virali...@microsoft.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Divyansh Mangal (Gerrit)

    unread,
    Apr 7, 2026, 12:38:56 PM (6 days ago) Apr 7
    to AyeAye, Virali Purbey, Vinay Singh, Ragvesh Sharma, Dileep Maurya, Gaurav Kumar, Sejal Anand, Chromium LUCI CQ, Menard, Alexis, chromium...@chromium.org, Dirk Schulze, Fredrik Söderquist, Olga Gerchikov, Stephen Chenney, blink-rev...@chromium.org, kinuko...@chromium.org, jmedle...@chromium.org, blink-revie...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, feature-me...@chromium.org, fmalit...@chromium.org, kouhe...@chromium.org, pdr+svgw...@chromium.org
    Attention needed from Vinay Singh and Virali Purbey

    Divyansh Mangal added 3 comments

    File third_party/blink/renderer/core/svg/graphics/svg_image.cc
    Line 242, Patchset 8: if (!clip_rect.IsEmpty()) {

    spatial_view_spec = SVGViewSpec::CreateFromSpatialFragment(
    MakeGarbageCollected<SVGRect>(clip_rect.x(), clip_rect.y(),
    clip_rect.width(),
    clip_rect.height()));
    }
    }

    if (spatial_view_spec) {
    return MakeGarbageCollected<SVGImageViewInfo>(spatial_view_spec,
    /*target*/ nullptr);
    }
    Virali Purbey . unresolved

    What happens when the URL contains both `xywh=...` and `svgView(viewBox(...))`? Currently the spatial fragment takes absolute priority and the `svgView()` is silently ignored. Is this intentional? The SVG 2 spec doesn't clearly define this interaction.

    Please add a comment documenting the intended precedence and ideally add a test for the combined case `(e.g., #svgView(viewBox(0,0,50,50))&xywh=10,10,20,20)`.

    Divyansh Mangal

    Thanks for the question Virali, seems like the interaction between various fragments is indeed listed in the spec which I earlier missed completely.

    https://svgwg.org/svg2-draft/linking.html#SVGFragmentIdentifiersDefinitions

    For our purpose this statement will apply:

    _If the SVG fragment identifier addresses a combination of the above non-time related identifiers with a time-related identifier (i.e. a timesegment), the behavior of each identifier is applied._

    if i am reading this correctly it means each fragments type effect will apply, which makes for pretty interesting WPTs as well. I will add those and the one that you suggested.

    File third_party/blink/renderer/core/svg/svg_view_spec.cc
    Line 80, Patchset 8:const SVGViewSpec* SVGViewSpec::CreateFromSpatialFragment(const SVGRect* rect) {

    if (!rect) {
    return nullptr;
    }
    SVGViewSpec* view_spec = MakeGarbageCollected<SVGViewSpec>();
    view_spec->view_box_ = rect;
    return view_spec;
    }
    Virali Purbey . unresolved

    This sets `view_box_` but leaves `preserve_aspect_ratio_` as nullptr. When `PreserveAspectRatio()` returns null, the SVG element's own `preserveAspectRatio` attribute is used. If the source SVG has `preserveAspectRatio="none"`, a non-square spatial clip (e.g., `xywh=0,0,100,50`) rendered into a square CSS box will get stretched, which is unlikely to be what we would expect.

    Consider explicitly setting `preserveAspectRatio` to `xMidYMid meet` (the SVG default) on the view spec to ensure consistent behavior regardless of what the SVG element declares.

    Divyansh Mangal

    Per the SVG spec's fragment identifier definitions https://svgwg.org/svg2-draft/linking.html#SVGFragmentIdentifiersDefinitions, only explicitly specified view attributes override the root element's attributes.
    The existing `svgView(viewBox(...))` and `<view>` paths follow this same pattern, when `preserveAspectRatio` isn't specified in the fragment, the element's own `preserveAspectRatio` is used (`CreateFromFragment` and `CreateForViewElement` both leave `preserve_aspect_ratio_` null when unspecified).

    forcing `xMidYMid meet` would make spatial fragments behave differently.
    Though I should definitely add some tests with `preserveAspectRatio` specified which will give us more coverage.

    File third_party/blink/web_tests/external/wpt/svg/linking/reftests/media-fragment-spatial-overflow-clamped.html
    Line 13, Patchset 7: background-image: url("reference/green-100x100.svg#xywh=0,0,200,200");
    Vinay Singh . unresolved

    Same here.

    Wouldn't this produce the same 100x100 green image anyway regardless of the fragment?
    Please correct me if I'm wrong.

    Divyansh Mangal

    Thats the expectation, we actually want to see the entire image itself, even if we give out of bounds spatial fragment per spec.

    Virali Purbey

    Acknowledged, showing the full image is the correct expected result here.

    The concern is discriminating power: this test produces the same green `100×100` output whether the fragment is parsed and clamped correctly, completely ignored, or fails to parse entirely. So it can't catch a regression in the clamping codepath.

    Could you add a companion test with a non-zero origin? e.g., `red-green-200x200.svg#xywh=50,50,300,300` → clamped to `50,50,150,150`. That way the clamped clip selects a visible sub-region that differs from "no fragment," and the test actually exercises the clamping logic. This test can stay as-is for spec-behavior documentation.

    Divyansh Mangal

    Just a thing that I noticed, if you try the same svg on Firefox they won't show 100x100 image, most likely because they dont do the clamping as suggested in the spec (atleast that's what I could gather from their code https://searchfox.org/firefox-main/source/dom/svg/SVGFragmentIdentifier.cpp#166) so this is a good test to have regardless.

    Though I will also the test which Virali suggested it will also increase coverage.

    Gerrit-Comment-Date: Tue, 07 Apr 2026 16:38:27 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Vinay Singh <vinay...@microsoft.com>
    Comment-In-Reply-To: Virali Purbey <virali...@microsoft.com>
    Comment-In-Reply-To: Divyansh Mangal <dma...@microsoft.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Fredrik Söderquist (Gerrit)

    unread,
    8:16 AM (1 hour ago) 8:16 AM
    to Divyansh Mangal, android-bu...@system.gserviceaccount.com, Virali Purbey, Vinay Singh, Ragvesh Sharma, Dileep Maurya, Gaurav Kumar, Sejal Anand, chromiu...@luci-project-accounts.iam.gserviceaccount.com, Menard, Alexis, chromium...@chromium.org, Dirk Schulze, Olga Gerchikov, Stephen Chenney, blink-rev...@chromium.org, kinuko...@chromium.org, jmedle...@chromium.org, blink-revie...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, feature-me...@chromium.org, fmalit...@chromium.org, kouhe...@chromium.org, pdr+svgw...@chromium.org
    Attention needed from Divyansh Mangal, Vinay Singh and Virali Purbey

    Fredrik Söderquist added 6 comments

    Patchset-level comments
    File-level comment, Patchset 10 (Latest):
    Fredrik Söderquist . resolved

    It's non-obvious to me how this should interact with sizing, but it will probably need to override the natural dimensions? The CSS images spec[1] says "clipped". (This mechanism would in theory be the same for raster images.)

    [1] https://drafts.csswg.org/css-images-4/#image-fragments

    File third_party/blink/renderer/core/svg/graphics/svg_image.cc
    Line 205, Patchset 8: if (RuntimeEnabledFeatures::SvgSupportMediaFragmentsEnabled()) {
    Virali Purbey . unresolved

    This block adds ~55 lines to `CreateViewInfo`. Can we consider extracting the media-fragment logic into a private helper (e.g., `CreateViewInfoFromSpatialFragment(const String& fragment))` to keep the two code paths easy to follow.

    Fredrik Söderquist

    This sounds like a good idea given that the added code is quite a bit larger than the existing code.

    File third_party/blink/renderer/core/svg/svg_view_spec.cc
    Line 80, Patchset 8:const SVGViewSpec* SVGViewSpec::CreateFromSpatialFragment(const SVGRect* rect) {
    if (!rect) {
    return nullptr;
    }
    SVGViewSpec* view_spec = MakeGarbageCollected<SVGViewSpec>();
    view_spec->view_box_ = rect;
    return view_spec;
    }
    Virali Purbey . unresolved

    This sets `view_box_` but leaves `preserve_aspect_ratio_` as nullptr. When `PreserveAspectRatio()` returns null, the SVG element's own `preserveAspectRatio` attribute is used. If the source SVG has `preserveAspectRatio="none"`, a non-square spatial clip (e.g., `xywh=0,0,100,50`) rendered into a square CSS box will get stretched, which is unlikely to be what we would expect.

    Consider explicitly setting `preserveAspectRatio` to `xMidYMid meet` (the SVG default) on the view spec to ensure consistent behavior regardless of what the SVG element declares.

    Divyansh Mangal

    Per the SVG spec's fragment identifier definitions https://svgwg.org/svg2-draft/linking.html#SVGFragmentIdentifiersDefinitions, only explicitly specified view attributes override the root element's attributes.
    The existing `svgView(viewBox(...))` and `<view>` paths follow this same pattern, when `preserveAspectRatio` isn't specified in the fragment, the element's own `preserveAspectRatio` is used (`CreateFromFragment` and `CreateForViewElement` both leave `preserve_aspect_ratio_` null when unspecified).

    forcing `xMidYMid meet` would make spatial fragments behave differently.
    Though I should definitely add some tests with `preserveAspectRatio` specified which will give us more coverage.

    Fredrik Söderquist

    Why would a spatial fragment apply to (override) the `viewBox` though? That's not how I'm reading the spec (the little of it there is). The way I'm reading it, it should rather act as a clip/subregion into the image. (Overriding the `viewBox' may affect the viewport, natural aspect ratio, etc.)

    File third_party/blink/web_tests/external/wpt/svg/linking/reftests/media-fragment-spatial-decimal-values.html
    Line 3, Patchset 10 (Latest):<link rel="help" href="https://www.w3.org/TR/media-frags/#naming-space">
    Fredrik Söderquist . unresolved

    Should probably also reference the section in the SVG spec. (Here and all the cases below.)

    File third_party/blink/web_tests/external/wpt/svg/linking/reftests/media-fragment-spatial-unknown-unit.html
    Line 10, Patchset 10 (Latest): background-image: url("reference/green-100x100.svg#xywh=foo:0,0,50,50");
    Fredrik Söderquist . unresolved

    How will you be able to tell if this fails?

    File third_party/blink/web_tests/external/wpt/svg/linking/reftests/reference/green-100x100.svg
    Line 1, Patchset 10 (Latest):<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
    Fredrik Söderquist . unresolved

    Don't do this. If you need a fixed-size version, then add one. (Also it looks like what you want is really a `support/` file.)

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Divyansh Mangal
    • Vinay Singh
    • Virali Purbey
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I906358afc719255004fb51f957458152aca1422b
    Gerrit-Change-Number: 7675457
    Gerrit-PatchSet: 10
    Gerrit-Owner: Divyansh Mangal <dma...@microsoft.com>
    Gerrit-Reviewer: Divyansh Mangal <dma...@microsoft.com>
    Gerrit-Reviewer: Fredrik Söderquist <f...@opera.com>
    Gerrit-Reviewer: Vinay Singh <vinay...@microsoft.com>
    Gerrit-Reviewer: Virali Purbey <virali...@microsoft.com>
    Gerrit-CC: Dileep Maurya <dileep...@microsoft.com>
    Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
    Gerrit-CC: Gaurav Kumar <gaur...@microsoft.com>
    Gerrit-CC: Menard, Alexis <alexis...@intel.com>
    Gerrit-CC: Olga Gerchikov <gerc...@microsoft.com>
    Gerrit-CC: Ragvesh Sharma <rags...@microsoft.com>
    Gerrit-CC: Sejal Anand <sejal...@microsoft.com>
    Gerrit-CC: Stephen Chenney <sche...@chromium.org>
    Gerrit-Attention: Vinay Singh <vinay...@microsoft.com>
    Gerrit-Attention: Virali Purbey <virali...@microsoft.com>
    Gerrit-Attention: Divyansh Mangal <dma...@microsoft.com>
    Gerrit-Comment-Date: Mon, 13 Apr 2026 12:16:09 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages