Change a bunch of methods to take a const CFX_Matrix& param.

Simplify some code along the way.

Change-Id: I0022c8a82188192c63b9ac0bc87e9b9dbf983040
Reviewed-on: https://pdfium-review.googlesource.com/10852
Reviewed-by: dsinclair <dsinclair@chromium.org>
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxge/cfx_renderdevice.cpp b/core/fxge/cfx_renderdevice.cpp
index cb0e600..a7b1a93 100644
--- a/core/fxge/cfx_renderdevice.cpp
+++ b/core/fxge/cfx_renderdevice.cpp
@@ -1125,7 +1125,7 @@
   return true;
 }
 
-void CFX_RenderDevice::DrawFillRect(CFX_Matrix* pUser2Device,
+void CFX_RenderDevice::DrawFillRect(const CFX_Matrix* pUser2Device,
                                     const CFX_FloatRect& rect,
                                     const FX_COLORREF& color) {
   CFX_PathData path;
@@ -1134,7 +1134,7 @@
   DrawPath(&path, pUser2Device, nullptr, color, 0, FXFILL_WINDING);
 }
 
-void CFX_RenderDevice::DrawFillArea(CFX_Matrix* pUser2Device,
+void CFX_RenderDevice::DrawFillArea(const CFX_Matrix* pUser2Device,
                                     const CFX_PointF* pPts,
                                     int32_t nCount,
                                     const FX_COLORREF& color) {
@@ -1146,7 +1146,7 @@
   DrawPath(&path, pUser2Device, nullptr, color, 0, FXFILL_ALTERNATE);
 }
 
-void CFX_RenderDevice::DrawStrokeRect(CFX_Matrix* pUser2Device,
+void CFX_RenderDevice::DrawStrokeRect(const CFX_Matrix* pUser2Device,
                                       const CFX_FloatRect& rect,
                                       const FX_COLORREF& color,
                                       float fWidth) {
@@ -1160,7 +1160,7 @@
   DrawPath(&path, pUser2Device, &gsd, 0, color, FXFILL_ALTERNATE);
 }
 
-void CFX_RenderDevice::DrawStrokeLine(CFX_Matrix* pUser2Device,
+void CFX_RenderDevice::DrawStrokeLine(const CFX_Matrix* pUser2Device,
                                       const CFX_PointF& ptMoveTo,
                                       const CFX_PointF& ptLineTo,
                                       const FX_COLORREF& color,
@@ -1175,14 +1175,14 @@
   DrawPath(&path, pUser2Device, &gsd, 0, color, FXFILL_ALTERNATE);
 }
 
-void CFX_RenderDevice::DrawFillRect(CFX_Matrix* pUser2Device,
+void CFX_RenderDevice::DrawFillRect(const CFX_Matrix* pUser2Device,
                                     const CFX_FloatRect& rect,
                                     const CFX_Color& color,
                                     int32_t nTransparency) {
   DrawFillRect(pUser2Device, rect, color.ToFXColor(nTransparency));
 }
 
-void CFX_RenderDevice::DrawShadow(CFX_Matrix* pUser2Device,
+void CFX_RenderDevice::DrawShadow(const CFX_Matrix* pUser2Device,
                                   bool bVertical,
                                   bool bHorizontal,
                                   CFX_FloatRect rect,
@@ -1214,7 +1214,7 @@
   }
 }
 
-void CFX_RenderDevice::DrawBorder(CFX_Matrix* pUser2Device,
+void CFX_RenderDevice::DrawBorder(const CFX_Matrix* pUser2Device,
                                   const CFX_FloatRect& rect,
                                   float fWidth,
                                   const CFX_Color& color,
diff --git a/core/fxge/cfx_renderdevice.h b/core/fxge/cfx_renderdevice.h
index 1a69c42..53443ab 100644
--- a/core/fxge/cfx_renderdevice.h
+++ b/core/fxge/cfx_renderdevice.h
@@ -229,23 +229,23 @@
                     CFX_PathData* pClippingPath,
                     int nFlag);
 
-  void DrawFillRect(CFX_Matrix* pUser2Device,
+  void DrawFillRect(const CFX_Matrix* pUser2Device,
                     const CFX_FloatRect& rect,
                     const CFX_Color& color,
                     int32_t nTransparency);
-  void DrawFillRect(CFX_Matrix* pUser2Device,
+  void DrawFillRect(const CFX_Matrix* pUser2Device,
                     const CFX_FloatRect& rect,
                     const FX_COLORREF& color);
-  void DrawStrokeRect(CFX_Matrix* pUser2Device,
+  void DrawStrokeRect(const CFX_Matrix* pUser2Device,
                       const CFX_FloatRect& rect,
                       const FX_COLORREF& color,
                       float fWidth);
-  void DrawStrokeLine(CFX_Matrix* pUser2Device,
+  void DrawStrokeLine(const CFX_Matrix* pUser2Device,
                       const CFX_PointF& ptMoveTo,
                       const CFX_PointF& ptLineTo,
                       const FX_COLORREF& color,
                       float fWidth);
-  void DrawBorder(CFX_Matrix* pUser2Device,
+  void DrawBorder(const CFX_Matrix* pUser2Device,
                   const CFX_FloatRect& rect,
                   float fWidth,
                   const CFX_Color& color,
@@ -253,11 +253,11 @@
                   const CFX_Color& crRightBottom,
                   BorderStyle nStyle,
                   int32_t nTransparency);
-  void DrawFillArea(CFX_Matrix* pUser2Device,
+  void DrawFillArea(const CFX_Matrix* pUser2Device,
                     const CFX_PointF* pPts,
                     int32_t nCount,
                     const FX_COLORREF& color);
-  void DrawShadow(CFX_Matrix* pUser2Device,
+  void DrawShadow(const CFX_Matrix* pUser2Device,
                   bool bVertical,
                   bool bHorizontal,
                   CFX_FloatRect rect,
diff --git a/fpdfsdk/formfiller/cffl_formfiller.cpp b/fpdfsdk/formfiller/cffl_formfiller.cpp
index e0af895..e0d02d0 100644
--- a/fpdfsdk/formfiller/cffl_formfiller.cpp
+++ b/fpdfsdk/formfiller/cffl_formfiller.cpp
@@ -88,7 +88,7 @@
   if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, false)) {
     CFX_Matrix mt = GetCurMatrix();
     mt.Concat(*pUser2Device);
-    pWnd->DrawAppearance(pDevice, &mt);
+    pWnd->DrawAppearance(pDevice, mt);
     return;
   }
 
diff --git a/fpdfsdk/pwl/cpwl_caret.cpp b/fpdfsdk/pwl/cpwl_caret.cpp
index 65c0fc5..3d05961 100644
--- a/fpdfsdk/pwl/cpwl_caret.cpp
+++ b/fpdfsdk/pwl/cpwl_caret.cpp
@@ -24,7 +24,7 @@
 }
 
 void CPWL_Caret::DrawThisAppearance(CFX_RenderDevice* pDevice,
-                                    CFX_Matrix* pUser2Device) {
+                                    const CFX_Matrix& mtUser2Device) {
   if (!IsVisible() || !m_bFlash)
     return;
 
@@ -49,7 +49,7 @@
 
   CFX_GraphStateData gsd;
   gsd.m_LineWidth = m_fWidth;
-  pDevice->DrawPath(&path, pUser2Device, &gsd, 0, ArgbEncode(255, 0, 0, 0),
+  pDevice->DrawPath(&path, &mtUser2Device, &gsd, 0, ArgbEncode(255, 0, 0, 0),
                     FXFILL_ALTERNATE);
 }
 
diff --git a/fpdfsdk/pwl/cpwl_caret.h b/fpdfsdk/pwl/cpwl_caret.h
index 5bba6fe..3203470 100644
--- a/fpdfsdk/pwl/cpwl_caret.h
+++ b/fpdfsdk/pwl/cpwl_caret.h
@@ -17,7 +17,7 @@
   // CPWL_Wnd
   CFX_ByteString GetClassName() const override;
   void DrawThisAppearance(CFX_RenderDevice* pDevice,
-                          CFX_Matrix* pUser2Device) override;
+                          const CFX_Matrix& mtUser2Device) override;
   void InvalidateRect(CFX_FloatRect* pRect) override;
   void SetVisible(bool bVisible) override {}
   void TimerProc() override;
diff --git a/fpdfsdk/pwl/cpwl_combo_box.cpp b/fpdfsdk/pwl/cpwl_combo_box.cpp
index 49254b8..8c5e99f 100644
--- a/fpdfsdk/pwl/cpwl_combo_box.cpp
+++ b/fpdfsdk/pwl/cpwl_combo_box.cpp
@@ -94,8 +94,8 @@
 }
 
 void CPWL_CBButton::DrawThisAppearance(CFX_RenderDevice* pDevice,
-                                       CFX_Matrix* pUser2Device) {
-  CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
+                                       const CFX_Matrix& mtUser2Device) {
+  CPWL_Wnd::DrawThisAppearance(pDevice, mtUser2Device);
 
   CFX_FloatRect rectWnd = CPWL_Wnd::GetWindowRect();
 
@@ -118,7 +118,7 @@
     path.AppendPoint(pt3, FXPT_TYPE::LineTo, false);
     path.AppendPoint(pt1, FXPT_TYPE::LineTo, false);
 
-    pDevice->DrawPath(&path, pUser2Device, nullptr,
+    pDevice->DrawPath(&path, &mtUser2Device, nullptr,
                       PWL_DEFAULT_BLACKCOLOR.ToFXColor(GetTransparency()), 0,
                       FXFILL_ALTERNATE);
   }
diff --git a/fpdfsdk/pwl/cpwl_combo_box.h b/fpdfsdk/pwl/cpwl_combo_box.h
index 81e4256..7059fac 100644
--- a/fpdfsdk/pwl/cpwl_combo_box.h
+++ b/fpdfsdk/pwl/cpwl_combo_box.h
@@ -37,7 +37,7 @@
 
   // CPWL_Wnd
   void DrawThisAppearance(CFX_RenderDevice* pDevice,
-                          CFX_Matrix* pUser2Device) override;
+                          const CFX_Matrix& mtUser2Device) override;
   bool OnLButtonDown(const CFX_PointF& point, uint32_t nFlag) override;
   bool OnLButtonUp(const CFX_PointF& point, uint32_t nFlag) override;
 };
diff --git a/fpdfsdk/pwl/cpwl_edit.cpp b/fpdfsdk/pwl/cpwl_edit.cpp
index d01e3f1..a6f6f2a 100644
--- a/fpdfsdk/pwl/cpwl_edit.cpp
+++ b/fpdfsdk/pwl/cpwl_edit.cpp
@@ -198,8 +198,8 @@
 }
 
 void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice,
-                                   CFX_Matrix* pUser2Device) {
-  CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
+                                   const CFX_Matrix& mtUser2Device) {
+  CPWL_Wnd::DrawThisAppearance(pDevice, mtUser2Device);
 
   CFX_FloatRect rcClient = GetClientRect();
 
@@ -231,7 +231,7 @@
               FXPT_TYPE::LineTo, false);
         }
         if (!path.GetPoints().empty()) {
-          pDevice->DrawPath(&path, pUser2Device, &gsd, 0,
+          pDevice->DrawPath(&path, &mtUser2Device, &gsd, 0,
                             GetBorderColor().ToFXColor(255), FXFILL_ALTERNATE);
         }
         break;
@@ -261,7 +261,7 @@
               FXPT_TYPE::LineTo, false);
         }
         if (!path.GetPoints().empty()) {
-          pDevice->DrawPath(&path, pUser2Device, &gsd, 0,
+          pDevice->DrawPath(&path, &mtUser2Device, &gsd, 0,
                             GetBorderColor().ToFXColor(255), FXFILL_ALTERNATE);
         }
         break;
@@ -280,7 +280,7 @@
   }
 
   CFX_SystemHandler* pSysHandler = GetSystemHandler();
-  CPWL_EditImpl::DrawEdit(pDevice, pUser2Device, m_pEdit.get(),
+  CPWL_EditImpl::DrawEdit(pDevice, mtUser2Device, m_pEdit.get(),
                           GetTextColor().ToFXColor(GetTransparency()), rcClip,
                           CFX_PointF(), pRange, pSysHandler,
                           m_pFormFiller.Get());
diff --git a/fpdfsdk/pwl/cpwl_edit.h b/fpdfsdk/pwl/cpwl_edit.h
index 1c2d9c0..7584023 100644
--- a/fpdfsdk/pwl/cpwl_edit.h
+++ b/fpdfsdk/pwl/cpwl_edit.h
@@ -49,7 +49,7 @@
   void RePosChildWnd() override;
   CFX_FloatRect GetClientRect() const override;
   void DrawThisAppearance(CFX_RenderDevice* pDevice,
-                          CFX_Matrix* pUser2Device) override;
+                          const CFX_Matrix& mtUser2Device) override;
   bool OnLButtonDown(const CFX_PointF& point, uint32_t nFlag) override;
   bool OnLButtonDblClk(const CFX_PointF& point, uint32_t nFlag) override;
   bool OnRButtonUp(const CFX_PointF& point, uint32_t nFlag) override;
diff --git a/fpdfsdk/pwl/cpwl_edit_impl.cpp b/fpdfsdk/pwl/cpwl_edit_impl.cpp
index 808eddb..f26811e 100644
--- a/fpdfsdk/pwl/cpwl_edit_impl.cpp
+++ b/fpdfsdk/pwl/cpwl_edit_impl.cpp
@@ -41,33 +41,27 @@
                     const CFX_PointF& pt,
                     CPDF_Font* pFont,
                     float fFontSize,
-                    CFX_Matrix* pUser2Device,
+                    const CFX_Matrix& mtUser2Device,
                     const CFX_ByteString& str,
                     FX_ARGB crTextFill,
                     int32_t nHorzScale) {
-  CFX_PointF pos = pUser2Device->Transform(pt);
+  if (!pFont)
+    return;
 
-  if (pFont) {
-    if (nHorzScale != 100) {
-      CFX_Matrix mt(nHorzScale / 100.0f, 0, 0, 1, 0, 0);
-      mt.Concat(*pUser2Device);
-
-      CPDF_RenderOptions ro;
-      ro.m_Flags = RENDER_CLEARTYPE;
-      ro.m_ColorMode = CPDF_RenderOptions::kNormal;
-
-      CPDF_TextRenderer::DrawTextString(pDevice, pos.x, pos.y, pFont, fFontSize,
-                                        &mt, str, crTextFill, nullptr, &ro);
-    } else {
-      CPDF_RenderOptions ro;
-      ro.m_Flags = RENDER_CLEARTYPE;
-      ro.m_ColorMode = CPDF_RenderOptions::kNormal;
-
-      CPDF_TextRenderer::DrawTextString(pDevice, pos.x, pos.y, pFont, fFontSize,
-                                        pUser2Device, str, crTextFill, nullptr,
-                                        &ro);
-    }
+  CFX_PointF pos = mtUser2Device.Transform(pt);
+  CFX_Matrix mt;
+  if (nHorzScale == 100) {
+    mt = mtUser2Device;
+  } else {
+    mt = CFX_Matrix(nHorzScale / 100.0f, 0, 0, 1, 0, 0);
+    mt.Concat(mtUser2Device);
   }
+
+  CPDF_RenderOptions ro;
+  ro.m_Flags = RENDER_CLEARTYPE;
+  ro.m_ColorMode = CPDF_RenderOptions::kNormal;
+  CPDF_TextRenderer::DrawTextString(pDevice, pos.x, pos.y, pFont, fFontSize,
+                                    &mt, str, crTextFill, nullptr, &ro);
 }
 
 }  // namespace
@@ -448,7 +442,7 @@
 
 // static
 void CPWL_EditImpl::DrawEdit(CFX_RenderDevice* pDevice,
-                             CFX_Matrix* pUser2Device,
+                             const CFX_Matrix& mtUser2Device,
                              CPWL_EditImpl* pEdit,
                              FX_COLORREF crTextFill,
                              const CFX_FloatRect& rcClip,
@@ -467,8 +461,8 @@
   FX_COLORREF crOldFill = crCurFill;
 
   bool bSelect = false;
-  const FX_COLORREF crWhite = ArgbEncode(255, 255, 255, 255);
-  const FX_COLORREF crSelBK = ArgbEncode(255, 0, 51, 113);
+  static const FX_COLORREF crWhite = ArgbEncode(255, 255, 255, 255);
+  static const FX_COLORREF crSelBK = ArgbEncode(255, 0, 51, 113);
 
   std::ostringstream sTextBuf;
   int32_t nFontIndex = -1;
@@ -476,92 +470,93 @@
   CFX_RenderDevice::StateRestorer restorer(pDevice);
   if (!rcClip.IsEmpty()) {
     CFX_FloatRect rcTemp = rcClip;
-    pUser2Device->TransformRect(rcTemp);
+    mtUser2Device.TransformRect(rcTemp);
     pDevice->SetClip_Rect(rcTemp.ToFxRect());
   }
 
   CPWL_EditImpl_Iterator* pIterator = pEdit->GetIterator();
-  if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) {
-    if (pRange)
-      pIterator->SetAt(pRange->BeginPos);
-    else
-      pIterator->SetAt(0);
+  IPVT_FontMap* pFontMap = pEdit->GetFontMap();
+  if (!pFontMap)
+    return;
 
-    CPVT_WordPlace oldplace;
-    while (pIterator->NextWord()) {
-      CPVT_WordPlace place = pIterator->GetAt();
-      if (pRange && place > pRange->EndPos)
-        break;
+  if (pRange)
+    pIterator->SetAt(pRange->BeginPos);
+  else
+    pIterator->SetAt(0);
 
-      if (!wrSelect.IsEmpty()) {
-        bSelect = place > wrSelect.BeginPos && place <= wrSelect.EndPos;
-        crCurFill = bSelect ? crWhite : crTextFill;
-      }
-      if (pSystemHandler && pSystemHandler->IsSelectionImplemented()) {
-        crCurFill = crTextFill;
-        crOldFill = crCurFill;
-      }
-      CPVT_Word word;
-      if (pIterator->GetWord(word)) {
-        if (bSelect) {
-          CPVT_Line line;
-          pIterator->GetLine(line);
+  CPVT_WordPlace oldplace;
+  while (pIterator->NextWord()) {
+    CPVT_WordPlace place = pIterator->GetAt();
+    if (pRange && place > pRange->EndPos)
+      break;
 
-          if (pSystemHandler && pSystemHandler->IsSelectionImplemented()) {
-            CFX_FloatRect rc(word.ptWord.x, line.ptLine.y + line.fLineDescent,
-                             word.ptWord.x + word.fWidth,
-                             line.ptLine.y + line.fLineAscent);
-            rc.Intersect(rcClip);
-            pSystemHandler->OutputSelectedRect(pFFLData, rc);
-          } else {
-            CFX_PathData pathSelBK;
-            pathSelBK.AppendRect(
-                word.ptWord.x, line.ptLine.y + line.fLineDescent,
-                word.ptWord.x + word.fWidth, line.ptLine.y + line.fLineAscent);
+    if (!wrSelect.IsEmpty()) {
+      bSelect = place > wrSelect.BeginPos && place <= wrSelect.EndPos;
+      crCurFill = bSelect ? crWhite : crTextFill;
+    }
+    if (pSystemHandler && pSystemHandler->IsSelectionImplemented()) {
+      crCurFill = crTextFill;
+      crOldFill = crCurFill;
+    }
+    CPVT_Word word;
+    if (pIterator->GetWord(word)) {
+      if (bSelect) {
+        CPVT_Line line;
+        pIterator->GetLine(line);
 
-            pDevice->DrawPath(&pathSelBK, pUser2Device, nullptr, crSelBK, 0,
-                              FXFILL_WINDING);
-          }
-        }
-
-        if (bContinuous) {
-          if (place.LineCmp(oldplace) != 0 || word.nFontIndex != nFontIndex ||
-              crOldFill != crCurFill) {
-            if (sTextBuf.tellp() > 0) {
-              DrawTextString(
-                  pDevice, CFX_PointF(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
-                  pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device,
-                  CFX_ByteString(sTextBuf), crOldFill, nHorzScale);
-
-              sTextBuf.str("");
-            }
-            nFontIndex = word.nFontIndex;
-            ptBT = word.ptWord;
-            crOldFill = crCurFill;
-          }
-
-          sTextBuf << pEdit->GetPDFWordString(word.nFontIndex, word.Word,
-                                              SubWord);
+        if (pSystemHandler && pSystemHandler->IsSelectionImplemented()) {
+          CFX_FloatRect rc(word.ptWord.x, line.ptLine.y + line.fLineDescent,
+                           word.ptWord.x + word.fWidth,
+                           line.ptLine.y + line.fLineAscent);
+          rc.Intersect(rcClip);
+          pSystemHandler->OutputSelectedRect(pFFLData, rc);
         } else {
-          DrawTextString(
-              pDevice,
-              CFX_PointF(word.ptWord.x + ptOffset.x,
-                         word.ptWord.y + ptOffset.y),
-              pFontMap->GetPDFFont(word.nFontIndex), fFontSize, pUser2Device,
-              pEdit->GetPDFWordString(word.nFontIndex, word.Word, SubWord),
-              crCurFill, nHorzScale);
-        }
-        oldplace = place;
-      }
-    }
+          CFX_PathData pathSelBK;
+          pathSelBK.AppendRect(word.ptWord.x, line.ptLine.y + line.fLineDescent,
+                               word.ptWord.x + word.fWidth,
+                               line.ptLine.y + line.fLineAscent);
 
-    if (sTextBuf.tellp() > 0) {
-      DrawTextString(pDevice,
-                     CFX_PointF(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
-                     pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device,
-                     CFX_ByteString(sTextBuf), crOldFill, nHorzScale);
+          pDevice->DrawPath(&pathSelBK, &mtUser2Device, nullptr, crSelBK, 0,
+                            FXFILL_WINDING);
+        }
+      }
+
+      if (bContinuous) {
+        if (place.LineCmp(oldplace) != 0 || word.nFontIndex != nFontIndex ||
+            crOldFill != crCurFill) {
+          if (sTextBuf.tellp() > 0) {
+            DrawTextString(
+                pDevice, CFX_PointF(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+                pFontMap->GetPDFFont(nFontIndex), fFontSize, mtUser2Device,
+                CFX_ByteString(sTextBuf), crOldFill, nHorzScale);
+
+            sTextBuf.str("");
+          }
+          nFontIndex = word.nFontIndex;
+          ptBT = word.ptWord;
+          crOldFill = crCurFill;
+        }
+
+        sTextBuf << pEdit->GetPDFWordString(word.nFontIndex, word.Word,
+                                            SubWord);
+      } else {
+        DrawTextString(
+            pDevice,
+            CFX_PointF(word.ptWord.x + ptOffset.x, word.ptWord.y + ptOffset.y),
+            pFontMap->GetPDFFont(word.nFontIndex), fFontSize, mtUser2Device,
+            pEdit->GetPDFWordString(word.nFontIndex, word.Word, SubWord),
+            crCurFill, nHorzScale);
+      }
+      oldplace = place;
     }
   }
+
+  if (sTextBuf.tellp() > 0) {
+    DrawTextString(pDevice,
+                   CFX_PointF(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+                   pFontMap->GetPDFFont(nFontIndex), fFontSize, mtUser2Device,
+                   CFX_ByteString(sTextBuf), crOldFill, nHorzScale);
+  }
 }
 
 CPWL_EditImpl::CPWL_EditImpl()
diff --git a/fpdfsdk/pwl/cpwl_edit_impl.h b/fpdfsdk/pwl/cpwl_edit_impl.h
index 80c6805..177a052 100644
--- a/fpdfsdk/pwl/cpwl_edit_impl.h
+++ b/fpdfsdk/pwl/cpwl_edit_impl.h
@@ -272,7 +272,7 @@
 class CPWL_EditImpl {
  public:
   static void DrawEdit(CFX_RenderDevice* pDevice,
-                       CFX_Matrix* pUser2Device,
+                       const CFX_Matrix& mtUser2Device,
                        CPWL_EditImpl* pEdit,
                        FX_COLORREF crTextFill,
                        const CFX_FloatRect& rcClip,
diff --git a/fpdfsdk/pwl/cpwl_list_box.cpp b/fpdfsdk/pwl/cpwl_list_box.cpp
index 060b3f6..a9c553e 100644
--- a/fpdfsdk/pwl/cpwl_list_box.cpp
+++ b/fpdfsdk/pwl/cpwl_list_box.cpp
@@ -38,18 +38,20 @@
   Info.fBigStep = fBigStep;
   m_pList->SetScrollInfo(Info);
 
-  if (CPWL_ScrollBar* pScroll = m_pList->GetVScrollBar()) {
-    if (IsFloatBigger(Info.fPlateWidth, Info.fContentMax - Info.fContentMin) ||
-        IsFloatEqual(Info.fPlateWidth, Info.fContentMax - Info.fContentMin)) {
-      if (pScroll->IsVisible()) {
-        pScroll->SetVisible(false);
-        m_pList->RePosChildWnd();
-      }
-    } else {
-      if (!pScroll->IsVisible()) {
-        pScroll->SetVisible(true);
-        m_pList->RePosChildWnd();
-      }
+  CPWL_ScrollBar* pScroll = m_pList->GetVScrollBar();
+  if (!pScroll)
+    return;
+
+  if (IsFloatBigger(Info.fPlateWidth, Info.fContentMax - Info.fContentMin) ||
+      IsFloatEqual(Info.fPlateWidth, Info.fContentMax - Info.fContentMin)) {
+    if (pScroll->IsVisible()) {
+      pScroll->SetVisible(false);
+      m_pList->RePosChildWnd();
+    }
+  } else {
+    if (!pScroll->IsVisible()) {
+      pScroll->SetVisible(true);
+      m_pList->RePosChildWnd();
     }
   }
 }
@@ -94,8 +96,8 @@
 }
 
 void CPWL_ListBox::DrawThisAppearance(CFX_RenderDevice* pDevice,
-                                      CFX_Matrix* pUser2Device) {
-  CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
+                                      const CFX_Matrix& mtUser2Device) {
+  CPWL_Wnd::DrawThisAppearance(pDevice, mtUser2Device);
 
   CFX_FloatRect rcPlate = m_pList->GetPlateRect();
   CFX_FloatRect rcList = GetListRect();
@@ -118,21 +120,21 @@
     if (m_pList->IsItemSelected(i)) {
       CFX_SystemHandler* pSysHandler = GetSystemHandler();
       if (pSysHandler && pSysHandler->IsSelectionImplemented()) {
-        CPWL_EditImpl::DrawEdit(pDevice, pUser2Device, m_pList->GetItemEdit(i),
+        CPWL_EditImpl::DrawEdit(pDevice, mtUser2Device, m_pList->GetItemEdit(i),
                                 GetTextColor().ToFXColor(255), rcList, ptOffset,
                                 nullptr, pSysHandler, m_pFormFiller.Get());
         pSysHandler->OutputSelectedRect(m_pFormFiller.Get(), rcItem);
       } else {
-        pDevice->DrawFillRect(pUser2Device, rcItem,
+        pDevice->DrawFillRect(&mtUser2Device, rcItem,
                               ArgbEncode(255, 0, 51, 113));
-        CPWL_EditImpl::DrawEdit(pDevice, pUser2Device, m_pList->GetItemEdit(i),
+        CPWL_EditImpl::DrawEdit(pDevice, mtUser2Device, m_pList->GetItemEdit(i),
                                 ArgbEncode(255, 255, 255, 255), rcList,
                                 ptOffset, nullptr, pSysHandler,
                                 m_pFormFiller.Get());
       }
     } else {
       CFX_SystemHandler* pSysHandler = GetSystemHandler();
-      CPWL_EditImpl::DrawEdit(pDevice, pUser2Device, m_pList->GetItemEdit(i),
+      CPWL_EditImpl::DrawEdit(pDevice, mtUser2Device, m_pList->GetItemEdit(i),
                               GetTextColor().ToFXColor(255), rcList, ptOffset,
                               nullptr, pSysHandler, nullptr);
     }
diff --git a/fpdfsdk/pwl/cpwl_list_box.h b/fpdfsdk/pwl/cpwl_list_box.h
index 8938f24..f620ec1 100644
--- a/fpdfsdk/pwl/cpwl_list_box.h
+++ b/fpdfsdk/pwl/cpwl_list_box.h
@@ -48,7 +48,7 @@
   void OnCreated() override;
   void OnDestroy() override;
   void DrawThisAppearance(CFX_RenderDevice* pDevice,
-                          CFX_Matrix* pUser2Device) override;
+                          const CFX_Matrix& mtUser2Device) override;
   bool OnKeyDown(uint16_t nChar, uint32_t nFlag) override;
   bool OnChar(uint16_t nChar, uint32_t nFlag) override;
   bool OnLButtonDown(const CFX_PointF& point, uint32_t nFlag) override;
diff --git a/fpdfsdk/pwl/cpwl_scroll_bar.cpp b/fpdfsdk/pwl/cpwl_scroll_bar.cpp
index 142988a..ea38b0f 100644
--- a/fpdfsdk/pwl/cpwl_scroll_bar.cpp
+++ b/fpdfsdk/pwl/cpwl_scroll_bar.cpp
@@ -136,7 +136,7 @@
 }
 
 void CPWL_SBButton::DrawThisAppearance(CFX_RenderDevice* pDevice,
-                                       CFX_Matrix* pUser2Device) {
+                                       const CFX_Matrix& mtUser2Device) {
   if (!IsVisible())
     return;
 
@@ -148,7 +148,7 @@
   int32_t nTransparency = GetTransparency();
 
   if (m_eScrollBarType == SBT_HSCROLL) {
-    CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
+    CPWL_Wnd::DrawThisAppearance(pDevice, mtUser2Device);
 
     CFX_PointF pt1;
     CFX_PointF pt2;
@@ -175,7 +175,7 @@
       path.AppendPoint(pt3, FXPT_TYPE::LineTo, false);
       path.AppendPoint(pt1, FXPT_TYPE::LineTo, false);
 
-      pDevice->DrawPath(&path, pUser2Device, nullptr,
+      pDevice->DrawPath(&path, &mtUser2Device, nullptr,
                         PWL_DEFAULT_BLACKCOLOR.ToFXColor(nTransparency), 0,
                         FXFILL_ALTERNATE);
     }
@@ -183,19 +183,19 @@
   }
 
   // draw border
-  pDevice->DrawStrokeRect(pUser2Device, rectWnd,
+  pDevice->DrawStrokeRect(&mtUser2Device, rectWnd,
                           ArgbEncode(nTransparency, 100, 100, 100), 0.0f);
-  pDevice->DrawStrokeRect(pUser2Device, rectWnd.GetDeflated(0.5f, 0.5f),
+  pDevice->DrawStrokeRect(&mtUser2Device, rectWnd.GetDeflated(0.5f, 0.5f),
                           ArgbEncode(nTransparency, 255, 255, 255), 1.0f);
 
   if (m_eSBButtonType != PSBT_POS) {
     // draw background
     if (IsEnabled()) {
-      pDevice->DrawShadow(pUser2Device, true, false,
+      pDevice->DrawShadow(&mtUser2Device, true, false,
                           rectWnd.GetDeflated(1.0f, 1.0f), nTransparency, 80,
                           220);
     } else {
-      pDevice->DrawFillRect(pUser2Device, rectWnd.GetDeflated(1.0f, 1.0f),
+      pDevice->DrawFillRect(&mtUser2Device, rectWnd.GetDeflated(1.0f, 1.0f),
                             ArgbEncode(255, 255, 255, 255));
     }
 
@@ -221,7 +221,7 @@
         pts.push_back(CFX_PointF(fX + 4.5f, fY + 3.0f));
         pts.push_back(CFX_PointF(fX + 2.5f, fY + 5.0f));
       }
-      pDevice->DrawFillArea(pUser2Device, pts.data(), 7,
+      pDevice->DrawFillArea(&mtUser2Device, pts.data(), 7,
                             IsEnabled()
                                 ? ArgbEncode(nTransparency, 255, 255, 255)
                                 : PWL_DEFAULT_HEAVYGRAYCOLOR.ToFXColor(255));
@@ -248,13 +248,13 @@
                                 ArgbEncode(nTransparency, 180, 180, 180),
                                 ArgbEncode(nTransparency, 210, 210, 210)};
     for (FX_COLORREF ref : refs) {
-      pDevice->DrawStrokeLine(pUser2Device, ptTop, ptBottom, ref, 1.0f);
+      pDevice->DrawStrokeLine(&mtUser2Device, ptTop, ptBottom, ref, 1.0f);
 
       ptTop.x += 1.0f;
       ptBottom.x += 1.0f;
     }
   } else {
-    pDevice->DrawFillRect(pUser2Device, rectWnd.GetDeflated(0.5f, 0.5f),
+    pDevice->DrawFillRect(&mtUser2Device, rectWnd.GetDeflated(0.5f, 0.5f),
                           ArgbEncode(255, 255, 255, 255));
   }
 
@@ -275,7 +275,7 @@
                                   ptCenter.y - nFrictionHeight / 2.0f + 0.5f);
 
   for (size_t i = 0; i < 3; ++i) {
-    pDevice->DrawStrokeLine(pUser2Device, ptLeft, ptRight, crStroke, 1.0f);
+    pDevice->DrawStrokeLine(&mtUser2Device, ptLeft, ptRight, crStroke, 1.0f);
     ptLeft.y += 2.0f;
     ptRight.y += 2.0f;
   }
@@ -403,20 +403,20 @@
 }
 
 void CPWL_ScrollBar::DrawThisAppearance(CFX_RenderDevice* pDevice,
-                                        CFX_Matrix* pUser2Device) {
+                                        const CFX_Matrix& mtUser2Device) {
   CFX_FloatRect rectWnd = GetWindowRect();
 
   if (IsVisible() && !rectWnd.IsEmpty()) {
-    pDevice->DrawFillRect(pUser2Device, rectWnd, GetBackgroundColor(),
+    pDevice->DrawFillRect(&mtUser2Device, rectWnd, GetBackgroundColor(),
                           GetTransparency());
 
     pDevice->DrawStrokeLine(
-        pUser2Device, CFX_PointF(rectWnd.left + 2.0f, rectWnd.top - 2.0f),
+        &mtUser2Device, CFX_PointF(rectWnd.left + 2.0f, rectWnd.top - 2.0f),
         CFX_PointF(rectWnd.left + 2.0f, rectWnd.bottom + 2.0f),
         ArgbEncode(GetTransparency(), 100, 100, 100), 1.0f);
 
     pDevice->DrawStrokeLine(
-        pUser2Device, CFX_PointF(rectWnd.right - 2.0f, rectWnd.top - 2.0f),
+        &mtUser2Device, CFX_PointF(rectWnd.right - 2.0f, rectWnd.top - 2.0f),
         CFX_PointF(rectWnd.right - 2.0f, rectWnd.bottom + 2.0f),
         ArgbEncode(GetTransparency(), 100, 100, 100), 1.0f);
   }
diff --git a/fpdfsdk/pwl/cpwl_scroll_bar.h b/fpdfsdk/pwl/cpwl_scroll_bar.h
index c78b6e3..e35a6a0 100644
--- a/fpdfsdk/pwl/cpwl_scroll_bar.h
+++ b/fpdfsdk/pwl/cpwl_scroll_bar.h
@@ -52,7 +52,7 @@
   CFX_ByteString GetClassName() const override;
   void OnCreate(PWL_CREATEPARAM& cp) override;
   void DrawThisAppearance(CFX_RenderDevice* pDevice,
-                          CFX_Matrix* pUser2Device) override;
+                          const CFX_Matrix& mtUser2Device) override;
   bool OnLButtonDown(const CFX_PointF& point, uint32_t nFlag) override;
   bool OnLButtonUp(const CFX_PointF& point, uint32_t nFlag) override;
   bool OnMouseMove(const CFX_PointF& point, uint32_t nFlag) override;
@@ -126,7 +126,7 @@
   void OnDestroy() override;
   void RePosChildWnd() override;
   void DrawThisAppearance(CFX_RenderDevice* pDevice,
-                          CFX_Matrix* pUser2Device) override;
+                          const CFX_Matrix& mtUser2Device) override;
   bool OnLButtonDown(const CFX_PointF& point, uint32_t nFlag) override;
   bool OnLButtonUp(const CFX_PointF& point, uint32_t nFlag) override;
   void SetScrollInfo(const PWL_SCROLL_INFO& info) override;
diff --git a/fpdfsdk/pwl/cpwl_wnd.cpp b/fpdfsdk/pwl/cpwl_wnd.cpp
index 37d0bc4..96a3720 100644
--- a/fpdfsdk/pwl/cpwl_wnd.cpp
+++ b/fpdfsdk/pwl/cpwl_wnd.cpp
@@ -245,27 +245,27 @@
 }
 
 void CPWL_Wnd::DrawAppearance(CFX_RenderDevice* pDevice,
-                              CFX_Matrix* pUser2Device) {
+                              const CFX_Matrix& mtUser2Device) {
   if (IsValid() && IsVisible()) {
-    DrawThisAppearance(pDevice, pUser2Device);
-    DrawChildAppearance(pDevice, pUser2Device);
+    DrawThisAppearance(pDevice, mtUser2Device);
+    DrawChildAppearance(pDevice, mtUser2Device);
   }
 }
 
 void CPWL_Wnd::DrawThisAppearance(CFX_RenderDevice* pDevice,
-                                  CFX_Matrix* pUser2Device) {
+                                  const CFX_Matrix& mtUser2Device) {
   CFX_FloatRect rectWnd = GetWindowRect();
   if (rectWnd.IsEmpty())
     return;
 
   if (HasFlag(PWS_BACKGROUND)) {
     float width = static_cast<float>(GetBorderWidth() + GetInnerBorderWidth());
-    pDevice->DrawFillRect(pUser2Device, rectWnd.GetDeflated(width, width),
+    pDevice->DrawFillRect(&mtUser2Device, rectWnd.GetDeflated(width, width),
                           GetBackgroundColor(), GetTransparency());
   }
 
   if (HasFlag(PWS_BORDER)) {
-    pDevice->DrawBorder(pUser2Device, rectWnd,
+    pDevice->DrawBorder(&mtUser2Device, rectWnd,
                         static_cast<float>(GetBorderWidth()), GetBorderColor(),
                         GetBorderLeftTopColor(GetBorderStyle()),
                         GetBorderRightBottomColor(GetBorderStyle()),
@@ -274,17 +274,17 @@
 }
 
 void CPWL_Wnd::DrawChildAppearance(CFX_RenderDevice* pDevice,
-                                   CFX_Matrix* pUser2Device) {
+                                   const CFX_Matrix& mtUser2Device) {
   for (CPWL_Wnd* pChild : m_Children) {
     if (!pChild)
       continue;
 
     CFX_Matrix mt = pChild->GetChildMatrix();
     if (mt.IsIdentity()) {
-      pChild->DrawAppearance(pDevice, pUser2Device);
+      pChild->DrawAppearance(pDevice, mtUser2Device);
     } else {
-      mt.Concat(*pUser2Device);
-      pChild->DrawAppearance(pDevice, &mt);
+      mt.Concat(mtUser2Device);
+      pChild->DrawAppearance(pDevice, mt);
     }
   }
 }
diff --git a/fpdfsdk/pwl/cpwl_wnd.h b/fpdfsdk/pwl/cpwl_wnd.h
index 78edaa2..3c6c282 100644
--- a/fpdfsdk/pwl/cpwl_wnd.h
+++ b/fpdfsdk/pwl/cpwl_wnd.h
@@ -215,7 +215,8 @@
   void SetCapture();
   void ReleaseCapture();
 
-  void DrawAppearance(CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device);
+  void DrawAppearance(CFX_RenderDevice* pDevice,
+                      const CFX_Matrix& mtUser2Device);
 
   CFX_Color GetBackgroundColor() const;
   void SetBackgroundColor(const CFX_Color& color);
@@ -278,7 +279,7 @@
   virtual void RePosChildWnd();
 
   virtual void DrawThisAppearance(CFX_RenderDevice* pDevice,
-                                  CFX_Matrix* pUser2Device);
+                                  const CFX_Matrix& mtUser2Device);
 
   virtual void OnCreate(PWL_CREATEPARAM& cp);
   virtual void OnCreated();
@@ -314,7 +315,8 @@
   CFX_PointF ParentToChild(const CFX_PointF& point) const;
   CFX_FloatRect ParentToChild(const CFX_FloatRect& rect) const;
 
-  void DrawChildAppearance(CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device);
+  void DrawChildAppearance(CFX_RenderDevice* pDevice,
+                           const CFX_Matrix& mtUser2Device);
 
   FX_RECT PWLtoWnd(const CFX_FloatRect& rect) const;