From 0d54f09ae49c0cf85de5fe2bd3da885c16523018 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 21 Nov 2017 16:32:30 +0000 Subject: Convert CXFA_WidgetData methods to Optional This CL converts the CXFA_WidgetData size methods to return Optionals instead of boolean with an out parameter. Change-Id: Ibf2fef5a58896abfea9865e086029377c051bdb6 Reviewed-on: https://pdfium-review.googlesource.com/18892 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- xfa/fxfa/parser/cxfa_widgetdata.cpp | 42 ++++++++++++++++++++++++++----------- xfa/fxfa/parser/cxfa_widgetdata.h | 12 +++++------ 2 files changed, 36 insertions(+), 18 deletions(-) (limited to 'xfa/fxfa/parser') diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp index 72c2d7fd34..3938884d0d 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.cpp +++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp @@ -327,28 +327,46 @@ CXFA_BindData CXFA_WidgetData::GetBindData() { m_pNode->JSNode()->GetProperty(0, XFA_Element::Bind, false)); } -bool CXFA_WidgetData::TryWidth(float& fWidth) { - return TryMeasure(XFA_Attribute::W, fWidth); +pdfium::Optional CXFA_WidgetData::TryWidth() { + float width = 0; + if (TryMeasure(XFA_Attribute::W, width)) + return {width}; + return {}; } -bool CXFA_WidgetData::TryHeight(float& fHeight) { - return TryMeasure(XFA_Attribute::H, fHeight); +pdfium::Optional CXFA_WidgetData::TryHeight() { + float height = 0; + if (TryMeasure(XFA_Attribute::H, height)) + return {height}; + return {}; } -bool CXFA_WidgetData::TryMinWidth(float& fMinWidth) { - return TryMeasure(XFA_Attribute::MinW, fMinWidth); +pdfium::Optional CXFA_WidgetData::TryMinWidth() { + float minWidth = 0; + if (TryMeasure(XFA_Attribute::MinW, minWidth)) + return {minWidth}; + return {}; } -bool CXFA_WidgetData::TryMinHeight(float& fMinHeight) { - return TryMeasure(XFA_Attribute::MinH, fMinHeight); +pdfium::Optional CXFA_WidgetData::TryMinHeight() { + float minHeight = 0; + if (TryMeasure(XFA_Attribute::MinH, minHeight)) + return {minHeight}; + return {}; } -bool CXFA_WidgetData::TryMaxWidth(float& fMaxWidth) { - return TryMeasure(XFA_Attribute::MaxW, fMaxWidth); +pdfium::Optional CXFA_WidgetData::TryMaxWidth() { + float maxWidth = 0; + if (TryMeasure(XFA_Attribute::MaxW, maxWidth)) + return {maxWidth}; + return {}; } -bool CXFA_WidgetData::TryMaxHeight(float& fMaxHeight) { - return TryMeasure(XFA_Attribute::MaxH, fMaxHeight); +pdfium::Optional CXFA_WidgetData::TryMaxHeight() { + float maxHeight = 0; + if (TryMeasure(XFA_Attribute::MaxH, maxHeight)) + return {maxHeight}; + return {}; } CXFA_BorderData CXFA_WidgetData::GetUIBorderData() { diff --git a/xfa/fxfa/parser/cxfa_widgetdata.h b/xfa/fxfa/parser/cxfa_widgetdata.h index 9d955a3d99..309f00fe12 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.h +++ b/xfa/fxfa/parser/cxfa_widgetdata.h @@ -61,12 +61,12 @@ class CXFA_WidgetData : public CXFA_DataData { CXFA_CalculateData GetCalculateData(); CXFA_ValidateData GetValidateData(bool bModified); - bool TryWidth(float& fWidth); - bool TryHeight(float& fHeight); - bool TryMinWidth(float& fMinWidth); - bool TryMinHeight(float& fMinHeight); - bool TryMaxWidth(float& fMaxWidth); - bool TryMaxHeight(float& fMaxHeight); + pdfium::Optional TryWidth(); + pdfium::Optional TryHeight(); + pdfium::Optional TryMinWidth(); + pdfium::Optional TryMinHeight(); + pdfium::Optional TryMaxWidth(); + pdfium::Optional TryMaxHeight(); CXFA_BorderData GetUIBorderData(); CFX_RectF GetUIMargin(); -- cgit v1.2.3