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

Side by Side Diff: content/browser/web_contents/web_contents_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 #import <Carbon/Carbon.h> 5 #import <Carbon/Carbon.h>
6 6
7 #import "content/browser/web_contents/web_contents_view_mac.h" 7 #import "content/browser/web_contents/web_contents_view_mac.h"
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 12 matching lines...) Expand all
23 #import "content/browser/web_contents/web_drag_source_mac.h" 23 #import "content/browser/web_contents/web_drag_source_mac.h"
24 #include "content/common/view_messages.h" 24 #include "content/common/view_messages.h"
25 #include "content/public/browser/web_contents_delegate.h" 25 #include "content/public/browser/web_contents_delegate.h"
26 #include "content/public/browser/web_contents_view_delegate.h" 26 #include "content/public/browser/web_contents_view_delegate.h"
27 #include "content/public/common/content_switches.h" 27 #include "content/public/common/content_switches.h"
28 #include "skia/ext/skia_utils_mac.h" 28 #include "skia/ext/skia_utils_mac.h"
29 #import "third_party/mozilla/NSPasteboard+Utils.h" 29 #import "third_party/mozilla/NSPasteboard+Utils.h"
30 #include "ui/base/clipboard/custom_data_helper.h" 30 #include "ui/base/clipboard/custom_data_helper.h"
31 #import "ui/base/cocoa/focus_tracker.h" 31 #import "ui/base/cocoa/focus_tracker.h"
32 #include "ui/base/dragdrop/cocoa_dnd_util.h" 32 #include "ui/base/dragdrop/cocoa_dnd_util.h"
33 #include "ui/display/screen.h"
33 #include "ui/gfx/image/image_skia_util_mac.h" 34 #include "ui/gfx/image/image_skia_util_mac.h"
34 35
35 using blink::WebDragOperation; 36 using blink::WebDragOperation;
36 using blink::WebDragOperationsMask; 37 using blink::WebDragOperationsMask;
37 using content::DropData; 38 using content::DropData;
38 using content::PopupMenuHelper; 39 using content::PopupMenuHelper;
39 using content::RenderViewHostFactory; 40 using content::RenderViewHostFactory;
40 using content::RenderWidgetHostView; 41 using content::RenderWidgetHostView;
41 using content::RenderWidgetHostViewMac; 42 using content::RenderWidgetHostViewMac;
42 using content::WebContents; 43 using content::WebContents;
(...skipping 24 matching lines...) Expand all
67 image:(NSImage*)image 68 image:(NSImage*)image
68 offset:(NSPoint)offset; 69 offset:(NSPoint)offset;
69 - (void)cancelDeferredClose; 70 - (void)cancelDeferredClose;
70 - (void)clearWebContentsView; 71 - (void)clearWebContentsView;
71 - (void)closeTabAfterEvent; 72 - (void)closeTabAfterEvent;
72 - (void)updateWebContentsVisibility; 73 - (void)updateWebContentsVisibility;
73 - (void)viewDidBecomeFirstResponder:(NSNotification*)notification; 74 - (void)viewDidBecomeFirstResponder:(NSNotification*)notification;
74 - (content::WebContentsImpl*)webContents; 75 - (content::WebContentsImpl*)webContents;
75 @end 76 @end
76 77
78 namespace {
79
80 blink::WebScreenInfo GetWebScreenInfo(NSView* view) {
81 display::Display display =
82 display::Screen::GetScreen()->GetDisplayNearestWindow(view);
83
84 NSScreen* screen = [NSScreen deepestScreen];
85
86 blink::WebScreenInfo results;
87
88 results.deviceScaleFactor = static_cast<int>(display.device_scale_factor());
89 results.depth = NSBitsPerPixelFromDepth([screen depth]);
90 results.depthPerComponent = NSBitsPerSampleFromDepth([screen depth]);
91 results.isMonochrome =
92 [[screen colorSpace] colorSpaceModel] == NSGrayColorSpaceModel;
93 results.rect = display.bounds();
94 results.availableRect = display.work_area();
95 results.orientationAngle = display.RotationAsDegree();
96 results.orientationType =
97 content::RenderWidgetHostViewBase::GetOrientationTypeForDesktop(display);
98
99 return results;
100 }
101
102 } // namespace
103
77 namespace content { 104 namespace content {
78 105
106 // static
107 void WebContentsView::GetDefaultScreenInfo(
108 blink::WebScreenInfo* results) {
109 *results = GetWebScreenInfo(NULL);
110 }
111
79 WebContentsView* CreateWebContentsView( 112 WebContentsView* CreateWebContentsView(
80 WebContentsImpl* web_contents, 113 WebContentsImpl* web_contents,
81 WebContentsViewDelegate* delegate, 114 WebContentsViewDelegate* delegate,
82 RenderViewHostDelegateView** render_view_host_delegate_view) { 115 RenderViewHostDelegateView** render_view_host_delegate_view) {
83 WebContentsViewMac* rv = new WebContentsViewMac(web_contents, delegate); 116 WebContentsViewMac* rv = new WebContentsViewMac(web_contents, delegate);
84 *render_view_host_delegate_view = rv; 117 *render_view_host_delegate_view = rv;
85 return rv; 118 return rv;
86 } 119 }
87 120
88 WebContentsViewMac::WebContentsViewMac(WebContentsImpl* web_contents, 121 WebContentsViewMac::WebContentsViewMac(WebContentsImpl* web_contents,
(...skipping 21 matching lines...) Expand all
110 if (!rwhv) 143 if (!rwhv)
111 return NULL; 144 return NULL;
112 return rwhv->GetNativeView(); 145 return rwhv->GetNativeView();
113 } 146 }
114 147
115 gfx::NativeWindow WebContentsViewMac::GetTopLevelNativeWindow() const { 148 gfx::NativeWindow WebContentsViewMac::GetTopLevelNativeWindow() const {
116 NSWindow* window = [cocoa_view_.get() window]; 149 NSWindow* window = [cocoa_view_.get() window];
117 return window ? window : delegate_->GetNativeWindow(); 150 return window ? window : delegate_->GetNativeWindow();
118 } 151 }
119 152
153 void WebContentsViewMac::GetScreenInfo(blink::WebScreenInfo* results) const {
154 *results = GetWebScreenInfo(GetNativeView());
155 }
156
120 void WebContentsViewMac::GetContainerBounds(gfx::Rect* out) const { 157 void WebContentsViewMac::GetContainerBounds(gfx::Rect* out) const {
121 NSWindow* window = [cocoa_view_.get() window]; 158 NSWindow* window = [cocoa_view_.get() window];
122 NSRect bounds = [cocoa_view_.get() bounds]; 159 NSRect bounds = [cocoa_view_.get() bounds];
123 if (window) { 160 if (window) {
124 // Convert bounds to window coordinate space. 161 // Convert bounds to window coordinate space.
125 bounds = [cocoa_view_.get() convertRect:bounds toView:nil]; 162 bounds = [cocoa_view_.get() convertRect:bounds toView:nil];
126 163
127 // Convert bounds to screen coordinate space. 164 // Convert bounds to screen coordinate space.
128 bounds = [window convertRectToScreen:bounds]; 165 bounds = [window convertRectToScreen:bounds];
129 } 166 }
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 714
678 - (void)viewDidHide { 715 - (void)viewDidHide {
679 [self updateWebContentsVisibility]; 716 [self updateWebContentsVisibility];
680 } 717 }
681 718
682 - (void)viewDidUnhide { 719 - (void)viewDidUnhide {
683 [self updateWebContentsVisibility]; 720 [self updateWebContentsVisibility];
684 } 721 }
685 722
686 @end 723 @end
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_view_mac.h ('k') | content/browser/web_contents/web_contents_view_mus.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698