Change XFA DrawWidget() code to take its CFX_Matrix by const-ref.

Change-Id: Idc9dfcafe6727c1689443ce8f9568567e55d51c8
Reviewed-on: https://pdfium-review.googlesource.com/11114
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
diff --git a/xfa/fwl/cfwl_barcode.cpp b/xfa/fwl/cfwl_barcode.cpp
index b51bb24..8db40d2 100644
--- a/xfa/fwl/cfwl_barcode.cpp
+++ b/xfa/fwl/cfwl_barcode.cpp
@@ -36,7 +36,7 @@
 }
 
 void CFWL_Barcode::DrawWidget(CXFA_Graphics* pGraphics,
-                              const CFX_Matrix* pMatrix) {
+                              const CFX_Matrix& matrix) {
   if (!pGraphics)
     return;
   if (!m_pProperties->m_pThemeProvider)
@@ -49,13 +49,12 @@
     CFX_Matrix mt;
     mt.e = GetRTClient().left;
     mt.f = GetRTClient().top;
-    if (pMatrix)
-      mt.Concat(*pMatrix);
+    mt.Concat(matrix);
 
-    m_pBarcodeEngine->RenderDevice(pGraphics->GetRenderDevice(), pMatrix);
+    m_pBarcodeEngine->RenderDevice(pGraphics->GetRenderDevice(), &matrix);
     return;
   }
-  CFWL_Edit::DrawWidget(pGraphics, pMatrix);
+  CFWL_Edit::DrawWidget(pGraphics, matrix);
 }
 
 void CFWL_Barcode::SetType(BC_TYPE type) {
diff --git a/xfa/fwl/cfwl_barcode.h b/xfa/fwl/cfwl_barcode.h
index c913a17..48bdeab 100644
--- a/xfa/fwl/cfwl_barcode.h
+++ b/xfa/fwl/cfwl_barcode.h
@@ -45,7 +45,7 @@
   // CFWL_Widget
   FWL_Type GetClassID() const override;
   void Update() override;
-  void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix* pMatrix) override;
+  void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix& matrix) override;
   void OnProcessEvent(CFWL_Event* pEvent) override;
 
   // CFWL_Edit
diff --git a/xfa/fwl/cfwl_caret.cpp b/xfa/fwl/cfwl_caret.cpp
index be7ecbf..1cef4f6 100644
--- a/xfa/fwl/cfwl_caret.cpp
+++ b/xfa/fwl/cfwl_caret.cpp
@@ -44,7 +44,7 @@
 void CFWL_Caret::Update() {}
 
 void CFWL_Caret::DrawWidget(CXFA_Graphics* pGraphics,
-                            const CFX_Matrix* pMatrix) {
+                            const CFX_Matrix& matrix) {
   if (!pGraphics)
     return;
   if (!m_pProperties->m_pThemeProvider)
@@ -52,7 +52,7 @@
   if (!m_pProperties->m_pThemeProvider)
     return;
 
-  DrawCaretBK(pGraphics, m_pProperties->m_pThemeProvider, pMatrix);
+  DrawCaretBK(pGraphics, m_pProperties->m_pThemeProvider, &matrix);
 }
 
 void CFWL_Caret::ShowCaret() {
@@ -90,8 +90,8 @@
 void CFWL_Caret::OnProcessMessage(CFWL_Message* pMessage) {}
 
 void CFWL_Caret::OnDrawWidget(CXFA_Graphics* pGraphics,
-                              const CFX_Matrix* pMatrix) {
-  DrawWidget(pGraphics, pMatrix);
+                              const CFX_Matrix& matrix) {
+  DrawWidget(pGraphics, matrix);
 }
 
 CFWL_Caret::Timer::Timer(CFWL_Caret* pCaret) : CFWL_Timer(pCaret) {}
diff --git a/xfa/fwl/cfwl_caret.h b/xfa/fwl/cfwl_caret.h
index d00f38a..32bc795 100644
--- a/xfa/fwl/cfwl_caret.h
+++ b/xfa/fwl/cfwl_caret.h
@@ -27,10 +27,10 @@
 
   // CFWL_Widget
   FWL_Type GetClassID() const override;
-  void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix* pMatrix) override;
+  void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix& matrix) override;
   void OnProcessMessage(CFWL_Message* pMessage) override;
   void OnDrawWidget(CXFA_Graphics* pGraphics,
-                    const CFX_Matrix* pMatrix) override;
+                    const CFX_Matrix& matrix) override;
   void Update() override;
 
   void ShowCaret();
diff --git a/xfa/fwl/cfwl_checkbox.cpp b/xfa/fwl/cfwl_checkbox.cpp
index bc45e5a..42b6cad 100644
--- a/xfa/fwl/cfwl_checkbox.cpp
+++ b/xfa/fwl/cfwl_checkbox.cpp
@@ -62,7 +62,7 @@
 }
 
 void CFWL_CheckBox::DrawWidget(CXFA_Graphics* pGraphics,
-                               const CFX_Matrix* pMatrix) {
+                               const CFX_Matrix& matrix) {
   if (!pGraphics)
     return;
   if (!m_pProperties->m_pThemeProvider)
@@ -71,7 +71,7 @@
   IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
   if (HasBorder()) {
     DrawBorder(pGraphics, CFWL_Part::Border, m_pProperties->m_pThemeProvider,
-               pMatrix);
+               matrix);
   }
 
   int32_t dwStates = GetPartStates();
@@ -81,8 +81,7 @@
   param.m_iPart = CFWL_Part::Background;
   param.m_dwStates = dwStates;
   param.m_pGraphics = pGraphics;
-  if (pMatrix)
-    param.m_matrix.Concat(*pMatrix);
+  param.m_matrix.Concat(matrix);
   param.m_rtPart = m_rtClient;
   if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused)
     param.m_pData = &m_rtFocus;
@@ -97,8 +96,7 @@
   textParam.m_iPart = CFWL_Part::Caption;
   textParam.m_dwStates = dwStates;
   textParam.m_pGraphics = pGraphics;
-  if (pMatrix)
-    textParam.m_matrix.Concat(*pMatrix);
+  textParam.m_matrix.Concat(matrix);
   textParam.m_rtPart = m_rtCaption;
   textParam.m_wsText = L"Check box";
   textParam.m_dwTTOStyles = m_dwTTOStyles;
@@ -268,8 +266,8 @@
 }
 
 void CFWL_CheckBox::OnDrawWidget(CXFA_Graphics* pGraphics,
-                                 const CFX_Matrix* pMatrix) {
-  DrawWidget(pGraphics, pMatrix);
+                                 const CFX_Matrix& matrix) {
+  DrawWidget(pGraphics, matrix);
 }
 
 void CFWL_CheckBox::OnFocusChanged(bool bSet) {
diff --git a/xfa/fwl/cfwl_checkbox.h b/xfa/fwl/cfwl_checkbox.h
index e90fbd1..9ae6590 100644
--- a/xfa/fwl/cfwl_checkbox.h
+++ b/xfa/fwl/cfwl_checkbox.h
@@ -41,11 +41,11 @@
   // CFWL_Widget
   FWL_Type GetClassID() const override;
   void Update() override;
-  void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix* pMatrix) override;
+  void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix& matrix) override;
 
   void OnProcessMessage(CFWL_Message* pMessage) override;
   void OnDrawWidget(CXFA_Graphics* pGraphics,
-                    const CFX_Matrix* pMatrix) override;
+                    const CFX_Matrix& matrix) override;
 
   void SetBoxSize(float fHeight);
 
diff --git a/xfa/fwl/cfwl_combobox.cpp b/xfa/fwl/cfwl_combobox.cpp
index ec90a15..a3dbe8c 100644
--- a/xfa/fwl/cfwl_combobox.cpp
+++ b/xfa/fwl/cfwl_combobox.cpp
@@ -126,9 +126,9 @@
 }
 
 void CFWL_ComboBox::DrawWidget(CXFA_Graphics* pGraphics,
-                               const CFX_Matrix* pMatrix) {
+                               const CFX_Matrix& matrix) {
   if (m_pWidgetMgr->IsFormDisabled()) {
-    DisForm_DrawWidget(pGraphics, pMatrix);
+    DisForm_DrawWidget(pGraphics, &matrix);
     return;
   }
 
@@ -139,7 +139,7 @@
 
   IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
   if (HasBorder())
-    DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
+    DrawBorder(pGraphics, CFWL_Part::Border, pTheme, matrix);
 
   if (!IsDropDownStyle()) {
     CFX_RectF rtTextBk(m_rtClient);
@@ -149,8 +149,7 @@
     param.m_pWidget = this;
     param.m_iPart = CFWL_Part::Background;
     param.m_pGraphics = pGraphics;
-    if (pMatrix)
-      param.m_matrix.Concat(*pMatrix);
+    param.m_matrix.Concat(matrix);
     param.m_rtPart = rtTextBk;
 
     if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
@@ -174,7 +173,7 @@
       theme_text.m_iPart = CFWL_Part::Caption;
       theme_text.m_dwStates = m_iBtnState;
       theme_text.m_pGraphics = pGraphics;
-      theme_text.m_matrix.Concat(*pMatrix);
+      theme_text.m_matrix.Concat(matrix);
       theme_text.m_rtPart = rtTextBk;
       theme_text.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused)
                                   ? CFWL_PartState_Selected
@@ -193,7 +192,7 @@
                          ? CFWL_PartState_Disabled
                          : m_iBtnState;
   param.m_pGraphics = pGraphics;
-  param.m_matrix.Concat(*pMatrix);
+  param.m_matrix.Concat(matrix);
   param.m_rtPart = m_rtBtn;
   pTheme->DrawBackground(&param);
 }
@@ -639,13 +638,13 @@
     CFX_RectF rtEdit = m_pEdit->GetWidgetRect();
     CFX_Matrix mt(1, 0, 0, 1, rtEdit.left, rtEdit.top);
     mt.Concat(mtOrg);
-    m_pEdit->DrawWidget(pGraphics, &mt);
+    m_pEdit->DrawWidget(pGraphics, mt);
   }
   if (m_pListBox && DisForm_IsDropListVisible()) {
     CFX_RectF rtList = m_pListBox->GetWidgetRect();
     CFX_Matrix mt(1, 0, 0, 1, rtList.left, rtList.top);
     mt.Concat(mtOrg);
-    m_pListBox->DrawWidget(pGraphics, &mt);
+    m_pListBox->DrawWidget(pGraphics, mt);
   }
 }
 
@@ -757,8 +756,8 @@
 }
 
 void CFWL_ComboBox::OnDrawWidget(CXFA_Graphics* pGraphics,
-                                 const CFX_Matrix* pMatrix) {
-  DrawWidget(pGraphics, pMatrix);
+                                 const CFX_Matrix& matrix) {
+  DrawWidget(pGraphics, matrix);
 }
 
 void CFWL_ComboBox::OnFocusChanged(CFWL_Message* pMsg, bool bSet) {
diff --git a/xfa/fwl/cfwl_combobox.h b/xfa/fwl/cfwl_combobox.h
index 396aa6c..0e1f815 100644
--- a/xfa/fwl/cfwl_combobox.h
+++ b/xfa/fwl/cfwl_combobox.h
@@ -52,12 +52,12 @@
   void RemoveStates(uint32_t dwStates) override;
   void Update() override;
   FWL_WidgetHit HitTest(const CFX_PointF& point) override;
-  void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix* pMatrix) override;
+  void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix& matrix) override;
   void SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) override;
   void OnProcessMessage(CFWL_Message* pMessage) override;
   void OnProcessEvent(CFWL_Event* pEvent) override;
   void OnDrawWidget(CXFA_Graphics* pGraphics,
-                    const CFX_Matrix* pMatrix) override;
+                    const CFX_Matrix& matrix) override;
 
   CFX_WideString GetTextByIndex(int32_t iIndex) const;
   int32_t GetCurSel() const { return m_iCurSel; }
diff --git a/xfa/fwl/cfwl_comboboxproxy.cpp b/xfa/fwl/cfwl_comboboxproxy.cpp
index 28c403f..d1db1c0 100644
--- a/xfa/fwl/cfwl_comboboxproxy.cpp
+++ b/xfa/fwl/cfwl_comboboxproxy.cpp
@@ -59,8 +59,8 @@
 }
 
 void CFWL_ComboBoxProxy::OnDrawWidget(CXFA_Graphics* pGraphics,
-                                      const CFX_Matrix* pMatrix) {
-  m_pComboBox->DrawStretchHandler(pGraphics, pMatrix);
+                                      const CFX_Matrix& matrix) {
+  m_pComboBox->DrawStretchHandler(pGraphics, &matrix);
 }
 
 void CFWL_ComboBoxProxy::OnLButtonDown(CFWL_Message* pMessage) {
diff --git a/xfa/fwl/cfwl_comboboxproxy.h b/xfa/fwl/cfwl_comboboxproxy.h
index 8282348..bb21707 100644
--- a/xfa/fwl/cfwl_comboboxproxy.h
+++ b/xfa/fwl/cfwl_comboboxproxy.h
@@ -24,7 +24,7 @@
   // CFWL_FormProxy
   void OnProcessMessage(CFWL_Message* pMessage) override;
   void OnDrawWidget(CXFA_Graphics* pGraphics,
-                    const CFX_Matrix* pMatrix) override;
+                    const CFX_Matrix& matrix) override;
 
   void Reset() { m_bLButtonUpSelf = false; }
 
diff --git a/xfa/fwl/cfwl_datetimepicker.cpp b/xfa/fwl/cfwl_datetimepicker.cpp
index 1a82a5c7..7383729a 100644
--- a/xfa/fwl/cfwl_datetimepicker.cpp
+++ b/xfa/fwl/cfwl_datetimepicker.cpp
@@ -115,7 +115,7 @@
 }
 
 void CFWL_DateTimePicker::DrawWidget(CXFA_Graphics* pGraphics,
-                                     const CFX_Matrix* pMatrix) {
+                                     const CFX_Matrix& matrix) {
   if (!pGraphics)
     return;
   if (!m_pProperties->m_pThemeProvider)
@@ -123,11 +123,11 @@
 
   IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
   if (HasBorder())
-    DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
+    DrawBorder(pGraphics, CFWL_Part::Border, pTheme, matrix);
   if (!m_rtBtn.IsEmpty())
-    DrawDropDownButton(pGraphics, pTheme, pMatrix);
+    DrawDropDownButton(pGraphics, pTheme, &matrix);
   if (m_pWidgetMgr->IsFormDisabled()) {
-    DisForm_DrawWidget(pGraphics, pMatrix);
+    DisForm_DrawWidget(pGraphics, &matrix);
     return;
   }
 }
@@ -453,7 +453,7 @@
     CFX_Matrix mt(1, 0, 0, 1, rtEdit.left, rtEdit.top);
     if (pMatrix)
       mt.Concat(*pMatrix);
-    m_pEdit->DrawWidget(pGraphics, &mt);
+    m_pEdit->DrawWidget(pGraphics, mt);
   }
   if (!IsMonthCalendarVisible())
     return;
@@ -462,7 +462,7 @@
   CFX_Matrix mt(1, 0, 0, 1, rtMonth.left, rtMonth.top);
   if (pMatrix)
     mt.Concat(*pMatrix);
-  m_pMonthCal->DrawWidget(pGraphics, &mt);
+  m_pMonthCal->DrawWidget(pGraphics, mt);
 }
 
 void CFWL_DateTimePicker::OnProcessMessage(CFWL_Message* pMessage) {
@@ -511,8 +511,8 @@
 }
 
 void CFWL_DateTimePicker::OnDrawWidget(CXFA_Graphics* pGraphics,
-                                       const CFX_Matrix* pMatrix) {
-  DrawWidget(pGraphics, pMatrix);
+                                       const CFX_Matrix& matrix) {
+  DrawWidget(pGraphics, matrix);
 }
 
 void CFWL_DateTimePicker::OnFocusChanged(CFWL_Message* pMsg, bool bSet) {
diff --git a/xfa/fwl/cfwl_datetimepicker.h b/xfa/fwl/cfwl_datetimepicker.h
index 79e9cad..fa7653e 100644
--- a/xfa/fwl/cfwl_datetimepicker.h
+++ b/xfa/fwl/cfwl_datetimepicker.h
@@ -39,11 +39,11 @@
   FWL_Type GetClassID() const override;
   void Update() override;
   FWL_WidgetHit HitTest(const CFX_PointF& point) override;
-  void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix* pMatrix) override;
+  void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix& matrix) override;
   void SetThemeProvider(IFWL_ThemeProvider* pTP) override;
   void OnProcessMessage(CFWL_Message* pMessage) override;
   void OnDrawWidget(CXFA_Graphics* pGraphics,
-                    const CFX_Matrix* pMatrix) override;
+                    const CFX_Matrix& matrix) override;
 
   void GetCurSel(int32_t& iYear, int32_t& iMonth, int32_t& iDay);
   void SetCurSel(int32_t iYear, int32_t iMonth, int32_t iDay);
diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp
index 184329f..fc8b0fa 100644
--- a/xfa/fwl/cfwl_edit.cpp
+++ b/xfa/fwl/cfwl_edit.cpp
@@ -239,8 +239,7 @@
   pGraphics->RestoreGraphState();
 }
 
-void CFWL_Edit::DrawWidget(CXFA_Graphics* pGraphics,
-                           const CFX_Matrix* pMatrix) {
+void CFWL_Edit::DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix& matrix) {
   if (!pGraphics)
     return;
   if (!m_pProperties->m_pThemeProvider)
@@ -250,15 +249,15 @@
 
   IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
   if (!m_pWidgetMgr->IsFormDisabled())
-    DrawTextBk(pGraphics, pTheme, pMatrix);
-  DrawContent(pGraphics, pTheme, pMatrix);
+    DrawTextBk(pGraphics, pTheme, &matrix);
+  DrawContent(pGraphics, pTheme, &matrix);
 
   if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) &&
       !(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly)) {
-    DrawSpellCheck(pGraphics, pMatrix);
+    DrawSpellCheck(pGraphics, &matrix);
   }
   if (HasBorder())
-    DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
+    DrawBorder(pGraphics, CFWL_Part::Border, pTheme, matrix);
 }
 
 void CFWL_Edit::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
@@ -1263,8 +1262,8 @@
 }
 
 void CFWL_Edit::OnDrawWidget(CXFA_Graphics* pGraphics,
-                             const CFX_Matrix* pMatrix) {
-  DrawWidget(pGraphics, pMatrix);
+                             const CFX_Matrix& matrix) {
+  DrawWidget(pGraphics, matrix);
 }
 
 void CFWL_Edit::DoButtonDown(CFWL_MessageMouse* pMsg) {
diff --git a/xfa/fwl/cfwl_edit.h b/xfa/fwl/cfwl_edit.h
index 9915f05..23d6158 100644
--- a/xfa/fwl/cfwl_edit.h
+++ b/xfa/fwl/cfwl_edit.h
@@ -61,12 +61,12 @@
   void Update() override;
   FWL_WidgetHit HitTest(const CFX_PointF& point) override;
   void SetStates(uint32_t dwStates) override;
-  void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix* pMatrix) override;
+  void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix& matrix) override;
   void SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) override;
   void OnProcessMessage(CFWL_Message* pMessage) override;
   void OnProcessEvent(CFWL_Event* pEvent) override;
   void OnDrawWidget(CXFA_Graphics* pGraphics,
-                    const CFX_Matrix* pMatrix) override;
+                    const CFX_Matrix& matrix) override;
 
   virtual void SetText(const CFX_WideString& wsText);
 
diff --git a/xfa/fwl/cfwl_form.cpp b/xfa/fwl/cfwl_form.cpp
index c560a0d..5ab7a56 100644
--- a/xfa/fwl/cfwl_form.cpp
+++ b/xfa/fwl/cfwl_form.cpp
@@ -75,8 +75,7 @@
                                : FWL_WidgetHit::Client;
 }
 
-void CFWL_Form::DrawWidget(CXFA_Graphics* pGraphics,
-                           const CFX_Matrix* pMatrix) {
+void CFWL_Form::DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix& matrix) {
   if (!pGraphics)
     return;
   if (!m_pProperties->m_pThemeProvider)
@@ -93,8 +92,7 @@
   param.m_dwStates = CFWL_PartState_Normal;
   param.m_pGraphics = pGraphics;
   param.m_rtPart = m_rtRelative;
-  if (pMatrix)
-    param.m_matrix.Concat(*pMatrix);
+  param.m_matrix.Concat(matrix);
   if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) {
     param.m_iPart = CFWL_Part::Border;
     pTheme->DrawBackground(&param);
@@ -240,8 +238,8 @@
 }
 
 void CFWL_Form::OnDrawWidget(CXFA_Graphics* pGraphics,
-                             const CFX_Matrix* pMatrix) {
-  DrawWidget(pGraphics, pMatrix);
+                             const CFX_Matrix& matrix) {
+  DrawWidget(pGraphics, matrix);
 }
 
 void CFWL_Form::OnLButtonDown(CFWL_MessageMouse* pMsg) {
diff --git a/xfa/fwl/cfwl_form.h b/xfa/fwl/cfwl_form.h
index 96452e8..78fee4b 100644
--- a/xfa/fwl/cfwl_form.h
+++ b/xfa/fwl/cfwl_form.h
@@ -38,10 +38,10 @@
   CFX_RectF GetClientRect() override;
   void Update() override;
   FWL_WidgetHit HitTest(const CFX_PointF& point) override;
-  void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix* pMatrix) override;
+  void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix& matrix) override;
   void OnProcessMessage(CFWL_Message* pMessage) override;
   void OnDrawWidget(CXFA_Graphics* pGraphics,
-                    const CFX_Matrix* pMatrix) override;
+                    const CFX_Matrix& matrix) override;
 
   CFWL_Widget* DoModal();
   void EndDoModal();
diff --git a/xfa/fwl/cfwl_formproxy.cpp b/xfa/fwl/cfwl_formproxy.cpp
index af7703e..123cf25 100644
--- a/xfa/fwl/cfwl_formproxy.cpp
+++ b/xfa/fwl/cfwl_formproxy.cpp
@@ -33,7 +33,7 @@
 void CFWL_FormProxy::Update() {}
 
 void CFWL_FormProxy::DrawWidget(CXFA_Graphics* pGraphics,
-                                const CFX_Matrix* pMatrix) {}
+                                const CFX_Matrix& matrix) {}
 
 void CFWL_FormProxy::OnProcessMessage(CFWL_Message* pMessage) {
   m_pOuter->GetDelegate()->OnProcessMessage(pMessage);
diff --git a/xfa/fwl/cfwl_formproxy.h b/xfa/fwl/cfwl_formproxy.h
index dbc49d8..6307195 100644
--- a/xfa/fwl/cfwl_formproxy.h
+++ b/xfa/fwl/cfwl_formproxy.h
@@ -24,7 +24,7 @@
   FWL_Type GetClassID() const override;
   bool IsInstance(const CFX_WideStringC& wsClass) const override;
   void Update() override;
-  void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix* pMatrix) override;
+  void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix& matrix) override;
   void OnProcessMessage(CFWL_Message* pMessage) override;
 };
 
diff --git a/xfa/fwl/cfwl_listbox.cpp b/xfa/fwl/cfwl_listbox.cpp
index d0455ff..ce1c013 100644
--- a/xfa/fwl/cfwl_listbox.cpp
+++ b/xfa/fwl/cfwl_listbox.cpp
@@ -91,7 +91,7 @@
 }
 
 void CFWL_ListBox::DrawWidget(CXFA_Graphics* pGraphics,
-                              const CFX_Matrix* pMatrix) {
+                              const CFX_Matrix& matrix) {
   if (!pGraphics)
     return;
   if (!m_pProperties->m_pThemeProvider)
@@ -100,21 +100,20 @@
   IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
   pGraphics->SaveGraphState();
   if (HasBorder())
-    DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
+    DrawBorder(pGraphics, CFWL_Part::Border, pTheme, matrix);
 
   CFX_RectF rtClip(m_rtConent);
   if (IsShowScrollBar(false))
     rtClip.height -= m_fScorllBarWidth;
   if (IsShowScrollBar(true))
     rtClip.width -= m_fScorllBarWidth;
-  if (pMatrix)
-    pMatrix->TransformRect(rtClip);
+  matrix.TransformRect(rtClip);
 
   pGraphics->SetClipRect(rtClip);
   if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_NoBackground) == 0)
-    DrawBkground(pGraphics, pTheme, pMatrix);
+    DrawBkground(pGraphics, pTheme, &matrix);
 
-  DrawItems(pGraphics, pTheme, pMatrix);
+  DrawItems(pGraphics, pTheme, &matrix);
   pGraphics->RestoreGraphState();
 }
 
@@ -714,8 +713,8 @@
 }
 
 void CFWL_ListBox::OnDrawWidget(CXFA_Graphics* pGraphics,
-                                const CFX_Matrix* pMatrix) {
-  DrawWidget(pGraphics, pMatrix);
+                                const CFX_Matrix& matrix) {
+  DrawWidget(pGraphics, matrix);
 }
 
 void CFWL_ListBox::OnFocusChanged(CFWL_Message* pMsg, bool bSet) {
diff --git a/xfa/fwl/cfwl_listbox.h b/xfa/fwl/cfwl_listbox.h
index e98f21b..4704a8a 100644
--- a/xfa/fwl/cfwl_listbox.h
+++ b/xfa/fwl/cfwl_listbox.h
@@ -42,12 +42,12 @@
   FWL_Type GetClassID() const override;
   void Update() override;
   FWL_WidgetHit HitTest(const CFX_PointF& point) override;
-  void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix* pMatrix) override;
+  void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix& matrix) override;
   void SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) override;
   void OnProcessMessage(CFWL_Message* pMessage) override;
   void OnProcessEvent(CFWL_Event* pEvent) override;
   void OnDrawWidget(CXFA_Graphics* pGraphics,
-                    const CFX_Matrix* pMatrix) override;
+                    const CFX_Matrix& matrix) override;
 
   int32_t CountItems(const CFWL_Widget* pWidget) const;
   CFWL_ListItem* GetItem(const CFWL_Widget* pWidget, int32_t nIndex) const;
diff --git a/xfa/fwl/cfwl_monthcalendar.cpp b/xfa/fwl/cfwl_monthcalendar.cpp
index 64e6977..11712fe 100644
--- a/xfa/fwl/cfwl_monthcalendar.cpp
+++ b/xfa/fwl/cfwl_monthcalendar.cpp
@@ -147,7 +147,7 @@
 }
 
 void CFWL_MonthCalendar::DrawWidget(CXFA_Graphics* pGraphics,
-                                    const CFX_Matrix* pMatrix) {
+                                    const CFX_Matrix& matrix) {
   if (!pGraphics)
     return;
   if (!m_pProperties->m_pThemeProvider)
@@ -155,20 +155,20 @@
 
   IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
   if (HasBorder())
-    DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
+    DrawBorder(pGraphics, CFWL_Part::Border, pTheme, matrix);
 
-  DrawBackground(pGraphics, pTheme, pMatrix);
-  DrawHeadBK(pGraphics, pTheme, pMatrix);
-  DrawLButton(pGraphics, pTheme, pMatrix);
-  DrawRButton(pGraphics, pTheme, pMatrix);
-  DrawSeperator(pGraphics, pTheme, pMatrix);
-  DrawDatesInBK(pGraphics, pTheme, pMatrix);
-  DrawDatesInCircle(pGraphics, pTheme, pMatrix);
-  DrawCaption(pGraphics, pTheme, pMatrix);
-  DrawWeek(pGraphics, pTheme, pMatrix);
-  DrawDatesIn(pGraphics, pTheme, pMatrix);
-  DrawDatesOut(pGraphics, pTheme, pMatrix);
-  DrawToday(pGraphics, pTheme, pMatrix);
+  DrawBackground(pGraphics, pTheme, &matrix);
+  DrawHeadBK(pGraphics, pTheme, &matrix);
+  DrawLButton(pGraphics, pTheme, &matrix);
+  DrawRButton(pGraphics, pTheme, &matrix);
+  DrawSeperator(pGraphics, pTheme, &matrix);
+  DrawDatesInBK(pGraphics, pTheme, &matrix);
+  DrawDatesInCircle(pGraphics, pTheme, &matrix);
+  DrawCaption(pGraphics, pTheme, &matrix);
+  DrawWeek(pGraphics, pTheme, &matrix);
+  DrawDatesIn(pGraphics, pTheme, &matrix);
+  DrawDatesOut(pGraphics, pTheme, &matrix);
+  DrawToday(pGraphics, pTheme, &matrix);
 }
 
 void CFWL_MonthCalendar::SetSelect(int32_t iYear,
@@ -749,8 +749,8 @@
 }
 
 void CFWL_MonthCalendar::OnDrawWidget(CXFA_Graphics* pGraphics,
-                                      const CFX_Matrix* pMatrix) {
-  DrawWidget(pGraphics, pMatrix);
+                                      const CFX_Matrix& matrix) {
+  DrawWidget(pGraphics, matrix);
 }
 
 void CFWL_MonthCalendar::OnLButtonDown(CFWL_MessageMouse* pMsg) {
diff --git a/xfa/fwl/cfwl_monthcalendar.h b/xfa/fwl/cfwl_monthcalendar.h
index e537c33..6e0d471 100644
--- a/xfa/fwl/cfwl_monthcalendar.h
+++ b/xfa/fwl/cfwl_monthcalendar.h
@@ -33,10 +33,10 @@
   FWL_Type GetClassID() const override;
   CFX_RectF GetAutosizedWidgetRect() override;
   void Update() override;
-  void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix* pMatrix) override;
+  void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix& matrix) override;
   void OnProcessMessage(CFWL_Message* pMessage) override;
   void OnDrawWidget(CXFA_Graphics* pGraphics,
-                    const CFX_Matrix* pMatrix) override;
+                    const CFX_Matrix& matrix) override;
 
   void SetSelect(int32_t iYear, int32_t iMonth, int32_t iDay);
 
diff --git a/xfa/fwl/cfwl_picturebox.cpp b/xfa/fwl/cfwl_picturebox.cpp
index 096b14e..637de94 100644
--- a/xfa/fwl/cfwl_picturebox.cpp
+++ b/xfa/fwl/cfwl_picturebox.cpp
@@ -33,7 +33,7 @@
 }
 
 void CFWL_PictureBox::DrawWidget(CXFA_Graphics* pGraphics,
-                                 const CFX_Matrix* pMatrix) {
+                                 const CFX_Matrix& matrix) {
   if (!pGraphics)
     return;
   if (!m_pProperties->m_pThemeProvider)
@@ -41,10 +41,10 @@
 
   IFWL_ThemeProvider* pTheme = GetAvailableTheme();
   if (HasBorder())
-    DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
+    DrawBorder(pGraphics, CFWL_Part::Border, pTheme, matrix);
 }
 
 void CFWL_PictureBox::OnDrawWidget(CXFA_Graphics* pGraphics,
-                                   const CFX_Matrix* pMatrix) {
-  DrawWidget(pGraphics, pMatrix);
+                                   const CFX_Matrix& matrix) {
+  DrawWidget(pGraphics, matrix);
 }
diff --git a/xfa/fwl/cfwl_picturebox.h b/xfa/fwl/cfwl_picturebox.h
index e244c85..363db8a 100644
--- a/xfa/fwl/cfwl_picturebox.h
+++ b/xfa/fwl/cfwl_picturebox.h
@@ -23,9 +23,9 @@
   // CFWL_Widget
   FWL_Type GetClassID() const override;
   void Update() override;
-  void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix* pMatrix) override;
+  void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix& matrix) override;
   void OnDrawWidget(CXFA_Graphics* pGraphics,
-                    const CFX_Matrix* pMatrix) override;
+                    const CFX_Matrix& matrix) override;
 
  private:
   CFX_RectF m_rtClient;
diff --git a/xfa/fwl/cfwl_pushbutton.cpp b/xfa/fwl/cfwl_pushbutton.cpp
index 1dfe2db..a912108 100644
--- a/xfa/fwl/cfwl_pushbutton.cpp
+++ b/xfa/fwl/cfwl_pushbutton.cpp
@@ -49,7 +49,7 @@
 }
 
 void CFWL_PushButton::DrawWidget(CXFA_Graphics* pGraphics,
-                                 const CFX_Matrix* pMatrix) {
+                                 const CFX_Matrix& matrix) {
   if (!pGraphics)
     return;
   if (!m_pProperties->m_pThemeProvider)
@@ -57,9 +57,9 @@
 
   if (HasBorder()) {
     DrawBorder(pGraphics, CFWL_Part::Border, m_pProperties->m_pThemeProvider,
-               pMatrix);
+               matrix);
   }
-  DrawBkground(pGraphics, m_pProperties->m_pThemeProvider, pMatrix);
+  DrawBkground(pGraphics, m_pProperties->m_pThemeProvider, &matrix);
 }
 
 void CFWL_PushButton::DrawBkground(CXFA_Graphics* pGraphics,
@@ -137,8 +137,8 @@
 }
 
 void CFWL_PushButton::OnDrawWidget(CXFA_Graphics* pGraphics,
-                                   const CFX_Matrix* pMatrix) {
-  DrawWidget(pGraphics, pMatrix);
+                                   const CFX_Matrix& matrix) {
+  DrawWidget(pGraphics, matrix);
 }
 
 void CFWL_PushButton::OnFocusChanged(CFWL_Message* pMsg, bool bSet) {
diff --git a/xfa/fwl/cfwl_pushbutton.h b/xfa/fwl/cfwl_pushbutton.h
index 84019ba..5c509fb 100644
--- a/xfa/fwl/cfwl_pushbutton.h
+++ b/xfa/fwl/cfwl_pushbutton.h
@@ -28,10 +28,10 @@
   FWL_Type GetClassID() const override;
   void SetStates(uint32_t dwStates) override;
   void Update() override;
-  void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix* pMatrix) override;
+  void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix& matrix) override;
   void OnProcessMessage(CFWL_Message* pMessage) override;
   void OnDrawWidget(CXFA_Graphics* pGraphics,
-                    const CFX_Matrix* pMatrix) override;
+                    const CFX_Matrix& matrix) override;
 
  private:
   void DrawBkground(CXFA_Graphics* pGraphics,
diff --git a/xfa/fwl/cfwl_scrollbar.cpp b/xfa/fwl/cfwl_scrollbar.cpp
index 0e1a9be..f723124 100644
--- a/xfa/fwl/cfwl_scrollbar.cpp
+++ b/xfa/fwl/cfwl_scrollbar.cpp
@@ -75,7 +75,7 @@
 }
 
 void CFWL_ScrollBar::DrawWidget(CXFA_Graphics* pGraphics,
-                                const CFX_Matrix* pMatrix) {
+                                const CFX_Matrix& matrix) {
   if (!pGraphics)
     return;
   if (!m_pProperties->m_pThemeProvider)
@@ -83,12 +83,12 @@
 
   IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
   if (HasBorder())
-    DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
-  DrawTrack(pGraphics, pTheme, true, pMatrix);
-  DrawTrack(pGraphics, pTheme, false, pMatrix);
-  DrawArrowBtn(pGraphics, pTheme, true, pMatrix);
-  DrawArrowBtn(pGraphics, pTheme, false, pMatrix);
-  DrawThumb(pGraphics, pTheme, pMatrix);
+    DrawBorder(pGraphics, CFWL_Part::Border, pTheme, matrix);
+  DrawTrack(pGraphics, pTheme, true, &matrix);
+  DrawTrack(pGraphics, pTheme, false, &matrix);
+  DrawArrowBtn(pGraphics, pTheme, true, &matrix);
+  DrawArrowBtn(pGraphics, pTheme, false, &matrix);
+  DrawThumb(pGraphics, pTheme, &matrix);
 }
 
 void CFWL_ScrollBar::SetTrackPos(float fTrackPos) {
@@ -356,8 +356,8 @@
 }
 
 void CFWL_ScrollBar::OnDrawWidget(CXFA_Graphics* pGraphics,
-                                  const CFX_Matrix* pMatrix) {
-  DrawWidget(pGraphics, pMatrix);
+                                  const CFX_Matrix& matrix) {
+  DrawWidget(pGraphics, matrix);
 }
 
 void CFWL_ScrollBar::OnLButtonDown(const CFX_PointF& point) {
diff --git a/xfa/fwl/cfwl_scrollbar.h b/xfa/fwl/cfwl_scrollbar.h
index 368dee9..b2523a6 100644
--- a/xfa/fwl/cfwl_scrollbar.h
+++ b/xfa/fwl/cfwl_scrollbar.h
@@ -30,10 +30,10 @@
   // CFWL_Widget
   FWL_Type GetClassID() const override;
   void Update() override;
-  void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix* pMatrix) override;
+  void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix& matrix) override;
   void OnProcessMessage(CFWL_Message* pMessage) override;
   void OnDrawWidget(CXFA_Graphics* pGraphics,
-                    const CFX_Matrix* pMatrix) override;
+                    const CFX_Matrix& matrix) override;
 
   void GetRange(float* fMin, float* fMax) const {
     ASSERT(fMin);
diff --git a/xfa/fwl/cfwl_spinbutton.cpp b/xfa/fwl/cfwl_spinbutton.cpp
index 2943c20..3119c75 100644
--- a/xfa/fwl/cfwl_spinbutton.cpp
+++ b/xfa/fwl/cfwl_spinbutton.cpp
@@ -79,20 +79,19 @@
 }
 
 void CFWL_SpinButton::DrawWidget(CXFA_Graphics* pGraphics,
-                                 const CFX_Matrix* pMatrix) {
+                                 const CFX_Matrix& matrix) {
   if (!pGraphics)
     return;
 
   CFX_RectF rtClip(m_rtClient);
-  if (pMatrix)
-    pMatrix->TransformRect(rtClip);
+  matrix.TransformRect(rtClip);
 
   IFWL_ThemeProvider* pTheme = GetAvailableTheme();
   if (HasBorder())
-    DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
+    DrawBorder(pGraphics, CFWL_Part::Border, pTheme, matrix);
 
-  DrawUpButton(pGraphics, pTheme, pMatrix);
-  DrawDownButton(pGraphics, pTheme, pMatrix);
+  DrawUpButton(pGraphics, pTheme, &matrix);
+  DrawDownButton(pGraphics, pTheme, &matrix);
 }
 
 void CFWL_SpinButton::DisableButton() {
@@ -183,8 +182,8 @@
 }
 
 void CFWL_SpinButton::OnDrawWidget(CXFA_Graphics* pGraphics,
-                                   const CFX_Matrix* pMatrix) {
-  DrawWidget(pGraphics, pMatrix);
+                                   const CFX_Matrix& matrix) {
+  DrawWidget(pGraphics, matrix);
 }
 
 void CFWL_SpinButton::OnFocusChanged(CFWL_Message* pMsg, bool bSet) {
diff --git a/xfa/fwl/cfwl_spinbutton.h b/xfa/fwl/cfwl_spinbutton.h
index 2dcb848..2ebabb1 100644
--- a/xfa/fwl/cfwl_spinbutton.h
+++ b/xfa/fwl/cfwl_spinbutton.h
@@ -28,10 +28,10 @@
   FWL_Type GetClassID() const override;
   void Update() override;
   FWL_WidgetHit HitTest(const CFX_PointF& point) override;
-  void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix* pMatrix) override;
+  void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix& matrix) override;
   void OnProcessMessage(CFWL_Message* pMessage) override;
   void OnDrawWidget(CXFA_Graphics* pGraphics,
-                    const CFX_Matrix* pMatrix) override;
+                    const CFX_Matrix& matrix) override;
 
  private:
   class Timer : public CFWL_Timer {
diff --git a/xfa/fwl/cfwl_widget.cpp b/xfa/fwl/cfwl_widget.cpp
index 8b8bf5d..9071f0f 100644
--- a/xfa/fwl/cfwl_widget.cpp
+++ b/xfa/fwl/cfwl_widget.cpp
@@ -538,13 +538,12 @@
 void CFWL_Widget::DrawBorder(CXFA_Graphics* pGraphics,
                              CFWL_Part iPartBorder,
                              IFWL_ThemeProvider* pTheme,
-                             const CFX_Matrix* pMatrix) {
+                             const CFX_Matrix& matrix) {
   CFWL_ThemeBackground param;
   param.m_pWidget = this;
   param.m_iPart = iPartBorder;
   param.m_pGraphics = pGraphics;
-  if (pMatrix)
-    param.m_matrix.Concat(*pMatrix, true);
+  param.m_matrix.Concat(matrix, true);
   param.m_rtPart = GetRelativeRect();
   pTheme->DrawBackground(&param);
 }
@@ -614,4 +613,4 @@
 void CFWL_Widget::OnProcessEvent(CFWL_Event* pEvent) {}
 
 void CFWL_Widget::OnDrawWidget(CXFA_Graphics* pGraphics,
-                               const CFX_Matrix* pMatrix) {}
+                               const CFX_Matrix& matrix) {}
diff --git a/xfa/fwl/cfwl_widget.h b/xfa/fwl/cfwl_widget.h
index 11b3569..3111e9e 100644
--- a/xfa/fwl/cfwl_widget.h
+++ b/xfa/fwl/cfwl_widget.h
@@ -65,14 +65,14 @@
   virtual void Update() = 0;
   virtual FWL_WidgetHit HitTest(const CFX_PointF& point);
   virtual void DrawWidget(CXFA_Graphics* pGraphics,
-                          const CFX_Matrix* pMatrix) = 0;
+                          const CFX_Matrix& matrix) = 0;
   virtual void SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
 
   // IFWL_WidgetDelegate.
   void OnProcessMessage(CFWL_Message* pMessage) override;
   void OnProcessEvent(CFWL_Event* pEvent) override;
   void OnDrawWidget(CXFA_Graphics* pGraphics,
-                    const CFX_Matrix* pMatrix) override;
+                    const CFX_Matrix& matrix) override;
 
   void InflateWidgetRect(CFX_RectF& rect);
   void SetWidgetRect(const CFX_RectF& rect);
@@ -147,7 +147,7 @@
   void DrawBorder(CXFA_Graphics* pGraphics,
                   CFWL_Part iPartBorder,
                   IFWL_ThemeProvider* pTheme,
-                  const CFX_Matrix* pMatrix);
+                  const CFX_Matrix& pMatrix);
 
   CFX_UnownedPtr<const CFWL_App> const m_pOwnerApp;
   CFX_UnownedPtr<CFWL_WidgetMgr> const m_pWidgetMgr;
diff --git a/xfa/fwl/cfwl_widgetmgr.cpp b/xfa/fwl/cfwl_widgetmgr.cpp
index d5b496a..f5beb41 100644
--- a/xfa/fwl/cfwl_widgetmgr.cpp
+++ b/xfa/fwl/cfwl_widgetmgr.cpp
@@ -419,7 +419,7 @@
 
 void CFWL_WidgetMgr::OnDrawWidget(CFWL_Widget* pWidget,
                                   CXFA_Graphics* pGraphics,
-                                  const CFX_Matrix* pMatrix) {
+                                  const CFX_Matrix& matrix) {
   if (!pWidget || !pGraphics)
     return;
 
@@ -430,22 +430,24 @@
   if (IsFormDisabled()) {
 #endif  // _FX_OS_ == _FX_MACOSX_
 
-    pWidget->GetDelegate()->OnDrawWidget(pGraphics, pMatrix);
+    pWidget->GetDelegate()->OnDrawWidget(pGraphics, matrix);
     clipBounds = pGraphics->GetClipRect();
     clipCopy = clipBounds;
 
 #if _FX_OS_ == _FX_MACOSX_
   } else {
-    clipBounds = CFX_RectF(pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d);
-    const_cast<CFX_Matrix*>(pMatrix)->SetIdentity();  // FIXME: const cast.
-    pWidget->GetDelegate()->OnDrawWidget(pGraphics, pMatrix);
+    clipBounds = CFX_RectF(matrix.a, matrix.b, matrix.c, matrix.d);
+    // FIXME: const cast
+    CFX_Matrix* pMatrixHack = const_cast<CFX_Matrix*>(&matrix);
+    pMatrixHack->SetIdentity();
+    pWidget->GetDelegate()->OnDrawWidget(pGraphics, *pMatrixHack);
   }
 #endif  // _FX_OS_ == _FX_MACOSX_
 
   if (!IsFormDisabled())
     clipBounds.Intersect(pWidget->GetClientRect());
   if (!clipBounds.IsEmpty())
-    DrawChild(pWidget, clipBounds, pGraphics, pMatrix);
+    DrawChild(pWidget, clipBounds, pGraphics, &matrix);
 
   GetWidgetMgrItem(pWidget)->iRedrawCounter = 0;
   ResetRedrawCounts(pWidget);
@@ -492,7 +494,7 @@
 
     if (IFWL_WidgetDelegate* pDelegate = child->GetDelegate()) {
       if (IsFormDisabled() || IsNeedRepaint(child, &widgetMatrix, rtClip))
-        pDelegate->OnDrawWidget(pGraphics, &widgetMatrix);
+        pDelegate->OnDrawWidget(pGraphics, widgetMatrix);
     }
     if (!bFormDisable)
       pGraphics->RestoreGraphState();
diff --git a/xfa/fwl/cfwl_widgetmgr.h b/xfa/fwl/cfwl_widgetmgr.h
index 9ea2238..f633ba8 100644
--- a/xfa/fwl/cfwl_widgetmgr.h
+++ b/xfa/fwl/cfwl_widgetmgr.h
@@ -32,7 +32,7 @@
   void OnProcessMessageToForm(CFWL_Message* pMessage);
   void OnDrawWidget(CFWL_Widget* pWidget,
                     CXFA_Graphics* pGraphics,
-                    const CFX_Matrix* pMatrix);
+                    const CFX_Matrix& matrix);
 
   CFWL_Widget* GetParentWidget(CFWL_Widget* pWidget) const;
   CFWL_Widget* GetOwnerWidget(CFWL_Widget* pWidget) const;
diff --git a/xfa/fwl/ifwl_widgetdelegate.h b/xfa/fwl/ifwl_widgetdelegate.h
index 8dee6da..09bac9a 100644
--- a/xfa/fwl/ifwl_widgetdelegate.h
+++ b/xfa/fwl/ifwl_widgetdelegate.h
@@ -21,7 +21,7 @@
   virtual void OnProcessMessage(CFWL_Message* pMessage) = 0;
   virtual void OnProcessEvent(CFWL_Event* pEvent) = 0;
   virtual void OnDrawWidget(CXFA_Graphics* pGraphics,
-                            const CFX_Matrix* pMatrix) = 0;
+                            const CFX_Matrix& matrix) = 0;
 };
 
 #endif  // XFA_FWL_IFWL_WIDGETDELEGATE_H_
diff --git a/xfa/fxfa/cxfa_ffarc.cpp b/xfa/fxfa/cxfa_ffarc.cpp
index ec60faa..5929cb9 100644
--- a/xfa/fxfa/cxfa_ffarc.cpp
+++ b/xfa/fxfa/cxfa_ffarc.cpp
@@ -28,5 +28,5 @@
   if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin())
     XFA_RectWidthoutMargin(rtArc, mgWidget);
 
-  DrawBorder(pGS, arcObj, rtArc, &mtRotate);
+  DrawBorder(pGS, arcObj, rtArc, mtRotate);
 }
diff --git a/xfa/fxfa/cxfa_ffbarcode.cpp b/xfa/fxfa/cxfa_ffbarcode.cpp
index b6d0eed..03a7c7d 100644
--- a/xfa/fxfa/cxfa_ffbarcode.cpp
+++ b/xfa/fxfa/cxfa_ffbarcode.cpp
@@ -148,13 +148,13 @@
 
   CXFA_FFWidget::RenderWidget(pGS, mtRotate, dwStatus);
   CXFA_Border borderUI = m_pDataAcc->GetUIBorder();
-  DrawBorder(pGS, borderUI, m_rtUI, &mtRotate);
+  DrawBorder(pGS, borderUI, m_rtUI, mtRotate);
   RenderCaption(pGS, &mtRotate);
   CFX_RectF rtWidget = m_pNormalWidget->GetWidgetRect();
 
   CFX_Matrix mt(1, 0, 0, 1, rtWidget.left, rtWidget.top);
   mt.Concat(mtRotate);
-  m_pNormalWidget->DrawWidget(pGS, &mt);
+  m_pNormalWidget->DrawWidget(pGS, mt);
 }
 
 void CXFA_FFBarcode::UpdateWidgetProperty() {
diff --git a/xfa/fxfa/cxfa_ffcheckbutton.cpp b/xfa/fxfa/cxfa_ffcheckbutton.cpp
index 6e23d58..5b8766d 100644
--- a/xfa/fxfa/cxfa_ffcheckbutton.cpp
+++ b/xfa/fxfa/cxfa_ffcheckbutton.cpp
@@ -234,7 +234,7 @@
   CXFA_FFWidget::RenderWidget(pGS, mtRotate, dwStatus);
   CXFA_Border borderUI = m_pDataAcc->GetUIBorder();
   DrawBorderWithFlags(
-      pGS, borderUI, m_rtUI, &mtRotate,
+      pGS, borderUI, m_rtUI, mtRotate,
       m_pDataAcc->GetCheckButtonShape() == XFA_ATTRIBUTEENUM_Round
           ? XFA_DRAWBOX_ForceRound
           : 0);
@@ -243,7 +243,7 @@
                 m_pDataAcc->GetCheckButtonShape() == XFA_ATTRIBUTEENUM_Round);
   CFX_Matrix mt(1, 0, 0, 1, m_rtCheckBox.left, m_rtCheckBox.top);
   mt.Concat(mtRotate);
-  GetApp()->GetWidgetMgr()->OnDrawWidget(m_pNormalWidget.get(), pGS, &mt);
+  GetApp()->GetWidgetMgr()->OnDrawWidget(m_pNormalWidget.get(), pGS, mt);
 }
 
 bool CXFA_FFCheckButton::OnLButtonUp(uint32_t dwFlags,
@@ -339,6 +339,6 @@
 }
 
 void CXFA_FFCheckButton::OnDrawWidget(CXFA_Graphics* pGraphics,
-                                      const CFX_Matrix* pMatrix) {
-  m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix);
+                                      const CFX_Matrix& matrix) {
+  m_pOldDelegate->OnDrawWidget(pGraphics, matrix);
 }
diff --git a/xfa/fxfa/cxfa_ffcheckbutton.h b/xfa/fxfa/cxfa_ffcheckbutton.h
index b993545..e405381 100644
--- a/xfa/fxfa/cxfa_ffcheckbutton.h
+++ b/xfa/fxfa/cxfa_ffcheckbutton.h
@@ -28,7 +28,7 @@
   void OnProcessMessage(CFWL_Message* pMessage) override;
   void OnProcessEvent(CFWL_Event* pEvent) override;
   void OnDrawWidget(CXFA_Graphics* pGraphics,
-                    const CFX_Matrix* pMatrix = nullptr) override;
+                    const CFX_Matrix& matrix) override;
 
   void SetFWLCheckState(XFA_CHECKSTATE eCheckState);
 
diff --git a/xfa/fxfa/cxfa_ffcombobox.cpp b/xfa/fxfa/cxfa_ffcombobox.cpp
index e256616..0c8c80c 100644
--- a/xfa/fxfa/cxfa_ffcombobox.cpp
+++ b/xfa/fxfa/cxfa_ffcombobox.cpp
@@ -355,6 +355,6 @@
 }
 
 void CXFA_FFComboBox::OnDrawWidget(CXFA_Graphics* pGraphics,
-                                   const CFX_Matrix* pMatrix) {
-  m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix);
+                                   const CFX_Matrix& matrix) {
+  m_pOldDelegate->OnDrawWidget(pGraphics, matrix);
 }
diff --git a/xfa/fxfa/cxfa_ffcombobox.h b/xfa/fxfa/cxfa_ffcombobox.h
index 6c93646..33e7d7c 100644
--- a/xfa/fxfa/cxfa_ffcombobox.h
+++ b/xfa/fxfa/cxfa_ffcombobox.h
@@ -40,7 +40,7 @@
   void OnProcessMessage(CFWL_Message* pMessage) override;
   void OnProcessEvent(CFWL_Event* pEvent) override;
   void OnDrawWidget(CXFA_Graphics* pGraphics,
-                    const CFX_Matrix* pMatrix = nullptr) override;
+                    const CFX_Matrix& matrix) override;
 
   virtual void OpenDropDownList();
 
diff --git a/xfa/fxfa/cxfa_fffield.cpp b/xfa/fxfa/cxfa_fffield.cpp
index c62f4dc..3100341 100644
--- a/xfa/fxfa/cxfa_fffield.cpp
+++ b/xfa/fxfa/cxfa_fffield.cpp
@@ -68,14 +68,14 @@
 
   CXFA_FFWidget::RenderWidget(pGS, mtRotate, dwStatus);
   CXFA_Border borderUI = m_pDataAcc->GetUIBorder();
-  DrawBorder(pGS, borderUI, m_rtUI, &mtRotate);
+  DrawBorder(pGS, borderUI, m_rtUI, mtRotate);
   RenderCaption(pGS, &mtRotate);
   DrawHighlight(pGS, &mtRotate, dwStatus, false);
 
   CFX_RectF rtWidget = m_pNormalWidget->GetWidgetRect();
   CFX_Matrix mt(1, 0, 0, 1, rtWidget.left, rtWidget.top);
   mt.Concat(mtRotate);
-  GetApp()->GetWidgetMgr()->OnDrawWidget(m_pNormalWidget.get(), pGS, &mt);
+  GetApp()->GetWidgetMgr()->OnDrawWidget(m_pNormalWidget.get(), pGS, mt);
 }
 
 void CXFA_FFField::DrawHighlight(CXFA_Graphics* pGS,
@@ -779,4 +779,4 @@
 }
 
 void CXFA_FFField::OnDrawWidget(CXFA_Graphics* pGraphics,
-                                const CFX_Matrix* pMatrix) {}
+                                const CFX_Matrix& matrix) {}
diff --git a/xfa/fxfa/cxfa_fffield.h b/xfa/fxfa/cxfa_fffield.h
index 5ed6b48..e476642 100644
--- a/xfa/fxfa/cxfa_fffield.h
+++ b/xfa/fxfa/cxfa_fffield.h
@@ -56,7 +56,7 @@
   void OnProcessMessage(CFWL_Message* pMessage) override;
   void OnProcessEvent(CFWL_Event* pEvent) override;
   void OnDrawWidget(CXFA_Graphics* pGraphics,
-                    const CFX_Matrix* pMatrix = nullptr) override;
+                    const CFX_Matrix& matrix) override;
 
   void UpdateFWL();
   uint32_t UpdateUIProperty();
diff --git a/xfa/fxfa/cxfa_ffimageedit.cpp b/xfa/fxfa/cxfa_ffimageedit.cpp
index bc5678a..1c9e014 100644
--- a/xfa/fxfa/cxfa_ffimageedit.cpp
+++ b/xfa/fxfa/cxfa_ffimageedit.cpp
@@ -62,7 +62,7 @@
 
   CXFA_FFWidget::RenderWidget(pGS, mtRotate, dwStatus);
   CXFA_Border borderUI = m_pDataAcc->GetUIBorder();
-  DrawBorder(pGS, borderUI, m_rtUI, &mtRotate);
+  DrawBorder(pGS, borderUI, m_rtUI, mtRotate);
   RenderCaption(pGS, &mtRotate);
   CFX_RetainPtr<CFX_DIBitmap> pDIBitmap = m_pDataAcc->GetImageEditImage();
   if (!pDIBitmap)
@@ -137,6 +137,6 @@
 }
 
 void CXFA_FFImageEdit::OnDrawWidget(CXFA_Graphics* pGraphics,
-                                    const CFX_Matrix* pMatrix) {
-  m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix);
+                                    const CFX_Matrix& matrix) {
+  m_pOldDelegate->OnDrawWidget(pGraphics, matrix);
 }
diff --git a/xfa/fxfa/cxfa_ffimageedit.h b/xfa/fxfa/cxfa_ffimageedit.h
index adda302..d9ab615 100644
--- a/xfa/fxfa/cxfa_ffimageedit.h
+++ b/xfa/fxfa/cxfa_ffimageedit.h
@@ -24,7 +24,7 @@
   void OnProcessMessage(CFWL_Message* pMessage) override;
   void OnProcessEvent(CFWL_Event* pEvent) override;
   void OnDrawWidget(CXFA_Graphics* pGraphics,
-                    const CFX_Matrix* pMatrix = nullptr) override;
+                    const CFX_Matrix& matrix) override;
 
  private:
   void SetFWLRect() override;
diff --git a/xfa/fxfa/cxfa_fflistbox.cpp b/xfa/fxfa/cxfa_fflistbox.cpp
index c086953..66e1fdb 100644
--- a/xfa/fxfa/cxfa_fflistbox.cpp
+++ b/xfa/fxfa/cxfa_fflistbox.cpp
@@ -205,6 +205,6 @@
 }
 
 void CXFA_FFListBox::OnDrawWidget(CXFA_Graphics* pGraphics,
-                                  const CFX_Matrix* pMatrix) {
-  m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix);
+                                  const CFX_Matrix& matrix) {
+  m_pOldDelegate->OnDrawWidget(pGraphics, matrix);
 }
diff --git a/xfa/fxfa/cxfa_fflistbox.h b/xfa/fxfa/cxfa_fflistbox.h
index f89df4c..bf97d93 100644
--- a/xfa/fxfa/cxfa_fflistbox.h
+++ b/xfa/fxfa/cxfa_fflistbox.h
@@ -20,7 +20,7 @@
   void OnProcessMessage(CFWL_Message* pMessage) override;
   void OnProcessEvent(CFWL_Event* pEvent) override;
   void OnDrawWidget(CXFA_Graphics* pGraphics,
-                    const CFX_Matrix* pMatrix = nullptr) override;
+                    const CFX_Matrix& matrix) override;
 
   void OnSelectChanged(CFWL_Widget* pWidget);
   void SetItemState(int32_t nIndex, bool bSelected);
diff --git a/xfa/fxfa/cxfa_ffpushbutton.cpp b/xfa/fxfa/cxfa_ffpushbutton.cpp
index 45d4e71..d201e42 100644
--- a/xfa/fxfa/cxfa_ffpushbutton.cpp
+++ b/xfa/fxfa/cxfa_ffpushbutton.cpp
@@ -43,7 +43,7 @@
   CFX_RectF rtWidget = GetRectWithoutRotate();
   CFX_Matrix mt(1, 0, 0, 1, rtWidget.left, rtWidget.top);
   mt.Concat(mtRotate);
-  GetApp()->GetWidgetMgr()->OnDrawWidget(m_pNormalWidget.get(), pGS, &mt);
+  GetApp()->GetWidgetMgr()->OnDrawWidget(m_pNormalWidget.get(), pGS, mt);
 }
 
 bool CXFA_FFPushButton::LoadWidget() {
@@ -204,7 +204,7 @@
 }
 
 void CXFA_FFPushButton::OnDrawWidget(CXFA_Graphics* pGraphics,
-                                     const CFX_Matrix* pMatrix) {
+                                     const CFX_Matrix& matrix) {
   if (m_pNormalWidget->GetStylesEx() & XFA_FWL_PSBSTYLEEXT_HiliteInverted) {
     if ((m_pNormalWidget->GetStates() & FWL_STATE_PSB_Pressed) &&
         (m_pNormalWidget->GetStates() & FWL_STATE_PSB_Hovered)) {
@@ -214,7 +214,7 @@
       CXFA_Path path;
       path.AddRectangle(rtFill.left, rtFill.top, rtFill.width, rtFill.height);
       pGraphics->SetFillColor(CXFA_Color(FXARGB_MAKE(128, 128, 255, 255)));
-      pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+      pGraphics->FillPath(&path, FXFILL_WINDING, &matrix);
     }
     return;
   }
@@ -229,7 +229,7 @@
       CXFA_Path path;
       CFX_RectF rect = m_pNormalWidget->GetWidgetRect();
       path.AddRectangle(0, 0, rect.width, rect.height);
-      pGraphics->StrokePath(&path, (CFX_Matrix*)pMatrix);
+      pGraphics->StrokePath(&path, &matrix);
     }
   }
 }
diff --git a/xfa/fxfa/cxfa_ffpushbutton.h b/xfa/fxfa/cxfa_ffpushbutton.h
index dda0606..f5b7f06 100644
--- a/xfa/fxfa/cxfa_ffpushbutton.h
+++ b/xfa/fxfa/cxfa_ffpushbutton.h
@@ -34,7 +34,7 @@
   void OnProcessMessage(CFWL_Message* pMessage) override;
   void OnProcessEvent(CFWL_Event* pEvent) override;
   void OnDrawWidget(CXFA_Graphics* pGraphics,
-                    const CFX_Matrix* pMatrix = nullptr) override;
+                    const CFX_Matrix& matrix) override;
 
  private:
   void LoadHighlightCaption();
diff --git a/xfa/fxfa/cxfa_ffrectangle.cpp b/xfa/fxfa/cxfa_ffrectangle.cpp
index 476f3ac..fe71048 100644
--- a/xfa/fxfa/cxfa_ffrectangle.cpp
+++ b/xfa/fxfa/cxfa_ffrectangle.cpp
@@ -29,5 +29,5 @@
   CFX_Matrix mtRotate = GetRotateMatrix();
   mtRotate.Concat(matrix);
 
-  DrawBorder(pGS, rtObj, rect, &mtRotate);
+  DrawBorder(pGS, rtObj, rect, mtRotate);
 }
diff --git a/xfa/fxfa/cxfa_ffsignature.cpp b/xfa/fxfa/cxfa_ffsignature.cpp
index f527cd9..202e387 100644
--- a/xfa/fxfa/cxfa_ffsignature.cpp
+++ b/xfa/fxfa/cxfa_ffsignature.cpp
@@ -32,7 +32,7 @@
   CXFA_FFWidget::RenderWidget(pGS, mtRotate, dwStatus);
 
   CXFA_Border borderUI = m_pDataAcc->GetUIBorder();
-  DrawBorder(pGS, borderUI, m_rtUI, &mtRotate);
+  DrawBorder(pGS, borderUI, m_rtUI, mtRotate);
   RenderCaption(pGS, &mtRotate);
   DrawHighlight(pGS, &mtRotate, dwStatus, false);
 }
diff --git a/xfa/fxfa/cxfa_fftextedit.cpp b/xfa/fxfa/cxfa_fftextedit.cpp
index 9d6cffb..dfa4c41 100644
--- a/xfa/fxfa/cxfa_fftextedit.cpp
+++ b/xfa/fxfa/cxfa_fftextedit.cpp
@@ -354,6 +354,6 @@
 }
 
 void CXFA_FFTextEdit::OnDrawWidget(CXFA_Graphics* pGraphics,
-                                   const CFX_Matrix* pMatrix) {
-  m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix);
+                                   const CFX_Matrix& matrix) {
+  m_pOldDelegate->OnDrawWidget(pGraphics, matrix);
 }
diff --git a/xfa/fxfa/cxfa_fftextedit.h b/xfa/fxfa/cxfa_fftextedit.h
index 48656ad..2a3da37 100644
--- a/xfa/fxfa/cxfa_fftextedit.h
+++ b/xfa/fxfa/cxfa_fftextedit.h
@@ -34,7 +34,7 @@
   void OnProcessMessage(CFWL_Message* pMessage) override;
   void OnProcessEvent(CFWL_Event* pEvent) override;
   void OnDrawWidget(CXFA_Graphics* pGraphics,
-                    const CFX_Matrix* pMatrix = nullptr) override;
+                    const CFX_Matrix& matrix) override;
 
   void OnTextChanged(CFWL_Widget* pWidget,
                      const CFX_WideString& wsChanged,
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index ee445bb..26ab37d 100644
--- a/xfa/fxfa/cxfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -391,7 +391,7 @@
                          CXFA_Graphics* pGS,
                          CXFA_Path& fillPath,
                          CFX_RectF rtFill,
-                         const CFX_Matrix* pMatrix) {
+                         const CFX_Matrix& matrix) {
   CXFA_Fill fill = box.GetFill();
   FX_ARGB crStart, crEnd;
   crStart = fill.GetColor();
@@ -407,14 +407,14 @@
                            2,
                        true, true, crStart, crEnd);
   pGS->SetFillColor(CXFA_Color(&shading));
-  pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix);
+  pGS->FillPath(&fillPath, FXFILL_WINDING, &matrix);
 }
 
 void XFA_BOX_Fill_Pattern(CXFA_Box box,
                           CXFA_Graphics* pGS,
                           CXFA_Path& fillPath,
                           CFX_RectF rtFill,
-                          const CFX_Matrix* pMatrix) {
+                          const CFX_Matrix& matrix) {
   CXFA_Fill fill = box.GetFill();
   FX_ARGB crStart, crEnd;
   crStart = fill.GetColor();
@@ -442,14 +442,14 @@
 
   CXFA_Pattern pattern(iHatch, crEnd, crStart);
   pGS->SetFillColor(CXFA_Color(&pattern, 0x0));
-  pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix);
+  pGS->FillPath(&fillPath, FXFILL_WINDING, &matrix);
 }
 
 void XFA_BOX_Fill_Linear(CXFA_Box box,
                          CXFA_Graphics* pGS,
                          CXFA_Path& fillPath,
                          CFX_RectF rtFill,
-                         const CFX_Matrix* pMatrix) {
+                         const CFX_Matrix& matrix) {
   CXFA_Fill fill = box.GetFill();
   FX_ARGB crStart = fill.GetColor();
   FX_ARGB crEnd;
@@ -478,14 +478,14 @@
   }
   CXFA_Shading shading(ptStart, ptEnd, false, false, crStart, crEnd);
   pGS->SetFillColor(CXFA_Color(&shading));
-  pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix);
+  pGS->FillPath(&fillPath, FXFILL_WINDING, &matrix);
 }
 
 void XFA_BOX_Fill(CXFA_Box box,
                   const std::vector<CXFA_Stroke>& strokes,
                   CXFA_Graphics* pGS,
                   const CFX_RectF& rtWidget,
-                  const CFX_Matrix* pMatrix,
+                  const CFX_Matrix& matrix,
                   uint32_t dwFlags) {
   CXFA_Fill fill = box.GetFill();
   if (!fill || fill.GetPresence() != XFA_ATTRIBUTEENUM_Visible)
@@ -499,13 +499,13 @@
   XFA_Element eType = fill.GetFillType();
   switch (eType) {
     case XFA_Element::Radial:
-      XFA_BOX_Fill_Radial(box, pGS, fillPath, rtWidget, pMatrix);
+      XFA_BOX_Fill_Radial(box, pGS, fillPath, rtWidget, matrix);
       break;
     case XFA_Element::Pattern:
-      XFA_BOX_Fill_Pattern(box, pGS, fillPath, rtWidget, pMatrix);
+      XFA_BOX_Fill_Pattern(box, pGS, fillPath, rtWidget, matrix);
       break;
     case XFA_Element::Linear:
-      XFA_BOX_Fill_Linear(box, pGS, fillPath, rtWidget, pMatrix);
+      XFA_BOX_Fill_Linear(box, pGS, fillPath, rtWidget, matrix);
       break;
     default: {
       FX_ARGB cr;
@@ -521,7 +521,7 @@
         cr = fill.GetColor();
       }
       pGS->SetFillColor(CXFA_Color(cr));
-      pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix);
+      pGS->FillPath(&fillPath, FXFILL_WINDING, &matrix);
     } break;
   }
   pGS->RestoreGraphState();
@@ -530,7 +530,7 @@
 void XFA_BOX_StrokePath(CXFA_Stroke stroke,
                         CXFA_Path* pPath,
                         CXFA_Graphics* pGS,
-                        const CFX_Matrix* pMatrix) {
+                        const CFX_Matrix& matrix) {
   if (!stroke || !stroke.IsVisible()) {
     return;
   }
@@ -548,14 +548,14 @@
   XFA_StrokeTypeSetLineDash(pGS, stroke.GetStrokeType(),
                             XFA_ATTRIBUTEENUM_Butt);
   pGS->SetStrokeColor(CXFA_Color(stroke.GetColor()));
-  pGS->StrokePath(pPath, pMatrix);
+  pGS->StrokePath(pPath, &matrix);
   pGS->RestoreGraphState();
 }
 
 void XFA_BOX_StrokeArc(CXFA_Box box,
                        CXFA_Graphics* pGS,
                        CFX_RectF rtWidget,
-                       const CFX_Matrix* pMatrix,
+                       const CFX_Matrix& matrix,
                        uint32_t dwFlags) {
   CXFA_Edge edge = box.GetEdge(0);
   if (!edge || !edge.IsVisible()) {
@@ -586,7 +586,7 @@
 
     CXFA_Path arcPath;
     XFA_BOX_GetPath_Arc(box, rtWidget, arcPath, dwFlags);
-    XFA_BOX_StrokePath(edge, &arcPath, pGS, pMatrix);
+    XFA_BOX_StrokePath(edge, &arcPath, pGS, matrix);
     return;
   }
   pGS->SaveGraphState();
@@ -615,33 +615,33 @@
                  FX_PI);
 
   pGS->SetStrokeColor(CXFA_Color(0xFF808080));
-  pGS->StrokePath(&arcPath, pMatrix);
+  pGS->StrokePath(&arcPath, &matrix);
   arcPath.Clear();
   arcPath.AddArc(rtWidget.TopLeft(), rtWidget.Size(), -1.0f * FX_PI / 4.0f,
                  FX_PI);
 
   pGS->SetStrokeColor(CXFA_Color(0xFFFFFFFF));
-  pGS->StrokePath(&arcPath, pMatrix);
+  pGS->StrokePath(&arcPath, &matrix);
   rtWidget.Deflate(fHalf, fHalf);
   arcPath.Clear();
   arcPath.AddArc(rtWidget.TopLeft(), rtWidget.Size(), 3.0f * FX_PI / 4.0f,
                  FX_PI);
 
   pGS->SetStrokeColor(CXFA_Color(0xFF404040));
-  pGS->StrokePath(&arcPath, pMatrix);
+  pGS->StrokePath(&arcPath, &matrix);
   arcPath.Clear();
   arcPath.AddArc(rtWidget.TopLeft(), rtWidget.Size(), -1.0f * FX_PI / 4.0f,
                  FX_PI);
 
   pGS->SetStrokeColor(CXFA_Color(0xFFC0C0C0));
-  pGS->StrokePath(&arcPath, pMatrix);
+  pGS->StrokePath(&arcPath, &matrix);
   pGS->RestoreGraphState();
 }
 
 void XFA_Draw3DRect(CXFA_Graphics* pGraphic,
                     const CFX_RectF& rt,
                     float fLineWidth,
-                    const CFX_Matrix* pMatrix,
+                    const CFX_Matrix& matrix,
                     FX_ARGB argbTopLeft,
                     FX_ARGB argbBottomRight) {
   float fBottom = rt.bottom();
@@ -655,7 +655,7 @@
   pathLT.LineTo(CFX_PointF(rt.left + fLineWidth, fBottom - fLineWidth));
   pathLT.LineTo(CFX_PointF(rt.left, fBottom));
   pGraphic->SetFillColor(CXFA_Color(argbTopLeft));
-  pGraphic->FillPath(&pathLT, FXFILL_WINDING, pMatrix);
+  pGraphic->FillPath(&pathLT, FXFILL_WINDING, &matrix);
 
   CXFA_Path pathRB;
   pathRB.MoveTo(CFX_PointF(fRight, rt.top));
@@ -666,13 +666,13 @@
   pathRB.LineTo(CFX_PointF(fRight - fLineWidth, rt.top + fLineWidth));
   pathRB.LineTo(CFX_PointF(fRight, rt.top));
   pGraphic->SetFillColor(CXFA_Color(argbBottomRight));
-  pGraphic->FillPath(&pathRB, FXFILL_WINDING, pMatrix);
+  pGraphic->FillPath(&pathRB, FXFILL_WINDING, &matrix);
 }
 
 void XFA_BOX_Stroke_3DRect_Lowered(CXFA_Graphics* pGS,
                                    CFX_RectF rt,
                                    float fThickness,
-                                   const CFX_Matrix* pMatrix) {
+                                   const CFX_Matrix& matrix) {
   float fHalfWidth = fThickness / 2.0f;
   CFX_RectF rtInner(rt);
   rtInner.Deflate(fHalfWidth, fHalfWidth);
@@ -681,14 +681,14 @@
   path.AddRectangle(rt.left, rt.top, rt.width, rt.height);
   path.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height);
   pGS->SetFillColor(CXFA_Color(0xFF000000));
-  pGS->FillPath(&path, FXFILL_ALTERNATE, pMatrix);
-  XFA_Draw3DRect(pGS, rtInner, fHalfWidth, pMatrix, 0xFF808080, 0xFFC0C0C0);
+  pGS->FillPath(&path, FXFILL_ALTERNATE, &matrix);
+  XFA_Draw3DRect(pGS, rtInner, fHalfWidth, matrix, 0xFF808080, 0xFFC0C0C0);
 }
 
 void XFA_BOX_Stroke_3DRect_Raised(CXFA_Graphics* pGS,
                                   CFX_RectF rt,
                                   float fThickness,
-                                  const CFX_Matrix* pMatrix) {
+                                  const CFX_Matrix& matrix) {
   float fHalfWidth = fThickness / 2.0f;
   CFX_RectF rtInner(rt);
   rtInner.Deflate(fHalfWidth, fHalfWidth);
@@ -697,37 +697,37 @@
   path.AddRectangle(rt.left, rt.top, rt.width, rt.height);
   path.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height);
   pGS->SetFillColor(CXFA_Color(0xFF000000));
-  pGS->FillPath(&path, FXFILL_ALTERNATE, pMatrix);
-  XFA_Draw3DRect(pGS, rtInner, fHalfWidth, pMatrix, 0xFFFFFFFF, 0xFF808080);
+  pGS->FillPath(&path, FXFILL_ALTERNATE, &matrix);
+  XFA_Draw3DRect(pGS, rtInner, fHalfWidth, matrix, 0xFFFFFFFF, 0xFF808080);
 }
 
 void XFA_BOX_Stroke_3DRect_Etched(CXFA_Graphics* pGS,
                                   CFX_RectF rt,
                                   float fThickness,
-                                  const CFX_Matrix* pMatrix) {
+                                  const CFX_Matrix& matrix) {
   float fHalfWidth = fThickness / 2.0f;
-  XFA_Draw3DRect(pGS, rt, fThickness, pMatrix, 0xFF808080, 0xFFFFFFFF);
+  XFA_Draw3DRect(pGS, rt, fThickness, matrix, 0xFF808080, 0xFFFFFFFF);
   CFX_RectF rtInner(rt);
   rtInner.Deflate(fHalfWidth, fHalfWidth);
-  XFA_Draw3DRect(pGS, rtInner, fHalfWidth, pMatrix, 0xFFFFFFFF, 0xFF808080);
+  XFA_Draw3DRect(pGS, rtInner, fHalfWidth, matrix, 0xFFFFFFFF, 0xFF808080);
 }
 
 void XFA_BOX_Stroke_3DRect_Embossed(CXFA_Graphics* pGS,
                                     CFX_RectF rt,
                                     float fThickness,
-                                    const CFX_Matrix* pMatrix) {
+                                    const CFX_Matrix& matrix) {
   float fHalfWidth = fThickness / 2.0f;
-  XFA_Draw3DRect(pGS, rt, fThickness, pMatrix, 0xFF808080, 0xFF000000);
+  XFA_Draw3DRect(pGS, rt, fThickness, matrix, 0xFF808080, 0xFF000000);
   CFX_RectF rtInner(rt);
   rtInner.Deflate(fHalfWidth, fHalfWidth);
-  XFA_Draw3DRect(pGS, rtInner, fHalfWidth, pMatrix, 0xFF000000, 0xFF808080);
+  XFA_Draw3DRect(pGS, rtInner, fHalfWidth, matrix, 0xFF000000, 0xFF808080);
 }
 
 void XFA_BOX_Stroke_Rect(CXFA_Box box,
                          const std::vector<CXFA_Stroke>& strokes,
                          CXFA_Graphics* pGS,
                          CFX_RectF rtWidget,
-                         const CFX_Matrix* pMatrix) {
+                         const CFX_Matrix& matrix) {
   bool bVisible = false;
   float fThickness = 0;
   int32_t i3DType = box.Get3DStyle(bVisible, fThickness);
@@ -737,16 +737,16 @@
     }
     switch (i3DType) {
       case XFA_ATTRIBUTEENUM_Lowered:
-        XFA_BOX_Stroke_3DRect_Lowered(pGS, rtWidget, fThickness, pMatrix);
+        XFA_BOX_Stroke_3DRect_Lowered(pGS, rtWidget, fThickness, matrix);
         break;
       case XFA_ATTRIBUTEENUM_Raised:
-        XFA_BOX_Stroke_3DRect_Raised(pGS, rtWidget, fThickness, pMatrix);
+        XFA_BOX_Stroke_3DRect_Raised(pGS, rtWidget, fThickness, matrix);
         break;
       case XFA_ATTRIBUTEENUM_Etched:
-        XFA_BOX_Stroke_3DRect_Etched(pGS, rtWidget, fThickness, pMatrix);
+        XFA_BOX_Stroke_3DRect_Etched(pGS, rtWidget, fThickness, matrix);
         break;
       case XFA_ATTRIBUTEENUM_Embossed:
-        XFA_BOX_Stroke_3DRect_Embossed(pGS, rtWidget, fThickness, pMatrix);
+        XFA_BOX_Stroke_3DRect_Embossed(pGS, rtWidget, fThickness, matrix);
         break;
     }
     return;
@@ -789,7 +789,7 @@
     if ((i % 1) == 0 && stroke.GetRadius() < 0) {
       bool bEmpty = path.IsEmpty();
       if (!bEmpty) {
-        XFA_BOX_StrokePath(stroke, &path, pGS, pMatrix);
+        XFA_BOX_StrokePath(stroke, &path, pGS, matrix);
         path.Clear();
       }
       bStart = true;
@@ -799,7 +799,7 @@
     CXFA_Stroke stroke2 = strokes[(i + 1) % 8];
     bStart = !stroke.SameStyles(stroke2);
     if (bStart) {
-      XFA_BOX_StrokePath(stroke, &path, pGS, pMatrix);
+      XFA_BOX_StrokePath(stroke, &path, pGS, matrix);
       path.Clear();
     }
   }
@@ -808,7 +808,7 @@
     if (bClose) {
       path.Close();
     }
-    XFA_BOX_StrokePath(strokes[7], &path, pGS, pMatrix);
+    XFA_BOX_StrokePath(strokes[7], &path, pGS, matrix);
   }
 }
 
@@ -816,10 +816,10 @@
                     const std::vector<CXFA_Stroke>& strokes,
                     CXFA_Graphics* pGS,
                     CFX_RectF rtWidget,
-                    const CFX_Matrix* pMatrix,
+                    const CFX_Matrix& matrix,
                     uint32_t dwFlags) {
   if (box.IsArc() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) {
-    XFA_BOX_StrokeArc(box, pGS, rtWidget, pMatrix, dwFlags);
+    XFA_BOX_StrokeArc(box, pGS, rtWidget, matrix, dwFlags);
     return;
   }
   bool bVisible = false;
@@ -875,13 +875,13 @@
         break;
     }
   }
-  XFA_BOX_Stroke_Rect(box, strokes, pGS, rtWidget, pMatrix);
+  XFA_BOX_Stroke_Rect(box, strokes, pGS, rtWidget, matrix);
 }
 
 void XFA_DrawBox(CXFA_Box box,
                  CXFA_Graphics* pGS,
                  const CFX_RectF& rtWidget,
-                 const CFX_Matrix* pMatrix,
+                 const CFX_Matrix& matrix,
                  uint32_t dwFlags) {
   if (!box || box.GetPresence() != XFA_ATTRIBUTEENUM_Visible)
     return;
@@ -895,8 +895,8 @@
   if (!(dwFlags & XFA_DRAWBOX_ForceRound) && eType != XFA_Element::Arc)
     box.GetStrokes(&strokes);
 
-  XFA_BOX_Fill(box, strokes, pGS, rtWidget, pMatrix, dwFlags);
-  XFA_BOX_Stroke(box, strokes, pGS, rtWidget, pMatrix, dwFlags);
+  XFA_BOX_Fill(box, strokes, pGS, rtWidget, matrix, dwFlags);
+  XFA_BOX_Stroke(box, strokes, pGS, rtWidget, matrix, dwFlags);
 }
 
 }  // namespace
@@ -991,7 +991,7 @@
     XFA_RectWidthoutMargin(rtBorder, margin);
 
   rtBorder.Normalize();
-  DrawBorder(pGS, border, rtBorder, &matrix);
+  DrawBorder(pGS, border, rtBorder, matrix);
 }
 
 bool CXFA_FFWidget::IsLoaded() {
@@ -1014,16 +1014,16 @@
 void CXFA_FFWidget::DrawBorder(CXFA_Graphics* pGS,
                                CXFA_Box box,
                                const CFX_RectF& rtBorder,
-                               const CFX_Matrix* pMatrix) {
-  XFA_DrawBox(box, pGS, rtBorder, pMatrix, 0);
+                               const CFX_Matrix& matrix) {
+  XFA_DrawBox(box, pGS, rtBorder, matrix, 0);
 }
 
 void CXFA_FFWidget::DrawBorderWithFlags(CXFA_Graphics* pGS,
                                         CXFA_Box box,
                                         const CFX_RectF& rtBorder,
-                                        const CFX_Matrix* pMatrix,
+                                        const CFX_Matrix& matrix,
                                         uint32_t dwFlags) {
-  XFA_DrawBox(box, pGS, rtBorder, pMatrix, dwFlags);
+  XFA_DrawBox(box, pGS, rtBorder, matrix, dwFlags);
 }
 
 void CXFA_FFWidget::AddInvalidateRect() {
diff --git a/xfa/fxfa/cxfa_ffwidget.h b/xfa/fxfa/cxfa_ffwidget.h
index cac2294..f2ca86f 100644
--- a/xfa/fxfa/cxfa_ffwidget.h
+++ b/xfa/fxfa/cxfa_ffwidget.h
@@ -169,11 +169,11 @@
   void DrawBorder(CXFA_Graphics* pGS,
                   CXFA_Box box,
                   const CFX_RectF& rtBorder,
-                  const CFX_Matrix* pMatrix);
+                  const CFX_Matrix& matrix);
   void DrawBorderWithFlags(CXFA_Graphics* pGS,
                            CXFA_Box box,
                            const CFX_RectF& rtBorder,
-                           const CFX_Matrix* pMatrix,
+                           const CFX_Matrix& matrix,
                            uint32_t dwFlags);
 
   CFX_RectF GetRectWithoutRotate();