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

Side by Side Diff: ui/views/bubble/bubble_frame_view.cc

Issue 1216673005: views::LabelButton should not call virtual methods from its constructor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20150703-Views-ButtonBorderRefactor
Patch Set: selfnits Created 5 years, 5 months 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium 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 #include "ui/views/bubble/bubble_frame_view.h" 5 #include "ui/views/bubble/bubble_frame_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ui/base/hit_test.h" 9 #include "ui/base/hit_test.h"
10 #include "ui/base/l10n/l10n_util.h" 10 #include "ui/base/l10n/l10n_util.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 90
91 // static 91 // static
92 gfx::Insets BubbleFrameView::GetTitleInsets() { 92 gfx::Insets BubbleFrameView::GetTitleInsets() {
93 return gfx::Insets( 93 return gfx::Insets(
94 kTitleTopInset, kTitleLeftInset, kTitleBottomInset, kTitleRightInset); 94 kTitleTopInset, kTitleLeftInset, kTitleBottomInset, kTitleRightInset);
95 } 95 }
96 96
97 // static 97 // static
98 LabelButton* BubbleFrameView::CreateCloseButton(ButtonListener* listener) { 98 LabelButton* BubbleFrameView::CreateCloseButton(ButtonListener* listener) {
99 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 99 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
100 LabelButton* close = new LabelButton(listener, base::string16()); 100 LabelButton* close = new LabelButton(listener);
101 close->SetBorder(nullptr);
102 close->Init(base::string16());
101 close->SetImage(CustomButton::STATE_NORMAL, 103 close->SetImage(CustomButton::STATE_NORMAL,
102 *rb.GetImageNamed(IDR_CLOSE_DIALOG).ToImageSkia()); 104 *rb.GetImageNamed(IDR_CLOSE_DIALOG).ToImageSkia());
103 close->SetImage(CustomButton::STATE_HOVERED, 105 close->SetImage(CustomButton::STATE_HOVERED,
104 *rb.GetImageNamed(IDR_CLOSE_DIALOG_H).ToImageSkia()); 106 *rb.GetImageNamed(IDR_CLOSE_DIALOG_H).ToImageSkia());
105 close->SetImage(CustomButton::STATE_PRESSED, 107 close->SetImage(CustomButton::STATE_PRESSED,
106 *rb.GetImageNamed(IDR_CLOSE_DIALOG_P).ToImageSkia()); 108 *rb.GetImageNamed(IDR_CLOSE_DIALOG_P).ToImageSkia());
107 close->SetBorder(nullptr);
sadrul 2015/07/08 05:59:11 What happens if this call to SetBorder() happens a
tapted 2015/07/08 06:31:32 That still works fine - it just wastes work becaus
108 close->SetSize(close->GetPreferredSize()); 109 close->SetSize(close->GetPreferredSize());
109 #if !defined(OS_WIN) 110 #if !defined(OS_WIN)
110 // Windows will automatically create a tooltip for the close button based on 111 // Windows will automatically create a tooltip for the close button based on
111 // the HTCLOSE result from NonClientHitTest(). 112 // the HTCLOSE result from NonClientHitTest().
112 close->SetTooltipText(l10n_util::GetStringUTF16(IDS_APP_CLOSE)); 113 close->SetTooltipText(l10n_util::GetStringUTF16(IDS_APP_CLOSE));
113 #endif 114 #endif
114 return close; 115 return close;
115 } 116 }
116 117
117 gfx::Rect BubbleFrameView::GetBoundsForClientView() const { 118 gfx::Rect BubbleFrameView::GetBoundsForClientView() const {
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 if (titlebar_extra_view_ != NULL) 441 if (titlebar_extra_view_ != NULL)
441 title_bar_width += titlebar_extra_view_->GetPreferredSize().width(); 442 title_bar_width += titlebar_extra_view_->GetPreferredSize().width();
442 gfx::Size size(client_size); 443 gfx::Size size(client_size);
443 size.SetToMax(gfx::Size(title_bar_width, 0)); 444 size.SetToMax(gfx::Size(title_bar_width, 0));
444 const gfx::Insets insets(GetInsets()); 445 const gfx::Insets insets(GetInsets());
445 size.Enlarge(insets.width(), insets.height()); 446 size.Enlarge(insets.width(), insets.height());
446 return size; 447 return size;
447 } 448 }
448 449
449 } // namespace views 450 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698