Bug 107831 - [chromium] Make selection handling work in applyPageScaleInCompositor mode
Summary: [chromium] Make selection handling work in applyPageScaleInCompositor mode
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-24 08:20 PST by Chris Hopman
Modified: 2013-01-31 12:57 PST (History)
6 users (show)

See Also:


Attachments
Patch (6.19 KB, patch)
2013-01-24 08:29 PST, Chris Hopman
no flags Details | Formatted Diff | Diff
Patch (3.07 KB, patch)
2013-01-30 16:44 PST, Chris Hopman
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Hopman 2013-01-24 08:20:00 PST
Make selection handling work in applyPageScaleInCompositor mode
Comment 1 Chris Hopman 2013-01-24 08:29:48 PST
Created attachment 184508 [details]
Patch
Comment 2 James Robinson 2013-01-30 15:05:58 PST
I'm not terribly familiar with editing code.  What bug does this fix and what tests cover that bug?
Comment 3 Ryosuke Niwa 2013-01-30 15:08:23 PST
Comment on attachment 184508 [details]
Patch

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

> Source/WebKit/chromium/src/WebFrameImpl.cpp:1386
> +    if (frame()->page()->settings()->applyPageScaleFactorInCompositor()) {
> +        unscaledBase.x /= view()->pageScaleFactor();
> +        unscaledBase.y /= view()->pageScaleFactor();
> +        unscaledExtent.x /= view()->pageScaleFactor();
> +        unscaledExtent.y /= view()->pageScaleFactor();
> +    }
> +    VisiblePosition basePosition = visiblePositionForWindowPoint(unscaledBase);
> +    VisiblePosition extentPosition = visiblePositionForWindowPoint(unscaledExtent);

There got to be a better way of achieving this. At minimum, we should have some helper function that automatically scale both x and y.
Comment 4 Chris Hopman 2013-01-30 16:44:53 PST
Created attachment 185621 [details]
Patch
Comment 5 Chris Hopman 2013-01-30 16:47:29 PST
Comment on attachment 184508 [details]
Patch

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

>> Source/WebKit/chromium/src/WebFrameImpl.cpp:1386
>> +    VisiblePosition extentPosition = visiblePositionForWindowPoint(unscaledExtent);
> 
> There got to be a better way of achieving this. At minimum, we should have some helper function that automatically scale both x and y.

Changed this to convert to IntPoint earlier and can then use IntPoint::scale. I was surprised that WebPoint had no way to scale, but I like this better anyway since I now don't need the conversion when calling windowToContents.
Comment 6 Chris Hopman 2013-01-30 16:51:21 PST
I changed this to only convert the points passed to ::selectRange and ::moveCaret[...], I'll handle the points sent back in selectionBounds separately. The issue here is that these functions take window points which, when applying the page scale factor in the compositor, need to be unscaled by the page scale factor when being passed in to WebKit.

As mentioned in https://bugs.webkit.org/show_bug.cgi?id=108386 I think we will have to move to having points be passed in to WebKit and returned from WebKit in document space so that we don't have to do this conversion from the two different "window" spaces.
Comment 7 Ryosuke Niwa 2013-01-30 20:18:11 PST
Comment on attachment 185621 [details]
Patch

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

> Source/WebKit/chromium/src/WebFrameImpl.cpp:1386
> +    if (frame()->page()->settings()->applyPageScaleFactorInCompositor()) {
> +        unscaledExtent.scale(1 / view()->pageScaleFactor(), 1 / view()->pageScaleFactor());
> +        unscaledBase.scale(1 / view()->pageScaleFactor(), 1 / view()->pageScaleFactor());
> +    }

I think you should be calling visibleContentScaleFactor() instead since frame's page scaling factor is not necessarily equal to view's page scaling factor. See ScrollView::visibleContentRect for example.
Comment 8 Alexandre Elias 2013-01-30 20:36:28 PST
I think pageScaleFactor is correct as we're first converting from physical window point to CSS-space window point, and then to the frame's coordinate space.  But please try on a page with a frame to make sure.
Comment 9 Chris Hopman 2013-01-31 09:00:41 PST
(In reply to comment #8)
> I think pageScaleFactor is correct as we're first converting from physical window point to CSS-space window point, and then to the frame's coordinate space.  But please try on a page with a frame to make sure.

This works correctly within a frame.
Comment 10 Alexandre Elias 2013-01-31 11:39:53 PST
LGTM.  Adam?

For context, although we no longer this kind of conversion when going from WebCore to Javascript, we now need it for input-eventy things from coming from the browser to WebCore.
Comment 11 Ryosuke Niwa 2013-01-31 12:04:19 PST
Comment on attachment 185621 [details]
Patch

Okay. We need to come up with a better strategy in the long term though and it sounds like you already know what needs to happen.
Comment 12 WebKit Review Bot 2013-01-31 12:57:08 PST
Comment on attachment 185621 [details]
Patch

Clearing flags on attachment: 185621

Committed r141470: <http://trac.webkit.org/changeset/141470>
Comment 13 WebKit Review Bot 2013-01-31 12:57:12 PST
All reviewed patches have been landed.  Closing bug.