Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 2122023002: Cross-process frames should be notified of device scale factor changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Version of patch without second test. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 836 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 DLOG(ERROR) << "Received unexpected frame type."; 1296 DLOG(ERROR) << "Received unexpected frame type.";
1328 bad_message::ReceivedBadMessage(render_widget_host_->GetProcess(), 1297 bad_message::ReceivedBadMessage(render_widget_host_->GetProcess(),
1329 bad_message::RWHVM_UNEXPECTED_FRAME_TYPE); 1298 bad_message::RWHVM_UNEXPECTED_FRAME_TYPE);
1330 } 1299 }
1331 } 1300 }
1332 1301
1333 void RenderWidgetHostViewMac::ClearCompositorFrame() { 1302 void RenderWidgetHostViewMac::ClearCompositorFrame() {
1334 browser_compositor_->GetDelegatedFrameHost()->ClearDelegatedFrame(); 1303 browser_compositor_->GetDelegatedFrameHost()->ClearDelegatedFrame();
1335 } 1304 }
1336 1305
1337 void RenderWidgetHostViewMac::GetScreenInfo(blink::WebScreenInfo* results) {
1338 *results = GetWebScreenInfo(GetNativeView());
1339 }
1340
1341 gfx::Rect RenderWidgetHostViewMac::GetBoundsInRootWindow() { 1306 gfx::Rect RenderWidgetHostViewMac::GetBoundsInRootWindow() {
1342 // TODO(shess): In case of !window, the view has been removed from 1307 // TODO(shess): In case of !window, the view has been removed from
1343 // the view hierarchy because the tab isn't main. Could retrieve 1308 // the view hierarchy because the tab isn't main. Could retrieve
1344 // the information from the main tab for our window. 1309 // the information from the main tab for our window.
1345 NSWindow* enclosing_window = ApparentWindowForView(cocoa_view_); 1310 NSWindow* enclosing_window = ApparentWindowForView(cocoa_view_);
1346 if (!enclosing_window) 1311 if (!enclosing_window)
1347 return gfx::Rect(); 1312 return gfx::Rect();
1348 1313
1349 NSRect bounds = [enclosing_window frame]; 1314 NSRect bounds = [enclosing_window frame];
1350 return FlipNSRectToRectScreen(bounds); 1315 return FlipNSRectToRectScreen(bounds);
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 //////////////////////////////////////////////////////////////////////////////// 1567 ////////////////////////////////////////////////////////////////////////////////
1603 // display::DisplayObserver, public: 1568 // display::DisplayObserver, public:
1604 1569
1605 void RenderWidgetHostViewMac::OnDisplayAdded(const display::Display& display) {} 1570 void RenderWidgetHostViewMac::OnDisplayAdded(const display::Display& display) {}
1606 1571
1607 void RenderWidgetHostViewMac::OnDisplayRemoved( 1572 void RenderWidgetHostViewMac::OnDisplayRemoved(
1608 const display::Display& display) {} 1573 const display::Display& display) {}
1609 1574
1610 void RenderWidgetHostViewMac::OnDisplayMetricsChanged( 1575 void RenderWidgetHostViewMac::OnDisplayMetricsChanged(
1611 const display::Display& display, 1576 const display::Display& display,
1612 uint32_t metrics) { 1577 uint32_t changed_metrics) {
1613 display::Screen* screen = display::Screen::GetScreen(); 1578 display::Screen* screen = display::Screen::GetScreen();
1614 if (display.id() != screen->GetDisplayNearestWindow(cocoa_view_).id()) 1579 if (display.id() != screen->GetDisplayNearestWindow(cocoa_view_).id())
1615 return; 1580 return;
1616 1581
1582 if (changed_metrics & DisplayObserver::DISPLAY_METRIC_DEVICE_SCALE_FACTOR) {
1583 RenderWidgetHostImpl* host =
1584 RenderWidgetHostImpl::From(GetRenderWidgetHost());
1585 if (host && host->delegate())
1586 host->delegate()->UpdateDeviceScaleFactor(display.device_scale_factor());
1587 }
1588
1617 UpdateScreenInfo(cocoa_view_); 1589 UpdateScreenInfo(cocoa_view_);
1618 } 1590 }
1619 1591
1620 } // namespace content 1592 } // namespace content
1621 1593
1622 // RenderWidgetHostViewCocoa --------------------------------------------------- 1594 // RenderWidgetHostViewCocoa ---------------------------------------------------
1623 1595
1624 @implementation RenderWidgetHostViewCocoa 1596 @implementation RenderWidgetHostViewCocoa
1625 @synthesize selectedRange = selectedRange_; 1597 @synthesize selectedRange = selectedRange_;
1626 @synthesize suppressNextEscapeKeyUp = suppressNextEscapeKeyUp_; 1598 @synthesize suppressNextEscapeKeyUp = suppressNextEscapeKeyUp_;
(...skipping 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after
3255 3227
3256 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding 3228 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding
3257 // regions that are not draggable. (See ControlRegionView in 3229 // regions that are not draggable. (See ControlRegionView in
3258 // native_app_window_cocoa.mm). This requires the render host view to be 3230 // native_app_window_cocoa.mm). This requires the render host view to be
3259 // draggable by default. 3231 // draggable by default.
3260 - (BOOL)mouseDownCanMoveWindow { 3232 - (BOOL)mouseDownCanMoveWindow {
3261 return YES; 3233 return YES;
3262 } 3234 }
3263 3235
3264 @end 3236 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698