Support overriding the deviceScaleFactor per WKWebView/WKView
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Feb 2015 20:46:19 +0000 (20:46 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Feb 2015 20:46:19 +0000 (20:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=141311

Reviewed by Tim Horton.

* UIProcess/API/Cocoa/WKViewPrivate.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _setOverrideDeviceScaleFactor:]):
(-[WKWebView _overrideDeviceScaleFactor]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/API/mac/WKView.mm:
(-[WKView _intrinsicDeviceScaleFactor]):
(-[WKView _setOverrideDeviceScaleFactor:]):
(-[WKView _overrideDeviceScaleFactor]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@179752 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h
Source/WebKit2/UIProcess/API/mac/WKView.mm

index a903623..c058e47 100644 (file)
@@ -1,3 +1,20 @@
+2015-02-05  Timothy Hatcher  <timothy@apple.com>
+
+        Support overriding the deviceScaleFactor per WKWebView/WKView
+        https://bugs.webkit.org/show_bug.cgi?id=141311
+
+        Reviewed by Tim Horton.
+
+        * UIProcess/API/Cocoa/WKViewPrivate.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _setOverrideDeviceScaleFactor:]):
+        (-[WKWebView _overrideDeviceScaleFactor]):
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView _intrinsicDeviceScaleFactor]):
+        (-[WKView _setOverrideDeviceScaleFactor:]):
+        (-[WKView _overrideDeviceScaleFactor]):
+
 2015-02-06  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] Remove WebKitWebView::close-notification signal
index a719a79..5d4a147 100644 (file)
@@ -90,6 +90,8 @@
 @property (nonatomic, setter=_setTopContentInset:) CGFloat _topContentInset;
 @property (nonatomic, setter=_setTotalHeightOfBanners:) CGFloat _totalHeightOfBanners;
 
+@property (nonatomic, setter=_setOverrideDeviceScaleFactor:) CGFloat _overrideDeviceScaleFactor WK_AVAILABLE(WK_MAC_TBA, NA);
+
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
 @property (nonatomic, setter=_setAutomaticallyAdjustsContentInsets:) BOOL _automaticallyAdjustsContentInsets;
 #endif
index 66b3797..db8f1dd 100644 (file)
@@ -2530,6 +2530,16 @@ static inline WebKit::FindOptions toFindOptions(_WKFindOptions wkFindOptions)
     _page->setDrawsTransparentBackground(drawsTransparentBackground);
 }
 
+- (void)_setOverrideDeviceScaleFactor:(CGFloat)deviceScaleFactor
+{
+    [_wkView _setOverrideDeviceScaleFactor:deviceScaleFactor];
+}
+
+- (CGFloat)_overrideDeviceScaleFactor
+{
+    return [_wkView _overrideDeviceScaleFactor];
+}
+
 - (void)_setTopContentInset:(CGFloat)contentInset
 {
     [_wkView _setTopContentInset:contentInset];
index d2400cc..3971fce 100644 (file)
@@ -155,9 +155,13 @@ typedef NS_OPTIONS(NSUInteger, _WKFindOptions) {
 @property (readonly) NSColor *_pageExtendedBackgroundColor;
 @property (nonatomic, setter=_setDrawsTransparentBackground:) BOOL _drawsTransparentBackground;
 @property (nonatomic, setter=_setTopContentInset:) CGFloat _topContentInset;
+
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
 @property (nonatomic, setter=_setAutomaticallyAdjustsContentInsets:) BOOL _automaticallyAdjustsContentInsets;
 #endif
+
+// Default value is 0. A value of 0 means the window's backing scale factor will be used and automatically update when the window moves screens.
+@property (nonatomic, setter=_setOverrideDeviceScaleFactor:) CGFloat _overrideDeviceScaleFactor WK_AVAILABLE(WK_MAC_TBA, NA);
 #endif
 
 - (void)_getMainResourceDataWithCompletionHandler:(void (^)(NSData *, NSError *))completionHandler;
index 41d14c9..6a90a83 100644 (file)
@@ -262,6 +262,8 @@ struct WKViewInterpretKeyEventsParameters {
     CGFloat _topContentInset;
     CGFloat _totalHeightOfBanners;
 
+    CGFloat _overrideDeviceScaleFactor;
+
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
     BOOL _automaticallyAdjustsContentInsets;
     RetainPtr<WKActionMenuController> _actionMenuController;
@@ -2828,6 +2830,8 @@ static void* keyValueObservingContext = &keyValueObservingContext;
 
 - (float)_intrinsicDeviceScaleFactor
 {
+    if (_data->_overrideDeviceScaleFactor)
+        return _data->_overrideDeviceScaleFactor;
     if (_data->_targetWindowForMovePreparation)
         return [_data->_targetWindowForMovePreparation backingScaleFactor];
     if (NSWindow *window = [self window])
@@ -4127,6 +4131,17 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path)
     return _data->_ignoresAllEvents;
 }
 
+- (void)_setOverrideDeviceScaleFactor:(CGFloat)deviceScaleFactor
+{
+    _data->_overrideDeviceScaleFactor = deviceScaleFactor;
+    _data->_page->setIntrinsicDeviceScaleFactor([self _intrinsicDeviceScaleFactor]);
+}
+
+- (CGFloat)_overrideDeviceScaleFactor
+{
+    return _data->_overrideDeviceScaleFactor;
+}
+
 - (void)_dispatchSetTopContentInset
 {
     if (!_data->_didScheduleSetTopContentInset)