summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_value.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-01-16 15:49:16 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-01-16 15:49:16 +0000
commit316dd2fcd64d0cda1e1b2cdc39ca541a57766b35 (patch)
treeaf3745a818839a7cebc92927f9e115c429bbbe0b /xfa/fxfa/parser/cxfa_value.cpp
parentd021ad2f6306ae9d7b2ab5acf225c3bd8e957f8f (diff)
downloadpdfium-316dd2fcd64d0cda1e1b2cdc39ca541a57766b35.tar.xz
Rename CXFA_Value methods for clarity
This CL marks the methods in CXFA_Value to make it clear which can return nullptr and updates callsites as needed. Change-Id: If1f794bcbbddaa57a1efdd67195df58a77b4373a Reviewed-on: https://pdfium-review.googlesource.com/22773 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cxfa_value.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_value.cpp40
1 files changed, 25 insertions, 15 deletions
diff --git a/xfa/fxfa/parser/cxfa_value.cpp b/xfa/fxfa/parser/cxfa_value.cpp
index dc93bba25c..7a952f7df3 100644
--- a/xfa/fxfa/parser/cxfa_value.cpp
+++ b/xfa/fxfa/parser/cxfa_value.cpp
@@ -63,31 +63,41 @@ XFA_Element CXFA_Value::GetChildValueClassID() const {
WideString CXFA_Value::GetChildValueContent() const {
CXFA_Node* pNode = GetFirstChild();
- if (!pNode)
- return L"";
- return pNode->JSObject()->TryContent(false, true).value_or(L"");
+ return pNode ? pNode->JSObject()->TryContent(false, true).value_or(L"") : L"";
}
-CXFA_Arc* CXFA_Value::GetArc() const {
- return static_cast<CXFA_Arc*>(GetFirstChild());
+CXFA_Arc* CXFA_Value::GetArcIfExists() const {
+ CXFA_Node* node = GetFirstChild();
+ ASSERT(!node || node->GetElementType() == XFA_Element::Arc);
+ return static_cast<CXFA_Arc*>(node);
}
-CXFA_Line* CXFA_Value::GetLine() const {
- return static_cast<CXFA_Line*>(GetFirstChild());
+CXFA_Line* CXFA_Value::GetLineIfExists() const {
+ CXFA_Node* node = GetFirstChild();
+ ASSERT(!node || node->GetElementType() == XFA_Element::Line);
+ return static_cast<CXFA_Line*>(node);
}
-CXFA_Rectangle* CXFA_Value::GetRectangle() const {
- return static_cast<CXFA_Rectangle*>(GetFirstChild());
+CXFA_Rectangle* CXFA_Value::GetRectangleIfExists() const {
+ CXFA_Node* node = GetFirstChild();
+ ASSERT(!node || node->GetElementType() == XFA_Element::Rectangle);
+ return static_cast<CXFA_Rectangle*>(node);
}
-CXFA_Text* CXFA_Value::GetText() const {
- return static_cast<CXFA_Text*>(GetFirstChild());
+CXFA_Text* CXFA_Value::GetTextIfExists() const {
+ CXFA_Node* node = GetFirstChild();
+ ASSERT(!node || node->GetElementType() == XFA_Element::Text);
+ return static_cast<CXFA_Text*>(node);
}
-CXFA_ExData* CXFA_Value::GetExData() const {
- return static_cast<CXFA_ExData*>(GetFirstChild());
+CXFA_ExData* CXFA_Value::GetExDataIfExists() const {
+ CXFA_Node* node = GetFirstChild();
+ ASSERT(!node || node->GetElementType() == XFA_Element::ExData);
+ return static_cast<CXFA_ExData*>(node);
}
-CXFA_Image* CXFA_Value::GetImage() const {
- return static_cast<CXFA_Image*>(GetFirstChild());
+CXFA_Image* CXFA_Value::GetImageIfExists() const {
+ CXFA_Node* node = GetFirstChild();
+ ASSERT(!node || node->GetElementType() == XFA_Element::Image);
+ return static_cast<CXFA_Image*>(node);
}