From ebbc08b858b4bb3e0a2cb69eb43c51b740515b9a Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 29 Nov 2017 19:50:09 +0000 Subject: Remove XFA_Unit::Angle We never use the ::Angle unit internally, we just access the value. This CL changes the default value to an Integer and drops the measurement. Change-Id: I85d6d84956595bb0576db42d287f54a5a3db1bed Reviewed-on: https://pdfium-review.googlesource.com/19790 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- xfa/fxfa/cxfa_ffwidget.cpp | 4 ++-- xfa/fxfa/fxfa_basic.h | 1 - xfa/fxfa/parser/cxfa_boxdata.cpp | 18 ++++-------------- xfa/fxfa/parser/cxfa_boxdata.h | 4 ++-- xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp | 10 ++++------ xfa/fxfa/parser/cxfa_measurement.cpp | 2 -- xfa/fxfa/parser/cxfa_widgetdata.cpp | 11 +++-------- xfa/fxfa/parser/xfa_basic_data_attributes.cpp | 12 ++++++------ 8 files changed, 21 insertions(+), 41 deletions(-) (limited to 'xfa/fxfa') diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp index a34e67ae9d..439b45be4d 100644 --- a/xfa/fxfa/cxfa_ffwidget.cpp +++ b/xfa/fxfa/cxfa_ffwidget.cpp @@ -55,8 +55,8 @@ void XFA_BOX_GetPath_Arc(const CXFA_BoxData& boxData, rtDraw.top = center.y - b; rtDraw.width = a + a; rtDraw.height = b + b; - pdfium::Optional startAngle = boxData.GetStartAngle(); - pdfium::Optional sweepAngle = boxData.GetSweepAngle(); + pdfium::Optional startAngle = boxData.GetStartAngle(); + pdfium::Optional sweepAngle = boxData.GetSweepAngle(); if (!startAngle && !sweepAngle) { fillPath.AddEllipse(rtDraw); return; diff --git a/xfa/fxfa/fxfa_basic.h b/xfa/fxfa/fxfa_basic.h index cdd53a965b..65bd8e3b92 100644 --- a/xfa/fxfa/fxfa_basic.h +++ b/xfa/fxfa/fxfa_basic.h @@ -976,7 +976,6 @@ struct XFA_ATTRIBUTEENUMINFO { enum class XFA_Unit : uint8_t { Percent = 0, - Angle, Em, Pt, In, diff --git a/xfa/fxfa/parser/cxfa_boxdata.cpp b/xfa/fxfa/parser/cxfa_boxdata.cpp index ef9864f6f9..ae172de5b1 100644 --- a/xfa/fxfa/parser/cxfa_boxdata.cpp +++ b/xfa/fxfa/parser/cxfa_boxdata.cpp @@ -109,26 +109,16 @@ bool CXFA_BoxData::IsCircular() const { return m_pNode->JSNode()->GetBoolean(XFA_Attribute::Circular); } -pdfium::Optional CXFA_BoxData::GetStartAngle() const { +pdfium::Optional CXFA_BoxData::GetStartAngle() const { if (!m_pNode) return {}; - - pdfium::Optional measure = - m_pNode->JSNode()->TryMeasure(XFA_Attribute::StartAngle, false); - if (!measure) - return {}; - return {measure->GetValue()}; + return m_pNode->JSNode()->TryInteger(XFA_Attribute::StartAngle, false); } -pdfium::Optional CXFA_BoxData::GetSweepAngle() const { +pdfium::Optional CXFA_BoxData::GetSweepAngle() const { if (!m_pNode) return {}; - - pdfium::Optional measure = - m_pNode->JSNode()->TryMeasure(XFA_Attribute::SweepAngle, false); - if (!measure) - return {}; - return {measure->GetValue()}; + return m_pNode->JSNode()->TryInteger(XFA_Attribute::SweepAngle, false); } CXFA_FillData CXFA_BoxData::GetFillData(bool bModified) const { diff --git a/xfa/fxfa/parser/cxfa_boxdata.h b/xfa/fxfa/parser/cxfa_boxdata.h index af92725ab2..7fd6869f2f 100644 --- a/xfa/fxfa/parser/cxfa_boxdata.h +++ b/xfa/fxfa/parser/cxfa_boxdata.h @@ -36,8 +36,8 @@ class CXFA_BoxData : public CXFA_DataData { std::vector GetStrokes() const; - pdfium::Optional GetStartAngle() const; - pdfium::Optional GetSweepAngle() const; + pdfium::Optional GetStartAngle() const; + pdfium::Optional GetSweepAngle() const; }; #endif // XFA_FXFA_PARSER_CXFA_BOXDATA_H_ diff --git a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp index ec610293ce..8fe36b0bbf 100644 --- a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp +++ b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp @@ -1103,9 +1103,8 @@ CFX_PointF CalculatePositionedContainerPos(CXFA_Node* pNode, CFX_PointF pos( pNode->JSNode()->GetMeasure(XFA_Attribute::X).ToUnit(XFA_Unit::Pt), pNode->JSNode()->GetMeasure(XFA_Attribute::Y).ToUnit(XFA_Unit::Pt)); - int32_t nRotate = FXSYS_round( - pNode->JSNode()->GetMeasure(XFA_Attribute::Rotate).GetValue()); - nRotate = XFA_MapRotation(nRotate) / 90; + int32_t nRotate = + XFA_MapRotation(pNode->JSNode()->GetInteger(XFA_Attribute::Rotate)) / 90; int32_t nAbsoluteAnchorType = nNextPos[nRotate][nAnchorType]; switch (nAbsoluteAnchorType / 3) { case 1: @@ -2758,9 +2757,8 @@ void CXFA_ItemLayoutProcessor::DoLayoutField() { CFX_SizeF size(-1, -1); pNotify->StartFieldDrawLayout(m_pFormNode, size.width, size.height); - int32_t nRotate = FXSYS_round( - m_pFormNode->JSNode()->GetMeasure(XFA_Attribute::Rotate).GetValue()); - nRotate = XFA_MapRotation(nRotate); + int32_t nRotate = + XFA_MapRotation(m_pFormNode->JSNode()->GetInteger(XFA_Attribute::Rotate)); if (nRotate == 90 || nRotate == 270) std::swap(size.width, size.height); diff --git a/xfa/fxfa/parser/cxfa_measurement.cpp b/xfa/fxfa/parser/cxfa_measurement.cpp index a929f701be..d0534c92dc 100644 --- a/xfa/fxfa/parser/cxfa_measurement.cpp +++ b/xfa/fxfa/parser/cxfa_measurement.cpp @@ -143,8 +143,6 @@ XFA_Unit CXFA_Measurement::GetUnitFromString(const WideStringView& wsUnit) { return XFA_Unit::Mp; if (wsUnit == L"em") return XFA_Unit::Em; - if (wsUnit == L"an") - return XFA_Unit::Angle; if (wsUnit == L"%") return XFA_Unit::Percent; return XFA_Unit::Unknown; diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp index 4c8257a039..520a559bb4 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.cpp +++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp @@ -235,14 +235,9 @@ bool CXFA_WidgetData::IsOpenAccess() const { } int32_t CXFA_WidgetData::GetRotate() const { - pdfium::Optional measure = - m_pNode->JSNode()->TryMeasure(XFA_Attribute::Rotate, false); - if (!measure) - return 0; - - int32_t iRotate = FXSYS_round(measure->GetValue()); - iRotate = XFA_MapRotation(iRotate); - return iRotate / 90 * 90; + pdfium::Optional degrees = + m_pNode->JSNode()->TryInteger(XFA_Attribute::Rotate, false); + return degrees ? XFA_MapRotation(*degrees) / 90 * 90 : 0; } CXFA_BorderData CXFA_WidgetData::GetBorderData(bool bModified) { diff --git a/xfa/fxfa/parser/xfa_basic_data_attributes.cpp b/xfa/fxfa/parser/xfa_basic_data_attributes.cpp index 038f89405a..961475a997 100644 --- a/xfa/fxfa/parser/xfa_basic_data_attributes.cpp +++ b/xfa/fxfa/parser/xfa_basic_data_attributes.cpp @@ -162,8 +162,8 @@ const XFA_ATTRIBUTEINFO g_XFAAttributeData[] = { {0x2cd79033, L"kerningMode", XFA_Attribute::KerningMode, XFA_AttributeType::Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)XFA_ATTRIBUTEENUM_None}, - {0x2ee7678f, L"rotate", XFA_Attribute::Rotate, XFA_AttributeType::Measure, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)L"0an"}, + {0x2ee7678f, L"rotate", XFA_Attribute::Rotate, XFA_AttributeType::Integer, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)0}, {0x2f105f72, L"wordCharacterCount", XFA_Attribute::WordCharacterCount, XFA_AttributeType::Integer, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)7}, @@ -264,8 +264,8 @@ const XFA_ATTRIBUTEINFO g_XFAAttributeData[] = { XFA_AttributeType::Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)XFA_ATTRIBUTEENUM_Error}, {0x5c054755, L"startAngle", XFA_Attribute::StartAngle, - XFA_AttributeType::Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)L"0an"}, + XFA_AttributeType::Integer, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)0}, {0x5ec958c0, L"cursorType", XFA_Attribute::CursorType, XFA_AttributeType::Enum, XFA_XDPPACKET_SourceSet, (void*)XFA_ATTRIBUTEENUM_ForwardOnly}, @@ -305,8 +305,8 @@ const XFA_ATTRIBUTEINFO g_XFAAttributeData[] = { XFA_AttributeType::Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)L"0in"}, {0x74788f8b, L"sweepAngle", XFA_Attribute::SweepAngle, - XFA_AttributeType::Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)L"360an"}, + XFA_AttributeType::Integer, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)360}, {0x78bff531, L"numberOfCells", XFA_Attribute::NumberOfCells, XFA_AttributeType::Integer, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)0}, -- cgit v1.2.3