 Chromium Code Reviews
 Chromium Code Reviews Issue 2505703003:
  Cleaning up nits in fwl/core files.  (Closed)
    
  
    Issue 2505703003:
  Cleaning up nits in fwl/core files.  (Closed) 
  | OLD | NEW | 
|---|---|
| 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_combobox.h" | 7 #include "xfa/fwl/core/cfwl_combobox.h" | 
| 8 | 8 | 
| 9 #include <utility> | 9 #include <utility> | 
| 10 | 10 | 
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 | 40 | 
| 41 int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText) { | 41 int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText) { | 
| 42 std::unique_ptr<CFWL_ListItem> pItem(new CFWL_ListItem); | 42 std::unique_ptr<CFWL_ListItem> pItem(new CFWL_ListItem); | 
| 43 pItem->m_wsText = wsText; | 43 pItem->m_wsText = wsText; | 
| 44 pItem->m_dwStyles = 0; | 44 pItem->m_dwStyles = 0; | 
| 45 m_ItemArray.push_back(std::move(pItem)); | 45 m_ItemArray.push_back(std::move(pItem)); | 
| 46 return m_ItemArray.size() - 1; | 46 return m_ItemArray.size() - 1; | 
| 47 } | 47 } | 
| 48 | 48 | 
| 49 bool CFWL_ComboBox::RemoveAt(int32_t iIndex) { | 49 bool CFWL_ComboBox::RemoveAt(int32_t iIndex) { | 
| 50 if (iIndex < 0 || static_cast<size_t>(iIndex) >= m_ItemArray.size()) { | 50 if (iIndex < 0 || static_cast<size_t>(iIndex) >= m_ItemArray.size()) | 
| 51 return false; | 51 return false; | 
| 52 } | 52 | 
| 53 m_ItemArray.erase(m_ItemArray.begin() + iIndex); | 53 m_ItemArray.erase(m_ItemArray.begin() + iIndex); | 
| 54 return true; | 54 return true; | 
| 55 } | 55 } | 
| 56 | 56 | 
| 57 void CFWL_ComboBox::RemoveAll() { | 57 void CFWL_ComboBox::RemoveAll() { | 
| 58 m_ItemArray.clear(); | 58 m_ItemArray.clear(); | 
| 59 } | 59 } | 
| 60 | 60 | 
| 61 void CFWL_ComboBox::GetTextByIndex(int32_t iIndex, | 61 void CFWL_ComboBox::GetTextByIndex(int32_t iIndex, | 
| 
npm
2016/11/15 21:38:30
Is this the point where you change the Get methods
 
dsinclair
2016/11/15 21:44:06
After I merge the classes.
 | |
| 62 CFX_WideString& wsText) const { | 62 CFX_WideString& wsText) const { | 
| 63 CFWL_ListItem* pItem = | 63 CFWL_ListItem* pItem = | 
| 64 static_cast<CFWL_ListItem*>(GetItem(m_pIface.get(), iIndex)); | 64 static_cast<CFWL_ListItem*>(GetItem(m_pIface.get(), iIndex)); | 
| 65 if (pItem) | 65 if (pItem) | 
| 66 wsText = pItem->m_wsText; | 66 wsText = pItem->m_wsText; | 
| 67 } | 67 } | 
| 68 | 68 | 
| 69 int32_t CFWL_ComboBox::GetCurSel() const { | 69 int32_t CFWL_ComboBox::GetCurSel() const { | 
| 70 return GetWidget() ? ToComboBox(GetWidget())->GetCurSel() : -1; | 70 return GetWidget() ? ToComboBox(GetWidget())->GetCurSel() : -1; | 
| 71 } | 71 } | 
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 CFX_WideString& wsCaption) {} | 160 CFX_WideString& wsCaption) {} | 
| 161 | 161 | 
| 162 int32_t CFWL_ComboBox::CountItems(const IFWL_Widget* pWidget) const { | 162 int32_t CFWL_ComboBox::CountItems(const IFWL_Widget* pWidget) const { | 
| 163 return m_ItemArray.size(); | 163 return m_ItemArray.size(); | 
| 164 } | 164 } | 
| 165 | 165 | 
| 166 CFWL_ListItem* CFWL_ComboBox::GetItem(const IFWL_Widget* pWidget, | 166 CFWL_ListItem* CFWL_ComboBox::GetItem(const IFWL_Widget* pWidget, | 
| 167 int32_t nIndex) const { | 167 int32_t nIndex) const { | 
| 168 if (nIndex < 0 || static_cast<size_t>(nIndex) >= m_ItemArray.size()) | 168 if (nIndex < 0 || static_cast<size_t>(nIndex) >= m_ItemArray.size()) | 
| 169 return nullptr; | 169 return nullptr; | 
| 170 | |
| 171 return m_ItemArray[nIndex].get(); | 170 return m_ItemArray[nIndex].get(); | 
| 172 } | 171 } | 
| 173 | 172 | 
| 174 int32_t CFWL_ComboBox::GetItemIndex(IFWL_Widget* pWidget, | 173 int32_t CFWL_ComboBox::GetItemIndex(IFWL_Widget* pWidget, | 
| 175 CFWL_ListItem* pItem) { | 174 CFWL_ListItem* pItem) { | 
| 176 auto it = std::find_if( | 175 auto it = std::find_if( | 
| 177 m_ItemArray.begin(), m_ItemArray.end(), | 176 m_ItemArray.begin(), m_ItemArray.end(), | 
| 178 [pItem](const std::unique_ptr<CFWL_ListItem>& candidate) { | 177 [pItem](const std::unique_ptr<CFWL_ListItem>& candidate) { | 
| 179 return candidate.get() == static_cast<CFWL_ListItem*>(pItem); | 178 return candidate.get() == static_cast<CFWL_ListItem*>(pItem); | 
| 180 }); | 179 }); | 
| 181 return it != m_ItemArray.end() ? it - m_ItemArray.begin() : -1; | 180 return it != m_ItemArray.end() ? it - m_ItemArray.begin() : -1; | 
| 182 } | 181 } | 
| 183 | 182 | 
| 184 uint32_t CFWL_ComboBox::GetItemStyles(IFWL_Widget* pWidget, | 183 uint32_t CFWL_ComboBox::GetItemStyles(IFWL_Widget* pWidget, | 
| 
npm
2016/11/15 21:38:30
Is this some inherited method, or can you remove p
 
dsinclair
2016/11/15 21:44:06
They're inherited from the DataProvider override.
 | |
| 185 CFWL_ListItem* pItem) { | 184 CFWL_ListItem* pItem) { | 
| 186 if (!pItem) | 185 return pItem ? static_cast<CFWL_ListItem*>(pItem)->m_dwStyles : 0; | 
| 187 return 0; | |
| 188 return static_cast<CFWL_ListItem*>(pItem)->m_dwStyles; | |
| 189 } | 186 } | 
| 190 | 187 | 
| 191 void CFWL_ComboBox::GetItemText(IFWL_Widget* pWidget, | 188 void CFWL_ComboBox::GetItemText(IFWL_Widget* pWidget, | 
| 192 CFWL_ListItem* pItem, | 189 CFWL_ListItem* pItem, | 
| 193 CFX_WideString& wsText) { | 190 CFX_WideString& wsText) { | 
| 194 if (pItem) | 191 if (pItem) | 
| 195 wsText = static_cast<CFWL_ListItem*>(pItem)->m_wsText; | 192 wsText = static_cast<CFWL_ListItem*>(pItem)->m_wsText; | 
| 196 } | 193 } | 
| 197 | 194 | 
| 198 void CFWL_ComboBox::GetItemRect(IFWL_Widget* pWidget, | 195 void CFWL_ComboBox::GetItemRect(IFWL_Widget* pWidget, | 
| 199 CFWL_ListItem* pItem, | 196 CFWL_ListItem* pItem, | 
| 200 CFX_RectF& rtItem) { | 197 CFX_RectF& rtItem) { | 
| 201 if (!pItem) | 198 if (!pItem) | 
| 202 return; | 199 return; | 
| 200 | |
| 203 CFWL_ListItem* pComboItem = static_cast<CFWL_ListItem*>(pItem); | 201 CFWL_ListItem* pComboItem = static_cast<CFWL_ListItem*>(pItem); | 
| 204 rtItem.Set(pComboItem->m_rtItem.left, pComboItem->m_rtItem.top, | 202 rtItem.Set(pComboItem->m_rtItem.left, pComboItem->m_rtItem.top, | 
| 205 pComboItem->m_rtItem.width, pComboItem->m_rtItem.height); | 203 pComboItem->m_rtItem.width, pComboItem->m_rtItem.height); | 
| 206 } | 204 } | 
| 207 | 205 | 
| 208 void* CFWL_ComboBox::GetItemData(IFWL_Widget* pWidget, CFWL_ListItem* pItem) { | 206 void* CFWL_ComboBox::GetItemData(IFWL_Widget* pWidget, CFWL_ListItem* pItem) { | 
| 209 return pItem ? static_cast<CFWL_ListItem*>(pItem)->m_pData : nullptr; | 207 return pItem ? static_cast<CFWL_ListItem*>(pItem)->m_pData : nullptr; | 
| 210 } | 208 } | 
| 211 | 209 | 
| 212 void CFWL_ComboBox::SetItemStyles(IFWL_Widget* pWidget, | 210 void CFWL_ComboBox::SetItemStyles(IFWL_Widget* pWidget, | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 | 245 | 
| 248 void CFWL_ComboBox::SetItemCheckState(IFWL_Widget* pWidget, | 246 void CFWL_ComboBox::SetItemCheckState(IFWL_Widget* pWidget, | 
| 249 CFWL_ListItem* pItem, | 247 CFWL_ListItem* pItem, | 
| 250 uint32_t dwCheckState) { | 248 uint32_t dwCheckState) { | 
| 251 static_cast<CFWL_ListItem*>(pItem)->m_dwCheckState = dwCheckState; | 249 static_cast<CFWL_ListItem*>(pItem)->m_dwCheckState = dwCheckState; | 
| 252 } | 250 } | 
| 253 | 251 | 
| 254 FX_FLOAT CFWL_ComboBox::GetListHeight(IFWL_Widget* pWidget) { | 252 FX_FLOAT CFWL_ComboBox::GetListHeight(IFWL_Widget* pWidget) { | 
| 255 return m_fMaxListHeight; | 253 return m_fMaxListHeight; | 
| 256 } | 254 } | 
| OLD | NEW |