Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(860)

Side by Side Diff: xfa/fwl/core/cfwl_widget.cpp

Issue 2556873004: Convert GetWidgetRect to return rect. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fwl/core/cfwl_widget.h ('k') | xfa/fwl/core/cfwl_widgetmgr.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fwl/core/cfwl_widget.h" 7 #include "xfa/fwl/core/cfwl_widget.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 CFWL_Widget::~CFWL_Widget() { 59 CFWL_Widget::~CFWL_Widget() {
60 NotifyDriver(); 60 NotifyDriver();
61 m_pWidgetMgr->RemoveWidget(this); 61 m_pWidgetMgr->RemoveWidget(this);
62 } 62 }
63 63
64 bool CFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const { 64 bool CFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const {
65 return false; 65 return false;
66 } 66 }
67 67
68 void CFWL_Widget::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { 68 CFX_RectF CFWL_Widget::GetWidgetRect(bool bAutoSize) {
69 if (!bAutoSize) { 69 if (!bAutoSize)
70 rect = m_pProperties->m_rtWidget; 70 return m_pProperties->m_rtWidget;
71 return; 71
72 } 72 CFX_RectF rect;
73 InflateWidgetRect(rect); 73 InflateWidgetRect(rect);
74 return rect;
74 } 75 }
75 76
76 void CFWL_Widget::InflateWidgetRect(CFX_RectF& rect) { 77 void CFWL_Widget::InflateWidgetRect(CFX_RectF& rect) {
77 if (HasEdge()) { 78 if (HasEdge()) {
78 FX_FLOAT fEdge = GetEdgeWidth(); 79 FX_FLOAT fEdge = GetEdgeWidth();
79 rect.Inflate(fEdge, fEdge); 80 rect.Inflate(fEdge, fEdge);
80 } 81 }
81 if (HasBorder()) { 82 if (HasBorder()) {
82 FX_FLOAT fBorder = GetBorderSize(true); 83 FX_FLOAT fBorder = GetBorderSize(true);
83 rect.Inflate(fBorder, fBorder); 84 rect.Inflate(fBorder, fBorder);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 szOffset.y = -szOffset.y; 195 szOffset.y = -szOffset.y;
195 } 196 }
196 fx += szOffset.x; 197 fx += szOffset.x;
197 fy += szOffset.y; 198 fy += szOffset.y;
198 return; 199 return;
199 } 200 }
200 CFX_RectF r; 201 CFX_RectF r;
201 CFX_Matrix m; 202 CFX_Matrix m;
202 CFWL_Widget* parent = GetParent(); 203 CFWL_Widget* parent = GetParent();
203 if (parent) { 204 if (parent) {
204 GetWidgetRect(r, false); 205 InflateWidgetRect(r);
205 fx += r.left; 206 fx += r.left;
206 fy += r.top; 207 fy += r.top;
207 GetMatrix(m, true); 208 GetMatrix(m, true);
208 m.TransformPoint(fx, fy); 209 m.TransformPoint(fx, fy);
209 } 210 }
210 CFWL_Widget* form1 = m_pWidgetMgr->GetSystemFormWidget(this); 211 CFWL_Widget* form1 = m_pWidgetMgr->GetSystemFormWidget(this);
211 if (!form1) 212 if (!form1)
212 return; 213 return;
214
213 if (!pWidget) { 215 if (!pWidget) {
214 form1->GetWidgetRect(r, false); 216 r = form1->GetWidgetRect(false);
215 fx += r.left; 217 fx += r.left;
216 fy += r.top; 218 fy += r.top;
217 return; 219 return;
218 } 220 }
219 CFWL_Widget* form2 = m_pWidgetMgr->GetSystemFormWidget(pWidget); 221 CFWL_Widget* form2 = m_pWidgetMgr->GetSystemFormWidget(pWidget);
220 if (!form2) 222 if (!form2)
221 return; 223 return;
222 if (form1 != form2) { 224 if (form1 != form2) {
223 form1->GetWidgetRect(r, false); 225 r = form1->GetWidgetRect(false);
224 fx += r.left; 226 fx += r.left;
225 fy += r.top; 227 fy += r.top;
226 form2->GetWidgetRect(r, false); 228 r = form2->GetWidgetRect(false);
227 fx -= r.left; 229 fx -= r.left;
228 fy -= r.top; 230 fy -= r.top;
229 } 231 }
230 parent = pWidget->GetParent(); 232 parent = pWidget->GetParent();
231 if (parent) { 233 if (parent) {
232 pWidget->GetMatrix(m, true); 234 pWidget->GetMatrix(m, true);
233 CFX_Matrix m1; 235 CFX_Matrix m1;
234 m1.SetIdentity(); 236 m1.SetIdentity();
235 m1.SetReverse(m); 237 m1.SetReverse(m);
236 m1.TransformPoint(fx, fy); 238 m1.TransformPoint(fx, fy);
237 pWidget->GetWidgetRect(r, false); 239 r = pWidget->GetWidgetRect(false);
dsinclair 2016/12/07 21:09:11 If pWidget isn't a subclass that overrides GetWidg
238 fx -= r.left; 240 fx -= r.left;
239 fy -= r.top; 241 fy -= r.top;
240 } 242 }
241 } 243 }
242 244
243 void CFWL_Widget::GetMatrix(CFX_Matrix& matrix, bool bGlobal) { 245 void CFWL_Widget::GetMatrix(CFX_Matrix& matrix, bool bGlobal) {
244 if (!m_pProperties) 246 if (!m_pProperties)
245 return; 247 return;
246 if (!bGlobal) { 248 if (!bGlobal) {
247 matrix.SetIdentity(); 249 matrix.SetIdentity();
248 return; 250 return;
249 } 251 }
250 252
251 CFWL_Widget* parent = GetParent(); 253 CFWL_Widget* parent = GetParent();
252 CFX_ArrayTemplate<CFWL_Widget*> parents; 254 CFX_ArrayTemplate<CFWL_Widget*> parents;
253 while (parent) { 255 while (parent) {
254 parents.Add(parent); 256 parents.Add(parent);
255 parent = parent->GetParent(); 257 parent = parent->GetParent();
256 } 258 }
257 matrix.SetIdentity(); 259 matrix.SetIdentity();
258 CFX_Matrix ctmOnParent; 260 CFX_Matrix ctmOnParent;
259 CFX_RectF rect; 261 CFX_RectF rect;
260 int32_t count = parents.GetSize(); 262 int32_t count = parents.GetSize();
261 for (int32_t i = count - 2; i >= 0; i--) { 263 for (int32_t i = count - 2; i >= 0; i--) {
262 parent = parents.GetAt(i); 264 parent = parents.GetAt(i);
263 parent->GetMatrix(ctmOnParent, false); 265 parent->GetMatrix(ctmOnParent, false);
264 parent->GetWidgetRect(rect, false); 266 rect = parent->GetWidgetRect(false);
dsinclair 2016/12/07 21:09:11 potential difference if parent is a subclass that
265 matrix.Concat(ctmOnParent, true); 267 matrix.Concat(ctmOnParent, true);
266 matrix.Translate(rect.left, rect.top, true); 268 matrix.Translate(rect.left, rect.top, true);
267 } 269 }
268 CFX_Matrix m; 270 CFX_Matrix m;
269 m.SetIdentity(); 271 m.SetIdentity();
270 matrix.Concat(m, true); 272 matrix.Concat(m, true);
271 parents.RemoveAll(); 273 parents.RemoveAll();
272 } 274 }
273 275
274 IFWL_ThemeProvider* CFWL_Widget::GetThemeProvider() const { 276 IFWL_ThemeProvider* CFWL_Widget::GetThemeProvider() const {
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 681
680 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); 682 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr();
681 if (!pWidgetMgr) 683 if (!pWidgetMgr)
682 return CFX_SizeF(); 684 return CFX_SizeF();
683 685
684 CFX_SizeF szRet(m_pProperties->m_rtWidget.left, 686 CFX_SizeF szRet(m_pProperties->m_rtWidget.left,
685 m_pProperties->m_rtWidget.top); 687 m_pProperties->m_rtWidget.top);
686 688
687 CFWL_Widget* pDstWidget = GetParent(); 689 CFWL_Widget* pDstWidget = GetParent();
688 while (pDstWidget && pDstWidget != pParent) { 690 while (pDstWidget && pDstWidget != pParent) {
689 CFX_RectF rtDst; 691 CFX_RectF rtDst = pDstWidget->GetWidgetRect(false);
690 pDstWidget->GetWidgetRect(rtDst, false);
691 szRet += CFX_SizeF(rtDst.left, rtDst.top); 692 szRet += CFX_SizeF(rtDst.left, rtDst.top);
692 pDstWidget = pWidgetMgr->GetParentWidget(pDstWidget); 693 pDstWidget = pWidgetMgr->GetParentWidget(pDstWidget);
693 } 694 }
694 return szRet; 695 return szRet;
695 } 696 }
696 697
697 bool CFWL_Widget::IsParent(CFWL_Widget* pParent) { 698 bool CFWL_Widget::IsParent(CFWL_Widget* pParent) {
698 CFWL_Widget* pUpWidget = GetParent(); 699 CFWL_Widget* pUpWidget = GetParent();
699 while (pUpWidget) { 700 while (pUpWidget) {
700 if (pUpWidget == pParent) 701 if (pUpWidget == pParent)
(...skipping 19 matching lines...) Expand all
720 } 721 }
721 default: 722 default:
722 break; 723 break;
723 } 724 }
724 } 725 }
725 726
726 void CFWL_Widget::OnProcessEvent(CFWL_Event* pEvent) {} 727 void CFWL_Widget::OnProcessEvent(CFWL_Event* pEvent) {}
727 728
728 void CFWL_Widget::OnDrawWidget(CFX_Graphics* pGraphics, 729 void CFWL_Widget::OnDrawWidget(CFX_Graphics* pGraphics,
729 const CFX_Matrix* pMatrix) {} 730 const CFX_Matrix* pMatrix) {}
OLDNEW
« no previous file with comments | « xfa/fwl/core/cfwl_widget.h ('k') | xfa/fwl/core/cfwl_widgetmgr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698