From 000b95b3c9dd7c7fbfbd6359404a09dfdc2d5226 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 21 Nov 2017 16:36:40 +0000 Subject: Rename CXFA_DataData::TryMeasure This CL renames CXFA_DataData::TryMeasure to TryMeasureAsFloat and changes to return an Optional instead of a bool with an out-param. Change-Id: I5adb75e3b8a2fb19330b33c90111f59f8c8cf722 Reviewed-on: https://pdfium-review.googlesource.com/18910 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- xfa/fxfa/parser/cxfa_datadata.cpp | 15 ++++++--------- xfa/fxfa/parser/cxfa_datadata.h | 4 +--- xfa/fxfa/parser/cxfa_margindata.cpp | 20 ++++---------------- xfa/fxfa/parser/cxfa_widgetdata.cpp | 30 ++++++------------------------ 4 files changed, 17 insertions(+), 52 deletions(-) diff --git a/xfa/fxfa/parser/cxfa_datadata.cpp b/xfa/fxfa/parser/cxfa_datadata.cpp index 28bb0a8b02..8429dd4e5e 100644 --- a/xfa/fxfa/parser/cxfa_datadata.cpp +++ b/xfa/fxfa/parser/cxfa_datadata.cpp @@ -69,14 +69,11 @@ XFA_Element CXFA_DataData::GetElementType() const { return m_pNode ? m_pNode->GetElementType() : XFA_Element::Unknown; } -bool CXFA_DataData::TryMeasure(XFA_Attribute eAttr, - float& fValue, - bool bUseDefault) const { +pdfium::Optional CXFA_DataData::TryMeasureAsFloat( + XFA_Attribute attr) const { pdfium::Optional measure = - m_pNode->JSNode()->TryMeasure(eAttr, bUseDefault); - if (!measure) - return false; - - fValue = measure->ToUnit(XFA_Unit::Pt); - return true; + m_pNode->JSNode()->TryMeasure(attr, false); + if (measure) + return {measure->ToUnit(XFA_Unit::Pt)}; + return {}; } diff --git a/xfa/fxfa/parser/cxfa_datadata.h b/xfa/fxfa/parser/cxfa_datadata.h index ff5aa2a3cf..a77e4512cb 100644 --- a/xfa/fxfa/parser/cxfa_datadata.h +++ b/xfa/fxfa/parser/cxfa_datadata.h @@ -25,9 +25,7 @@ class CXFA_DataData { XFA_Element GetElementType() const; protected: - bool TryMeasure(XFA_Attribute eAttr, - float& fValue, - bool bUseDefault = false) const; + pdfium::Optional TryMeasureAsFloat(XFA_Attribute attr) const; CXFA_Node* m_pNode; }; diff --git a/xfa/fxfa/parser/cxfa_margindata.cpp b/xfa/fxfa/parser/cxfa_margindata.cpp index 3af8352263..c8baf2d05a 100644 --- a/xfa/fxfa/parser/cxfa_margindata.cpp +++ b/xfa/fxfa/parser/cxfa_margindata.cpp @@ -25,29 +25,17 @@ float CXFA_MarginData::GetBottomInset() const { } pdfium::Optional CXFA_MarginData::TryLeftInset() const { - float value = 0; - if (TryMeasure(XFA_Attribute::LeftInset, value)) - return {value}; - return {}; + return TryMeasureAsFloat(XFA_Attribute::LeftInset); } pdfium::Optional CXFA_MarginData::TryTopInset() const { - float value = 0; - if (TryMeasure(XFA_Attribute::TopInset, value)) - return {value}; - return {}; + return TryMeasureAsFloat(XFA_Attribute::TopInset); } pdfium::Optional CXFA_MarginData::TryRightInset() const { - float value = 0; - if (TryMeasure(XFA_Attribute::RightInset, value)) - return {value}; - return {}; + return TryMeasureAsFloat(XFA_Attribute::RightInset); } pdfium::Optional CXFA_MarginData::TryBottomInset() const { - float value = 0; - if (TryMeasure(XFA_Attribute::BottomInset, value)) - return {value}; - return {}; + return TryMeasureAsFloat(XFA_Attribute::BottomInset); } diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp index 3938884d0d..d0efce71a0 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.cpp +++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp @@ -328,45 +328,27 @@ CXFA_BindData CXFA_WidgetData::GetBindData() { } pdfium::Optional CXFA_WidgetData::TryWidth() { - float width = 0; - if (TryMeasure(XFA_Attribute::W, width)) - return {width}; - return {}; + return TryMeasureAsFloat(XFA_Attribute::W); } pdfium::Optional CXFA_WidgetData::TryHeight() { - float height = 0; - if (TryMeasure(XFA_Attribute::H, height)) - return {height}; - return {}; + return TryMeasureAsFloat(XFA_Attribute::H); } pdfium::Optional CXFA_WidgetData::TryMinWidth() { - float minWidth = 0; - if (TryMeasure(XFA_Attribute::MinW, minWidth)) - return {minWidth}; - return {}; + return TryMeasureAsFloat(XFA_Attribute::MinW); } pdfium::Optional CXFA_WidgetData::TryMinHeight() { - float minHeight = 0; - if (TryMeasure(XFA_Attribute::MinH, minHeight)) - return {minHeight}; - return {}; + return TryMeasureAsFloat(XFA_Attribute::MinH); } pdfium::Optional CXFA_WidgetData::TryMaxWidth() { - float maxWidth = 0; - if (TryMeasure(XFA_Attribute::MaxW, maxWidth)) - return {maxWidth}; - return {}; + return TryMeasureAsFloat(XFA_Attribute::MaxW); } pdfium::Optional CXFA_WidgetData::TryMaxHeight() { - float maxHeight = 0; - if (TryMeasure(XFA_Attribute::MaxH, maxHeight)) - return {maxHeight}; - return {}; + return TryMeasureAsFloat(XFA_Attribute::MaxH); } CXFA_BorderData CXFA_WidgetData::GetUIBorderData() { -- cgit v1.2.3