summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fxedit/fxet_edit.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-02-26 14:24:28 -0800
committerTom Sepez <tsepez@chromium.org>2016-02-26 14:24:28 -0800
commit281a9eadff15b167e2ee3032e21b83190ad49125 (patch)
treef02f7d0842f59d8e69bda011b3e62547ffb1acde /fpdfsdk/src/fxedit/fxet_edit.cpp
parent566b974287ce0e81a963138152b8898f22480f52 (diff)
downloadpdfium-281a9eadff15b167e2ee3032e21b83190ad49125.tar.xz
Re-land "Replace CPDF_Rect and CPDF_Point with CFX types."
TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1737593006 .
Diffstat (limited to 'fpdfsdk/src/fxedit/fxet_edit.cpp')
-rw-r--r--fpdfsdk/src/fxedit/fxet_edit.cpp142
1 files changed, 73 insertions, 69 deletions
diff --git a/fpdfsdk/src/fxedit/fxet_edit.cpp b/fpdfsdk/src/fxedit/fxet_edit.cpp
index 0e66b0e3b5..1b68dc0510 100644
--- a/fpdfsdk/src/fxedit/fxet_edit.cpp
+++ b/fpdfsdk/src/fxedit/fxet_edit.cpp
@@ -155,7 +155,7 @@ void CFX_Edit_Refresh::BeginRefresh() {
}
void CFX_Edit_Refresh::Push(const CPVT_WordRange& linerange,
- const CPDF_Rect& rect) {
+ const CFX_FloatRect& rect) {
m_NewLineRects.Add(linerange, rect);
}
@@ -175,7 +175,7 @@ void CFX_Edit_Refresh::NoAnalyse() {
void CFX_Edit_Refresh::Analyse(int32_t nAlignment) {
FX_BOOL bLineTopChanged = FALSE;
- CPDF_Rect rcResult;
+ CFX_FloatRect rcResult;
FX_FLOAT fWidthDiff;
int32_t szMax = std::max(m_OldLineRects.GetSize(), m_NewLineRects.GetSize());
@@ -240,7 +240,7 @@ void CFX_Edit_Refresh::Analyse(int32_t nAlignment) {
}
}
-void CFX_Edit_Refresh::AddRefresh(const CPDF_Rect& rect) {
+void CFX_Edit_Refresh::AddRefresh(const CFX_FloatRect& rect) {
m_RefreshRects.Add(rect);
}
@@ -814,9 +814,9 @@ IFX_Edit_FontMap* CFX_Edit::GetFontMap() {
return NULL;
}
-void CFX_Edit::SetPlateRect(const CPDF_Rect& rect, FX_BOOL bPaint) {
+void CFX_Edit::SetPlateRect(const CFX_FloatRect& rect, FX_BOOL bPaint) {
m_pVT->SetPlateRect(rect);
- m_ptScrollPos = CPDF_Point(rect.left, rect.top);
+ m_ptScrollPos = CFX_FloatPoint(rect.left, rect.top);
if (bPaint)
Paint();
}
@@ -1631,11 +1631,11 @@ int32_t CFX_Edit::GetCharArray() const {
return m_pVT->GetCharArray();
}
-CPDF_Rect CFX_Edit::GetPlateRect() const {
+CFX_FloatRect CFX_Edit::GetPlateRect() const {
return m_pVT->GetPlateRect();
}
-CPDF_Rect CFX_Edit::GetContentRect() const {
+CFX_FloatRect CFX_Edit::GetContentRect() const {
return VTToEdit(m_pVT->GetContentRect());
}
@@ -1659,12 +1659,12 @@ CPVT_WordRange CFX_Edit::GetVisibleWordRange() const {
return GetWholeWordRange();
if (m_pVT->IsValid()) {
- CPDF_Rect rcPlate = m_pVT->GetPlateRect();
+ CFX_FloatRect rcPlate = m_pVT->GetPlateRect();
- CPVT_WordPlace place1 =
- m_pVT->SearchWordPlace(EditToVT(CPDF_Point(rcPlate.left, rcPlate.top)));
+ CPVT_WordPlace place1 = m_pVT->SearchWordPlace(
+ EditToVT(CFX_FloatPoint(rcPlate.left, rcPlate.top)));
CPVT_WordPlace place2 = m_pVT->SearchWordPlace(
- EditToVT(CPDF_Point(rcPlate.right, rcPlate.bottom)));
+ EditToVT(CFX_FloatPoint(rcPlate.right, rcPlate.bottom)));
return CPVT_WordRange(place1, place2);
}
@@ -1672,7 +1672,7 @@ CPVT_WordRange CFX_Edit::GetVisibleWordRange() const {
return CPVT_WordRange();
}
-CPVT_WordPlace CFX_Edit::SearchWordPlace(const CPDF_Point& point) const {
+CPVT_WordPlace CFX_Edit::SearchWordPlace(const CFX_FloatPoint& point) const {
if (m_pVT->IsValid()) {
return m_pVT->SearchWordPlace(EditToVT(point));
}
@@ -1712,7 +1712,7 @@ void CFX_Edit::RearrangePart(const CPVT_WordRange& range) {
void CFX_Edit::SetContentChanged() {
if (m_bNotify && m_pNotify) {
- CPDF_Rect rcContent = m_pVT->GetContentRect();
+ CFX_FloatRect rcContent = m_pVT->GetContentRect();
if (rcContent.Width() != m_rcOldContent.Width() ||
rcContent.Height() != m_rcOldContent.Height()) {
if (!m_bNotifyFlag) {
@@ -1751,9 +1751,9 @@ FX_BOOL CFX_Edit::IsSelected() const {
return m_SelState.IsExist();
}
-CPDF_Point CFX_Edit::VTToEdit(const CPDF_Point& point) const {
- CPDF_Rect rcContent = m_pVT->GetContentRect();
- CPDF_Rect rcPlate = m_pVT->GetPlateRect();
+CFX_FloatPoint CFX_Edit::VTToEdit(const CFX_FloatPoint& point) const {
+ CFX_FloatRect rcContent = m_pVT->GetContentRect();
+ CFX_FloatRect rcPlate = m_pVT->GetPlateRect();
FX_FLOAT fPadding = 0.0f;
@@ -1769,13 +1769,13 @@ CPDF_Point CFX_Edit::VTToEdit(const CPDF_Point& point) const {
break;
}
- return CPDF_Point(point.x - (m_ptScrollPos.x - rcPlate.left),
- point.y - (m_ptScrollPos.y + fPadding - rcPlate.top));
+ return CFX_FloatPoint(point.x - (m_ptScrollPos.x - rcPlate.left),
+ point.y - (m_ptScrollPos.y + fPadding - rcPlate.top));
}
-CPDF_Point CFX_Edit::EditToVT(const CPDF_Point& point) const {
- CPDF_Rect rcContent = m_pVT->GetContentRect();
- CPDF_Rect rcPlate = m_pVT->GetPlateRect();
+CFX_FloatPoint CFX_Edit::EditToVT(const CFX_FloatPoint& point) const {
+ CFX_FloatRect rcContent = m_pVT->GetContentRect();
+ CFX_FloatRect rcPlate = m_pVT->GetPlateRect();
FX_FLOAT fPadding = 0.0f;
@@ -1791,28 +1791,32 @@ CPDF_Point CFX_Edit::EditToVT(const CPDF_Point& point) const {
break;
}
- return CPDF_Point(point.x + (m_ptScrollPos.x - rcPlate.left),
- point.y + (m_ptScrollPos.y + fPadding - rcPlate.top));
+ return CFX_FloatPoint(point.x + (m_ptScrollPos.x - rcPlate.left),
+ point.y + (m_ptScrollPos.y + fPadding - rcPlate.top));
}
-CPDF_Rect CFX_Edit::VTToEdit(const CPDF_Rect& rect) const {
- CPDF_Point ptLeftBottom = VTToEdit(CPDF_Point(rect.left, rect.bottom));
- CPDF_Point ptRightTop = VTToEdit(CPDF_Point(rect.right, rect.top));
+CFX_FloatRect CFX_Edit::VTToEdit(const CFX_FloatRect& rect) const {
+ CFX_FloatPoint ptLeftBottom =
+ VTToEdit(CFX_FloatPoint(rect.left, rect.bottom));
+ CFX_FloatPoint ptRightTop = VTToEdit(CFX_FloatPoint(rect.right, rect.top));
- return CPDF_Rect(ptLeftBottom.x, ptLeftBottom.y, ptRightTop.x, ptRightTop.y);
+ return CFX_FloatRect(ptLeftBottom.x, ptLeftBottom.y, ptRightTop.x,
+ ptRightTop.y);
}
-CPDF_Rect CFX_Edit::EditToVT(const CPDF_Rect& rect) const {
- CPDF_Point ptLeftBottom = EditToVT(CPDF_Point(rect.left, rect.bottom));
- CPDF_Point ptRightTop = EditToVT(CPDF_Point(rect.right, rect.top));
+CFX_FloatRect CFX_Edit::EditToVT(const CFX_FloatRect& rect) const {
+ CFX_FloatPoint ptLeftBottom =
+ EditToVT(CFX_FloatPoint(rect.left, rect.bottom));
+ CFX_FloatPoint ptRightTop = EditToVT(CFX_FloatPoint(rect.right, rect.top));
- return CPDF_Rect(ptLeftBottom.x, ptLeftBottom.y, ptRightTop.x, ptRightTop.y);
+ return CFX_FloatRect(ptLeftBottom.x, ptLeftBottom.y, ptRightTop.x,
+ ptRightTop.y);
}
void CFX_Edit::SetScrollInfo() {
if (m_bNotify && m_pNotify) {
- CPDF_Rect rcPlate = m_pVT->GetPlateRect();
- CPDF_Rect rcContent = m_pVT->GetContentRect();
+ CFX_FloatRect rcPlate = m_pVT->GetPlateRect();
+ CFX_FloatRect rcContent = m_pVT->GetContentRect();
if (!m_bNotifyFlag) {
m_bNotifyFlag = TRUE;
@@ -1868,21 +1872,21 @@ void CFX_Edit::SetScrollPosY(FX_FLOAT fy) {
}
}
-void CFX_Edit::SetScrollPos(const CPDF_Point& point) {
+void CFX_Edit::SetScrollPos(const CFX_FloatPoint& point) {
SetScrollPosX(point.x);
SetScrollPosY(point.y);
SetScrollLimit();
SetCaretInfo();
}
-CPDF_Point CFX_Edit::GetScrollPos() const {
+CFX_FloatPoint CFX_Edit::GetScrollPos() const {
return m_ptScrollPos;
}
void CFX_Edit::SetScrollLimit() {
if (m_pVT->IsValid()) {
- CPDF_Rect rcContent = m_pVT->GetContentRect();
- CPDF_Rect rcPlate = m_pVT->GetPlateRect();
+ CFX_FloatRect rcContent = m_pVT->GetContentRect();
+ CFX_FloatRect rcPlate = m_pVT->GetPlateRect();
if (rcPlate.Width() > rcContent.Width()) {
SetScrollPosX(rcPlate.left);
@@ -1912,8 +1916,8 @@ void CFX_Edit::ScrollToCaret() {
SetScrollLimit();
if (m_pVT->IsValid()) {
- CPDF_Point ptHead(0, 0);
- CPDF_Point ptFoot(0, 0);
+ CFX_FloatPoint ptHead(0, 0);
+ CFX_FloatPoint ptFoot(0, 0);
if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) {
pIterator->SetAt(m_wpCaret);
@@ -1933,10 +1937,10 @@ void CFX_Edit::ScrollToCaret() {
}
}
- CPDF_Point ptHeadEdit = VTToEdit(ptHead);
- CPDF_Point ptFootEdit = VTToEdit(ptFoot);
+ CFX_FloatPoint ptHeadEdit = VTToEdit(ptHead);
+ CFX_FloatPoint ptFootEdit = VTToEdit(ptFoot);
- CPDF_Rect rcPlate = m_pVT->GetPlateRect();
+ CFX_FloatRect rcPlate = m_pVT->GetPlateRect();
if (!FX_EDIT_IsFloatEqual(rcPlate.left, rcPlate.right)) {
if (FX_EDIT_IsFloatSmaller(ptHeadEdit.x, rcPlate.left) ||
@@ -2003,10 +2007,10 @@ void CFX_Edit::RefreshPushLineRects(const CPVT_WordRange& wr) {
if (lineinfo.lineplace.LineCmp(wpEnd) > 0)
break;
- CPDF_Rect rcLine(lineinfo.ptLine.x,
- lineinfo.ptLine.y + lineinfo.fLineDescent,
- lineinfo.ptLine.x + lineinfo.fLineWidth,
- lineinfo.ptLine.y + lineinfo.fLineAscent);
+ CFX_FloatRect rcLine(lineinfo.ptLine.x,
+ lineinfo.ptLine.y + lineinfo.fLineDescent,
+ lineinfo.ptLine.x + lineinfo.fLineWidth,
+ lineinfo.ptLine.y + lineinfo.fLineAscent);
m_Refresh.Push(CPVT_WordRange(lineinfo.lineplace, lineinfo.lineEnd),
VTToEdit(rcLine));
@@ -2038,17 +2042,17 @@ void CFX_Edit::RefreshPushRandomRects(const CPVT_WordRange& wr) {
if (place.LineCmp(wrTemp.BeginPos) == 0 ||
place.LineCmp(wrTemp.EndPos) == 0) {
- CPDF_Rect rcWord(wordinfo.ptWord.x,
- lineinfo.ptLine.y + lineinfo.fLineDescent,
- wordinfo.ptWord.x + wordinfo.fWidth,
- lineinfo.ptLine.y + lineinfo.fLineAscent);
+ CFX_FloatRect rcWord(wordinfo.ptWord.x,
+ lineinfo.ptLine.y + lineinfo.fLineDescent,
+ wordinfo.ptWord.x + wordinfo.fWidth,
+ lineinfo.ptLine.y + lineinfo.fLineAscent);
m_Refresh.AddRefresh(VTToEdit(rcWord));
} else {
- CPDF_Rect rcLine(lineinfo.ptLine.x,
- lineinfo.ptLine.y + lineinfo.fLineDescent,
- lineinfo.ptLine.x + lineinfo.fLineWidth,
- lineinfo.ptLine.y + lineinfo.fLineAscent);
+ CFX_FloatRect rcLine(lineinfo.ptLine.x,
+ lineinfo.ptLine.y + lineinfo.fLineDescent,
+ lineinfo.ptLine.x + lineinfo.fLineWidth,
+ lineinfo.ptLine.y + lineinfo.fLineAscent);
m_Refresh.AddRefresh(VTToEdit(rcLine));
@@ -2081,29 +2085,29 @@ void CFX_Edit::RefreshWordRange(const CPVT_WordRange& wr) {
if (place.LineCmp(wrTemp.BeginPos) == 0 ||
place.LineCmp(wrTemp.EndPos) == 0) {
- CPDF_Rect rcWord(wordinfo.ptWord.x,
- lineinfo.ptLine.y + lineinfo.fLineDescent,
- wordinfo.ptWord.x + wordinfo.fWidth,
- lineinfo.ptLine.y + lineinfo.fLineAscent);
+ CFX_FloatRect rcWord(wordinfo.ptWord.x,
+ lineinfo.ptLine.y + lineinfo.fLineDescent,
+ wordinfo.ptWord.x + wordinfo.fWidth,
+ lineinfo.ptLine.y + lineinfo.fLineAscent);
if (m_bNotify && m_pNotify) {
if (!m_bNotifyFlag) {
m_bNotifyFlag = TRUE;
- CPDF_Rect rcRefresh = VTToEdit(rcWord);
+ CFX_FloatRect rcRefresh = VTToEdit(rcWord);
m_pNotify->IOnInvalidateRect(&rcRefresh);
m_bNotifyFlag = FALSE;
}
}
} else {
- CPDF_Rect rcLine(lineinfo.ptLine.x,
- lineinfo.ptLine.y + lineinfo.fLineDescent,
- lineinfo.ptLine.x + lineinfo.fLineWidth,
- lineinfo.ptLine.y + lineinfo.fLineAscent);
+ CFX_FloatRect rcLine(lineinfo.ptLine.x,
+ lineinfo.ptLine.y + lineinfo.fLineDescent,
+ lineinfo.ptLine.x + lineinfo.fLineWidth,
+ lineinfo.ptLine.y + lineinfo.fLineAscent);
if (m_bNotify && m_pNotify) {
if (!m_bNotifyFlag) {
m_bNotifyFlag = TRUE;
- CPDF_Rect rcRefresh = VTToEdit(rcLine);
+ CFX_FloatRect rcRefresh = VTToEdit(rcLine);
m_pNotify->IOnInvalidateRect(&rcRefresh);
m_bNotifyFlag = FALSE;
}
@@ -2123,7 +2127,7 @@ void CFX_Edit::SetCaret(const CPVT_WordPlace& place) {
void CFX_Edit::SetCaretInfo() {
if (m_bNotify && m_pNotify) {
if (!m_bNotifyFlag) {
- CPDF_Point ptHead(0.0f, 0.0f), ptFoot(0.0f, 0.0f);
+ CFX_FloatPoint ptHead(0.0f, 0.0f), ptFoot(0.0f, 0.0f);
if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) {
pIterator->SetAt(m_wpCaret);
@@ -2195,7 +2199,7 @@ void CFX_Edit::SetCaret(int32_t nPos) {
}
}
-void CFX_Edit::OnMouseDown(const CPDF_Point& point,
+void CFX_Edit::OnMouseDown(const CFX_FloatPoint& point,
FX_BOOL bShift,
FX_BOOL bCtrl) {
if (m_pVT->IsValid()) {
@@ -2209,7 +2213,7 @@ void CFX_Edit::OnMouseDown(const CPDF_Point& point,
}
}
-void CFX_Edit::OnMouseMove(const CPDF_Point& point,
+void CFX_Edit::OnMouseMove(const CFX_FloatPoint& point,
FX_BOOL bShift,
FX_BOOL bCtrl) {
if (m_pVT->IsValid()) {
@@ -2853,8 +2857,8 @@ FX_BOOL CFX_Edit::IsTextFull() const {
FX_BOOL CFX_Edit::IsTextOverflow() const {
if (!m_bEnableScroll && !m_bEnableOverflow) {
- CPDF_Rect rcPlate = m_pVT->GetPlateRect();
- CPDF_Rect rcContent = m_pVT->GetContentRect();
+ CFX_FloatRect rcPlate = m_pVT->GetPlateRect();
+ CFX_FloatRect rcContent = m_pVT->GetContentRect();
if (m_pVT->IsMultiLine() && GetTotalLines() > 1) {
if (FX_EDIT_IsFloatBigger(rcContent.Height(), rcPlate.Height()))