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

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

Issue 2564443003: Change CFWL_Widget::GetMatrix to return the matrix (Closed)
Patch Set: Re-add check 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
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/cfwl_widget.h" 7 #include "xfa/fwl/cfwl_widget.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 fy += szOffset.y; 188 fy += szOffset.y;
189 return; 189 return;
190 } 190 }
191 CFX_RectF r; 191 CFX_RectF r;
192 CFX_Matrix m; 192 CFX_Matrix m;
193 CFWL_Widget* parent = GetParent(); 193 CFWL_Widget* parent = GetParent();
194 if (parent) { 194 if (parent) {
195 r = GetWidgetRect(); 195 r = GetWidgetRect();
196 fx += r.left; 196 fx += r.left;
197 fy += r.top; 197 fy += r.top;
198 GetMatrix(m, true); 198 m = GetMatrix();
199 m.TransformPoint(fx, fy); 199 m.TransformPoint(fx, fy);
200 } 200 }
201 CFWL_Widget* form1 = m_pWidgetMgr->GetSystemFormWidget(this); 201 CFWL_Widget* form1 = m_pWidgetMgr->GetSystemFormWidget(this);
202 if (!form1) 202 if (!form1)
203 return; 203 return;
204 204
205 if (!pWidget) { 205 if (!pWidget) {
206 r = form1->GetWidgetRect(); 206 r = form1->GetWidgetRect();
207 fx += r.left; 207 fx += r.left;
208 fy += r.top; 208 fy += r.top;
209 return; 209 return;
210 } 210 }
211 CFWL_Widget* form2 = m_pWidgetMgr->GetSystemFormWidget(pWidget); 211 CFWL_Widget* form2 = m_pWidgetMgr->GetSystemFormWidget(pWidget);
212 if (!form2) 212 if (!form2)
213 return; 213 return;
214 if (form1 != form2) { 214 if (form1 != form2) {
215 r = form1->GetWidgetRect(); 215 r = form1->GetWidgetRect();
216 fx += r.left; 216 fx += r.left;
217 fy += r.top; 217 fy += r.top;
218 r = form2->GetWidgetRect(); 218 r = form2->GetWidgetRect();
219 fx -= r.left; 219 fx -= r.left;
220 fy -= r.top; 220 fy -= r.top;
221 } 221 }
222 parent = pWidget->GetParent(); 222 parent = pWidget->GetParent();
223 if (parent) { 223 if (parent) {
224 pWidget->GetMatrix(m, true);
225 CFX_Matrix m1; 224 CFX_Matrix m1;
226 m1.SetIdentity(); 225 m1.SetReverse(pWidget->GetMatrix());
227 m1.SetReverse(m);
228 m1.TransformPoint(fx, fy); 226 m1.TransformPoint(fx, fy);
229 r = pWidget->GetWidgetRect(); 227 r = pWidget->GetWidgetRect();
230 fx -= r.left; 228 fx -= r.left;
231 fy -= r.top; 229 fy -= r.top;
232 } 230 }
233 } 231 }
234 232
235 void CFWL_Widget::GetMatrix(CFX_Matrix& matrix, bool bGlobal) { 233 CFX_Matrix CFWL_Widget::GetMatrix() {
236 if (!m_pProperties) 234 if (!m_pProperties)
237 return; 235 return CFX_Matrix();
238 if (!bGlobal) {
Tom Sepez 2016/12/08 19:23:07 really? really? sigh.
239 matrix.SetIdentity();
240 return;
241 }
242 236
243 CFWL_Widget* parent = GetParent(); 237 CFWL_Widget* parent = GetParent();
244 CFX_ArrayTemplate<CFWL_Widget*> parents; 238 CFX_ArrayTemplate<CFWL_Widget*> parents;
245 while (parent) { 239 while (parent) {
246 parents.Add(parent); 240 parents.Add(parent);
247 parent = parent->GetParent(); 241 parent = parent->GetParent();
248 } 242 }
249 matrix.SetIdentity(); 243
244 CFX_Matrix matrix;
250 CFX_Matrix ctmOnParent; 245 CFX_Matrix ctmOnParent;
251 CFX_RectF rect; 246 CFX_RectF rect;
252 int32_t count = parents.GetSize(); 247 int32_t count = parents.GetSize();
253 for (int32_t i = count - 2; i >= 0; i--) { 248 for (int32_t i = count - 2; i >= 0; i--) {
254 parent = parents.GetAt(i); 249 parent = parents.GetAt(i);
255 parent->GetMatrix(ctmOnParent, false); 250
251 if (parent->m_pProperties)
252 ctmOnParent.SetIdentity();
256 rect = parent->GetWidgetRect(); 253 rect = parent->GetWidgetRect();
257 matrix.Concat(ctmOnParent, true); 254 matrix.Concat(ctmOnParent, true);
258 matrix.Translate(rect.left, rect.top, true); 255 matrix.Translate(rect.left, rect.top, true);
259 } 256 }
260 CFX_Matrix m; 257 CFX_Matrix m;
261 m.SetIdentity(); 258 m.SetIdentity();
262 matrix.Concat(m, true); 259 matrix.Concat(m, true);
263 parents.RemoveAll(); 260 parents.RemoveAll();
261
262 return matrix;
264 } 263 }
265 264
266 IFWL_ThemeProvider* CFWL_Widget::GetThemeProvider() const { 265 IFWL_ThemeProvider* CFWL_Widget::GetThemeProvider() const {
267 return m_pProperties->m_pThemeProvider; 266 return m_pProperties->m_pThemeProvider;
268 } 267 }
269 268
270 void CFWL_Widget::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { 269 void CFWL_Widget::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
271 m_pProperties->m_pThemeProvider = pThemeProvider; 270 m_pProperties->m_pThemeProvider = pThemeProvider;
272 } 271 }
273 272
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 } 706 }
708 default: 707 default:
709 break; 708 break;
710 } 709 }
711 } 710 }
712 711
713 void CFWL_Widget::OnProcessEvent(CFWL_Event* pEvent) {} 712 void CFWL_Widget::OnProcessEvent(CFWL_Event* pEvent) {}
714 713
715 void CFWL_Widget::OnDrawWidget(CFX_Graphics* pGraphics, 714 void CFWL_Widget::OnDrawWidget(CFX_Graphics* pGraphics,
716 const CFX_Matrix* pMatrix) {} 715 const CFX_Matrix* pMatrix) {}
OLDNEW
« xfa/fwl/cfwl_widget.h ('K') | « xfa/fwl/cfwl_widget.h ('k') | xfa/fwl/cfwl_widgetmgr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698