Add a layout mode that scales down the view to try to fit the document
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 May 2015 22:46:15 +0000 (22:46 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 May 2015 22:46:15 +0000 (22:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=145022
<rdar://problem/19790341>

Reviewed by Dean Jackson.

* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode):
(WebKit::WebPageCreationParameters::decode):
* Shared/WebPageCreationParameters.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::creationParameters):
(WebKit::WebPageProxy::setShouldScaleViewToFitDocument):
* UIProcess/WebPageProxy.h:
* WebProcess/WebPage/DrawingArea.h:
(WebKit::DrawingArea::setShouldScaleViewToFitDocument):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):
(WebKit::WebPage::setShouldScaleViewToFitDocument):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
Plumb shouldScaleViewToFitDocument through to the DrawingArea.

* UIProcess/mac/WKViewLayoutStrategy.mm:
(+[WKViewLayoutStrategy layoutStrategyWithPage:view:mode:]):
(-[WKViewDynamicSizeComputedFromMinimumDocumentSizeLayoutStrategy initWithPage:view:mode:]):
(-[WKViewDynamicSizeComputedFromMinimumDocumentSizeLayoutStrategy updateLayout]):
(-[WKViewDynamicSizeComputedFromMinimumDocumentSizeLayoutStrategy willChangeLayoutStrategy]):
* UIProcess/API/C/WKLayoutMode.h:
* UIProcess/API/Cocoa/_WKLayoutMode.h:
Add a new layout mode, which just turns on shouldScaleViewToFitDocument,
and otherwise behaves as normal.

* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::setShouldScaleViewToFitDocument):
(WebKit::TiledCoreAnimationDrawingArea::scaleViewToFitDocumentIfNeeded):
(WebKit::TiledCoreAnimationDrawingArea::flushLayers):
On every flush where either the document size or view size has changed,
or layout is outstanding, do a layout with fixed layout off to determine
whether the document fits inside the view. If it doesn't, scale it down
to fit. This will require an extra layout for every resize while in the
scaled-down state, but there is potential for future optimization.

* MiniBrowser/mac/BrowserWindow.xib:
* MiniBrowser/mac/BrowserWindowController.h:
* MiniBrowser/mac/WK2BrowserWindowController.m:
(-[WK2BrowserWindowController toggleShrinkToFit:]):
(-[WK2BrowserWindowController toggleUseMinimumViewSize:]): Deleted.
Switch to _WKLayoutModeDynamicSizeComputedFromMinimumDocumentSize.

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

20 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebPageCreationParameters.cpp
Source/WebKit2/Shared/WebPageCreationParameters.h
Source/WebKit2/UIProcess/API/C/WKLayoutMode.h
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/Cocoa/_WKLayoutMode.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/mac/WKViewLayoutStrategy.mm
Source/WebKit2/WebProcess/WebPage/DrawingArea.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h
Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm
Tools/ChangeLog
Tools/MiniBrowser/mac/BrowserWindow.xib
Tools/MiniBrowser/mac/BrowserWindowController.h
Tools/MiniBrowser/mac/WK1BrowserWindowController.m
Tools/MiniBrowser/mac/WK2BrowserWindowController.m

index 915ed86..e928ef6 100644 (file)
@@ -1,3 +1,49 @@
+2015-05-14  Timothy Horton  <timothy_horton@apple.com>
+
+        Add a layout mode that scales down the view to try to fit the document
+        https://bugs.webkit.org/show_bug.cgi?id=145022
+        <rdar://problem/19790341>
+
+        Reviewed by Dean Jackson.
+
+        * Shared/WebPageCreationParameters.cpp:
+        (WebKit::WebPageCreationParameters::encode):
+        (WebKit::WebPageCreationParameters::decode):
+        * Shared/WebPageCreationParameters.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::creationParameters):
+        (WebKit::WebPageProxy::setShouldScaleViewToFitDocument):
+        * UIProcess/WebPageProxy.h:
+        * WebProcess/WebPage/DrawingArea.h:
+        (WebKit::DrawingArea::setShouldScaleViewToFitDocument):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::WebPage):
+        (WebKit::WebPage::setShouldScaleViewToFitDocument):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+        Plumb shouldScaleViewToFitDocument through to the DrawingArea.
+
+        * UIProcess/mac/WKViewLayoutStrategy.mm:
+        (+[WKViewLayoutStrategy layoutStrategyWithPage:view:mode:]):
+        (-[WKViewDynamicSizeComputedFromMinimumDocumentSizeLayoutStrategy initWithPage:view:mode:]):
+        (-[WKViewDynamicSizeComputedFromMinimumDocumentSizeLayoutStrategy updateLayout]):
+        (-[WKViewDynamicSizeComputedFromMinimumDocumentSizeLayoutStrategy willChangeLayoutStrategy]):
+        * UIProcess/API/C/WKLayoutMode.h:
+        * UIProcess/API/Cocoa/_WKLayoutMode.h:
+        Add a new layout mode, which just turns on shouldScaleViewToFitDocument,
+        and otherwise behaves as normal.
+
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+        (WebKit::TiledCoreAnimationDrawingArea::setShouldScaleViewToFitDocument):
+        (WebKit::TiledCoreAnimationDrawingArea::scaleViewToFitDocumentIfNeeded):
+        (WebKit::TiledCoreAnimationDrawingArea::flushLayers):
+        On every flush where either the document size or view size has changed,
+        or layout is outstanding, do a layout with fixed layout off to determine
+        whether the document fits inside the view. If it doesn't, scale it down
+        to fit. This will require an extra layout for every resize while in the
+        scaled-down state, but there is potential for future optimization.
+
 2015-05-14  Anders Carlsson  <andersca@apple.com>
 
         Local storage origins should include origins with transient local storage
index f8c118c..9f8e348 100644 (file)
@@ -83,6 +83,7 @@ void WebPageCreationParameters::encode(IPC::ArgumentEncoder& encoder) const
     encoder << textAutosizingWidth;
 #endif
     encoder << appleMailPaginationQuirkEnabled;
+    encoder << shouldScaleViewToFitDocument;
 }
 
 bool WebPageCreationParameters::decode(IPC::ArgumentDecoder& decoder, WebPageCreationParameters& parameters)
@@ -184,6 +185,9 @@ bool WebPageCreationParameters::decode(IPC::ArgumentDecoder& decoder, WebPageCre
     if (!decoder.decode(parameters.appleMailPaginationQuirkEnabled))
         return false;
 
+    if (!decoder.decode(parameters.shouldScaleViewToFitDocument))
+        return false;
+
     return true;
 }
 
index 6fbf7dd..f0ea190 100644 (file)
@@ -129,6 +129,7 @@ struct WebPageCreationParameters {
     float textAutosizingWidth;
 #endif
     bool appleMailPaginationQuirkEnabled;
+    bool shouldScaleViewToFitDocument;
 };
 
 } // namespace WebKit
index 6b6a26f..67266a4 100644 (file)
@@ -36,7 +36,8 @@ enum {
     kWKLayoutModeViewSize,
     kWKLayoutModeFixedSize,
     kWKLayoutModeDynamicSizeComputedFromViewScale,
-    kWKLayoutModeDynamicSizeWithMinimumViewSize
+    kWKLayoutModeDynamicSizeWithMinimumViewSize,
+    kWKLayoutModeDynamicSizeComputedFromMinimumDocumentSize
 };
 typedef uint32_t WKLayoutMode;
 
index c9a1280..671030b 100644 (file)
@@ -2301,6 +2301,8 @@ static inline WebKit::FindOptions toFindOptions(_WKFindOptions wkFindOptions)
         return _WKLayoutModeDynamicSizeComputedFromViewScale;
     case kWKLayoutModeDynamicSizeWithMinimumViewSize:
         return _WKLayoutModeDynamicSizeWithMinimumViewSize;
+    case kWKLayoutModeDynamicSizeComputedFromMinimumDocumentSize:
+        return _WKLayoutModeDynamicSizeComputedFromMinimumDocumentSize;
     case kWKLayoutModeViewSize:
     default:
         return _WKLayoutModeViewSize;
@@ -2324,6 +2326,9 @@ static inline WebKit::FindOptions toFindOptions(_WKFindOptions wkFindOptions)
     case _WKLayoutModeDynamicSizeWithMinimumViewSize:
         wkViewLayoutMode = kWKLayoutModeDynamicSizeWithMinimumViewSize;
         break;
+    case _WKLayoutModeDynamicSizeComputedFromMinimumDocumentSize:
+        wkViewLayoutMode = kWKLayoutModeDynamicSizeComputedFromMinimumDocumentSize;
+        break;
     case _WKLayoutModeViewSize:
     default:
         wkViewLayoutMode = kWKLayoutModeViewSize;
index d9c158b..6d18e54 100644 (file)
@@ -35,7 +35,10 @@ typedef NS_ENUM(NSUInteger, _WKLayoutMode) {
     _WKLayoutModeDynamicSizeComputedFromViewScale,
 
     // Lay out the view at a heuristically-determined size based on the minimum view size.
-    _WKLayoutModeDynamicSizeWithMinimumViewSize
+    _WKLayoutModeDynamicSizeWithMinimumViewSize,
+
+    // Lay out the view at a heuristically-determined size based on the minimum size of the document.
+    _WKLayoutModeDynamicSizeComputedFromMinimumDocumentSize,
 
 } WK_ENUM_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
 
index 5a8bcab..204e1ab 100644 (file)
@@ -5024,6 +5024,7 @@ WebPageCreationParameters WebPageProxy::creationParameters()
 #else
     parameters.appleMailPaginationQuirkEnabled = false;
 #endif
+    parameters.shouldScaleViewToFitDocument = m_shouldScaleViewToFitDocument;
 
     return parameters;
 }
@@ -5881,4 +5882,17 @@ void WebPageProxy::clearWheelEventTestTrigger()
     m_process->send(Messages::WebPage::ClearWheelEventTestTrigger(), m_pageID);
 }
 
+void WebPageProxy::setShouldScaleViewToFitDocument(bool shouldScaleViewToFitDocument)
+{
+    if (m_shouldScaleViewToFitDocument == shouldScaleViewToFitDocument)
+        return;
+
+    m_shouldScaleViewToFitDocument = shouldScaleViewToFitDocument;
+
+    if (!isValid())
+        return;
+
+    m_process->send(Messages::WebPage::SetShouldScaleViewToFitDocument(shouldScaleViewToFitDocument), m_pageID);
+}
+
 } // namespace WebKit
index 242b42a..ff9af24 100644 (file)
@@ -655,6 +655,7 @@ public:
 #if PLATFORM(COCOA)
     void scaleViewAndUpdateGeometryFenced(double scale, WebCore::IntSize viewSize, std::function<void (const WebCore::MachSendRight&, CallbackBase::Error)>);
 #endif
+    void setShouldScaleViewToFitDocument(bool);
 
     float deviceScaleFactor() const;
     void setIntrinsicDeviceScaleFactor(float);
@@ -1710,7 +1711,9 @@ private:
     bool m_mayStartMediaWhenInWindow;
 
     bool m_waitingForDidUpdateViewState;
-        
+
+    bool m_shouldScaleViewToFitDocument { false };
+
 #if PLATFORM(COCOA)
     HashMap<String, String> m_temporaryPDFFiles;
     std::unique_ptr<WebCore::RunLoopObserver> m_viewStateChangeDispatcher;
index 8047252..760eff7 100644 (file)
@@ -52,6 +52,9 @@ using namespace WebKit;
 }
 @end
 
+@interface WKViewDynamicSizeComputedFromMinimumDocumentSizeLayoutStrategy : WKViewLayoutStrategy
+@end
+
 @implementation WKViewLayoutStrategy
 
 + (instancetype)layoutStrategyWithPage:(WebPageProxy&)page view:(WKView *)wkView mode:(WKLayoutMode)mode
@@ -68,6 +71,9 @@ using namespace WebKit;
     case kWKLayoutModeDynamicSizeWithMinimumViewSize:
         strategy = [[WKViewDynamicSizeWithMinimumViewSizeLayoutStrategy alloc] initWithPage:page view:wkView mode:mode];
         break;
+    case kWKLayoutModeDynamicSizeComputedFromMinimumDocumentSize:
+        strategy = [[WKViewDynamicSizeComputedFromMinimumDocumentSizeLayoutStrategy alloc] initWithPage:page view:wkView mode:mode];
+        break;
     case kWKLayoutModeViewSize:
     default:
         strategy = [[WKViewViewSizeLayoutStrategy alloc] initWithPage:page view:wkView mode:mode];
@@ -374,4 +380,29 @@ using namespace WebKit;
 
 @end
 
+@implementation WKViewDynamicSizeComputedFromMinimumDocumentSizeLayoutStrategy
+
+- (instancetype)initWithPage:(WebPageProxy&)page view:(WKView *)wkView mode:(WKLayoutMode)mode
+{
+    self = [super initWithPage:page view:wkView mode:mode];
+
+    if (!self)
+        return nil;
+
+    _page->setShouldScaleViewToFitDocument(true);
+
+    return self;
+}
+
+- (void)updateLayout
+{
+}
+
+- (void)willChangeLayoutStrategy
+{
+    _page->setShouldScaleViewToFitDocument(false);
+}
+
+@end
+
 #endif // PLATFORM(MAC)
index 726c574..eff4346 100644 (file)
@@ -126,6 +126,8 @@ public:
 
     virtual void attachViewOverlayGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*) { }
 
+    virtual void setShouldScaleViewToFitDocument(bool) { }
+
 #if PLATFORM(COCOA)
     // Used by TiledCoreAnimationDrawingArea.
     virtual void updateGeometry(const WebCore::IntSize& viewSize, const WebCore::IntSize& layerPosition, bool flushSynchronously) { }
index de4f4e2..7e600df 100644 (file)
@@ -381,6 +381,7 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
 
     m_drawingArea = DrawingArea::create(*this, parameters);
     m_drawingArea->setPaintingEnabled(false);
+    m_drawingArea->setShouldScaleViewToFitDocument(parameters.shouldScaleViewToFitDocument);
 
 #if ENABLE(ASYNC_SCROLLING)
     m_useAsyncScrolling = parameters.store.getBoolValueForKey(WebPreferencesKey::threadedScrollingEnabledKey());
@@ -4954,4 +4955,12 @@ void WebPage::clearWheelEventTestTrigger()
     m_page->clearTrigger();
 }
 
+void WebPage::setShouldScaleViewToFitDocument(bool shouldScaleViewToFitDocument)
+{
+    if (!m_drawingArea)
+        return;
+
+    m_drawingArea->setShouldScaleViewToFitDocument(shouldScaleViewToFitDocument);
+}
+
 } // namespace WebKit
index 2bf9119..393f2c5 100644 (file)
@@ -1129,6 +1129,8 @@ private:
 
     void clearWheelEventTestTrigger();
 
+    void setShouldScaleViewToFitDocument(bool);
+
     uint64_t m_pageID;
 
     std::unique_ptr<WebCore::Page> m_page;
index dc44f72..31a436b 100644 (file)
@@ -433,4 +433,5 @@ messages -> WebPage LegacyReceiver {
 #endif
 
     ClearWheelEventTestTrigger()
+    SetShouldScaleViewToFitDocument(bool shouldScaleViewToFitDocument)
 }
index 9d51fd8..baed5f7 100644 (file)
@@ -100,6 +100,8 @@ private:
     virtual void setColorSpace(const ColorSpaceData&) override;
     virtual void addFence(const WebCore::MachSendRight&) override;
 
+    virtual void setShouldScaleViewToFitDocument(bool) override;
+
     virtual void adjustTransientZoom(double scale, WebCore::FloatPoint origin) override;
     virtual void commitTransientZoom(double scale, WebCore::FloatPoint origin) override;
     void applyTransientZoomToPage(double scale, WebCore::FloatPoint origin);
@@ -118,6 +120,7 @@ private:
 
     void updateIntrinsicContentSizeIfNeeded();
     void updateScrolledExposedRect();
+    void scaleViewToFitDocumentIfNeeded();
 
     bool m_layerTreeStateIsFrozen;
     WebCore::LayerFlushScheduler m_layerFlushScheduler;
@@ -150,6 +153,10 @@ private:
     WebCore::GraphicsLayer* m_viewOverlayRootLayer;
 
     Vector<uint64_t> m_fenceCallbacksForAfterNextFlush;
+    bool m_shouldScaleViewToFitDocument { false };
+
+    WebCore::IntSize m_lastViewSizeForScaleToFit;
+    WebCore::IntSize m_lastDocumentSizeForScaleToFit;
 };
 
 } // namespace WebKit
index 2cbbc61..bf6c3aa 100644 (file)
@@ -261,6 +261,54 @@ void TiledCoreAnimationDrawingArea::updateIntrinsicContentSizeIfNeeded()
     m_webPage.send(Messages::DrawingAreaProxy::IntrinsicContentSizeDidChange(contentSize));
 }
 
+void TiledCoreAnimationDrawingArea::setShouldScaleViewToFitDocument(bool shouldScaleView)
+{
+    if (m_shouldScaleViewToFitDocument == shouldScaleView)
+        return;
+
+    m_shouldScaleViewToFitDocument = shouldScaleView;
+    scheduleCompositingLayerFlush();
+}
+
+void TiledCoreAnimationDrawingArea::scaleViewToFitDocumentIfNeeded()
+{
+    // FIXME: Defer scrollbar flashing until after the second layout.
+
+    const int maximumDocumentWidthForScaling = 1440;
+    const float minimumViewScale = 0.1;
+
+    if (!m_shouldScaleViewToFitDocument)
+        return;
+
+    if (!m_webPage.mainFrame()->view()->needsLayout() && m_lastDocumentSizeForScaleToFit == m_webPage.mainFrameView()->renderView()->unscaledDocumentRect().size() && m_lastViewSizeForScaleToFit == m_webPage.size())
+        return;
+
+    // Lay out at the view size.
+    m_webPage.setUseFixedLayout(false);
+    m_webPage.layoutIfNeeded();
+
+    IntSize documentSize = m_webPage.mainFrameView()->renderView()->unscaledDocumentRect().size();
+    m_lastViewSizeForScaleToFit = m_webPage.size();
+    m_lastDocumentSizeForScaleToFit = documentSize;
+
+    int documentWidth = documentSize.width();
+    int viewWidth = m_webPage.size().width();
+
+    float viewScale = 1;
+
+    // Avoid scaling down documents that don't fit in a certain width, to allow
+    // sites that want horizontal scrollbars to continue to have them.
+    if (documentWidth && documentWidth < maximumDocumentWidthForScaling && viewWidth < documentWidth) {
+        // If the document doesn't fit in the view, scale it down but lay out at the view size.
+        m_webPage.setUseFixedLayout(true);
+        viewScale = (float)viewWidth / (float)documentWidth;
+        viewScale = std::max(viewScale, minimumViewScale);
+        m_webPage.setFixedLayoutSize(IntSize(ceilf(m_webPage.size().width() / viewScale), m_webPage.size().height()));
+    }
+
+    m_webPage.scaleView(viewScale);
+}
+
 void TiledCoreAnimationDrawingArea::dispatchAfterEnsuringUpdatedScrollPosition(std::function<void ()> function)
 {
 #if ENABLE(ASYNC_SCROLLING)
@@ -302,6 +350,8 @@ bool TiledCoreAnimationDrawingArea::flushLayers()
     ASSERT(!m_layerTreeStateIsFrozen);
 
     @autoreleasepool {
+        scaleViewToFitDocumentIfNeeded();
+
         m_webPage.layoutIfNeeded();
 
         updateIntrinsicContentSizeIfNeeded();
index 3e3b54c..db4ea2d 100644 (file)
@@ -1,3 +1,18 @@
+2015-05-14  Timothy Horton  <timothy_horton@apple.com>
+
+        Add a layout mode that scales down the view to try to fit the document
+        https://bugs.webkit.org/show_bug.cgi?id=145022
+        <rdar://problem/19790341>
+
+        Reviewed by Dean Jackson.
+
+        * MiniBrowser/mac/BrowserWindow.xib:
+        * MiniBrowser/mac/BrowserWindowController.h:
+        * MiniBrowser/mac/WK2BrowserWindowController.m:
+        (-[WK2BrowserWindowController toggleShrinkToFit:]):
+        (-[WK2BrowserWindowController toggleUseMinimumViewSize:]): Deleted.
+        Switch to _WKLayoutModeDynamicSizeComputedFromMinimumDocumentSize.
+
 2015-05-14  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         [CMake] Don't read the LOCATION property of targets
index b3afc78..4472f01 100644 (file)
@@ -12,7 +12,7 @@
                 <outlet property="forwardButton" destination="42" id="47"/>
                 <outlet property="progressIndicator" destination="21" id="33"/>
                 <outlet property="reloadButton" destination="23" id="34"/>
-                <outlet property="toggleUseMinimumViewSizeButton" destination="82" id="FTZ-YK-Ae5"/>
+                <outlet property="toggleUseShrinkToFitButton" destination="82" id="9w7-AB-Ye3"/>
                 <outlet property="toolbar" destination="48" id="67"/>
                 <outlet property="urlText" destination="10" id="32"/>
                 <outlet property="window" destination="1" id="3"/>
@@ -85,7 +85,7 @@
                             </connections>
                         </button>
                     </toolbarItem>
-                    <toolbarItem implicitItemIdentifier="76DCF2B0-1DDE-47D2-9212-705E6E310CCE" label="Use Minimum View Size" paletteLabel="Use Minimum View Size" image="NSEnterFullScreenTemplate" id="81" customClass="MBToolbarItem">
+                    <toolbarItem implicitItemIdentifier="76DCF2B0-1DDE-47D2-9212-705E6E310CCE" label="Use Shrink To Fit" paletteLabel="Use Shrink To Fit" image="NSEnterFullScreenTemplate" id="81" customClass="MBToolbarItem">
                         <nil key="toolTip"/>
                         <size key="minSize" width="29" height="25"/>
                         <size key="maxSize" width="29" height="25"/>
@@ -96,6 +96,9 @@
                                 <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                 <font key="font" metaFont="system"/>
                             </buttonCell>
+                            <connections>
+                                <action selector="toggleShrinkToFit:" target="-2" id="gp7-Vk-KTI"/>
+                            </connections>
                         </button>
                         <connections>
                             <action selector="toggleUseMinimumViewSize:" target="-2" id="gZA-yS-7L4"/>
index ad8502f..0071646 100644 (file)
@@ -47,7 +47,7 @@
 
 - (IBAction)setScale:(id)sender;
 
-- (IBAction)toggleUseMinimumViewSize:(id)sender;
+- (IBAction)toggleShrinkToFit:(id)sender;
 
 - (IBAction)dumpSourceToConsole:(id)sender;
 - (IBAction)find:(id)sender;
@@ -64,7 +64,7 @@
     IBOutlet NSToolbar *toolbar;
     IBOutlet NSTextField *urlText;
     IBOutlet NSView *containerView;
-    IBOutlet NSButton *toggleUseMinimumViewSizeButton;
+    IBOutlet NSButton *toggleUseShrinkToFitButton;
     
     IBOutlet NSWindow *findPanelWindow;
 
index d05ee95..65584ea 100644 (file)
     _zoomTextOnly = !_zoomTextOnly;
 }
 
-- (IBAction)toggleUseMinimumViewSize:(id)sender
+- (IBAction)toggleShrinkToFit:(id)sender
 {
 
 }
index 53b9723..70cf0c2 100644 (file)
@@ -48,7 +48,7 @@ static void* keyValueObservingContext = &keyValueObservingContext;
     BOOL _zoomTextOnly;
     BOOL _isPrivateBrowsingWindow;
 
-    BOOL _useMinimumViewSize;
+    BOOL _useShrinkToFit;
 }
 
 - (void)awakeFromNib
@@ -237,12 +237,11 @@ static CGFloat viewScaleForMenuItemTag(NSInteger tag)
     return _zoomTextOnly ? (_webView._textZoomFactor != 1) : (_webView._pageZoomFactor != 1);
 }
 
-- (IBAction)toggleUseMinimumViewSize:(id)sender
+- (IBAction)toggleShrinkToFit:(id)sender
 {
-    _useMinimumViewSize = !_useMinimumViewSize;
-    toggleUseMinimumViewSizeButton.image = _useMinimumViewSize ? [NSImage imageNamed:@"NSExitFullScreenTemplate"] : [NSImage imageNamed:@"NSEnterFullScreenTemplate"];
-    [_webView _setMinimumViewSize:CGSizeMake(1024, 0)];
-    [_webView _setLayoutMode:_useMinimumViewSize ? _WKLayoutModeDynamicSizeWithMinimumViewSize : _WKLayoutModeViewSize];
+    _useShrinkToFit = !_useShrinkToFit;
+    toggleUseShrinkToFitButton.image = _useShrinkToFit ? [NSImage imageNamed:@"NSExitFullScreenTemplate"] : [NSImage imageNamed:@"NSEnterFullScreenTemplate"];
+    [_webView _setLayoutMode:_useShrinkToFit ? _WKLayoutModeDynamicSizeComputedFromMinimumDocumentSize : _WKLayoutModeViewSize];
 }
 
 - (IBAction)dumpSourceToConsole:(id)sender