From 603f57b85c0643f0598f03b97c4525501f3e1221 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Wed, 14 Dec 2016 06:25:02 -0800 Subject: Update CFWL_ListBox to return instead of using out params. This CL updates the CFWL_ListBox code to work with return values instead of out params. This also extracts the CFWL_ListItem code out of CFWL_ListBox and puts into the correct class. Review-Url: https://codereview.chromium.org/2572783002 --- xfa/fwl/cfwl_combolist.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'xfa/fwl/cfwl_combolist.cpp') diff --git a/xfa/fwl/cfwl_combolist.cpp b/xfa/fwl/cfwl_combolist.cpp index 1fa9acb68e..e78372cb26 100644 --- a/xfa/fwl/cfwl_combolist.cpp +++ b/xfa/fwl/cfwl_combolist.cpp @@ -32,7 +32,7 @@ int32_t CFWL_ComboList::MatchItem(const CFX_WideString& wsMatch) { int32_t iCount = CountItems(this); for (int32_t i = 0; i < iCount; i++) { CFWL_ListItem* hItem = GetItem(this, i); - CFX_WideString wsText = GetItemText(this, hItem); + CFX_WideString wsText = hItem ? hItem->GetText() : L""; FX_STRSIZE pos = wsText.Find(wsMatch.c_str()); if (!pos) return i; @@ -42,22 +42,20 @@ int32_t CFWL_ComboList::MatchItem(const CFX_WideString& wsMatch) { void CFWL_ComboList::ChangeSelected(int32_t iSel) { CFWL_ListItem* hItem = GetItem(this, iSel); - CFX_RectF rtInvalidate; - rtInvalidate.Reset(); CFWL_ListItem* hOld = GetSelItem(0); int32_t iOld = GetItemIndex(this, hOld); if (iOld == iSel) return; + + CFX_RectF rtInvalidate; if (iOld > -1) { - CFWL_ListItem* hItem = GetItem(this, iOld); - GetItemRect(this, hItem, rtInvalidate); + if (CFWL_ListItem* hOldItem = GetItem(this, iOld)) + rtInvalidate = hOldItem->GetRect(); SetSelItem(hOld, false); } if (hItem) { - CFX_RectF rect; - CFWL_ListItem* hItem = GetItem(this, iSel); - GetItemRect(this, hItem, rect); - rtInvalidate.Union(rect); + if (CFWL_ListItem* hOldItem = GetItem(this, iSel)) + rtInvalidate.Union(hOldItem->GetRect()); CFWL_ListItem* hSel = GetItem(this, iSel); SetSelItem(hSel, true); } -- cgit v1.2.3