[Webkit-unassigned] [Bug 278181] New: [macOS] `-[WKWebView _firstRectForCharacterRange:]` reports a rect with double height when the range covers the last line, and `after-white-space` is used

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Aug 15 12:35:36 PDT 2024


https://bugs.webkit.org/show_bug.cgi?id=278181

            Bug ID: 278181
           Summary: [macOS] `-[WKWebView _firstRectForCharacterRange:]`
                    reports a rect with double height when the range
                    covers the last line, and `after-white-space` is used
           Product: WebKit
           Version: Other
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: HTML Editing
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: akeerthi at apple.com
                CC: wenson_hsieh at apple.com

Found this bug, while looking at another one. There is currently no known user-facing impact and it appears to be a longstanding issue.

Reproducible in an API test:

```
TEST(WKWebViewMacEditingTests, Repro)
{
    RetainPtr webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
    [webView _setEditable:YES];

    [webView synchronouslyLoadHTMLString:@"<body style='line-break: after-white-space;'><div>Lorem ipsum dolor sit amet, consectetur adipiscing</div><div>elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div></body>"];
    [webView stringByEvaluatingJavaScript:@"document.body.focus()"];

    [webView selectAll:nil];

    auto [firstRect, actualRange] = [webView _firstRectForCharacterRange:NSMakeRange(409, 36)];

    NSLog(@"%@", NSStringFromRect(firstRect));
}
```

The range (409, 36) encompasses the last line, containing "deserunt mollit anim id est laborum.".

The logging reports a rect with a height of 36 (as opposed to 18, which is expected). Additionally, the width is larger than then width of the encompassed text.

The issue does not reproduce if `line-break: after-white-space` is removed.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20240815/695b9708/attachment.htm>


More information about the webkit-unassigned mailing list