RESOLVED FIXED 235695
DocumentContext gives empty rects for blank lines.
https://bugs.webkit.org/show_bug.cgi?id=235695
Summary DocumentContext gives empty rects for blank lines.
Megan Gardner
Reported 2022-01-27 00:32:26 PST
DocumentContext gives empty rects for blank lines.
Attachments
Patch (7.43 KB, patch)
2022-01-27 00:38 PST, Megan Gardner
no flags
Patch (10.87 KB, patch)
2022-01-27 14:21 PST, Megan Gardner
no flags
Patch (10.00 KB, patch)
2022-01-27 15:19 PST, Megan Gardner
no flags
Patch for landing (10.00 KB, patch)
2022-01-27 20:03 PST, Megan Gardner
no flags
Megan Gardner
Comment 1 2022-01-27 00:38:50 PST
Aditya Keerthi
Comment 2 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?
Wenson Hsieh
Comment 3 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; } ```
Megan Gardner
Comment 4 2022-01-27 14:21:38 PST
Tim Horton
Comment 5 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
Megan Gardner
Comment 6 2022-01-27 15:19:15 PST
Megan Gardner
Comment 7 2022-01-27 20:03:16 PST
Created attachment 450201 [details] Patch for landing
EWS
Comment 8 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].
Radar WebKit Bug Importer
Comment 9 2022-01-27 21:15:37 PST
Note You need to log in before you can comment on or make changes to this bug.