summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-02-21 12:56:24 -0500
committerChromium commit bot <commit-bot@chromium.org>2017-02-21 19:05:18 +0000
commit1f403cee9478021862c7cc4e516907bd51e8f0f6 (patch)
tree57829fa3b036ee9ddd57a8ad5b3541fe4e96fdb8
parent04557b8a7c2d3dab06fe9eadacc3c7744b3e14e2 (diff)
downloadpdfium-1f403cee9478021862c7cc4e516907bd51e8f0f6.tar.xz
Convert more TransformPoint calls to Transform
This Cl converts several uses of TransformPoint to use Transform(CFX_PointF). Change-Id: I9bc3c484e0a4304b904584218bd9e59dec7db727 Reviewed-on: https://pdfium-review.googlesource.com/2791 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
-rw-r--r--core/fpdfapi/page/cpdf_meshstream.cpp6
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp10
-rw-r--r--core/fxcrt/fx_basic_coords.cpp22
-rw-r--r--core/fxge/ge/cfx_pathdata.cpp18
-rw-r--r--core/fxge/ge/cfx_renderdevice.cpp13
-rw-r--r--core/fxge/win32/cfx_psrenderer.cpp22
-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
-rw-r--r--third_party/agg23/agg_rasterizer_scanline_aa.h7
-rw-r--r--xfa/fwl/cfwl_combolist.cpp18
-rw-r--r--xfa/fwl/cfwl_combolist.h2
-rw-r--r--xfa/fwl/cfwl_notedriver.cpp29
-rw-r--r--xfa/fwl/cfwl_widget.cpp106
-rw-r--r--xfa/fwl/cfwl_widget.h2
-rw-r--r--xfa/fwl/cfwl_widgetmgr.cpp24
-rw-r--r--xfa/fxfa/app/xfa_ffwidget.cpp12
-rw-r--r--xfa/fxfa/app/xfa_ffwidgethandler.cpp40
-rw-r--r--xfa/fxfa/xfa_ffwidget.h2
21 files changed, 185 insertions, 224 deletions
diff --git a/core/fpdfapi/page/cpdf_meshstream.cpp b/core/fpdfapi/page/cpdf_meshstream.cpp
index fbbd22276f..75069cab7f 100644
--- a/core/fpdfapi/page/cpdf_meshstream.cpp
+++ b/core/fpdfapi/page/cpdf_meshstream.cpp
@@ -214,8 +214,7 @@ CPDF_MeshVertex CPDF_MeshStream::ReadVertex(const CFX_Matrix& pObject2Bitmap,
*flag = ReadFlag();
CPDF_MeshVertex vertex;
- vertex.position = ReadCoords();
- pObject2Bitmap.TransformPoint(vertex.position.x, vertex.position.y);
+ vertex.position = pObject2Bitmap.Transform(ReadCoords());
std::tie(vertex.r, vertex.g, vertex.b) = ReadColor();
m_BitStream.ByteAlign();
@@ -229,8 +228,7 @@ bool CPDF_MeshStream::ReadVertexRow(const CFX_Matrix& pObject2Bitmap,
if (m_BitStream.IsEOF())
return false;
- vertex[i].position = ReadCoords();
- pObject2Bitmap.TransformPoint(vertex[i].position.x, vertex[i].position.y);
+ vertex[i].position = pObject2Bitmap.Transform(ReadCoords());
std::tie(vertex[i].r, vertex[i].g, vertex[i].b) = ReadColor();
m_BitStream.ByteAlign();
}
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 5a340cd8b1..b041a72662 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -2228,13 +2228,11 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern,
for (int col = min_col; col <= max_col; col++)
for (int row = min_row; row <= max_row; row++) {
- FX_FLOAT orig_x, orig_y;
- orig_x = col * pPattern->x_step();
- orig_y = row * pPattern->y_step();
- mtPattern2Device.TransformPoint(orig_x, orig_y);
+ CFX_PointF original = mtPattern2Device.Transform(
+ CFX_PointF(col * pPattern->x_step(), row * pPattern->y_step()));
CFX_Matrix matrix = *pObj2Device;
- matrix.Translate(orig_x - mtPattern2Device.e,
- orig_y - mtPattern2Device.f);
+ matrix.Translate(original.x - mtPattern2Device.e,
+ original.y - mtPattern2Device.f);
m_pDevice->SaveState();
CPDF_RenderStatus status;
status.Initialize(m_pContext, m_pDevice, nullptr, nullptr, this,
diff --git a/core/fxcrt/fx_basic_coords.cpp b/core/fxcrt/fx_basic_coords.cpp
index ea11acab6b..c9f3195f36 100644
--- a/core/fxcrt/fx_basic_coords.cpp
+++ b/core/fxcrt/fx_basic_coords.cpp
@@ -390,20 +390,20 @@ void CFX_Matrix::TransformRect(FX_FLOAT& left,
FX_FLOAT& right,
FX_FLOAT& top,
FX_FLOAT& bottom) const {
- FX_FLOAT x[4] = {left, left, right, right};
- FX_FLOAT y[4] = {top, bottom, top, bottom};
+ CFX_PointF points[] = {
+ {left, top}, {left, bottom}, {right, top}, {right, bottom}};
for (int i = 0; i < 4; i++)
- TransformPoint(x[i], y[i]);
+ points[i] = Transform(points[i]);
- right = x[0];
- left = x[0];
- top = y[0];
- bottom = y[0];
+ right = points[0].x;
+ left = points[0].x;
+ top = points[0].y;
+ bottom = points[0].y;
for (int i = 1; i < 4; i++) {
- right = std::max(right, x[i]);
- left = std::min(left, x[i]);
- top = std::max(top, y[i]);
- bottom = std::min(bottom, y[i]);
+ right = std::max(right, points[i].x);
+ left = std::min(left, points[i].x);
+ top = std::max(top, points[i].y);
+ bottom = std::min(bottom, points[i].y);
}
}
diff --git a/core/fxge/ge/cfx_pathdata.cpp b/core/fxge/ge/cfx_pathdata.cpp
index 11c421e468..e06eadd6ce 100644
--- a/core/fxge/ge/cfx_pathdata.cpp
+++ b/core/fxge/ge/cfx_pathdata.cpp
@@ -452,26 +452,24 @@ bool CFX_PathData::IsRect(const CFX_Matrix* pMatrix,
return false;
}
- FX_FLOAT x[5];
- FX_FLOAT y[5];
+ CFX_PointF points[5];
for (size_t i = 0; i < m_Points.size(); i++) {
- x[i] = m_Points[i].m_PointX;
- y[i] = m_Points[i].m_PointY;
- pMatrix->TransformPoint(x[i], y[i]);
+ points[i] = pMatrix->Transform(
+ CFX_PointF(m_Points[i].m_PointX, m_Points[i].m_PointY));
if (i == 0)
continue;
if (m_Points[i].m_Type != FXPT_TYPE::LineTo)
return false;
- if (x[i] != x[i - 1] && y[i] != y[i - 1])
+ if (points[i].x != points[i - 1].x && points[i].y != points[i - 1].y)
return false;
}
if (pRect) {
- pRect->left = x[0];
- pRect->right = x[2];
- pRect->bottom = y[0];
- pRect->top = y[2];
+ pRect->left = points[0].x;
+ pRect->right = points[2].x;
+ pRect->bottom = points[0].y;
+ pRect->top = points[2].y;
pRect->Normalize();
}
return true;
diff --git a/core/fxge/ge/cfx_renderdevice.cpp b/core/fxge/ge/cfx_renderdevice.cpp
index 86e74cafc4..203fecf061 100644
--- a/core/fxge/ge/cfx_renderdevice.cpp
+++ b/core/fxge/ge/cfx_renderdevice.cpp
@@ -490,15 +490,14 @@ bool CFX_RenderDevice::DrawPathWithBlend(const CFX_PathData* pPathData,
uint8_t fill_alpha = (fill_mode & 3) ? FXARGB_A(fill_color) : 0;
const std::vector<FX_PATHPOINT>& pPoints = pPathData->GetPoints();
if (stroke_alpha == 0 && pPoints.size() == 2) {
- FX_FLOAT x1 = pPoints[0].m_PointX;
- FX_FLOAT y1 = pPoints[0].m_PointY;
- FX_FLOAT x2 = pPoints[1].m_PointX;
- FX_FLOAT y2 = pPoints[1].m_PointY;
+ CFX_PointF pos1(pPoints[0].m_PointX, pPoints[0].m_PointY);
+ CFX_PointF pos2(pPoints[1].m_PointX, pPoints[1].m_PointY);
if (pObject2Device) {
- pObject2Device->TransformPoint(x1, y1);
- pObject2Device->TransformPoint(x2, y2);
+ pos1 = pObject2Device->Transform(pos1);
+ pos2 = pObject2Device->Transform(pos2);
}
- DrawCosmeticLine(x1, y1, x2, y2, fill_color, fill_mode, blend_type);
+ DrawCosmeticLine(pos1.x, pos1.y, pos2.x, pos2.y, fill_color, fill_mode,
+ blend_type);
return true;
}
diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp
index 32da090ed6..a0e675e23c 100644
--- a/core/fxge/win32/cfx_psrenderer.cpp
+++ b/core/fxge/win32/cfx_psrenderer.cpp
@@ -116,12 +116,11 @@ void CFX_PSRenderer::OutputPath(const CFX_PathData* pPathData,
for (size_t i = 0; i < size; i++) {
FXPT_TYPE type = pPathData->GetType(i);
bool closing = pPathData->IsClosingFigure(i);
- FX_FLOAT x = pPathData->GetPointX(i);
- FX_FLOAT y = pPathData->GetPointY(i);
+ CFX_PointF pos(pPathData->GetPointX(i), pPathData->GetPointY(i));
if (pObject2Device)
- pObject2Device->TransformPoint(x, y);
+ pos = pObject2Device->Transform(pos);
- buf << x << " " << y;
+ buf << pos.x << " " << pos.y;
switch (type) {
case FXPT_TYPE::MoveTo:
buf << " m ";
@@ -132,15 +131,16 @@ void CFX_PSRenderer::OutputPath(const CFX_PathData* pPathData,
buf << "h ";
break;
case FXPT_TYPE::BezierTo: {
- FX_FLOAT x1 = pPathData->GetPointX(i + 1);
- FX_FLOAT x2 = pPathData->GetPointX(i + 2);
- FX_FLOAT y1 = pPathData->GetPointY(i + 1);
- FX_FLOAT y2 = pPathData->GetPointY(i + 2);
+ CFX_PointF pos1(pPathData->GetPointX(i + 1),
+ pPathData->GetPointY(i + 1));
+ CFX_PointF pos2(pPathData->GetPointX(i + 2),
+ pPathData->GetPointY(i + 2));
if (pObject2Device) {
- pObject2Device->TransformPoint(x1, y1);
- pObject2Device->TransformPoint(x2, y2);
+ pos1 = pObject2Device->Transform(pos1);
+ pos2 = pObject2Device->Transform(pos2);
}
- buf << " " << x1 << " " << y1 << " " << x2 << " " << y2 << " c";
+ buf << " " << pos1.x << " " << pos1.y << " " << pos2.x << " " << pos2.y
+ << " c";
if (closing)
buf << " h";
buf << "\n";
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);
diff --git a/third_party/agg23/agg_rasterizer_scanline_aa.h b/third_party/agg23/agg_rasterizer_scanline_aa.h
index 3cf1822301..fc28290f54 100644
--- a/third_party/agg23/agg_rasterizer_scanline_aa.h
+++ b/third_party/agg23/agg_rasterizer_scanline_aa.h
@@ -390,8 +390,11 @@ public:
unsigned cmd;
vs.rewind(path_id);
while(!is_stop(cmd = vs.vertex(&x, &y))) {
- if (pMatrix)
- pMatrix->TransformPoint(x, y);
+ if (pMatrix) {
+ CFX_PointF ret = pMatrix->Transform(CFX_PointF(x, y));
+ x = ret.x;
+ y = ret.y;
+ }
add_vertex(x, y, cmd);
}
}
diff --git a/xfa/fwl/cfwl_combolist.cpp b/xfa/fwl/cfwl_combolist.cpp
index d411f03ca3..171b54121c 100644
--- a/xfa/fwl/cfwl_combolist.cpp
+++ b/xfa/fwl/cfwl_combolist.cpp
@@ -63,12 +63,11 @@ void CFWL_ComboList::ChangeSelected(int32_t iSel) {
RepaintRect(rtInvalidate);
}
-void CFWL_ComboList::ClientToOuter(FX_FLOAT& fx, FX_FLOAT& fy) {
- fx += m_pProperties->m_rtWidget.left, fy += m_pProperties->m_rtWidget.top;
+CFX_PointF CFWL_ComboList::ClientToOuter(const CFX_PointF& point) {
+ CFX_PointF ret = point + CFX_PointF(m_pProperties->m_rtWidget.left,
+ m_pProperties->m_rtWidget.top);
CFWL_Widget* pOwner = GetOwner();
- if (!pOwner)
- return;
- pOwner->TransformTo(m_pOuter, fx, fy);
+ return pOwner ? pOwner->TransformTo(m_pOuter, ret) : ret;
}
void CFWL_ComboList::OnProcessMessage(CFWL_Message* pMessage) {
@@ -148,7 +147,10 @@ void CFWL_ComboList::OnDropListMouseMove(CFWL_MessageMouse* pMsg) {
ChangeSelected(GetItemIndex(this, hItem));
} else if (m_bNotifyOwner) {
- ClientToOuter(pMsg->m_fx, pMsg->m_fy);
+ CFX_PointF point = ClientToOuter(CFX_PointF(pMsg->m_fx, pMsg->m_fy));
+ pMsg->m_fx = point.x;
+ pMsg->m_fy = point.y;
+
CFWL_ComboBox* pOuter = static_cast<CFWL_ComboBox*>(m_pOuter);
pOuter->GetDelegate()->OnProcessMessage(pMsg);
}
@@ -165,7 +167,9 @@ void CFWL_ComboList::OnDropListLButtonDown(CFWL_MessageMouse* pMsg) {
void CFWL_ComboList::OnDropListLButtonUp(CFWL_MessageMouse* pMsg) {
CFWL_ComboBox* pOuter = static_cast<CFWL_ComboBox*>(m_pOuter);
if (m_bNotifyOwner) {
- ClientToOuter(pMsg->m_fx, pMsg->m_fy);
+ CFX_PointF point = ClientToOuter(CFX_PointF(pMsg->m_fx, pMsg->m_fy));
+ pMsg->m_fx = point.x;
+ pMsg->m_fy = point.y;
pOuter->GetDelegate()->OnProcessMessage(pMsg);
return;
}
diff --git a/xfa/fwl/cfwl_combolist.h b/xfa/fwl/cfwl_combolist.h
index e1d5fd9b24..b7ba6b5780 100644
--- a/xfa/fwl/cfwl_combolist.h
+++ b/xfa/fwl/cfwl_combolist.h
@@ -29,7 +29,7 @@ class CFWL_ComboList : public CFWL_ListBox {
void SetNotifyOwner(bool notify) { m_bNotifyOwner = notify; }
private:
- void ClientToOuter(FX_FLOAT& fx, FX_FLOAT& fy);
+ CFX_PointF ClientToOuter(const CFX_PointF& point);
void OnDropListFocusChanged(CFWL_Message* pMsg, bool bSet);
void OnDropListMouseMove(CFWL_MessageMouse* pMsg);
void OnDropListLButtonDown(CFWL_MessageMouse* pMsg);
diff --git a/xfa/fwl/cfwl_notedriver.cpp b/xfa/fwl/cfwl_notedriver.cpp
index f4db9b14ab..6904759e59 100644
--- a/xfa/fwl/cfwl_notedriver.cpp
+++ b/xfa/fwl/cfwl_notedriver.cpp
@@ -341,8 +341,12 @@ bool CFWL_NoteDriver::DoMouse(CFWL_Message* pMessage,
pMsg->m_dwCmd == FWL_MouseCommand::Enter) {
return !!pMsg->m_pDstTarget;
}
- if (pMsg->m_pDstTarget != pMessageForm)
- pMsg->m_pDstTarget->TransformTo(pMessageForm, pMsg->m_fx, pMsg->m_fy);
+ if (pMsg->m_pDstTarget != pMessageForm) {
+ CFX_PointF point = pMsg->m_pDstTarget->TransformTo(
+ pMessageForm, CFX_PointF(pMsg->m_fx, pMsg->m_fy));
+ pMsg->m_fx = point.x;
+ pMsg->m_fy = point.y;
+ }
if (!DoMouseEx(pMsg, pMessageForm))
pMsg->m_pDstTarget = pMessageForm;
return true;
@@ -360,7 +364,10 @@ bool CFWL_NoteDriver::DoWheel(CFWL_Message* pMessage,
if (!pDst)
return false;
- pMessageForm->TransformTo(pDst, pMsg->m_fx, pMsg->m_fy);
+ CFX_PointF point =
+ pMessageForm->TransformTo(pDst, CFX_PointF(pMsg->m_fx, pMsg->m_fy));
+ pMsg->m_fx = point.x;
+ pMsg->m_fy = point.y;
pMsg->m_pDstTarget = pDst;
return true;
}
@@ -380,8 +387,12 @@ bool CFWL_NoteDriver::DoMouseEx(CFWL_Message* pMessage,
pWidgetMgr->GetWidgetAtPoint(pMessageForm, pMsg->m_fx, pMsg->m_fy);
}
if (pTarget) {
- if (pMessageForm != pTarget)
- pMessageForm->TransformTo(pTarget, pMsg->m_fx, pMsg->m_fy);
+ if (pMessageForm != pTarget) {
+ CFX_PointF point = pMessageForm->TransformTo(
+ pTarget, CFX_PointF(pMsg->m_fx, pMsg->m_fy));
+ pMsg->m_fx = point.x;
+ pMsg->m_fy = point.y;
+ }
}
if (!pTarget)
return false;
@@ -398,10 +409,10 @@ void CFWL_NoteDriver::MouseSecondary(CFWL_Message* pMessage) {
CFWL_MessageMouse* pMsg = static_cast<CFWL_MessageMouse*>(pMessage);
if (m_pHover) {
CFWL_MessageMouse msLeave(nullptr, m_pHover);
- msLeave.m_fx = pMsg->m_fx;
- msLeave.m_fy = pMsg->m_fy;
- pTarget->TransformTo(m_pHover, msLeave.m_fx, msLeave.m_fy);
-
+ CFX_PointF point =
+ pTarget->TransformTo(m_pHover, CFX_PointF(pMsg->m_fx, pMsg->m_fy));
+ msLeave.m_fx = point.x;
+ msLeave.m_fy = point.y;
msLeave.m_dwFlags = 0;
msLeave.m_dwCmd = FWL_MouseCommand::Leave;
DispatchMessage(&msLeave, nullptr);
diff --git a/xfa/fwl/cfwl_widget.cpp b/xfa/fwl/cfwl_widget.cpp
index e9c6ddc7d8..3462ea792a 100644
--- a/xfa/fwl/cfwl_widget.cpp
+++ b/xfa/fwl/cfwl_widget.cpp
@@ -159,9 +159,8 @@ FWL_WidgetHit CFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
return FWL_WidgetHit::Unknown;
}
-void CFWL_Widget::TransformTo(CFWL_Widget* pWidget,
- FX_FLOAT& fx,
- FX_FLOAT& fy) {
+CFX_PointF CFWL_Widget::TransformTo(CFWL_Widget* pWidget,
+ const CFX_PointF& point) {
if (m_pWidgetMgr->IsFormDisabled()) {
CFX_SizeF szOffset;
if (IsParent(pWidget)) {
@@ -171,50 +170,36 @@ void CFWL_Widget::TransformTo(CFWL_Widget* pWidget,
szOffset.width = -szOffset.width;
szOffset.height = -szOffset.height;
}
- fx += szOffset.width;
- fy += szOffset.height;
- return;
+ return point + CFX_PointF(szOffset.width, szOffset.height);
}
- CFX_RectF r;
- CFX_Matrix m;
+
+ CFX_PointF ret = point;
CFWL_Widget* parent = GetParent();
- if (parent) {
- r = GetWidgetRect();
- fx += r.left;
- fy += r.top;
- m = GetMatrix();
- m.TransformPoint(fx, fy);
- }
+ if (parent)
+ ret = GetMatrix().Transform(ret + GetWidgetRect().TopLeft());
+
CFWL_Widget* form1 = m_pWidgetMgr->GetSystemFormWidget(this);
if (!form1)
- return;
+ return ret;
+
+ if (!pWidget)
+ return ret + form1->GetWidgetRect().TopLeft();
- if (!pWidget) {
- r = form1->GetWidgetRect();
- fx += r.left;
- fy += r.top;
- return;
- }
CFWL_Widget* form2 = m_pWidgetMgr->GetSystemFormWidget(pWidget);
if (!form2)
- return;
+ return ret;
if (form1 != form2) {
- r = form1->GetWidgetRect();
- fx += r.left;
- fy += r.top;
- r = form2->GetWidgetRect();
- fx -= r.left;
- fy -= r.top;
+ ret += form1->GetWidgetRect().TopLeft();
+ ret -= form2->GetWidgetRect().TopLeft();
}
+
parent = pWidget->GetParent();
- if (parent) {
- CFX_Matrix m1;
- m1.SetReverse(pWidget->GetMatrix());
- m1.TransformPoint(fx, fy);
- r = pWidget->GetWidgetRect();
- fx -= r.left;
- fy -= r.top;
- }
+ if (!parent)
+ return ret;
+
+ CFX_Matrix m;
+ m.SetReverse(pWidget->GetMatrix());
+ return m.Transform(ret) - pWidget->GetWidgetRect().TopLeft();
}
CFX_Matrix CFWL_Widget::GetMatrix() {
@@ -419,32 +404,31 @@ bool CFWL_Widget::GetPopupPosMenu(FX_FLOAT fMinHeight,
FX_FLOAT fMaxHeight,
const CFX_RectF& rtAnchor,
CFX_RectF& rtPopup) {
- FX_FLOAT fx = 0;
- FX_FLOAT fy = 0;
-
if (GetStylesEx() & FWL_STYLEEXT_MNU_Vert) {
bool bLeft = m_pProperties->m_rtWidget.left < 0;
FX_FLOAT fRight = rtAnchor.right() + rtPopup.width;
- TransformTo(nullptr, fx, fy);
- if (fRight + fx > 0.0f || bLeft) {
+ CFX_PointF point = TransformTo(nullptr, CFX_PointF());
+ if (fRight + point.x > 0.0f || bLeft) {
rtPopup = CFX_RectF(rtAnchor.left - rtPopup.width, rtAnchor.top,
rtPopup.width, rtPopup.height);
} else {
rtPopup = CFX_RectF(rtAnchor.right(), rtAnchor.top, rtPopup.width,
rtPopup.height);
}
+ rtPopup.Offset(point.x, point.y);
+ return true;
+ }
+
+ FX_FLOAT fBottom = rtAnchor.bottom() + rtPopup.height;
+ CFX_PointF point = TransformTo(nullptr, point);
+ if (fBottom + point.y > 0.0f) {
+ rtPopup = CFX_RectF(rtAnchor.left, rtAnchor.top - rtPopup.height,
+ rtPopup.width, rtPopup.height);
} else {
- FX_FLOAT fBottom = rtAnchor.bottom() + rtPopup.height;
- TransformTo(nullptr, fx, fy);
- if (fBottom + fy > 0.0f) {
- rtPopup = CFX_RectF(rtAnchor.left, rtAnchor.top - rtPopup.height,
- rtPopup.width, rtPopup.height);
- } else {
- rtPopup = CFX_RectF(rtAnchor.left, rtAnchor.bottom(), rtPopup.width,
- rtPopup.height);
- }
+ rtPopup = CFX_RectF(rtAnchor.left, rtAnchor.bottom(), rtPopup.width,
+ rtPopup.height);
}
- rtPopup.Offset(fx, fy);
+ rtPopup.Offset(point.x, point.y);
return true;
}
@@ -452,9 +436,6 @@ bool CFWL_Widget::GetPopupPosComboBox(FX_FLOAT fMinHeight,
FX_FLOAT fMaxHeight,
const CFX_RectF& rtAnchor,
CFX_RectF& rtPopup) {
- FX_FLOAT fx = 0;
- FX_FLOAT fy = 0;
-
FX_FLOAT fPopHeight = rtPopup.height;
if (rtPopup.height > fMaxHeight)
fPopHeight = fMaxHeight;
@@ -463,15 +444,15 @@ bool CFWL_Widget::GetPopupPosComboBox(FX_FLOAT fMinHeight,
FX_FLOAT fWidth = std::max(rtAnchor.width, rtPopup.width);
FX_FLOAT fBottom = rtAnchor.bottom() + fPopHeight;
- TransformTo(nullptr, fx, fy);
- if (fBottom + fy > 0.0f) {
+ CFX_PointF point = TransformTo(nullptr, CFX_PointF());
+ if (fBottom + point.y > 0.0f) {
rtPopup =
CFX_RectF(rtAnchor.left, rtAnchor.top - fPopHeight, fWidth, fPopHeight);
} else {
rtPopup = CFX_RectF(rtAnchor.left, rtAnchor.bottom(), fWidth, fPopHeight);
}
- rtPopup.Offset(fx, fy);
+ rtPopup.Offset(point.x, point.y);
return true;
}
@@ -479,18 +460,15 @@ bool CFWL_Widget::GetPopupPosGeneral(FX_FLOAT fMinHeight,
FX_FLOAT fMaxHeight,
const CFX_RectF& rtAnchor,
CFX_RectF& rtPopup) {
- FX_FLOAT fx = 0;
- FX_FLOAT fy = 0;
-
- TransformTo(nullptr, fx, fy);
- if (rtAnchor.bottom() + fy > 0.0f) {
+ CFX_PointF point = TransformTo(nullptr, CFX_PointF());
+ if (rtAnchor.bottom() + point.y > 0.0f) {
rtPopup = CFX_RectF(rtAnchor.left, rtAnchor.top - rtPopup.height,
rtPopup.width, rtPopup.height);
} else {
rtPopup = CFX_RectF(rtAnchor.left, rtAnchor.bottom(), rtPopup.width,
rtPopup.height);
}
- rtPopup.Offset(fx, fy);
+ rtPopup.Offset(point.x, point.y);
return true;
}
diff --git a/xfa/fwl/cfwl_widget.h b/xfa/fwl/cfwl_widget.h
index 74fa314bfd..a375005970 100644
--- a/xfa/fwl/cfwl_widget.h
+++ b/xfa/fwl/cfwl_widget.h
@@ -90,7 +90,7 @@ class CFWL_Widget : public IFWL_WidgetDelegate {
m_iLock--;
}
- void TransformTo(CFWL_Widget* pWidget, FX_FLOAT& fx, FX_FLOAT& fy);
+ CFX_PointF TransformTo(CFWL_Widget* pWidget, const CFX_PointF& point);
CFX_Matrix GetMatrix();
IFWL_ThemeProvider* GetThemeProvider() const;
diff --git a/xfa/fwl/cfwl_widgetmgr.cpp b/xfa/fwl/cfwl_widgetmgr.cpp
index 0af93dc38b..ea4cbde230 100644
--- a/xfa/fwl/cfwl_widgetmgr.cpp
+++ b/xfa/fwl/cfwl_widgetmgr.cpp
@@ -160,7 +160,10 @@ void CFWL_WidgetMgr::RepaintWidget(CFWL_Widget* pWidget,
if (!pNative)
return;
- pWidget->TransformTo(pNative, transformedRect.left, transformedRect.top);
+ CFX_PointF pos = pWidget->TransformTo(
+ pNative, CFX_PointF(transformedRect.left, transformedRect.top));
+ transformedRect.left = pos.x;
+ transformedRect.top = pos.y;
}
AddRedrawCounts(pNative);
m_pAdapter->RepaintWidget(pNative);
@@ -260,24 +263,21 @@ CFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(CFWL_Widget* parent,
if (!parent)
return nullptr;
- FX_FLOAT x1;
- FX_FLOAT y1;
+ CFX_PointF pos;
CFWL_Widget* child = GetLastChildWidget(parent);
while (child) {
if ((child->GetStates() & FWL_WGTSTATE_Invisible) == 0) {
- x1 = x;
- y1 = y;
CFX_Matrix m;
m.SetIdentity();
CFX_Matrix matrixOnParent;
m.SetReverse(matrixOnParent);
- m.TransformPoint(x1, y1);
+ pos = m.Transform(CFX_PointF(x, y));
+
CFX_RectF bounds = child->GetWidgetRect();
- if (bounds.Contains(x1, y1)) {
- x1 -= bounds.left;
- y1 -= bounds.top;
- return GetWidgetAtPoint(child, x1, y1);
+ if (bounds.Contains(pos.x, pos.y)) {
+ pos -= bounds.TopLeft();
+ return GetWidgetAtPoint(child, pos.x, pos.y);
}
}
child = GetPriorSiblingWidget(child);
@@ -484,7 +484,9 @@ void CFWL_WidgetMgr::DrawChild(CFWL_Widget* parent,
widgetMatrix.Concat(*pMatrix);
if (!bFormDisable) {
- widgetMatrix.TransformPoint(clipBounds.left, clipBounds.top);
+ CFX_PointF pos = widgetMatrix.Transform(clipBounds.TopLeft());
+ clipBounds.left = pos.x;
+ clipBounds.top = pos.y;
clipBounds.Intersect(rtClip);
if (clipBounds.IsEmpty())
continue;
diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp
index 3ee0a3cbe8..7a8cc646dd 100644
--- a/xfa/fxfa/app/xfa_ffwidget.cpp
+++ b/xfa/fxfa/app/xfa_ffwidget.cpp
@@ -316,15 +316,17 @@ bool CXFA_FFWidget::ReplaceSpellCheckWord(CFX_PointF pointf,
const CFX_ByteStringC& bsReplace) {
return false;
}
-void CXFA_FFWidget::Rotate2Normal(FX_FLOAT& fx, FX_FLOAT& fy) {
+
+CFX_PointF CXFA_FFWidget::Rotate2Normal(const CFX_PointF& point) {
CFX_Matrix mt = GetRotateMatrix();
- if (mt.IsIdentity()) {
- return;
- }
+ if (mt.IsIdentity())
+ return point;
+
CFX_Matrix mtReverse;
mtReverse.SetReverse(mt);
- mtReverse.TransformPoint(fx, fy);
+ return mtReverse.Transform(point);
}
+
static void XFA_GetMatrix(CFX_Matrix& m,
int32_t iRotate,
XFA_ATTRIBUTEENUM at,
diff --git a/xfa/fxfa/app/xfa_ffwidgethandler.cpp b/xfa/fxfa/app/xfa_ffwidgethandler.cpp
index 551d8f6595..bbca0409d3 100644
--- a/xfa/fxfa/app/xfa_ffwidgethandler.cpp
+++ b/xfa/fxfa/app/xfa_ffwidgethandler.cpp
@@ -43,8 +43,8 @@ bool CXFA_FFWidgetHandler::OnLButtonDown(CXFA_FFWidget* hWidget,
FX_FLOAT fx,
FX_FLOAT fy) {
m_pDocView->LockUpdate();
- hWidget->Rotate2Normal(fx, fy);
- bool bRet = hWidget->OnLButtonDown(dwFlags, fx, fy);
+ CFX_PointF pos = hWidget->Rotate2Normal(CFX_PointF(fx, fy));
+ bool bRet = hWidget->OnLButtonDown(dwFlags, pos.x, pos.y);
if (bRet && m_pDocView->SetFocus(hWidget)) {
m_pDocView->GetDoc()->GetDocEnvironment()->SetFocusWidget(
m_pDocView->GetDoc(), hWidget);
@@ -59,9 +59,9 @@ bool CXFA_FFWidgetHandler::OnLButtonUp(CXFA_FFWidget* hWidget,
FX_FLOAT fx,
FX_FLOAT fy) {
m_pDocView->LockUpdate();
- hWidget->Rotate2Normal(fx, fy);
+ CFX_PointF pos = hWidget->Rotate2Normal(CFX_PointF(fx, fy));
m_pDocView->m_bLayoutEvent = true;
- bool bRet = hWidget->OnLButtonUp(dwFlags, fx, fy);
+ bool bRet = hWidget->OnLButtonUp(dwFlags, pos.x, pos.y);
m_pDocView->UnlockUpdate();
m_pDocView->UpdateDocView();
return bRet;
@@ -71,8 +71,8 @@ bool CXFA_FFWidgetHandler::OnLButtonDblClk(CXFA_FFWidget* hWidget,
uint32_t dwFlags,
FX_FLOAT fx,
FX_FLOAT fy) {
- hWidget->Rotate2Normal(fx, fy);
- bool bRet = hWidget->OnLButtonDblClk(dwFlags, fx, fy);
+ CFX_PointF pos = hWidget->Rotate2Normal(CFX_PointF(fx, fy));
+ bool bRet = hWidget->OnLButtonDblClk(dwFlags, pos.x, pos.y);
m_pDocView->RunInvalidate();
return bRet;
}
@@ -81,8 +81,8 @@ bool CXFA_FFWidgetHandler::OnMouseMove(CXFA_FFWidget* hWidget,
uint32_t dwFlags,
FX_FLOAT fx,
FX_FLOAT fy) {
- hWidget->Rotate2Normal(fx, fy);
- bool bRet = hWidget->OnMouseMove(dwFlags, fx, fy);
+ CFX_PointF pos = hWidget->Rotate2Normal(CFX_PointF(fx, fy));
+ bool bRet = hWidget->OnMouseMove(dwFlags, pos.x, pos.y);
m_pDocView->RunInvalidate();
return bRet;
}
@@ -92,8 +92,8 @@ bool CXFA_FFWidgetHandler::OnMouseWheel(CXFA_FFWidget* hWidget,
int16_t zDelta,
FX_FLOAT fx,
FX_FLOAT fy) {
- hWidget->Rotate2Normal(fx, fy);
- bool bRet = hWidget->OnMouseWheel(dwFlags, zDelta, fx, fy);
+ CFX_PointF pos = hWidget->Rotate2Normal(CFX_PointF(fx, fy));
+ bool bRet = hWidget->OnMouseWheel(dwFlags, zDelta, pos.x, pos.y);
m_pDocView->RunInvalidate();
return bRet;
}
@@ -102,8 +102,8 @@ bool CXFA_FFWidgetHandler::OnRButtonDown(CXFA_FFWidget* hWidget,
uint32_t dwFlags,
FX_FLOAT fx,
FX_FLOAT fy) {
- hWidget->Rotate2Normal(fx, fy);
- bool bRet = hWidget->OnRButtonDown(dwFlags, fx, fy);
+ CFX_PointF pos = hWidget->Rotate2Normal(CFX_PointF(fx, fy));
+ bool bRet = hWidget->OnRButtonDown(dwFlags, pos.x, pos.y);
if (bRet && m_pDocView->SetFocus(hWidget)) {
m_pDocView->GetDoc()->GetDocEnvironment()->SetFocusWidget(
m_pDocView->GetDoc(), hWidget);
@@ -116,8 +116,8 @@ bool CXFA_FFWidgetHandler::OnRButtonUp(CXFA_FFWidget* hWidget,
uint32_t dwFlags,
FX_FLOAT fx,
FX_FLOAT fy) {
- hWidget->Rotate2Normal(fx, fy);
- bool bRet = hWidget->OnRButtonUp(dwFlags, fx, fy);
+ CFX_PointF pos = hWidget->Rotate2Normal(CFX_PointF(fx, fy));
+ bool bRet = hWidget->OnRButtonUp(dwFlags, pos.x, pos.y);
m_pDocView->RunInvalidate();
return bRet;
}
@@ -126,8 +126,8 @@ bool CXFA_FFWidgetHandler::OnRButtonDblClk(CXFA_FFWidget* hWidget,
uint32_t dwFlags,
FX_FLOAT fx,
FX_FLOAT fy) {
- hWidget->Rotate2Normal(fx, fy);
- bool bRet = hWidget->OnRButtonDblClk(dwFlags, fx, fy);
+ CFX_PointF pos = hWidget->Rotate2Normal(CFX_PointF(fx, fy));
+ bool bRet = hWidget->OnRButtonDblClk(dwFlags, pos.x, pos.y);
m_pDocView->RunInvalidate();
return bRet;
}
@@ -163,15 +163,15 @@ FWL_WidgetHit CXFA_FFWidgetHandler::OnHitTest(CXFA_FFWidget* hWidget,
if (!(hWidget->GetStatus() & XFA_WidgetStatus_Visible))
return FWL_WidgetHit::Unknown;
- hWidget->Rotate2Normal(fx, fy);
- return hWidget->OnHitTest(fx, fy);
+ CFX_PointF pos = hWidget->Rotate2Normal(CFX_PointF(fx, fy));
+ return hWidget->OnHitTest(pos.x, pos.y);
}
bool CXFA_FFWidgetHandler::OnSetCursor(CXFA_FFWidget* hWidget,
FX_FLOAT fx,
FX_FLOAT fy) {
- hWidget->Rotate2Normal(fx, fy);
- return hWidget->OnSetCursor(fx, fy);
+ CFX_PointF pos = hWidget->Rotate2Normal(CFX_PointF(fx, fy));
+ return hWidget->OnSetCursor(pos.x, pos.y);
}
void CXFA_FFWidgetHandler::RenderWidget(CXFA_FFWidget* hWidget,
diff --git a/xfa/fxfa/xfa_ffwidget.h b/xfa/fxfa/xfa_ffwidget.h
index c7701d357e..57dfc639da 100644
--- a/xfa/fxfa/xfa_ffwidget.h
+++ b/xfa/fxfa/xfa_ffwidget.h
@@ -119,7 +119,7 @@ class CXFA_FFWidget : public CXFA_ContentLayoutItem {
void AddInvalidateRect(const CFX_RectF* pRect = nullptr);
bool GetCaptionText(CFX_WideString& wsCap);
bool IsFocused();
- void Rotate2Normal(FX_FLOAT& fx, FX_FLOAT& fy);
+ CFX_PointF Rotate2Normal(const CFX_PointF& point);
CFX_Matrix GetRotateMatrix();
bool IsLayoutRectEmpty();
CXFA_FFWidget* GetParent();