Rename `iRotate` to `rotation`
Use Google C++ style naming. The build rules specify -Wshadow, so there
should be a warning if this rename collides with a pre-existing
`rotation` variable. Also rename some `rotate` variables to `rotation`
for consistency.
Change-Id: I0962f7db1815e95219219bbb47692c8fc2ec1ee4
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/132211
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_page.cpp b/core/fpdfapi/page/cpdf_page.cpp
index 272a394..795fd19 100644
--- a/core/fpdfapi/page/cpdf_page.cpp
+++ b/core/fpdfapi/page/cpdf_page.cpp
@@ -108,21 +108,22 @@
std::optional<CFX_PointF> CPDF_Page::DeviceToPage(
const FX_RECT& rect,
- int rotate,
+ int rotation,
const CFX_PointF& device_point) const {
- CFX_Matrix page2device = GetDisplayMatrix(rect, rotate);
+ CFX_Matrix page2device = GetDisplayMatrix(rect, rotation);
return page2device.GetInverse().Transform(device_point);
}
std::optional<CFX_PointF> CPDF_Page::PageToDevice(
const FX_RECT& rect,
- int rotate,
+ int rotation,
const CFX_PointF& page_point) const {
- CFX_Matrix page2device = GetDisplayMatrix(rect, rotate);
+ CFX_Matrix page2device = GetDisplayMatrix(rect, rotation);
return page2device.Transform(page_point);
}
-CFX_Matrix CPDF_Page::GetDisplayMatrix(const FX_RECT& rect, int iRotate) const {
+CFX_Matrix CPDF_Page::GetDisplayMatrix(const FX_RECT& rect,
+ int rotation) const {
if (page_size_.width == 0 || page_size_.height == 0) {
return CFX_Matrix();
}
@@ -133,14 +134,14 @@
float y1 = 0;
float x2 = 0;
float y2 = 0;
- iRotate %= 4;
+ rotation %= 4;
// This code implicitly inverts the y-axis to account for page coordinates
// pointing up and bitmap coordinates pointing down. (x0, y0) is the base
// point, (x1, y1) is that point translated on y and (x2, y2) is the point
- // translated on x. On iRotate = 0, y0 is rect.bottom and the translation
+ // translated on x. On rotation = 0, y0 is rect.bottom and the translation
// to get y1 is performed as negative. This results in the desired
// transformation.
- switch (iRotate) {
+ switch (rotation) {
case 0:
x0 = rect.left;
y0 = rect.bottom;
@@ -183,8 +184,8 @@
int CPDF_Page::GetPageRotation() const {
RetainPtr<const CPDF_Object> pRotate =
GetPageAttr(pdfium::page_object::kRotate);
- int rotate = pRotate ? (pRotate->GetInteger() / 90) % 4 : 0;
- return (rotate < 0) ? (rotate + 4) : rotate;
+ int rotation = pRotate ? (pRotate->GetInteger() / 90) % 4 : 0;
+ return (rotation < 0) ? (rotation + 4) : rotation;
}
RetainPtr<CPDF_Array> CPDF_Page::GetOrCreateAnnotsArray() {
diff --git a/core/fpdfapi/page/cpdf_page.h b/core/fpdfapi/page/cpdf_page.h
index 7e14511..25da545 100644
--- a/core/fpdfapi/page/cpdf_page.h
+++ b/core/fpdfapi/page/cpdf_page.h
@@ -57,14 +57,14 @@
CPDF_Document* GetDocument() const override;
float GetPageWidth() const override;
float GetPageHeight() const override;
- CFX_Matrix GetDisplayMatrix(const FX_RECT& rect, int iRotate) const override;
+ CFX_Matrix GetDisplayMatrix(const FX_RECT& rect, int rotation) const override;
std::optional<CFX_PointF> DeviceToPage(
const FX_RECT& rect,
- int rotate,
+ int rotation,
const CFX_PointF& device_point) const override;
std::optional<CFX_PointF> PageToDevice(
const FX_RECT& rect,
- int rotate,
+ int rotation,
const CFX_PointF& page_point) const override;
// CPDF_PageObjectHolder:
diff --git a/core/fpdfapi/page/ipdf_page.h b/core/fpdfapi/page/ipdf_page.h
index a37155f..c693ac4 100644
--- a/core/fpdfapi/page/ipdf_page.h
+++ b/core/fpdfapi/page/ipdf_page.h
@@ -34,16 +34,16 @@
virtual float GetPageWidth() const = 0;
virtual float GetPageHeight() const = 0;
virtual CFX_Matrix GetDisplayMatrix(const FX_RECT& rect,
- int iRotate) const = 0;
+ int rotation) const = 0;
virtual std::optional<CFX_PointF> DeviceToPage(
const FX_RECT& rect,
- int rotate,
+ int rotation,
const CFX_PointF& device_point) const = 0;
virtual std::optional<CFX_PointF> PageToDevice(
const FX_RECT& rect,
- int rotate,
+ int rotation,
const CFX_PointF& page_point) const = 0;
};
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp
index 283ea84..09061ec 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp
@@ -186,32 +186,32 @@
std::optional<CFX_PointF> CPDFXFA_Page::DeviceToPage(
const FX_RECT& rect,
- int rotate,
+ int rotation,
const CFX_PointF& device_point) const {
CXFA_FFPageView* pPageView = GetXFAPageView();
if (!pdfpage_ && !pPageView) {
return std::nullopt;
}
- CFX_Matrix page2device = GetDisplayMatrix(rect, rotate);
+ CFX_Matrix page2device = GetDisplayMatrix(rect, rotation);
return page2device.GetInverse().Transform(device_point);
}
std::optional<CFX_PointF> CPDFXFA_Page::PageToDevice(
const FX_RECT& rect,
- int rotate,
+ int rotation,
const CFX_PointF& page_point) const {
CXFA_FFPageView* pPageView = GetXFAPageView();
if (!pdfpage_ && !pPageView) {
return std::nullopt;
}
- CFX_Matrix page2device = GetDisplayMatrix(rect, rotate);
+ CFX_Matrix page2device = GetDisplayMatrix(rect, rotation);
return page2device.Transform(page_point);
}
CFX_Matrix CPDFXFA_Page::GetDisplayMatrix(const FX_RECT& rect,
- int iRotate) const {
+ int rotation) const {
CXFA_FFPageView* pPageView = GetXFAPageView();
if (!pdfpage_ && !pPageView) {
return CFX_Matrix();
@@ -223,12 +223,12 @@
case FormType::kAcroForm:
case FormType::kXFAForeground:
if (pdfpage_) {
- return pdfpage_->GetDisplayMatrix(rect, iRotate);
+ return pdfpage_->GetDisplayMatrix(rect, rotation);
}
[[fallthrough]];
case FormType::kXFAFull:
if (pPageView) {
- return pPageView->GetDisplayMatrix(rect, iRotate);
+ return pPageView->GetDisplayMatrix(rect, rotation);
}
break;
}
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_page.h b/fpdfsdk/fpdfxfa/cpdfxfa_page.h
index b358123..3c761ff 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_page.h
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_page.h
@@ -32,14 +32,14 @@
CPDF_Document* GetDocument() const override;
float GetPageWidth() const override;
float GetPageHeight() const override;
- CFX_Matrix GetDisplayMatrix(const FX_RECT& rect, int iRotate) const override;
+ CFX_Matrix GetDisplayMatrix(const FX_RECT& rect, int rotation) const override;
std::optional<CFX_PointF> DeviceToPage(
const FX_RECT& rect,
- int rotate,
+ int rotation,
const CFX_PointF& device_point) const override;
std::optional<CFX_PointF> PageToDevice(
const FX_RECT& rect,
- int rotate,
+ int rotation,
const CFX_PointF& page_point) const override;
bool LoadPage();
diff --git a/xfa/fxfa/cxfa_ffpageview.cpp b/xfa/fxfa/cxfa_ffpageview.cpp
index 9f2bea9..4fff68b 100644
--- a/xfa/fxfa/cxfa_ffpageview.cpp
+++ b/xfa/fxfa/cxfa_ffpageview.cpp
@@ -30,20 +30,20 @@
CFX_Matrix GetPageMatrix(const CFX_RectF& docPageRect,
const FX_RECT& devicePageRect,
- int32_t iRotate) {
- DCHECK(iRotate >= 0);
- DCHECK(iRotate <= 3);
+ int32_t rotation) {
+ DCHECK(rotation >= 0);
+ DCHECK(rotation <= 3);
CFX_Matrix m;
- if (iRotate == 0 || iRotate == 2) {
+ if (rotation == 0 || rotation == 2) {
m.a *= (float)devicePageRect.Width() / docPageRect.width;
m.d *= (float)devicePageRect.Height() / docPageRect.height;
} else {
m.a *= (float)devicePageRect.Height() / docPageRect.width;
m.d *= (float)devicePageRect.Width() / docPageRect.height;
}
- m.Rotate(iRotate * 1.57079632675f);
- switch (iRotate) {
+ m.Rotate(rotation * 1.57079632675f);
+ switch (rotation) {
case 0:
m.e = devicePageRect.left;
m.f = devicePageRect.top;
@@ -263,13 +263,13 @@
}
CFX_Matrix CXFA_FFPageView::GetDisplayMatrix(const FX_RECT& rtDisp,
- int32_t iRotate) const {
+ int32_t rotation) const {
auto* pItem = GetLayoutItem();
if (!pItem) {
return CFX_Matrix();
}
- return GetPageMatrix(CFX_RectF(0, 0, pItem->GetPageSize()), rtDisp, iRotate);
+ return GetPageMatrix(CFX_RectF(0, 0, pItem->GetPageSize()), rtDisp, rotation);
}
CXFA_FFWidget::IteratorIface* CXFA_FFPageView::CreateGCedTraverseWidgetIterator(
diff --git a/xfa/fxfa/cxfa_ffpageview.h b/xfa/fxfa/cxfa_ffpageview.h
index b6a09c4..1e73447 100644
--- a/xfa/fxfa/cxfa_ffpageview.h
+++ b/xfa/fxfa/cxfa_ffpageview.h
@@ -35,7 +35,7 @@
CXFA_FFDocView* GetDocView() const;
CFX_RectF GetPageViewRect() const;
- CFX_Matrix GetDisplayMatrix(const FX_RECT& rtDisp, int32_t iRotate) const;
+ CFX_Matrix GetDisplayMatrix(const FX_RECT& rtDisp, int32_t rotation) const;
// This always returns a non-null iterator from the gc heap.
CXFA_FFWidget::IteratorIface* CreateGCedTraverseWidgetIterator(
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index 2840785..bd60b5a 100644
--- a/xfa/fxfa/cxfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -522,14 +522,14 @@
}
CFX_Matrix CXFA_FFWidget::GetRotateMatrix() {
- int32_t iRotate = node_->GetRotate();
- if (!iRotate) {
+ int32_t rotation = node_->GetRotate();
+ if (rotation == 0) {
return CFX_Matrix();
}
CFX_RectF rcWidget = GetRectWithoutRotate();
CFX_Matrix mt;
- switch (iRotate) {
+ switch (rotation) {
case 90:
mt.a = 0;
mt.b = -1;