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

Unified Diff: xfa/fwl/cfwl_widget.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « xfa/fwl/cfwl_widget.h ('k') | xfa/fwl/cfwl_widgetmgr.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: xfa/fwl/cfwl_widget.cpp
diff --git a/xfa/fwl/cfwl_widget.cpp b/xfa/fwl/cfwl_widget.cpp
index 4da576423a411ffa7ad12c9f9e8bb318af369656..071e0ded8d260e5d3aaac2af527b7904833a3f87 100644
--- a/xfa/fwl/cfwl_widget.cpp
+++ b/xfa/fwl/cfwl_widget.cpp
@@ -92,12 +92,13 @@ void CFWL_Widget::SetWidgetRect(const CFX_RectF& rect) {
m_pWidgetMgr->SetWidgetRect_Native(this, rect);
}
-void CFWL_Widget::GetClientRect(CFX_RectF& rect) {
- GetEdgeRect(rect);
+CFX_RectF CFWL_Widget::GetClientRect() {
+ CFX_RectF rect = GetEdgeRect();
if (HasEdge()) {
FX_FLOAT fEdge = GetEdgeWidth();
rect.Deflate(fEdge, fEdge);
}
+ return rect;
}
void CFWL_Widget::SetParent(CFWL_Widget* pParent) {
@@ -162,22 +163,12 @@ void CFWL_Widget::RemoveStates(uint32_t dwStates) {
}
FWL_WidgetHit CFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
- CFX_RectF rtClient;
- GetClientRect(rtClient);
- if (rtClient.Contains(fx, fy))
+ if (GetClientRect().Contains(fx, fy))
return FWL_WidgetHit::Client;
- if (HasEdge()) {
- CFX_RectF rtEdge;
- GetEdgeRect(rtEdge);
- if (rtEdge.Contains(fx, fy))
- return FWL_WidgetHit::Edge;
- }
- if (HasBorder()) {
- CFX_RectF rtRelative;
- GetRelativeRect(rtRelative);
- if (rtRelative.Contains(fx, fy))
- return FWL_WidgetHit::Border;
- }
+ if (HasEdge() && GetEdgeRect().Contains(fx, fy))
+ return FWL_WidgetHit::Edge;
+ if (HasBorder() && GetRelativeRect().Contains(fx, fy))
+ return FWL_WidgetHit::Border;
return FWL_WidgetHit::Unknown;
}
@@ -317,14 +308,15 @@ bool CFWL_Widget::IsOffscreen() const {
return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Offscreen);
}
-void CFWL_Widget::GetEdgeRect(CFX_RectF& rtEdge) {
- rtEdge = m_pProperties->m_rtWidget;
+CFX_RectF CFWL_Widget::GetEdgeRect() {
+ CFX_RectF rtEdge = m_pProperties->m_rtWidget;
rtEdge.left = rtEdge.top = 0;
if (HasBorder()) {
FX_FLOAT fCX = GetBorderSize(true);
FX_FLOAT fCY = GetBorderSize(false);
rtEdge.Deflate(fCX, fCY);
}
+ return rtEdge;
}
FX_FLOAT CFWL_Widget::GetBorderSize(bool bCX) {
@@ -358,9 +350,11 @@ FX_FLOAT CFWL_Widget::GetEdgeWidth() {
return 0;
}
-void CFWL_Widget::GetRelativeRect(CFX_RectF& rect) {
- rect = m_pProperties->m_rtWidget;
- rect.left = rect.top = 0;
+CFX_RectF CFWL_Widget::GetRelativeRect() {
+ CFX_RectF rect = m_pProperties->m_rtWidget;
+ rect.left = 0;
+ rect.top = 0;
+ return rect;
}
void* CFWL_Widget::GetThemeCapacity(CFWL_WidgetCapacity dwCapacity) {
@@ -602,30 +596,29 @@ void CFWL_Widget::DispatchEvent(CFWL_Event* pEvent) {
pNoteDriver->SendEvent(pEvent);
}
-void CFWL_Widget::Repaint(const CFX_RectF* pRect) {
- if (pRect) {
- m_pWidgetMgr->RepaintWidget(this, pRect);
- return;
- }
+void CFWL_Widget::Repaint() {
CFX_RectF rect;
rect = m_pProperties->m_rtWidget;
- rect.left = rect.top = 0;
- m_pWidgetMgr->RepaintWidget(this, &rect);
+ rect.left = 0;
+ rect.top = 0;
+ RepaintRect(rect);
+}
+
+void CFWL_Widget::RepaintRect(const CFX_RectF& pRect) {
+ m_pWidgetMgr->RepaintWidget(this, pRect);
}
void CFWL_Widget::DrawBackground(CFX_Graphics* pGraphics,
CFWL_Part iPartBk,
IFWL_ThemeProvider* pTheme,
const CFX_Matrix* pMatrix) {
- CFX_RectF rtRelative;
- GetRelativeRect(rtRelative);
CFWL_ThemeBackground param;
param.m_pWidget = this;
param.m_iPart = iPartBk;
param.m_pGraphics = pGraphics;
if (pMatrix)
param.m_matrix.Concat(*pMatrix, true);
- param.m_rtPart = rtRelative;
+ param.m_rtPart = GetRelativeRect();
pTheme->DrawBackground(&param);
}
@@ -633,15 +626,13 @@ void CFWL_Widget::DrawBorder(CFX_Graphics* pGraphics,
CFWL_Part iPartBorder,
IFWL_ThemeProvider* pTheme,
const CFX_Matrix* pMatrix) {
- CFX_RectF rtRelative;
- GetRelativeRect(rtRelative);
CFWL_ThemeBackground param;
param.m_pWidget = this;
param.m_iPart = iPartBorder;
param.m_pGraphics = pGraphics;
if (pMatrix)
param.m_matrix.Concat(*pMatrix, true);
- param.m_rtPart = rtRelative;
+ param.m_rtPart = GetRelativeRect();
pTheme->DrawBackground(&param);
}
@@ -649,15 +640,13 @@ void CFWL_Widget::DrawEdge(CFX_Graphics* pGraphics,
CFWL_Part iPartEdge,
IFWL_ThemeProvider* pTheme,
const CFX_Matrix* pMatrix) {
- CFX_RectF rtEdge;
- GetEdgeRect(rtEdge);
CFWL_ThemeBackground param;
param.m_pWidget = this;
param.m_iPart = iPartEdge;
param.m_pGraphics = pGraphics;
if (pMatrix)
param.m_matrix.Concat(*pMatrix, true);
- param.m_rtPart = rtEdge;
+ param.m_rtPart = GetEdgeRect();
pTheme->DrawBackground(&param);
}
« no previous file with comments | « xfa/fwl/cfwl_widget.h ('k') | xfa/fwl/cfwl_widgetmgr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698