Pass CreateParams to CPWL_Wnd constructor.

The previous reshuffling means we always have the create params
earlier, so pass them in at create time.

Clean up two forward declarations that were not needed as
noticed in the process.

Change-Id: I5d3861f3c1e3508e0d25950e919859244fac5f8b
Reviewed-on: https://pdfium-review.googlesource.com/c/44710
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fpdfsdk/formfiller/cffl_checkbox.cpp b/fpdfsdk/formfiller/cffl_checkbox.cpp
index fbf6c34..a40cfc6 100644
--- a/fpdfsdk/formfiller/cffl_checkbox.cpp
+++ b/fpdfsdk/formfiller/cffl_checkbox.cpp
@@ -24,8 +24,8 @@
 std::unique_ptr<CPWL_Wnd> CFFL_CheckBox::NewPWLWindow(
     const CPWL_Wnd::CreateParams& cp,
     std::unique_ptr<CPWL_Wnd::PrivateData> pAttachedData) {
-  auto pWnd = pdfium::MakeUnique<CPWL_CheckBox>(std::move(pAttachedData));
-  pWnd->Realize(cp);
+  auto pWnd = pdfium::MakeUnique<CPWL_CheckBox>(cp, std::move(pAttachedData));
+  pWnd->Realize();
   pWnd->SetCheck(m_pWidget->IsChecked());
   return std::move(pWnd);
 }
diff --git a/fpdfsdk/formfiller/cffl_combobox.cpp b/fpdfsdk/formfiller/cffl_combobox.cpp
index 358596e..f163c78 100644
--- a/fpdfsdk/formfiller/cffl_combobox.cpp
+++ b/fpdfsdk/formfiller/cffl_combobox.cpp
@@ -47,9 +47,9 @@
 std::unique_ptr<CPWL_Wnd> CFFL_ComboBox::NewPWLWindow(
     const CPWL_Wnd::CreateParams& cp,
     std::unique_ptr<CPWL_Wnd::PrivateData> pAttachedData) {
-  auto pWnd = pdfium::MakeUnique<CPWL_ComboBox>(std::move(pAttachedData));
+  auto pWnd = pdfium::MakeUnique<CPWL_ComboBox>(cp, std::move(pAttachedData));
   pWnd->AttachFFLData(this);
-  pWnd->Realize(cp);
+  pWnd->Realize();
 
   CFFL_InteractiveFormFiller* pFormFiller =
       m_pFormFillEnv->GetInteractiveFormFiller();
diff --git a/fpdfsdk/formfiller/cffl_listbox.cpp b/fpdfsdk/formfiller/cffl_listbox.cpp
index e601c83..0b67ab0 100644
--- a/fpdfsdk/formfiller/cffl_listbox.cpp
+++ b/fpdfsdk/formfiller/cffl_listbox.cpp
@@ -42,9 +42,9 @@
 std::unique_ptr<CPWL_Wnd> CFFL_ListBox::NewPWLWindow(
     const CPWL_Wnd::CreateParams& cp,
     std::unique_ptr<CPWL_Wnd::PrivateData> pAttachedData) {
-  auto pWnd = pdfium::MakeUnique<CPWL_ListBox>(std::move(pAttachedData));
+  auto pWnd = pdfium::MakeUnique<CPWL_ListBox>(cp, std::move(pAttachedData));
   pWnd->AttachFFLData(this);
-  pWnd->Realize(cp);
+  pWnd->Realize();
   pWnd->SetFillerNotify(m_pFormFillEnv->GetInteractiveFormFiller());
 
   for (int32_t i = 0, sz = m_pWidget->CountOptions(); i < sz; i++)
diff --git a/fpdfsdk/formfiller/cffl_pushbutton.cpp b/fpdfsdk/formfiller/cffl_pushbutton.cpp
index d7a4218..4f80593 100644
--- a/fpdfsdk/formfiller/cffl_pushbutton.cpp
+++ b/fpdfsdk/formfiller/cffl_pushbutton.cpp
@@ -20,7 +20,7 @@
 std::unique_ptr<CPWL_Wnd> CFFL_PushButton::NewPWLWindow(
     const CPWL_Wnd::CreateParams& cp,
     std::unique_ptr<CPWL_Wnd::PrivateData> pAttachedData) {
-  auto pWnd = pdfium::MakeUnique<CPWL_PushButton>(std::move(pAttachedData));
-  pWnd->Realize(cp);
+  auto pWnd = pdfium::MakeUnique<CPWL_PushButton>(cp, std::move(pAttachedData));
+  pWnd->Realize();
   return std::move(pWnd);
 }
diff --git a/fpdfsdk/formfiller/cffl_radiobutton.cpp b/fpdfsdk/formfiller/cffl_radiobutton.cpp
index ffe1ee7..c8c65dc 100644
--- a/fpdfsdk/formfiller/cffl_radiobutton.cpp
+++ b/fpdfsdk/formfiller/cffl_radiobutton.cpp
@@ -23,8 +23,9 @@
 std::unique_ptr<CPWL_Wnd> CFFL_RadioButton::NewPWLWindow(
     const CPWL_Wnd::CreateParams& cp,
     std::unique_ptr<CPWL_Wnd::PrivateData> pAttachedData) {
-  auto pWnd = pdfium::MakeUnique<CPWL_RadioButton>(std::move(pAttachedData));
-  pWnd->Realize(cp);
+  auto pWnd =
+      pdfium::MakeUnique<CPWL_RadioButton>(cp, std::move(pAttachedData));
+  pWnd->Realize();
   pWnd->SetCheck(m_pWidget->IsChecked());
   return std::move(pWnd);
 }
diff --git a/fpdfsdk/formfiller/cffl_textfield.cpp b/fpdfsdk/formfiller/cffl_textfield.cpp
index 79f4f3d..76b2ec1 100644
--- a/fpdfsdk/formfiller/cffl_textfield.cpp
+++ b/fpdfsdk/formfiller/cffl_textfield.cpp
@@ -72,9 +72,9 @@
 std::unique_ptr<CPWL_Wnd> CFFL_TextField::NewPWLWindow(
     const CPWL_Wnd::CreateParams& cp,
     std::unique_ptr<CPWL_Wnd::PrivateData> pAttachedData) {
-  auto pWnd = pdfium::MakeUnique<CPWL_Edit>(std::move(pAttachedData));
+  auto pWnd = pdfium::MakeUnique<CPWL_Edit>(cp, std::move(pAttachedData));
   pWnd->AttachFFLData(this);
-  pWnd->Realize(cp);
+  pWnd->Realize();
   pWnd->SetFillerNotify(m_pFormFillEnv->GetInteractiveFormFiller());
 
   int32_t nMaxLen = m_pWidget->GetMaxLen();
diff --git a/fpdfsdk/pwl/cpwl_appstream.cpp b/fpdfsdk/pwl/cpwl_appstream.cpp
index 02541aa3..93bd3e7 100644
--- a/fpdfsdk/pwl/cpwl_appstream.cpp
+++ b/fpdfsdk/pwl/cpwl_appstream.cpp
@@ -683,10 +683,11 @@
   if (rcIcon.IsEmpty() || !pIconStream)
     return ByteString();
 
-  CPWL_Icon icon(nullptr);
-  CPWL_Wnd::CreateParams cp;  // No parent.
+  CPWL_Wnd::CreateParams cp;
   cp.dwFlags = PWS_VISIBLE;
-  icon.Realize(cp);
+
+  CPWL_Icon icon(cp, nullptr);
+  icon.Realize();
   icon.SetIconFit(&fit);
   icon.SetPDFStream(pIconStream);
   if (!icon.Move(rcIcon, false, false))
diff --git a/fpdfsdk/pwl/cpwl_button.cpp b/fpdfsdk/pwl/cpwl_button.cpp
index 766e8c4..9f746cf 100644
--- a/fpdfsdk/pwl/cpwl_button.cpp
+++ b/fpdfsdk/pwl/cpwl_button.cpp
@@ -10,8 +10,9 @@
 
 #include "fpdfsdk/pwl/cpwl_wnd.h"
 
-CPWL_Button::CPWL_Button(std::unique_ptr<PrivateData> pAttachedData)
-    : CPWL_Wnd(std::move(pAttachedData)) {}
+CPWL_Button::CPWL_Button(const CreateParams& cp,
+                         std::unique_ptr<PrivateData> pAttachedData)
+    : CPWL_Wnd(cp, std::move(pAttachedData)) {}
 
 CPWL_Button::~CPWL_Button() = default;
 
diff --git a/fpdfsdk/pwl/cpwl_button.h b/fpdfsdk/pwl/cpwl_button.h
index cf53ff9..5835b7a 100644
--- a/fpdfsdk/pwl/cpwl_button.h
+++ b/fpdfsdk/pwl/cpwl_button.h
@@ -13,7 +13,8 @@
 
 class CPWL_Button : public CPWL_Wnd {
  public:
-  explicit CPWL_Button(std::unique_ptr<PrivateData> pAttachedData);
+  CPWL_Button(const CreateParams& cp,
+              std::unique_ptr<PrivateData> pAttachedData);
   ~CPWL_Button() override;
 
   // CPWL_Wnd
diff --git a/fpdfsdk/pwl/cpwl_caret.cpp b/fpdfsdk/pwl/cpwl_caret.cpp
index 63fb1ce..4dfda8a 100644
--- a/fpdfsdk/pwl/cpwl_caret.cpp
+++ b/fpdfsdk/pwl/cpwl_caret.cpp
@@ -16,8 +16,9 @@
 
 #define PWL_CARET_FLASHINTERVAL 500
 
-CPWL_Caret::CPWL_Caret(std::unique_ptr<PrivateData> pAttachedData)
-    : CPWL_Wnd(std::move(pAttachedData)) {}
+CPWL_Caret::CPWL_Caret(const CreateParams& cp,
+                       std::unique_ptr<PrivateData> pAttachedData)
+    : CPWL_Wnd(cp, std::move(pAttachedData)) {}
 
 CPWL_Caret::~CPWL_Caret() = default;
 
diff --git a/fpdfsdk/pwl/cpwl_caret.h b/fpdfsdk/pwl/cpwl_caret.h
index c85a877..f576fe3 100644
--- a/fpdfsdk/pwl/cpwl_caret.h
+++ b/fpdfsdk/pwl/cpwl_caret.h
@@ -13,7 +13,8 @@
 
 class CPWL_Caret final : public CPWL_Wnd {
  public:
-  explicit CPWL_Caret(std::unique_ptr<PrivateData> pAttachedData);
+  CPWL_Caret(const CreateParams& cp,
+             std::unique_ptr<PrivateData> pAttachedData);
   ~CPWL_Caret() override;
 
   // CPWL_Wnd
diff --git a/fpdfsdk/pwl/cpwl_combo_box.cpp b/fpdfsdk/pwl/cpwl_combo_box.cpp
index 887b022..eef4496 100644
--- a/fpdfsdk/pwl/cpwl_combo_box.cpp
+++ b/fpdfsdk/pwl/cpwl_combo_box.cpp
@@ -27,8 +27,9 @@
 
 }  // namespace
 
-CPWL_CBListBox::CPWL_CBListBox(std::unique_ptr<PrivateData> pAttachedData)
-    : CPWL_ListBox(std::move(pAttachedData)) {}
+CPWL_CBListBox::CPWL_CBListBox(const CreateParams& cp,
+                               std::unique_ptr<PrivateData> pAttachedData)
+    : CPWL_ListBox(cp, std::move(pAttachedData)) {}
 
 CPWL_CBListBox::~CPWL_CBListBox() = default;
 
@@ -100,8 +101,9 @@
   return OnNotifySelectionChanged(true, nFlag);
 }
 
-CPWL_CBButton::CPWL_CBButton(std::unique_ptr<PrivateData> pAttachedData)
-    : CPWL_Wnd(std::move(pAttachedData)) {}
+CPWL_CBButton::CPWL_CBButton(const CreateParams& cp,
+                             std::unique_ptr<PrivateData> pAttachedData)
+    : CPWL_Wnd(cp, std::move(pAttachedData)) {}
 
 CPWL_CBButton::~CPWL_CBButton() = default;
 
@@ -156,8 +158,9 @@
   return true;
 }
 
-CPWL_ComboBox::CPWL_ComboBox(std::unique_ptr<PrivateData> pAttachedData)
-    : CPWL_Wnd(std::move(pAttachedData)) {}
+CPWL_ComboBox::CPWL_ComboBox(const CreateParams& cp,
+                             std::unique_ptr<PrivateData> pAttachedData)
+    : CPWL_Wnd(cp, std::move(pAttachedData)) {}
 
 CPWL_ComboBox::~CPWL_ComboBox() = default;
 
@@ -286,11 +289,11 @@
   ecp.dwBorderWidth = 0;
   ecp.nBorderStyle = BorderStyle::SOLID;
 
-  auto pEdit = pdfium::MakeUnique<CPWL_Edit>(CloneAttachedData());
+  auto pEdit = pdfium::MakeUnique<CPWL_Edit>(ecp, CloneAttachedData());
   m_pEdit = pEdit.get();
   m_pEdit->AttachFFLData(m_pFormFiller.Get());
   AddChild(std::move(pEdit));
-  m_pEdit->Realize(ecp);
+  m_pEdit->Realize();
 }
 
 void CPWL_ComboBox::CreateButton(const CreateParams& cp) {
@@ -306,10 +309,10 @@
   bcp.nBorderStyle = BorderStyle::BEVELED;
   bcp.eCursorType = FXCT_ARROW;
 
-  auto pButton = pdfium::MakeUnique<CPWL_CBButton>(CloneAttachedData());
+  auto pButton = pdfium::MakeUnique<CPWL_CBButton>(bcp, CloneAttachedData());
   m_pButton = pButton.get();
   AddChild(std::move(pButton));
-  m_pButton->Realize(bcp);
+  m_pButton->Realize();
 }
 
 void CPWL_ComboBox::CreateListBox(const CreateParams& cp) {
@@ -333,11 +336,11 @@
   if (cp.sBackgroundColor.nColorType == CFX_Color::kTransparent)
     lcp.sBackgroundColor = PWL_DEFAULT_WHITECOLOR;
 
-  auto pList = pdfium::MakeUnique<CPWL_CBListBox>(CloneAttachedData());
+  auto pList = pdfium::MakeUnique<CPWL_CBListBox>(lcp, CloneAttachedData());
   m_pList = pList.get();
   m_pList->AttachFFLData(m_pFormFiller.Get());
   AddChild(std::move(pList));
-  m_pList->Realize(lcp);
+  m_pList->Realize();
 }
 
 bool CPWL_ComboBox::RePosChildWnd() {
diff --git a/fpdfsdk/pwl/cpwl_combo_box.h b/fpdfsdk/pwl/cpwl_combo_box.h
index e3a3ff3..ee6ed90 100644
--- a/fpdfsdk/pwl/cpwl_combo_box.h
+++ b/fpdfsdk/pwl/cpwl_combo_box.h
@@ -16,7 +16,8 @@
 
 class CPWL_CBListBox final : public CPWL_ListBox {
  public:
-  explicit CPWL_CBListBox(std::unique_ptr<PrivateData> pAttachedData);
+  CPWL_CBListBox(const CreateParams& cp,
+                 std::unique_ptr<PrivateData> pAttachedData);
   ~CPWL_CBListBox() override;
 
   // CPWL_ListBox
@@ -30,7 +31,8 @@
 
 class CPWL_CBButton final : public CPWL_Wnd {
  public:
-  explicit CPWL_CBButton(std::unique_ptr<PrivateData> pAttachedData);
+  CPWL_CBButton(const CreateParams& cp,
+                std::unique_ptr<PrivateData> pAttachedData);
   ~CPWL_CBButton() override;
 
   // CPWL_Wnd
@@ -42,7 +44,8 @@
 
 class CPWL_ComboBox final : public CPWL_Wnd {
  public:
-  explicit CPWL_ComboBox(std::unique_ptr<PrivateData> pAttachedData);
+  CPWL_ComboBox(const CreateParams& cp,
+                std::unique_ptr<PrivateData> pAttachedData);
   ~CPWL_ComboBox() override;
 
   CPWL_Edit* GetEdit() const { return m_pEdit.Get(); }
diff --git a/fpdfsdk/pwl/cpwl_edit.cpp b/fpdfsdk/pwl/cpwl_edit.cpp
index d0922cd..abaac94 100644
--- a/fpdfsdk/pwl/cpwl_edit.cpp
+++ b/fpdfsdk/pwl/cpwl_edit.cpp
@@ -27,8 +27,9 @@
 #include "fpdfsdk/pwl/cpwl_wnd.h"
 #include "public/fpdf_fwlevent.h"
 
-CPWL_Edit::CPWL_Edit(std::unique_ptr<PrivateData> pAttachedData)
-    : CPWL_EditCtrl(std::move(pAttachedData)) {}
+CPWL_Edit::CPWL_Edit(const CreateParams& cp,
+                     std::unique_ptr<PrivateData> pAttachedData)
+    : CPWL_EditCtrl(cp, std::move(pAttachedData)) {}
 
 CPWL_Edit::~CPWL_Edit() {
   ASSERT(!m_bFocus);
diff --git a/fpdfsdk/pwl/cpwl_edit.h b/fpdfsdk/pwl/cpwl_edit.h
index c996437..419a240 100644
--- a/fpdfsdk/pwl/cpwl_edit.h
+++ b/fpdfsdk/pwl/cpwl_edit.h
@@ -43,7 +43,7 @@
 
 class CPWL_Edit final : public CPWL_EditCtrl {
  public:
-  explicit CPWL_Edit(std::unique_ptr<PrivateData> pAttachedData);
+  CPWL_Edit(const CreateParams& cp, std::unique_ptr<PrivateData> pAttachedData);
   ~CPWL_Edit() override;
 
   // CPWL_EditCtrl
diff --git a/fpdfsdk/pwl/cpwl_edit_ctrl.cpp b/fpdfsdk/pwl/cpwl_edit_ctrl.cpp
index 44918be..1b398a6 100644
--- a/fpdfsdk/pwl/cpwl_edit_ctrl.cpp
+++ b/fpdfsdk/pwl/cpwl_edit_ctrl.cpp
@@ -18,8 +18,9 @@
 #include "public/fpdf_fwlevent.h"
 #include "third_party/base/ptr_util.h"
 
-CPWL_EditCtrl::CPWL_EditCtrl(std::unique_ptr<PrivateData> pAttachedData)
-    : CPWL_Wnd(std::move(pAttachedData)),
+CPWL_EditCtrl::CPWL_EditCtrl(const CreateParams& cp,
+                             std::unique_ptr<PrivateData> pAttachedData)
+    : CPWL_Wnd(cp, std::move(pAttachedData)),
       m_pEdit(pdfium::MakeUnique<CPWL_EditImpl>()) {}
 
 CPWL_EditCtrl::~CPWL_EditCtrl() = default;
@@ -94,11 +95,11 @@
   ecp.nBorderStyle = BorderStyle::SOLID;
   ecp.rcRectWnd = CFX_FloatRect();
 
-  auto pCaret = pdfium::MakeUnique<CPWL_Caret>(CloneAttachedData());
+  auto pCaret = pdfium::MakeUnique<CPWL_Caret>(ecp, CloneAttachedData());
   m_pEditCaret = pCaret.get();
   m_pEditCaret->SetInvalidRect(GetClientRect());
   AddChild(std::move(pCaret));
-  m_pEditCaret->Realize(ecp);
+  m_pEditCaret->Realize();
 }
 
 void CPWL_EditCtrl::SetFontSize(float fFontSize) {
diff --git a/fpdfsdk/pwl/cpwl_edit_ctrl.h b/fpdfsdk/pwl/cpwl_edit_ctrl.h
index eb8ccb8..cb89943 100644
--- a/fpdfsdk/pwl/cpwl_edit_ctrl.h
+++ b/fpdfsdk/pwl/cpwl_edit_ctrl.h
@@ -23,7 +23,8 @@
 
 class CPWL_EditCtrl : public CPWL_Wnd {
  public:
-  explicit CPWL_EditCtrl(std::unique_ptr<PrivateData> pAttachedData);
+  CPWL_EditCtrl(const CreateParams& cp,
+                std::unique_ptr<PrivateData> pAttachedData);
   ~CPWL_EditCtrl() override;
 
   void SetSelection(int32_t nStartChar, int32_t nEndChar);
diff --git a/fpdfsdk/pwl/cpwl_icon.cpp b/fpdfsdk/pwl/cpwl_icon.cpp
index 8d672f5..946c76f 100644
--- a/fpdfsdk/pwl/cpwl_icon.cpp
+++ b/fpdfsdk/pwl/cpwl_icon.cpp
@@ -15,8 +15,9 @@
 #include "core/fpdfapi/parser/cpdf_stream.h"
 #include "fpdfsdk/pwl/cpwl_wnd.h"
 
-CPWL_Icon::CPWL_Icon(std::unique_ptr<PrivateData> pAttachedData)
-    : CPWL_Wnd(std::move(pAttachedData)) {}
+CPWL_Icon::CPWL_Icon(const CreateParams& cp,
+                     std::unique_ptr<PrivateData> pAttachedData)
+    : CPWL_Wnd(cp, std::move(pAttachedData)) {}
 
 CPWL_Icon::~CPWL_Icon() = default;
 
diff --git a/fpdfsdk/pwl/cpwl_icon.h b/fpdfsdk/pwl/cpwl_icon.h
index 83709f7..b36c697 100644
--- a/fpdfsdk/pwl/cpwl_icon.h
+++ b/fpdfsdk/pwl/cpwl_icon.h
@@ -16,7 +16,7 @@
 
 class CPWL_Icon final : public CPWL_Wnd {
  public:
-  explicit CPWL_Icon(std::unique_ptr<PrivateData> pAttachedData);
+  CPWL_Icon(const CreateParams& cp, std::unique_ptr<PrivateData> pAttachedData);
   ~CPWL_Icon() override;
 
   void SetIconFit(CPDF_IconFit* pIconFit) { m_pIconFit = pIconFit; }
diff --git a/fpdfsdk/pwl/cpwl_list_box.cpp b/fpdfsdk/pwl/cpwl_list_box.cpp
index 4cea17b..003fe11 100644
--- a/fpdfsdk/pwl/cpwl_list_box.cpp
+++ b/fpdfsdk/pwl/cpwl_list_box.cpp
@@ -65,8 +65,9 @@
   m_pList->InvalidateRect(pRect);
 }
 
-CPWL_ListBox::CPWL_ListBox(std::unique_ptr<PrivateData> pAttachedData)
-    : CPWL_Wnd(std::move(pAttachedData)),
+CPWL_ListBox::CPWL_ListBox(const CreateParams& cp,
+                           std::unique_ptr<PrivateData> pAttachedData)
+    : CPWL_Wnd(cp, std::move(pAttachedData)),
       m_pList(pdfium::MakeUnique<CPWL_ListCtrl>()) {}
 
 CPWL_ListBox::~CPWL_ListBox() = default;
diff --git a/fpdfsdk/pwl/cpwl_list_box.h b/fpdfsdk/pwl/cpwl_list_box.h
index cbfca45..2b4d693 100644
--- a/fpdfsdk/pwl/cpwl_list_box.h
+++ b/fpdfsdk/pwl/cpwl_list_box.h
@@ -38,7 +38,8 @@
 
 class CPWL_ListBox : public CPWL_Wnd {
  public:
-  explicit CPWL_ListBox(std::unique_ptr<PrivateData> pAttachedData);
+  CPWL_ListBox(const CreateParams& cp,
+               std::unique_ptr<PrivateData> pAttachedData);
   ~CPWL_ListBox() override;
 
   // CPWL_Wnd
diff --git a/fpdfsdk/pwl/cpwl_scroll_bar.cpp b/fpdfsdk/pwl/cpwl_scroll_bar.cpp
index fb2060a..0209ba0 100644
--- a/fpdfsdk/pwl/cpwl_scroll_bar.cpp
+++ b/fpdfsdk/pwl/cpwl_scroll_bar.cpp
@@ -105,10 +105,11 @@
     SetPos(ScrollRange.fMin);
 }
 
-CPWL_SBButton::CPWL_SBButton(std::unique_ptr<PrivateData> pAttachedData,
+CPWL_SBButton::CPWL_SBButton(const CreateParams& cp,
+                             std::unique_ptr<PrivateData> pAttachedData,
                              PWL_SCROLLBAR_TYPE eScrollBarType,
                              PWL_SBBUTTON_TYPE eButtonType)
-    : CPWL_Wnd(std::move(pAttachedData)),
+    : CPWL_Wnd(cp, std::move(pAttachedData)),
       m_eScrollBarType(eScrollBarType),
       m_eSBButtonType(eButtonType) {}
 
@@ -298,9 +299,10 @@
   return true;
 }
 
-CPWL_ScrollBar::CPWL_ScrollBar(std::unique_ptr<PrivateData> pAttachedData,
+CPWL_ScrollBar::CPWL_ScrollBar(const CreateParams& cp,
+                               std::unique_ptr<PrivateData> pAttachedData,
                                PWL_SCROLLBAR_TYPE sbType)
-    : CPWL_Wnd(std::move(pAttachedData)), m_sbType(sbType) {}
+    : CPWL_Wnd(cp, std::move(pAttachedData)), m_sbType(sbType) {}
 
 CPWL_ScrollBar::~CPWL_ScrollBar() = default;
 
@@ -541,29 +543,29 @@
       PWS_VISIBLE | PWS_CHILD | PWS_BORDER | PWS_BACKGROUND | PWS_NOREFRESHCLIP;
 
   if (!m_pMinButton) {
-    auto pButton = pdfium::MakeUnique<CPWL_SBButton>(CloneAttachedData(),
+    auto pButton = pdfium::MakeUnique<CPWL_SBButton>(scp, CloneAttachedData(),
                                                      m_sbType, PSBT_MIN);
     m_pMinButton = pButton.get();
     AddChild(std::move(pButton));
-    m_pMinButton->Realize(scp);
+    m_pMinButton->Realize();
   }
 
   if (!m_pMaxButton) {
-    auto pButton = pdfium::MakeUnique<CPWL_SBButton>(CloneAttachedData(),
+    auto pButton = pdfium::MakeUnique<CPWL_SBButton>(scp, CloneAttachedData(),
                                                      m_sbType, PSBT_MAX);
     m_pMaxButton = pButton.get();
     AddChild(std::move(pButton));
-    m_pMaxButton->Realize(scp);
+    m_pMaxButton->Realize();
   }
 
   if (!m_pPosButton) {
-    auto pButton = pdfium::MakeUnique<CPWL_SBButton>(CloneAttachedData(),
+    auto pButton = pdfium::MakeUnique<CPWL_SBButton>(scp, CloneAttachedData(),
                                                      m_sbType, PSBT_POS);
     m_pPosButton = pButton.get();
     ObservedPtr thisObserved(this);
     if (m_pPosButton->SetVisible(false) && thisObserved) {
       AddChild(std::move(pButton));
-      m_pPosButton->Realize(scp);
+      m_pPosButton->Realize();
     }
   }
 }
diff --git a/fpdfsdk/pwl/cpwl_scroll_bar.h b/fpdfsdk/pwl/cpwl_scroll_bar.h
index 40660db..82c995b 100644
--- a/fpdfsdk/pwl/cpwl_scroll_bar.h
+++ b/fpdfsdk/pwl/cpwl_scroll_bar.h
@@ -12,9 +12,6 @@
 #include "core/fxcrt/unowned_ptr.h"
 #include "fpdfsdk/pwl/cpwl_wnd.h"
 
-class CPWL_SBButton;
-class CPWL_ScrollBar;
-
 struct PWL_SCROLL_INFO {
  public:
   PWL_SCROLL_INFO()
@@ -46,7 +43,8 @@
 
 class CPWL_SBButton final : public CPWL_Wnd {
  public:
-  CPWL_SBButton(std::unique_ptr<PrivateData> pAttachedData,
+  CPWL_SBButton(const CreateParams& cp,
+                std::unique_ptr<PrivateData> pAttachedData,
                 PWL_SCROLLBAR_TYPE eScrollBarType,
                 PWL_SBBUTTON_TYPE eButtonType);
   ~CPWL_SBButton() override;
@@ -117,7 +115,8 @@
 
 class CPWL_ScrollBar final : public CPWL_Wnd {
  public:
-  CPWL_ScrollBar(std::unique_ptr<PrivateData> pAttachedData,
+  CPWL_ScrollBar(const CreateParams& cp,
+                 std::unique_ptr<PrivateData> pAttachedData,
                  PWL_SCROLLBAR_TYPE sbType);
   ~CPWL_ScrollBar() override;
 
diff --git a/fpdfsdk/pwl/cpwl_special_button.cpp b/fpdfsdk/pwl/cpwl_special_button.cpp
index 8e5f1b8..16f8c89 100644
--- a/fpdfsdk/pwl/cpwl_special_button.cpp
+++ b/fpdfsdk/pwl/cpwl_special_button.cpp
@@ -11,8 +11,9 @@
 #include "fpdfsdk/pwl/cpwl_button.h"
 #include "fpdfsdk/pwl/cpwl_wnd.h"
 
-CPWL_PushButton::CPWL_PushButton(std::unique_ptr<PrivateData> pAttachedData)
-    : CPWL_Button(std::move(pAttachedData)) {}
+CPWL_PushButton::CPWL_PushButton(const CreateParams& cp,
+                                 std::unique_ptr<PrivateData> pAttachedData)
+    : CPWL_Button(cp, std::move(pAttachedData)) {}
 
 CPWL_PushButton::~CPWL_PushButton() = default;
 
@@ -21,8 +22,9 @@
                                      static_cast<float>(GetBorderWidth()));
 }
 
-CPWL_CheckBox::CPWL_CheckBox(std::unique_ptr<PrivateData> pAttachedData)
-    : CPWL_Button(std::move(pAttachedData)) {}
+CPWL_CheckBox::CPWL_CheckBox(const CreateParams& cp,
+                             std::unique_ptr<PrivateData> pAttachedData)
+    : CPWL_Button(cp, std::move(pAttachedData)) {}
 
 CPWL_CheckBox::~CPWL_CheckBox() = default;
 
@@ -39,8 +41,9 @@
   return true;
 }
 
-CPWL_RadioButton::CPWL_RadioButton(std::unique_ptr<PrivateData> pAttachedData)
-    : CPWL_Button(std::move(pAttachedData)) {}
+CPWL_RadioButton::CPWL_RadioButton(const CreateParams& cp,
+                                   std::unique_ptr<PrivateData> pAttachedData)
+    : CPWL_Button(cp, std::move(pAttachedData)) {}
 
 CPWL_RadioButton::~CPWL_RadioButton() = default;
 
diff --git a/fpdfsdk/pwl/cpwl_special_button.h b/fpdfsdk/pwl/cpwl_special_button.h
index 28c2a6b..68bb965 100644
--- a/fpdfsdk/pwl/cpwl_special_button.h
+++ b/fpdfsdk/pwl/cpwl_special_button.h
@@ -13,7 +13,8 @@
 
 class CPWL_PushButton final : public CPWL_Button {
  public:
-  explicit CPWL_PushButton(std::unique_ptr<PrivateData> pAttachedData);
+  CPWL_PushButton(const CreateParams& cp,
+                  std::unique_ptr<PrivateData> pAttachedData);
   ~CPWL_PushButton() override;
 
   // CPWL_Button:
@@ -22,7 +23,8 @@
 
 class CPWL_CheckBox final : public CPWL_Button {
  public:
-  explicit CPWL_CheckBox(std::unique_ptr<PrivateData> pAttachedData);
+  CPWL_CheckBox(const CreateParams& cp,
+                std::unique_ptr<PrivateData> pAttachedData);
   ~CPWL_CheckBox() override;
 
   // CPWL_Button:
@@ -38,7 +40,8 @@
 
 class CPWL_RadioButton final : public CPWL_Button {
  public:
-  explicit CPWL_RadioButton(std::unique_ptr<PrivateData> pAttachedData);
+  CPWL_RadioButton(const CreateParams& cp,
+                   std::unique_ptr<PrivateData> pAttachedData);
   ~CPWL_RadioButton() override;
 
   // CPWL_Button
diff --git a/fpdfsdk/pwl/cpwl_wnd.cpp b/fpdfsdk/pwl/cpwl_wnd.cpp
index 8ed57de..90aa15c 100644
--- a/fpdfsdk/pwl/cpwl_wnd.cpp
+++ b/fpdfsdk/pwl/cpwl_wnd.cpp
@@ -111,17 +111,17 @@
   UnownedPtr<CPWL_Wnd> m_pMainKeyboardWnd;
 };
 
-CPWL_Wnd::CPWL_Wnd(std::unique_ptr<PrivateData> pAttachedData)
-    : m_pAttachedData(std::move(pAttachedData)) {}
+CPWL_Wnd::CPWL_Wnd(const CreateParams& cp,
+                   std::unique_ptr<PrivateData> pAttachedData)
+    : m_CreationParams(cp), m_pAttachedData(std::move(pAttachedData)) {}
 
 CPWL_Wnd::~CPWL_Wnd() {
   ASSERT(!m_bCreated);
 }
 
-void CPWL_Wnd::Realize(const CreateParams& cp) {
+void CPWL_Wnd::Realize() {
   ASSERT(!m_bCreated);
 
-  m_CreationParams = cp;
   OnCreate(&m_CreationParams);
   m_CreationParams.rcRectWnd.Normalize();
   m_rcWindow = m_CreationParams.rcRectWnd;
@@ -484,20 +484,17 @@
     return;
 
   CreateParams scp = cp;
-
-  // flags
   scp.dwFlags =
       PWS_CHILD | PWS_BACKGROUND | PWS_AUTOTRANSPARENT | PWS_NOREFRESHCLIP;
-
   scp.sBackgroundColor = PWL_DEFAULT_WHITECOLOR;
   scp.eCursorType = FXCT_ARROW;
   scp.nTransparency = PWL_SCROLLBAR_TRANSPARENCY;
 
   auto pBar =
-      pdfium::MakeUnique<CPWL_ScrollBar>(CloneAttachedData(), SBT_VSCROLL);
+      pdfium::MakeUnique<CPWL_ScrollBar>(scp, CloneAttachedData(), SBT_VSCROLL);
   m_pVScrollBar = pBar.get();
   AddChild(std::move(pBar));
-  m_pVScrollBar->Realize(scp);
+  m_pVScrollBar->Realize();
 }
 
 void CPWL_Wnd::SetCapture() {
diff --git a/fpdfsdk/pwl/cpwl_wnd.h b/fpdfsdk/pwl/cpwl_wnd.h
index 51e34a7..64fe131 100644
--- a/fpdfsdk/pwl/cpwl_wnd.h
+++ b/fpdfsdk/pwl/cpwl_wnd.h
@@ -132,7 +132,7 @@
     CFX_Matrix mtChild;                               // ignore
   };
 
-  explicit CPWL_Wnd(std::unique_ptr<PrivateData> pAttachedData);
+  CPWL_Wnd(const CreateParams& cp, std::unique_ptr<PrivateData> pAttachedData);
   ~CPWL_Wnd() override;
 
   // Returns |true| iff this instance is still allocated.
@@ -178,7 +178,7 @@
 
   void AddChild(std::unique_ptr<CPWL_Wnd> pWnd);
   void RemoveChild(CPWL_Wnd* pWnd);
-  void Realize(const CreateParams& cp);
+  void Realize();
   void Destroy();
   bool Move(const CFX_FloatRect& rcNew, bool bReset, bool bRefresh);