Chromium Code Reviews| 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/bookmarks/bookmark_bar_view.h" | 5 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 #include "ui/base/l10n/l10n_util.h" | 72 #include "ui/base/l10n/l10n_util.h" |
| 73 #include "ui/base/page_transition_types.h" | 73 #include "ui/base/page_transition_types.h" |
| 74 #include "ui/base/resource/resource_bundle.h" | 74 #include "ui/base/resource/resource_bundle.h" |
| 75 #include "ui/base/theme_provider.h" | 75 #include "ui/base/theme_provider.h" |
| 76 #include "ui/base/window_open_disposition.h" | 76 #include "ui/base/window_open_disposition.h" |
| 77 #include "ui/compositor/paint_recorder.h" | 77 #include "ui/compositor/paint_recorder.h" |
| 78 #include "ui/gfx/animation/slide_animation.h" | 78 #include "ui/gfx/animation/slide_animation.h" |
| 79 #include "ui/gfx/canvas.h" | 79 #include "ui/gfx/canvas.h" |
| 80 #include "ui/gfx/color_utils.h" | 80 #include "ui/gfx/color_utils.h" |
| 81 #include "ui/gfx/favicon_size.h" | 81 #include "ui/gfx/favicon_size.h" |
| 82 #include "ui/gfx/geometry/insets.h" | |
| 82 #include "ui/gfx/geometry/rect.h" | 83 #include "ui/gfx/geometry/rect.h" |
| 83 #include "ui/gfx/image/image_skia_operations.h" | 84 #include "ui/gfx/image/image_skia_operations.h" |
| 84 #include "ui/gfx/paint_vector_icon.h" | 85 #include "ui/gfx/paint_vector_icon.h" |
| 85 #include "ui/gfx/scoped_canvas.h" | 86 #include "ui/gfx/scoped_canvas.h" |
| 86 #include "ui/gfx/text_constants.h" | 87 #include "ui/gfx/text_constants.h" |
| 87 #include "ui/gfx/text_elider.h" | 88 #include "ui/gfx/text_elider.h" |
| 88 #include "ui/gfx/vector_icons_public.h" | 89 #include "ui/gfx/vector_icons_public.h" |
| 89 #include "ui/resources/grit/ui_resources.h" | 90 #include "ui/resources/grit/ui_resources.h" |
| 90 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" | 91 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" |
| 91 #include "ui/views/animation/ink_drop_highlight.h" | 92 #include "ui/views/animation/ink_drop_highlight.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 namespace { | 159 namespace { |
| 159 | 160 |
| 160 // To enable/disable BookmarkBar animations during testing. In production | 161 // To enable/disable BookmarkBar animations during testing. In production |
| 161 // animations are enabled by default. | 162 // animations are enabled by default. |
| 162 bool animations_enabled = true; | 163 bool animations_enabled = true; |
| 163 | 164 |
| 164 gfx::ImageSkia* GetImageSkiaNamed(int id) { | 165 gfx::ImageSkia* GetImageSkiaNamed(int id) { |
| 165 return ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(id); | 166 return ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(id); |
| 166 } | 167 } |
| 167 | 168 |
| 169 // Ink drop ripple/highlight for bookmark buttons should be inset 1px vertically | |
| 170 // so that they do not touch the bookmark bar borders. | |
| 171 const gfx::Insets kInkDropInsets(1, 0); | |
|
sky
2016/11/29 05:12:34
Doesn't this result in a static initializer? Style
mohsen
2016/11/29 05:52:27
Right, my bad! However, I think style guide allows
| |
| 172 | |
| 168 gfx::Rect CalculateInkDropBounds(const gfx::Size& size) { | 173 gfx::Rect CalculateInkDropBounds(const gfx::Size& size) { |
| 169 gfx::Rect ink_drop_bounds(size); | 174 gfx::Rect ink_drop_bounds(size); |
| 170 ink_drop_bounds.Inset(0, 1); | 175 ink_drop_bounds.Inset(kInkDropInsets); |
| 171 return ink_drop_bounds; | 176 return ink_drop_bounds; |
| 172 } | 177 } |
| 173 | 178 |
| 174 // BookmarkButtonBase ----------------------------------------------- | 179 // BookmarkButtonBase ----------------------------------------------- |
| 175 | 180 |
| 176 // Base class for non-menu hosting buttons used on the bookmark bar. | 181 // Base class for non-menu hosting buttons used on the bookmark bar. |
| 177 | 182 |
| 178 class BookmarkButtonBase : public views::LabelButton { | 183 class BookmarkButtonBase : public views::LabelButton { |
| 179 public: | 184 public: |
| 180 BookmarkButtonBase(views::ButtonListener* listener, | 185 BookmarkButtonBase(views::ButtonListener* listener, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 // LabelButton: | 223 // LabelButton: |
| 219 std::unique_ptr<views::InkDrop> CreateInkDrop() override { | 224 std::unique_ptr<views::InkDrop> CreateInkDrop() override { |
| 220 std::unique_ptr<views::InkDropImpl> ink_drop = | 225 std::unique_ptr<views::InkDropImpl> ink_drop = |
| 221 CreateDefaultFloodFillInkDropImpl(); | 226 CreateDefaultFloodFillInkDropImpl(); |
| 222 ink_drop->SetShowHighlightOnFocus(true); | 227 ink_drop->SetShowHighlightOnFocus(true); |
| 223 return std::move(ink_drop); | 228 return std::move(ink_drop); |
| 224 } | 229 } |
| 225 | 230 |
| 226 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override { | 231 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override { |
| 227 return base::MakeUnique<views::FloodFillInkDropRipple>( | 232 return base::MakeUnique<views::FloodFillInkDropRipple>( |
| 228 CalculateInkDropBounds(size()), GetInkDropCenterBasedOnLastEvent(), | 233 size(), kInkDropInsets, GetInkDropCenterBasedOnLastEvent(), |
| 229 GetInkDropBaseColor(), ink_drop_visible_opacity()); | 234 GetInkDropBaseColor(), ink_drop_visible_opacity()); |
| 230 } | 235 } |
| 231 | 236 |
| 232 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() | 237 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() |
| 233 const override { | 238 const override { |
| 234 const gfx::Rect bounds = CalculateInkDropBounds(size()); | 239 const gfx::Rect bounds = CalculateInkDropBounds(size()); |
| 235 return base::MakeUnique<views::InkDropHighlight>( | 240 return base::MakeUnique<views::InkDropHighlight>( |
| 236 bounds.size(), 0, gfx::RectF(bounds).CenterPoint(), | 241 bounds.size(), 0, gfx::RectF(bounds).CenterPoint(), |
| 237 GetInkDropBaseColor()); | 242 GetInkDropBaseColor()); |
| 238 } | 243 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 // MenuButton: | 346 // MenuButton: |
| 342 std::unique_ptr<views::InkDrop> CreateInkDrop() override { | 347 std::unique_ptr<views::InkDrop> CreateInkDrop() override { |
| 343 std::unique_ptr<views::InkDropImpl> ink_drop = | 348 std::unique_ptr<views::InkDropImpl> ink_drop = |
| 344 CreateDefaultFloodFillInkDropImpl(); | 349 CreateDefaultFloodFillInkDropImpl(); |
| 345 ink_drop->SetShowHighlightOnFocus(true); | 350 ink_drop->SetShowHighlightOnFocus(true); |
| 346 return std::move(ink_drop); | 351 return std::move(ink_drop); |
| 347 } | 352 } |
| 348 | 353 |
| 349 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override { | 354 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override { |
| 350 return base::MakeUnique<views::FloodFillInkDropRipple>( | 355 return base::MakeUnique<views::FloodFillInkDropRipple>( |
| 351 CalculateInkDropBounds(size()), GetInkDropCenterBasedOnLastEvent(), | 356 size(), kInkDropInsets, GetInkDropCenterBasedOnLastEvent(), |
| 352 GetInkDropBaseColor(), ink_drop_visible_opacity()); | 357 GetInkDropBaseColor(), ink_drop_visible_opacity()); |
| 353 } | 358 } |
| 354 | 359 |
| 355 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() | 360 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() |
| 356 const override { | 361 const override { |
| 357 const gfx::Rect bounds = CalculateInkDropBounds(size()); | 362 const gfx::Rect bounds = CalculateInkDropBounds(size()); |
| 358 return base::MakeUnique<views::InkDropHighlight>( | 363 return base::MakeUnique<views::InkDropHighlight>( |
| 359 bounds.size(), 0, gfx::RectF(bounds).CenterPoint(), | 364 bounds.size(), 0, gfx::RectF(bounds).CenterPoint(), |
| 360 GetInkDropBaseColor()); | 365 GetInkDropBaseColor()); |
| 361 } | 366 } |
| (...skipping 1781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2143 return; | 2148 return; |
| 2144 apps_page_shortcut_->SetVisible(visible); | 2149 apps_page_shortcut_->SetVisible(visible); |
| 2145 UpdateBookmarksSeparatorVisibility(); | 2150 UpdateBookmarksSeparatorVisibility(); |
| 2146 LayoutAndPaint(); | 2151 LayoutAndPaint(); |
| 2147 } | 2152 } |
| 2148 | 2153 |
| 2149 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { | 2154 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { |
| 2150 if (UpdateOtherAndManagedButtonsVisibility()) | 2155 if (UpdateOtherAndManagedButtonsVisibility()) |
| 2151 LayoutAndPaint(); | 2156 LayoutAndPaint(); |
| 2152 } | 2157 } |
| OLD | NEW |