Cleanup CXFA_StrokeData

This CL fixes return types and makes methods consts.

Change-Id: I97da09a491d10760d6adf4efcc0557130cf8b405
Reviewed-on: https://pdfium-review.googlesource.com/19110
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
diff --git a/xfa/fxfa/cxfa_ffline.cpp b/xfa/fxfa/cxfa_ffline.cpp
index df83fa6..16794c3 100644
--- a/xfa/fxfa/cxfa_ffline.cpp
+++ b/xfa/fxfa/cxfa_ffline.cpp
@@ -10,6 +10,22 @@
 #include "xfa/fxgraphics/cxfa_gepath.h"
 #include "xfa/fxgraphics/cxfa_graphics.h"
 
+namespace {
+
+CFX_GraphStateData::LineCap LineCapToFXGE(XFA_ATTRIBUTEENUM iLineCap) {
+  switch (iLineCap) {
+    case XFA_ATTRIBUTEENUM_Round:
+      return CFX_GraphStateData::LineCapRound;
+    case XFA_ATTRIBUTEENUM_Butt:
+      return CFX_GraphStateData::LineCapButt;
+    default:
+      break;
+  }
+  return CFX_GraphStateData::LineCapSquare;
+}
+
+}  // namespace
+
 CXFA_FFLine::CXFA_FFLine(CXFA_WidgetAcc* pDataAcc) : CXFA_FFDraw(pDataAcc) {}
 
 CXFA_FFLine::~CXFA_FFLine() {}
@@ -74,12 +90,12 @@
 
   CXFA_LineData lineData = valueData.GetLineData();
   FX_ARGB lineColor = 0xFF000000;
-  int32_t iStrokeType = 0;
   float fLineWidth = 1.0f;
-  int32_t iCap = 0;
+  XFA_ATTRIBUTEENUM iStrokeType = XFA_ATTRIBUTEENUM_Unknown;
+  XFA_ATTRIBUTEENUM iCap = XFA_ATTRIBUTEENUM_Unknown;
   CXFA_EdgeData edgeData = lineData.GetEdgeData();
   if (edgeData.HasValidNode()) {
-    if (edgeData.GetPresence() != XFA_ATTRIBUTEENUM_Visible)
+    if (!edgeData.IsVisible())
       return;
 
     lineColor = edgeData.GetColor();
@@ -107,8 +123,9 @@
   pGS->SetLineWidth(fLineWidth);
   pGS->EnableActOnDash();
   XFA_StrokeTypeSetLineDash(pGS, iStrokeType, iCap);
+
   pGS->SetStrokeColor(CXFA_GEColor(lineColor));
-  pGS->SetLineCap(XFA_LineCapToFXGE(iCap));
+  pGS->SetLineCap(LineCapToFXGE(iCap));
   pGS->StrokePath(&linePath, &mtRotate);
   pGS->RestoreGraphState();
 }
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index a5d19f0..7847bea 100644
--- a/xfa/fxfa/cxfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -90,9 +90,9 @@
     CXFA_StrokeData strokeBeforeData = strokes[(nIndex + 1 * 8 - 1) % 8];
     CXFA_StrokeData strokeAfterData = strokes[nIndex + 1];
     if (strokeData.IsInverted()) {
-      if (!strokeData.SameStyles(strokeBeforeData))
+      if (!strokeData.SameStyles(strokeBeforeData, 0))
         halfBefore = strokeBeforeData.GetThickness() / 2;
-      if (!strokeData.SameStyles(strokeAfterData))
+      if (!strokeData.SameStyles(strokeAfterData, 0))
         halfAfter = strokeAfterData.GetThickness() / 2;
     }
   } else {
@@ -257,7 +257,7 @@
   CXFA_StrokeData strokeData1 = strokes[0];
   for (int32_t i = 1; i < 8; i++) {
     CXFA_StrokeData strokeData2 = strokes[i];
-    if (!strokeData1.SameStyles(strokeData2)) {
+    if (!strokeData1.SameStyles(strokeData2, 0)) {
       bSameStyles = false;
       break;
     }
@@ -754,7 +754,7 @@
   CXFA_StrokeData strokeData1 = strokes[0];
   for (int32_t i = 1; i < 8; i++) {
     CXFA_StrokeData strokeData2 = strokes[i];
-    if (!strokeData1.SameStyles(strokeData2)) {
+    if (!strokeData1.SameStyles(strokeData2, 0)) {
       bSameStyles = false;
       break;
     }
@@ -795,7 +795,7 @@
       continue;
     }
     XFA_BOX_GetPath(strokes, rtWidget, path, i, bStart, !bSameStyles);
-    bStart = !strokeData.SameStyles(strokes[(i + 1) % 8]);
+    bStart = !strokeData.SameStyles(strokes[(i + 1) % 8], 0);
     if (bStart) {
       XFA_BOX_StrokePath(strokeData, &path, pGS, matrix);
       path.Clear();
@@ -1334,16 +1334,19 @@
   eParam.m_pTarget = m_pDataAcc.Get();
   m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Exit, &eParam);
 }
+
 bool CXFA_FFWidget::IsButtonDown() {
   return (m_dwStatus & XFA_WidgetStatus_ButtonDown) != 0;
 }
+
 void CXFA_FFWidget::SetButtonDown(bool bSet) {
   bSet ? m_dwStatus |= XFA_WidgetStatus_ButtonDown
        : m_dwStatus &= ~XFA_WidgetStatus_ButtonDown;
 }
+
 int32_t XFA_StrokeTypeSetLineDash(CXFA_Graphics* pGraphics,
-                                  int32_t iStrokeType,
-                                  int32_t iCapType) {
+                                  XFA_ATTRIBUTEENUM iStrokeType,
+                                  XFA_ATTRIBUTEENUM iCapType) {
   switch (iStrokeType) {
     case XFA_ATTRIBUTEENUM_DashDot: {
       float dashArray[] = {4, 1, 2, 1};
@@ -1366,17 +1369,17 @@
     }
     case XFA_ATTRIBUTEENUM_Dashed: {
       float dashArray[] = {5, 1};
-      if (iCapType != XFA_ATTRIBUTEENUM_Butt) {
+      if (iCapType != XFA_ATTRIBUTEENUM_Butt)
         dashArray[1] = 2;
-      }
+
       pGraphics->SetLineDash(0, dashArray, 2);
       return FX_DASHSTYLE_Dash;
     }
     case XFA_ATTRIBUTEENUM_Dotted: {
       float dashArray[] = {2, 1};
-      if (iCapType != XFA_ATTRIBUTEENUM_Butt) {
+      if (iCapType != XFA_ATTRIBUTEENUM_Butt)
         dashArray[1] = 2;
-      }
+
       pGraphics->SetLineDash(0, dashArray, 2);
       return FX_DASHSTYLE_Dot;
     }
@@ -1386,17 +1389,6 @@
   pGraphics->SetLineDash(FX_DASHSTYLE_Solid);
   return FX_DASHSTYLE_Solid;
 }
-CFX_GraphStateData::LineCap XFA_LineCapToFXGE(int32_t iLineCap) {
-  switch (iLineCap) {
-    case XFA_ATTRIBUTEENUM_Round:
-      return CFX_GraphStateData::LineCapRound;
-    case XFA_ATTRIBUTEENUM_Butt:
-      return CFX_GraphStateData::LineCapButt;
-    default:
-      break;
-  }
-  return CFX_GraphStateData::LineCapSquare;
-}
 
 class CXFA_ImageRenderer {
  public:
diff --git a/xfa/fxfa/cxfa_ffwidget.h b/xfa/fxfa/cxfa_ffwidget.h
index 5729654..4e9863c 100644
--- a/xfa/fxfa/cxfa_ffwidget.h
+++ b/xfa/fxfa/cxfa_ffwidget.h
@@ -35,9 +35,8 @@
 };
 
 int32_t XFA_StrokeTypeSetLineDash(CXFA_Graphics* pGraphics,
-                                  int32_t iStrokeType,
-                                  int32_t iCapType);
-CFX_GraphStateData::LineCap XFA_LineCapToFXGE(int32_t iLineCap);
+                                  XFA_ATTRIBUTEENUM iStrokeType,
+                                  XFA_ATTRIBUTEENUM iCapType);
 void XFA_DrawImage(CXFA_Graphics* pGS,
                    const CFX_RectF& rtImage,
                    const CFX_Matrix& matrix,
diff --git a/xfa/fxfa/parser/cxfa_boxdata.cpp b/xfa/fxfa/parser/cxfa_boxdata.cpp
index a9f7ace..ef9864f 100644
--- a/xfa/fxfa/parser/cxfa_boxdata.cpp
+++ b/xfa/fxfa/parser/cxfa_boxdata.cpp
@@ -63,7 +63,8 @@
       strokeData = find;
     break;
   }
-  int32_t iType = strokeData.GetStrokeType();
+
+  XFA_ATTRIBUTEENUM iType = strokeData.GetStrokeType();
   if (iType == XFA_ATTRIBUTEENUM_Lowered || iType == XFA_ATTRIBUTEENUM_Raised ||
       iType == XFA_ATTRIBUTEENUM_Etched ||
       iType == XFA_ATTRIBUTEENUM_Embossed) {
diff --git a/xfa/fxfa/parser/cxfa_strokedata.cpp b/xfa/fxfa/parser/cxfa_strokedata.cpp
index edbac24..0845719 100644
--- a/xfa/fxfa/parser/cxfa_strokedata.cpp
+++ b/xfa/fxfa/parser/cxfa_strokedata.cpp
@@ -10,18 +10,19 @@
 #include "xfa/fxfa/parser/cxfa_node.h"
 #include "xfa/fxfa/parser/xfa_utils.h"
 
-int32_t CXFA_StrokeData::GetPresence() const {
-  return m_pNode ? m_pNode->JSNode()->GetEnum(XFA_Attribute::Presence)
-                 : XFA_ATTRIBUTEENUM_Invisible;
+bool CXFA_StrokeData::IsVisible() const {
+  return m_pNode ? m_pNode->JSNode()->GetEnum(XFA_Attribute::Presence) ==
+                       XFA_ATTRIBUTEENUM_Visible
+                 : false;
 }
 
-int32_t CXFA_StrokeData::GetCapType() const {
+XFA_ATTRIBUTEENUM CXFA_StrokeData::GetCapType() const {
   if (!m_pNode)
     return XFA_ATTRIBUTEENUM_Square;
   return m_pNode->JSNode()->GetEnum(XFA_Attribute::Cap);
 }
 
-int32_t CXFA_StrokeData::GetStrokeType() const {
+XFA_ATTRIBUTEENUM CXFA_StrokeData::GetStrokeType() const {
   return m_pNode ? m_pNode->JSNode()->GetEnum(XFA_Attribute::Stroke)
                  : XFA_ATTRIBUTEENUM_Solid;
 }
@@ -70,7 +71,7 @@
                             false);
 }
 
-int32_t CXFA_StrokeData::GetJoinType() const {
+XFA_ATTRIBUTEENUM CXFA_StrokeData::GetJoinType() const {
   return m_pNode ? m_pNode->JSNode()->GetEnum(XFA_Attribute::Join)
                  : XFA_ATTRIBUTEENUM_Square;
 }
diff --git a/xfa/fxfa/parser/cxfa_strokedata.h b/xfa/fxfa/parser/cxfa_strokedata.h
index 2921f88..b701c25 100644
--- a/xfa/fxfa/parser/cxfa_strokedata.h
+++ b/xfa/fxfa/parser/cxfa_strokedata.h
@@ -25,20 +25,22 @@
   explicit CXFA_StrokeData(CXFA_Node* pNode) : CXFA_DataData(pNode) {}
 
   bool IsCorner() const { return GetElementType() == XFA_Element::Corner; }
-  bool IsEdge() const { return GetElementType() == XFA_Element::Edge; }
-  bool IsVisible() const { return GetPresence() == XFA_ATTRIBUTEENUM_Visible; }
-  int32_t GetPresence() const;
-  int32_t GetCapType() const;
-  int32_t GetStrokeType() const;
+  bool IsVisible() const;
+  bool IsInverted() const;
+
+  XFA_ATTRIBUTEENUM GetCapType() const;
+  XFA_ATTRIBUTEENUM GetStrokeType() const;
+  XFA_ATTRIBUTEENUM GetJoinType() const;
+  float GetRadius() const;
   float GetThickness() const;
+
   CXFA_Measurement GetMSThickness() const;
   void SetMSThickness(CXFA_Measurement msThinkness);
+
   FX_ARGB GetColor() const;
   void SetColor(FX_ARGB argb);
-  int32_t GetJoinType() const;
-  bool IsInverted() const;
-  float GetRadius() const;
-  bool SameStyles(CXFA_StrokeData stroke, uint32_t dwFlags = 0) const;
+
+  bool SameStyles(CXFA_StrokeData stroke, uint32_t dwFlags) const;
 };
 
 #endif  // XFA_FXFA_PARSER_CXFA_STROKEDATA_H_
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index 4688aee..13b1c7a 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -25,7 +25,7 @@
                        int32_t nIndex) {
   float fThickness = 0;
 
-  if (strokes[nIndex * 2 + 1].GetPresence() == XFA_ATTRIBUTEENUM_Visible) {
+  if (strokes[nIndex * 2 + 1].IsVisible()) {
     if (nIndex == 0)
       fThickness += 2.5f;