summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-11-20 22:23:50 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-20 22:23:50 +0000
commit120c19b6a19377c341658c342c4351eccbb59741 (patch)
tree6799a4d504efd2eb1c7a036bf7959a9352c199e4
parent2501ae2474c1f097a06634d647de2eb3fb730864 (diff)
downloadpdfium-chromium/3274.tar.xz
Rename CXFA_MarginData methodschromium/3274
This CL renames the CXFA_MarginData::Get*Inset methods to CXFA_MarginData::Try*Inset to match the fact that they may fail. The default value has been removed and all the callers correctly set the default values. Change-Id: Ib0dc8dc35807b60a0ddc0e5724604cb39845fcea Reviewed-on: https://pdfium-review.googlesource.com/18771 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
-rw-r--r--xfa/fxfa/cxfa_fffield.cpp13
-rw-r--r--xfa/fxfa/cxfa_fftext.cpp20
-rw-r--r--xfa/fxfa/cxfa_ffwidget.cpp16
-rw-r--r--xfa/fxfa/cxfa_widgetacc.cpp73
-rw-r--r--xfa/fxfa/parser/cxfa_margindata.cpp12
-rw-r--r--xfa/fxfa/parser/cxfa_margindata.h8
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.cpp13
7 files changed, 80 insertions, 75 deletions
diff --git a/xfa/fxfa/cxfa_fffield.cpp b/xfa/fxfa/cxfa_fffield.cpp
index 7e36fea2cf..b4142ba701 100644
--- a/xfa/fxfa/cxfa_fffield.cpp
+++ b/xfa/fxfa/cxfa_fffield.cpp
@@ -172,11 +172,14 @@ void CXFA_FFField::CapPlacement() {
CXFA_MarginData marginData = m_pDataAcc->GetMarginData();
if (marginData.HasValidNode()) {
CXFA_LayoutItem* pItem = this;
- float fLeftInset = 0, fRightInset = 0, fTopInset = 0, fBottomInset = 0;
- marginData.GetLeftInset(fLeftInset);
- marginData.GetRightInset(fRightInset);
- marginData.GetTopInset(fTopInset);
- marginData.GetBottomInset(fBottomInset);
+ float fLeftInset = 0;
+ float fRightInset = 0;
+ float fTopInset = 0;
+ float fBottomInset = 0;
+ marginData.TryLeftInset(fLeftInset);
+ marginData.TryRightInset(fRightInset);
+ marginData.TryTopInset(fTopInset);
+ marginData.TryBottomInset(fBottomInset);
if (!pItem->GetPrev() && !pItem->GetNext()) {
rtWidget.Deflate(fLeftInset, fTopInset, fRightInset, fBottomInset);
} else {
diff --git a/xfa/fxfa/cxfa_fftext.cpp b/xfa/fxfa/cxfa_fftext.cpp
index 1eac4fd309..6242b8ec17 100644
--- a/xfa/fxfa/cxfa_fftext.cpp
+++ b/xfa/fxfa/cxfa_fftext.cpp
@@ -46,16 +46,16 @@ void CXFA_FFText::RenderWidget(CXFA_Graphics* pGS,
if (!pItem->GetPrev() && !pItem->GetNext()) {
XFA_RectWidthoutMargin(rtText, marginData);
} else {
- float fLeftInset;
- float fRightInset;
+ float fLeftInset = 0;
+ float fRightInset = 0;
float fTopInset = 0;
float fBottomInset = 0;
- marginData.GetLeftInset(fLeftInset);
- marginData.GetRightInset(fRightInset);
+ marginData.TryLeftInset(fLeftInset);
+ marginData.TryRightInset(fRightInset);
if (!pItem->GetPrev())
- marginData.GetTopInset(fTopInset);
+ marginData.TryTopInset(fTopInset);
else if (!pItem->GetNext())
- marginData.GetBottomInset(fBottomInset);
+ marginData.TryBottomInset(fBottomInset);
rtText.Deflate(fLeftInset, fTopInset, fRightInset, fBottomInset);
}
@@ -91,12 +91,12 @@ bool CXFA_FFText::PerformLayout() {
CXFA_MarginData marginData = m_pDataAcc->GetMarginData();
if (marginData.HasValidNode()) {
if (!pItem->GetPrev()) {
- float fTopInset;
- marginData.GetTopInset(fTopInset);
+ float fTopInset = 0;
+ marginData.TryTopInset(fTopInset);
rtText.height -= fTopInset;
} else if (!pItem->GetNext()) {
- float fBottomInset;
- marginData.GetBottomInset(fBottomInset);
+ float fBottomInset = 0;
+ marginData.TryBottomInset(fBottomInset);
rtText.height -= fBottomInset;
}
}
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index 88c1fea971..00ab8cda0e 100644
--- a/xfa/fxfa/cxfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -2026,14 +2026,14 @@ void XFA_RectWidthoutMargin(CFX_RectF& rt,
if (!marginData.HasValidNode())
return;
- float fLeftInset;
- float fTopInset;
- float fRightInset;
- float fBottomInset;
- marginData.GetLeftInset(fLeftInset);
- marginData.GetTopInset(fTopInset);
- marginData.GetRightInset(fRightInset);
- marginData.GetBottomInset(fBottomInset);
+ float fLeftInset = 0;
+ float fTopInset = 0;
+ float fRightInset = 0;
+ float fBottomInset = 0;
+ marginData.TryLeftInset(fLeftInset);
+ marginData.TryTopInset(fTopInset);
+ marginData.TryRightInset(fRightInset);
+ marginData.TryBottomInset(fBottomInset);
rt.Deflate(fLeftInset, fTopInset, fRightInset, fBottomInset);
}
diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp
index 4adc447aaa..b55adc04a4 100644
--- a/xfa/fxfa/cxfa_widgetacc.cpp
+++ b/xfa/fxfa/cxfa_widgetacc.cpp
@@ -731,14 +731,14 @@ void CXFA_WidgetAcc::CalcCaptionSize(CFX_SizeF& szCap) {
CXFA_MarginData captionMarginData = captionData.GetMarginData();
if (captionMarginData.HasValidNode()) {
- float fLeftInset;
- float fTopInset;
- float fRightInset;
- float fBottomInset;
- captionMarginData.GetLeftInset(fLeftInset);
- captionMarginData.GetTopInset(fTopInset);
- captionMarginData.GetRightInset(fRightInset);
- captionMarginData.GetBottomInset(fBottomInset);
+ float fLeftInset = 0;
+ float fTopInset = 0;
+ float fRightInset = 0;
+ float fBottomInset = 0;
+ captionMarginData.TryLeftInset(fLeftInset);
+ captionMarginData.TryTopInset(fTopInset);
+ captionMarginData.TryRightInset(fRightInset);
+ captionMarginData.TryBottomInset(fBottomInset);
if (bReserveExit) {
bVert ? (szCap.width += fLeftInset + fRightInset)
: (szCap.height += fTopInset + fBottomInset);
@@ -779,11 +779,14 @@ bool CXFA_WidgetAcc::CalculateFieldAutoSize(CFX_SizeF& size) {
bool CXFA_WidgetAcc::CalculateWidgetAutoSize(CFX_SizeF& size) {
CXFA_MarginData marginData = GetMarginData();
if (marginData.HasValidNode()) {
- float fLeftInset, fTopInset, fRightInset, fBottomInset;
- marginData.GetLeftInset(fLeftInset);
- marginData.GetTopInset(fTopInset);
- marginData.GetRightInset(fRightInset);
- marginData.GetBottomInset(fBottomInset);
+ float fLeftInset = 0;
+ float fTopInset = 0;
+ float fRightInset = 0;
+ float fBottomInset = 0;
+ marginData.TryLeftInset(fLeftInset);
+ marginData.TryTopInset(fTopInset);
+ marginData.TryRightInset(fRightInset);
+ marginData.TryBottomInset(fBottomInset);
size.width += fLeftInset + fRightInset;
size.height += fTopInset + fBottomInset;
}
@@ -874,10 +877,10 @@ bool CXFA_WidgetAcc::CalculateTextEditAutoSize(CFX_SizeF& size) {
size.width -= rtUIMargin.left + rtUIMargin.width;
CXFA_MarginData marginData = GetMarginData();
if (marginData.HasValidNode()) {
- float fLeftInset;
- float fRightInset;
- marginData.GetLeftInset(fLeftInset);
- marginData.GetRightInset(fRightInset);
+ float fLeftInset = 0;
+ float fRightInset = 0;
+ marginData.TryLeftInset(fLeftInset);
+ marginData.TryRightInset(fRightInset);
size.width -= fLeftInset + fRightInset;
}
CalculateTextContentSize(size);
@@ -1021,10 +1024,10 @@ void CXFA_WidgetAcc::LoadText() {
float CXFA_WidgetAcc::CalculateWidgetAutoWidth(float fWidthCalc) {
CXFA_MarginData marginData = GetMarginData();
if (marginData.HasValidNode()) {
- float fLeftInset;
- float fRightInset;
- marginData.GetLeftInset(fLeftInset);
- marginData.GetRightInset(fRightInset);
+ float fLeftInset = 0;
+ float fRightInset = 0;
+ marginData.TryLeftInset(fLeftInset);
+ marginData.TryRightInset(fRightInset);
fWidthCalc += fLeftInset + fRightInset;
}
@@ -1040,10 +1043,10 @@ float CXFA_WidgetAcc::CalculateWidgetAutoWidth(float fWidthCalc) {
float CXFA_WidgetAcc::GetWidthWithoutMargin(float fWidthCalc) {
CXFA_MarginData marginData = GetMarginData();
if (marginData.HasValidNode()) {
- float fLeftInset;
- float fRightInset;
- marginData.GetLeftInset(fLeftInset);
- marginData.GetRightInset(fRightInset);
+ float fLeftInset = 0;
+ float fRightInset = 0;
+ marginData.TryLeftInset(fLeftInset);
+ marginData.TryRightInset(fRightInset);
fWidthCalc -= fLeftInset + fRightInset;
}
return fWidthCalc;
@@ -1052,10 +1055,10 @@ float CXFA_WidgetAcc::GetWidthWithoutMargin(float fWidthCalc) {
float CXFA_WidgetAcc::CalculateWidgetAutoHeight(float fHeightCalc) {
CXFA_MarginData marginData = GetMarginData();
if (marginData.HasValidNode()) {
- float fTopInset;
- float fBottomInset;
- marginData.GetTopInset(fTopInset);
- marginData.GetBottomInset(fBottomInset);
+ float fTopInset = 0;
+ float fBottomInset = 0;
+ marginData.TryTopInset(fTopInset);
+ marginData.TryBottomInset(fBottomInset);
fHeightCalc += fTopInset + fBottomInset;
}
@@ -1071,10 +1074,10 @@ float CXFA_WidgetAcc::CalculateWidgetAutoHeight(float fHeightCalc) {
float CXFA_WidgetAcc::GetHeightWithoutMargin(float fHeightCalc) {
CXFA_MarginData marginData = GetMarginData();
if (marginData.HasValidNode()) {
- float fTopInset;
- float fBottomInset;
- marginData.GetTopInset(fTopInset);
- marginData.GetBottomInset(fBottomInset);
+ float fTopInset = 0;
+ float fBottomInset = 0;
+ marginData.TryTopInset(fTopInset);
+ marginData.TryBottomInset(fBottomInset);
fHeightCalc -= fTopInset + fBottomInset;
}
return fHeightCalc;
@@ -1170,8 +1173,8 @@ bool CXFA_WidgetAcc::FindSplitPos(int32_t iBlockIndex, float& fCalcHeight) {
if (iBlockIndex == 0) {
CXFA_MarginData marginData = GetMarginData();
if (marginData.HasValidNode()) {
- marginData.GetTopInset(fTopInset);
- marginData.GetBottomInset(fBottomInset);
+ marginData.TryTopInset(fTopInset);
+ marginData.TryBottomInset(fBottomInset);
}
CFX_RectF rtUIMargin = GetUIMargin();
diff --git a/xfa/fxfa/parser/cxfa_margindata.cpp b/xfa/fxfa/parser/cxfa_margindata.cpp
index 08cc9fd844..2c5689cfa0 100644
--- a/xfa/fxfa/parser/cxfa_margindata.cpp
+++ b/xfa/fxfa/parser/cxfa_margindata.cpp
@@ -8,22 +8,18 @@
CXFA_MarginData::CXFA_MarginData(CXFA_Node* pNode) : CXFA_DataData(pNode) {}
-bool CXFA_MarginData::GetLeftInset(float& fInset, float fDefInset) const {
- fInset = fDefInset;
+bool CXFA_MarginData::TryLeftInset(float& fInset) const {
return TryMeasure(XFA_Attribute::LeftInset, fInset);
}
-bool CXFA_MarginData::GetTopInset(float& fInset, float fDefInset) const {
- fInset = fDefInset;
+bool CXFA_MarginData::TryTopInset(float& fInset) const {
return TryMeasure(XFA_Attribute::TopInset, fInset);
}
-bool CXFA_MarginData::GetRightInset(float& fInset, float fDefInset) const {
- fInset = fDefInset;
+bool CXFA_MarginData::TryRightInset(float& fInset) const {
return TryMeasure(XFA_Attribute::RightInset, fInset);
}
-bool CXFA_MarginData::GetBottomInset(float& fInset, float fDefInset) const {
- fInset = fDefInset;
+bool CXFA_MarginData::TryBottomInset(float& fInset) const {
return TryMeasure(XFA_Attribute::BottomInset, fInset);
}
diff --git a/xfa/fxfa/parser/cxfa_margindata.h b/xfa/fxfa/parser/cxfa_margindata.h
index 5695fcc5f5..6933c3d078 100644
--- a/xfa/fxfa/parser/cxfa_margindata.h
+++ b/xfa/fxfa/parser/cxfa_margindata.h
@@ -16,10 +16,10 @@ class CXFA_MarginData : public CXFA_DataData {
public:
explicit CXFA_MarginData(CXFA_Node* pNode);
- bool GetLeftInset(float& fInset, float fDefInset = 0) const;
- bool GetTopInset(float& fInset, float fDefInset = 0) const;
- bool GetRightInset(float& fInset, float fDefInset = 0) const;
- bool GetBottomInset(float& fInset, float fDefInset = 0) const;
+ bool TryLeftInset(float& fInset) const;
+ bool TryTopInset(float& fInset) const;
+ bool TryRightInset(float& fInset) const;
+ bool TryBottomInset(float& fInset) const;
};
#endif // XFA_FXFA_PARSER_CXFA_MARGINDATA_H_
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index b5ceb4a4d4..98e81f3c2b 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -373,11 +373,14 @@ CFX_RectF CXFA_WidgetData::GetUIMargin() {
return CFX_RectF();
}
- float fLeftInset, fTopInset, fRightInset, fBottomInset;
- bool bLeft = mgUI.GetLeftInset(fLeftInset);
- bool bTop = mgUI.GetTopInset(fTopInset);
- bool bRight = mgUI.GetRightInset(fRightInset);
- bool bBottom = mgUI.GetBottomInset(fBottomInset);
+ float fLeftInset = 0;
+ float fTopInset = 0;
+ float fRightInset = 0;
+ float fBottomInset = 0;
+ bool bLeft = mgUI.TryLeftInset(fLeftInset);
+ bool bTop = mgUI.TryTopInset(fTopInset);
+ bool bRight = mgUI.TryRightInset(fRightInset);
+ bool bBottom = mgUI.TryBottomInset(fBottomInset);
if (borderData.HasValidNode()) {
bool bVisible = false;
float fThickness = 0;