summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-02-29 17:27:50 -0800
committerTom Sepez <tsepez@chromium.org>2016-02-29 17:27:50 -0800
commit020fd8a9f715b7a0e9f9d9689245ebee1e2e7e18 (patch)
tree6cc766fc0414435079d2c96c59f44a7038ee16db
parentac4b8361e7919c6188587b89cbfbb748b3079b5b (diff)
downloadpdfium-020fd8a9f715b7a0e9f9d9689245ebee1e2e7e18.tar.xz
Add CFX_FloatRect::ToFxRect().
R=dsinclair@chromium.org Review URL: https://codereview.chromium.org/1752543002 .
-rw-r--r--core/include/fxcrt/fx_coordinates.h19
-rw-r--r--core/src/fxcrt/fx_basic_coords.cpp20
-rw-r--r--fpdfsdk/src/fxedit/fxet_pageobjs.cpp12
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_Utils.cpp4
4 files changed, 26 insertions, 29 deletions
diff --git a/core/include/fxcrt/fx_coordinates.h b/core/include/fxcrt/fx_coordinates.h
index 2cd249310e..2f52f78b8f 100644
--- a/core/include/fxcrt/fx_coordinates.h
+++ b/core/include/fxcrt/fx_coordinates.h
@@ -185,10 +185,10 @@ struct FX_RECT {
static_cast<uint16_t>(right), static_cast<uint16_t>(bottom));
}
- int left;
- int top;
- int right;
- int bottom;
+ int32_t left;
+ int32_t top;
+ int32_t right;
+ int32_t bottom;
};
// LBRT rectangles (y-axis runs upwards).
@@ -220,9 +220,9 @@ class CFX_FloatRect {
top = 0.0f;
}
- FX_BOOL IsEmpty() const { return left >= right || bottom >= top; }
- FX_BOOL Contains(const CFX_FloatRect& other_rect) const;
- FX_BOOL Contains(FX_FLOAT x, FX_FLOAT y) const;
+ bool IsEmpty() const { return left >= right || bottom >= top; }
+ bool Contains(const CFX_FloatRect& other_rect) const;
+ bool Contains(FX_FLOAT x, FX_FLOAT y) const;
void Transform(const CFX_Matrix* pMatrix);
void Intersect(const CFX_FloatRect& other_rect);
@@ -300,6 +300,11 @@ class CFX_FloatRect {
static CFX_FloatRect GetBBox(const CFX_PointF* pPoints, int nPoints);
+ FX_RECT ToFxRect() const {
+ return FX_RECT(static_cast<int32_t>(left), static_cast<int32_t>(top),
+ static_cast<int32_t>(right), static_cast<int32_t>(bottom));
+ }
+
FX_FLOAT left;
FX_FLOAT bottom;
FX_FLOAT right;
diff --git a/core/src/fxcrt/fx_basic_coords.cpp b/core/src/fxcrt/fx_basic_coords.cpp
index 27feb55113..4f723ef919 100644
--- a/core/src/fxcrt/fx_basic_coords.cpp
+++ b/core/src/fxcrt/fx_basic_coords.cpp
@@ -187,22 +187,22 @@ FX_RECT CFX_FloatRect::GetClosestRect() const {
rect.Normalize();
return rect;
}
-FX_BOOL CFX_FloatRect::Contains(const CFX_FloatRect& other_rect) const {
- CFX_FloatRect n1 = *this;
+
+bool CFX_FloatRect::Contains(const CFX_FloatRect& other_rect) const {
+ CFX_FloatRect n1(*this);
+ CFX_FloatRect n2(other_rect);
n1.Normalize();
- CFX_FloatRect n2 = other_rect;
n2.Normalize();
- if (n2.left >= n1.left && n2.right <= n1.right && n2.bottom >= n1.bottom &&
- n2.top <= n1.top) {
- return TRUE;
- }
- return FALSE;
+ return n2.left >= n1.left && n2.right <= n1.right && n2.bottom >= n1.bottom &&
+ n2.top <= n1.top;
}
-FX_BOOL CFX_FloatRect::Contains(FX_FLOAT x, FX_FLOAT y) const {
- CFX_FloatRect n1 = *this;
+
+bool CFX_FloatRect::Contains(FX_FLOAT x, FX_FLOAT y) const {
+ CFX_FloatRect n1(*this);
n1.Normalize();
return x <= n1.right && x >= n1.left && y <= n1.top && y >= n1.bottom;
}
+
void CFX_FloatRect::UpdateRect(FX_FLOAT x, FX_FLOAT y) {
if (left > x) {
left = x;
diff --git a/fpdfsdk/src/fxedit/fxet_pageobjs.cpp b/fpdfsdk/src/fxedit/fxet_pageobjs.cpp
index 63ab467ebe..6d091b7c19 100644
--- a/fpdfsdk/src/fxedit/fxet_pageobjs.cpp
+++ b/fpdfsdk/src/fxedit/fxet_pageobjs.cpp
@@ -100,9 +100,7 @@ void IFX_Edit::DrawUnderline(CFX_RenderDevice* pDevice,
if (!rcClip.IsEmpty()) {
CFX_FloatRect rcTemp = rcClip;
pUser2Device->TransformRect(rcTemp);
- pDevice->SetClip_Rect(FX_RECT((int32_t)rcTemp.left, (int32_t)rcTemp.top,
- (int32_t)rcTemp.right,
- (int32_t)rcTemp.bottom));
+ pDevice->SetClip_Rect(rcTemp.ToFxRect());
}
if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
@@ -171,9 +169,7 @@ void IFX_Edit::DrawEdit(CFX_RenderDevice* pDevice,
if (!rcClip.IsEmpty()) {
CFX_FloatRect rcTemp = rcClip;
pUser2Device->TransformRect(rcTemp);
- pDevice->SetClip_Rect(FX_RECT((int32_t)rcTemp.left, (int32_t)rcTemp.top,
- (int32_t)rcTemp.right,
- (int32_t)rcTemp.bottom));
+ pDevice->SetClip_Rect(rcTemp.ToFxRect());
}
if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
@@ -293,9 +289,7 @@ void IFX_Edit::DrawRichEdit(CFX_RenderDevice* pDevice,
if (!rcClip.IsEmpty()) {
CFX_FloatRect rcTemp = rcClip;
pUser2Device->TransformRect(rcTemp);
- pDevice->SetClip_Rect(FX_RECT((int32_t)rcTemp.left, (int32_t)rcTemp.top,
- (int32_t)rcTemp.right,
- (int32_t)rcTemp.bottom));
+ pDevice->SetClip_Rect(rcTemp.ToFxRect());
}
if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
diff --git a/fpdfsdk/src/pdfwindow/PWL_Utils.cpp b/fpdfsdk/src/pdfwindow/PWL_Utils.cpp
index db1323e78a..926ab3f0b7 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Utils.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Utils.cpp
@@ -1696,9 +1696,7 @@ void CPWL_Utils::DrawEditSpellCheck(CFX_RenderDevice* pDevice,
if (!rcClip.IsEmpty()) {
CFX_FloatRect rcTemp = rcClip;
pUser2Device->TransformRect(rcTemp);
- pDevice->SetClip_Rect(FX_RECT((int32_t)rcTemp.left, (int32_t)rcTemp.top,
- (int32_t)rcTemp.right,
- (int32_t)rcTemp.bottom));
+ pDevice->SetClip_Rect(rcTemp.ToFxRect());
}
if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {