Clean up GenerateBorderAP()

- Use WriteFloat() instead of operator<<(float).
- Rename `fWidth` and `fHalfWidth` to Google C++ style.
- Change `fWidth / 2` and `fHalfWidth * 2` to use the other width
  variable instead.

Change-Id: I148b6bb1750bede5f921eb3d019bf95274aa04d7
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/123311
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Tom Sepez <tsepez@google.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfdoc/cpdf_generateap.cpp b/core/fpdfdoc/cpdf_generateap.cpp
index d2c50a2..66b767a 100644
--- a/core/fpdfdoc/cpdf_generateap.cpp
+++ b/core/fpdfdoc/cpdf_generateap.cpp
@@ -207,7 +207,7 @@
 }
 
 ByteString GenerateBorderAP(const CFX_FloatRect& rect,
-                            float fWidth,
+                            float width,
                             const CFX_Color& color,
                             const CFX_Color& crLeftTop,
                             const CFX_Color& crRightBottom,
@@ -219,8 +219,8 @@
   const float fRight = rect.right;
   const float fTop = rect.top;
   const float fBottom = rect.bottom;
-  if (fWidth > 0.0f) {
-    float fHalfWidth = fWidth / 2.0f;
+  if (width > 0.0f) {
+    const float half_width = width / 2.0f;
     switch (nStyle) {
       case BorderStyle::kSolid:
         sColor = GenerateColorAP(color, PaintOperation::kFill);
@@ -228,7 +228,7 @@
           sAppStream << sColor;
           WriteRect(sAppStream, rect) << " re\n";
           CFX_FloatRect inner_rect = rect;
-          inner_rect.Deflate(fWidth, fWidth);
+          inner_rect.Deflate(width, width);
           WriteRect(sAppStream, inner_rect) << " re f*\n";
         }
         break;
@@ -236,18 +236,18 @@
         sColor = GenerateColorAP(color, PaintOperation::kStroke);
         if (sColor.GetLength() > 0) {
           sAppStream << sColor;
-          sAppStream << fWidth << " w"
-                     << " [" << dash.nDash << " " << dash.nGap << "] "
-                     << dash.nPhase << " d\n";
-          WritePoint(sAppStream, {fLeft + fWidth / 2, fBottom + fWidth / 2})
+          WriteFloat(sAppStream, width)
+              << " w [" << dash.nDash << " " << dash.nGap << "] " << dash.nPhase
+              << " d\n";
+          WritePoint(sAppStream, {fLeft + half_width, fBottom + half_width})
               << " m\n";
-          WritePoint(sAppStream, {fLeft + fWidth / 2, fTop - fWidth / 2})
+          WritePoint(sAppStream, {fLeft + half_width, fTop - half_width})
               << " l\n";
-          WritePoint(sAppStream, {fRight - fWidth / 2, fTop - fWidth / 2})
+          WritePoint(sAppStream, {fRight - half_width, fTop - half_width})
               << " l\n";
-          WritePoint(sAppStream, {fRight - fWidth / 2, fBottom + fWidth / 2})
+          WritePoint(sAppStream, {fRight - half_width, fBottom + half_width})
               << " l\n";
-          WritePoint(sAppStream, {fLeft + fWidth / 2, fBottom + fWidth / 2})
+          WritePoint(sAppStream, {fLeft + half_width, fBottom + half_width})
               << " l S\n";
         }
         break;
@@ -256,47 +256,35 @@
         sColor = GenerateColorAP(crLeftTop, PaintOperation::kFill);
         if (sColor.GetLength() > 0) {
           sAppStream << sColor;
-          WritePoint(sAppStream, {fLeft + fHalfWidth, fBottom + fHalfWidth})
+          WritePoint(sAppStream, {fLeft + half_width, fBottom + half_width})
               << " m\n";
-          WritePoint(sAppStream, {fLeft + fHalfWidth, fTop - fHalfWidth})
+          WritePoint(sAppStream, {fLeft + half_width, fTop - half_width})
               << " l\n";
-          WritePoint(sAppStream, {fRight - fHalfWidth, fTop - fHalfWidth})
+          WritePoint(sAppStream, {fRight - half_width, fTop - half_width})
               << " l\n";
-          WritePoint(sAppStream,
-                     {fRight - fHalfWidth * 2, fTop - fHalfWidth * 2})
-              << " l\n";
-          WritePoint(sAppStream,
-                     {fLeft + fHalfWidth * 2, fTop - fHalfWidth * 2})
-              << " l\n";
-          WritePoint(sAppStream,
-                     {fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2})
-              << " l f\n";
+          WritePoint(sAppStream, {fRight - width, fTop - width}) << " l\n";
+          WritePoint(sAppStream, {fLeft + width, fTop - width}) << " l\n";
+          WritePoint(sAppStream, {fLeft + width, fBottom + width}) << " l f\n";
         }
         sColor = GenerateColorAP(crRightBottom, PaintOperation::kFill);
         if (sColor.GetLength() > 0) {
           sAppStream << sColor;
-          WritePoint(sAppStream, {fRight - fHalfWidth, fTop - fHalfWidth})
+          WritePoint(sAppStream, {fRight - half_width, fTop - half_width})
               << " m\n";
-          WritePoint(sAppStream, {fRight - fHalfWidth, fBottom + fHalfWidth})
+          WritePoint(sAppStream, {fRight - half_width, fBottom + half_width})
               << " l\n";
-          WritePoint(sAppStream, {fLeft + fHalfWidth, fBottom + fHalfWidth})
+          WritePoint(sAppStream, {fLeft + half_width, fBottom + half_width})
               << " l\n";
-          WritePoint(sAppStream,
-                     {fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2})
-              << " l\n";
-          WritePoint(sAppStream,
-                     {fRight - fHalfWidth * 2, fBottom + fHalfWidth * 2})
-              << " l\n";
-          WritePoint(sAppStream,
-                     {fRight - fHalfWidth * 2, fTop - fHalfWidth * 2})
-              << " l f\n";
+          WritePoint(sAppStream, {fLeft + width, fBottom + width}) << " l\n";
+          WritePoint(sAppStream, {fRight - width, fBottom + width}) << " l\n";
+          WritePoint(sAppStream, {fRight - width, fTop - width}) << " l f\n";
         }
         sColor = GenerateColorAP(color, PaintOperation::kFill);
         if (sColor.GetLength() > 0) {
           sAppStream << sColor;
           WriteRect(sAppStream, rect) << " re\n";
           CFX_FloatRect inner_rect = rect;
-          inner_rect.Deflate(fHalfWidth, fHalfWidth);
+          inner_rect.Deflate(half_width, half_width);
           WriteRect(sAppStream, inner_rect) << " re f*\n";
         }
         break;
@@ -304,9 +292,9 @@
         sColor = GenerateColorAP(color, PaintOperation::kStroke);
         if (sColor.GetLength() > 0) {
           sAppStream << sColor;
-          sAppStream << fWidth << " w\n";
-          WritePoint(sAppStream, {fLeft, fBottom + fWidth / 2}) << " m\n";
-          WritePoint(sAppStream, {fRight, fBottom + fWidth / 2}) << " l S\n";
+          WriteFloat(sAppStream, width) << " w\n";
+          WritePoint(sAppStream, {fLeft, fBottom + half_width}) << " m\n";
+          WritePoint(sAppStream, {fRight, fBottom + half_width}) << " l S\n";
         }
         break;
     }