<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[184358] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/184358">184358</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2015-05-14 15:46:15 -0700 (Thu, 14 May 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add a layout mode that scales down the view to try to fit the document
https://bugs.webkit.org/show_bug.cgi?id=145022
&lt;rdar://problem/19790341&gt;

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.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedWebPageCreationParameterscpp">trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedWebPageCreationParametersh">trunk/Source/WebKit2/Shared/WebPageCreationParameters.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICWKLayoutModeh">trunk/Source/WebKit2/UIProcess/API/C/WKLayoutMode.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoa_WKLayoutModeh">trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKLayoutMode.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxycpp">trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxyh">trunk/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacWKViewLayoutStrategymm">trunk/Source/WebKit2/UIProcess/mac/WKViewLayoutStrategy.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageDrawingAreah">trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagecpp">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPageh">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagemessagesin">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacTiledCoreAnimationDrawingAreah">trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacTiledCoreAnimationDrawingAreamm">trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsMiniBrowsermacBrowserWindowxib">trunk/Tools/MiniBrowser/mac/BrowserWindow.xib</a></li>
<li><a href="#trunkToolsMiniBrowsermacBrowserWindowControllerh">trunk/Tools/MiniBrowser/mac/BrowserWindowController.h</a></li>
<li><a href="#trunkToolsMiniBrowsermacWK1BrowserWindowControllerm">trunk/Tools/MiniBrowser/mac/WK1BrowserWindowController.m</a></li>
<li><a href="#trunkToolsMiniBrowsermacWK2BrowserWindowControllerm">trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (184357 => 184358)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,49 @@
</span><ins>+2015-05-14  Timothy Horton  &lt;timothy_horton@apple.com&gt;
+
+        Add a layout mode that scales down the view to try to fit the document
+        https://bugs.webkit.org/show_bug.cgi?id=145022
+        &lt;rdar://problem/19790341&gt;
+
+        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.
+
</ins><span class="cx"> 2015-05-14  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Local storage origins should include origins with transient local storage
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebPageCreationParameterscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp (184357 => 184358)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -83,6 +83,7 @@
</span><span class="cx">     encoder &lt;&lt; textAutosizingWidth;
</span><span class="cx"> #endif
</span><span class="cx">     encoder &lt;&lt; appleMailPaginationQuirkEnabled;
</span><ins>+    encoder &lt;&lt; shouldScaleViewToFitDocument;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool WebPageCreationParameters::decode(IPC::ArgumentDecoder&amp; decoder, WebPageCreationParameters&amp; parameters)
</span><span class="lines">@@ -184,6 +185,9 @@
</span><span class="cx">     if (!decoder.decode(parameters.appleMailPaginationQuirkEnabled))
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><ins>+    if (!decoder.decode(parameters.shouldScaleViewToFitDocument))
+        return false;
+
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebPageCreationParametersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebPageCreationParameters.h (184357 => 184358)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -129,6 +129,7 @@
</span><span class="cx">     float textAutosizingWidth;
</span><span class="cx"> #endif
</span><span class="cx">     bool appleMailPaginationQuirkEnabled;
</span><ins>+    bool shouldScaleViewToFitDocument;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICWKLayoutModeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/C/WKLayoutMode.h (184357 => 184358)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -36,7 +36,8 @@
</span><span class="cx">     kWKLayoutModeViewSize,
</span><span class="cx">     kWKLayoutModeFixedSize,
</span><span class="cx">     kWKLayoutModeDynamicSizeComputedFromViewScale,
</span><del>-    kWKLayoutModeDynamicSizeWithMinimumViewSize
</del><ins>+    kWKLayoutModeDynamicSizeWithMinimumViewSize,
+    kWKLayoutModeDynamicSizeComputedFromMinimumDocumentSize
</ins><span class="cx"> };
</span><span class="cx"> typedef uint32_t WKLayoutMode;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (184357 => 184358)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -2301,6 +2301,8 @@
</span><span class="cx">         return _WKLayoutModeDynamicSizeComputedFromViewScale;
</span><span class="cx">     case kWKLayoutModeDynamicSizeWithMinimumViewSize:
</span><span class="cx">         return _WKLayoutModeDynamicSizeWithMinimumViewSize;
</span><ins>+    case kWKLayoutModeDynamicSizeComputedFromMinimumDocumentSize:
+        return _WKLayoutModeDynamicSizeComputedFromMinimumDocumentSize;
</ins><span class="cx">     case kWKLayoutModeViewSize:
</span><span class="cx">     default:
</span><span class="cx">         return _WKLayoutModeViewSize;
</span><span class="lines">@@ -2324,6 +2326,9 @@
</span><span class="cx">     case _WKLayoutModeDynamicSizeWithMinimumViewSize:
</span><span class="cx">         wkViewLayoutMode = kWKLayoutModeDynamicSizeWithMinimumViewSize;
</span><span class="cx">         break;
</span><ins>+    case _WKLayoutModeDynamicSizeComputedFromMinimumDocumentSize:
+        wkViewLayoutMode = kWKLayoutModeDynamicSizeComputedFromMinimumDocumentSize;
+        break;
</ins><span class="cx">     case _WKLayoutModeViewSize:
</span><span class="cx">     default:
</span><span class="cx">         wkViewLayoutMode = kWKLayoutModeViewSize;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoa_WKLayoutModeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKLayoutMode.h (184357 => 184358)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -35,8 +35,11 @@
</span><span class="cx">     _WKLayoutModeDynamicSizeComputedFromViewScale,
</span><span class="cx"> 
</span><span class="cx">     // Lay out the view at a heuristically-determined size based on the minimum view size.
</span><del>-    _WKLayoutModeDynamicSizeWithMinimumViewSize
</del><ins>+    _WKLayoutModeDynamicSizeWithMinimumViewSize,
</ins><span class="cx"> 
</span><ins>+    // Lay out the view at a heuristically-determined size based on the minimum size of the document.
+    _WKLayoutModeDynamicSizeComputedFromMinimumDocumentSize,
+
</ins><span class="cx"> } WK_ENUM_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
</span><span class="cx"> 
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (184357 => 184358)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -5024,6 +5024,7 @@
</span><span class="cx"> #else
</span><span class="cx">     parameters.appleMailPaginationQuirkEnabled = false;
</span><span class="cx"> #endif
</span><ins>+    parameters.shouldScaleViewToFitDocument = m_shouldScaleViewToFitDocument;
</ins><span class="cx"> 
</span><span class="cx">     return parameters;
</span><span class="cx"> }
</span><span class="lines">@@ -5881,4 +5882,17 @@
</span><span class="cx">     m_process-&gt;send(Messages::WebPage::ClearWheelEventTestTrigger(), m_pageID);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPageProxy::setShouldScaleViewToFitDocument(bool shouldScaleViewToFitDocument)
+{
+    if (m_shouldScaleViewToFitDocument == shouldScaleViewToFitDocument)
+        return;
+
+    m_shouldScaleViewToFitDocument = shouldScaleViewToFitDocument;
+
+    if (!isValid())
+        return;
+
+    m_process-&gt;send(Messages::WebPage::SetShouldScaleViewToFitDocument(shouldScaleViewToFitDocument), m_pageID);
+}
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (184357 => 184358)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -655,6 +655,7 @@
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx">     void scaleViewAndUpdateGeometryFenced(double scale, WebCore::IntSize viewSize, std::function&lt;void (const WebCore::MachSendRight&amp;, CallbackBase::Error)&gt;);
</span><span class="cx"> #endif
</span><ins>+    void setShouldScaleViewToFitDocument(bool);
</ins><span class="cx"> 
</span><span class="cx">     float deviceScaleFactor() const;
</span><span class="cx">     void setIntrinsicDeviceScaleFactor(float);
</span><span class="lines">@@ -1710,7 +1711,9 @@
</span><span class="cx">     bool m_mayStartMediaWhenInWindow;
</span><span class="cx"> 
</span><span class="cx">     bool m_waitingForDidUpdateViewState;
</span><del>-        
</del><ins>+
+    bool m_shouldScaleViewToFitDocument { false };
+
</ins><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx">     HashMap&lt;String, String&gt; m_temporaryPDFFiles;
</span><span class="cx">     std::unique_ptr&lt;WebCore::RunLoopObserver&gt; m_viewStateChangeDispatcher;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacWKViewLayoutStrategymm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/WKViewLayoutStrategy.mm (184357 => 184358)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -52,6 +52,9 @@
</span><span class="cx"> }
</span><span class="cx"> @end
</span><span class="cx"> 
</span><ins>+@interface WKViewDynamicSizeComputedFromMinimumDocumentSizeLayoutStrategy : WKViewLayoutStrategy
+@end
+
</ins><span class="cx"> @implementation WKViewLayoutStrategy
</span><span class="cx"> 
</span><span class="cx"> + (instancetype)layoutStrategyWithPage:(WebPageProxy&amp;)page view:(WKView *)wkView mode:(WKLayoutMode)mode
</span><span class="lines">@@ -68,6 +71,9 @@
</span><span class="cx">     case kWKLayoutModeDynamicSizeWithMinimumViewSize:
</span><span class="cx">         strategy = [[WKViewDynamicSizeWithMinimumViewSizeLayoutStrategy alloc] initWithPage:page view:wkView mode:mode];
</span><span class="cx">         break;
</span><ins>+    case kWKLayoutModeDynamicSizeComputedFromMinimumDocumentSize:
+        strategy = [[WKViewDynamicSizeComputedFromMinimumDocumentSizeLayoutStrategy alloc] initWithPage:page view:wkView mode:mode];
+        break;
</ins><span class="cx">     case kWKLayoutModeViewSize:
</span><span class="cx">     default:
</span><span class="cx">         strategy = [[WKViewViewSizeLayoutStrategy alloc] initWithPage:page view:wkView mode:mode];
</span><span class="lines">@@ -374,4 +380,29 @@
</span><span class="cx"> 
</span><span class="cx"> @end
</span><span class="cx"> 
</span><ins>+@implementation WKViewDynamicSizeComputedFromMinimumDocumentSizeLayoutStrategy
+
+- (instancetype)initWithPage:(WebPageProxy&amp;)page view:(WKView *)wkView mode:(WKLayoutMode)mode
+{
+    self = [super initWithPage:page view:wkView mode:mode];
+
+    if (!self)
+        return nil;
+
+    _page-&gt;setShouldScaleViewToFitDocument(true);
+
+    return self;
+}
+
+- (void)updateLayout
+{
+}
+
+- (void)willChangeLayoutStrategy
+{
+    _page-&gt;setShouldScaleViewToFitDocument(false);
+}
+
+@end
+
</ins><span class="cx"> #endif // PLATFORM(MAC)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageDrawingAreah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h (184357 => 184358)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -126,6 +126,8 @@
</span><span class="cx"> 
</span><span class="cx">     virtual void attachViewOverlayGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*) { }
</span><span class="cx"> 
</span><ins>+    virtual void setShouldScaleViewToFitDocument(bool) { }
+
</ins><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx">     // Used by TiledCoreAnimationDrawingArea.
</span><span class="cx">     virtual void updateGeometry(const WebCore::IntSize&amp; viewSize, const WebCore::IntSize&amp; layerPosition, bool flushSynchronously) { }
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (184357 => 184358)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -381,6 +381,7 @@
</span><span class="cx"> 
</span><span class="cx">     m_drawingArea = DrawingArea::create(*this, parameters);
</span><span class="cx">     m_drawingArea-&gt;setPaintingEnabled(false);
</span><ins>+    m_drawingArea-&gt;setShouldScaleViewToFitDocument(parameters.shouldScaleViewToFitDocument);
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(ASYNC_SCROLLING)
</span><span class="cx">     m_useAsyncScrolling = parameters.store.getBoolValueForKey(WebPreferencesKey::threadedScrollingEnabledKey());
</span><span class="lines">@@ -4954,4 +4955,12 @@
</span><span class="cx">     m_page-&gt;clearTrigger();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPage::setShouldScaleViewToFitDocument(bool shouldScaleViewToFitDocument)
+{
+    if (!m_drawingArea)
+        return;
+
+    m_drawingArea-&gt;setShouldScaleViewToFitDocument(shouldScaleViewToFitDocument);
+}
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (184357 => 184358)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1129,6 +1129,8 @@
</span><span class="cx"> 
</span><span class="cx">     void clearWheelEventTestTrigger();
</span><span class="cx"> 
</span><ins>+    void setShouldScaleViewToFitDocument(bool);
+
</ins><span class="cx">     uint64_t m_pageID;
</span><span class="cx"> 
</span><span class="cx">     std::unique_ptr&lt;WebCore::Page&gt; m_page;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagemessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (184357 => 184358)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -433,4 +433,5 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     ClearWheelEventTestTrigger()
</span><ins>+    SetShouldScaleViewToFitDocument(bool shouldScaleViewToFitDocument)
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacTiledCoreAnimationDrawingAreah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h (184357 => 184358)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -100,6 +100,8 @@
</span><span class="cx">     virtual void setColorSpace(const ColorSpaceData&amp;) override;
</span><span class="cx">     virtual void addFence(const WebCore::MachSendRight&amp;) override;
</span><span class="cx"> 
</span><ins>+    virtual void setShouldScaleViewToFitDocument(bool) override;
+
</ins><span class="cx">     virtual void adjustTransientZoom(double scale, WebCore::FloatPoint origin) override;
</span><span class="cx">     virtual void commitTransientZoom(double scale, WebCore::FloatPoint origin) override;
</span><span class="cx">     void applyTransientZoomToPage(double scale, WebCore::FloatPoint origin);
</span><span class="lines">@@ -118,6 +120,7 @@
</span><span class="cx"> 
</span><span class="cx">     void updateIntrinsicContentSizeIfNeeded();
</span><span class="cx">     void updateScrolledExposedRect();
</span><ins>+    void scaleViewToFitDocumentIfNeeded();
</ins><span class="cx"> 
</span><span class="cx">     bool m_layerTreeStateIsFrozen;
</span><span class="cx">     WebCore::LayerFlushScheduler m_layerFlushScheduler;
</span><span class="lines">@@ -150,6 +153,10 @@
</span><span class="cx">     WebCore::GraphicsLayer* m_viewOverlayRootLayer;
</span><span class="cx"> 
</span><span class="cx">     Vector&lt;uint64_t&gt; m_fenceCallbacksForAfterNextFlush;
</span><ins>+    bool m_shouldScaleViewToFitDocument { false };
+
+    WebCore::IntSize m_lastViewSizeForScaleToFit;
+    WebCore::IntSize m_lastDocumentSizeForScaleToFit;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacTiledCoreAnimationDrawingAreamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm (184357 => 184358)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -261,6 +261,54 @@
</span><span class="cx">     m_webPage.send(Messages::DrawingAreaProxy::IntrinsicContentSizeDidChange(contentSize));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+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()-&gt;view()-&gt;needsLayout() &amp;&amp; m_lastDocumentSizeForScaleToFit == m_webPage.mainFrameView()-&gt;renderView()-&gt;unscaledDocumentRect().size() &amp;&amp; m_lastViewSizeForScaleToFit == m_webPage.size())
+        return;
+
+    // Lay out at the view size.
+    m_webPage.setUseFixedLayout(false);
+    m_webPage.layoutIfNeeded();
+
+    IntSize documentSize = m_webPage.mainFrameView()-&gt;renderView()-&gt;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 &amp;&amp; documentWidth &lt; maximumDocumentWidthForScaling &amp;&amp; viewWidth &lt; 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);
+}
+
</ins><span class="cx"> void TiledCoreAnimationDrawingArea::dispatchAfterEnsuringUpdatedScrollPosition(std::function&lt;void ()&gt; function)
</span><span class="cx"> {
</span><span class="cx"> #if ENABLE(ASYNC_SCROLLING)
</span><span class="lines">@@ -302,6 +350,8 @@
</span><span class="cx">     ASSERT(!m_layerTreeStateIsFrozen);
</span><span class="cx"> 
</span><span class="cx">     @autoreleasepool {
</span><ins>+        scaleViewToFitDocumentIfNeeded();
+
</ins><span class="cx">         m_webPage.layoutIfNeeded();
</span><span class="cx"> 
</span><span class="cx">         updateIntrinsicContentSizeIfNeeded();
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (184357 => 184358)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-05-14 22:29:25 UTC (rev 184357)
+++ trunk/Tools/ChangeLog        2015-05-14 22:46:15 UTC (rev 184358)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2015-05-14  Timothy Horton  &lt;timothy_horton@apple.com&gt;
+
+        Add a layout mode that scales down the view to try to fit the document
+        https://bugs.webkit.org/show_bug.cgi?id=145022
+        &lt;rdar://problem/19790341&gt;
+
+        Reviewed by Dean Jackson.
+
+        * MiniBrowser/mac/BrowserWindow.xib:
+        * MiniBrowser/mac/BrowserWindowController.h:
+        * MiniBrowser/mac/WK2BrowserWindowController.m:
+        (-[WK2BrowserWindowController toggleShrinkToFit:]):
+        (-[WK2BrowserWindowController toggleUseMinimumViewSize:]): Deleted.
+        Switch to _WKLayoutModeDynamicSizeComputedFromMinimumDocumentSize.
+
</ins><span class="cx"> 2015-05-14  Michael Catanzaro  &lt;mcatanzaro@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [CMake] Don't read the LOCATION property of targets
</span></span></pre></div>
<a id="trunkToolsMiniBrowsermacBrowserWindowxib"></a>
<div class="modfile"><h4>Modified: trunk/Tools/MiniBrowser/mac/BrowserWindow.xib (184357 => 184358)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -12,7 +12,7 @@
</span><span class="cx">                 &lt;outlet property=&quot;forwardButton&quot; destination=&quot;42&quot; id=&quot;47&quot;/&gt;
</span><span class="cx">                 &lt;outlet property=&quot;progressIndicator&quot; destination=&quot;21&quot; id=&quot;33&quot;/&gt;
</span><span class="cx">                 &lt;outlet property=&quot;reloadButton&quot; destination=&quot;23&quot; id=&quot;34&quot;/&gt;
</span><del>-                &lt;outlet property=&quot;toggleUseMinimumViewSizeButton&quot; destination=&quot;82&quot; id=&quot;FTZ-YK-Ae5&quot;/&gt;
</del><ins>+                &lt;outlet property=&quot;toggleUseShrinkToFitButton&quot; destination=&quot;82&quot; id=&quot;9w7-AB-Ye3&quot;/&gt;
</ins><span class="cx">                 &lt;outlet property=&quot;toolbar&quot; destination=&quot;48&quot; id=&quot;67&quot;/&gt;
</span><span class="cx">                 &lt;outlet property=&quot;urlText&quot; destination=&quot;10&quot; id=&quot;32&quot;/&gt;
</span><span class="cx">                 &lt;outlet property=&quot;window&quot; destination=&quot;1&quot; id=&quot;3&quot;/&gt;
</span><span class="lines">@@ -85,7 +85,7 @@
</span><span class="cx">                             &lt;/connections&gt;
</span><span class="cx">                         &lt;/button&gt;
</span><span class="cx">                     &lt;/toolbarItem&gt;
</span><del>-                    &lt;toolbarItem implicitItemIdentifier=&quot;76DCF2B0-1DDE-47D2-9212-705E6E310CCE&quot; label=&quot;Use Minimum View Size&quot; paletteLabel=&quot;Use Minimum View Size&quot; image=&quot;NSEnterFullScreenTemplate&quot; id=&quot;81&quot; customClass=&quot;MBToolbarItem&quot;&gt;
</del><ins>+                    &lt;toolbarItem implicitItemIdentifier=&quot;76DCF2B0-1DDE-47D2-9212-705E6E310CCE&quot; label=&quot;Use Shrink To Fit&quot; paletteLabel=&quot;Use Shrink To Fit&quot; image=&quot;NSEnterFullScreenTemplate&quot; id=&quot;81&quot; customClass=&quot;MBToolbarItem&quot;&gt;
</ins><span class="cx">                         &lt;nil key=&quot;toolTip&quot;/&gt;
</span><span class="cx">                         &lt;size key=&quot;minSize&quot; width=&quot;29&quot; height=&quot;25&quot;/&gt;
</span><span class="cx">                         &lt;size key=&quot;maxSize&quot; width=&quot;29&quot; height=&quot;25&quot;/&gt;
</span><span class="lines">@@ -96,6 +96,9 @@
</span><span class="cx">                                 &lt;behavior key=&quot;behavior&quot; pushIn=&quot;YES&quot; lightByBackground=&quot;YES&quot; lightByGray=&quot;YES&quot;/&gt;
</span><span class="cx">                                 &lt;font key=&quot;font&quot; metaFont=&quot;system&quot;/&gt;
</span><span class="cx">                             &lt;/buttonCell&gt;
</span><ins>+                            &lt;connections&gt;
+                                &lt;action selector=&quot;toggleShrinkToFit:&quot; target=&quot;-2&quot; id=&quot;gp7-Vk-KTI&quot;/&gt;
+                            &lt;/connections&gt;
</ins><span class="cx">                         &lt;/button&gt;
</span><span class="cx">                         &lt;connections&gt;
</span><span class="cx">                             &lt;action selector=&quot;toggleUseMinimumViewSize:&quot; target=&quot;-2&quot; id=&quot;gZA-yS-7L4&quot;/&gt;
</span></span></pre></div>
<a id="trunkToolsMiniBrowsermacBrowserWindowControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/MiniBrowser/mac/BrowserWindowController.h (184357 => 184358)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -47,7 +47,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (IBAction)setScale:(id)sender;
</span><span class="cx"> 
</span><del>-- (IBAction)toggleUseMinimumViewSize:(id)sender;
</del><ins>+- (IBAction)toggleShrinkToFit:(id)sender;
</ins><span class="cx"> 
</span><span class="cx"> - (IBAction)dumpSourceToConsole:(id)sender;
</span><span class="cx"> - (IBAction)find:(id)sender;
</span><span class="lines">@@ -64,7 +64,7 @@
</span><span class="cx">     IBOutlet NSToolbar *toolbar;
</span><span class="cx">     IBOutlet NSTextField *urlText;
</span><span class="cx">     IBOutlet NSView *containerView;
</span><del>-    IBOutlet NSButton *toggleUseMinimumViewSizeButton;
</del><ins>+    IBOutlet NSButton *toggleUseShrinkToFitButton;
</ins><span class="cx">     
</span><span class="cx">     IBOutlet NSWindow *findPanelWindow;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsMiniBrowsermacWK1BrowserWindowControllerm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/MiniBrowser/mac/WK1BrowserWindowController.m (184357 => 184358)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -229,7 +229,7 @@
</span><span class="cx">     _zoomTextOnly = !_zoomTextOnly;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (IBAction)toggleUseMinimumViewSize:(id)sender
</del><ins>+- (IBAction)toggleShrinkToFit:(id)sender
</ins><span class="cx"> {
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkToolsMiniBrowsermacWK2BrowserWindowControllerm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m (184357 => 184358)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -48,7 +48,7 @@
</span><span class="cx">     BOOL _zoomTextOnly;
</span><span class="cx">     BOOL _isPrivateBrowsingWindow;
</span><span class="cx"> 
</span><del>-    BOOL _useMinimumViewSize;
</del><ins>+    BOOL _useShrinkToFit;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)awakeFromNib
</span><span class="lines">@@ -237,12 +237,11 @@
</span><span class="cx">     return _zoomTextOnly ? (_webView._textZoomFactor != 1) : (_webView._pageZoomFactor != 1);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (IBAction)toggleUseMinimumViewSize:(id)sender
</del><ins>+- (IBAction)toggleShrinkToFit:(id)sender
</ins><span class="cx"> {
</span><del>-    _useMinimumViewSize = !_useMinimumViewSize;
-    toggleUseMinimumViewSizeButton.image = _useMinimumViewSize ? [NSImage imageNamed:@&quot;NSExitFullScreenTemplate&quot;] : [NSImage imageNamed:@&quot;NSEnterFullScreenTemplate&quot;];
-    [_webView _setMinimumViewSize:CGSizeMake(1024, 0)];
-    [_webView _setLayoutMode:_useMinimumViewSize ? _WKLayoutModeDynamicSizeWithMinimumViewSize : _WKLayoutModeViewSize];
</del><ins>+    _useShrinkToFit = !_useShrinkToFit;
+    toggleUseShrinkToFitButton.image = _useShrinkToFit ? [NSImage imageNamed:@&quot;NSExitFullScreenTemplate&quot;] : [NSImage imageNamed:@&quot;NSEnterFullScreenTemplate&quot;];
+    [_webView _setLayoutMode:_useShrinkToFit ? _WKLayoutModeDynamicSizeComputedFromMinimumDocumentSize : _WKLayoutModeViewSize];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (IBAction)dumpSourceToConsole:(id)sender
</span></span></pre>
</div>
</div>

</body>
</html>