Bug 171453

Summary: On-screen panel for candidate bar is in the wrong place when the caret is at the start of a paragraph
Product: WebKit Reporter: Beth Dakin <bdakin>
Component: WebKit Misc.Assignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: bdakin, enrica, thorton, wenson_hsieh, zalan
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
thorton: review+
Patch+test thorton: review+

Description Beth Dakin 2017-04-28 15:21:35 PDT
On-screen panel for candidate bar is in the wrong place when the caret is at the start of a paragraph

1. Load any web page with a contenteditable field on a Mac with TouchBar.
2. Click on the editable field so that there is a caret at the beginning but no content yet.
3. Tap and hold on a typing suggestion in the TouchBar.

Expected: There is onscreen UI just belown the blinking caret.
Actual: There is onscreen UI that is arbitrarily far from caret.

This bug only happens when the caret is at the beginning of the paragraph, and it seems to be becuase Range::absoluteTextQuads() returns no quads in this case.
Comment 1 Beth Dakin 2017-04-28 15:22:09 PDT
rdar://problem/29779764
Comment 2 Beth Dakin 2017-04-28 15:31:25 PDT
Created attachment 308602 [details]
Patch
Comment 3 Tim Horton 2017-04-28 15:34:46 PDT
Comment on attachment 308602 [details]
Patch

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

No test? :)

> Source/WebKit2/ChangeLog:13
> +        is because Range::absoluteTextQuads() returns no quads in this case. I think it 
> +        might be correct that absoluteTextQuads() returns no quads in this case, so this 

Should check with Zalan to see if he thinks this is actually correct or a deeper bug.
Comment 4 Beth Dakin 2017-04-28 16:32:52 PDT
Created attachment 308613 [details]
Patch+test
Comment 5 Tim Horton 2017-04-28 16:34:17 PDT
Comment on attachment 308613 [details]
Patch+test

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

> Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewCandidateTests.mm:250
> +    EXPECT_EQ(194, candidateRect.origin.y);

Will this change if the font changes? That might be annoying. Could use JS to get the real number, or use Ahem, or ...
Comment 6 zalan 2017-04-28 19:05:32 PDT
(In reply to Tim Horton from comment #3)
> Comment on attachment 308602 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=308602&action=review
> 
> No test? :)
> 
> > Source/WebKit2/ChangeLog:13
> > +        is because Range::absoluteTextQuads() returns no quads in this case. I think it 
> > +        might be correct that absoluteTextQuads() returns no quads in this case, so this 
> 
> Should check with Zalan to see if he thinks this is actually correct or a
> deeper bug.
The editable element is super empty, so there's nothing to return.
Comment 7 Beth Dakin 2017-05-01 10:37:18 PDT
https://trac.webkit.org/changeset/216018/webkit