| 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 "content/browser/renderer_host/render_widget_host_view_mac.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h" |
| 6 | 6 |
| 7 #import <objc/runtime.h> | 7 #import <objc/runtime.h> |
| 8 #include <OpenGL/gl.h> | 8 #include <OpenGL/gl.h> |
| 9 #include <QuartzCore/QuartzCore.h> | 9 #include <QuartzCore/QuartzCore.h> |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 // case from extension popup windows. | 369 // case from extension popup windows. |
| 370 NSWindow* ancestor_window = [enclosing_window parentWindow]; | 370 NSWindow* ancestor_window = [enclosing_window parentWindow]; |
| 371 if (ancestor_window && (NSWidth([enclosing_window frame]) == | 371 if (ancestor_window && (NSWidth([enclosing_window frame]) == |
| 372 NSWidth([ancestor_window frame]))) { | 372 NSWidth([ancestor_window frame]))) { |
| 373 enclosing_window = ancestor_window; | 373 enclosing_window = ancestor_window; |
| 374 } | 374 } |
| 375 | 375 |
| 376 return enclosing_window; | 376 return enclosing_window; |
| 377 } | 377 } |
| 378 | 378 |
| 379 blink::WebScreenInfo GetWebScreenInfo(NSView* view) { | |
| 380 display::Display display = | |
| 381 display::Screen::GetScreen()->GetDisplayNearestWindow(view); | |
| 382 | |
| 383 NSScreen* screen = [NSScreen deepestScreen]; | |
| 384 | |
| 385 blink::WebScreenInfo results; | |
| 386 | |
| 387 results.deviceScaleFactor = static_cast<int>(display.device_scale_factor()); | |
| 388 results.depth = NSBitsPerPixelFromDepth([screen depth]); | |
| 389 results.depthPerComponent = NSBitsPerSampleFromDepth([screen depth]); | |
| 390 results.isMonochrome = | |
| 391 [[screen colorSpace] colorSpaceModel] == NSGrayColorSpaceModel; | |
| 392 results.rect = display.bounds(); | |
| 393 results.availableRect = display.work_area(); | |
| 394 results.orientationAngle = display.RotationAsDegree(); | |
| 395 results.orientationType = | |
| 396 content::RenderWidgetHostViewBase::GetOrientationTypeForDesktop(display); | |
| 397 | |
| 398 return results; | |
| 399 } | |
| 400 | |
| 401 } // namespace | 379 } // namespace |
| 402 | 380 |
| 403 namespace content { | 381 namespace content { |
| 404 | 382 |
| 405 //////////////////////////////////////////////////////////////////////////////// | 383 //////////////////////////////////////////////////////////////////////////////// |
| 406 // BrowserCompositorMacClient, public: | 384 // BrowserCompositorMacClient, public: |
| 407 | 385 |
| 408 NSView* RenderWidgetHostViewMac::BrowserCompositorMacGetNSView() const { | 386 NSView* RenderWidgetHostViewMac::BrowserCompositorMacGetNSView() const { |
| 409 return cocoa_view_; | 387 return cocoa_view_; |
| 410 } | 388 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 *timebase = base::TimeTicks(); | 440 *timebase = base::TimeTicks(); |
| 463 *interval = base::TimeDelta(); | 441 *interval = base::TimeDelta(); |
| 464 } | 442 } |
| 465 | 443 |
| 466 void RenderWidgetHostViewMac::AcceleratedWidgetSwapCompleted() { | 444 void RenderWidgetHostViewMac::AcceleratedWidgetSwapCompleted() { |
| 467 if (display_link_) | 445 if (display_link_) |
| 468 display_link_->NotifyCurrentTime(base::TimeTicks::Now()); | 446 display_link_->NotifyCurrentTime(base::TimeTicks::Now()); |
| 469 } | 447 } |
| 470 | 448 |
| 471 /////////////////////////////////////////////////////////////////////////////// | 449 /////////////////////////////////////////////////////////////////////////////// |
| 472 // RenderWidgetHostViewBase, public: | |
| 473 | |
| 474 // static | |
| 475 void RenderWidgetHostViewBase::GetDefaultScreenInfo( | |
| 476 blink::WebScreenInfo* results) { | |
| 477 *results = GetWebScreenInfo(NULL); | |
| 478 } | |
| 479 | |
| 480 /////////////////////////////////////////////////////////////////////////////// | |
| 481 // RenderWidgetHostViewMac, public: | 450 // RenderWidgetHostViewMac, public: |
| 482 | 451 |
| 483 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget, | 452 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget, |
| 484 bool is_guest_view_hack) | 453 bool is_guest_view_hack) |
| 485 : render_widget_host_(RenderWidgetHostImpl::From(widget)), | 454 : render_widget_host_(RenderWidgetHostImpl::From(widget)), |
| 486 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 455 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
| 487 can_compose_inline_(true), | 456 can_compose_inline_(true), |
| 488 page_at_minimum_scale_(true), | 457 page_at_minimum_scale_(true), |
| 489 is_loading_(false), | 458 is_loading_(false), |
| 490 allow_pause_for_resize_or_repaint_(true), | 459 allow_pause_for_resize_or_repaint_(true), |
| (...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1311 DLOG(ERROR) << "Received unexpected frame type."; | 1280 DLOG(ERROR) << "Received unexpected frame type."; |
| 1312 bad_message::ReceivedBadMessage(render_widget_host_->GetProcess(), | 1281 bad_message::ReceivedBadMessage(render_widget_host_->GetProcess(), |
| 1313 bad_message::RWHVM_UNEXPECTED_FRAME_TYPE); | 1282 bad_message::RWHVM_UNEXPECTED_FRAME_TYPE); |
| 1314 } | 1283 } |
| 1315 } | 1284 } |
| 1316 | 1285 |
| 1317 void RenderWidgetHostViewMac::ClearCompositorFrame() { | 1286 void RenderWidgetHostViewMac::ClearCompositorFrame() { |
| 1318 browser_compositor_->GetDelegatedFrameHost()->ClearDelegatedFrame(); | 1287 browser_compositor_->GetDelegatedFrameHost()->ClearDelegatedFrame(); |
| 1319 } | 1288 } |
| 1320 | 1289 |
| 1321 void RenderWidgetHostViewMac::GetScreenInfo(blink::WebScreenInfo* results) { | |
| 1322 *results = GetWebScreenInfo(GetNativeView()); | |
| 1323 } | |
| 1324 | |
| 1325 gfx::Rect RenderWidgetHostViewMac::GetBoundsInRootWindow() { | 1290 gfx::Rect RenderWidgetHostViewMac::GetBoundsInRootWindow() { |
| 1326 // TODO(shess): In case of !window, the view has been removed from | 1291 // TODO(shess): In case of !window, the view has been removed from |
| 1327 // the view hierarchy because the tab isn't main. Could retrieve | 1292 // the view hierarchy because the tab isn't main. Could retrieve |
| 1328 // the information from the main tab for our window. | 1293 // the information from the main tab for our window. |
| 1329 NSWindow* enclosing_window = ApparentWindowForView(cocoa_view_); | 1294 NSWindow* enclosing_window = ApparentWindowForView(cocoa_view_); |
| 1330 if (!enclosing_window) | 1295 if (!enclosing_window) |
| 1331 return gfx::Rect(); | 1296 return gfx::Rect(); |
| 1332 | 1297 |
| 1333 NSRect bounds = [enclosing_window frame]; | 1298 NSRect bounds = [enclosing_window frame]; |
| 1334 return FlipNSRectToRectScreen(bounds); | 1299 return FlipNSRectToRectScreen(bounds); |
| (...skipping 1902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3237 | 3202 |
| 3238 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3203 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 3239 // regions that are not draggable. (See ControlRegionView in | 3204 // regions that are not draggable. (See ControlRegionView in |
| 3240 // native_app_window_cocoa.mm). This requires the render host view to be | 3205 // native_app_window_cocoa.mm). This requires the render host view to be |
| 3241 // draggable by default. | 3206 // draggable by default. |
| 3242 - (BOOL)mouseDownCanMoveWindow { | 3207 - (BOOL)mouseDownCanMoveWindow { |
| 3243 return YES; | 3208 return YES; |
| 3244 } | 3209 } |
| 3245 | 3210 |
| 3246 @end | 3211 @end |
| OLD | NEW |