Bug 209462 - Simplify characterRectsForRange() in WebPage::requestDocumentEditingContext()
Summary: Simplify characterRectsForRange() in WebPage::requestDocumentEditingContext()
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: WebKit Local Build
Hardware: iPhone / iPad iOS 13
: P2 Normal
Assignee: Daniel Bates
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-03-23 21:06 PDT by Daniel Bates
Modified: 2020-03-24 14:17 PDT (History)
3 users (show)

See Also:


Attachments
Patch (2.97 KB, patch)
2020-03-23 21:13 PDT, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch (2.97 KB, patch)
2020-03-23 21:53 PDT, Daniel Bates
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Bates 2020-03-23 21:06:57 PDT
Simplify characterRectsForRange() before I make changes to it.
Comment 1 Daniel Bates 2020-03-23 21:13:37 PDT
Created attachment 394350 [details]
Patch
Comment 2 Daniel Bates 2020-03-23 21:51:45 PDT
Comment on attachment 394350 [details]
Patch

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

> Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:4246
> +                rects.append({ createLiveRange(iterator.range())->absoluteBoundingBox(Range::BoundingRectBehavior::IgnoreEmptyTextSelections), { ++offsetSoFar, stride } });

r-, should be offsetSoFar++
Comment 3 Daniel Bates 2020-03-23 21:53:21 PDT
Created attachment 394353 [details]
Patch
Comment 4 Wenson Hsieh 2020-03-23 21:54:38 PDT
Comment on attachment 394353 [details]
Patch

r=mews
Comment 5 Daniel Bates 2020-03-23 22:06:59 PDT
Thanks Wenson!
Comment 6 Daniel Bates 2020-03-24 11:00:19 PDT
Comment on attachment 394353 [details]
Patch

Clearing flags on attachment: 394353

Committed r258920: <https://trac.webkit.org/changeset/258920>
Comment 7 Daniel Bates 2020-03-24 11:00:20 PDT
All reviewed patches have been landed.  Closing bug.
Comment 8 Radar WebKit Bug Importer 2020-03-24 11:01:16 PDT
<rdar://problem/60832084>
Comment 9 Darin Adler 2020-03-24 12:21:14 PDT
Comment on attachment 394350 [details]
Patch

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

> Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:4239
> +    auto characterRectsForRange = [](const Range& range, unsigned startOffset) {

No reason for this to take const Range& instead of const SimpleRange&; all this function does with the range is create a CharacterIterator, which takes a SimpleRange.
Comment 10 Daniel Bates 2020-03-24 14:06:10 PDT
(In reply to Darin Adler from comment #9)
> Comment on attachment 394350 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=394350&action=review
> 
> > Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:4239
> > +    auto characterRectsForRange = [](const Range& range, unsigned startOffset) {
> 
> No reason for this to take const Range& instead of const SimpleRange&; all
> this function does with the range is create a CharacterIterator, which takes
> a SimpleRange.

That's too simple to do.
Comment 11 Daniel Bates 2020-03-24 14:07:55 PDT
(In reply to Daniel Bates from comment #10)
> (In reply to Darin Adler from comment #9)
> > Comment on attachment 394350 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=394350&action=review
> > 
> > > Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:4239
> > > +    auto characterRectsForRange = [](const Range& range, unsigned startOffset) {
> > 
> > No reason for this to take const Range& instead of const SimpleRange&; all
> > this function does with the range is create a CharacterIterator, which takes
> > a SimpleRange.
> 
> That's too simple to do.

I was joking by the way. I can change it, but the caller currently passes a Range. I haven't put thought into whether the caller can be a SimpleRange.
Comment 12 Darin Adler 2020-03-24 14:08:31 PDT
(In reply to Daniel Bates from comment #11)
> I was joking by the way. I can change it, but the caller currently passes a
> Range. I haven't put thought into whether the caller can be a SimpleRange.

You can pass a Range to a function that takes a const SimpleRange&. Caller won’t have to change at all.
Comment 13 Daniel Bates 2020-03-24 14:17:45 PDT
(In reply to Darin Adler from comment #12)
> (In reply to Daniel Bates from comment #11)
> > I was joking by the way. I can change it, but the caller currently passes a
> > Range. I haven't put thought into whether the caller can be a SimpleRange.
> 
> You can pass a Range to a function that takes a const SimpleRange&. Caller
> won’t have to change at all.

OK. Patch up at bug #209495.