Title: [175681] branches/safari-600.3-branch/Source/WebKit2
Revision
175681
Author
dburk...@apple.com
Date
2014-11-05 22:30:19 -0800 (Wed, 05 Nov 2014)

Log Message

Merged r175645. <rdar://problems/18887140>

Modified Paths

Diff

Modified: branches/safari-600.3-branch/Source/WebKit2/ChangeLog (175680 => 175681)


--- branches/safari-600.3-branch/Source/WebKit2/ChangeLog	2014-11-06 06:29:11 UTC (rev 175680)
+++ branches/safari-600.3-branch/Source/WebKit2/ChangeLog	2014-11-06 06:30:19 UTC (rev 175681)
@@ -1,5 +1,27 @@
 2014-11-05  Dana Burkart  <dburk...@apple.com>
 
+        Merge r175645. <rdar://problem/18887140>
+
+    2014-11-05  Beth Dakin  <bda...@apple.com>
+    
+            Page preview popover should show scaled-down web content
+            https://bugs.webkit.org/show_bug.cgi?id=138444
+    
+            Reviewed by Anders Carlsson.
+    
+            Instead of keeping the preferred size in the controller, keep the main view’s 
+            size, and then scale the bounds of the popover’s view using that and the scale 
+            factor as a constant. Set the size of the popover explicitly so that it doesn’t 
+            get the view’s size. This will cause it to scale the WKWebView.
+            * UIProcess/mac/WKActionMenuController.mm:
+            (-[WKPagePreviewViewController initWithPageURL:]):
+            (-[WKPagePreviewViewController loadView]):
+            (-[WKActionMenuController _createPreviewPopoverForURL:originRect:]):
+            (-[WKActionMenuController _preferredSizeForPopoverPresentedFromOriginRect:]):
+    
+
+2014-11-05  Dana Burkart  <dburk...@apple.com>
+
         Merge r175643. <rdar://problem/18885782>
 
     2014-11-05  Conrad Shultz  <conrad_shu...@apple.com>

Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm (175680 => 175681)


--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm	2014-11-06 06:29:11 UTC (rev 175680)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm	2014-11-06 06:30:19 UTC (rev 175681)
@@ -60,6 +60,8 @@
 using namespace WebCore;
 using namespace WebKit;
 
+static const CGFloat popoverToViewScale = 0.75;
+
 @interface WKActionMenuController () <NSSharingServiceDelegate, NSSharingServicePickerDelegate, NSPopoverDelegate>
 - (void)_updateActionMenuItemsForStage:(MenuUpdateStage)stage;
 - (BOOL)_canAddImageToPhotos;
@@ -74,7 +76,7 @@
 #if WK_API_ENABLED
 @interface WKPagePreviewViewController : NSViewController {
 @public
-    NSSize _preferredSize;
+    NSSize _mainViewSize;
 
 @private
     RetainPtr<NSURL> _url;
@@ -92,19 +94,22 @@
         return nil;
 
     _url = URL;
-    _preferredSize = NSMakeSize(320, 568);
+    _mainViewSize = NSMakeSize(320, 568);
 
     return self;
 }
 
 - (void)loadView
 {
-    RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, _preferredSize.width, _preferredSize.height)]);
+    RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, _mainViewSize.width, _mainViewSize.height)]);
     [webView _setIgnoresNonWheelMouseEvents:YES];
     if (_url) {
         NSURLRequest *request = [NSURLRequest requestWithURL:_url.get()];
         [webView loadRequest:request];
     }
+
+    // Setting the webView bounds will scale it to 75% of the _mainViewSize. 
+    [webView setBounds:NSMakeRect(0, 0, _mainViewSize.width / popoverToViewScale, _mainViewSize.height / popoverToViewScale)];
     self.view = webView.get();
 }
 
@@ -291,17 +296,17 @@
 - (void)_createPreviewPopoverForURL:(NSURL *)url originRect:(NSRect)originRect
 {
     RetainPtr<WKPagePreviewViewController> previewViewController = adoptNS([[WKPagePreviewViewController alloc] initWithPageURL:url]);
-    previewViewController->_preferredSize = [self _preferredSizeForPopoverPresentedFromOriginRect:originRect];
+    previewViewController->_mainViewSize = _wkView.bounds.size;
 
     _previewPopover = adoptNS([[NSPopover alloc] init]);
     [_previewPopover setBehavior:NSPopoverBehaviorTransient];
+    [_previewPopover setContentSize:[self _preferredSizeForPopoverPresentedFromOriginRect:originRect]];
     [_previewPopover setContentViewController:previewViewController.get()];
     [_previewPopover setDelegate:self];
 }
 
 - (NSSize)_preferredSizeForPopoverPresentedFromOriginRect:(NSRect)originRect
 {
-    static const CGFloat preferredPopoverToWKViewScale = 0.75;
     static const CGFloat screenPadding = 40;
 
     NSWindow *window = _wkView.window;
@@ -317,7 +322,7 @@
     CGFloat maxAvailableHorizontalSpace = fmax(availableSpaceAtLeft, availableSpaceAtRight) - screenPadding;
 
     NSRect wkViewBounds = _wkView.bounds;
-    NSSize preferredSize = NSMakeSize(NSWidth(wkViewBounds) * preferredPopoverToWKViewScale, NSHeight(wkViewBounds) * preferredPopoverToWKViewScale);
+    NSSize preferredSize = NSMakeSize(NSWidth(wkViewBounds) * popoverToViewScale, NSHeight(wkViewBounds) * popoverToViewScale);
     preferredSize.width = fmin(preferredSize.width, maxAvailableHorizontalSpace);
     preferredSize.height = fmin(preferredSize.height, maxAvailableVerticalSpace);
     return preferredSize;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to