Chromium Code Reviews| Index: xfa/fwl/core/cfwl_edit.cpp |
| diff --git a/xfa/fwl/core/cfwl_edit.cpp b/xfa/fwl/core/cfwl_edit.cpp |
| index 28ab71bac0ebc53f0ee0236ca94badaca5ddc668..751c88138979cc2b984f48d07eaf807f85e96a4a 100644 |
| --- a/xfa/fwl/core/cfwl_edit.cpp |
| +++ b/xfa/fwl/core/cfwl_edit.cpp |
| @@ -89,28 +89,27 @@ FWL_Type CFWL_Edit::GetClassID() const { |
| return FWL_Type::Edit; |
| } |
| -void CFWL_Edit::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { |
| - if (!bAutoSize) { |
| - rect = m_pProperties->m_rtWidget; |
| - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { |
| - if (IsShowScrollBar(true)) { |
| - FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>( |
| - GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); |
| - rect.width += *pfWidth; |
| - rect.width += kEditMargin; |
| - } |
| - if (IsShowScrollBar(false)) { |
| - FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>( |
| - GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); |
| - rect.height += *pfWidth; |
| - rect.height += kEditMargin; |
| - } |
| +CFX_RectF CFWL_Edit::GetWidgetRect() { |
| + CFX_RectF rect = m_pProperties->m_rtWidget; |
| + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { |
| + if (IsShowScrollBar(true)) { |
| + FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>( |
| + GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); |
| + rect.width += *pfWidth; |
| + rect.width += kEditMargin; |
| + } |
| + if (IsShowScrollBar(false)) { |
| + FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>( |
| + GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); |
| + rect.height += *pfWidth; |
| + rect.height += kEditMargin; |
| } |
| - return; |
| } |
| + return rect; |
| +} |
| - rect.Set(0, 0, 0, 0); |
| - |
| +CFX_RectF CFWL_Edit::GetAutosizedWidgetRect() { |
| + CFX_RectF rect; |
| int32_t iTextLen = m_EdtEngine.GetTextLength(); |
|
Tom Sepez
2016/12/07 21:53:20
nit: local needed?
dsinclair
2016/12/08 02:35:06
Done.
|
| if (iTextLen > 0) { |
| CFX_WideString wsText = m_EdtEngine.GetText(0, -1); |
| @@ -120,6 +119,7 @@ void CFWL_Edit::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { |
| rect.Set(0, 0, sz.x, sz.y); |
| } |
| InflateWidgetRect(rect); |
| + return rect; |
| } |
| void CFWL_Edit::SetStates(uint32_t dwStates) { |
| @@ -149,15 +149,11 @@ void CFWL_Edit::Update() { |
| FWL_WidgetHit CFWL_Edit::HitTest(FX_FLOAT fx, FX_FLOAT fy) { |
| if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { |
| if (IsShowScrollBar(true)) { |
| - CFX_RectF rect; |
| - m_pVertScrollBar->GetWidgetRect(rect, false); |
| - if (rect.Contains(fx, fy)) |
| + if (m_pVertScrollBar->GetWidgetRect().Contains(fx, fy)) |
|
Tom Sepez
2016/12/07 21:53:20
nice.
dsinclair
2016/12/08 02:35:06
Acknowledged.
|
| return FWL_WidgetHit::VScrollBar; |
| } |
| if (IsShowScrollBar(false)) { |
| - CFX_RectF rect; |
| - m_pHorzScrollBar->GetWidgetRect(rect, false); |
| - if (rect.Contains(fx, fy)) |
| + if (m_pHorzScrollBar->GetWidgetRect().Contains(fx, fy)) |
| return FWL_WidgetHit::HScrollBar; |
| } |
| } |
| @@ -428,7 +424,7 @@ void CFWL_Edit::OnCaretChanged() { |
| if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) { |
| CFWL_ScrollBar* pScroll = UpdateScroll(); |
| if (pScroll) { |
| - pScroll->GetWidgetRect(rtInvalid, false); |
| + rtInvalid = pScroll->GetWidgetRect(); |
| bRepaintScroll = true; |
| } |
| } |
| @@ -519,8 +515,7 @@ void CFWL_Edit::DrawTextBk(CFX_Graphics* pGraphics, |
| if (!IsShowScrollBar(true) || !IsShowScrollBar(false)) |
| return; |
| - CFX_RectF rtScroll; |
| - m_pHorzScrollBar->GetWidgetRect(rtScroll, false); |
| + CFX_RectF rtScroll = m_pHorzScrollBar->GetWidgetRect(); |
| CFX_RectF rtStatic; |
| rtStatic.Set(m_rtClient.right() - rtScroll.height, |
| @@ -903,8 +898,7 @@ CFWL_ScrollBar* CFWL_Edit::UpdateScroll() { |
| const CFX_RectF& rtFDE = pPage->GetContentsBox(); |
| CFWL_ScrollBar* pRepaint = nullptr; |
| if (bShowHorz) { |
| - CFX_RectF rtScroll; |
| - m_pHorzScrollBar->GetWidgetRect(rtScroll, false); |
| + CFX_RectF rtScroll = m_pHorzScrollBar->GetWidgetRect(); |
| if (rtScroll.width < rtFDE.width) { |
| m_pHorzScrollBar->LockUpdate(); |
| FX_FLOAT fRange = rtFDE.width - rtScroll.width; |
| @@ -930,8 +924,7 @@ CFWL_ScrollBar* CFWL_Edit::UpdateScroll() { |
| } |
| if (bShowVert) { |
| - CFX_RectF rtScroll; |
| - m_pVertScrollBar->GetWidgetRect(rtScroll, false); |
| + CFX_RectF rtScroll = m_pVertScrollBar->GetWidgetRect(); |
| if (rtScroll.height < rtFDE.height) { |
| m_pVertScrollBar->LockUpdate(); |
| FX_FLOAT fStep = m_EdtEngine.GetEditParams()->fLineSpace; |
| @@ -1180,8 +1173,7 @@ void CFWL_Edit::ShowCaret(CFX_RectF* pRect) { |
| while (pOuter->GetOuter()) { |
| pOuter = pOuter->GetOuter(); |
| - CFX_RectF rtOuter; |
| - pOuter->GetWidgetRect(rtOuter, false); |
| + CFX_RectF rtOuter = pOuter->GetWidgetRect(); |
| pRect->Offset(rtOuter.left, rtOuter.top); |
| } |
| @@ -1646,8 +1638,7 @@ bool CFWL_Edit::OnScroll(CFWL_ScrollBar* pScrollBar, |
| UpdateOffset(pScrollBar, fPos - iCurPos); |
| UpdateCaret(); |
| - CFX_RectF rect; |
| - GetWidgetRect(rect, false); |
| + CFX_RectF rect = GetWidgetRect(); |
| CFX_RectF rtInvalidate; |
| rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); |
| Repaint(&rtInvalidate); |