Replace FWLTHEME color and capacity defines with constexpr [pdfium : main]

0 views
Skip to first unread message

Helmut Januschka (Gerrit)

unread,
May 31, 2026, 1:07:17 PM (4 days ago) May 31
to pdfium-...@googlegroups.com

Helmut Januschka has uploaded the change for review

Commit message

Replace FWLTHEME color and capacity defines with constexpr

Move the FWL theme color and font size defaults to inline constexpr constants in namespace pdfium. Rename them to kFwlTheme* to follow PDFium naming.
Bug: 42270078
Change-Id: I0b983d71b5535e57c0b55e53d15b3ab4ea7bfdba

Change diff

diff --git a/xfa/fwl/theme/cfwl_checkboxtp.cpp b/xfa/fwl/theme/cfwl_checkboxtp.cpp
index b5cd542..0033120 100644
--- a/xfa/fwl/theme/cfwl_checkboxtp.cpp
+++ b/xfa/fwl/theme/cfwl_checkboxtp.cpp
@@ -43,8 +43,8 @@
void CFWL_CheckBoxTP::DrawText(const CFWL_ThemeText& pParams) {
EnsureTTOInitialized(pParams.GetWidget()->GetThemeProvider());
text_out_->SetTextColor(pParams.states_ & CFWL_PartState::kDisabled
- ? FWLTHEME_CAPACITY_TextDisColor
- : FWLTHEME_CAPACITY_TextColor);
+ ? kFwlThemeTextDisabledColor
+ : kFwlThemeTextColor);
CFWL_WidgetTP::DrawText(pParams);
}

diff --git a/xfa/fwl/theme/cfwl_comboboxtp.cpp b/xfa/fwl/theme/cfwl_comboboxtp.cpp
index b46fb66..a781e51 100644
--- a/xfa/fwl/theme/cfwl_comboboxtp.cpp
+++ b/xfa/fwl/theme/cfwl_comboboxtp.cpp
@@ -31,9 +31,9 @@
path.AddRectangle(rect.left, rect.top, rect.width, rect.height);
FX_ARGB argb_color;
if (pParams.states_ & CFWL_PartState::kSelected) {
- argb_color = FWLTHEME_COLOR_BKSelected;
+ argb_color = kFwlThemeColorBackgroundSelected;
} else if (pParams.states_ & CFWL_PartState::kDisabled) {
- argb_color = FWLTHEME_COLOR_EDGERB1;
+ argb_color = kFwlThemeColorEdgeRb1;
} else {
argb_color = 0xFFFFFFFF;
}
diff --git a/xfa/fwl/theme/cfwl_edittp.cpp b/xfa/fwl/theme/cfwl_edittp.cpp
index 3634f37..6b8e1c9 100644
--- a/xfa/fwl/theme/cfwl_edittp.cpp
+++ b/xfa/fwl/theme/cfwl_edittp.cpp
@@ -30,7 +30,8 @@
CFGAS_GEGraphics::StateRestorer restorer(pGraphics);
const CFGAS_GEPath* pParamsPath = pParams.GetPath();
if (pParamsPath) {
- pGraphics->SetFillColor(CFGAS_GEColor(FWLTHEME_COLOR_BKSelected));
+ pGraphics->SetFillColor(
+ CFGAS_GEColor(kFwlThemeColorBackgroundSelected));
pGraphics->FillPath(*pParamsPath,
CFX_FillRenderOptions::FillType::kWinding,
pParams.matrix_);
@@ -38,10 +39,10 @@
CFGAS_GEPath path;
path.AddRectangle(pParams.part_rect_.left, pParams.part_rect_.top,
pParams.part_rect_.width, pParams.part_rect_.height);
- CFGAS_GEColor cr(FWLTHEME_COLOR_Background);
+ CFGAS_GEColor cr(kFwlThemeColorBackground);
if (!pParams.static_background_) {
if (pParams.states_ & CFWL_PartState::kDisabled) {
- cr = CFGAS_GEColor(FWLTHEME_COLOR_EDGERB1);
+ cr = CFGAS_GEColor(kFwlThemeColorEdgeRb1);
} else if (pParams.states_ & CFWL_PartState::kReadOnly) {
cr = CFGAS_GEColor(ArgbEncode(255, 236, 233, 216));
} else {
diff --git a/xfa/fwl/theme/cfwl_listboxtp.cpp b/xfa/fwl/theme/cfwl_listboxtp.cpp
index 4a085d8..bf1026c 100644
--- a/xfa/fwl/theme/cfwl_listboxtp.cpp
+++ b/xfa/fwl/theme/cfwl_listboxtp.cpp
@@ -30,7 +30,7 @@
FillSolidRect(pParams.GetGraphics(), ArgbEncode(255, 255, 255, 255),
pParams.part_rect_, pParams.matrix_);
if (pParams.data_rect_) {
- FillSolidRect(pParams.GetGraphics(), FWLTHEME_COLOR_Background,
+ FillSolidRect(pParams.GetGraphics(), kFwlThemeColorBackground,
*pParams.data_rect_, pParams.matrix_);
}
break;
@@ -63,7 +63,7 @@
const CFX_Matrix& matrix) {
if (dwStates & CFWL_PartState::kSelected) {
CFGAS_GEGraphics::StateRestorer restorer(pGraphics);
- pGraphics->SetFillColor(CFGAS_GEColor(FWLTHEME_COLOR_BKSelected));
+ pGraphics->SetFillColor(CFGAS_GEColor(kFwlThemeColorBackgroundSelected));
CFGAS_GEPath path;
#if BUILDFLAG(IS_APPLE)
path.AddRectangle(rtItem.left, rtItem.top, rtItem.width - 1,
diff --git a/xfa/fwl/theme/cfwl_utils.h b/xfa/fwl/theme/cfwl_utils.h
index 70c5916..3a8f746 100644
--- a/xfa/fwl/theme/cfwl_utils.h
+++ b/xfa/fwl/theme/cfwl_utils.h
@@ -18,13 +18,16 @@

enum class FWLTHEME_DIRECTION : uint8_t { kUp = 0, kDown, kLeft, kRight };

-#define FWLTHEME_COLOR_EDGERB1 (ArgbEncode(255, 241, 239, 226))
-#define FWLTHEME_COLOR_Background (ArgbEncode(255, 236, 233, 216))
-#define FWLTHEME_COLOR_BKSelected (ArgbEncode(255, 153, 193, 218))
+inline constexpr FX_ARGB kFwlThemeColorEdgeRb1 = ArgbEncode(255, 241, 239, 226);
+inline constexpr FX_ARGB kFwlThemeColorBackground =
+ ArgbEncode(255, 236, 233, 216);
+inline constexpr FX_ARGB kFwlThemeColorBackgroundSelected =
+ ArgbEncode(255, 153, 193, 218);

-#define FWLTHEME_CAPACITY_FontSize 12.0f
-#define FWLTHEME_CAPACITY_TextColor (ArgbEncode(255, 0, 0, 0))
-#define FWLTHEME_CAPACITY_TextDisColor (ArgbEncode(255, 172, 168, 153))
+inline constexpr float kFwlThemeFontSize = 12.0f;
+inline constexpr FX_ARGB kFwlThemeTextColor = ArgbEncode(255, 0, 0, 0);
+inline constexpr FX_ARGB kFwlThemeTextDisabledColor =
+ ArgbEncode(255, 172, 168, 153);

} // namespace pdfium

diff --git a/xfa/fwl/theme/cfwl_widgettp.cpp b/xfa/fwl/theme/cfwl_widgettp.cpp
index ab43f57..80c6fec 100644
--- a/xfa/fwl/theme/cfwl_widgettp.cpp
+++ b/xfa/fwl/theme/cfwl_widgettp.cpp
@@ -79,8 +79,8 @@

text_out_ = std::make_unique<CFDE_TextOut>();
text_out_->SetFont(pProvider->GetFWLFont());
- text_out_->SetFontSize(FWLTHEME_CAPACITY_FontSize);
- text_out_->SetTextColor(FWLTHEME_CAPACITY_TextColor);
+ text_out_->SetFontSize(kFwlThemeFontSize);
+ text_out_->SetTextColor(kFwlThemeTextColor);
}

void CFWL_WidgetTP::DrawBorder(CFGAS_GEGraphics* pGraphics,
@@ -103,7 +103,7 @@
void CFWL_WidgetTP::FillBackground(CFGAS_GEGraphics* pGraphics,
const CFX_RectF& rect,
const CFX_Matrix& matrix) {
- FillSolidRect(pGraphics, FWLTHEME_COLOR_Background, rect, matrix);
+ FillSolidRect(pGraphics, kFwlThemeColorBackground, rect, matrix);
}

void CFWL_WidgetTP::FillSolidRect(CFGAS_GEGraphics* pGraphics,
diff --git a/xfa/fxfa/cxfa_fwltheme.cpp b/xfa/fxfa/cxfa_fwltheme.cpp
index ab253c8..3b5ff1a 100644
--- a/xfa/fxfa/cxfa_fwltheme.cpp
+++ b/xfa/fxfa/cxfa_fwltheme.cpp
@@ -102,8 +102,8 @@
text_out_->SetStyles(pParams.tto_styles_);
text_out_->SetAlignment(pParams.tto_align_);
text_out_->SetFont(calendar_font_);
- text_out_->SetFontSize(FWLTHEME_CAPACITY_FontSize);
- text_out_->SetTextColor(FWLTHEME_CAPACITY_TextColor);
+ text_out_->SetFontSize(kFwlThemeFontSize);
+ text_out_->SetTextColor(kFwlThemeTextColor);
if ((pParams.GetPart() == CFWL_ThemePart::Part::kDatesIn) &&
!(pParams.states_ & CFWL_PartState::kFlagged) &&
(pParams.states_ & Mask<CFWL_PartState>{CFWL_PartState::kHovered,
@@ -190,7 +190,7 @@
if (CXFA_FFWidget* pWidget = GetOutmostFFWidget(pThemePart.GetWidget())) {
return pWidget->GetNode()->GetFontSize();
}
- return FWLTHEME_CAPACITY_FontSize;
+ return kFwlThemeFontSize;
}

RetainPtr<CFGAS_GEFont> CXFA_FWLTheme::GetFont(
@@ -226,7 +226,7 @@
if (CXFA_FFWidget* pWidget = GetOutmostFFWidget(pThemePart.GetWidget())) {
return pWidget->GetNode()->GetTextColor();
}
- return FWLTHEME_CAPACITY_TextColor;
+ return kFwlThemeTextColor;
}

CFX_SizeF CXFA_FWLTheme::GetSpaceAboveBelow(
@@ -251,8 +251,8 @@

if (pParams.GetWidget()->GetClassID() == FWL_Type::MonthCalendar) {
text_out_->SetFont(calendar_font_);
- text_out_->SetFontSize(FWLTHEME_CAPACITY_FontSize);
- text_out_->SetTextColor(FWLTHEME_CAPACITY_TextColor);
+ text_out_->SetFontSize(kFwlThemeFontSize);
+ text_out_->SetTextColor(kFwlThemeTextColor);
text_out_->SetAlignment(pParams.tto_align_);
text_out_->SetStyles(pParams.tto_styles_);
text_out_->CalcLogicSize(pParams.text_.AsStringView(), pRect);

Change information

Files:
  • M xfa/fwl/theme/cfwl_checkboxtp.cpp
  • M xfa/fwl/theme/cfwl_comboboxtp.cpp
  • M xfa/fwl/theme/cfwl_edittp.cpp
  • M xfa/fwl/theme/cfwl_listboxtp.cpp
  • M xfa/fwl/theme/cfwl_utils.h
  • M xfa/fwl/theme/cfwl_widgettp.cpp
  • M xfa/fxfa/cxfa_fwltheme.cpp
Change size: M
Delta: 7 files changed, 28 insertions(+), 24 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: pdfium
Gerrit-Branch: main
Gerrit-Change-Id: I0b983d71b5535e57c0b55e53d15b3ab4ea7bfdba
Gerrit-Change-Number: 148836
Gerrit-PatchSet: 1
Gerrit-Owner: Helmut Januschka <hel...@januschka.com>
unsatisfied_requirement
open
diffy

Aryan Krishnan (Gerrit)

unread,
May 31, 2026, 1:48:10 PM (4 days ago) May 31
to Helmut Januschka, pdfium-...@googlegroups.com
Attention needed from Helmut Januschka

Aryan Krishnan added 1 comment

Commit Message
Line 9, Patchset 1 (Latest):Move the FWL theme color and font size defaults to inline constexpr constants in namespace pdfium. Rename them to kFwlTheme* to follow PDFium naming.
Aryan Krishnan . unresolved

Wrap line 9 :)

Open in Gerrit

Related details

Attention is currently required from:
  • Helmut Januschka
Submit Requirements:
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: pdfium
    Gerrit-Branch: main
    Gerrit-Change-Id: I0b983d71b5535e57c0b55e53d15b3ab4ea7bfdba
    Gerrit-Change-Number: 148836
    Gerrit-PatchSet: 1
    Gerrit-Owner: Helmut Januschka <hel...@januschka.com>
    Gerrit-CC: Aryan Krishnan <aryankr...@gmail.com>
    Gerrit-Attention: Helmut Januschka <hel...@januschka.com>
    Gerrit-Comment-Date: Sun, 31 May 2026 17:48:05 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages