Index: chrome/browser/views/download_item_view.cc |
=================================================================== |
--- chrome/browser/views/download_item_view.cc (revision 3391) |
+++ chrome/browser/views/download_item_view.cc (working copy) |
@@ -73,8 +73,7 @@ |
save_button_(NULL), |
discard_button_(NULL), |
dangerous_download_label_(NULL), |
- dangerous_download_label_sized_(false), |
- cached_button_size_(0, 0) { |
+ dangerous_download_label_sized_(false) { |
// TODO(idana) Bug# 1163334 |
// |
// We currently do not mirror each download item on the download shelf (even |
@@ -178,9 +177,8 @@ |
else |
box_y_ = kVerticalPadding; |
- CSize size; |
- GetPreferredSize(&size); |
- drop_down_x_ = size.cx - normal_drop_down_image_set_.top->width(); |
+ gfx::Size size = GetPreferredSize(); |
+ drop_down_x_ = size.width() - normal_drop_down_image_set_.top->width(); |
body_hover_animation_.reset(new SlideAnimation(this)); |
drop_hover_animation_.reset(new SlideAnimation(this)); |
@@ -303,13 +301,13 @@ |
dangerous_download_label_->SetBounds(x, y, |
dangerous_download_label_->width(), |
dangerous_download_label_->height()); |
- CSize button_size; |
- GetButtonSize(&button_size); |
+ gfx::Size button_size = GetButtonSize(); |
x += dangerous_download_label_->width() + kLabelPadding; |
- y = (height() - button_size.cy) / 2; |
- save_button_->SetBounds(x, y, button_size.cx, button_size.cy); |
- x += button_size.cx + kButtonPadding; |
- discard_button_->SetBounds(x, y, button_size.cx, button_size.cy); |
+ y = (height() - button_size.height()) / 2; |
+ save_button_->SetBounds(x, y, button_size.width(), button_size.height()); |
+ x += button_size.width() + kButtonPadding; |
+ discard_button_->SetBounds(x, y, button_size.width(), |
+ button_size.height()); |
} |
} |
@@ -550,20 +548,20 @@ |
parent_->SchedulePaint(); |
} |
-void DownloadItemView::GetPreferredSize(CSize* out) { |
+gfx::Size DownloadItemView::GetPreferredSize() { |
int width, height; |
if (IsDangerousMode()) { |
width = kLeftPadding + dangerous_mode_body_image_set_.top_left->width(); |
width += warning_icon_->width() + kLabelPadding; |
width += dangerous_download_label_->width() + kLabelPadding; |
- CSize button_size; |
- GetButtonSize(&button_size); |
- width += button_size.cx * 2 + kButtonPadding; |
+ gfx::Size button_size = GetButtonSize(); |
+ width += button_size.width() * 2 + kButtonPadding; |
width += dangerous_mode_body_image_set_.top_right->width(); |
height = std::max<int>(2 * kVerticalPadding + 2 * font_.height() + |
kVerticalTextPadding, |
2 * kVerticalPadding + warning_icon_->height()); |
- height = std::max<int>(height, 2 * kVerticalPadding + button_size.cy); |
+ height = std::max<int>(height, |
+ 2 * kVerticalPadding + button_size.height()); |
} else { |
width = kLeftPadding + normal_body_image_set_.top_left->width(); |
width += download_util::kSmallProgressIconSize; |
@@ -574,8 +572,7 @@ |
kVerticalTextPadding, |
download_util::kSmallProgressIconSize); |
} |
- out->cx = width; |
- out->cy = height; |
+ return gfx::Size(width, height); |
} |
void DownloadItemView::OnMouseExited(const ChromeViews::MouseEvent& event) { |
@@ -728,27 +725,27 @@ |
NewCallback(this, &DownloadItemView::OnExtractIconComplete)); |
} |
-void DownloadItemView::GetButtonSize(CSize* size) { |
+gfx::Size DownloadItemView::GetButtonSize() { |
DCHECK(save_button_ && discard_button_); |
+ gfx::Size size; |
+ |
// We cache the size when successfully retrieved, not for performance reasons |
// but because if this DownloadItemView is being animated while the tab is |
// not showing, the native buttons are not parented and their preferred size |
// is 0, messing-up the layout. |
- if (cached_button_size_.cx != 0) { |
- *size = cached_button_size_; |
- } |
+ if (cached_button_size_.width() != 0) |
+ size = cached_button_size_; |
- CSize tmp_size; |
- save_button_->GetMinimumSize(size); |
- discard_button_->GetMinimumSize(&tmp_size); |
+ size = save_button_->GetMinimumSize(); |
+ gfx::Size discard_size = discard_button_->GetMinimumSize(); |
- size->cx = std::max(size->cx, tmp_size.cx); |
- size->cy = std::max(size->cy, tmp_size.cy); |
+ size.SetSize(std::max(size.width(), discard_size.width()), |
+ std::max(size.height(), discard_size.height())); |
- if (size->cx != 0) { |
- cached_button_size_.cx = size->cx; |
- cached_button_size_.cy = size->cy; |
- } |
+ if (size.width() != 0) |
+ cached_button_size_ = size; |
+ |
+ return size; |
} |
// This method computes the miminum width of the label for diplaying its text |
@@ -766,22 +763,22 @@ |
// current width. |
dangerous_download_label_->SetBounds(0, 0, 1000, 1000); |
- CSize size(0, 0); |
+ gfx::Size size; |
int min_width = -1; |
int sp_index = text.find(L" "); |
while (sp_index != std::wstring::npos) { |
text.replace(sp_index, 1, L"\n"); |
dangerous_download_label_->SetText(text); |
- dangerous_download_label_->GetPreferredSize(&size); |
+ size = dangerous_download_label_->GetPreferredSize(); |
if (min_width == -1) |
- min_width = size.cx; |
+ min_width = size.width(); |
- // If thw width is growing again, it means we passed the optimal width spot. |
- if (size.cx > min_width) |
+ // If the width is growing again, it means we passed the optimal width spot. |
+ if (size.width() > min_width) |
break; |
else |
- min_width = size.cx; |
+ min_width = size.width(); |
// Restore the string. |
text.replace(sp_index, 1, L" "); |
@@ -791,8 +788,8 @@ |
// If we have a line with no space, we won't cut it. |
if (min_width == -1) |
- dangerous_download_label_->GetPreferredSize(&size); |
+ size = dangerous_download_label_->GetPreferredSize(); |
- dangerous_download_label_->SetBounds(0, 0, size.cx, size.cy); |
+ dangerous_download_label_->SetBounds(gfx::Point(), size); |
dangerous_download_label_sized_ = true; |
} |