Changeset 187018 in webkit
- Timestamp:
- Jul 19, 2015 11:38:40 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 2 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r187016 r187018 1 2015-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 1 14 2015-07-19 Jordan Harband <ljharb@gmail.com> 2 15 -
trunk/LayoutTests/fast/shrink-wrap/rect-shrink-wrap.html
r186976 r187018 1 1 <script> 2 2 3 if (!window.internals) 4 document.write("This test must be run in a test runner.") 5 3 6 function testRects(offset, rects, radius) { 4 if (!window.internals)5 document.write("This test must be run in a test runner.")6 7 7 if (radius == undefined) 8 8 radius = 8; 9 9 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 } 41 37 } 42 38 … … 244 240 </style> 245 241 246 < canvas id="shrink" width="800" height="600"></canvas>242 <svg id="paths" width="800" height="600"></svg> -
trunk/Source/WebCore/ChangeLog
r187009 r187018 1 2015-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 1 22 2015-07-19 David Kilzer <ddkilzer@apple.com> 2 23 -
trunk/Source/WebCore/svg/SVGPathUtilities.cpp
r184852 r187018 27 27 #include "SVGPathByteStreamBuilder.h" 28 28 #include "SVGPathByteStreamSource.h" 29 #include "SVGPathConsumer.h" 29 30 #include "SVGPathElement.h" 30 31 #include "SVGPathParser.h" … … 331 332 } 332 333 333 } 334 static 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 361 bool 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 56 56 bool getPointAtLengthOfSVGPathByteStream(SVGPathByteStream*, float length, SVGPoint&); 57 57 58 // Path -> String 59 WEBCORE_EXPORT bool buildStringFromPath(const Path&, String&); 60 58 61 } // namespace WebCore 59 62 -
trunk/Source/WebCore/testing/Internals.cpp
r187004 r187018 2983 2983 } 2984 2984 2985 PassRefPtr<DOMPath> Internals::pathWithShrinkWrappedRects(Vector<double> rectComponents, double radius, ExceptionCode& ec)2985 String Internals::pathStringWithShrinkWrappedRects(Vector<double> rectComponents, double radius, ExceptionCode& ec) 2986 2986 { 2987 2987 if (rectComponents.size() % 4) { 2988 2988 ec = INVALID_ACCESS_ERR; 2989 return nullptr;2989 return String(); 2990 2990 } 2991 2991 … … 3003 3003 3004 3004 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 425 425 #endif 426 426 427 PassRefPtr<DOMPath> pathWithShrinkWrappedRects(Vector<double> rectComponents, double radius, ExceptionCode&);427 String pathStringWithShrinkWrappedRects(Vector<double> rectComponents, double radius, ExceptionCode&); 428 428 429 429 private: -
trunk/Source/WebCore/testing/Internals.idl
r187004 r187018 388 388 #endif 389 389 390 [RaisesException] DOM Path 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.