| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #import "chrome/browser/ui/cocoa/tabpose_window.h" | 5 #import "chrome/browser/ui/cocoa/tabpose_window.h" |
| 6 | 6 |
| 7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| 11 #include "base/mac/mac_util.h" | 11 #include "base/mac/mac_util.h" |
| 12 #include "base/mac/scoped_cftyperef.h" | 12 #include "base/mac/scoped_cftyperef.h" |
| 13 #include "base/memory/scoped_callback_factory.h" | 13 #include "base/memory/scoped_callback_factory.h" |
| 14 #include "base/sys_string_conversions.h" | 14 #include "base/sys_string_conversions.h" |
| 15 #include "chrome/app/chrome_command_ids.h" | 15 #include "chrome/app/chrome_command_ids.h" |
| 16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/extensions/extension_tab_helper.h" | 17 #include "chrome/browser/extensions/extension_tab_helper.h" |
| 18 #include "chrome/browser/prefs/pref_service.h" | 18 #include "chrome/browser/prefs/pref_service.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" | 20 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" |
| 21 #include "chrome/browser/tab_contents/thumbnail_generator.h" | 21 #include "chrome/browser/tab_contents/thumbnail_generator.h" |
| 22 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" | 22 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
| 23 #include "chrome/browser/ui/cocoa/animation_utils.h" |
| 23 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" | 24 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" |
| 24 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 25 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 25 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" | 26 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" |
| 26 #import "chrome/browser/ui/cocoa/tab_contents/favicon_util.h" | 27 #import "chrome/browser/ui/cocoa/tab_contents/favicon_util.h" |
| 27 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" | 28 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
| 28 #import "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h" | 29 #import "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h" |
| 29 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 30 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 30 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
| 31 #import "content/browser/debugger/devtools_window.h" | 32 #import "content/browser/debugger/devtools_window.h" |
| 32 #include "content/browser/renderer_host/backing_store_mac.h" | 33 #include "content/browser/renderer_host/backing_store_mac.h" |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 } else if (thumbnail_) { | 345 } else if (thumbnail_) { |
| 345 // No cache hit, but the renderer returned a thumbnail to us. | 346 // No cache hit, but the renderer returned a thumbnail to us. |
| 346 gfx::ScopedCGContextSaveGState CGContextSaveGState(context); | 347 gfx::ScopedCGContextSaveGState CGContextSaveGState(context); |
| 347 CGContextSetInterpolationQuality(context, kCGInterpolationHigh); | 348 CGContextSetInterpolationQuality(context, kCGInterpolationHigh); |
| 348 CGContextDrawImage(context, destRect, thumbnail_.get()); | 349 CGContextDrawImage(context, destRect, thumbnail_.get()); |
| 349 } | 350 } |
| 350 } | 351 } |
| 351 | 352 |
| 352 @end | 353 @end |
| 353 | 354 |
| 354 namespace { | |
| 355 | |
| 356 class ScopedCAActionDisabler { | |
| 357 public: | |
| 358 ScopedCAActionDisabler() { | |
| 359 [CATransaction begin]; | |
| 360 [CATransaction setValue:[NSNumber numberWithBool:YES] | |
| 361 forKey:kCATransactionDisableActions]; | |
| 362 } | |
| 363 | |
| 364 ~ScopedCAActionDisabler() { | |
| 365 [CATransaction commit]; | |
| 366 } | |
| 367 }; | |
| 368 | |
| 369 class ScopedCAActionSetDuration { | |
| 370 public: | |
| 371 explicit ScopedCAActionSetDuration(CGFloat duration) { | |
| 372 [CATransaction begin]; | |
| 373 [CATransaction setValue:[NSNumber numberWithFloat:duration] | |
| 374 forKey:kCATransactionAnimationDuration]; | |
| 375 } | |
| 376 | |
| 377 ~ScopedCAActionSetDuration() { | |
| 378 [CATransaction commit]; | |
| 379 } | |
| 380 }; | |
| 381 | |
| 382 } // namespace | |
| 383 | |
| 384 // Given the number |n| of tiles with a desired aspect ratio of |a| and a | 355 // Given the number |n| of tiles with a desired aspect ratio of |a| and a |
| 385 // desired distance |dx|, |dy| between tiles, returns how many tiles fit | 356 // desired distance |dx|, |dy| between tiles, returns how many tiles fit |
| 386 // vertically into a rectangle with the dimensions |w_c|, |h_c|. This returns | 357 // vertically into a rectangle with the dimensions |w_c|, |h_c|. This returns |
| 387 // an exact solution, which is usually a fractional number. | 358 // an exact solution, which is usually a fractional number. |
| 388 static float FitNRectsWithAspectIntoBoundingSizeWithConstantPadding( | 359 static float FitNRectsWithAspectIntoBoundingSizeWithConstantPadding( |
| 389 int n, double a, int w_c, int h_c, int dx, int dy) { | 360 int n, double a, int w_c, int h_c, int dx, int dy) { |
| 390 // We want to have the small rects have the same aspect ratio a as a full | 361 // We want to have the small rects have the same aspect ratio a as a full |
| 391 // tab. Let w, h be the size of a small rect, and w_c, h_c the size of the | 362 // tab. Let w, h be the size of a small rect, and w_c, h_c the size of the |
| 392 // container. dx, dy are the distances between small rects in x, y direction. | 363 // container. dx, dy are the distances between small rects in x, y direction. |
| 393 | 364 |
| (...skipping 1308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1702 tile.set_tab_contents(contents); | 1673 tile.set_tab_contents(contents); |
| 1703 ThumbnailLayer* thumbLayer = [allThumbnailLayers_ objectAtIndex:index]; | 1674 ThumbnailLayer* thumbLayer = [allThumbnailLayers_ objectAtIndex:index]; |
| 1704 [thumbLayer setTabContents:contents]; | 1675 [thumbLayer setTabContents:contents]; |
| 1705 } | 1676 } |
| 1706 | 1677 |
| 1707 - (void)tabStripModelDeleted { | 1678 - (void)tabStripModelDeleted { |
| 1708 [self close]; | 1679 [self close]; |
| 1709 } | 1680 } |
| 1710 | 1681 |
| 1711 @end | 1682 @end |
| OLD | NEW |