summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/cfx_systemhandler.cpp14
-rw-r--r--fpdfsdk/pdfwindow/PWL_EditCtrl.cpp35
-rw-r--r--fpdfsdk/pdfwindow/PWL_EditCtrl.h3
-rw-r--r--fpdfsdk/pdfwindow/PWL_Wnd.cpp19
-rw-r--r--fpdfsdk/pdfwindow/PWL_Wnd.h5
5 files changed, 22 insertions, 54 deletions
diff --git a/fpdfsdk/cfx_systemhandler.cpp b/fpdfsdk/cfx_systemhandler.cpp
index 966dd63d4c..8ccbd75fbf 100644
--- a/fpdfsdk/cfx_systemhandler.cpp
+++ b/fpdfsdk/cfx_systemhandler.cpp
@@ -46,14 +46,12 @@ void CFX_SystemHandler::InvalidateRect(CPDFSDK_Widget* widget, FX_RECT rect) {
CFX_Matrix device2page;
device2page.SetReverse(page2device);
- FX_FLOAT left = static_cast<FX_FLOAT>(rect.left);
- FX_FLOAT top = static_cast<FX_FLOAT>(rect.top);
- FX_FLOAT right = static_cast<FX_FLOAT>(rect.right);
- FX_FLOAT bottom = static_cast<FX_FLOAT>(rect.bottom);
- device2page.TransformPoint(left, top);
- device2page.TransformPoint(right, bottom);
-
- CFX_FloatRect rcPDF(left, bottom, right, top);
+ CFX_PointF left_top = device2page.Transform(CFX_PointF(
+ static_cast<FX_FLOAT>(rect.left), static_cast<FX_FLOAT>(rect.top)));
+ CFX_PointF right_bottom = device2page.Transform(CFX_PointF(
+ static_cast<FX_FLOAT>(rect.right), static_cast<FX_FLOAT>(rect.bottom)));
+
+ CFX_FloatRect rcPDF(left_top.x, right_bottom.y, right_bottom.x, left_top.y);
rcPDF.Normalize();
m_pFormFillEnv->Invalidate(pPage, rcPDF.left, rcPDF.top, rcPDF.right,
diff --git a/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp b/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp
index 64272e34c5..4921ab7a08 100644
--- a/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp
+++ b/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp
@@ -40,13 +40,7 @@ void CPWL_EditCtrl::OnCreated() {
bool CPWL_EditCtrl::IsWndHorV() {
CFX_Matrix mt = GetWindowMatrix();
- CFX_PointF point1(0, 1);
- CFX_PointF point2(1, 1);
-
- mt.TransformPoint(point1.x, point1.y);
- mt.TransformPoint(point2.x, point2.y);
-
- return point2.y == point1.y;
+ return mt.Transform(CFX_PointF(1, 1)).y == mt.Transform(CFX_PointF(0, 1)).y;
}
void CPWL_EditCtrl::SetCursor() {
@@ -328,37 +322,30 @@ void CPWL_EditCtrl::SetEditCaret(bool bVisible) {
CFX_PointF ptHead;
CFX_PointF ptFoot;
if (bVisible)
- GetCaretInfo(ptHead, ptFoot);
+ GetCaretInfo(&ptHead, &ptFoot);
CPVT_WordPlace wpTemp = m_pEdit->GetCaretWordPlace();
IOnSetCaret(bVisible, ptHead, ptFoot, wpTemp);
}
-void CPWL_EditCtrl::GetCaretInfo(CFX_PointF& ptHead, CFX_PointF& ptFoot) const {
+void CPWL_EditCtrl::GetCaretInfo(CFX_PointF* ptHead, CFX_PointF* ptFoot) const {
CFX_Edit_Iterator* pIterator = m_pEdit->GetIterator();
pIterator->SetAt(m_pEdit->GetCaret());
CPVT_Word word;
CPVT_Line line;
if (pIterator->GetWord(word)) {
- ptHead.x = word.ptWord.x + word.fWidth;
- ptHead.y = word.ptWord.y + word.fAscent;
- ptFoot.x = word.ptWord.x + word.fWidth;
- ptFoot.y = word.ptWord.y + word.fDescent;
+ ptHead->x = word.ptWord.x + word.fWidth;
+ ptHead->y = word.ptWord.y + word.fAscent;
+ ptFoot->x = word.ptWord.x + word.fWidth;
+ ptFoot->y = word.ptWord.y + word.fDescent;
} else if (pIterator->GetLine(line)) {
- ptHead.x = line.ptLine.x;
- ptHead.y = line.ptLine.y + line.fLineAscent;
- ptFoot.x = line.ptLine.x;
- ptFoot.y = line.ptLine.y + line.fLineDescent;
+ ptHead->x = line.ptLine.x;
+ ptHead->y = line.ptLine.y + line.fLineAscent;
+ ptFoot->x = line.ptLine.x;
+ ptFoot->y = line.ptLine.y + line.fLineDescent;
}
}
-void CPWL_EditCtrl::GetCaretPos(int32_t& x, int32_t& y) const {
- CFX_PointF ptHead;
- CFX_PointF ptFoot;
- GetCaretInfo(ptHead, ptFoot);
- PWLtoWnd(ptHead, x, y);
-}
-
void CPWL_EditCtrl::SetCaret(bool bVisible,
const CFX_PointF& ptHead,
const CFX_PointF& ptFoot) {
diff --git a/fpdfsdk/pdfwindow/PWL_EditCtrl.h b/fpdfsdk/pdfwindow/PWL_EditCtrl.h
index 8b65d4a7b5..498570b3b0 100644
--- a/fpdfsdk/pdfwindow/PWL_EditCtrl.h
+++ b/fpdfsdk/pdfwindow/PWL_EditCtrl.h
@@ -34,7 +34,6 @@ class CPWL_EditCtrl : public CPWL_Wnd {
~CPWL_EditCtrl() override;
CFX_FloatRect GetContentRect() const;
- void GetCaretPos(int32_t& x, int32_t& y) const;
CFX_WideString GetText() const;
void SetSel(int32_t nStartChar, int32_t nEndChar);
@@ -121,7 +120,7 @@ class CPWL_EditCtrl : public CPWL_Wnd {
void Delete();
void Backspace();
- void GetCaretInfo(CFX_PointF& ptHead, CFX_PointF& ptFoot) const;
+ void GetCaretInfo(CFX_PointF* ptHead, CFX_PointF* ptFoot) const;
void SetCaret(bool bVisible,
const CFX_PointF& ptHead,
const CFX_PointF& ptFoot);
diff --git a/fpdfsdk/pdfwindow/PWL_Wnd.cpp b/fpdfsdk/pdfwindow/PWL_Wnd.cpp
index cf573220b7..341ae7448f 100644
--- a/fpdfsdk/pdfwindow/PWL_Wnd.cpp
+++ b/fpdfsdk/pdfwindow/PWL_Wnd.cpp
@@ -849,14 +849,6 @@ CFX_Matrix CPWL_Wnd::GetWindowMatrix() const {
return mt;
}
-void CPWL_Wnd::PWLtoWnd(const CFX_PointF& point, int32_t& x, int32_t& y) const {
- CFX_Matrix mt = GetWindowMatrix();
- CFX_PointF pt = point;
- mt.TransformPoint(pt.x, pt.y);
- x = (int32_t)(pt.x + 0.5);
- y = (int32_t)(pt.y + 0.5);
-}
-
FX_RECT CPWL_Wnd::PWLtoWnd(const CFX_FloatRect& rect) const {
CFX_FloatRect rcTemp = rect;
CFX_Matrix mt = GetWindowMatrix();
@@ -867,12 +859,7 @@ FX_RECT CPWL_Wnd::PWLtoWnd(const CFX_FloatRect& rect) const {
CFX_PointF CPWL_Wnd::ChildToParent(const CFX_PointF& point) const {
CFX_Matrix mt = GetChildMatrix();
- if (mt.IsIdentity())
- return point;
-
- CFX_PointF pt = point;
- mt.TransformPoint(pt.x, pt.y);
- return pt;
+ return mt.IsIdentity() ? point : mt.Transform(point);
}
CFX_FloatRect CPWL_Wnd::ChildToParent(const CFX_FloatRect& rect) const {
@@ -891,9 +878,7 @@ CFX_PointF CPWL_Wnd::ParentToChild(const CFX_PointF& point) const {
return point;
mt.SetReverse(mt);
- CFX_PointF pt = point;
- mt.TransformPoint(pt.x, pt.y);
- return pt;
+ return mt.Transform(point);
}
CFX_FloatRect CPWL_Wnd::ParentToChild(const CFX_FloatRect& rect) const {
diff --git a/fpdfsdk/pdfwindow/PWL_Wnd.h b/fpdfsdk/pdfwindow/PWL_Wnd.h
index 12b29aeb7e..92c099f9cd 100644
--- a/fpdfsdk/pdfwindow/PWL_Wnd.h
+++ b/fpdfsdk/pdfwindow/PWL_Wnd.h
@@ -389,9 +389,6 @@ class CPWL_Wnd : public CPWL_TimerHandler {
void InvalidateRectMove(const CFX_FloatRect& rcOld,
const CFX_FloatRect& rcNew);
- void PWLtoWnd(const CFX_PointF& point, int32_t& x, int32_t& y) const;
- FX_RECT PWLtoWnd(const CFX_FloatRect& rect) const;
-
bool IsWndCaptureMouse(const CPWL_Wnd* pWnd) const;
bool IsWndCaptureKeyboard(const CPWL_Wnd* pWnd) const;
const CPWL_Wnd* GetRootWnd() const;
@@ -401,6 +398,8 @@ class CPWL_Wnd : public CPWL_TimerHandler {
bool IsALTpressed(uint32_t nFlag) const;
private:
+ FX_RECT PWLtoWnd(const CFX_FloatRect& rect) const;
+
void AddChild(CPWL_Wnd* pWnd);
void RemoveChild(CPWL_Wnd* pWnd);