Changeset 187018 in webkit


Ignore:
Timestamp:
Jul 19, 2015 11:38:40 PM (9 years ago)
Author:
timothy_horton@apple.com
Message:

Make shrink-wrapping test a ref-test instead of pixel-test
https://bugs.webkit.org/show_bug.cgi?id=147081

Reviewed by Sam Weinig.

Source/WebCore:

Nobody runs pixel tests.

  • svg/SVGPathUtilities.cpp:

(WebCore::pathIteratorForBuildingString):
(WebCore::buildStringFromPath):

  • svg/SVGPathUtilities.h:

Add a helper that turns a Path into a SVG path string.

  • testing/Internals.cpp:

(WebCore::Internals::pathStringWithShrinkWrappedRects):

  • testing/Internals.h:
  • testing/Internals.idl:

Have the internals shrink-wrap method return an SVG path instead of a DOMPath.

LayoutTests:

  • fast/shrink-wrap/rect-shrink-wrap-expected.html: Added.
  • fast/shrink-wrap/rect-shrink-wrap-expected.png: Removed.
  • fast/shrink-wrap/rect-shrink-wrap-expected.txt: Removed.
  • fast/shrink-wrap/rect-shrink-wrap.html:

SVG all the things.

Location:
trunk
Files:
1 added
2 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r187016 r187018  
     12015-07-19  Tim Horton  <timothy_horton@apple.com>
     2
     3        Make shrink-wrapping test a ref-test instead of pixel-test
     4        https://bugs.webkit.org/show_bug.cgi?id=147081
     5
     6        Reviewed by Sam Weinig.
     7
     8        * fast/shrink-wrap/rect-shrink-wrap-expected.html: Added.
     9        * fast/shrink-wrap/rect-shrink-wrap-expected.png: Removed.
     10        * fast/shrink-wrap/rect-shrink-wrap-expected.txt: Removed.
     11        * fast/shrink-wrap/rect-shrink-wrap.html:
     12        SVG all the things.
     13
    1142015-07-19  Jordan Harband  <ljharb@gmail.com>
    215
  • trunk/LayoutTests/fast/shrink-wrap/rect-shrink-wrap.html

    r186976 r187018  
    11<script>
    22
     3if (!window.internals)
     4        document.write("This test must be run in a test runner.")
     5
    36function testRects(offset, rects, radius) {
    4     if (!window.internals)
    5         document.write("This test must be run in a test runner.")
    6 
    77    if (radius == undefined)
    88        radius = 8;
    99
    10     var concatRects = [];
    11     for (var i in rects)
    12         Array.prototype.push.apply(concatRects, rects[i]);
    13 
    14     var path = undefined;
    15     if (window.internals)
    16         path = window.internals.pathWithShrinkWrappedRects(concatRects, radius);
    17 
    18     var canvas = document.getElementById("shrink");
    19     var ctx = canvas.getContext("2d");
    20 
    21     ctx.save();
    22 
    23     ctx.translate.apply(ctx, offset);
    24 
    25     ctx.fillStyle = "rgba(0,0,0,0.2)";
    26 
    27     for (var i in rects)
    28         ctx.fillRect.apply(ctx, rects[i]);
    29 
    30     ctx.strokeStyle = "rgba(0,0,0,0.5)";
    31     ctx.lineWidth = 1;
    32     for (var i in rects)
    33         ctx.strokeRect.apply(ctx, rects[i]);
    34 
    35     ctx.strokeStyle = "blue";
    36     ctx.lineWidth = 3;
    37     if (path)
    38         ctx.stroke(path);
    39 
    40     ctx.restore();
     10    var gElement = document.createElementNS("http://www.w3.org/2000/svg", "g");
     11    gElement.setAttribute("transform", "translate(" + offset[0] + ", " + offset[1] + ")");
     12    document.getElementById("paths").appendChild(gElement);
     13
     14    for (var i in rects) {
     15        var rectElement = document.createElementNS("http://www.w3.org/2000/svg", "rect");
     16        rectElement.setAttribute("x", rects[i][0]);
     17        rectElement.setAttribute("y", rects[i][1]);
     18        rectElement.setAttribute("width", rects[i][2]);
     19        rectElement.setAttribute("height", rects[i][3]);
     20        rectElement.setAttribute("fill", "rgba(0, 0, 0, 0.2)");
     21        rectElement.setAttribute("stroke", "rgba(0, 0, 0, 0.5)");
     22        gElement.appendChild(rectElement);
     23    }
     24
     25    if (window.internals) {
     26        var concatRects = [];
     27        for (var i in rects)
     28            Array.prototype.push.apply(concatRects, rects[i]);
     29        var pathString = window.internals.pathStringWithShrinkWrappedRects(concatRects, radius);
     30        var pathElement = document.createElementNS("http://www.w3.org/2000/svg", "path");
     31        pathElement.setAttribute("d", pathString)
     32        pathElement.setAttribute("fill", "none");
     33        pathElement.setAttribute("stroke", "blue");
     34        pathElement.setAttribute("stroke-width", "3");
     35        gElement.appendChild(pathElement);
     36    }
    4137}
    4238
     
    244240</style>
    245241
    246 <canvas id="shrink" width="800" height="600"></canvas>
     242<svg id="paths" width="800" height="600"></svg>
  • trunk/Source/WebCore/ChangeLog

    r187009 r187018  
     12015-07-19  Tim Horton  <timothy_horton@apple.com>
     2
     3        Make shrink-wrapping test a ref-test instead of pixel-test
     4        https://bugs.webkit.org/show_bug.cgi?id=147081
     5
     6        Reviewed by Sam Weinig.
     7
     8        Nobody runs pixel tests.
     9
     10        * svg/SVGPathUtilities.cpp:
     11        (WebCore::pathIteratorForBuildingString):
     12        (WebCore::buildStringFromPath):
     13        * svg/SVGPathUtilities.h:
     14        Add a helper that turns a Path into a SVG path string.
     15
     16        * testing/Internals.cpp:
     17        (WebCore::Internals::pathStringWithShrinkWrappedRects):
     18        * testing/Internals.h:
     19        * testing/Internals.idl:
     20        Have the internals shrink-wrap method return an SVG path instead of a DOMPath.
     21
    1222015-07-19  David Kilzer  <ddkilzer@apple.com>
    223
  • trunk/Source/WebCore/svg/SVGPathUtilities.cpp

    r184852 r187018  
    2727#include "SVGPathByteStreamBuilder.h"
    2828#include "SVGPathByteStreamSource.h"
     29#include "SVGPathConsumer.h"
    2930#include "SVGPathElement.h"
    3031#include "SVGPathParser.h"
     
    331332}
    332333
    333 }
     334static void pathIteratorForBuildingString(void* info, const PathElement* pathElement)
     335{
     336    SVGPathConsumer* consumer = static_cast<SVGPathConsumer*>(info);
     337
     338    switch (pathElement->type) {
     339    case PathElementMoveToPoint:
     340        consumer->moveTo(pathElement->points[0], false, AbsoluteCoordinates);
     341        break;
     342    case PathElementAddLineToPoint:
     343        consumer->lineTo(pathElement->points[0], AbsoluteCoordinates);
     344        break;
     345    case PathElementAddQuadCurveToPoint:
     346        consumer->curveToQuadratic(pathElement->points[0], pathElement->points[1], AbsoluteCoordinates);
     347        break;
     348    case PathElementAddCurveToPoint:
     349        consumer->curveToCubic(pathElement->points[0], pathElement->points[1], pathElement->points[2], AbsoluteCoordinates);
     350        break;
     351    case PathElementCloseSubpath:
     352        consumer->closePath();
     353        break;
     354
     355    default:
     356        ASSERT_NOT_REACHED();
     357        break;
     358    }
     359}
     360
     361bool buildStringFromPath(const Path& path, String& string)
     362{
     363    // Ideally we would have a SVGPathPlatformPathSource, but it's not possible to manually iterate
     364    // a path, only apply a function to all path elements at once.
     365
     366    SVGPathStringBuilder* builder = globalSVGPathStringBuilder();
     367    path.apply(builder, &pathIteratorForBuildingString);
     368    string = builder->result();
     369    static_cast<SVGPathConsumer*>(builder)->cleanup();
     370
     371    return true;
     372}
     373
     374}
  • trunk/Source/WebCore/svg/SVGPathUtilities.h

    r163440 r187018  
    5656bool getPointAtLengthOfSVGPathByteStream(SVGPathByteStream*, float length, SVGPoint&);
    5757
     58// Path -> String
     59WEBCORE_EXPORT bool buildStringFromPath(const Path&, String&);
     60
    5861} // namespace WebCore
    5962
  • trunk/Source/WebCore/testing/Internals.cpp

    r187004 r187018  
    29832983}
    29842984
    2985 PassRefPtr<DOMPath> Internals::pathWithShrinkWrappedRects(Vector<double> rectComponents, double radius, ExceptionCode& ec)
     2985String Internals::pathStringWithShrinkWrappedRects(Vector<double> rectComponents, double radius, ExceptionCode& ec)
    29862986{
    29872987    if (rectComponents.size() % 4) {
    29882988        ec = INVALID_ACCESS_ERR;
    2989         return nullptr;
     2989        return String();
    29902990    }
    29912991
     
    30033003
    30043004    Path path = PathUtilities::pathWithShrinkWrappedRects(rects, radius);
    3005     return DOMPath::create(path);
    3006 }
    3007 
    3008 }
     3005
     3006    String pathString;
     3007    buildStringFromPath(path, pathString);
     3008
     3009    return pathString;
     3010}
     3011
     3012}
  • trunk/Source/WebCore/testing/Internals.h

    r187004 r187018  
    425425#endif
    426426
    427     PassRefPtr<DOMPath> pathWithShrinkWrappedRects(Vector<double> rectComponents, double radius, ExceptionCode&);
     427    String pathStringWithShrinkWrappedRects(Vector<double> rectComponents, double radius, ExceptionCode&);
    428428
    429429private:
  • trunk/Source/WebCore/testing/Internals.idl

    r187004 r187018  
    388388#endif
    389389
    390     [RaisesException] DOMPath pathWithShrinkWrappedRects(sequence<double> rectComponents, double radius);
    391 };
     390    [RaisesException] DOMString pathStringWithShrinkWrappedRects(sequence<double> rectComponents, double radius);
     391};
Note: See TracChangeset for help on using the changeset viewer.