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

Unified Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 10537067: mac: Basic HighDPI implementation for web contents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: done Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/web_contents/web_contents_impl.cc » ('j') | ui/gfx/screen_mac.mm » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_widget_host_view_mac.mm
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm
index 540f830b764aaaa9c9d1774d70aef65c6010561c..ddc7c1c04ce5f379f1860dcf017b6d0a00f70427 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -95,8 +95,18 @@ typedef unsigned long long NSEventMask;
handler:(NSEvent* (^)(NSEvent*))block;
+ (void)removeMonitor:(id)eventMonitor;
@end
+
+@interface NSScreen (LionAPI)
+- (CGFloat)backingScaleFactor;
+@end
+
+@interface NSWindow (LionAPI)
+- (CGFloat)backingScaleFactor;
+@end
+
#endif // 10.7
+
static inline int ToWebKitModifiers(NSUInteger flags) {
int modifiers = 0;
if (flags & NSControlKeyMask) modifiers |= WebInputEvent::ControlKey;
@@ -780,8 +790,21 @@ bool RenderWidgetHostViewMac::IsPopup() const {
BackingStore* RenderWidgetHostViewMac::AllocBackingStore(
const gfx::Size& size) {
- // TODO(thakis): Pass correct scale factor.
- return new BackingStoreMac(render_widget_host_, size, 1.0);
+ // TODO(thakis): Register for backing scale factor change events and pass
+ // that on.
+ float scale = 1;
+ if (NSWindow* window = [cocoa_view_ window]) {
+ if ([window respondsToSelector:@selector(backingScaleFactor)])
+ scale = [window backingScaleFactor];
+ else
+ scale = [window userSpaceScaleFactor];
+ } else if (NSScreen* screen = [NSScreen mainScreen]) {
+ if ([screen respondsToSelector:@selector(backingScaleFactor)])
+ scale = [screen backingScaleFactor];
+ else
+ scale = [screen userSpaceScaleFactor];
+ }
+ return new BackingStoreMac(render_widget_host_, size, scale);
}
void RenderWidgetHostViewMac::CopyFromCompositingSurface(
@@ -1948,6 +1971,7 @@ void RenderWidgetHostViewMac::SetTextInputActive(bool active) {
}
if (backingStore) {
+ // Note: All coordinates are in view units, not pixels.
gfx::Rect bitmapRect(0, 0,
backingStore->size().width(),
backingStore->size().height());
« no previous file with comments | « no previous file | content/browser/web_contents/web_contents_impl.cc » ('j') | ui/gfx/screen_mac.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698