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

Unified Diff: xfa/fwl/core/cfwl_edit.cpp

Issue 2557103002: Cleanup FWL default values part II. (Closed)
Patch Set: Unused 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
Index: xfa/fwl/core/cfwl_edit.cpp
diff --git a/xfa/fwl/core/cfwl_edit.cpp b/xfa/fwl/core/cfwl_edit.cpp
index 035813c2f6608e40118666789a4c371304966751..a87d32d8b6286a62af4533271c6dc693bc745dda 100644
--- a/xfa/fwl/core/cfwl_edit.cpp
+++ b/xfa/fwl/core/cfwl_edit.cpp
@@ -113,7 +113,7 @@ void CFWL_Edit::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) {
int32_t iTextLen = m_EdtEngine.GetTextLength();
if (iTextLen > 0) {
- CFX_WideString wsText = m_EdtEngine.GetText(0);
+ CFX_WideString wsText = m_EdtEngine.GetText(0, -1);
CFX_SizeF sz = CalcTextSize(
wsText, m_pProperties->m_pThemeProvider,
!!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine));
@@ -298,16 +298,16 @@ int32_t CFWL_Edit::GetTextLength() const {
return m_EdtEngine.GetTextLength();
}
-CFX_WideString CFWL_Edit::GetText(int32_t nStart, int32_t nCount) const {
- return m_EdtEngine.GetText(nStart, nCount);
+CFX_WideString CFWL_Edit::GetText() const {
+ return m_EdtEngine.GetText(0, -1);
}
void CFWL_Edit::ClearText() {
m_EdtEngine.ClearText();
}
-void CFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) {
- m_EdtEngine.AddSelRange(nStart, nCount);
+void CFWL_Edit::AddSelRange(int32_t nStart) {
+ m_EdtEngine.AddSelRange(nStart, -1);
}
int32_t CFWL_Edit::CountSelRanges() const {
@@ -342,7 +342,8 @@ bool CFWL_Edit::Copy(CFX_WideString& wsCopy) {
wsCopy.clear();
CFX_WideString wsTemp;
- int32_t nStart, nLength;
+ int32_t nStart;
+ int32_t nLength;
for (int32_t i = 0; i < nCount; i++) {
nLength = m_EdtEngine.GetSelRange(i, nStart);
Tom Sepez 2016/12/07 17:33:32 nStart used uninitiaized? Or is it an out paramet
dsinclair 2016/12/07 18:28:49 Done. It was being passed as an int32_t&, changed
wsTemp = m_EdtEngine.GetText(nStart, nLength);
Tom Sepez 2016/12/07 17:33:32 wsTemp local to this block? Or eliminate
dsinclair 2016/12/07 18:28:49 Done.
@@ -417,9 +418,7 @@ void CFWL_Edit::SetOuter(CFWL_Widget* pOuter) {
m_pOuter = pOuter;
}
-void CFWL_Edit::On_CaretChanged(CFDE_TxtEdtEngine* pEdit,
- int32_t nPage,
- bool bVisible) {
+void CFWL_Edit::On_CaretChanged() {
if (m_rtEngine.IsEmpty())
return;
if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)
@@ -444,8 +443,7 @@ void CFWL_Edit::On_CaretChanged(CFDE_TxtEdtEngine* pEdit,
}
}
-void CFWL_Edit::On_TextChanged(CFDE_TxtEdtEngine* pEdit,
- FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) {
+void CFWL_Edit::On_TextChanged(FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) {
Tom Sepez 2016/12/07 17:33:32 nit: pass by const reference?
dsinclair 2016/12/07 18:28:49 Done.
if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VAlignMask)
UpdateVAlignment();
@@ -461,15 +459,13 @@ void CFWL_Edit::On_TextChanged(CFDE_TxtEdtEngine* pEdit,
Repaint(&rtTemp);
}
-void CFWL_Edit::On_SelChanged(CFDE_TxtEdtEngine* pEdit) {
+void CFWL_Edit::On_SelChanged() {
CFX_RectF rtTemp;
GetClientRect(rtTemp);
Repaint(&rtTemp);
}
-bool CFWL_Edit::On_PageLoad(CFDE_TxtEdtEngine* pEdit,
- int32_t nPageIndex,
- int32_t nPurpose) {
+bool CFWL_Edit::On_PageLoad(int32_t nPageIndex) {
IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(nPageIndex);
if (!pPage)
return false;
@@ -478,9 +474,7 @@ bool CFWL_Edit::On_PageLoad(CFDE_TxtEdtEngine* pEdit,
return true;
}
-bool CFWL_Edit::On_PageUnload(CFDE_TxtEdtEngine* pEdit,
- int32_t nPageIndex,
- int32_t nPurpose) {
+bool CFWL_Edit::On_PageUnload(int32_t nPageIndex) {
IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(nPageIndex);
if (!pPage)
return false;
@@ -489,12 +483,11 @@ bool CFWL_Edit::On_PageUnload(CFDE_TxtEdtEngine* pEdit,
return true;
}
-void CFWL_Edit::On_AddDoRecord(CFDE_TxtEdtEngine* pEdit,
- IFDE_TxtEdtDoRecord* pRecord) {
+void CFWL_Edit::On_AddDoRecord(IFDE_TxtEdtDoRecord* pRecord) {
AddDoRecord(pRecord);
}
-bool CFWL_Edit::On_Validate(CFDE_TxtEdtEngine* pEdit, CFX_WideString& wsText) {
+bool CFWL_Edit::On_Validate(CFX_WideString& wsText) {
Tom Sepez 2016/12/07 17:33:32 nit: pass by const reference?
dsinclair 2016/12/07 18:28:49 Done.
CFWL_Widget* pDst = GetOuter();
if (!pDst)
pDst = this;
@@ -1042,7 +1035,7 @@ void CFWL_Edit::Layout() {
bool bShowVertScrollbar = IsShowScrollBar(true);
bool bShowHorzScrollbar = IsShowScrollBar(false);
if (bShowVertScrollbar) {
- InitScrollBar();
+ InitVerticalScrollBar();
CFX_RectF rtVertScr;
if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
@@ -1064,7 +1057,7 @@ void CFWL_Edit::Layout() {
}
if (bShowHorzScrollbar) {
- InitScrollBar(false);
+ InitHorizontalScrollBar();
CFX_RectF rtHoriScr;
if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
@@ -1099,7 +1092,7 @@ void CFWL_Edit::LayoutScrollBar() {
pfWidth = static_cast<FX_FLOAT*>(
GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
FX_FLOAT fWidth = pfWidth ? *pfWidth : 0;
- InitScrollBar();
+ InitVerticalScrollBar();
CFX_RectF rtVertScr;
if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
rtVertScr.Set(m_rtClient.right() + kEditMargin, m_rtClient.top, fWidth,
@@ -1126,7 +1119,7 @@ void CFWL_Edit::LayoutScrollBar() {
}
FX_FLOAT fWidth = pfWidth ? *pfWidth : 0;
- InitScrollBar(false);
+ InitHorizontalScrollBar();
CFX_RectF rtHoriScr;
if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() + kEditMargin,
@@ -1153,21 +1146,30 @@ void CFWL_Edit::DeviceToEngine(CFX_PointF& pt) {
pt.y += m_fScrollOffsetY - m_rtEngine.top - m_fVAlignOffset;
}
-void CFWL_Edit::InitScrollBar(bool bVert) {
- if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar))
+void CFWL_Edit::InitVerticalScrollBar() {
+ if (m_pVertScrollBar)
return;
auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>();
- prop->m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz;
+ prop->m_dwStyleExes = FWL_STYLEEXT_SCB_Vert;
prop->m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible;
prop->m_pParent = this;
prop->m_pThemeProvider = m_pProperties->m_pThemeProvider;
+ m_pVertScrollBar =
+ pdfium::MakeUnique<CFWL_ScrollBar>(m_pOwnerApp, std::move(prop), this);
+}
- CFWL_ScrollBar* sb = new CFWL_ScrollBar(m_pOwnerApp, std::move(prop), this);
- if (bVert)
- m_pVertScrollBar.reset(sb);
- else
- m_pHorzScrollBar.reset(sb);
+void CFWL_Edit::InitHorizontalScrollBar() {
+ if (m_pHorzScrollBar)
+ return;
+
+ auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>();
+ prop->m_dwStyleExes = FWL_STYLEEXT_SCB_Horz;
+ prop->m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible;
+ prop->m_pParent = this;
+ prop->m_pThemeProvider = m_pProperties->m_pThemeProvider;
+ m_pHorzScrollBar =
+ pdfium::MakeUnique<CFWL_ScrollBar>(m_pOwnerApp, std::move(prop), this);
}
void CFWL_Edit::ShowCaret(CFX_RectF* pRect) {
@@ -1235,7 +1237,7 @@ bool CFWL_Edit::ValidateNumberChar(FX_WCHAR cNum) {
if (!m_bSetRange)
return true;
- CFX_WideString wsText = m_EdtEngine.GetText(0);
+ CFX_WideString wsText = m_EdtEngine.GetText(0, -1);
if (wsText.IsEmpty()) {
if (cNum == L'0')
return false;

Powered by Google App Engine
This is Rietveld 408576698