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

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

Issue 2556873004: Convert GetWidgetRect to return rect. (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/core/cfwl_widget.cpp ('k') | xfa/fxfa/app/xfa_ffbarcode.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_widgetmgr.h" 7 #include "xfa/fwl/core/cfwl_widgetmgr.h"
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
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* pRect) {
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 rect(*pRect);
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; 160 CFX_RectF rtTemp = pNative->GetWidgetRect();
161 pNative->GetWidgetRect(rtTemp, false);
162 rect.left += rtTemp.left; 161 rect.left += rtTemp.left;
163 rect.top += rtTemp.top; 162 rect.top += rtTemp.top;
164 pNative = pOuter; 163 pNative = pOuter;
165 pOuter = pOuter->GetOuter(); 164 pOuter = pOuter->GetOuter();
166 } 165 }
167 } else if (!IsAbleNative(pWidget)) { 166 } else if (!IsAbleNative(pWidget)) {
168 pNative = GetSystemFormWidget(pWidget); 167 pNative = GetSystemFormWidget(pWidget);
169 if (!pNative) 168 if (!pNative)
170 return; 169 return;
171 170
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 while (child) { 296 while (child) {
298 if ((child->GetStates() & FWL_WGTSTATE_Invisible) == 0) { 297 if ((child->GetStates() & FWL_WGTSTATE_Invisible) == 0) {
299 x1 = x; 298 x1 = x;
300 y1 = y; 299 y1 = y;
301 CFX_Matrix matrixOnParent; 300 CFX_Matrix matrixOnParent;
302 child->GetMatrix(matrixOnParent, false); 301 child->GetMatrix(matrixOnParent, false);
303 CFX_Matrix m; 302 CFX_Matrix m;
304 m.SetIdentity(); 303 m.SetIdentity();
305 m.SetReverse(matrixOnParent); 304 m.SetReverse(matrixOnParent);
306 m.TransformPoint(x1, y1); 305 m.TransformPoint(x1, y1);
307 CFX_RectF bounds; 306 CFX_RectF bounds = child->GetWidgetRect();
308 child->GetWidgetRect(bounds, false);
309 if (bounds.Contains(x1, y1)) { 307 if (bounds.Contains(x1, y1)) {
310 x1 -= bounds.left; 308 x1 -= bounds.left;
311 y1 -= bounds.top; 309 y1 -= bounds.top;
312 return GetWidgetAtPoint(child, x1, y1); 310 return GetWidgetAtPoint(child, x1, y1);
313 } 311 }
314 } 312 }
315 child = GetPriorSiblingWidget(child); 313 child = GetPriorSiblingWidget(child);
316 } 314 }
317 return parent; 315 return parent;
318 } 316 }
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 #endif 464 #endif
467 } 465 }
468 466
469 void CFWL_WidgetMgr::OnDrawWidget(CFWL_Widget* pWidget, 467 void CFWL_WidgetMgr::OnDrawWidget(CFWL_Widget* pWidget,
470 CFX_Graphics* pGraphics, 468 CFX_Graphics* pGraphics,
471 const CFX_Matrix* pMatrix) { 469 const CFX_Matrix* pMatrix) {
472 if (!pWidget || !pGraphics) 470 if (!pWidget || !pGraphics)
473 return; 471 return;
474 472
475 CFX_Graphics* pTemp = DrawWidgetBefore(pWidget, pGraphics, pMatrix); 473 CFX_Graphics* pTemp = DrawWidgetBefore(pWidget, pGraphics, pMatrix);
476 CFX_RectF clipCopy; 474 CFX_RectF clipCopy = pWidget->GetWidgetRect();
477 pWidget->GetWidgetRect(clipCopy, false);
478 clipCopy.left = clipCopy.top = 0; 475 clipCopy.left = clipCopy.top = 0;
479 476
480 if (UseOffscreenDirect(pWidget)) { 477 if (UseOffscreenDirect(pWidget)) {
481 DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix); 478 DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix);
482 return; 479 return;
483 } 480 }
484 CFX_RectF clipBounds; 481 CFX_RectF clipBounds;
485 482
486 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ || \ 483 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ || \
487 _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_ANDROID_ 484 _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_ANDROID_
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 return; 517 return;
521 518
522 bool bFormDisable = IsFormDisabled(); 519 bool bFormDisable = IsFormDisabled();
523 CFWL_Widget* pNextChild = GetFirstChildWidget(parent); 520 CFWL_Widget* pNextChild = GetFirstChildWidget(parent);
524 while (pNextChild) { 521 while (pNextChild) {
525 CFWL_Widget* child = pNextChild; 522 CFWL_Widget* child = pNextChild;
526 pNextChild = GetNextSiblingWidget(child); 523 pNextChild = GetNextSiblingWidget(child);
527 if (child->GetStates() & FWL_WGTSTATE_Invisible) 524 if (child->GetStates() & FWL_WGTSTATE_Invisible)
528 continue; 525 continue;
529 526
530 CFX_RectF rtWidget; 527 CFX_RectF rtWidget = child->GetWidgetRect();
531 child->GetWidgetRect(rtWidget, false);
532 if (rtWidget.IsEmpty()) 528 if (rtWidget.IsEmpty())
533 continue; 529 continue;
534 530
535 CFX_Matrix widgetMatrix; 531 CFX_Matrix widgetMatrix;
536 CFX_RectF clipBounds(rtWidget); 532 CFX_RectF clipBounds(rtWidget);
537 if (!bFormDisable) 533 if (!bFormDisable)
538 child->GetMatrix(widgetMatrix, true); 534 child->GetMatrix(widgetMatrix, true);
539 if (pMatrix) 535 if (pMatrix)
540 widgetMatrix.Concat(*pMatrix); 536 widgetMatrix.Concat(*pMatrix);
541 537
(...skipping 23 matching lines...) Expand all
565 561
566 CFX_Graphics* CFWL_WidgetMgr::DrawWidgetBefore(CFWL_Widget* pWidget, 562 CFX_Graphics* CFWL_WidgetMgr::DrawWidgetBefore(CFWL_Widget* pWidget,
567 CFX_Graphics* pGraphics, 563 CFX_Graphics* pGraphics,
568 const CFX_Matrix* pMatrix) { 564 const CFX_Matrix* pMatrix) {
569 if (!FWL_UseOffscreen(pWidget)) 565 if (!FWL_UseOffscreen(pWidget))
570 return pGraphics; 566 return pGraphics;
571 567
572 Item* pItem = GetWidgetMgrItem(pWidget); 568 Item* pItem = GetWidgetMgrItem(pWidget);
573 if (!pItem->pOffscreen) { 569 if (!pItem->pOffscreen) {
574 pItem->pOffscreen.reset(new CFX_Graphics); 570 pItem->pOffscreen.reset(new CFX_Graphics);
575 CFX_RectF rect; 571 CFX_RectF rect = pWidget->GetWidgetRect();
576 pWidget->GetWidgetRect(rect, false);
577 pItem->pOffscreen->Create((int32_t)rect.width, (int32_t)rect.height, 572 pItem->pOffscreen->Create((int32_t)rect.width, (int32_t)rect.height,
578 FXDIB_Argb); 573 FXDIB_Argb);
579 } 574 }
580 CFX_RectF rect; 575 CFX_RectF rect;
581 pGraphics->GetClipRect(rect); 576 pGraphics->GetClipRect(rect);
582 pItem->pOffscreen->SetClipRect(rect); 577 pItem->pOffscreen->SetClipRect(rect);
583 return pItem->pOffscreen.get(); 578 return pItem->pOffscreen.get();
584 } 579 }
585 580
586 void CFWL_WidgetMgr::DrawWidgetAfter(CFWL_Widget* pWidget, 581 void CFWL_WidgetMgr::DrawWidgetAfter(CFWL_Widget* pWidget,
(...skipping 14 matching lines...) Expand all
601 596
602 bool CFWL_WidgetMgr::IsNeedRepaint(CFWL_Widget* pWidget, 597 bool CFWL_WidgetMgr::IsNeedRepaint(CFWL_Widget* pWidget,
603 CFX_Matrix* pMatrix, 598 CFX_Matrix* pMatrix,
604 const CFX_RectF& rtDirty) { 599 const CFX_RectF& rtDirty) {
605 Item* pItem = GetWidgetMgrItem(pWidget); 600 Item* pItem = GetWidgetMgrItem(pWidget);
606 if (pItem && pItem->iRedrawCounter > 0) { 601 if (pItem && pItem->iRedrawCounter > 0) {
607 pItem->iRedrawCounter = 0; 602 pItem->iRedrawCounter = 0;
608 return true; 603 return true;
609 } 604 }
610 605
611 CFX_RectF rtWidget; 606 CFX_RectF rtWidget = pWidget->GetWidgetRect();
612 pWidget->GetWidgetRect(rtWidget, false);
613 rtWidget.left = rtWidget.top = 0; 607 rtWidget.left = rtWidget.top = 0;
614 pMatrix->TransformRect(rtWidget); 608 pMatrix->TransformRect(rtWidget);
615 if (!rtWidget.IntersectWith(rtDirty)) 609 if (!rtWidget.IntersectWith(rtDirty))
616 return false; 610 return false;
617 611
618 CFWL_Widget* pChild = 612 CFWL_Widget* pChild =
619 pWidget->GetOwnerApp()->GetWidgetMgr()->GetFirstChildWidget(pWidget); 613 pWidget->GetOwnerApp()->GetWidgetMgr()->GetFirstChildWidget(pWidget);
620 if (!pChild) 614 if (!pChild)
621 return true; 615 return true;
622 616
(...skipping 15 matching lines...) Expand all
638 hitPoint[5].hitPoint.x = hitPoint[9].hitPoint.x = 632 hitPoint[5].hitPoint.x = hitPoint[9].hitPoint.x =
639 rtWidget.width + rtWidget.left; 633 rtWidget.width + rtWidget.left;
640 hitPoint[0].hitPoint.y = hitPoint[1].hitPoint.y = rtWidget.top; 634 hitPoint[0].hitPoint.y = hitPoint[1].hitPoint.y = rtWidget.top;
641 hitPoint[2].hitPoint.y = hitPoint[3].hitPoint.y = hitPoint[4].hitPoint.y = 635 hitPoint[2].hitPoint.y = hitPoint[3].hitPoint.y = hitPoint[4].hitPoint.y =
642 hitPoint[5].hitPoint.y = fyPiece + rtWidget.top; 636 hitPoint[5].hitPoint.y = fyPiece + rtWidget.top;
643 hitPoint[6].hitPoint.y = hitPoint[7].hitPoint.y = hitPoint[8].hitPoint.y = 637 hitPoint[6].hitPoint.y = hitPoint[7].hitPoint.y = hitPoint[8].hitPoint.y =
644 hitPoint[9].hitPoint.y = fyPiece * 2 + rtWidget.top; 638 hitPoint[9].hitPoint.y = fyPiece * 2 + rtWidget.top;
645 hitPoint[10].hitPoint.y = hitPoint[11].hitPoint.y = 639 hitPoint[10].hitPoint.y = hitPoint[11].hitPoint.y =
646 rtWidget.height + rtWidget.top; 640 rtWidget.height + rtWidget.top;
647 do { 641 do {
648 CFX_RectF rect; 642 CFX_RectF rect = pChild->GetWidgetRect();
649 pChild->GetWidgetRect(rect, false);
650 CFX_RectF r = rect; 643 CFX_RectF r = rect;
651 r.left += rtWidget.left; 644 r.left += rtWidget.left;
652 r.top += rtWidget.top; 645 r.top += rtWidget.top;
653 if (r.IsEmpty()) 646 if (r.IsEmpty())
654 continue; 647 continue;
655 if (r.Contains(rtDirty)) 648 if (r.Contains(rtDirty))
656 return false; 649 return false;
657 if (!bChildIntersectWithDirty && r.IntersectWith(rtDirty)) 650 if (!bChildIntersectWithDirty && r.IntersectWith(rtDirty))
658 bChildIntersectWithDirty = true; 651 bChildIntersectWithDirty = true;
659 if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) 652 if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild)
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 return true; 692 return true;
700 } 693 }
701 694
702 bool CFWL_WidgetMgr::UseOffscreenDirect(CFWL_Widget* pWidget) const { 695 bool CFWL_WidgetMgr::UseOffscreenDirect(CFWL_Widget* pWidget) const {
703 Item* pItem = GetWidgetMgrItem(pWidget); 696 Item* pItem = GetWidgetMgrItem(pWidget);
704 if (!FWL_UseOffscreen(pWidget) || !(pItem->pOffscreen)) 697 if (!FWL_UseOffscreen(pWidget) || !(pItem->pOffscreen))
705 return false; 698 return false;
706 699
707 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) 700 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_)
708 if (pItem->bOutsideChanged) { 701 if (pItem->bOutsideChanged) {
709 CFX_RectF r; 702 CFX_RectF r = pWidget->GetWidgetRect();
710 pWidget->GetWidgetRect(r, false);
711 CFX_RectF temp(m_rtScreen); 703 CFX_RectF temp(m_rtScreen);
712 temp.Deflate(50, 50); 704 temp.Deflate(50, 50);
713 if (!temp.Contains(r)) 705 if (!temp.Contains(r))
714 return false; 706 return false;
715 707
716 pItem->bOutsideChanged = false; 708 pItem->bOutsideChanged = false;
717 } 709 }
718 #endif 710 #endif
719 711
720 return pItem->iRedrawCounter == 0; 712 return pItem->iRedrawCounter == 0;
(...skipping 10 matching lines...) Expand all
731 pWidget(widget), 723 pWidget(widget),
732 iRedrawCounter(0) 724 iRedrawCounter(0)
733 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) 725 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_)
734 , 726 ,
735 bOutsideChanged(false) 727 bOutsideChanged(false)
736 #endif 728 #endif
737 { 729 {
738 } 730 }
739 731
740 CFWL_WidgetMgr::Item::~Item() {} 732 CFWL_WidgetMgr::Item::~Item() {}
OLDNEW
« no previous file with comments | « xfa/fwl/core/cfwl_widget.cpp ('k') | xfa/fxfa/app/xfa_ffbarcode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698