| OLD | NEW |
| 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 "chrome/browser/ui/views/location_bar/icon_label_bubble_view.h" | 5 #include "chrome/browser/ui/views/location_bar/icon_label_bubble_view.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/layout_constants.h" | 7 #include "chrome/browser/ui/layout_constants.h" |
| 8 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h" | 8 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h" |
| 9 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 9 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 10 #include "ui/accessibility/ax_node_data.h" | 10 #include "ui/accessibility/ax_node_data.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 else | 110 else |
| 111 bubble_trailing_padding -= space_shortage; | 111 bubble_trailing_padding -= space_shortage; |
| 112 } | 112 } |
| 113 image_->SetBounds(0, 0, image_width, height()); | 113 image_->SetBounds(0, 0, image_width, height()); |
| 114 | 114 |
| 115 // Compute the label bounds. The label gets whatever size is left over after | 115 // Compute the label bounds. The label gets whatever size is left over after |
| 116 // accounting for the preferred image width and padding amounts. Note that if | 116 // accounting for the preferred image width and padding amounts. Note that if |
| 117 // the label has zero size it doesn't actually matter what we compute its X | 117 // the label has zero size it doesn't actually matter what we compute its X |
| 118 // value to be, since it won't be visible. | 118 // value to be, since it won't be visible. |
| 119 const int label_x = image_->bounds().right() + GetInternalSpacing(); | 119 const int label_x = image_->bounds().right() + GetInternalSpacing(); |
| 120 const int label_width = | 120 const int label_width = std::max( |
| 121 std::max(0, width() - label_x - bubble_trailing_padding); | 121 0, width() - label_x - bubble_trailing_padding - kSpaceBesideSeparator); |
| 122 label_->SetBounds(label_x, 0, label_width, height()); | 122 label_->SetBounds(label_x, 0, label_width, height()); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void IconLabelBubbleView::GetAccessibleNodeData(ui::AXNodeData* node_data) { | 125 void IconLabelBubbleView::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
| 126 label_->GetAccessibleNodeData(node_data); | 126 label_->GetAccessibleNodeData(node_data); |
| 127 } | 127 } |
| 128 | 128 |
| 129 void IconLabelBubbleView::OnNativeThemeChanged( | 129 void IconLabelBubbleView::OnNativeThemeChanged( |
| 130 const ui::NativeTheme* native_theme) { | 130 const ui::NativeTheme* native_theme) { |
| 131 label_->SetEnabledColor(GetTextColor()); | 131 label_->SetEnabledColor(GetTextColor()); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 return; | 222 return; |
| 223 | 223 |
| 224 const SkColor plain_text_color = GetNativeTheme()->GetSystemColor( | 224 const SkColor plain_text_color = GetNativeTheme()->GetSystemColor( |
| 225 ui::NativeTheme::kColorId_TextfieldDefaultColor); | 225 ui::NativeTheme::kColorId_TextfieldDefaultColor); |
| 226 const SkColor separator_color = SkColorSetA( | 226 const SkColor separator_color = SkColorSetA( |
| 227 plain_text_color, color_utils::IsDark(plain_text_color) ? 0x59 : 0xCC); | 227 plain_text_color, color_utils::IsDark(plain_text_color) ? 0x59 : 0xCC); |
| 228 | 228 |
| 229 gfx::Rect bounds(label_->bounds()); | 229 gfx::Rect bounds(label_->bounds()); |
| 230 const int kSeparatorHeight = 16; | 230 const int kSeparatorHeight = 16; |
| 231 bounds.Inset(0, (bounds.height() - kSeparatorHeight) / 2); | 231 bounds.Inset(0, (bounds.height() - kSeparatorHeight) / 2); |
| 232 | 232 bounds.set_width(bounds.width() + kSpaceBesideSeparator); |
| 233 // Draw the 1 px separator. | 233 canvas->Draw1pxLine(gfx::PointF(bounds.top_right()), |
| 234 gfx::ScopedCanvas scoped_canvas(canvas); | 234 gfx::PointF(bounds.bottom_right()), separator_color); |
| 235 const float scale = canvas->UndoDeviceScaleFactor(); | |
| 236 // Keep the separator aligned on a pixel center. | |
| 237 const gfx::RectF pixel_aligned_bounds = | |
| 238 gfx::ScaleRect(gfx::RectF(bounds), scale) - gfx::Vector2dF(0.5f, 0); | |
| 239 canvas->DrawLine(pixel_aligned_bounds.top_right(), | |
| 240 pixel_aligned_bounds.bottom_right(), separator_color); | |
| 241 } | 235 } |
| OLD | NEW |