Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / shapes / resources / rounded-rectangle.js
index dd4c004..c9f4e9e 100644 (file)
@@ -3,20 +3,27 @@ function ellipseXIntercept(yi, rx, ry)
     return rx * Math.sqrt(1 - (yi * yi) / (ry * ry));
 }
 
-function scanConvertRoundedRectangleOutside(r, height, lineHeight)
+function scanConvertRoundedRectangleOutside(r, height, lineHeight, corner)
 {
     var intervals = [];
+    var upperCorner = true;
+    var lowerCorner = true;
+
+    if (corner == "upper")
+        lowerCorner = false;
+    else if (corner == "lower")
+        upperCorner = false;
 
     for (var y = 0; y < height; y += lineHeight) {
         if (y + lineHeight <= r.y || y >= r.y + r.height)
             continue;
 
-        if (y + lineHeight < r.y + r.ry) {
+        if (upperCorner && (y + lineHeight < r.y + r.ry)) {
             // within the upper rounded corner part of the rectangle
             var dx = ellipseXIntercept(y + lineHeight - r.y - r.ry, r.rx, r.ry);
             intervals.push( { y: y, left: r.x + r.rx - dx, right: r.x + r.width - r.rx + dx} );
         }
-        else if (y > r.y + r.height - r.ry) {
+        else if (lowerCorner && (y > r.y + r.height - r.ry)) {
             // within the lower rounded corner part of the rectangle
             var dx = ellipseXIntercept(y - (r.y + r.height - r.ry), r.rx, r.ry);
             intervals.push( { y: y, left: r.x + r.rx - dx, right: r.x + r.width - r.rx + dx} );
@@ -37,7 +44,7 @@ function genLeftRightRoundedRectFloatShapeOutsideRefTest(args)
 function genLeftRoundedRectFloatShapeOutsideRefTest(args)
 {
     var leftRoundedRect = args.roundedRect;
-    var leftRoundedRectIntervals = scanConvertRoundedRectangleOutside(leftRoundedRect, args.containerHeight, args.lineHeight);
+    var leftRoundedRectIntervals = scanConvertRoundedRectangleOutside(leftRoundedRect, args.containerHeight, args.lineHeight, args.corner);
     var leftFloatDivs = leftRoundedRectIntervals.map(function(interval) {
         var width = SubPixelLayout.snapToLayoutUnit(interval.right);
         var cls = "left-" + args.floatElementClassSuffix;
@@ -50,7 +57,7 @@ function genRightRoundedRectFloatShapeOutsideRefTest(args)
 {
     var rightRoundedRect = Object.create(args.roundedRect);
     rightRoundedRect.x = args.containerWidth - args.roundedRect.width;
-    var rightRoundedRectIntervals = scanConvertRoundedRectangleOutside(rightRoundedRect, args.containerHeight, args.lineHeight);
+    var rightRoundedRectIntervals = scanConvertRoundedRectangleOutside(rightRoundedRect, args.containerHeight, args.lineHeight, args.corner);
     var rightFloatDivs = rightRoundedRectIntervals.map(function(interval) {
         var width = args.containerWidth - SubPixelLayout.snapToLayoutUnit(interval.left);
         var cls = "right-" + args.floatElementClassSuffix;