diff options
author | yosin@chromium.org <yosin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-26 02:52:16 +0000 |
---|---|---|
committer | yosin@chromium.org <yosin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-26 02:52:16 +0000 |
commit | 529038fce5f5745ff9243134379cc51835eb4643 (patch) | |
tree | cb0495371ba62084b13a1470b2322a956fc41f2b | |
parent | 746b824e301ca413188ad074ff9ea17cc0447e82 (diff) | |
download | chromium_src-529038fce5f5745ff9243134379cc51835eb4643.zip chromium_src-529038fce5f5745ff9243134379cc51835eb4643.tar.gz chromium_src-529038fce5f5745ff9243134379cc51835eb4643.tar.bz2 |
* Use DestoryIcon instead of DeleteObject
* Changes for cpplint.py
BUG=97559
TEST=Manual on Win7
Review URL: http://codereview.chromium.org/7977045
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102689 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | views/controls/table/native_table_win.cc | 18 | ||||
-rw-r--r-- | views/controls/table/table_view.cc | 16 |
2 files changed, 20 insertions, 14 deletions
diff --git a/views/controls/table/native_table_win.cc b/views/controls/table/native_table_win.cc index 1a568cf..d901906 100644 --- a/views/controls/table/native_table_win.cc +++ b/views/controls/table/native_table_win.cc @@ -7,7 +7,10 @@ #include <commctrl.h> #include <windowsx.h> +#include <algorithm> + #include "base/logging.h" +#include "base/win/scoped_gdi_object.h" #include "skia/ext/skia_utils_win.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util_win.h" @@ -325,7 +328,7 @@ bool NativeTableWin::ProcessMessage(UINT message, WPARAM w_param, // will disable all of the above behavior. NMLVGETINFOTIP* info_tip = reinterpret_cast<NMLVGETINFOTIP*>(hdr); string16 tooltip = table_->model()->GetTooltip(info_tip->iItem); - CHECK(info_tip->cchTextMax >= 2); + CHECK_GE(info_tip->cchTextMax, 2); if (tooltip.length() >= static_cast<size_t>(info_tip->cchTextMax)) { // Elide the tooltip if necessary. tooltip.erase(info_tip->cchTextMax - 2); // Ellipsis + '\0' @@ -393,11 +396,12 @@ void NativeTableWin::CreateNativeControl() { gfx::CanvasSkia canvas(kImageSize, kImageSize, false); // Make the background completely transparent. canvas.drawColor(SK_ColorBLACK, SkXfermode::kClear_Mode); - HICON empty_icon = - IconUtil::CreateHICONFromSkBitmap(canvas.ExtractBitmap()); - ImageList_AddIcon(image_list, empty_icon); - ImageList_AddIcon(image_list, empty_icon); - DeleteObject(empty_icon); + { + base::win::ScopedHICON empty_icon( + IconUtil::CreateHICONFromSkBitmap(canvas.ExtractBitmap())); + ImageList_AddIcon(image_list, empty_icon); + ImageList_AddIcon(image_list, empty_icon); + } ListView_SetImageList(native_view(), image_list, LVSIL_SMALL); } @@ -483,7 +487,7 @@ LRESULT NativeTableWin::OnCustomDraw(NMLVCUSTOMDRAW* draw_info) { r |= CDRF_NOTIFYPOSTPAINT; return r; } - case (CDDS_ITEMPREPAINT | CDDS_SUBITEM): { + case CDDS_ITEMPREPAINT | CDDS_SUBITEM: { // TODO(jcampan): implement custom colors and fonts. return CDRF_DODEFAULT; } diff --git a/views/controls/table/table_view.cc b/views/controls/table/table_view.cc index b6b6bb5..c8c1d59 100644 --- a/views/controls/table/table_view.cc +++ b/views/controls/table/table_view.cc @@ -11,6 +11,7 @@ #include "base/i18n/rtl.h" #include "base/string_util.h" +#include "base/win/scoped_gdi_object.h" #include "skia/ext/skia_utils_win.h" #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkColorFilter.h" @@ -807,11 +808,12 @@ HWND TableView::CreateNativeControl(HWND parent_container) { gfx::CanvasSkia canvas(kImageSize, kImageSize, false); // Make the background completely transparent. canvas.drawColor(SK_ColorBLACK, SkXfermode::kClear_Mode); - HICON empty_icon = - IconUtil::CreateHICONFromSkBitmap(canvas.ExtractBitmap()); - ImageList_AddIcon(image_list, empty_icon); - ImageList_AddIcon(image_list, empty_icon); - DeleteObject(empty_icon); + { + base::win::ScopedHICON empty_icon( + IconUtil::CreateHICONFromSkBitmap(canvas.ExtractBitmap())); + ImageList_AddIcon(image_list, empty_icon); + ImageList_AddIcon(image_list, empty_icon); + } ListView_SetImageList(list_view_, image_list, LVSIL_SMALL); } @@ -1082,7 +1084,7 @@ LRESULT TableView::OnNotify(int w_param, LPNMHDR hdr) { NMLVGETINFOTIP* info_tip = reinterpret_cast<NMLVGETINFOTIP*>(hdr); string16 tooltip = model_->GetTooltip(ViewToModel(info_tip->iItem)); - CHECK(info_tip->cchTextMax >= 2); + CHECK_GE(info_tip->cchTextMax, 2); if (tooltip.length() >= static_cast<size_t>(info_tip->cchTextMax)) { tooltip.erase(info_tip->cchTextMax - 2); // Ellipsis + '\0' const char16 kEllipsis = 0x2026; @@ -1172,7 +1174,7 @@ LRESULT TableView::OnCustomDraw(NMLVCUSTOMDRAW* draw_info) { r |= CDRF_NOTIFYPOSTPAINT; return r; } - case (CDDS_ITEMPREPAINT | CDDS_SUBITEM): { + case CDDS_ITEMPREPAINT | CDDS_SUBITEM: { // The list-view is painting a subitem. See if the colors should be // changed from the default. if (custom_colors_enabled_) { |