From 9d47de6b27b167db46b6aba38352fc42a8b6adae Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 16 Nov 2017 14:07:17 +0000 Subject: Convert TryEnum to return an optional This CL converts CJX_Node::TryEnum to return a pdfium::Optional instead of a bool with an out parameter. Change-Id: Icc1b063ce51656cc5e467aba358eb9e7d6754fea Reviewed-on: https://pdfium-review.googlesource.com/18512 Commit-Queue: dsinclair Reviewed-by: Tom Sepez --- xfa/fxfa/parser/cxfa_fontdata.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'xfa/fxfa/parser/cxfa_fontdata.cpp') diff --git a/xfa/fxfa/parser/cxfa_fontdata.cpp b/xfa/fxfa/parser/cxfa_fontdata.cpp index f5600f24df..5ca845f056 100644 --- a/xfa/fxfa/parser/cxfa_fontdata.cpp +++ b/xfa/fxfa/parser/cxfa_fontdata.cpp @@ -51,9 +51,9 @@ int32_t CXFA_FontData::GetUnderline() { } int32_t CXFA_FontData::GetUnderlinePeriod() { - XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_All; - m_pNode->JSNode()->TryEnum(XFA_Attribute::UnderlinePeriod, eAttr, true); - return eAttr; + return m_pNode->JSNode() + ->TryEnum(XFA_Attribute::UnderlinePeriod, true) + .value_or(XFA_ATTRIBUTEENUM_All); } float CXFA_FontData::GetFontSize() { @@ -67,15 +67,13 @@ void CXFA_FontData::GetTypeface(WideString& wsTypeFace) { } bool CXFA_FontData::IsBold() { - XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Normal; - m_pNode->JSNode()->TryEnum(XFA_Attribute::Weight, eAttr, true); - return eAttr == XFA_ATTRIBUTEENUM_Bold; + return m_pNode->JSNode()->GetEnum(XFA_Attribute::Weight) == + XFA_ATTRIBUTEENUM_Bold; } bool CXFA_FontData::IsItalic() { - XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Normal; - m_pNode->JSNode()->TryEnum(XFA_Attribute::Posture, eAttr, true); - return eAttr == XFA_ATTRIBUTEENUM_Italic; + return m_pNode->JSNode()->GetEnum(XFA_Attribute::Posture) == + XFA_ATTRIBUTEENUM_Italic; } void CXFA_FontData::SetColor(FX_ARGB color) { -- cgit v1.2.3