Title: [184358] trunk
Revision
184358
Author
[email protected]
Date
2015-05-14 15:46:15 -0700 (Thu, 14 May 2015)

Log Message

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.

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

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (184357 => 184358)


--- trunk/Source/WebKit2/ChangeLog	2015-05-14 22:29:25 UTC (rev 184357)
+++ trunk/Source/WebKit2/ChangeLog	2015-05-14 22:46:15 UTC (rev 184358)
@@ -1,3 +1,49 @@
+2015-05-14  Timothy Horton  <[email protected]>
+
+        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  <[email protected]>
 
         Local storage origins should include origins with transient local storage

Modified: trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp (184357 => 184358)


--- trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp	2015-05-14 22:29:25 UTC (rev 184357)
+++ trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp	2015-05-14 22:46:15 UTC (rev 184358)
@@ -83,6 +83,7 @@
     encoder << textAutosizingWidth;
 #endif
     encoder << appleMailPaginationQuirkEnabled;
+    encoder << shouldScaleViewToFitDocument;
 }
 
 bool WebPageCreationParameters::decode(IPC::ArgumentDecoder& decoder, WebPageCreationParameters& parameters)
@@ -184,6 +185,9 @@
     if (!decoder.decode(parameters.appleMailPaginationQuirkEnabled))
         return false;
 
+    if (!decoder.decode(parameters.shouldScaleViewToFitDocument))
+        return false;
+
     return true;
 }
 

Modified: trunk/Source/WebKit2/Shared/WebPageCreationParameters.h (184357 => 184358)


--- trunk/Source/WebKit2/Shared/WebPageCreationParameters.h	2015-05-14 22:29:25 UTC (rev 184357)
+++ trunk/Source/WebKit2/Shared/WebPageCreationParameters.h	2015-05-14 22:46:15 UTC (rev 184358)
@@ -129,6 +129,7 @@
     float textAutosizingWidth;
 #endif
     bool appleMailPaginationQuirkEnabled;
+    bool shouldScaleViewToFitDocument;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKLayoutMode.h (184357 => 184358)


--- trunk/Source/WebKit2/UIProcess/API/C/WKLayoutMode.h	2015-05-14 22:29:25 UTC (rev 184357)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKLayoutMode.h	2015-05-14 22:46:15 UTC (rev 184358)
@@ -36,7 +36,8 @@
     kWKLayoutModeViewSize,
     kWKLayoutModeFixedSize,
     kWKLayoutModeDynamicSizeComputedFromViewScale,
-    kWKLayoutModeDynamicSizeWithMinimumViewSize
+    kWKLayoutModeDynamicSizeWithMinimumViewSize,
+    kWKLayoutModeDynamicSizeComputedFromMinimumDocumentSize
 };
 typedef uint32_t WKLayoutMode;
 

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (184357 => 184358)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2015-05-14 22:29:25 UTC (rev 184357)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2015-05-14 22:46:15 UTC (rev 184358)
@@ -2301,6 +2301,8 @@
         return _WKLayoutModeDynamicSizeComputedFromViewScale;
     case kWKLayoutModeDynamicSizeWithMinimumViewSize:
         return _WKLayoutModeDynamicSizeWithMinimumViewSize;
+    case kWKLayoutModeDynamicSizeComputedFromMinimumDocumentSize:
+        return _WKLayoutModeDynamicSizeComputedFromMinimumDocumentSize;
     case kWKLayoutModeViewSize:
     default:
         return _WKLayoutModeViewSize;
@@ -2324,6 +2326,9 @@
     case _WKLayoutModeDynamicSizeWithMinimumViewSize:
         wkViewLayoutMode = kWKLayoutModeDynamicSizeWithMinimumViewSize;
         break;
+    case _WKLayoutModeDynamicSizeComputedFromMinimumDocumentSize:
+        wkViewLayoutMode = kWKLayoutModeDynamicSizeComputedFromMinimumDocumentSize;
+        break;
     case _WKLayoutModeViewSize:
     default:
         wkViewLayoutMode = kWKLayoutModeViewSize;

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKLayoutMode.h (184357 => 184358)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKLayoutMode.h	2015-05-14 22:29:25 UTC (rev 184357)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKLayoutMode.h	2015-05-14 22:46:15 UTC (rev 184358)
@@ -35,8 +35,11 @@
     _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);
 
 #endif

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (184357 => 184358)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2015-05-14 22:29:25 UTC (rev 184357)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2015-05-14 22:46:15 UTC (rev 184358)
@@ -5024,6 +5024,7 @@
 #else
     parameters.appleMailPaginationQuirkEnabled = false;
 #endif
+    parameters.shouldScaleViewToFitDocument = m_shouldScaleViewToFitDocument;
 
     return parameters;
 }
@@ -5881,4 +5882,17 @@
     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

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (184357 => 184358)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2015-05-14 22:29:25 UTC (rev 184357)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2015-05-14 22:46:15 UTC (rev 184358)
@@ -655,6 +655,7 @@
 #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 @@
     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;

Modified: trunk/Source/WebKit2/UIProcess/mac/WKViewLayoutStrategy.mm (184357 => 184358)


--- trunk/Source/WebKit2/UIProcess/mac/WKViewLayoutStrategy.mm	2015-05-14 22:29:25 UTC (rev 184357)
+++ trunk/Source/WebKit2/UIProcess/mac/WKViewLayoutStrategy.mm	2015-05-14 22:46:15 UTC (rev 184358)
@@ -52,6 +52,9 @@
 }
 @end
 
+@interface WKViewDynamicSizeComputedFromMinimumDocumentSizeLayoutStrategy : WKViewLayoutStrategy
+@end
+
 @implementation WKViewLayoutStrategy
 
 + (instancetype)layoutStrategyWithPage:(WebPageProxy&)page view:(WKView *)wkView mode:(WKLayoutMode)mode
@@ -68,6 +71,9 @@
     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 @@
 
 @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)

Modified: trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h (184357 => 184358)


--- trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h	2015-05-14 22:29:25 UTC (rev 184357)
+++ trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h	2015-05-14 22:46:15 UTC (rev 184358)
@@ -126,6 +126,8 @@
 
     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) { }

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (184357 => 184358)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2015-05-14 22:29:25 UTC (rev 184357)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2015-05-14 22:46:15 UTC (rev 184358)
@@ -381,6 +381,7 @@
 
     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 @@
     m_page->clearTrigger();
 }
 
+void WebPage::setShouldScaleViewToFitDocument(bool shouldScaleViewToFitDocument)
+{
+    if (!m_drawingArea)
+        return;
+
+    m_drawingArea->setShouldScaleViewToFitDocument(shouldScaleViewToFitDocument);
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (184357 => 184358)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2015-05-14 22:29:25 UTC (rev 184357)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2015-05-14 22:46:15 UTC (rev 184358)
@@ -1129,6 +1129,8 @@
 
     void clearWheelEventTestTrigger();
 
+    void setShouldScaleViewToFitDocument(bool);
+
     uint64_t m_pageID;
 
     std::unique_ptr<WebCore::Page> m_page;

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (184357 => 184358)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2015-05-14 22:29:25 UTC (rev 184357)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2015-05-14 22:46:15 UTC (rev 184358)
@@ -433,4 +433,5 @@
 #endif
 
     ClearWheelEventTestTrigger()
+    SetShouldScaleViewToFitDocument(bool shouldScaleViewToFitDocument)
 }

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h (184357 => 184358)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h	2015-05-14 22:29:25 UTC (rev 184357)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h	2015-05-14 22:46:15 UTC (rev 184358)
@@ -100,6 +100,8 @@
     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 @@
 
     void updateIntrinsicContentSizeIfNeeded();
     void updateScrolledExposedRect();
+    void scaleViewToFitDocumentIfNeeded();
 
     bool m_layerTreeStateIsFrozen;
     WebCore::LayerFlushScheduler m_layerFlushScheduler;
@@ -150,6 +153,10 @@
     WebCore::GraphicsLayer* m_viewOverlayRootLayer;
 
     Vector<uint64_t> m_fenceCallbacksForAfterNextFlush;
+    bool m_shouldScaleViewToFitDocument { false };
+
+    WebCore::IntSize m_lastViewSizeForScaleToFit;
+    WebCore::IntSize m_lastDocumentSizeForScaleToFit;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm (184357 => 184358)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2015-05-14 22:29:25 UTC (rev 184357)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2015-05-14 22:46:15 UTC (rev 184358)
@@ -261,6 +261,54 @@
     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 @@
     ASSERT(!m_layerTreeStateIsFrozen);
 
     @autoreleasepool {
+        scaleViewToFitDocumentIfNeeded();
+
         m_webPage.layoutIfNeeded();
 
         updateIntrinsicContentSizeIfNeeded();

Modified: trunk/Tools/ChangeLog (184357 => 184358)


--- trunk/Tools/ChangeLog	2015-05-14 22:29:25 UTC (rev 184357)
+++ trunk/Tools/ChangeLog	2015-05-14 22:46:15 UTC (rev 184358)
@@ -1,3 +1,18 @@
+2015-05-14  Timothy Horton  <[email protected]>
+
+        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  <[email protected]>
 
         [CMake] Don't read the LOCATION property of targets

Modified: trunk/Tools/MiniBrowser/mac/BrowserWindow.xib (184357 => 184358)


--- trunk/Tools/MiniBrowser/mac/BrowserWindow.xib	2015-05-14 22:29:25 UTC (rev 184357)
+++ trunk/Tools/MiniBrowser/mac/BrowserWindow.xib	2015-05-14 22:46:15 UTC (rev 184358)
@@ -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"/>

Modified: trunk/Tools/MiniBrowser/mac/BrowserWindowController.h (184357 => 184358)


--- trunk/Tools/MiniBrowser/mac/BrowserWindowController.h	2015-05-14 22:29:25 UTC (rev 184357)
+++ trunk/Tools/MiniBrowser/mac/BrowserWindowController.h	2015-05-14 22:46:15 UTC (rev 184358)
@@ -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;
 

Modified: trunk/Tools/MiniBrowser/mac/WK1BrowserWindowController.m (184357 => 184358)


--- trunk/Tools/MiniBrowser/mac/WK1BrowserWindowController.m	2015-05-14 22:29:25 UTC (rev 184357)
+++ trunk/Tools/MiniBrowser/mac/WK1BrowserWindowController.m	2015-05-14 22:46:15 UTC (rev 184358)
@@ -229,7 +229,7 @@
     _zoomTextOnly = !_zoomTextOnly;
 }
 
-- (IBAction)toggleUseMinimumViewSize:(id)sender
+- (IBAction)toggleShrinkToFit:(id)sender
 {
 
 }

Modified: trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m (184357 => 184358)


--- trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m	2015-05-14 22:29:25 UTC (rev 184357)
+++ trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m	2015-05-14 22:46:15 UTC (rev 184358)
@@ -48,7 +48,7 @@
     BOOL _zoomTextOnly;
     BOOL _isPrivateBrowsingWindow;
 
-    BOOL _useMinimumViewSize;
+    BOOL _useShrinkToFit;
 }
 
 - (void)awakeFromNib
@@ -237,12 +237,11 @@
     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
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to