From 1babeeed9c259b9d486b4cbee949253769d18fff Mon Sep 17 00:00:00 2001 From: dsinclair Date: Thu, 8 Dec 2016 19:45:00 -0800 Subject: Change CFWL_Widget::GetMatrix to return the matrix This CL switches to using a return value instead of an out parameter. The global flag was also removed and the call sites changed to just SetIdentity as appropriate. Review-Url: https://codereview.chromium.org/2564443003 --- xfa/fwl/cfwl_widget.cpp | 23 +++++++++++------------ xfa/fwl/cfwl_widget.h | 2 +- xfa/fwl/cfwl_widgetmgr.cpp | 3 +-- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/xfa/fwl/cfwl_widget.cpp b/xfa/fwl/cfwl_widget.cpp index 071e0ded8d..40b922395e 100644 --- a/xfa/fwl/cfwl_widget.cpp +++ b/xfa/fwl/cfwl_widget.cpp @@ -195,7 +195,7 @@ void CFWL_Widget::TransformTo(CFWL_Widget* pWidget, r = GetWidgetRect(); fx += r.left; fy += r.top; - GetMatrix(m, true); + m = GetMatrix(); m.TransformPoint(fx, fy); } CFWL_Widget* form1 = m_pWidgetMgr->GetSystemFormWidget(this); @@ -221,10 +221,8 @@ void CFWL_Widget::TransformTo(CFWL_Widget* pWidget, } parent = pWidget->GetParent(); if (parent) { - pWidget->GetMatrix(m, true); CFX_Matrix m1; - m1.SetIdentity(); - m1.SetReverse(m); + m1.SetReverse(pWidget->GetMatrix()); m1.TransformPoint(fx, fy); r = pWidget->GetWidgetRect(); fx -= r.left; @@ -232,13 +230,9 @@ void CFWL_Widget::TransformTo(CFWL_Widget* pWidget, } } -void CFWL_Widget::GetMatrix(CFX_Matrix& matrix, bool bGlobal) { +CFX_Matrix CFWL_Widget::GetMatrix() { if (!m_pProperties) - return; - if (!bGlobal) { - matrix.SetIdentity(); - return; - } + return CFX_Matrix(); CFWL_Widget* parent = GetParent(); CFX_ArrayTemplate parents; @@ -246,13 +240,16 @@ void CFWL_Widget::GetMatrix(CFX_Matrix& matrix, bool bGlobal) { parents.Add(parent); parent = parent->GetParent(); } - matrix.SetIdentity(); + + CFX_Matrix matrix; CFX_Matrix ctmOnParent; CFX_RectF rect; int32_t count = parents.GetSize(); for (int32_t i = count - 2; i >= 0; i--) { parent = parents.GetAt(i); - parent->GetMatrix(ctmOnParent, false); + + if (parent->m_pProperties) + ctmOnParent.SetIdentity(); rect = parent->GetWidgetRect(); matrix.Concat(ctmOnParent, true); matrix.Translate(rect.left, rect.top, true); @@ -261,6 +258,8 @@ void CFWL_Widget::GetMatrix(CFX_Matrix& matrix, bool bGlobal) { m.SetIdentity(); matrix.Concat(m, true); parents.RemoveAll(); + + return matrix; } IFWL_ThemeProvider* CFWL_Widget::GetThemeProvider() const { diff --git a/xfa/fwl/cfwl_widget.h b/xfa/fwl/cfwl_widget.h index 5046aab888..e2fce0e1ac 100644 --- a/xfa/fwl/cfwl_widget.h +++ b/xfa/fwl/cfwl_widget.h @@ -91,7 +91,7 @@ class CFWL_Widget : public IFWL_WidgetDelegate { } void TransformTo(CFWL_Widget* pWidget, FX_FLOAT& fx, FX_FLOAT& fy); - void GetMatrix(CFX_Matrix& matrix, bool bGlobal); + CFX_Matrix GetMatrix(); IFWL_ThemeProvider* GetThemeProvider() const; void SetDelegate(IFWL_WidgetDelegate* delegate) { m_pDelegate = delegate; } diff --git a/xfa/fwl/cfwl_widgetmgr.cpp b/xfa/fwl/cfwl_widgetmgr.cpp index f01c02b6b8..e7eca100cc 100644 --- a/xfa/fwl/cfwl_widgetmgr.cpp +++ b/xfa/fwl/cfwl_widgetmgr.cpp @@ -298,7 +298,6 @@ CFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(CFWL_Widget* parent, x1 = x; y1 = y; CFX_Matrix matrixOnParent; - child->GetMatrix(matrixOnParent, false); CFX_Matrix m; m.SetIdentity(); m.SetReverse(matrixOnParent); @@ -528,7 +527,7 @@ void CFWL_WidgetMgr::DrawChild(CFWL_Widget* parent, CFX_Matrix widgetMatrix; CFX_RectF clipBounds(rtWidget); if (!bFormDisable) - child->GetMatrix(widgetMatrix, true); + widgetMatrix = child->GetMatrix(); if (pMatrix) widgetMatrix.Concat(*pMatrix); -- cgit v1.2.3