Bug 153040

Summary: WK2: Request completion candidates when needed
Product: WebKit Reporter: Beth Dakin <bdakin>
Component: WebKit APIAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: andersca, ap, bdakin, buildbot, commit-queue, enrica, rniwa, sam, thorton
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 153098    
Bug Blocks:    
Attachments:
Description Flags
Patch
buildbot: commit-queue-
Archive of layout-test-results from ews106 for mac-yosemite-wk2
none
Patch
enrica: review+, buildbot: commit-queue-
Archive of layout-test-results from ews103 for mac-yosemite
none
Archive of layout-test-results from ews112 for mac-yosemite
none
Patch thorton: review+

Description Beth Dakin 2016-01-12 14:34:07 PST
WK2: Request completion candidates when needed

rdar://problem/24155631
Comment 1 Beth Dakin 2016-01-12 15:20:38 PST
Created attachment 268818 [details]
Patch
Comment 2 WebKit Commit Bot 2016-01-12 15:22:01 PST
Attachment 268818 [details] did not pass style-queue:


ERROR: Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:2109:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
ERROR: Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:2129:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
Total errors found: 2 in 13 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Build Bot 2016-01-12 16:07:01 PST
Comment on attachment 268818 [details]
Patch

Attachment 268818 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/684120

New failing tests:
fast/dom/focus-contenteditable.html
Comment 4 Build Bot 2016-01-12 16:07:04 PST
Created attachment 268826 [details]
Archive of layout-test-results from ews106 for mac-yosemite-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews106  Port: mac-yosemite-wk2  Platform: Mac OS X 10.10.5
Comment 5 Beth Dakin 2016-01-13 16:01:09 PST
Created attachment 268909 [details]
Patch
Comment 6 WebKit Commit Bot 2016-01-13 16:05:02 PST
Attachment 268909 [details] did not pass style-queue:


ERROR: Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:2109:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
ERROR: Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:2129:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
Total errors found: 2 in 15 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 7 Enrica Casucci 2016-01-13 16:43:22 PST
Comment on attachment 268909 [details]
Patch

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

Looks good to me

> Source/WebCore/editing/Editor.cpp:3553
> +    RefPtr<Range> rangeForCurrentlyTypedString = candidateRangeForSelection(selection, m_frame);

I think you can have only one parameter (m_frame) to this function, since you compute the VisibleSelectionFrom it

> Source/WebCore/editing/Editor.cpp:3563
> +    RefPtr<Range> candidateRange = candidateRangeForSelection(selection, m_frame);

same here.

> Source/WebKit2/ChangeLog:10
> +        Mac need to support postLayoutData in order to have some layout-related 

typo needs
Comment 8 Build Bot 2016-01-13 16:52:32 PST
Comment on attachment 268909 [details]
Patch

Attachment 268909 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/688106

New failing tests:
fast/dom/focus-contenteditable.html
Comment 9 Build Bot 2016-01-13 16:52:35 PST
Created attachment 268916 [details]
Archive of layout-test-results from ews103 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews103  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 10 Build Bot 2016-01-13 17:01:19 PST
Comment on attachment 268909 [details]
Patch

Attachment 268909 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/688104

New failing tests:
fast/dom/focus-contenteditable.html
Comment 11 Build Bot 2016-01-13 17:01:22 PST
Created attachment 268921 [details]
Archive of layout-test-results from ews112 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews112  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 12 Beth Dakin 2016-01-13 17:04:19 PST
Thanks Enrica! Good find. I fixed all three things.

http://trac.webkit.org/changeset/195002
Comment 13 Alexey Proskuryakov 2016-01-13 22:47:21 PST
Comment on attachment 268909 [details]
Patch

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

> Source/WebKit2/Shared/EditorState.cpp:131
> +#if PLATFORM(MAC)
> +    encoder << candidateRequestStartPosition;
> +    encoder << paragraphContextForCandidateRequest;
> +    encoder << stringForCandidateRequest;
> +#endif

EditorState is a very unfortunate hack which cannot possibly result in reliable behavior.

Does the API require synchronous return? Can we request making it asynchronous?
Comment 14 Beth Dakin 2016-01-13 23:08:06 PST
(In reply to comment #13)
> Comment on attachment 268909 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=268909&action=review
> 
> > Source/WebKit2/Shared/EditorState.cpp:131
> > +#if PLATFORM(MAC)
> > +    encoder << candidateRequestStartPosition;
> > +    encoder << paragraphContextForCandidateRequest;
> > +    encoder << stringForCandidateRequest;
> > +#endif
> 
> EditorState is a very unfortunate hack which cannot possibly result in
> reliable behavior.
> 
> Does the API require synchronous return? Can we request making it
> asynchronous?

I was not aware that EditorState is considered a hack! I'm open to other ideas for the best way to implement this. The API does not require synchronous return, but we do need to request candidates on every selection change, and the analogous iOS API is implemented via EditorState, so it seems like a good place for it.
Comment 15 Alexey Proskuryakov 2016-01-14 09:44:22 PST
Yes, let's talk about it today!

This code crashes every time on bots, so I'm going to roll out for now anyway.
Comment 16 WebKit Commit Bot 2016-01-14 09:46:39 PST
Re-opened since this is blocked by bug 153098
Comment 17 Beth Dakin 2016-01-14 09:56:32 PST
(In reply to comment #15)
> Yes, let's talk about it today!
> 
> This code crashes every time on bots, so I'm going to roll out for now
> anyway.

It's fine that this was rolled out, but to be clear, it crashed only one test: imported/blink/editing/text-iterator/read-past-cloned-first-letter.html 

and I was already investigating. My investigation indicates that this is a long-standing bug that we happen to trigger now. Of course I do need to fix it now that new code is triggering it, but I just want to clarify that this is not happening because EditorState is "hacky" or because of any other problem with the patch.
Comment 18 Alexey Proskuryakov 2016-01-14 10:33:20 PST
> it crashed only one test

That's not what I saw on bots, unfortunately.
Comment 19 Beth Dakin 2016-01-14 13:23:25 PST
(In reply to comment #17)
> (In reply to comment #15)
> imported/blink/editing/text-iterator/read-past-cloned-first-letter.html 
> 

I filed https://bugs.webkit.org/show_bug.cgi?id=153104 and uploaded a patch to fix this bug.
Comment 20 Beth Dakin 2016-01-14 14:14:31 PST
Created attachment 269002 [details]
Patch

https://bugs.webkit.org/show_bug.cgi?id=153104 tracks fixing the blink test that crashes because of this patch (the patch has been reviewed and committed), and the crashing internal tests are fixed in this version of the patch.
Comment 21 Beth Dakin 2016-01-14 14:45:55 PST
Thanks Tim! http://trac.webkit.org/changeset/195078

Alexey and I talked, and I have some follow-up tasks to look into having the  API changed a bit, which would let us make something more robust.
Comment 22 Alexey Proskuryakov 2016-01-15 09:14:08 PST
Hmm, not sure why EWS refused to process this patch.
Comment 23 Alexey Proskuryakov 2016-01-15 09:14:54 PST
Ah, that's because it was landed before EWS had a chance to look at it.