Bug 235695 - DocumentContext gives empty rects for blank lines.
Summary: DocumentContext gives empty rects for blank lines.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Megan Gardner
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-01-27 00:32 PST by Megan Gardner
Modified: 2022-01-27 21:15 PST (History)
4 users (show)

See Also:


Attachments
Patch (7.43 KB, patch)
2022-01-27 00:38 PST, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch (10.87 KB, patch)
2022-01-27 14:21 PST, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch (10.00 KB, patch)
2022-01-27 15:19 PST, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch for landing (10.00 KB, patch)
2022-01-27 20:03 PST, Megan Gardner
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Megan Gardner 2022-01-27 00:32:26 PST
DocumentContext gives empty rects for blank lines.
Comment 1 Megan Gardner 2022-01-27 00:38:50 PST
Created attachment 450110 [details]
Patch
Comment 2 Aditya Keerthi 2022-01-27 09:10:24 PST
Comment on attachment 450110 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=450110&action=review

> Source/WebCore/platform/graphics/GeometryUtilities.cpp:108
> +FloatRect unionRectIfNonZero(const Vector<FloatRect>& rects)

This looks the same as `unionRectIgnoringZeroRects`!

Maybe just add a new method for `const Vector<IntRect>&` and give it the same name as the existing method?
Comment 3 Wenson Hsieh 2022-01-27 09:22:25 PST
Comment on attachment 450110 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=450110&action=review

This should be API-testable (there are existing examples in DocumentEditingContext.mm)

>> Source/WebCore/platform/graphics/GeometryUtilities.cpp:108
>> +FloatRect unionRectIfNonZero(const Vector<FloatRect>& rects)
> 
> This looks the same as `unionRectIgnoringZeroRects`!
> 
> Maybe just add a new method for `const Vector<IntRect>&` and give it the same name as the existing method?

Indeed!

Could also consider consolidating both into a template function and letting type deduction do it's thing:

```
template <typename RectType>
RectType unionRectIgnoringZeroRects(const Vector<RectType>& rects)
{
    RectType result;
    for (auto& rect : rects)
        result.uniteIfNonZero(rect);
    return result;
}
```
Comment 4 Megan Gardner 2022-01-27 14:21:38 PST
Created attachment 450178 [details]
Patch
Comment 5 Tim Horton 2022-01-27 14:47:17 PST
Comment on attachment 450178 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=450178&action=review

> Tools/TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm:489
> +    auto documentRect = CGRectFromJSONEncodedDOMRectJSValue([webView objectByEvaluatingJavaScript:@"text.getBoundingClientRect().toJSON()"]);
> +    documentRect.origin.x += (documentRect.size.width / 2) - (glyphWidth * 2);
> +    documentRect.origin.y += (documentRect.size.height / 2) - (glyphWidth * 2);
> +    documentRect.size.width = glyphWidth;
> +    documentRect.size.height = glyphWidth;

You never use documentRect so you can delete all of this
Comment 6 Megan Gardner 2022-01-27 15:19:15 PST
Created attachment 450188 [details]
Patch
Comment 7 Megan Gardner 2022-01-27 20:03:16 PST
Created attachment 450201 [details]
Patch for landing
Comment 8 EWS 2022-01-27 21:14:38 PST
Committed r288721 (246514@main): <https://commits.webkit.org/246514@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 450201 [details].
Comment 9 Radar WebKit Bug Importer 2022-01-27 21:15:37 PST
<rdar://problem/88169210>