WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
197177
Return annotated text checking strings via UIWKDocumentContext
https://bugs.webkit.org/show_bug.cgi?id=197177
Summary
Return annotated text checking strings via UIWKDocumentContext
Tim Horton
Reported
2019-04-22 14:00:01 PDT
Return annotated text checking strings via UIWKDocumentContext
Attachments
Patch
(5.90 KB, patch)
2019-04-22 14:00 PDT
,
Tim Horton
no flags
Details
Formatted Diff
Diff
Patch
(5.93 KB, patch)
2019-04-23 16:18 PDT
,
Tim Horton
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Tim Horton
Comment 1
2019-04-22 14:00:20 PDT
Created
attachment 367971
[details]
Patch
Tim Horton
Comment 2
2019-04-22 14:00:22 PDT
<
rdar://problem/49064839
>
Ryosuke Niwa
Comment 3
2019-04-23 13:44:57 PDT
Comment on
attachment 367971
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=367971&action=review
> Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.h:54 > + AttributedString annotatedSubstringBetweenPositions(WebCore::VisiblePosition, WebCore::VisiblePosition);
Use const &?
> Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.mm:171 > + RefPtr<Document> document = start.deepEquivalent().document();
makeRefPtr?
> Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.mm:185 > + RefPtr<Range> currentTextRange = it.range();
It's expensive to create range. Do this after the continue below.
> Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.mm:190 > + [string replaceCharactersInRange:NSMakeRange(stringLength, 0) withString:it.text().createNSStringWithoutCopying().get()];
Why not just appendString?
> Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.mm:202 > + auto subrange = TextIterator::subrange(*currentTextRange, marker->startOffset(), marker->endOffset() - marker->startOffset()); > + > + size_t subrangeLocation; > + size_t subrangeLength; > + TextIterator::getLocationAndLengthFromRange(commonAncestor.get(), &subrange.get(), subrangeLocation, subrangeLength);
This is a pretty bad o(n^2)...
Chris Dumez
Comment 4
2019-04-23 13:46:40 PDT
Comment on
attachment 367971
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=367971&action=review
>> Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.mm:171 >> + RefPtr<Document> document = start.deepEquivalent().document(); > > makeRefPtr?
What's the benefit?
Tim Horton
Comment 5
2019-04-23 15:41:46 PDT
(In reply to Ryosuke Niwa from
comment #3
)
> Comment on
attachment 367971
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=367971&action=review
>
> > Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.mm:202 > > + auto subrange = TextIterator::subrange(*currentTextRange, marker->startOffset(), marker->endOffset() - marker->startOffset()); > > + > > + size_t subrangeLocation; > > + size_t subrangeLength; > > + TextIterator::getLocationAndLengthFromRange(commonAncestor.get(), &subrange.get(), subrangeLocation, subrangeLength); > > This is a pretty bad o(n^2)...
Yeah this whole thing is awful. Is there a straightforward better way, though?
Tim Horton
Comment 6
2019-04-23 16:18:57 PDT
Created
attachment 368079
[details]
Patch
WebKit Commit Bot
Comment 7
2019-04-23 16:46:51 PDT
Comment on
attachment 368079
[details]
Patch Clearing flags on attachment: 368079 Committed
r244570
: <
https://trac.webkit.org/changeset/244570
>
WebKit Commit Bot
Comment 8
2019-04-23 16:46:53 PDT
All reviewed patches have been landed. Closing bug.
Ryosuke Niwa
Comment 9
2019-04-23 21:02:53 PDT
(In reply to Chris Dumez from
comment #4
)
> Comment on
attachment 367971
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=367971&action=review
> > >> Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.mm:171 > >> + RefPtr<Document> document = start.deepEquivalent().document(); > > > > makeRefPtr? > > What's the benefit?
The benefit is that we can use auto as in: auto document = makeRefPtr(start.deepEquivalent().document());
Chris Dumez
Comment 10
2019-04-24 08:48:40 PDT
(In reply to Ryosuke Niwa from
comment #9
)
> (In reply to Chris Dumez from
comment #4
) > > Comment on
attachment 367971
[details]
> > Patch > > > > View in context: > >
https://bugs.webkit.org/attachment.cgi?id=367971&action=review
> > > > >> Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.mm:171 > > >> + RefPtr<Document> document = start.deepEquivalent().document(); > > > > > > makeRefPtr? > > > > What's the benefit? > > The benefit is that we can use auto as in: > auto document = makeRefPtr(start.deepEquivalent().document());
ah, with "auto". I get it now :)
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug