Bug 132372 - Phone number data detection UI is offset for iframes, pages with topContentInset
Summary: Phone number data detection UI is offset for iframes, pages with topContentInset
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2014-04-29 19:55 PDT by Beth Dakin
Modified: 2014-04-30 15:47 PDT (History)
4 users (show)

See Also:


Attachments
Patch (2.27 KB, text/plain)
2014-04-29 20:00 PDT, Beth Dakin
no flags Details
Patch (3.01 KB, patch)
2014-04-29 20:07 PDT, Beth Dakin
simon.fraser: review-
Details | Formatted Diff | Diff
Document overlay patch (3.10 KB, patch)
2014-04-30 15:02 PDT, Beth Dakin
thorton: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Beth Dakin 2014-04-29 19:55:31 PDT
Phone number data detection UI is offset for iframes and pages with topContentInset. The right coordinate math is not happening.

<rdar://problem/16651235>
Comment 1 Beth Dakin 2014-04-29 20:00:05 PDT
Created attachment 230451 [details]
Patch
Comment 2 Beth Dakin 2014-04-29 20:05:41 PDT
Comment on attachment 230451 [details]
Patch

Wait, missing one thing.
Comment 3 Beth Dakin 2014-04-29 20:07:42 PDT
Created attachment 230452 [details]
Patch
Comment 4 Simon Fraser (smfr) 2014-04-29 20:45:37 PDT
Comment on attachment 230452 [details]
Patch

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

> Source/WebKit2/WebProcess/WebPage/mac/TelephoneNumberOverlayControllerMac.mm:77
> +        IntPoint frameOffset(frame->view()->scrollOffset().width(), frame->view()->scrollOffset().height());
> +        offset.move(frameOffset.x(), frameOffset.y());
> +        offset = frame->view()->contentsToRootView(offset);

contentsToRootView() already subtracts the scrollOffset, so I'm not sure why you have to do it manually here.
Comment 5 Beth Dakin 2014-04-29 21:31:34 PDT
(In reply to comment #4)
> (From update of attachment 230452 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=230452&action=review
> 
> > Source/WebKit2/WebProcess/WebPage/mac/TelephoneNumberOverlayControllerMac.mm:77
> > +        IntPoint frameOffset(frame->view()->scrollOffset().width(), frame->view()->scrollOffset().height());
> > +        offset.move(frameOffset.x(), frameOffset.y());
> > +        offset = frame->view()->contentsToRootView(offset);
> 
> contentsToRootView() already subtracts the scrollOffset, so I'm not sure why you have to do it manually here.

Hmm, you're right. This is kind of a hack I guess. The original offset value is not actually a contents point because it already factors in the scroll position, so I was factoring it out only to get contentsToRootView() to work correctly and factor it back in.

Using Widget::convertToRootView() does the right thing for frames and subframes, but that leaves overflow areas broken. 

I'm torn about defending the hack vs. finding a better solution. Will think on this a bit more.
Comment 6 Brady Eidson 2014-04-30 09:22:09 PDT
For the selection overlay controller, Tim mentioned the new PageOverlay type "PageOverlay::OverlayType::Document" that supposedly handles scrolling automatically.

Tim, do you think switching over to PageOverlay::OverlayType::Document here would just make this class of bug disappear?
Comment 7 Darin Adler 2014-04-30 09:28:44 PDT
Comment on attachment 230452 [details]
Patch

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

> Source/WebKit2/WebProcess/WebPage/mac/TelephoneNumberOverlayControllerMac.mm:73
> +        Frame* frame = range->ownerDocument().frame();

The code below uses FrameView, not Frame, so I suggest putting that into a local variable. Also, I suggest using a reference, not a pointer.

> Source/WebKit2/WebProcess/WebPage/mac/TelephoneNumberOverlayControllerMac.mm:76
> +        IntPoint frameOffset(frame->view()->scrollOffset().width(), frame->view()->scrollOffset().height());
> +        offset.move(frameOffset.x(), frameOffset.y());

From a micro-code-structure point of view, this can just be:

    offset.move(view.scrollOffset());

There’s no need to convert the IntSize to an IntPoint since IntPoint::move already takes an IntSize. That’s separate from the question you are discussing with Simon about whether this is OK.

I fact, again ignoring the correctness of the coordinate math that you are discussing with Simon, I think this 6-line snippet can be written like in two lines like this:

    FrameView& view = *range->ownerDocument().view();
    rect.setLocation(view.contentsToRootView(rect.location() + view.scrollOffset()));
Comment 8 Tim Horton 2014-04-30 11:24:53 PDT
(In reply to comment #6)
> For the selection overlay controller, Tim mentioned the new PageOverlay type "PageOverlay::OverlayType::Document" that supposedly handles scrolling automatically.
> 
> Tim, do you think switching over to PageOverlay::OverlayType::Document here would just make this class of bug disappear?

Not a chance. It will make the topContentInset bug disappear, but for subframes you still need to do something yourself.
Comment 9 Simon Fraser (smfr) 2014-04-30 11:43:59 PDT
Comment on attachment 230452 [details]
Patch

I think we decided that we should use document overlays for this, which affects the coordinate math.
Comment 10 Beth Dakin 2014-04-30 15:02:49 PDT
Created attachment 230526 [details]
Document overlay patch
Comment 11 Tim Horton 2014-04-30 15:36:01 PDT
Comment on attachment 230526 [details]
Document overlay patch

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

> Source/WebKit2/WebProcess/WebPage/mac/TelephoneNumberOverlayControllerMac.mm:75
> +        rect.setLocation(mainFrameView.convertChildToSelf(viewForRange, rect.location()));

What happens with transformed frames/overflow scroll/etc.? We might need FIXMEs about those things?
Comment 12 Beth Dakin 2014-04-30 15:47:16 PDT
Thanks Tim! http://trac.webkit.org/changeset/168053