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 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" | 5 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include <utility> | 9 #include <utility> |
8 | 10 |
9 #include "base/mac/scoped_cftyperef.h" | 11 #include "base/mac/scoped_cftyperef.h" |
10 #include "base/mac/scoped_nsobject.h" | 12 #include "base/mac/scoped_nsobject.h" |
| 13 #include "base/macros.h" |
11 #include "chrome/browser/devtools/devtools_window.h" | 14 #include "chrome/browser/devtools/devtools_window.h" |
12 #import "chrome/browser/themes/theme_properties.h" | 15 #import "chrome/browser/themes/theme_properties.h" |
13 #import "chrome/browser/themes/theme_service.h" | 16 #import "chrome/browser/themes/theme_service.h" |
14 #import "chrome/browser/ui/cocoa/themed_window.h" | 17 #import "chrome/browser/ui/cocoa/themed_window.h" |
15 #include "chrome/browser/ui/view_ids.h" | 18 #include "chrome/browser/ui/view_ids.h" |
16 #include "content/public/browser/render_view_host.h" | 19 #include "content/public/browser/render_view_host.h" |
17 #include "content/public/browser/render_widget_host.h" | 20 #include "content/public/browser/render_widget_host.h" |
18 #include "content/public/browser/render_widget_host_view.h" | 21 #include "content/public/browser/render_widget_host_view.h" |
19 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
20 #include "content/public/browser/web_contents_observer.h" | 23 #include "content/public/browser/web_contents_observer.h" |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 const gfx::Size captureSize = wc->GetPreferredSize(); | 334 const gfx::Size captureSize = wc->GetPreferredSize(); |
332 if (captureSize.width() <= rect.width() && | 335 if (captureSize.width() <= rect.width() && |
333 captureSize.height() <= rect.height()) { | 336 captureSize.height() <= rect.height()) { |
334 // No scaling, just centering. | 337 // No scaling, just centering. |
335 rect.ClampToCenteredSize(captureSize); | 338 rect.ClampToCenteredSize(captureSize); |
336 } else { | 339 } else { |
337 // Scale down, preserving aspect ratio, and center. | 340 // Scale down, preserving aspect ratio, and center. |
338 // TODO(miu): This is basically media::ComputeLetterboxRegion(), and it | 341 // TODO(miu): This is basically media::ComputeLetterboxRegion(), and it |
339 // looks like others have written this code elsewhere. Let's consolidate | 342 // looks like others have written this code elsewhere. Let's consolidate |
340 // into a shared function ui/gfx/geometry or around there. | 343 // into a shared function ui/gfx/geometry or around there. |
341 const int64 x = static_cast<int64>(captureSize.width()) * rect.height(); | 344 const int64_t x = static_cast<int64_t>(captureSize.width()) * rect.height(); |
342 const int64 y = static_cast<int64>(captureSize.height()) * rect.width(); | 345 const int64_t y = static_cast<int64_t>(captureSize.height()) * rect.width(); |
343 if (y < x) { | 346 if (y < x) { |
344 rect.ClampToCenteredSize(gfx::Size( | 347 rect.ClampToCenteredSize(gfx::Size( |
345 rect.width(), static_cast<int>(y / captureSize.width()))); | 348 rect.width(), static_cast<int>(y / captureSize.width()))); |
346 } else { | 349 } else { |
347 rect.ClampToCenteredSize(gfx::Size( | 350 rect.ClampToCenteredSize(gfx::Size( |
348 static_cast<int>(x / captureSize.height()), rect.height())); | 351 static_cast<int>(x / captureSize.height()), rect.height())); |
349 } | 352 } |
350 } | 353 } |
351 | 354 |
352 return NSRectFromCGRect(rect.ToCGRect()); | 355 return NSRectFromCGRect(rect.ToCGRect()); |
353 } | 356 } |
354 | 357 |
355 @end | 358 @end |
OLD | NEW |