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

Unified Diff: chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc

Issue 2144903004: New location security strings and animation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc
diff --git a/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc b/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc
index 4abe60c7c68684c4ea339439a1923b18e5df36a6..2f6a68381ce71478daabc97ee82848806f813559 100644
--- a/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc
+++ b/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/ui/views/location_bar/icon_label_bubble_view.h"
+#include <iostream>
+
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/layout_constants.h"
#include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h"
@@ -123,8 +125,9 @@ bool IconLabelBubbleView::OnActivate(const ui::Event& event) {
}
gfx::Size IconLabelBubbleView::GetPreferredSize() const {
+ std::cout << "Icon::GetPreferredSize\n";
Peter Kasting 2016/07/19 21:17:19 You may want to use the VLOG macro for this kind o
Kevin Bailey 2016/08/12 18:49:14 ack
// Height will be ignored by the LocationBarView.
- return GetSizeForLabelWidth(label_->GetPreferredSize().width());
+ return GetSizeForLabelWidth(GetLabelPreferredWidth());
}
bool IconLabelBubbleView::OnKeyPressed(const ui::KeyEvent& event) {
@@ -140,6 +143,7 @@ bool IconLabelBubbleView::OnKeyReleased(const ui::KeyEvent& event) {
}
void IconLabelBubbleView::Layout() {
+ std::cout << "Icon::Layout " << (void*)this << "\n";
// Compute the image bounds. In non-MD, the leading padding depends on
// whether this is an extension icon, since extension icons and
// Chrome-provided icons are different sizes. In MD, these sizes are the
@@ -250,11 +254,18 @@ gfx::Size IconLabelBubbleView::GetSizeForLabelWidth(int label_width) const {
// enough to show the icon. We don't want to shrink all the way back to
// zero, since this would mean the view would completely disappear and then
// pop back to an icon after the animation finishes.
- const int max_width = GetImageTrailingEdge() + GetInternalSpacing() +
- label_width + post_label_width;
- const int current_width = WidthMultiplier() * max_width;
- size.set_width(shrinking ? std::max(current_width, size.width())
- : current_width);
+ // Changed so that, while shrinking, |multiplier| only refers to the label,
+ // separator and padding.
Peter Kasting 2016/07/19 21:17:20 I'm not really sure why. You'll want to explain t
Kevin Bailey 2016/08/12 18:49:14 I integrated the comment better. Strictly speaking
+ if (shrinking) {
+ const int current_width = GetImageTrailingEdge() + GetInternalSpacing() +
+ (label_width + post_label_width) * WidthMultiplier();
+ size.set_width(std::max(current_width, size.width()));
Peter Kasting 2016/07/19 21:17:20 Unless GetInternalSpacing() or WidthMultiplier() c
Kevin Bailey 2016/08/12 18:49:14 Done.
+ } else {
+ const int max_width = GetImageTrailingEdge() + GetInternalSpacing() +
+ label_width + post_label_width;
+ const int current_width = WidthMultiplier() * max_width;
+ size.set_width(current_width);
+ }
}
return size;
}
@@ -263,6 +274,10 @@ int IconLabelBubbleView::MinimumWidthForImageWithBackgroundShown() const {
return GetImageTrailingEdge() + GetOuterPadding(false);
}
+int IconLabelBubbleView::GetLabelPreferredWidth() const {
+ return label_->GetPreferredSize().width();
+}
+
void IconLabelBubbleView::SetLabelBackgroundColor(
SkColor chip_background_color) {
// The background images are painted atop |parent_background_color_|.
@@ -307,6 +322,7 @@ const char* IconLabelBubbleView::GetClassName() const {
}
void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) {
+ std::cout << "Icon::OnPaint\n";
if (!ShouldShowBackground())
return;
if (background_painter_) {
@@ -321,18 +337,20 @@ void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) {
const SkColor separator_color = SkColorSetA(
plain_text_color, color_utils::IsDark(plain_text_color) ? 0x59 : 0xCC);
- gfx::Rect bounds(GetLocalBounds());
- const int kSeparatorHeight = 16;
- bounds.Inset(GetPostSeparatorPadding(),
- (bounds.height() - kSeparatorHeight) / 2);
-
- // Draw the 1 px separator.
- gfx::ScopedCanvas scoped_canvas(canvas);
- const float scale = canvas->UndoDeviceScaleFactor();
- // Keep the separator aligned on a pixel center.
- const gfx::RectF pixel_aligned_bounds =
- gfx::ScaleRect(gfx::RectF(bounds), scale) - gfx::Vector2dF(0.5f, 0);
- canvas->DrawLine(pixel_aligned_bounds.top_right(),
- pixel_aligned_bounds.bottom_right(), separator_color);
+ if (!IsShrinking() || WidthMultiplier() > 0) {
Peter Kasting 2016/07/19 21:17:19 This doesn't break the keyword search presentation
Kevin Bailey 2016/08/12 18:49:14 We don't shrink any more, so reverted.
+ gfx::Rect bounds(GetLocalBounds());
+ const int kSeparatorHeight = 16;
+ bounds.Inset(GetPostSeparatorPadding(),
+ (bounds.height() - kSeparatorHeight) / 2);
+
+ // Draw the 1 px separator.
+ gfx::ScopedCanvas scoped_canvas(canvas);
+ const float scale = canvas->UndoDeviceScaleFactor();
+ // Keep the separator aligned on a pixel center.
+ const gfx::RectF pixel_aligned_bounds =
+ gfx::ScaleRect(gfx::RectF(bounds), scale) - gfx::Vector2dF(0.5f, 0);
+ canvas->DrawLine(pixel_aligned_bounds.top_right(),
+ pixel_aligned_bounds.bottom_right(), separator_color);
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698