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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 if (ancestor_window && (NSWidth([enclosing_window frame]) == | 389 if (ancestor_window && (NSWidth([enclosing_window frame]) == |
390 NSWidth([ancestor_window frame]))) { | 390 NSWidth([ancestor_window frame]))) { |
391 enclosing_window = ancestor_window; | 391 enclosing_window = ancestor_window; |
392 } | 392 } |
393 | 393 |
394 return enclosing_window; | 394 return enclosing_window; |
395 } | 395 } |
396 | 396 |
397 blink::WebScreenInfo GetWebScreenInfo(NSView* view) { | 397 blink::WebScreenInfo GetWebScreenInfo(NSView* view) { |
398 gfx::Display display = | 398 gfx::Display display = |
399 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(view); | 399 gfx::Screen::GetScreen()->GetDisplayNearestWindow(view); |
400 | 400 |
401 NSScreen* screen = [NSScreen deepestScreen]; | 401 NSScreen* screen = [NSScreen deepestScreen]; |
402 | 402 |
403 blink::WebScreenInfo results; | 403 blink::WebScreenInfo results; |
404 | 404 |
405 results.deviceScaleFactor = static_cast<int>(display.device_scale_factor()); | 405 results.deviceScaleFactor = static_cast<int>(display.device_scale_factor()); |
406 results.depth = NSBitsPerPixelFromDepth([screen depth]); | 406 results.depth = NSBitsPerPixelFromDepth([screen depth]); |
407 results.depthPerComponent = NSBitsPerSampleFromDepth([screen depth]); | 407 results.depthPerComponent = NSBitsPerSampleFromDepth([screen depth]); |
408 results.isMonochrome = | 408 results.isMonochrome = |
409 [[screen colorSpace] colorSpaceModel] == NSGrayColorSpaceModel; | 409 [[screen colorSpace] colorSpaceModel] == NSGrayColorSpaceModel; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 background_layer_.reset([[CALayer alloc] init]); | 532 background_layer_.reset([[CALayer alloc] init]); |
533 // Set the default color to be white. This is the wrong thing to do, but many | 533 // Set the default color to be white. This is the wrong thing to do, but many |
534 // UI components expect this view to be opaque. | 534 // UI components expect this view to be opaque. |
535 [background_layer_ setBackgroundColor:CGColorGetConstantColor(kCGColorWhite)]; | 535 [background_layer_ setBackgroundColor:CGColorGetConstantColor(kCGColorWhite)]; |
536 [cocoa_view_ setLayer:background_layer_]; | 536 [cocoa_view_ setLayer:background_layer_]; |
537 [cocoa_view_ setWantsLayer:YES]; | 537 [cocoa_view_ setWantsLayer:YES]; |
538 | 538 |
539 root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); | 539 root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); |
540 delegated_frame_host_.reset(new DelegatedFrameHost(this)); | 540 delegated_frame_host_.reset(new DelegatedFrameHost(this)); |
541 | 541 |
542 gfx::Screen::GetScreenFor(cocoa_view_)->AddObserver(this); | 542 gfx::Screen::GetScreen()->AddObserver(this); |
543 | 543 |
544 if (!is_guest_view_hack_) | 544 if (!is_guest_view_hack_) |
545 render_widget_host_->SetView(this); | 545 render_widget_host_->SetView(this); |
546 | 546 |
547 // Let the page-level input event router know about our surface ID | 547 // Let the page-level input event router know about our surface ID |
548 // namespace for surface-based hit testing. | 548 // namespace for surface-based hit testing. |
549 if (render_widget_host_->delegate() && | 549 if (render_widget_host_->delegate() && |
550 render_widget_host_->delegate()->GetInputEventRouter()) { | 550 render_widget_host_->delegate()->GetInputEventRouter()) { |
551 render_widget_host_->delegate() | 551 render_widget_host_->delegate() |
552 ->GetInputEventRouter() | 552 ->GetInputEventRouter() |
553 ->AddSurfaceIdNamespaceOwner(GetSurfaceIdNamespace(), this); | 553 ->AddSurfaceIdNamespaceOwner(GetSurfaceIdNamespace(), this); |
554 } | 554 } |
555 } | 555 } |
556 | 556 |
557 RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { | 557 RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { |
558 gfx::Screen::GetScreenFor(cocoa_view_)->RemoveObserver(this); | 558 gfx::Screen::GetScreen()->RemoveObserver(this); |
559 | 559 |
560 // This is being called from |cocoa_view_|'s destructor, so invalidate the | 560 // This is being called from |cocoa_view_|'s destructor, so invalidate the |
561 // pointer. | 561 // pointer. |
562 cocoa_view_ = nil; | 562 cocoa_view_ = nil; |
563 | 563 |
564 UnlockMouse(); | 564 UnlockMouse(); |
565 | 565 |
566 if (render_widget_host_ && render_widget_host_->delegate() && | 566 if (render_widget_host_ && render_widget_host_->delegate() && |
567 render_widget_host_->delegate()->GetInputEventRouter()) { | 567 render_widget_host_->delegate()->GetInputEventRouter()) { |
568 render_widget_host_->delegate() | 568 render_widget_host_->delegate() |
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1567 uint32_t RenderWidgetHostViewMac::GetSurfaceIdNamespace() { | 1567 uint32_t RenderWidgetHostViewMac::GetSurfaceIdNamespace() { |
1568 DCHECK(delegated_frame_host_); | 1568 DCHECK(delegated_frame_host_); |
1569 return delegated_frame_host_->GetSurfaceIdNamespace(); | 1569 return delegated_frame_host_->GetSurfaceIdNamespace(); |
1570 } | 1570 } |
1571 | 1571 |
1572 uint32_t RenderWidgetHostViewMac::SurfaceIdNamespaceAtPoint( | 1572 uint32_t RenderWidgetHostViewMac::SurfaceIdNamespaceAtPoint( |
1573 const gfx::Point& point, | 1573 const gfx::Point& point, |
1574 gfx::Point* transformed_point) { | 1574 gfx::Point* transformed_point) { |
1575 // The surface hittest happens in device pixels, so we need to convert the | 1575 // The surface hittest happens in device pixels, so we need to convert the |
1576 // |point| from DIPs to pixels before hittesting. | 1576 // |point| from DIPs to pixels before hittesting. |
1577 float scale_factor = gfx::Screen::GetScreenFor(cocoa_view_) | 1577 float scale_factor = gfx::Screen::GetScreen() |
1578 ->GetDisplayNearestWindow(cocoa_view_) | 1578 ->GetDisplayNearestWindow(cocoa_view_) |
1579 .device_scale_factor(); | 1579 .device_scale_factor(); |
1580 gfx::Point point_in_pixels = gfx::ConvertPointToPixel(scale_factor, point); | 1580 gfx::Point point_in_pixels = gfx::ConvertPointToPixel(scale_factor, point); |
1581 cc::SurfaceId id = delegated_frame_host_->SurfaceIdAtPoint(point_in_pixels, | 1581 cc::SurfaceId id = delegated_frame_host_->SurfaceIdAtPoint(point_in_pixels, |
1582 transformed_point); | 1582 transformed_point); |
1583 *transformed_point = gfx::ConvertPointToDIP(scale_factor, *transformed_point); | 1583 *transformed_point = gfx::ConvertPointToDIP(scale_factor, *transformed_point); |
1584 | 1584 |
1585 // It is possible that the renderer has not yet produced a surface, in which | 1585 // It is possible that the renderer has not yet produced a surface, in which |
1586 // case we return our current namespace. | 1586 // case we return our current namespace. |
1587 if (id.is_null()) | 1587 if (id.is_null()) |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1752 // gfx::DisplayObserver, public: | 1752 // gfx::DisplayObserver, public: |
1753 | 1753 |
1754 void RenderWidgetHostViewMac::OnDisplayAdded(const gfx::Display& display) { | 1754 void RenderWidgetHostViewMac::OnDisplayAdded(const gfx::Display& display) { |
1755 } | 1755 } |
1756 | 1756 |
1757 void RenderWidgetHostViewMac::OnDisplayRemoved(const gfx::Display& display) { | 1757 void RenderWidgetHostViewMac::OnDisplayRemoved(const gfx::Display& display) { |
1758 } | 1758 } |
1759 | 1759 |
1760 void RenderWidgetHostViewMac::OnDisplayMetricsChanged( | 1760 void RenderWidgetHostViewMac::OnDisplayMetricsChanged( |
1761 const gfx::Display& display, uint32_t metrics) { | 1761 const gfx::Display& display, uint32_t metrics) { |
1762 gfx::Screen* screen = gfx::Screen::GetScreenFor(cocoa_view_); | 1762 gfx::Screen* screen = gfx::Screen::GetScreen(); |
1763 if (display.id() != screen->GetDisplayNearestWindow(cocoa_view_).id()) | 1763 if (display.id() != screen->GetDisplayNearestWindow(cocoa_view_).id()) |
1764 return; | 1764 return; |
1765 | 1765 |
1766 UpdateScreenInfo(cocoa_view_); | 1766 UpdateScreenInfo(cocoa_view_); |
1767 } | 1767 } |
1768 | 1768 |
1769 } // namespace content | 1769 } // namespace content |
1770 | 1770 |
1771 // RenderWidgetHostViewCocoa --------------------------------------------------- | 1771 // RenderWidgetHostViewCocoa --------------------------------------------------- |
1772 | 1772 |
(...skipping 1663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3436 | 3436 |
3437 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3437 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
3438 // regions that are not draggable. (See ControlRegionView in | 3438 // regions that are not draggable. (See ControlRegionView in |
3439 // native_app_window_cocoa.mm). This requires the render host view to be | 3439 // native_app_window_cocoa.mm). This requires the render host view to be |
3440 // draggable by default. | 3440 // draggable by default. |
3441 - (BOOL)mouseDownCanMoveWindow { | 3441 - (BOOL)mouseDownCanMoveWindow { |
3442 return YES; | 3442 return YES; |
3443 } | 3443 } |
3444 | 3444 |
3445 @end | 3445 @end |
OLD | NEW |