Bug 139258

Summary: dominant-baseline in an SVG <text> tag is not inherited by its children <tspan> tags
Product: WebKit Reporter: Said Abou-Hallawa <sabouhallawa>
Component: SVGAssignee: Nobody <webkit-unassigned>
Status: REOPENED ---    
Severity: Normal CC: ahmad.saleem792, commit-queue, gusanmaz, oliver, webkit-bug-importer, yan, zimmermann
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=259286
Bug Depends on: 259335    
Bug Blocks:    
Attachments:
Description Flags
result
none
expected none

Description Said Abou-Hallawa 2014-12-04 09:51:47 PST
Open the following svg

<svg xmlns="http://www.w3.org/2000/svg">
  <line x1="0" y1="200" x2="100%" y2="200" style="stroke:rgb(255,0,0);stroke-width:1" />
  <text x="20" y="200" dominant-baseline="central" font-size="50px">
    foo<tspan>bar </tspan><tspan>baz</tspan>
  </text>
</svg>

Result: The first word "foo" is the only text which is rendered with alignment equal to "central". The rest of the text in the <tspan> tags is rendered with alignment equal to "alphabetic".

The w3c specs http://www.w3.org/TR/SVG/text.html says about the value "auto" of the dominant-baseline, which is the default: "If this property occurs on a ‘tspan’, ‘tref’, ‘altGlyph’ or ‘textPath’ element, then the dominant-baseline and the baseline-table components remain the same as those of the parent text content element."

So it is expected to have all the text in the <tspan> tags in the svg above to be rendered with the same alignment as the parent text content element's alignment.
Comment 1 Said Abou-Hallawa 2014-12-04 09:54:27 PST
Created attachment 242573 [details]
result
Comment 2 Said Abou-Hallawa 2014-12-04 09:54:50 PST
Created attachment 242574 [details]
expected
Comment 3 Radar WebKit Bug Importer 2014-12-04 09:55:42 PST
<rdar://problem/19144671>
Comment 4 Yan Wong 2020-04-25 03:52:23 PDT
dominant-baseline should be inherited in SVG 2, so this is an SVG 2 improvement, which would be welcome in webkit. It *is* inherited in the latest version of Chrome and Firefox. See https://www.fxsitecompat.dev/en-CA/docs/2019/dominant-baseline-is-now-inherited-from-its-parent-element/
Comment 5 Ahmad Saleem 2023-05-13 06:35:30 PDT
https://src.chromium.org/viewvc/blink?view=revision&revision=199970

^ This makes us pass following test case - https://jsfiddle.net/azLe745x/

but it regresses following:

imported/w3c/web-platform-tests/svg/styling/presentation-attributes-irrelevant.html
imported/w3c/web-platform-tests/svg/styling/presentation-attributes-relevant.html
imported/w3c/web-platform-tests/svg/styling/presentation-attributes-unknown.html

With following failing:

dominant-baseline presentation attribute supported on a irrelevant element
dominant-baseline presentation attribute supported on a relevant element
dominant-baseline presentation attribute supported on an unknown SVG element
Comment 6 Ahmad Saleem 2023-05-28 15:58:32 PDT
(In reply to Ahmad Saleem from comment #5)
> https://src.chromium.org/viewvc/blink?view=revision&revision=199970
> 
> ^ This makes us pass following test case - https://jsfiddle.net/azLe745x/
> 
> but it regresses following:
> 
> imported/w3c/web-platform-tests/svg/styling/presentation-attributes-
> irrelevant.html
> imported/w3c/web-platform-tests/svg/styling/presentation-attributes-relevant.
> html
> imported/w3c/web-platform-tests/svg/styling/presentation-attributes-unknown.
> html
> 
> With following failing:
> 
> dominant-baseline presentation attribute supported on a irrelevant element
> dominant-baseline presentation attribute supported on a relevant element
> dominant-baseline presentation attribute supported on an unknown SVG element

Running these tests directly from WPT on Minibrowser where I have Blink patch merged does not show them failing when I do merge. :-(

I do have other SVG patches, which can mess with my internal build, so I think I can try doing draft PR.

Any suggestion?
Comment 7 EWS 2023-06-26 13:10:07 PDT
Committed 265525@main (0ed9d940afc3): <https://commits.webkit.org/265525@main>

Reviewed commits have been landed. Closing PR #14833 and removing active labels.
Comment 8 Ahmad Saleem 2023-07-04 09:54:32 PDT
*** Bug 249085 has been marked as a duplicate of this bug. ***
Comment 9 Ahmad Saleem 2023-07-07 14:03:53 PDT
*** Bug 217564 has been marked as a duplicate of this bug. ***
Comment 10 WebKit Commit Bot 2023-07-19 03:33:42 PDT
Re-opened since this is blocked by bug 259335