Change CFWL_Widget::GetMatrix to return the matrix

This CL switches to using a return value instead of an out parameter. The global
flag was also removed and the call sites changed to just SetIdentity as
appropriate.

Review-Url: https://codereview.chromium.org/2564443003
diff --git a/xfa/fwl/cfwl_widget.cpp b/xfa/fwl/cfwl_widget.cpp
index 071e0de..40b9223 100644
--- a/xfa/fwl/cfwl_widget.cpp
+++ b/xfa/fwl/cfwl_widget.cpp
@@ -195,7 +195,7 @@
     r = GetWidgetRect();
     fx += r.left;
     fy += r.top;
-    GetMatrix(m, true);
+    m = GetMatrix();
     m.TransformPoint(fx, fy);
   }
   CFWL_Widget* form1 = m_pWidgetMgr->GetSystemFormWidget(this);
@@ -221,10 +221,8 @@
   }
   parent = pWidget->GetParent();
   if (parent) {
-    pWidget->GetMatrix(m, true);
     CFX_Matrix m1;
-    m1.SetIdentity();
-    m1.SetReverse(m);
+    m1.SetReverse(pWidget->GetMatrix());
     m1.TransformPoint(fx, fy);
     r = pWidget->GetWidgetRect();
     fx -= r.left;
@@ -232,13 +230,9 @@
   }
 }
 
-void CFWL_Widget::GetMatrix(CFX_Matrix& matrix, bool bGlobal) {
+CFX_Matrix CFWL_Widget::GetMatrix() {
   if (!m_pProperties)
-    return;
-  if (!bGlobal) {
-    matrix.SetIdentity();
-    return;
-  }
+    return CFX_Matrix();
 
   CFWL_Widget* parent = GetParent();
   CFX_ArrayTemplate<CFWL_Widget*> parents;
@@ -246,13 +240,16 @@
     parents.Add(parent);
     parent = parent->GetParent();
   }
-  matrix.SetIdentity();
+
+  CFX_Matrix matrix;
   CFX_Matrix ctmOnParent;
   CFX_RectF rect;
   int32_t count = parents.GetSize();
   for (int32_t i = count - 2; i >= 0; i--) {
     parent = parents.GetAt(i);
-    parent->GetMatrix(ctmOnParent, false);
+
+    if (parent->m_pProperties)
+      ctmOnParent.SetIdentity();
     rect = parent->GetWidgetRect();
     matrix.Concat(ctmOnParent, true);
     matrix.Translate(rect.left, rect.top, true);
@@ -261,6 +258,8 @@
   m.SetIdentity();
   matrix.Concat(m, true);
   parents.RemoveAll();
+
+  return matrix;
 }
 
 IFWL_ThemeProvider* CFWL_Widget::GetThemeProvider() const {
diff --git a/xfa/fwl/cfwl_widget.h b/xfa/fwl/cfwl_widget.h
index 5046aab..e2fce0e 100644
--- a/xfa/fwl/cfwl_widget.h
+++ b/xfa/fwl/cfwl_widget.h
@@ -91,7 +91,7 @@
   }
 
   void TransformTo(CFWL_Widget* pWidget, FX_FLOAT& fx, FX_FLOAT& fy);
-  void GetMatrix(CFX_Matrix& matrix, bool bGlobal);
+  CFX_Matrix GetMatrix();
   IFWL_ThemeProvider* GetThemeProvider() const;
 
   void SetDelegate(IFWL_WidgetDelegate* delegate) { m_pDelegate = delegate; }
diff --git a/xfa/fwl/cfwl_widgetmgr.cpp b/xfa/fwl/cfwl_widgetmgr.cpp
index f01c02b..e7eca10 100644
--- a/xfa/fwl/cfwl_widgetmgr.cpp
+++ b/xfa/fwl/cfwl_widgetmgr.cpp
@@ -298,7 +298,6 @@
       x1 = x;
       y1 = y;
       CFX_Matrix matrixOnParent;
-      child->GetMatrix(matrixOnParent, false);
       CFX_Matrix m;
       m.SetIdentity();
       m.SetReverse(matrixOnParent);
@@ -528,7 +527,7 @@
     CFX_Matrix widgetMatrix;
     CFX_RectF clipBounds(rtWidget);
     if (!bFormDisable)
-      child->GetMatrix(widgetMatrix, true);
+      widgetMatrix = child->GetMatrix();
     if (pMatrix)
       widgetMatrix.Concat(*pMatrix);