Bug 94355 - [chromium] Enhance support for transforms in LinkHighlight.
Summary: [chromium] Enhance support for transforms in LinkHighlight.
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: W. James MacLean
URL:
Keywords:
Depends on: 84487
Blocks:
  Show dependency treegraph
 
Reported: 2012-08-17 09:50 PDT by W. James MacLean
Modified: 2012-10-05 14:22 PDT (History)
5 users (show)

See Also:


Attachments
Patch (63.06 KB, patch)
2012-08-27 12:45 PDT, W. James MacLean
no flags Details | Formatted Diff | Diff
Patch (77.28 KB, patch)
2012-09-10 15:52 PDT, W. James MacLean
no flags Details | Formatted Diff | Diff
Patch (87.59 KB, patch)
2012-10-03 16:30 PDT, W. James MacLean
no flags Details | Formatted Diff | Diff
Patch for landing (87.59 KB, patch)
2012-10-05 12:04 PDT, W. James MacLean
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description W. James MacLean 2012-08-17 09:50:12 PDT
At present, LinkHighlight does not correctly handle all transforms (notably rotation, but in some cases scale).
Comment 1 Alexandre Elias 2012-08-17 11:30:54 PDT
OK, we may need this to use on Android in the short term, as page scale is currently a transform.  What are the cases where scale is not applied correctly?
Comment 2 W. James MacLean 2012-08-17 11:37:38 PDT
(In reply to comment #1)
> OK, we may need this to use on Android in the short term, as page scale is currently a transform.  What are the cases where scale is not applied correctly?

This patch will land shortly after 84487 ... we just need to update so we transform quad points instead of a rect. Right now applying sclaeX or scaleY may cause the highlight to be slightly off in it's positioning.
Comment 3 Alexandre Elias 2012-08-17 11:39:19 PDT
OK, thanks.  It's fine to land the other one first, just so long as we follow up on this.
Comment 4 W. James MacLean 2012-08-17 11:44:37 PDT
(In reply to comment #3)
> OK, thanks.  It's fine to land the other one first, just so long as we follow up on this.

This should be done *very soon* after the first one lands :-)
Comment 5 W. James MacLean 2012-08-27 12:45:41 PDT
Created attachment 160783 [details]
Patch

This CL extends the current link highlighter to account for transformed targets. Transformed links will be represented by a rectilinear bounding box (at present), but transformed divs will be highlighted according to their borders. This CL also improves path specificity by using the quad list inside the target, as opposed to the target's bounding box.
Comment 6 James Robinson 2012-09-04 10:26:12 PDT
Comment on attachment 160783 [details]
Patch

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

Close - I think it needs a bit more polish, though.

> Source/WebKit/chromium/src/LinkHighlight.cpp:144
> +static void convertPointsTargetToCompositedLayer(const Vector<IntPoint>& vector, RenderObject* targetRenderer, RenderObject* compositedRenderer, Vector<FloatPoint>& outVector)

vector / outVector aren't great variable names - can you name them for the data they represent?

> Source/WebKit/chromium/src/LinkHighlight.cpp:161
> +static void addQuadToPath(const Vector<FloatPoint>&quad, Path& path)

space between & and quad

> Source/WebKit/chromium/src/LinkHighlight.cpp:163
> +    // FIXME: Make this create rounded rectangles, just like the axis-aligned case.

Path has an addPathForRoundedRect, if it's useful

> Source/WebKit/chromium/src/LinkHighlight.cpp:176
> +    // FIXME: find way to compare highlight paths, or get rid of the return value for this function.

SkPath has an operator==. I think you should resolve this fixme one way or the other in this patch - there's no real value in leaving this in such a weird state when all changes will be internal to this file.

> Source/WebKit/chromium/src/LinkHighlight.cpp:192
> +        boundingQuad.append(roundedIntPoint(quads[quadIndex].p1()));

rounded points aren't necessarily bounding, so either the code or the variable name is wrong here. Do you want FloatQuad::enclosingBoundingBox(), perhaps?
Comment 7 W. James MacLean 2012-09-10 15:52:21 PDT
Created attachment 163237 [details]
Patch

(In reply to comment #6)
> (From update of attachment 160783 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=160783&action=review
> 
> Close - I think it needs a bit more polish, though.
> 
> > Source/WebKit/chromium/src/LinkHighlight.cpp:144
> > +static void convertPointsTargetToCompositedLayer(const Vector<IntPoint>& vector, RenderObject* targetRenderer, RenderObject* compositedRenderer, Vector<FloatPoint>& outVector)
> 
> vector / outVector aren't great variable names - can you name them for the data they represent?

Fixed.

> > Source/WebKit/chromium/src/LinkHighlight.cpp:161
> > +static void addQuadToPath(const Vector<FloatPoint>&quad, Path& path)
> 
> space between & and quad

Fixed.

> > Source/WebKit/chromium/src/LinkHighlight.cpp:163
> > +    // FIXME: Make this create rounded rectangles, just like the axis-aligned case.
> 
> Path has an addPathForRoundedRect, if it's useful

Hmmm, I don't think it helps ... it takes a rect as input, and not a quad, so it seems it only helps with axis-aligned quads.

> > Source/WebKit/chromium/src/LinkHighlight.cpp:176
> > +    // FIXME: find way to compare highlight paths, or get rid of the return value for this function.
> 
> SkPath has an operator==. I think you should resolve this fixme one way or the other in this patch - there's no real value in leaving this in such a weird state when all changes will be internal to this file.

Had to wait for a Skia patch to land before I could follow up with this patch. The == operator is used within skia, and based on initial testing seems to do what we want.

> > Source/WebKit/chromium/src/LinkHighlight.cpp:192
> > +        boundingQuad.append(roundedIntPoint(quads[quadIndex].p1()));
> 
> rounded points aren't necessarily bounding, so either the code or the variable name is wrong here. Do you want FloatQuad::enclosingBoundingBox(), perhaps?

It's not critical that it be a bounding box, and it keeps the code simpler to just use rounded points, so for now I'm just using the rounded points and have renamed the variable.

I've also remove the ZIndex test, as it seems that applying a 2-D rotation kills the auto zIndex property of the target, thus rendering rotated divs non-highlightable.
Comment 8 Adrienne Walker 2012-10-01 15:38:59 PDT
Comment on attachment 163237 [details]
Patch

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

> Source/WebKit/chromium/src/LinkHighlight.cpp:146
> +static void convertPointsTargetToCompositedLayer(const Vector<IntPoint>& targetSpacePoints, RenderObject* targetRenderer, RenderObject* compositedRenderer, Vector<FloatPoint>& compositedSpacePoints)

Do you need to use so many vectors here? Why not input a FloatQuad (and round it here) and output a FloatQuad?

> Source/WebKit/chromium/src/LinkHighlight.cpp:207
> +        if (quads.size() == 1 && quad.isRectilinear()) {
> +            FloatSize rectRoundingRadii(3, 3);
> +            newPath.addRoundedRect(quad.boundingBox(), rectRoundingRadii);
> +        } else
> +            addQuadToPath(transformedQuad, newPath);

Do the existing tests hit both of these cases?

> Source/WebKit/chromium/src/WebViewImpl.cpp:1166
>      // If the document has click handlers installed, we don't want to default to applying the highlight to the entire RenderView, or the
>      // entire body. Also, if the node has non-auto Z-index, we cannot be sure of it's ordering with respect to other possible target nodes.
>      RenderObject* touchNodeRenderer = bestTouchNode ? bestTouchNode->renderer() : 0;
> -    if (bestTouchNode && (!touchNodeRenderer || touchNodeRenderer->isRenderView() || touchNodeRenderer->isBody() || !touchNodeRenderer->style()->hasAutoZIndex()))
> +    if (bestTouchNode && (!touchNodeRenderer || touchNodeRenderer->isRenderView() || touchNodeRenderer->isBody()))

I don't understand this change or why the comment has been left unchanged.  Also, s/it's/its/.
Comment 9 W. James MacLean 2012-10-03 16:13:13 PDT
Comment on attachment 163237 [details]
Patch

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

>> Source/WebKit/chromium/src/LinkHighlight.cpp:146
>> +static void convertPointsTargetToCompositedLayer(const Vector<IntPoint>& targetSpacePoints, RenderObject* targetRenderer, RenderObject* compositedRenderer, Vector<FloatPoint>& compositedSpacePoints)
> 
> Do you need to use so many vectors here? Why not input a FloatQuad (and round it here) and output a FloatQuad?

Originally I had expected we'd need to transform arbitrary polygons, and there might be some benefit to doing it this way. Also, it irks me to no end that FloatPoint doesn't have an index operator ;-)

Vectors removed.

>> Source/WebKit/chromium/src/LinkHighlight.cpp:207
>> +            addQuadToPath(transformedQuad, newPath);
> 
> Do the existing tests hit both of these cases?

Sorry, no; will add a multi-quad test in new patch.

>> Source/WebKit/chromium/src/WebViewImpl.cpp:1166
>> +    if (bestTouchNode && (!touchNodeRenderer || touchNodeRenderer->isRenderView() || touchNodeRenderer->isBody()))
> 
> I don't understand this change or why the comment has been left unchanged.  Also, s/it's/its/.

The comment should have been updated (strange about "it's", I don't usually mix those up ;-) ).

We had originally opted out of highlighting any node with non-auto Z-index, primarily to match what Clank is doing. However, it seems this is not necessary, and it interferes with properly highlighting rotated elements.
Comment 10 W. James MacLean 2012-10-03 16:30:15 PDT
Created attachment 166988 [details]
Patch
Comment 11 Adrienne Walker 2012-10-04 10:23:24 PDT
Comment on attachment 166988 [details]
Patch

Why are all the tests in platform/chromium-linux?
Comment 12 W. James MacLean 2012-10-04 11:24:44 PDT
(In reply to comment #11)
> (From update of attachment 166988 [details])
> Why are all the tests in platform/chromium-linux?

At present this is only turned on for ChromeOS. The plan is to get the behaviour right, then turn it on for Win8 as well, at which time we will re-structure the same tests to run on both.

Right now, this is disabled by default on ChromeOS and enabled via a flag.
Comment 13 Adrienne Walker 2012-10-05 11:10:37 PDT
(In reply to comment #12)
> (In reply to comment #11)
> > (From update of attachment 166988 [details] [details])
> > Why are all the tests in platform/chromium-linux?
> 
> At present this is only turned on for ChromeOS. The plan is to get the behaviour right, then turn it on for Win8 as well, at which time we will re-structure the same tests to run on both.
> 
> Right now, this is disabled by default on ChromeOS and enabled via a flag.

Huh.  Where is this flag set?  Why would this test not run on other platforms?
Comment 14 W. James MacLean 2012-10-05 11:17:26 PDT
(In reply to comment #13)
> (In reply to comment #12)
> > (In reply to comment #11)
> > > (From update of attachment 166988 [details] [details] [details])
> > > Why are all the tests in platform/chromium-linux?
> > 
> > At present this is only turned on for ChromeOS. The plan is to get the behaviour right, then turn it on for Win8 as well, at which time we will re-structure the same tests to run on both.
> > 
> > Right now, this is disabled by default on ChromeOS and enabled via a flag.
> 
> Huh.  Where is this flag set?  Why would this test not run on other platforms?

It's set via compiler define in WebViewImpl::handleGestureEvent(), and also requires --enable-touch-events (since otherwise GestureTapDown won't be sent). The tests should in theory run elsewhere, but during the dogfood phase we chose to just run them on Linux.

The question of where the tests run is a little moot at present, since they got turned off (temporarily) in https://bugs.webkit.org/show_bug.cgi?id=96951, although the root cause doesn't seem to be the highlighting code based on our investigations thus far.
Comment 15 W. James MacLean 2012-10-05 11:20:23 PDT
(In reply to comment #13)
> (In reply to comment #12)
> > (In reply to comment #11)
> > > (From update of attachment 166988 [details] [details] [details])
> > > Why are all the tests in platform/chromium-linux?
> > 
> > At present this is only turned on for ChromeOS. The plan is to get the behaviour right, then turn it on for Win8 as well, at which time we will re-structure the same tests to run on both.
> > 
> > Right now, this is disabled by default on ChromeOS and enabled via a flag.
> 
> Huh.  Where is this flag set?  Why would this test not run on other platforms?

Oh, and it requires --enable-gesture-tap-highlight too ...
Comment 16 Adrienne Walker 2012-10-05 11:31:14 PDT
(In reply to comment #15)
> (In reply to comment #13)
> > (In reply to comment #12)
> > > (In reply to comment #11)
> > > > (From update of attachment 166988 [details] [details] [details] [details])
> > > > Why are all the tests in platform/chromium-linux?
> > > 
> > > At present this is only turned on for ChromeOS. The plan is to get the behaviour right, then turn it on for Win8 as well, at which time we will re-structure the same tests to run on both.
> > > 
> > > Right now, this is disabled by default on ChromeOS and enabled via a flag.
> > 
> > Huh.  Where is this flag set?  Why would this test not run on other platforms?
> 
> Oh, and it requires --enable-gesture-tap-highlight too ...

Where is this set for the tests?

I guess it's just weird for me to see something that's not really platform-specific have tests in a platform-specific directory.
Comment 17 W. James MacLean 2012-10-05 11:41:03 PDT
(In reply to comment #16)
> (In reply to comment #15)
> > (In reply to comment #13)
> > > (In reply to comment #12)
> > > > (In reply to comment #11)
> > > > > (From update of attachment 166988 [details] [details] [details] [details] [details])
> > > > > Why are all the tests in platform/chromium-linux?
> > > > 
> > > > At present this is only turned on for ChromeOS. The plan is to get the behaviour right, then turn it on for Win8 as well, at which time we will re-structure the same tests to run on both.
> > > > 
> > > > Right now, this is disabled by default on ChromeOS and enabled via a flag.
> > > 
> > > Huh.  Where is this flag set?  Why would this test not run on other platforms?
> > 
> > Oh, and it requires --enable-gesture-tap-highlight too ...
> 
> Where is this set for the tests?

Oh, sorry ... thought we were talking about the end-user.

The tests only run on Linux due to the conditional compile on the call to enableTouchHighlight from WebViewImpl::handleGestureEvent(). WebKit turns on highlights by default, but the chrome browser overrides this and turns them off by default. So for DRT they are on by default (but would fail on non-Linux bots due to enableTouchHighlight not being called).

> I guess it's just weird for me to see something that's not really platform-specific have tests in a platform-specific directory.

It is a little weird, and once we're past dogfood I would like to broaden the tests so all platforms run them, though I guess I need to get them re-enabled on Linux first :-)
Comment 18 Adrienne Walker 2012-10-05 11:53:01 PDT
Comment on attachment 166988 [details]
Patch

R=me.  Ok, sure.
Comment 19 W. James MacLean 2012-10-05 12:04:55 PDT
Created attachment 167363 [details]
Patch for landing
Comment 20 WebKit Review Bot 2012-10-05 14:22:10 PDT
Comment on attachment 167363 [details]
Patch for landing

Clearing flags on attachment: 167363

Committed r130551: <http://trac.webkit.org/changeset/130551>
Comment 21 WebKit Review Bot 2012-10-05 14:22:14 PDT
All reviewed patches have been landed.  Closing bug.