Remove pointless CFX_FloatRect construction.
Also just call CFX_FloatRect() instead of explicitly writing out all
zeros.
Change-Id: I7574e64791d0c9ba613b14d0a613737dfbf39b12
Reviewed-on: https://pdfium-review.googlesource.com/7172
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_pageobjectholder.cpp b/core/fpdfapi/page/cpdf_pageobjectholder.cpp
index 614fa34..2b7e62b 100644
--- a/core/fpdfapi/page/cpdf_pageobjectholder.cpp
+++ b/core/fpdfapi/page/cpdf_pageobjectholder.cpp
@@ -55,7 +55,7 @@
CFX_FloatRect CPDF_PageObjectHolder::CalcBoundingBox() const {
if (m_PageObjectList.empty())
- return CFX_FloatRect(0, 0, 0, 0);
+ return CFX_FloatRect();
float left = 1000000.0f;
float right = -1000000.0f;
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 151b0e6..e00dbc5 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -75,11 +75,11 @@
CPDF_Stream* pStream = ToStream(pShading->GetShadingObject());
CPDF_ColorSpace* pCS = pShading->GetCS();
if (!pStream || !pCS)
- return CFX_FloatRect(0, 0, 0, 0);
+ return CFX_FloatRect();
CPDF_MeshStream stream(type, pShading->GetFuncs(), pStream, pCS);
if (!stream.Load())
- return CFX_FloatRect(0, 0, 0, 0);
+ return CFX_FloatRect();
CFX_FloatRect rect;
bool bStarted = false;
diff --git a/fpdfsdk/cpdfsdk_widgethandler.cpp b/fpdfsdk/cpdfsdk_widgethandler.cpp
index 68d95ed..6092500 100644
--- a/fpdfsdk/cpdfsdk_widgethandler.cpp
+++ b/fpdfsdk/cpdfsdk_widgethandler.cpp
@@ -276,8 +276,7 @@
CPDFSDK_Annot* pAnnot) {
if (!pAnnot->IsSignatureWidget() && m_pFormFiller)
return CFX_FloatRect(m_pFormFiller->GetViewBBox(pPageView, pAnnot));
-
- return CFX_FloatRect(0, 0, 0, 0);
+ return CFX_FloatRect();
}
CFX_WideString CPDFSDK_WidgetHandler::GetSelectedText(CPDFSDK_Annot* pAnnot) {
diff --git a/fpdfsdk/formfiller/cffl_formfiller.cpp b/fpdfsdk/formfiller/cffl_formfiller.cpp
index 80f725b..281f0d7 100644
--- a/fpdfsdk/formfiller/cffl_formfiller.cpp
+++ b/fpdfsdk/formfiller/cffl_formfiller.cpp
@@ -6,6 +6,8 @@
#include "fpdfsdk/formfiller/cffl_formfiller.h"
+#include <utility>
+
#include "core/fpdfapi/page/cpdf_page.h"
#include "core/fxge/cfx_renderdevice.h"
#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
@@ -54,8 +56,7 @@
if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, false)) {
return pWnd->GetWindowRect();
}
-
- return CFX_FloatRect(0, 0, 0, 0);
+ return CFX_FloatRect();
}
FX_RECT CFFL_FormFiller::GetViewBBox(CPDFSDK_PageView* pPageView,
@@ -433,8 +434,7 @@
float fWidth = rectAnnot.right - rectAnnot.left;
float fHeight = rectAnnot.top - rectAnnot.bottom;
if ((m_pWidget->GetRotate() / 90) & 0x01)
- return CFX_FloatRect(0, 0, fHeight, fWidth);
-
+ std::swap(fWidth, fHeight);
return CFX_FloatRect(0, 0, fWidth, fHeight);
}
@@ -450,7 +450,7 @@
if (rcPage.Contains(rcFocus))
return rcFocus;
}
- return CFX_FloatRect(0, 0, 0, 0);
+ return CFX_FloatRect();
}
CFX_FloatRect CFFL_FormFiller::FFLtoPWL(const CFX_FloatRect& rect) {
diff --git a/fpdfsdk/pdfwindow/cpwl_combo_box.cpp b/fpdfsdk/pdfwindow/cpwl_combo_box.cpp
index 3a6f08c..3223db1 100644
--- a/fpdfsdk/pdfwindow/cpwl_combo_box.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_combo_box.cpp
@@ -293,7 +293,7 @@
if (!HasFlag(PCBS_ALLOWCUSTOMTEXT))
ecp.dwFlags |= PWS_READONLY;
- ecp.rcRectWnd = CFX_FloatRect(0, 0, 0, 0);
+ ecp.rcRectWnd = CFX_FloatRect();
ecp.dwBorderWidth = 0;
ecp.nBorderStyle = BorderStyle::SOLID;
m_pEdit->Create(ecp);
@@ -330,7 +330,7 @@
lcp.nBorderStyle = BorderStyle::SOLID;
lcp.dwBorderWidth = 1;
lcp.eCursorType = FXCT_ARROW;
- lcp.rcRectWnd = CFX_FloatRect(0, 0, 0, 0);
+ lcp.rcRectWnd = CFX_FloatRect();
if (cp.dwFlags & PWS_AUTOFONTSIZE)
lcp.fFontSize = PWLCB_DEFAULTFONTSIZE;
diff --git a/fpdfsdk/pdfwindow/cpwl_edit.cpp b/fpdfsdk/pdfwindow/cpwl_edit.cpp
index aa257b9..4ad1076 100644
--- a/fpdfsdk/pdfwindow/cpwl_edit.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_edit.cpp
@@ -179,7 +179,7 @@
m_pEdit->EnableUndo(HasFlag(PES_UNDO));
if (HasFlag(PES_TEXTOVERFLOW)) {
- SetClipRect(CFX_FloatRect(0.0f, 0.0f, 0.0f, 0.0f));
+ SetClipRect(CFX_FloatRect());
m_pEdit->SetTextOverflow(true, false);
} else {
if (m_pEditCaret) {
diff --git a/fpdfsdk/pdfwindow/cpwl_edit_ctrl.cpp b/fpdfsdk/pdfwindow/cpwl_edit_ctrl.cpp
index 3390696..d8a157a 100644
--- a/fpdfsdk/pdfwindow/cpwl_edit_ctrl.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_edit_ctrl.cpp
@@ -122,7 +122,7 @@
ecp.dwFlags = PWS_CHILD | PWS_NOREFRESHCLIP;
ecp.dwBorderWidth = 0;
ecp.nBorderStyle = BorderStyle::SOLID;
- ecp.rcRectWnd = CFX_FloatRect(0, 0, 0, 0);
+ ecp.rcRectWnd = CFX_FloatRect();
m_pEditCaret->Create(ecp);
}
diff --git a/fpdfsdk/pdfwindow/cpwl_utils.cpp b/fpdfsdk/pdfwindow/cpwl_utils.cpp
index ce263ef..4dd897d 100644
--- a/fpdfsdk/pdfwindow/cpwl_utils.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_utils.cpp
@@ -353,22 +353,19 @@
Icon.SetIconFit(&IconFit);
Icon.SetPDFStream(pIconStream);
- CFX_FloatRect rcLabel = CFX_FloatRect(0, 0, 0, 0);
- CFX_FloatRect rcIcon = CFX_FloatRect(0, 0, 0, 0);
+ CFX_FloatRect rcLabel;
+ CFX_FloatRect rcIcon;
float fWidth = 0.0f;
float fHeight = 0.0f;
switch (nLayOut) {
case PPBL_LABEL:
rcLabel = rcBBox;
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
break;
case PPBL_ICON:
rcIcon = rcBBox;
- rcLabel = CFX_FloatRect(0, 0, 0, 0);
break;
case PPBL_ICONTOPLABELBOTTOM:
-
if (pIconStream) {
if (IsFloatZero(fFontSize)) {
fHeight = rcBBox.top - rcBBox.bottom;
@@ -380,7 +377,6 @@
fHeight = rcLabelContent.Height();
if (rcBBox.bottom + fHeight > rcBBox.top) {
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
rcLabel = rcBBox;
} else {
rcLabel = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcBBox.right,
@@ -391,12 +387,9 @@
}
} else {
rcLabel = rcBBox;
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
}
-
break;
case PPBL_LABELTOPICONBOTTOM:
-
if (pIconStream) {
if (IsFloatZero(fFontSize)) {
fHeight = rcBBox.top - rcBBox.bottom;
@@ -409,7 +402,6 @@
fHeight = rcLabelContent.Height();
if (rcBBox.bottom + fHeight > rcBBox.top) {
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
rcLabel = rcBBox;
} else {
rcLabel = CFX_FloatRect(rcBBox.left, rcBBox.top - fHeight,
@@ -420,21 +412,17 @@
}
} else {
rcLabel = rcBBox;
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
}
-
break;
case PPBL_ICONLEFTLABELRIGHT:
-
if (pIconStream) {
if (IsFloatZero(fFontSize)) {
fWidth = rcBBox.right - rcBBox.left;
- rcLabel = CFX_FloatRect(rcBBox.right - fWidth * fAutoFontScale,
- rcBBox.bottom, rcBBox.right, rcBBox.top);
- rcIcon = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcLabel.left,
- rcBBox.top);
-
if (rcLabelContent.Width() < fWidth * fAutoFontScale) {
+ rcLabel = CFX_FloatRect(rcBBox.right - fWidth * fAutoFontScale,
+ rcBBox.bottom, rcBBox.right, rcBBox.top);
+ rcIcon = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcLabel.left,
+ rcBBox.top);
} else {
if (rcLabelContent.Width() < fWidth) {
rcLabel = CFX_FloatRect(rcBBox.right - rcLabelContent.Width(),
@@ -443,15 +431,12 @@
rcBBox.top);
} else {
rcLabel = rcBBox;
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
}
}
} else {
fWidth = rcLabelContent.Width();
-
if (rcBBox.left + fWidth > rcBBox.right) {
rcLabel = rcBBox;
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
} else {
rcLabel = CFX_FloatRect(rcBBox.right - fWidth, rcBBox.bottom,
rcBBox.right, rcBBox.top);
@@ -461,22 +446,18 @@
}
} else {
rcLabel = rcBBox;
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
}
-
break;
case PPBL_LABELLEFTICONRIGHT:
-
if (pIconStream) {
if (IsFloatZero(fFontSize)) {
fWidth = rcBBox.right - rcBBox.left;
- rcLabel =
- CFX_FloatRect(rcBBox.left, rcBBox.bottom,
- rcBBox.left + fWidth * fAutoFontScale, rcBBox.top);
- rcIcon = CFX_FloatRect(rcLabel.right, rcBBox.bottom, rcBBox.right,
- rcBBox.top);
-
if (rcLabelContent.Width() < fWidth * fAutoFontScale) {
+ rcLabel = CFX_FloatRect(rcBBox.left, rcBBox.bottom,
+ rcBBox.left + fWidth * fAutoFontScale,
+ rcBBox.top);
+ rcIcon = CFX_FloatRect(rcLabel.right, rcBBox.bottom, rcBBox.right,
+ rcBBox.top);
} else {
if (rcLabelContent.Width() < fWidth) {
rcLabel = CFX_FloatRect(rcBBox.left, rcBBox.bottom,
@@ -486,15 +467,12 @@
rcBBox.top);
} else {
rcLabel = rcBBox;
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
}
}
} else {
fWidth = rcLabelContent.Width();
-
if (rcBBox.left + fWidth > rcBBox.right) {
rcLabel = rcBBox;
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
} else {
rcLabel = CFX_FloatRect(rcBBox.left, rcBBox.bottom,
rcBBox.left + fWidth, rcBBox.top);
@@ -504,9 +482,7 @@
}
} else {
rcLabel = rcBBox;
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
}
-
break;
case PPBL_LABELOVERICON:
rcLabel = rcBBox;