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 #ifndef CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 15 matching lines...) Expand all Loading... | |
26 | 26 |
27 class AlertIndicatorButton; | 27 class AlertIndicatorButton; |
28 class TabController; | 28 class TabController; |
29 | 29 |
30 namespace gfx { | 30 namespace gfx { |
31 class Animation; | 31 class Animation; |
32 class AnimationContainer; | 32 class AnimationContainer; |
33 class LinearAnimation; | 33 class LinearAnimation; |
34 class ThrobAnimation; | 34 class ThrobAnimation; |
35 } | 35 } |
36 namespace ui { | |
37 class ThemeProvider; | |
38 } | |
36 namespace views { | 39 namespace views { |
37 class ImageButton; | 40 class ImageButton; |
38 class Label; | 41 class Label; |
39 } | 42 } |
40 | 43 |
41 /////////////////////////////////////////////////////////////////////////////// | 44 /////////////////////////////////////////////////////////////////////////////// |
42 // | 45 // |
43 // A View that renders a Tab in a TabStrip. | 46 // A View that renders a Tab in a TabStrip. |
44 // | 47 // |
45 /////////////////////////////////////////////////////////////////////////////// | 48 /////////////////////////////////////////////////////////////////////////////// |
46 class Tab : public gfx::AnimationDelegate, | 49 class Tab : public gfx::AnimationDelegate, |
47 public views::ButtonListener, | 50 public views::ButtonListener, |
48 public views::ContextMenuController, | 51 public views::ContextMenuController, |
49 public views::MaskedTargeterDelegate, | 52 public views::MaskedTargeterDelegate, |
50 public views::View { | 53 public views::View { |
51 public: | 54 public: |
52 // The Tab's class name. | 55 // The Tab's class name. |
53 static const char kViewClassName[]; | 56 static const char kViewClassName[]; |
54 | 57 |
58 struct PaintBackgroundParams { | |
oshima
2016/07/13 20:55:28
can you move this to private & .cc file?
Greg Levin
2016/07/15 22:24:48
Done in Patch #3 ; moved to namespace in Patch #4.
| |
59 const ui::ThemeProvider* tp; | |
60 views::GlowHoverController* hc; | |
61 bool is_active; | |
62 int fill_id; | |
63 bool has_custom_image; | |
64 int x_offset; | |
65 int y_offset; | |
66 gfx::Size size; | |
67 SkColor stroke_color; | |
68 }; | |
69 | |
55 Tab(TabController* controller, gfx::AnimationContainer* container); | 70 Tab(TabController* controller, gfx::AnimationContainer* container); |
56 ~Tab() override; | 71 ~Tab() override; |
57 | 72 |
58 TabController* controller() const { return controller_; } | 73 TabController* controller() const { return controller_; } |
59 | 74 |
60 // Used to set/check whether this Tab is being animated closed. | 75 // Used to set/check whether this Tab is being animated closed. |
61 void set_closing(bool closing) { closing_ = closing; } | 76 void set_closing(bool closing) { closing_ = closing; } |
62 bool closing() const { return closing_; } | 77 bool closing() const { return closing_; } |
63 | 78 |
64 // See description above field. | 79 // See description above field. |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 friend class TabTest; | 192 friend class TabTest; |
178 friend class TabStripTest; | 193 friend class TabStripTest; |
179 FRIEND_TEST_ALL_PREFIXES(TabStripTest, TabHitTestMaskWhenStacked); | 194 FRIEND_TEST_ALL_PREFIXES(TabStripTest, TabHitTestMaskWhenStacked); |
180 FRIEND_TEST_ALL_PREFIXES(TabStripTest, TabCloseButtonVisibilityWhenStacked); | 195 FRIEND_TEST_ALL_PREFIXES(TabStripTest, TabCloseButtonVisibilityWhenStacked); |
181 | 196 |
182 // The animation object used to swap the favicon with the sad tab icon. | 197 // The animation object used to swap the favicon with the sad tab icon. |
183 class FaviconCrashAnimation; | 198 class FaviconCrashAnimation; |
184 | 199 |
185 class TabCloseButton; | 200 class TabCloseButton; |
186 class ThrobberView; | 201 class ThrobberView; |
202 class TabImageSource; | |
187 | 203 |
188 // All metadata necessary to uniquely identify a cached image. | 204 // All metadata necessary to uniquely identify a cached image. |
189 struct ImageCacheEntryMetadata; | 205 struct ImageCacheEntryMetadata; |
190 | 206 |
191 // A cached image and the metadata used to generate it. | 207 // A cached image and the metadata used to generate it. |
192 struct ImageCacheEntry; | 208 struct ImageCacheEntry; |
193 typedef std::list<ImageCacheEntry> ImageCache; | 209 typedef std::list<ImageCacheEntry> ImageCache; |
194 | 210 |
195 // gfx::AnimationDelegate: | 211 // gfx::AnimationDelegate: |
196 void AnimationProgressed(const gfx::Animation* animation) override; | 212 void AnimationProgressed(const gfx::Animation* animation) override; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
245 void PaintImmersiveTab(gfx::Canvas* canvas); | 261 void PaintImmersiveTab(gfx::Canvas* canvas); |
246 | 262 |
247 // Paint various portions of the Tab. | 263 // Paint various portions of the Tab. |
248 void PaintTabBackground(gfx::Canvas* canvas); | 264 void PaintTabBackground(gfx::Canvas* canvas); |
249 void PaintInactiveTabBackground(gfx::Canvas* canvas); | 265 void PaintInactiveTabBackground(gfx::Canvas* canvas); |
250 void PaintTabBackgroundUsingFillId(gfx::Canvas* canvas, | 266 void PaintTabBackgroundUsingFillId(gfx::Canvas* canvas, |
251 bool is_active, | 267 bool is_active, |
252 int fill_id, | 268 int fill_id, |
253 bool has_custom_image, | 269 bool has_custom_image, |
254 int y_offset); | 270 int y_offset); |
255 void PaintTabFill(gfx::Canvas* canvas, | 271 static void PaintTabBackgroundUsingFillId( |
256 gfx::ImageSkia* fill_image, | 272 gfx::Canvas* canvas, |
257 int x_offset, | 273 const PaintBackgroundParams& params); |
258 int y_offset, | 274 static void PaintTabFill(gfx::Canvas* canvas, |
259 bool is_active); | 275 gfx::ImageSkia* fill_image, |
276 int x_offset, | |
277 int y_offset, | |
278 const gfx::Size& size, | |
279 bool is_active); | |
oshima
2016/07/13 20:55:28
move private static member function to anonymous n
Greg Levin
2016/07/15 22:24:48
Done. Moved PaintTabBackgroundUsingFillId() in Pa
| |
260 | 280 |
261 // Paints the pinned tab title changed indicator and |favicon_|. |favicon_| | 281 // Paints the pinned tab title changed indicator and |favicon_|. |favicon_| |
262 // may be null. |favicon_draw_bounds| is |favicon_bounds_| adjusted for rtl | 282 // may be null. |favicon_draw_bounds| is |favicon_bounds_| adjusted for rtl |
263 // and clipped to the bounds of the tab. | 283 // and clipped to the bounds of the tab. |
264 void PaintPinnedTabTitleChangedIndicatorAndIcon( | 284 void PaintPinnedTabTitleChangedIndicatorAndIcon( |
265 gfx::Canvas* canvas, | 285 gfx::Canvas* canvas, |
266 const gfx::Rect& favicon_draw_bounds); | 286 const gfx::Rect& favicon_draw_bounds); |
267 | 287 |
268 // Paints the favicon, mirrored for RTL if needed. | 288 // Paints the favicon, mirrored for RTL if needed. |
269 void PaintIcon(gfx::Canvas* canvas); | 289 void PaintIcon(gfx::Canvas* canvas); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
302 // Recalculates the correct |button_color_| and resets the title, alert | 322 // Recalculates the correct |button_color_| and resets the title, alert |
303 // indicator, and close button colors if necessary. This should be called any | 323 // indicator, and close button colors if necessary. This should be called any |
304 // time the theme or active state may have changed. | 324 // time the theme or active state may have changed. |
305 void OnButtonColorMaybeChanged(); | 325 void OnButtonColorMaybeChanged(); |
306 | 326 |
307 // Schedules repaint task for icon. | 327 // Schedules repaint task for icon. |
308 void ScheduleIconPaint(); | 328 void ScheduleIconPaint(); |
309 | 329 |
310 // Computes a path corresponding to the tab's content region inside the outer | 330 // Computes a path corresponding to the tab's content region inside the outer |
311 // stroke. | 331 // stroke. |
312 void GetFillPath(float scale, SkPath* path) const; | 332 static void GetFillPath(float scale, const gfx::Size& size, SkPath* path); |
313 | 333 |
314 // Computes a path corresponding to the tab's outer border for a given |scale| | 334 // Computes a path corresponding to the tab's outer border for a given |scale| |
315 // and stores it in |path|. If |extend_to_top| is true, the path is extended | 335 // and stores it in |path|. If |extend_to_top| is true, the path is extended |
316 // vertically to the top of the tab bounds. The caller uses this for Fitts' | 336 // vertically to the top of the tab bounds. The caller uses this for Fitts' |
317 // Law purposes in maximized/fullscreen mode. | 337 // Law purposes in maximized/fullscreen mode. |
318 void GetBorderPath(float scale, bool extend_to_top, SkPath* path) const; | 338 static void GetBorderPath(float scale, |
339 const gfx::Size& size, | |
340 bool extend_to_top, | |
341 SkPath* path); | |
319 | 342 |
320 // Returns the rectangle for the light bar in immersive mode. | 343 // Returns the rectangle for the light bar in immersive mode. |
321 gfx::Rect GetImmersiveBarRect() const; | 344 gfx::Rect GetImmersiveBarRect() const; |
322 | 345 |
323 // Performs a one-time initialization of static resources such as tab images. | 346 // Performs a one-time initialization of static resources such as tab images. |
324 static void InitTabResources(); | 347 static void InitTabResources(); |
325 | 348 |
326 // Loads the images to be used for the tab background. | 349 // Loads the images to be used for the tab background. |
327 static void LoadTabImages(); | 350 static void LoadTabImages(); |
328 | 351 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
406 gfx::ImageSkia favicon_; | 429 gfx::ImageSkia favicon_; |
407 | 430 |
408 // As the majority of the tabs are inactive, and painting tabs is slowish, | 431 // As the majority of the tabs are inactive, and painting tabs is slowish, |
409 // we cache a handful of the inactive tab backgrounds here. | 432 // we cache a handful of the inactive tab backgrounds here. |
410 static ImageCache* image_cache_; | 433 static ImageCache* image_cache_; |
411 | 434 |
412 DISALLOW_COPY_AND_ASSIGN(Tab); | 435 DISALLOW_COPY_AND_ASSIGN(Tab); |
413 }; | 436 }; |
414 | 437 |
415 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ | 438 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ |
OLD | NEW |