| 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 friend class TabStripTest; | 178 friend class TabStripTest; |
| 179 FRIEND_TEST_ALL_PREFIXES(TabStripTest, TabHitTestMaskWhenStacked); | 179 FRIEND_TEST_ALL_PREFIXES(TabStripTest, TabHitTestMaskWhenStacked); |
| 180 FRIEND_TEST_ALL_PREFIXES(TabStripTest, TabCloseButtonVisibilityWhenStacked); | 180 FRIEND_TEST_ALL_PREFIXES(TabStripTest, TabCloseButtonVisibilityWhenStacked); |
| 181 | 181 |
| 182 // The animation object used to swap the favicon with the sad tab icon. | 182 // The animation object used to swap the favicon with the sad tab icon. |
| 183 class FaviconCrashAnimation; | 183 class FaviconCrashAnimation; |
| 184 | 184 |
| 185 class TabCloseButton; | 185 class TabCloseButton; |
| 186 class ThrobberView; | 186 class ThrobberView; |
| 187 | 187 |
| 188 // All metadata necessary to uniquely identify a cached image. | |
| 189 struct ImageCacheEntryMetadata; | |
| 190 | |
| 191 // A cached image and the metadata used to generate it. | |
| 192 struct ImageCacheEntry; | |
| 193 typedef std::list<ImageCacheEntry> ImageCache; | |
| 194 | |
| 195 // gfx::AnimationDelegate: | 188 // gfx::AnimationDelegate: |
| 196 void AnimationProgressed(const gfx::Animation* animation) override; | 189 void AnimationProgressed(const gfx::Animation* animation) override; |
| 197 void AnimationCanceled(const gfx::Animation* animation) override; | 190 void AnimationCanceled(const gfx::Animation* animation) override; |
| 198 void AnimationEnded(const gfx::Animation* animation) override; | 191 void AnimationEnded(const gfx::Animation* animation) override; |
| 199 | 192 |
| 200 // views::ButtonListener: | 193 // views::ButtonListener: |
| 201 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 194 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 202 | 195 |
| 203 // views::ContextMenuController: | 196 // views::ContextMenuController: |
| 204 void ShowContextMenuForView(views::View* source, | 197 void ShowContextMenuForView(views::View* source, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 void PaintImmersiveTab(gfx::Canvas* canvas); | 238 void PaintImmersiveTab(gfx::Canvas* canvas); |
| 246 | 239 |
| 247 // Paint various portions of the Tab. | 240 // Paint various portions of the Tab. |
| 248 void PaintTabBackground(gfx::Canvas* canvas); | 241 void PaintTabBackground(gfx::Canvas* canvas); |
| 249 void PaintInactiveTabBackground(gfx::Canvas* canvas); | 242 void PaintInactiveTabBackground(gfx::Canvas* canvas); |
| 250 void PaintTabBackgroundUsingFillId(gfx::Canvas* canvas, | 243 void PaintTabBackgroundUsingFillId(gfx::Canvas* canvas, |
| 251 bool is_active, | 244 bool is_active, |
| 252 int fill_id, | 245 int fill_id, |
| 253 bool has_custom_image, | 246 bool has_custom_image, |
| 254 int y_offset); | 247 int y_offset); |
| 255 void PaintTabFill(gfx::Canvas* canvas, | |
| 256 gfx::ImageSkia* fill_image, | |
| 257 int x_offset, | |
| 258 int y_offset, | |
| 259 bool is_active); | |
| 260 | 248 |
| 261 // Paints the pinned tab title changed indicator and |favicon_|. |favicon_| | 249 // Paints the pinned tab title changed indicator and |favicon_|. |favicon_| |
| 262 // may be null. |favicon_draw_bounds| is |favicon_bounds_| adjusted for rtl | 250 // may be null. |favicon_draw_bounds| is |favicon_bounds_| adjusted for rtl |
| 263 // and clipped to the bounds of the tab. | 251 // and clipped to the bounds of the tab. |
| 264 void PaintPinnedTabTitleChangedIndicatorAndIcon( | 252 void PaintPinnedTabTitleChangedIndicatorAndIcon( |
| 265 gfx::Canvas* canvas, | 253 gfx::Canvas* canvas, |
| 266 const gfx::Rect& favicon_draw_bounds); | 254 const gfx::Rect& favicon_draw_bounds); |
| 267 | 255 |
| 268 // Paints the favicon, mirrored for RTL if needed. | 256 // Paints the favicon, mirrored for RTL if needed. |
| 269 void PaintIcon(gfx::Canvas* canvas); | 257 void PaintIcon(gfx::Canvas* canvas); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 300 void SetShouldDisplayCrashedFavicon(bool value); | 288 void SetShouldDisplayCrashedFavicon(bool value); |
| 301 | 289 |
| 302 // Recalculates the correct |button_color_| and resets the title, alert | 290 // Recalculates the correct |button_color_| and resets the title, alert |
| 303 // indicator, and close button colors if necessary. This should be called any | 291 // indicator, and close button colors if necessary. This should be called any |
| 304 // time the theme or active state may have changed. | 292 // time the theme or active state may have changed. |
| 305 void OnButtonColorMaybeChanged(); | 293 void OnButtonColorMaybeChanged(); |
| 306 | 294 |
| 307 // Schedules repaint task for icon. | 295 // Schedules repaint task for icon. |
| 308 void ScheduleIconPaint(); | 296 void ScheduleIconPaint(); |
| 309 | 297 |
| 310 // Computes a path corresponding to the tab's content region inside the outer | |
| 311 // stroke. | |
| 312 void GetFillPath(float scale, SkPath* path) const; | |
| 313 | |
| 314 // 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 | |
| 316 // vertically to the top of the tab bounds. The caller uses this for Fitts' | |
| 317 // Law purposes in maximized/fullscreen mode. | |
| 318 void GetBorderPath(float scale, bool extend_to_top, SkPath* path) const; | |
| 319 | |
| 320 // Returns the rectangle for the light bar in immersive mode. | 298 // Returns the rectangle for the light bar in immersive mode. |
| 321 gfx::Rect GetImmersiveBarRect() const; | 299 gfx::Rect GetImmersiveBarRect() const; |
| 322 | 300 |
| 323 // Performs a one-time initialization of static resources such as tab images. | |
| 324 static void InitTabResources(); | |
| 325 | |
| 326 // Loads the images to be used for the tab background. | |
| 327 static void LoadTabImages(); | |
| 328 | |
| 329 // The controller, never NULL. | 301 // The controller, never NULL. |
| 330 TabController* const controller_; | 302 TabController* const controller_; |
| 331 | 303 |
| 332 TabRendererData data_; | 304 TabRendererData data_; |
| 333 | 305 |
| 334 // True if the tab is being animated closed. | 306 // True if the tab is being animated closed. |
| 335 bool closing_; | 307 bool closing_; |
| 336 | 308 |
| 337 // True if the tab is being dragged. | 309 // True if the tab is being dragged. |
| 338 bool dragging_; | 310 bool dragging_; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 367 bool tab_activated_with_last_tap_down_; | 339 bool tab_activated_with_last_tap_down_; |
| 368 | 340 |
| 369 views::GlowHoverController hover_controller_; | 341 views::GlowHoverController hover_controller_; |
| 370 | 342 |
| 371 // The bounds of various sections of the display. | 343 // The bounds of various sections of the display. |
| 372 gfx::Rect favicon_bounds_; | 344 gfx::Rect favicon_bounds_; |
| 373 | 345 |
| 374 // The offset used to paint the inactive background image. | 346 // The offset used to paint the inactive background image. |
| 375 gfx::Point background_offset_; | 347 gfx::Point background_offset_; |
| 376 | 348 |
| 377 struct TabImages { | |
| 378 gfx::ImageSkia* image_l; | |
| 379 gfx::ImageSkia* image_c; | |
| 380 gfx::ImageSkia* image_r; | |
| 381 int l_width; | |
| 382 int r_width; | |
| 383 }; | |
| 384 static TabImages active_images_; | |
| 385 static TabImages inactive_images_; | |
| 386 static TabImages mask_images_; | |
| 387 | |
| 388 // Whether we're showing the icon. It is cached so that we can detect when it | 349 // Whether we're showing the icon. It is cached so that we can detect when it |
| 389 // changes and layout appropriately. | 350 // changes and layout appropriately. |
| 390 bool showing_icon_; | 351 bool showing_icon_; |
| 391 | 352 |
| 392 // Whether we're showing the alert indicator. It is cached so that we can | 353 // Whether we're showing the alert indicator. It is cached so that we can |
| 393 // detect when it changes and layout appropriately. | 354 // detect when it changes and layout appropriately. |
| 394 bool showing_alert_indicator_; | 355 bool showing_alert_indicator_; |
| 395 | 356 |
| 396 // Whether we are showing the close button. It is cached so that we can | 357 // Whether we are showing the close button. It is cached so that we can |
| 397 // detect when it changes and layout appropriately. | 358 // detect when it changes and layout appropriately. |
| 398 bool showing_close_button_; | 359 bool showing_close_button_; |
| 399 | 360 |
| 400 // The current color of the alert indicator and close button icons. | 361 // The current color of the alert indicator and close button icons. |
| 401 SkColor button_color_; | 362 SkColor button_color_; |
| 402 | 363 |
| 403 // The favicon for the tab. This might be the sad tab icon or a copy of | 364 // The favicon for the tab. This might be the sad tab icon or a copy of |
| 404 // data().favicon and may be modified for theming. It is created on demand | 365 // data().favicon and may be modified for theming. It is created on demand |
| 405 // and thus may be null. | 366 // and thus may be null. |
| 406 gfx::ImageSkia favicon_; | 367 gfx::ImageSkia favicon_; |
| 407 | 368 |
| 408 // As the majority of the tabs are inactive, and painting tabs is slowish, | |
| 409 // we cache a handful of the inactive tab backgrounds here. | |
| 410 static ImageCache* image_cache_; | |
| 411 | |
| 412 DISALLOW_COPY_AND_ASSIGN(Tab); | 369 DISALLOW_COPY_AND_ASSIGN(Tab); |
| 413 }; | 370 }; |
| 414 | 371 |
| 415 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ | 372 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ |
| OLD | NEW |