WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
214331
Should represent `TextPlaceholderElement` as an `NSTextAttachmentCharacter` instead of a `\n`
https://bugs.webkit.org/show_bug.cgi?id=214331
Summary
Should represent `TextPlaceholderElement` as an `NSTextAttachmentCharacter` i...
Devin Rousso
Reported
2020-07-14 16:24:19 PDT
This can muck with whitespace addition/removal with iOS smart editing.
Attachments
Patch
(13.13 KB, patch)
2020-07-14 16:50 PDT
,
Devin Rousso
no flags
Details
Formatted Diff
Diff
Patch
(14.41 KB, patch)
2020-07-14 17:46 PDT
,
Devin Rousso
no flags
Details
Formatted Diff
Diff
Patch
(14.41 KB, patch)
2020-07-14 17:52 PDT
,
Devin Rousso
no flags
Details
Formatted Diff
Diff
Patch
(11.81 KB, patch)
2020-07-14 18:49 PDT
,
Devin Rousso
no flags
Details
Formatted Diff
Diff
Patch
(12.89 KB, patch)
2020-07-15 10:28 PDT
,
Devin Rousso
no flags
Details
Formatted Diff
Diff
Patch
(13.27 KB, patch)
2020-07-15 12:47 PDT
,
Devin Rousso
no flags
Details
Formatted Diff
Diff
Show Obsolete
(5)
View All
Add attachment
proposed patch, testcase, etc.
Devin Rousso
Comment 1
2020-07-14 16:41:09 PDT
<
rdar://problem/64779558
>
Devin Rousso
Comment 2
2020-07-14 16:50:56 PDT
Created
attachment 404306
[details]
Patch
Devin Rousso
Comment 3
2020-07-14 17:46:04 PDT
Created
attachment 404311
[details]
Patch
Devin Rousso
Comment 4
2020-07-14 17:52:22 PDT
Created
attachment 404312
[details]
Patch ... stupid semicolons (╯°□°)╯︵ ┻━┻
Wenson Hsieh
Comment 5
2020-07-14 17:55:35 PDT
Comment on
attachment 404311
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=404311&action=review
> Source/WebCore/editing/TextIterator.cpp:807 > +static bool shouldEmitReplacementInsteadOfNode(Node& node)
This should probably take `const Node&` as the argument type.
> Source/WebCore/editing/TextIterator.cpp:851 > + // Placeholders should eventually disappear, so treating them as a line break doesn't make sense > + // as when they are removed the text after it is combined with the text before it.
Nit - I think this comment would be more effective inside `shouldEmitReplacementInsteadOfNode`, since that is where the notion of “emitting replacement characters instead of nodes" becomes relevant to `TextPlaceholderElement`.
> Source/WebKit/UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h:61 > +- (void)_insertTextPlaceholderWithSize:(CGSize)size completionHandler:(void (^)(UITextPlaceholder *))completionHandler; > +- (void)_removeTextPlaceholder:(UITextPlaceholder *)placeholder willInsertText:(BOOL)willInsertText completionHandler:(void (^)(void))completionHandler;
Nit - I think you could actually omit this extra plumbing on WKWebView, and just use -textInputContentView instead to grab the WKContentView (exposed as a <UIWKInteractionViewProtocol>-conformant responder).
> Source/WebKit/UIProcess/API/ios/WKWebViewTestingIOS.mm:117 > +- (void)_insertTextPlaceholderWithSize:(CGSize)size completionHandler:(void (^)(UITextPlaceholder *))completionHandler > +{ > + [_contentView insertTextPlaceholderWithSize:size completionHandler:completionHandler]; > +} > + > +- (void)_removeTextPlaceholder:(UITextPlaceholder *)placeholder willInsertText:(BOOL)willInsertText completionHandler:(void (^)(void))completionHandler > +{ > + [_contentView removeTextPlaceholder:placeholder willInsertText:willInsertText completionHandler:completionHandler]; > +} > +
(Ditto)
> Tools/TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm:863 > + auto* placeholder = [webView synchronouslyInsertTextPlaceholderWithSize:CGSizeMake(5, 5)];
Nit - the * should be on the other side here. But also, we can just use `auto` for these.
> Tools/TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm:880 > + auto* placeholder = [webView synchronouslyInsertTextPlaceholderWithSize:CGSizeMake(5, 5)];
Ditto.
Wenson Hsieh
Comment 6
2020-07-14 18:15:33 PDT
Comment on
attachment 404312
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=404312&action=review
> Source/WebKit/Platform/spi/ios/UIKitSPI.h:708 > +- (void)insertTextPlaceholderWithSize:(CGSize)size completionHandler:(void (^)(UITextPlaceholder *))completionHandler; > +- (void)removeTextPlaceholder:(UITextPlaceholder *)placeholder willInsertText:(BOOL)willInsertText completionHandler:(void (^)(void))completionHandler;
This should also go inside the `@optional` section, to match the actual SPI header.
Devin Rousso
Comment 7
2020-07-14 18:49:05 PDT
Comment on
attachment 404311
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=404311&action=review
>> Source/WebCore/editing/TextIterator.cpp:807 >> +static bool shouldEmitReplacementInsteadOfNode(Node& node) > > This should probably take `const Node&` as the argument type.
I was matching the other `shouldEmit*` functions, but yeah I could do that.
Devin Rousso
Comment 8
2020-07-14 18:49:56 PDT
Created
attachment 404314
[details]
Patch
Devin Rousso
Comment 9
2020-07-15 10:28:53 PDT
Created
attachment 404355
[details]
Patch
Wenson Hsieh
Comment 10
2020-07-15 11:37:04 PDT
Comment on
attachment 404355
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=404355&action=review
> Source/WebCore/ChangeLog:9 > + Reviewed by NOBODY (OOPS!). > + > + * editing/TextIterator.cpp:
It would be nice to have a few words here to explain why we want to emit the replacement character instead of a newline (something similar to what you already wrote in the comment below).
Devin Rousso
Comment 11
2020-07-15 12:47:40 PDT
Created
attachment 404376
[details]
Patch
EWS
Comment 12
2020-07-15 14:16:00 PDT
Committed
r264420
: <
https://trac.webkit.org/changeset/264420
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 404376
[details]
.
Darin Adler
Comment 13
2020-07-15 14:40:22 PDT
Comment on
attachment 404376
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=404376&action=review
> Source/WebCore/editing/TextIterator.cpp:1014 > + emitCharacter(0xFFFC, *m_node->parentNode(), m_node, 0, 0);
Should write: objectReplacementCharacter Instead of: 0xFFFC It’s in the header CharacterNames.h.
Devin Rousso
Comment 14
2020-07-15 15:44:58 PDT
Comment on
attachment 404376
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=404376&action=review
>> Source/WebCore/editing/TextIterator.cpp:1014 >> + emitCharacter(0xFFFC, *m_node->parentNode(), m_node, 0, 0); > > Should write: > > objectReplacementCharacter > > Instead of: > > 0xFFFC > > It’s in the header CharacterNames.h.
Oh neat! I did not know that existed :) Will land a followup.
Devin Rousso
Comment 15
2020-07-15 17:37:31 PDT
Committed
r264439
: Unreviewed followup, use objectReplacementCharacter instead of 0xFFFC
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