| 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 page_at_minimum_scale_(true), | 455 page_at_minimum_scale_(true), |
| 487 is_loading_(false), | 456 is_loading_(false), |
| 488 allow_pause_for_resize_or_repaint_(true), | 457 allow_pause_for_resize_or_repaint_(true), |
| 489 is_guest_view_hack_(is_guest_view_hack), | 458 is_guest_view_hack_(is_guest_view_hack), |
| 490 fullscreen_parent_host_view_(nullptr), | 459 fullscreen_parent_host_view_(nullptr), |
| (...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1325 DLOG(ERROR) << "Received unexpected frame type."; | 1294 DLOG(ERROR) << "Received unexpected frame type."; |
| 1326 bad_message::ReceivedBadMessage(render_widget_host_->GetProcess(), | 1295 bad_message::ReceivedBadMessage(render_widget_host_->GetProcess(), |
| 1327 bad_message::RWHVM_UNEXPECTED_FRAME_TYPE); | 1296 bad_message::RWHVM_UNEXPECTED_FRAME_TYPE); |
| 1328 } | 1297 } |
| 1329 } | 1298 } |
| 1330 | 1299 |
| 1331 void RenderWidgetHostViewMac::ClearCompositorFrame() { | 1300 void RenderWidgetHostViewMac::ClearCompositorFrame() { |
| 1332 browser_compositor_->GetDelegatedFrameHost()->ClearDelegatedFrame(); | 1301 browser_compositor_->GetDelegatedFrameHost()->ClearDelegatedFrame(); |
| 1333 } | 1302 } |
| 1334 | 1303 |
| 1335 void RenderWidgetHostViewMac::GetScreenInfo(blink::WebScreenInfo* results) { | |
| 1336 *results = GetWebScreenInfo(GetNativeView()); | |
| 1337 } | |
| 1338 | |
| 1339 gfx::Rect RenderWidgetHostViewMac::GetBoundsInRootWindow() { | 1304 gfx::Rect RenderWidgetHostViewMac::GetBoundsInRootWindow() { |
| 1340 // TODO(shess): In case of !window, the view has been removed from | 1305 // TODO(shess): In case of !window, the view has been removed from |
| 1341 // the view hierarchy because the tab isn't main. Could retrieve | 1306 // the view hierarchy because the tab isn't main. Could retrieve |
| 1342 // the information from the main tab for our window. | 1307 // the information from the main tab for our window. |
| 1343 NSWindow* enclosing_window = ApparentWindowForView(cocoa_view_); | 1308 NSWindow* enclosing_window = ApparentWindowForView(cocoa_view_); |
| 1344 if (!enclosing_window) | 1309 if (!enclosing_window) |
| 1345 return gfx::Rect(); | 1310 return gfx::Rect(); |
| 1346 | 1311 |
| 1347 NSRect bounds = [enclosing_window frame]; | 1312 NSRect bounds = [enclosing_window frame]; |
| 1348 return FlipNSRectToRectScreen(bounds); | 1313 return FlipNSRectToRectScreen(bounds); |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1600 //////////////////////////////////////////////////////////////////////////////// | 1565 //////////////////////////////////////////////////////////////////////////////// |
| 1601 // display::DisplayObserver, public: | 1566 // display::DisplayObserver, public: |
| 1602 | 1567 |
| 1603 void RenderWidgetHostViewMac::OnDisplayAdded(const display::Display& display) {} | 1568 void RenderWidgetHostViewMac::OnDisplayAdded(const display::Display& display) {} |
| 1604 | 1569 |
| 1605 void RenderWidgetHostViewMac::OnDisplayRemoved( | 1570 void RenderWidgetHostViewMac::OnDisplayRemoved( |
| 1606 const display::Display& display) {} | 1571 const display::Display& display) {} |
| 1607 | 1572 |
| 1608 void RenderWidgetHostViewMac::OnDisplayMetricsChanged( | 1573 void RenderWidgetHostViewMac::OnDisplayMetricsChanged( |
| 1609 const display::Display& display, | 1574 const display::Display& display, |
| 1610 uint32_t metrics) { | 1575 uint32_t changed_metrics) { |
| 1611 display::Screen* screen = display::Screen::GetScreen(); | 1576 display::Screen* screen = display::Screen::GetScreen(); |
| 1612 if (display.id() != screen->GetDisplayNearestWindow(cocoa_view_).id()) | 1577 if (display.id() != screen->GetDisplayNearestWindow(cocoa_view_).id()) |
| 1613 return; | 1578 return; |
| 1614 | 1579 |
| 1580 if (changed_metrics & DisplayObserver::DISPLAY_METRIC_DEVICE_SCALE_FACTOR) { |
| 1581 RenderWidgetHostImpl* host = |
| 1582 RenderWidgetHostImpl::From(GetRenderWidgetHost()); |
| 1583 if (host && host->delegate()) |
| 1584 host->delegate()->UpdateDeviceScaleFactor(display.device_scale_factor()); |
| 1585 } |
| 1586 |
| 1615 UpdateScreenInfo(cocoa_view_); | 1587 UpdateScreenInfo(cocoa_view_); |
| 1616 } | 1588 } |
| 1617 | 1589 |
| 1618 } // namespace content | 1590 } // namespace content |
| 1619 | 1591 |
| 1620 // RenderWidgetHostViewCocoa --------------------------------------------------- | 1592 // RenderWidgetHostViewCocoa --------------------------------------------------- |
| 1621 | 1593 |
| 1622 @implementation RenderWidgetHostViewCocoa | 1594 @implementation RenderWidgetHostViewCocoa |
| 1623 @synthesize selectedRange = selectedRange_; | 1595 @synthesize selectedRange = selectedRange_; |
| 1624 @synthesize suppressNextEscapeKeyUp = suppressNextEscapeKeyUp_; | 1596 @synthesize suppressNextEscapeKeyUp = suppressNextEscapeKeyUp_; |
| (...skipping 1634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3259 | 3231 |
| 3260 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3232 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 3261 // regions that are not draggable. (See ControlRegionView in | 3233 // regions that are not draggable. (See ControlRegionView in |
| 3262 // native_app_window_cocoa.mm). This requires the render host view to be | 3234 // native_app_window_cocoa.mm). This requires the render host view to be |
| 3263 // draggable by default. | 3235 // draggable by default. |
| 3264 - (BOOL)mouseDownCanMoveWindow { | 3236 - (BOOL)mouseDownCanMoveWindow { |
| 3265 return YES; | 3237 return YES; |
| 3266 } | 3238 } |
| 3267 | 3239 |
| 3268 @end | 3240 @end |
| OLD | NEW |