Bug 1316549 Part 4 - Use logical names for ComputeEllipseLineInterceptDiff(). draft
authorTing-Yu Lin <tlin@mozilla.com>
Fri, 18 Nov 2016 13:54:09 +0800
changeset 442779 cc034fadbe4d44e7fd9bf2c1f403680488904699
parent 442778 8c7c0434e1c5f380154abdbf1f0b4b0455c32bcd
child 443311 36227623650fd8580aa9af163f4c5c6078636a78
push id36803
push userbmo:tlin@mozilla.com
push dateWed, 23 Nov 2016 06:29:01 +0000
bugs1316549
milestone53.0a1
Bug 1316549 Part 4 - Use logical names for ComputeEllipseLineInterceptDiff(). This patch is just renames. No logic change for the function. MozReview-Commit-ID: K7w0YL3G3gu
layout/generic/nsFloatManager.cpp
layout/generic/nsFloatManager.h
--- a/layout/generic/nsFloatManager.cpp
+++ b/layout/generic/nsFloatManager.cpp
@@ -632,17 +632,17 @@ nsFloatManager::FloatInfo::LineLeft(Writ
     if (aWM.IsLineInverted()) {
       // This happens only when aWM is vertical-lr. Need to swap blockStart
       // and blockEnd corners.
       std::swap(blockStartCornerRadiusL, blockEndCornerRadiusL);
       std::swap(blockStartCornerRadiusB, blockEndCornerRadiusB);
     }
 
     nscoord lineLeftDiff =
-      ComputeEllipseXInterceptDiff(
+      ComputeEllipseLineInterceptDiff(
         ShapeBoxRect().y, ShapeBoxRect().YMost(),
         blockStartCornerRadiusL, blockStartCornerRadiusB,
         blockEndCornerRadiusL, blockEndCornerRadiusB,
         aBStart, aBEnd);
     return ShapeBoxRect().x + lineLeftDiff;
   }
 
   // XXX: Other shape source types are not implemented yet.
@@ -690,96 +690,97 @@ nsFloatManager::FloatInfo::LineRight(Wri
     if (aWM.IsLineInverted()) {
       // This happens only when aWM is vertical-lr. Need to swap blockStart
       // and blockEnd corners.
       std::swap(blockStartCornerRadiusL, blockEndCornerRadiusL);
       std::swap(blockStartCornerRadiusB, blockEndCornerRadiusB);
     }
 
     nscoord lineRightDiff =
-      ComputeEllipseXInterceptDiff(
+      ComputeEllipseLineInterceptDiff(
         ShapeBoxRect().y, ShapeBoxRect().YMost(),
         blockStartCornerRadiusL, blockStartCornerRadiusB,
         blockEndCornerRadiusL, blockEndCornerRadiusB,
         aBStart, aBEnd);
     return ShapeBoxRect().XMost() - lineRightDiff;
   }
 
   // XXX: Other shape source types are not implemented yet.
 
   return LineRight();
 }
 
 /* static */ nscoord
-nsFloatManager::FloatInfo::ComputeEllipseXInterceptDiff(
-  const nscoord aShapeBoxY, const nscoord aShapeBoxYMost,
-  const nscoord aTopCornerRadiusX, const nscoord aTopCornerRadiusY,
-  const nscoord aBottomCornerRadiusX, const nscoord aBottomCornerRadiusY,
-  const nscoord aBandY, const nscoord aBandYMost)
+nsFloatManager::FloatInfo::ComputeEllipseLineInterceptDiff(
+  const nscoord aShapeBoxBStart, const nscoord aShapeBoxBEnd,
+  const nscoord aBStartCornerRadiusL, const nscoord aBStartCornerRadiusB,
+  const nscoord aBEndCornerRadiusL, const nscoord aBEndCornerRadiusB,
+  const nscoord aBandBStart, const nscoord aBandBEnd)
 {
-  // An Example for the band intersects with the top right corner of an ellipse.
+  // An example for the band intersecting with the top right corner of an
+  // ellipse with writing-mode horizontal-tb.
   //
-  //                                xIntercept xDiff
+  //                             lineIntercept lineDiff
   //                                    |       |
-  //  +---------------------------------|-------|-+---- aShapeBoxY
+  //  +---------------------------------|-------|-+---- aShapeBoxBStart
   //  |                ##########^      |       | |
   //  |            ##############|####  |       | |
-  //  +---------#################|######|-------|-+---- aBandY
+  //  +---------#################|######|-------|-+---- aBandBStart
   //  |       ###################|######|##     | |
-  //  |      # aTopCornerRadiusY |######|###    | |
+  //  |     aBStartCornerRadiusB |######|###    | |
   //  |    ######################|######|#####  | |
-  //  +---#######################|<-----------><->^---- aBandYMost
+  //  +---#######################|<-----------><->^---- aBandBEnd
   //  |  ########################|##############  |
-  //  |  ########################|##############  |---- y
+  //  |  ########################|##############  |---- b
   //  | #########################|############### |
   //  | ######################## v<-------------->v
-  //  |######################### aTopCornerRadiusX|
+  //  |###################### aBStartCornerRadiusL|
   //  |###########################################|
   //  |###########################################|
   //  |###########################################|
   //  |###########################################|
   //  | ######################################### |
   //  | ######################################### |
   //  |  #######################################  |
   //  |  #######################################  |
   //  |   #####################################   |
   //  |    ###################################    |
   //  |      ###############################      |
   //  |       #############################       |
   //  |         #########################         |
   //  |            ###################            |
   //  |                ###########                |
-  //  +-------------------------------------------+----- aShapeBoxYMost
+  //  +-------------------------------------------+----- aShapeBoxBEnd
 
-  NS_ASSERTION(aShapeBoxY <= aShapeBoxYMost, "Bad shape box coordinates!");
-  NS_ASSERTION(aBandY <= aBandYMost, "Bad band coordinates!");
+  NS_ASSERTION(aShapeBoxBStart <= aShapeBoxBEnd, "Bad shape box coordinates!");
+  NS_ASSERTION(aBandBStart <= aBandBEnd, "Bad band coordinates!");
 
-  nscoord xDiff = 0;
+  nscoord lineDiff = 0;
 
-  // If the band intersects both the top and bottom corners, we don't need
-  // to enter either branch because the correct xDiff is 0.
-  if (aTopCornerRadiusY > 0 &&
-      aBandYMost >= aShapeBoxY &&
-      aBandYMost <= aShapeBoxY + aTopCornerRadiusY) {
-    // The band intersects only the top corner.
-    nscoord y = aTopCornerRadiusY - (aBandYMost - aShapeBoxY);
-    nscoord xIntercept =
-      XInterceptAtY(y, aTopCornerRadiusX, aTopCornerRadiusY);
-    xDiff = aTopCornerRadiusX - xIntercept;
-  } else if (aBottomCornerRadiusY > 0 &&
-             aBandY >= aShapeBoxYMost - aBottomCornerRadiusY &&
-             aBandY <= aShapeBoxYMost) {
-    // The band intersects only the bottom corner.
-    nscoord y = aBottomCornerRadiusY - (aShapeBoxYMost - aBandY);
-    nscoord xIntercept =
-      XInterceptAtY(y, aBottomCornerRadiusX, aBottomCornerRadiusY);
-    xDiff = aBottomCornerRadiusX - xIntercept;
+  // If the band intersects both the block-start and block-end corners, we
+  // don't need to enter either branch because the correct lineDiff is 0.
+  if (aBStartCornerRadiusB > 0 &&
+      aBandBEnd >= aShapeBoxBStart &&
+      aBandBEnd <= aShapeBoxBStart + aBStartCornerRadiusB) {
+    // The band intersects only the block-start corner.
+    nscoord b = aBStartCornerRadiusB - (aBandBEnd - aShapeBoxBStart);
+    nscoord lineIntercept =
+      XInterceptAtY(b, aBStartCornerRadiusL, aBStartCornerRadiusB);
+    lineDiff = aBStartCornerRadiusL - lineIntercept;
+  } else if (aBEndCornerRadiusB > 0 &&
+             aBandBStart >= aShapeBoxBEnd - aBEndCornerRadiusB &&
+             aBandBStart <= aShapeBoxBEnd) {
+    // The band intersects only the block-end corner.
+    nscoord b = aBEndCornerRadiusB - (aShapeBoxBEnd - aBandBStart);
+    nscoord lineIntercept =
+      XInterceptAtY(b, aBEndCornerRadiusL, aBEndCornerRadiusB);
+    lineDiff = aBEndCornerRadiusL - lineIntercept;
   }
 
-  return xDiff;
+  return lineDiff;
 }
 
 /* static */ nscoord
 nsFloatManager::FloatInfo::XInterceptAtY(const nscoord aY,
                                          const nscoord aRadiusX,
                                          const nscoord aRadiusY)
 {
   // Solve for x in the ellipse equation (x/radiusX)^2 + (y/radiusY)^2 = 1.
--- a/layout/generic/nsFloatManager.h
+++ b/layout/generic/nsFloatManager.h
@@ -344,28 +344,29 @@ private:
     {
       return aShapeType == ShapeType::Margin ? BStart() : ShapeBoxRect().y;
     }
     nscoord BEnd(ShapeType aShapeType) const
     {
       return aShapeType == ShapeType::Margin ? BEnd() : ShapeBoxRect().YMost();
     }
 
-    // Compute the minimum x-axis difference between the bounding shape box
-    // and its rounded corner within the given band (y-axis region). This is
-    // used as a helper function to compute the LineRight() and LineLeft().
-    // See the picture in the implementation for an example.
+    // Compute the minimum line-axis difference between the bounding shape
+    // box and its rounded corner within the given band (block-axis region).
+    // This is used as a helper function to compute the LineRight() and
+    // LineLeft(). See the picture in the implementation for an example.
+    // RadiusL and RadiusB stand for radius on the line-axis and block-axis.
     //
-    // Returns the x-axis diff, or 0 if there's no rounded corner within
-    // the given band.
-    static nscoord ComputeEllipseXInterceptDiff(
-      const nscoord aShapeBoxY, const nscoord aShapeBoxYMost,
-      const nscoord aTopCornerRadiusX, const nscoord aTopCornerRadiusY,
-      const nscoord aBottomCornerRadiusX, const nscoord aBottomCornerRadiusY,
-      const nscoord aBandY, const nscoord aBandYMost);
+    // Returns radius-x diff on the line-axis, or 0 if there's no rounded
+    // corner within the given band.
+    static nscoord ComputeEllipseLineInterceptDiff(
+      const nscoord aShapeBoxBStart, const nscoord aShapeBoxBEnd,
+      const nscoord aBStartCornerRadiusL, const nscoord aBStartCornerRadiusB,
+      const nscoord aBEndCornerRadiusL, const nscoord aBEndCornerRadiusB,
+      const nscoord aBandBStart, const nscoord aBandBEnd);
 
     static nscoord XInterceptAtY(const nscoord aY, const nscoord aRadiusX,
                                  const nscoord aRadiusY);
 
 #ifdef NS_BUILD_REFCNT_LOGGING
     FloatInfo(const FloatInfo& aOther);
     ~FloatInfo();
 #endif