const-qualify more xfa object methods
As enabled by the newly-added const GetChild<>() method.
Change-Id: I8900eb1eb7388048e6113826e50725057c21d725
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/84514
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/xfa/fxfa/parser/cxfa_bind.cpp b/xfa/fxfa/parser/cxfa_bind.cpp
index 1ec5f20..fca2067 100644
--- a/xfa/fxfa/parser/cxfa_bind.cpp
+++ b/xfa/fxfa/parser/cxfa_bind.cpp
@@ -47,8 +47,7 @@
CXFA_Bind::~CXFA_Bind() = default;
-WideString CXFA_Bind::GetPicture() {
- CXFA_Picture* pPicture =
- GetChild<CXFA_Picture>(0, XFA_Element::Picture, false);
+WideString CXFA_Bind::GetPicture() const {
+ const auto* pPicture = GetChild<CXFA_Picture>(0, XFA_Element::Picture, false);
return pPicture ? pPicture->JSObject()->GetContent(false) : WideString();
}
diff --git a/xfa/fxfa/parser/cxfa_bind.h b/xfa/fxfa/parser/cxfa_bind.h
index 7045c88..a957d19 100644
--- a/xfa/fxfa/parser/cxfa_bind.h
+++ b/xfa/fxfa/parser/cxfa_bind.h
@@ -14,7 +14,7 @@
CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
~CXFA_Bind() override;
- WideString GetPicture();
+ WideString GetPicture() const;
private:
CXFA_Bind(CXFA_Document* doc, XFA_PacketType packet);
diff --git a/xfa/fxfa/parser/cxfa_calculate.cpp b/xfa/fxfa/parser/cxfa_calculate.cpp
index d3a2767..9fb55ba 100644
--- a/xfa/fxfa/parser/cxfa_calculate.cpp
+++ b/xfa/fxfa/parser/cxfa_calculate.cpp
@@ -54,11 +54,11 @@
return GetChild<CXFA_Script>(0, XFA_Element::Script, false);
}
-WideString CXFA_Calculate::GetMessageText() {
- CXFA_Message* pNode = GetChild<CXFA_Message>(0, XFA_Element::Message, false);
+WideString CXFA_Calculate::GetMessageText() const {
+ const auto* pNode = GetChild<CXFA_Message>(0, XFA_Element::Message, false);
if (!pNode)
return WideString();
- CXFA_Text* text = pNode->GetChild<CXFA_Text>(0, XFA_Element::Text, false);
+ const auto* text = pNode->GetChild<CXFA_Text>(0, XFA_Element::Text, false);
return text ? text->GetContent() : WideString();
}
diff --git a/xfa/fxfa/parser/cxfa_calculate.h b/xfa/fxfa/parser/cxfa_calculate.h
index 34a4e58..2354a69 100644
--- a/xfa/fxfa/parser/cxfa_calculate.h
+++ b/xfa/fxfa/parser/cxfa_calculate.h
@@ -18,7 +18,7 @@
XFA_AttributeValue GetOverride();
CXFA_Script* GetScriptIfExists();
- WideString GetMessageText();
+ WideString GetMessageText() const;
private:
CXFA_Calculate(CXFA_Document* doc, XFA_PacketType packet);
diff --git a/xfa/fxfa/parser/cxfa_font.cpp b/xfa/fxfa/parser/cxfa_font.cpp
index 8952639..4e3d48b 100644
--- a/xfa/fxfa/parser/cxfa_font.cpp
+++ b/xfa/fxfa/parser/cxfa_font.cpp
@@ -132,7 +132,7 @@
node->SetColor(color);
}
-FX_ARGB CXFA_Font::GetColor() {
- CXFA_Fill* fill = GetChild<CXFA_Fill>(0, XFA_Element::Fill, false);
+FX_ARGB CXFA_Font::GetColor() const {
+ const auto* fill = GetChild<CXFA_Fill>(0, XFA_Element::Fill, false);
return fill ? fill->GetTextColor() : 0xFF000000;
}
diff --git a/xfa/fxfa/parser/cxfa_font.h b/xfa/fxfa/parser/cxfa_font.h
index 1f9fa4e..04cddbb 100644
--- a/xfa/fxfa/parser/cxfa_font.h
+++ b/xfa/fxfa/parser/cxfa_font.h
@@ -28,7 +28,7 @@
bool IsBold();
bool IsItalic();
- FX_ARGB GetColor();
+ FX_ARGB GetColor() const;
void SetColor(FX_ARGB color);
private:
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 5b7fddf..0c74f00 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -2228,7 +2228,7 @@
JSObject()->SetContent(wsValue, wsFormatValue, bNotify, false, true);
}
-WideString CXFA_Node::GetRawValue() {
+WideString CXFA_Node::GetRawValue() const {
return JSObject()->GetContent(false);
}
@@ -3930,8 +3930,8 @@
dwFontStyle);
}
-bool CXFA_Node::HasButtonRollover() {
- CXFA_Items* pItems = GetChild<CXFA_Items>(0, XFA_Element::Items, false);
+bool CXFA_Node::HasButtonRollover() const {
+ const auto* pItems = GetChild<CXFA_Items>(0, XFA_Element::Items, false);
if (!pItems)
return false;
@@ -3946,8 +3946,8 @@
return false;
}
-bool CXFA_Node::HasButtonDown() {
- CXFA_Items* pItems = GetChild<CXFA_Items>(0, XFA_Element::Items, false);
+bool CXFA_Node::HasButtonDown() const {
+ const auto* pItems = GetChild<CXFA_Items>(0, XFA_Element::Items, false);
if (!pItems)
return false;
@@ -4612,8 +4612,9 @@
return pUIChild && pUIChild->JSObject()->GetBoolean(XFA_Attribute::MultiLine);
}
-std::pair<XFA_Element, int32_t> CXFA_Node::GetMaxChars() {
- if (CXFA_Value* pNode = GetChild<CXFA_Value>(0, XFA_Element::Value, false)) {
+std::pair<XFA_Element, int32_t> CXFA_Node::GetMaxChars() const {
+ const auto* pNode = GetChild<CXFA_Value>(0, XFA_Element::Value, false);
+ if (pNode) {
if (CXFA_Node* pChild = pNode->GetFirstChild()) {
switch (pChild->GetElementType()) {
case XFA_Element::Text:
@@ -4632,12 +4633,12 @@
return {XFA_Element::Unknown, 0};
}
-int32_t CXFA_Node::GetFracDigits() {
- CXFA_Value* pNode = GetChild<CXFA_Value>(0, XFA_Element::Value, false);
+int32_t CXFA_Node::GetFracDigits() const {
+ const auto* pNode = GetChild<CXFA_Value>(0, XFA_Element::Value, false);
if (!pNode)
return -1;
- CXFA_Decimal* pChild =
+ const auto* pChild =
pNode->GetChild<CXFA_Decimal>(0, XFA_Element::Decimal, false);
if (!pChild)
return -1;
@@ -4647,12 +4648,12 @@
.value_or(-1);
}
-int32_t CXFA_Node::GetLeadDigits() {
- CXFA_Value* pNode = GetChild<CXFA_Value>(0, XFA_Element::Value, false);
+int32_t CXFA_Node::GetLeadDigits() const {
+ const auto* pNode = GetChild<CXFA_Value>(0, XFA_Element::Value, false);
if (!pNode)
return -1;
- CXFA_Decimal* pChild =
+ const auto* pChild =
pNode->GetChild<CXFA_Decimal>(0, XFA_Element::Decimal, false);
if (!pChild)
return -1;
@@ -4715,10 +4716,11 @@
CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this);
switch (ePicture) {
case XFA_ValuePicture::kDisplay: {
- if (CXFA_Format* pFormat =
- GetChild<CXFA_Format>(0, XFA_Element::Format, false)) {
- if (CXFA_Picture* pPicture = pFormat->GetChild<CXFA_Picture>(
- 0, XFA_Element::Picture, false)) {
+ auto* pFormat = GetChild<CXFA_Format>(0, XFA_Element::Format, false);
+ if (pFormat) {
+ auto* pPicture =
+ pFormat->GetChild<CXFA_Picture>(0, XFA_Element::Picture, false);
+ if (pPicture) {
Optional<WideString> picture =
pPicture->JSObject()->TryContent(false, true);
if (picture.has_value())
diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h
index d7dd9c0..c452771 100644
--- a/xfa/fxfa/parser/cxfa_node.h
+++ b/xfa/fxfa/parser/cxfa_node.h
@@ -276,7 +276,7 @@
CXFA_Validate* GetOrCreateValidateIfPossible();
CXFA_Value* GetFormValueIfExists() const;
- WideString GetRawValue();
+ WideString GetRawValue() const;
int32_t GetRotate() const;
Optional<float> TryWidth();
@@ -342,8 +342,8 @@
bool IsRadioButton();
bool IsMultiLine();
- bool HasButtonRollover();
- bool HasButtonDown();
+ bool HasButtonRollover() const;
+ bool HasButtonDown() const;
float GetCheckButtonSize();
@@ -401,9 +401,9 @@
WideString GetFormatDataValue(const WideString& wsValue);
WideString NormalizeNumStr(const WideString& wsValue);
- std::pair<XFA_Element, int32_t> GetMaxChars();
- int32_t GetFracDigits();
- int32_t GetLeadDigits();
+ std::pair<XFA_Element, int32_t> GetMaxChars() const;
+ int32_t GetFracDigits() const;
+ int32_t GetLeadDigits() const;
WideString NumericLimit(const WideString& wsValue);
diff --git a/xfa/fxfa/parser/cxfa_stroke.cpp b/xfa/fxfa/parser/cxfa_stroke.cpp
index 605390e..fe29a97 100644
--- a/xfa/fxfa/parser/cxfa_stroke.cpp
+++ b/xfa/fxfa/parser/cxfa_stroke.cpp
@@ -110,8 +110,8 @@
JSObject()->SetMeasure(XFA_Attribute::Thickness, msThinkness, false);
}
-FX_ARGB CXFA_Stroke::GetColor() {
- CXFA_Color* pNode = GetChild<CXFA_Color>(0, XFA_Element::Color, false);
+FX_ARGB CXFA_Stroke::GetColor() const {
+ const auto* pNode = GetChild<CXFA_Color>(0, XFA_Element::Color, false);
if (!pNode)
return 0xFF000000;
diff --git a/xfa/fxfa/parser/cxfa_stroke.h b/xfa/fxfa/parser/cxfa_stroke.h
index 33e1b55..86fede9 100644
--- a/xfa/fxfa/parser/cxfa_stroke.h
+++ b/xfa/fxfa/parser/cxfa_stroke.h
@@ -42,7 +42,7 @@
CXFA_Measurement GetMSThickness() const;
void SetMSThickness(CXFA_Measurement msThinkness);
- FX_ARGB GetColor();
+ FX_ARGB GetColor() const;
void SetColor(FX_ARGB argb);
bool SameStyles(CXFA_Stroke* stroke, Mask<SameStyleOption> dwFlags);
diff --git a/xfa/fxfa/parser/cxfa_text.cpp b/xfa/fxfa/parser/cxfa_text.cpp
index 3e51a21..e10f853 100644
--- a/xfa/fxfa/parser/cxfa_text.cpp
+++ b/xfa/fxfa/parser/cxfa_text.cpp
@@ -37,6 +37,6 @@
CXFA_Text::~CXFA_Text() = default;
-WideString CXFA_Text::GetContent() {
+WideString CXFA_Text::GetContent() const {
return JSObject()->GetContent(false);
}
diff --git a/xfa/fxfa/parser/cxfa_text.h b/xfa/fxfa/parser/cxfa_text.h
index 705c14c..33c1845 100644
--- a/xfa/fxfa/parser/cxfa_text.h
+++ b/xfa/fxfa/parser/cxfa_text.h
@@ -15,7 +15,7 @@
CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
~CXFA_Text() override;
- WideString GetContent();
+ WideString GetContent() const;
private:
CXFA_Text(CXFA_Document* doc, XFA_PacketType packet);
diff --git a/xfa/fxfa/parser/cxfa_validate.cpp b/xfa/fxfa/parser/cxfa_validate.cpp
index 786ef39..3cd3aba 100644
--- a/xfa/fxfa/parser/cxfa_validate.cpp
+++ b/xfa/fxfa/parser/cxfa_validate.cpp
@@ -145,8 +145,8 @@
pTextNode->JSObject()->SetContent(wsMessage, wsMessage, false, false, true);
}
-WideString CXFA_Validate::GetPicture() {
- CXFA_Picture* pNode = GetChild<CXFA_Picture>(0, XFA_Element::Picture, false);
+WideString CXFA_Validate::GetPicture() const {
+ const auto* pNode = GetChild<CXFA_Picture>(0, XFA_Element::Picture, false);
return pNode ? pNode->JSObject()->GetContent(false) : WideString();
}
diff --git a/xfa/fxfa/parser/cxfa_validate.h b/xfa/fxfa/parser/cxfa_validate.h
index 8fdf5dd..f793196 100644
--- a/xfa/fxfa/parser/cxfa_validate.h
+++ b/xfa/fxfa/parser/cxfa_validate.h
@@ -30,7 +30,7 @@
WideString GetScriptMessageText();
void SetScriptMessageText(const WideString& wsMessage);
- WideString GetPicture();
+ WideString GetPicture() const;
CXFA_Script* GetScriptIfExists();
private:
diff --git a/xfa/fxfa/parser/xfa_utils.cpp b/xfa/fxfa/parser/xfa_utils.cpp
index 138a13b..6541e63 100644
--- a/xfa/fxfa/parser/xfa_utils.cpp
+++ b/xfa/fxfa/parser/xfa_utils.cpp
@@ -363,8 +363,8 @@
} // namespace
-CXFA_LocaleValue XFA_GetLocaleValue(CXFA_Node* pNode) {
- CXFA_Value* pNodeValue =
+CXFA_LocaleValue XFA_GetLocaleValue(const CXFA_Node* pNode) {
+ const auto* pNodeValue =
pNode->GetChild<CXFA_Value>(0, XFA_Element::Value, false);
if (!pNodeValue)
return CXFA_LocaleValue();
@@ -478,11 +478,12 @@
}
}
-bool XFA_FieldIsMultiListBox(CXFA_Node* pFieldNode) {
+bool XFA_FieldIsMultiListBox(const CXFA_Node* pFieldNode) {
if (!pFieldNode)
return false;
- CXFA_Ui* pUIChild = pFieldNode->GetChild<CXFA_Ui>(0, XFA_Element::Ui, false);
+ const auto* pUIChild =
+ pFieldNode->GetChild<CXFA_Ui>(0, XFA_Element::Ui, false);
if (!pUIChild)
return false;
diff --git a/xfa/fxfa/parser/xfa_utils.h b/xfa/fxfa/parser/xfa_utils.h
index 59cef0f..b684dd6 100644
--- a/xfa/fxfa/parser/xfa_utils.h
+++ b/xfa/fxfa/parser/xfa_utils.h
@@ -21,12 +21,12 @@
const WideString& wsQualifier,
WideString* wsNamespaceURI);
-CXFA_LocaleValue XFA_GetLocaleValue(CXFA_Node* pNode);
+CXFA_LocaleValue XFA_GetLocaleValue(const CXFA_Node* pNode);
CXFA_LocaleValue::ValueType XFA_GetLocaleValueType(XFA_Element element);
int32_t XFA_MapRotation(int32_t nRotation);
bool XFA_RecognizeRichText(CFX_XMLElement* pRichTextXMLNode);
-bool XFA_FieldIsMultiListBox(CXFA_Node* pFieldNode);
+bool XFA_FieldIsMultiListBox(const CXFA_Node* pFieldNode);
void XFA_DataExporter_DealWithDataGroupNode(CXFA_Node* pDataNode);
void XFA_DataExporter_RegenerateFormFile(