Bug 248357 - SVG text selection has bugs with collapsed whitespace
Summary: SVG text selection has bugs with collapsed whitespace
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-11-26 02:33 PST by Ahmad Saleem
Modified: 2023-10-02 07:06 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ahmad Saleem 2022-11-26 02:33:00 PST
Hi Team,

While going through Chromium Monorail, I come across another failing test case in Safari:

Link -  https://jsfiddle.net/progers/g1z286fL/

While trying to select text from world to next line "hello", it does not paint the selection properly and jump it to first top line while it works fine in Chrome Canary 110.

It is broken in Safari Technology Preview 158 and 16.1 both, it was fixed with this commit:

Commit - https://src.chromium.org/viewvc/blink?view=revision&revision=194860

It had some pre-requisite fixes for "SelectionTestCase.js" script, which I will land first so this can be looked into as potential blink merge.

Thanks!
Comment 1 Radar WebKit Bug Importer 2022-12-03 02:33:38 PST
<rdar://problem/102933142>
Comment 2 Ahmad Saleem 2023-02-08 06:01:18 PST
I tried this in following PR:

https://github.com/WebKit/WebKit/pull/9749

At least selection works in local testing but it does not pass the test and also regresses other, so there might be some pre-requisite to it or some other underlying difference.

NOTE - GTK does not regress the test cases, which got regressed on Mac-OS, which seems to indicate some vendor specific bits.

I am closing my PR for time being and going to test more locally.
Comment 3 Ahmad Saleem 2023-09-04 07:07:02 PDT
Instead of 'squaredDistanceToClosestPoint' from Chromium patch, merge this as well: https://chromium.googlesource.com/chromium/src.git/+/ec9931b6a84f86605970d9aab571d2ca429df2fa

(Implement) - https://chromium.googlesource.com/chromium/src.git/+/ac7237a24b28daa6f1c5292f32e940cc63fba39d
Comment 4 Ahmad Saleem 2023-09-04 15:53:27 PDT
Only got this failure locally: svg/text/select-textLength-spacingAndGlyphs-squeeze-3.svg

This would make it pass:

<svg version="1.1" baseProfile="basic" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 160 120">
<g id="container"/>

<!-- "Squ" should be selected, char 8-10 -->
<text id="test" x="10" y="10" font-family="Arial" font-size="10" textLength="50" lengthAdjust="spacingAndGlyphs">Text to Squeeze</text>

<script xlink:href="resources/SelectionTestCase.js"/>
<script>selectRange("test", 8, 10, "o ");</script>
</svg>
Comment 5 Ahmad Saleem 2023-10-02 07:06:39 PDT
float FloatRect::squaredDistanceTo(const FloatPoint& point) const
{
    FloatPoint closestPoint;
    closestPoint.setX(clampTo<float>(point.x(), x(), maxX()));
    closestPoint.setY(clampTo<float>(point.y(), y(), maxY()));
    return (point - closestPoint).diagonalLengthSquared();
}

^ In FloatRect.cpp

float squaredDistanceTo(const FloatPoint&) const;

^ In FloatRect.h

____

Just wanted to update.