Bug 211148 - [iOS] Implement -markedTextRange
Summary: [iOS] Implement -markedTextRange
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, PlatformOnly
Depends on:
Blocks:
 
Reported: 2020-04-28 15:23 PDT by Daniel Bates
Modified: 2020-04-30 09:01 PDT (History)
2 users (show)

See Also:


Attachments
Patch and tests (24.93 KB, patch)
2020-04-28 16:01 PDT, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch and tests (24.93 KB, patch)
2020-04-29 10:06 PDT, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch and tests (27.27 KB, patch)
2020-04-29 15:09 PDT, Daniel Bates
no flags Details | Formatted Diff | Diff
To land (26.80 KB, patch)
2020-04-30 09:00 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-04-28 15:23:09 PDT
Implement -markedTextRange to return the UITextRange for the marked text so that UIKit clients can query for this info.
Comment 1 Daniel Bates 2020-04-28 15:23:35 PDT
<rdar://problem/57865890>
Comment 2 Daniel Bates 2020-04-28 16:01:06 PDT
Created attachment 397896 [details]
Patch and tests
Comment 3 Daniel Bates 2020-04-28 18:10:59 PDT
Comment on attachment 397896 [details]
Patch and tests

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

> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:4126
> +        return markedTextRects.isEmpty() ? CGRectZero : markedTextRects.first().rect();

CGRectZero to match current behavior. Maybe can return RectNull...need to check.

> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:4136
> +        return markedTextRects.isEmpty() ? CGRectZero : markedTextRects.last().rect();

CGRectZero to match current behavior. Maybe can return RectNull...need to check.
Comment 4 Daniel Bates 2020-04-29 10:06:49 PDT
Created attachment 397973 [details]
Patch and tests
Comment 5 Daniel Bates 2020-04-29 15:09:17 PDT
Created attachment 397998 [details]
Patch and tests
Comment 6 Wenson Hsieh 2020-04-29 16:46:23 PDT
Comment on attachment 397998 [details]
Patch and tests

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

> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:4493
> +    if (bool isInHorizontalWritingMode = caretRect.width() < caretRect.height())

I find this variable name a bit misleading, since this isn’t (technically) about writing mode, but the geometry of the caret (i.e. keeping the caret “skinny” in either axis).

> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:4510
> +    if (bool isInHorizontalWritingMode = caretRect.width() < caretRect.height()) {

Ditto.
Comment 7 Daniel Bates 2020-04-30 08:57:51 PDT
Comment on attachment 397998 [details]
Patch and tests

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

>> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:4493
>> +    if (bool isInHorizontalWritingMode = caretRect.width() < caretRect.height())
> 
> I find this variable name a bit misleading, since this isn’t (technically) about writing mode, but the geometry of the caret (i.e. keeping the caret “skinny” in either axis).

Will rename to isHorizontalCaret

FYI I was trying to explain the origin of the "horizontal" or "vertical" caret. It originates from the writing mode! This code will 100% have to change if caret geometry radically changed (e.g. caret becomes a square or something more exotic) and when the geometry becomes ambiguous then the only truth we have is the writing mode. As I write this it dawns on me that there is no point to explain this.... it's obvious + this code is "theme" code.
Comment 8 Daniel Bates 2020-04-30 08:58:07 PDT
Comment on attachment 397998 [details]
Patch and tests

Thanks for the review!
Comment 9 Daniel Bates 2020-04-30 08:59:37 PDT
Comment on attachment 397998 [details]
Patch and tests

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

>>> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:4493
>>> +    if (bool isInHorizontalWritingMode = caretRect.width() < caretRect.height())
>> 
>> I find this variable name a bit misleading, since this isn’t (technically) about writing mode, but the geometry of the caret (i.e. keeping the caret “skinny” in either axis).
> 
> Will rename to isHorizontalCaret
> 
> FYI I was trying to explain the origin of the "horizontal" or "vertical" caret. It originates from the writing mode! This code will 100% have to change if caret geometry radically changed (e.g. caret becomes a square or something more exotic) and when the geometry becomes ambiguous then the only truth we have is the writing mode. As I write this it dawns on me that there is no point to explain this.... it's obvious + this code is "theme" code.

Just for me (because I'm removing this comment before landing):

    // In theory, the writing mode should be sent over with the editor state because
    // the caret could take **any** shape. In practice, the caret is always rectangular
    // and displayed between characters.
Comment 10 Daniel Bates 2020-04-30 09:00:54 PDT
Created attachment 398056 [details]
To land
Comment 11 Daniel Bates 2020-04-30 09:01:17 PDT
Committed r260952: <https://trac.webkit.org/changeset/260952>