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

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

Issue 2560873005: Cleanup CFWL_Widget code to return CFX_RectFs where appropriate (Closed)
Patch Set: Review feedback 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/cfwl_widgetmgr.h ('k') | xfa/fxfa/app/xfa_fwladapter.h » ('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/cfwl_widgetmgr.h" 7 #include "xfa/fwl/cfwl_widgetmgr.h"
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 pChild->pNext = pItem; 141 pChild->pNext = pItem;
142 pItem->pPrevious = pChild; 142 pItem->pPrevious = pChild;
143 } else { 143 } else {
144 pItem->pParent->pChild = pItem; 144 pItem->pParent->pChild = pItem;
145 pItem->pPrevious = nullptr; 145 pItem->pPrevious = nullptr;
146 } 146 }
147 pItem->pNext = nullptr; 147 pItem->pNext = nullptr;
148 } 148 }
149 149
150 void CFWL_WidgetMgr::RepaintWidget(CFWL_Widget* pWidget, 150 void CFWL_WidgetMgr::RepaintWidget(CFWL_Widget* pWidget,
151 const CFX_RectF* pRect) { 151 const CFX_RectF& rect) {
152 if (!m_pAdapter) 152 if (!m_pAdapter)
153 return; 153 return;
154 154
155 CFWL_Widget* pNative = pWidget; 155 CFWL_Widget* pNative = pWidget;
156 CFX_RectF rect(*pRect); 156 CFX_RectF transformedRect = rect;
157 if (IsFormDisabled()) { 157 if (IsFormDisabled()) {
158 CFWL_Widget* pOuter = pWidget->GetOuter(); 158 CFWL_Widget* pOuter = pWidget->GetOuter();
159 while (pOuter) { 159 while (pOuter) {
160 CFX_RectF rtTemp = pNative->GetWidgetRect(); 160 CFX_RectF rtTemp = pNative->GetWidgetRect();
161 rect.left += rtTemp.left; 161 transformedRect.left += rtTemp.left;
162 rect.top += rtTemp.top; 162 transformedRect.top += rtTemp.top;
163 pNative = pOuter; 163 pNative = pOuter;
164 pOuter = pOuter->GetOuter(); 164 pOuter = pOuter->GetOuter();
165 } 165 }
166 } else if (!IsAbleNative(pWidget)) { 166 } else if (!IsAbleNative(pWidget)) {
167 pNative = GetSystemFormWidget(pWidget); 167 pNative = GetSystemFormWidget(pWidget);
168 if (!pNative) 168 if (!pNative)
169 return; 169 return;
170 170
171 pWidget->TransformTo(pNative, rect.left, rect.top); 171 pWidget->TransformTo(pNative, transformedRect.left, transformedRect.top);
172 } 172 }
173 AddRedrawCounts(pNative); 173 AddRedrawCounts(pNative);
174 m_pAdapter->RepaintWidget(pNative, &rect); 174 m_pAdapter->RepaintWidget(pNative);
175 } 175 }
176 176
177 void CFWL_WidgetMgr::InsertWidget(CFWL_Widget* pParent, CFWL_Widget* pChild) { 177 void CFWL_WidgetMgr::InsertWidget(CFWL_Widget* pParent, CFWL_Widget* pChild) {
178 Item* pParentItem = GetWidgetMgrItem(pParent); 178 Item* pParentItem = GetWidgetMgrItem(pParent);
179 if (!pParentItem) { 179 if (!pParentItem) {
180 auto item = pdfium::MakeUnique<Item>(pParent); 180 auto item = pdfium::MakeUnique<Item>(pParent);
181 pParentItem = item.get(); 181 pParentItem = item.get();
182 m_mapWidgetItem[pParent] = std::move(item); 182 m_mapWidgetItem[pParent] = std::move(item);
183 183
184 pParentItem->pParent = GetWidgetMgrItem(nullptr); 184 pParentItem->pParent = GetWidgetMgrItem(nullptr);
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 pWidget->GetDelegate()->OnDrawWidget(pTemp, pMatrix); 490 pWidget->GetDelegate()->OnDrawWidget(pTemp, pMatrix);
491 pGraphics->GetClipRect(clipBounds); 491 pGraphics->GetClipRect(clipBounds);
492 clipCopy = clipBounds; 492 clipCopy = clipBounds;
493 } else { 493 } else {
494 clipBounds.Set(pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d); 494 clipBounds.Set(pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d);
495 const_cast<CFX_Matrix*>(pMatrix)->SetIdentity(); // FIXME: const cast. 495 const_cast<CFX_Matrix*>(pMatrix)->SetIdentity(); // FIXME: const cast.
496 pWidget->GetDelegate()->OnDrawWidget(pTemp, pMatrix); 496 pWidget->GetDelegate()->OnDrawWidget(pTemp, pMatrix);
497 } 497 }
498 #endif // _FX_OS_ == _FX_MACOSX_ 498 #endif // _FX_OS_ == _FX_MACOSX_
499 499
500 if (!IsFormDisabled()) { 500 if (!IsFormDisabled())
501 CFX_RectF rtClient; 501 clipBounds.Intersect(pWidget->GetClientRect());
502 pWidget->GetClientRect(rtClient);
503 clipBounds.Intersect(rtClient);
504 }
505 if (!clipBounds.IsEmpty()) 502 if (!clipBounds.IsEmpty())
506 DrawChild(pWidget, clipBounds, pTemp, pMatrix); 503 DrawChild(pWidget, clipBounds, pTemp, pMatrix);
507 504
508 DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix); 505 DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix);
509 ResetRedrawCounts(pWidget); 506 ResetRedrawCounts(pWidget);
510 } 507 }
511 508
512 void CFWL_WidgetMgr::DrawChild(CFWL_Widget* parent, 509 void CFWL_WidgetMgr::DrawChild(CFWL_Widget* parent,
513 const CFX_RectF& rtClip, 510 const CFX_RectF& rtClip,
514 CFX_Graphics* pGraphics, 511 CFX_Graphics* pGraphics,
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 pWidget(widget), 720 pWidget(widget),
724 iRedrawCounter(0) 721 iRedrawCounter(0)
725 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) 722 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_)
726 , 723 ,
727 bOutsideChanged(false) 724 bOutsideChanged(false)
728 #endif 725 #endif
729 { 726 {
730 } 727 }
731 728
732 CFWL_WidgetMgr::Item::~Item() {} 729 CFWL_WidgetMgr::Item::~Item() {}
OLDNEW
« no previous file with comments | « xfa/fwl/cfwl_widgetmgr.h ('k') | xfa/fxfa/app/xfa_fwladapter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698