Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: LayoutTests/csswg/contributors/adobe/submitted/shapes/shape-outside/resources/rounded-rectangle.js

Issue 200633005: [CSS Shapes] Remove deprecated shapes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix test expectations Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 function ellipseXIntercept(yi, rx, ry)
2 {
3 return rx * Math.sqrt(1 - (yi * yi) / (ry * ry));
4 }
5
6 function scanConvertRoundedRectangleOutside(r, height, lineHeight)
7 {
8 var intervals = [];
9
10 for (var y = 0; y < height; y += lineHeight) {
11 if (y + lineHeight <= r.y || y >= r.y + r.height)
12 continue;
13
14 if (y + lineHeight < r.y + r.ry) {
15 // within the upper rounded corner of the rectangle
16 var dx = ellipseXIntercept(y + lineHeight - r.y - r.ry, r.rx, r.ry);
17 intervals.push( { y: y, left: r.x + r.rx - dx, right: r.x + r.width - r.rx + dx} );
18 }
19 else if (y > r.y + r.height - r.ry) {
20 // within the lower rounded corner of the rectangle
21 var dx = ellipseXIntercept(y - (r.y + r.height - r.ry), r.rx, r.ry);
22 intervals.push( { y: y, left: r.x + r.rx - dx, right: r.x + r.width - r.rx + dx} );
23 }
24 else // within the rectangle's vertical edges
25 intervals.push( {y: y, left: r.x, right: r.x + r.width} );
26 }
27
28 return intervals;
29 }
30
31 function genLeftRightRoundedRectFloatShapeOutsideRefTest(args)
32 {
33 genLeftRoundedRectFloatShapeOutsideRefTest(args);
34 genRightRoundedRectFloatShapeOutsideRefTest(args);
35 }
36
37 function genLeftRoundedRectFloatShapeOutsideRefTest(args)
38 {
39 var leftRoundedRect = args.roundedRect;
40 var leftRoundedRectIntervals = scanConvertRoundedRectangleOutside(leftRounde dRect, args.containerHeight, args.lineHeight);
41 var leftFloatDivs = leftRoundedRectIntervals.map(function(interval) {
42 var width = SubPixelLayout.snapToLayoutUnit(interval.right);
43 var cls = "left-" + args.floatElementClassSuffix;
44 return '<div class="' + cls + '" style="width:' + width + 'px"></div>';
45 });
46 document.getElementById("left-" + args.insertElementIdSuffix).insertAdjacent HTML('afterend', leftFloatDivs.join("\n"));
47 }
48
49 function genRightRoundedRectFloatShapeOutsideRefTest(args)
50 {
51 var rightRoundedRect = Object.create(args.roundedRect);
52 rightRoundedRect.x = args.containerWidth - args.roundedRect.width;
53 var rightRoundedRectIntervals = scanConvertRoundedRectangleOutside(rightRoun dedRect, args.containerHeight, args.lineHeight);
54 var rightFloatDivs = rightRoundedRectIntervals.map(function(interval) {
55 var width = args.containerWidth - SubPixelLayout.snapToLayoutUnit(interv al.left);
56 var cls = "right-" + args.floatElementClassSuffix;
57 return '<div class="' + cls + '" style="width:' + width + 'px"></div>';
58 });
59 document.getElementById("right-" + args.insertElementIdSuffix).insertAdjacen tHTML('afterend', rightFloatDivs.join("\n"));
60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698