Bug 211087

Summary: [iOS] Marked text editor state only needs to be set when layout is up-to-date
Product: WebKit Reporter: Daniel Bates <dbates>
Component: WebKit Misc.Assignee: Daniel Bates <dbates>
Status: RESOLVED FIXED    
Severity: Normal CC: darin, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: iPhone / iPad   
OS: iOS 13   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
To Land
none
To Land
none
To Land
none
To Land
none
To Land
none
To Land
none
To Land none

Daniel Bates
Reported 2020-04-27 11:13:42 PDT
Marked text editor state only needs to be set when layout is up-to-date. The code already ensures this: the caller WebPage::editorState() forces a layout whenever platformNeedsLayoutForEditorState() returns true, which it is if there is a composition. So, this bug is just about categorizing the marked text editor state fields to match what happens today: they are always updated post layout. So, they should be grouped under post-layout data.
Attachments
Patch (13.29 KB, patch)
2020-04-27 11:46 PDT, Daniel Bates
no flags
Patch (12.08 KB, patch)
2020-04-27 11:57 PDT, Daniel Bates
no flags
Patch (12.08 KB, patch)
2020-04-27 11:58 PDT, Daniel Bates
no flags
To Land (12.12 KB, patch)
2020-04-27 12:21 PDT, Daniel Bates
no flags
To Land (16.75 KB, patch)
2020-04-27 14:42 PDT, Daniel Bates
no flags
To Land (16.76 KB, patch)
2020-04-27 14:43 PDT, Daniel Bates
no flags
To Land (16.79 KB, patch)
2020-04-27 14:47 PDT, Daniel Bates
no flags
To Land (16.81 KB, patch)
2020-04-27 16:20 PDT, Daniel Bates
no flags
To Land (16.81 KB, patch)
2020-04-27 16:41 PDT, Daniel Bates
no flags
To Land (18.04 KB, patch)
2020-04-27 16:51 PDT, Daniel Bates
no flags
Daniel Bates
Comment 1 2020-04-27 11:46:33 PDT
Daniel Bates
Comment 2 2020-04-27 11:50:40 PDT
Comment on attachment 397707 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=397707&action=review > Source/WebKit/Shared/EditorState.cpp:287 > - if (editorState.postLayoutData().caretRectAtEnd != IntRect()) > + if (!editorState.postLayoutData().firstMarkedRect.isEmpty()) Note isEmpty() is good enough. It's NOT equivalent to != IntRect(), which compares rect location + rect size.
Daniel Bates
Comment 3 2020-04-27 11:52:52 PDT
Comment on attachment 397707 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=397707&action=review > Source/WebKit/ChangeLog:23 > + am here also replace checks of != IntRect() with IntRect::isEmpty(), which is more canonical. Note isEmpty() is good enough. It's NOT equivalent to != IntRect(), which compares rect location + rect size.
Daniel Bates
Comment 4 2020-04-27 11:55:36 PDT
Comment on attachment 397707 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=397707&action=review >> Source/WebKit/ChangeLog:23 >> + am here also replace checks of != IntRect() with IntRect::isEmpty(), which is more canonical. > > Note isEmpty() is good enough. It's NOT equivalent to != IntRect(), which compares rect location + rect size. Actually, I'm thinking this change is wrong. will revert
Daniel Bates
Comment 5 2020-04-27 11:57:26 PDT
Daniel Bates
Comment 6 2020-04-27 11:58:44 PDT
Darin Adler
Comment 7 2020-04-27 12:06:36 PDT
Comment on attachment 397710 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=397710&action=review > Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:-246 > + // We only set the remaining EditorState entries if layout is done as a performance optimization > + // to avoid the need to force a synchronous layout here to compute these entries. > + if (!view || view->needsLayout() || result.isMissingPostLayoutData) > return; > - } Seems like this only needs to check isMissingPostLayoutData. The other conditions are already guaranteed by the editorState function before this is called. Maybe even change the interface to getPlatformEditorState to make this clearer. Also seems like isMissingPostLayoutData should eventually be dumped and instead we should use Optional for m_postLayoutData. That way the two can’t get out of sync.
Daniel Bates
Comment 8 2020-04-27 12:18:44 PDT
Comment on attachment 397710 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=397710&action=review Thanks for the review. >> Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:-246 >> - } > > Seems like this only needs to check isMissingPostLayoutData. The other conditions are already guaranteed by the editorState function before this is called. Maybe even change the interface to getPlatformEditorState to make this clearer. > > Also seems like isMissingPostLayoutData should eventually be dumped and instead we should use Optional for m_postLayoutData. That way the two can’t get out of sync. Yep and yep. I'll make m_postLayoutData optional in the next patch.
Daniel Bates
Comment 9 2020-04-27 12:21:36 PDT
Daniel Bates
Comment 10 2020-04-27 14:42:12 PDT
Daniel Bates
Comment 11 2020-04-27 14:43:06 PDT
Daniel Bates
Comment 12 2020-04-27 14:47:28 PDT
Daniel Bates
Comment 13 2020-04-27 16:20:31 PDT
Daniel Bates
Comment 14 2020-04-27 16:21:16 PDT
Comment on attachment 397761 [details] To Land View in context: https://bugs.webkit.org/attachment.cgi?id=397761&action=review > Source/WebKit/ChangeLog:34 > + could cause this, but the code currently covers this case. So, taking a RefPtr is about future proofing. RefPtr => Ref
Daniel Bates
Comment 15 2020-04-27 16:41:20 PDT
Daniel Bates
Comment 16 2020-04-27 16:51:14 PDT
EWS
Comment 17 2020-04-28 07:54:56 PDT
Committed r260826: <https://trac.webkit.org/changeset/260826> All reviewed patches have been landed. Closing bug and clearing flags on attachment 397766 [details].
Radar WebKit Bug Importer
Comment 18 2020-04-28 07:55:15 PDT
Note You need to log in before you can comment on or make changes to this bug.