Changeset 130551 in webkit


Ignore:
Timestamp:
Oct 5, 2012, 2:22:18 PM (13 years ago)
Author:
wjmaclean@chromium.org
Message:

[chromium] Enhance support for transforms in LinkHighlight.
https://bugs.webkit.org/show_bug.cgi?id=94355

Reviewed by Adrienne Walker.

Improved handling of transformed highlight targets, where the transform goes beyond simple translation.

Source/WebKit/chromium:

  • src/LinkHighlight.cpp:

(WebKit::convertTargetSpaceQuadToCompositedLayer): Converts target space quad to composited layer coordinates.
(WebKit):
(WebKit::addQuadToPath): Supports adding non-rectilinear quads to Path.
(WebKit::LinkHighlight::computeHighlightLayerPathAndPosition): Updated to deal with target's quadlist, transform individual quads according to transforms.

  • src/WebViewImpl.cpp:

(WebKit::WebViewImpl::bestTouchLinkNode):

LayoutTests:

  • platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-multi-line.html: Added.
  • platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-rotated-div.html: Added.
  • platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-rotated-link.html: Added.
  • platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-scaledX.html: Added.
  • platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-scaledY.html: Added.
  • platform/chromium-linux/platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-ZIndex-expected.png: Removed.
  • platform/chromium-linux/platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-ZIndex-expected.txt: Removed.
  • platform/chromium-linux/platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-multi-line-expected.png: Added.
  • platform/chromium-linux/platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-multi-line-expected.txt: Added.
  • platform/chromium-linux/platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-rotated-div-expected.png: Added.
  • platform/chromium-linux/platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-rotated-div-expected.txt: Added.
  • platform/chromium-linux/platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-rotated-link-expected.png: Added.
  • platform/chromium-linux/platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-rotated-link-expected.txt: Added.
  • platform/chromium-linux/platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-scaledX-expected.png: Added.
  • platform/chromium-linux/platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-scaledX-expected.txt: Added.
  • platform/chromium-linux/platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-scaledY-expected.png: Added.
  • platform/chromium-linux/platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-scaledY-expected.txt: Added.
Location:
trunk
Files:
14 added
2 deleted
4 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r130549 r130551  
     12012-10-05  W. James MacLean  <wjmaclean@chromium.org>
     2
     3        [chromium] Enhance support for transforms in LinkHighlight.
     4        https://bugs.webkit.org/show_bug.cgi?id=94355
     5
     6        Reviewed by Adrienne Walker.
     7
     8        Improved handling of transformed highlight targets, where the transform goes beyond simple translation.
     9
     10        * platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-multi-line.html: Added.
     11        * platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-rotated-div.html: Added.
     12        * platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-rotated-link.html: Added.
     13        * platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-scaledX.html: Added.
     14        * platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-scaledY.html: Added.
     15        * platform/chromium-linux/platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-ZIndex-expected.png: Removed.
     16        * platform/chromium-linux/platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-ZIndex-expected.txt: Removed.
     17        * platform/chromium-linux/platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-multi-line-expected.png: Added.
     18        * platform/chromium-linux/platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-multi-line-expected.txt: Added.
     19        * platform/chromium-linux/platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-rotated-div-expected.png: Added.
     20        * platform/chromium-linux/platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-rotated-div-expected.txt: Added.
     21        * platform/chromium-linux/platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-rotated-link-expected.png: Added.
     22        * platform/chromium-linux/platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-rotated-link-expected.txt: Added.
     23        * platform/chromium-linux/platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-scaledX-expected.png: Added.
     24        * platform/chromium-linux/platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-scaledX-expected.txt: Added.
     25        * platform/chromium-linux/platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-scaledY-expected.png: Added.
     26        * platform/chromium-linux/platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-scaledY-expected.txt: Added.
     27
    1282012-10-05  Ojan Vafai  <ojan@chromium.org>
    229
  • trunk/LayoutTests/platform/chromium-linux/compositing/gestures/gesture-tapHighlight-simple-multi-line.html

    r130550 r130551  
    55</head>
    66<body onload="runTest();">
    7 <div style="-webkit-transform: translateZ(0); position: relative; left: 10px; top: 40px">
    8 <a href="" id="targetLink" style="z-index: 1; -webkit-tap-highlight-color: rgba(0, 255, 0, 0.5)">Target Link.</a>
     7<div style="-webkit-transform: translateZ(0); position: relative; left: 10; top: 40">
     8<a href="" id="targetLink" style="-webkit-tap-highlight-color: rgba(0, 255, 0, 0.5)">Long Target<br>Link.</a>
    99</div>
    10 <div style="position: relative; left: 10px; top: 70px">
    11 This test is successful if no link highlight appears (in particular, the entire viewport should remain unchanged, and the background
    12 should be white and not grey).
     10<div style="position: relative; left: 10; top: 70">
     11This test is successful if "Long Target Link" above is covered in two transparent green rectangles with square corners.
    1312</div>
    1413<script>
    15 // This test makes sure a GestureTapDown event on the page background doesn't "highlight" elements that have explicit z-index.
    1614function runTest() {
    1715    var clientRect = document.getElementById('targetLink').getBoundingClientRect();
    18     x = 150; // Pick a tap location outside the link area, so we're clicking on the background.
    19     y = 150;
     16    x = (clientRect.left + clientRect.right) / 2;
     17    y = (clientRect.top + clientRect.bottom) / 2;
    2018    if (window.testRunner) {
    2119        testRunner.dumpAsText(true);
  • trunk/Source/WebKit/chromium/ChangeLog

    r130550 r130551  
     12012-10-05  W. James MacLean  <wjmaclean@chromium.org>
     2
     3        [chromium] Enhance support for transforms in LinkHighlight.
     4        https://bugs.webkit.org/show_bug.cgi?id=94355
     5
     6        Reviewed by Adrienne Walker.
     7
     8        Improved handling of transformed highlight targets, where the transform goes beyond simple translation.
     9
     10        * src/LinkHighlight.cpp:
     11        (WebKit::convertTargetSpaceQuadToCompositedLayer): Converts target space quad to composited layer coordinates.
     12        (WebKit):
     13        (WebKit::addQuadToPath): Supports adding non-rectilinear quads to Path.
     14        (WebKit::LinkHighlight::computeHighlightLayerPathAndPosition): Updated to deal with target's quadlist, transform individual quads according to transforms.
     15        * src/WebViewImpl.cpp:
     16        (WebKit::WebViewImpl::bestTouchLinkNode):
     17
    1182012-10-05  Julien Chaffraix  <jchaffraix@webkit.org>
    219
  • trunk/Source/WebKit/chromium/src/LinkHighlight.cpp

    r130539 r130551  
    144144}
    145145
     146static void convertTargetSpaceQuadToCompositedLayer(const FloatQuad& targetSpaceQuad, RenderObject* targetRenderer, RenderObject* compositedRenderer, FloatQuad& compositedSpaceQuad)
     147{
     148    ASSERT(targetRenderer);
     149    ASSERT(compositedRenderer);
     150
     151    for (unsigned i = 0; i < 4; ++i) {
     152        IntPoint point;
     153        switch (i) {
     154        case 0: point = roundedIntPoint(targetSpaceQuad.p1()); break;
     155        case 1: point = roundedIntPoint(targetSpaceQuad.p2()); break;
     156        case 2: point = roundedIntPoint(targetSpaceQuad.p3()); break;
     157        case 3: point = roundedIntPoint(targetSpaceQuad.p4()); break;
     158        }
     159
     160        point = targetRenderer->frame()->view()->contentsToWindow(point);
     161        point = compositedRenderer->frame()->view()->windowToContents(point);
     162        FloatPoint floatPoint = compositedRenderer->absoluteToLocal(point, false, true);
     163
     164        switch (i) {
     165        case 0: compositedSpaceQuad.setP1(floatPoint); break;
     166        case 1: compositedSpaceQuad.setP2(floatPoint); break;
     167        case 2: compositedSpaceQuad.setP3(floatPoint); break;
     168        case 3: compositedSpaceQuad.setP4(floatPoint); break;
     169        }
     170    }
     171}
     172
     173static void addQuadToPath(const FloatQuad& quad, Path& path)
     174{
     175    // FIXME: Make this create rounded quad-paths, just like the axis-aligned case.
     176    path.moveTo(quad.p1());
     177    path.addLineTo(quad.p2());
     178    path.addLineTo(quad.p3());
     179    path.addLineTo(quad.p4());
     180    path.closeSubpath();
     181}
     182
    146183bool LinkHighlight::computeHighlightLayerPathAndPosition(RenderLayer* compositingLayer)
    147184{
     
    149186        return false;
    150187
    151     bool pathHasChanged = false;
    152     FloatRect boundingRect = m_node->pixelSnappedBoundingBox();
    153 
    154     // FIXME: If we ever use a more sophisticated highlight path, we'll need
    155     // to devise a way of detecting when it changes.
    156     if (boundingRect.size() != m_path.boundingRect().size()) {
    157         FloatSize rectRoundingRadii(3, 3);
    158         m_path.clear();
    159         m_path.addRoundedRect(boundingRect, rectRoundingRadii);
    160         // Always treat the path as being at the origin of this layer.
    161         m_path.translate(FloatPoint() - boundingRect.location());
    162         pathHasChanged = true;
    163     }
    164 
    165     FloatRect nodeBounds = boundingRect;
    166 
    167     // This is a simplified, but basically correct, transformation of the target location, converted
    168     // from its containing frame view to window coordinates and then back to the containing frame view
    169     // of the composited layer.
    170     // FIXME: We also need to transform the target's size in case of scaling. This can be done by also transforming
    171     //        the full rects in the xToY calls, and transforming both the upper-left and lower right corners
    172     //        to local coordinates at the end..
    173188    ASSERT(compositingLayer);
    174     IntPoint targetWindow = m_node->renderer()->frame()->view()->contentsToWindow(enclosingIntRect(nodeBounds).location());
    175     IntPoint targetCompositorAbsolute = compositingLayer->renderer()->frame()->view()->windowToContents(targetWindow);
    176     FloatPoint targetCompositorLocal = compositingLayer->renderer()->absoluteToLocal(targetCompositorAbsolute, false, true);
    177 
    178     m_contentLayer->layer()->setBounds(WebSize(enclosingIntRect(nodeBounds).size()));
    179     m_contentLayer->layer()->setPosition(WebFloatPoint(targetCompositorLocal));
     189
     190    // Get quads for node in absolute coordinates.
     191    Vector<FloatQuad> quads;
     192    m_node->renderer()->absoluteQuads(quads);
     193    ASSERT(quads.size());
     194
     195    Path newPath;
     196    for (unsigned quadIndex = 0; quadIndex < quads.size(); ++quadIndex) {
     197
     198        FloatQuad transformedQuad;
     199
     200        // Transform node quads in target absolute coords to local coordinates in the compositor layer.
     201        convertTargetSpaceQuadToCompositedLayer(quads[quadIndex], m_node->renderer(), compositingLayer->renderer(), transformedQuad);
     202
     203        // FIXME: for now, we'll only use rounded paths if we have a single node quad. The reason for this is that
     204        // we may sometimes get a chain of adjacent boxes (e.g. for text nodes) which end up looking like sausage
     205        // links: these should ideally be merged into a single rect before creating the path, but that's
     206        // another CL.
     207        if (quads.size() == 1 && transformedQuad.isRectilinear()) {
     208            FloatSize rectRoundingRadii(3, 3);
     209            newPath.addRoundedRect(transformedQuad.boundingBox(), rectRoundingRadii);
     210        } else
     211            addQuadToPath(transformedQuad, newPath);
     212    }
     213
     214    FloatRect boundingRect = newPath.boundingRect();
     215    newPath.translate(FloatPoint() - boundingRect.location());
     216
     217    bool pathHasChanged = !m_path.platformPath() || !(*newPath.platformPath() == *m_path.platformPath());
     218    if (pathHasChanged) {
     219        m_path = newPath;
     220        m_contentLayer->layer()->setBounds(enclosingIntRect(boundingRect).size());
     221    }
     222
     223    m_contentLayer->layer()->setPosition(boundingRect.location());
    180224
    181225    return pathHasChanged;
  • trunk/Source/WebKit/chromium/src/WebViewImpl.cpp

    r130547 r130551  
    12041204        bestTouchNode = bestTouchNode->parentNode();
    12051205
    1206     // If the document has click handlers installed, we don't want to default to applying the highlight to the entire RenderView, or the
    1207     // 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.
     1206    // If the document/body have click handlers installed, we don't want to default to applying the highlight to the entire RenderView, or the
     1207    // entire body.
    12081208    RenderObject* touchNodeRenderer = bestTouchNode ? bestTouchNode->renderer() : 0;
    1209     if (bestTouchNode && (!touchNodeRenderer || touchNodeRenderer->isRenderView() || touchNodeRenderer->isBody() || !touchNodeRenderer->style()->hasAutoZIndex()))
     1209    if (bestTouchNode && (!touchNodeRenderer || touchNodeRenderer->isRenderView() || touchNodeRenderer->isBody()))
    12101210        return 0;
    12111211
Note: See TracChangeset for help on using the changeset viewer.