<!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>[163654] trunk/Source</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/163654">163654</a></dd>
<dt>Author</dt> <dd>benjamin@webkit.org</dd>
<dt>Date</dt> <dd>2014-02-07 15:03:03 -0800 (Fri, 07 Feb 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[WK2] Add support for text document viewport configuration
https://bugs.webkit.org/show_bug.cgi?id=128359

Patch by Benjamin Poulain &lt;bpoulain@apple.com&gt; on 2014-02-07
Reviewed by Simon Fraser.

Source/WebCore: 

Define a set of ViewportParameters suitable for displaying text documents.
Add a documents class for text document to differentiate them from other type of documents.

* WebCore.exp.in:
* dom/Document.h:
(WebCore::Document::isTextDocument):
* html/TextDocument.cpp:
(WebCore::TextDocument::TextDocument):
* page/ViewportConfiguration.cpp:
(WebCore::ViewportConfiguration::ViewportConfiguration):
(WebCore::ViewportConfiguration::webpageParameters):
(WebCore::ViewportConfiguration::plainTextParameters):
* page/ViewportConfiguration.h:

Source/WebKit2: 

When a text document is being loaded, use the plainText viewport parameters.

* UIProcess/API/ios/WKContentView.h:
* UIProcess/API/ios/WKContentView.mm:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::didCommitLoad):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCoredomDocumenth">trunk/Source/WebCore/dom/Document.h</a></li>
<li><a href="#trunkSourceWebCorehtmlTextDocumentcpp">trunk/Source/WebCore/html/TextDocument.cpp</a></li>
<li><a href="#trunkSourceWebCorepageViewportConfigurationcpp">trunk/Source/WebCore/page/ViewportConfiguration.cpp</a></li>
<li><a href="#trunkSourceWebCorepageViewportConfigurationh">trunk/Source/WebCore/page/ViewportConfiguration.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIiosWKContentViewh">trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIiosWKContentViewmm">trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagecpp">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (163653 => 163654)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-02-07 23:02:49 UTC (rev 163653)
+++ trunk/Source/WebCore/ChangeLog        2014-02-07 23:03:03 UTC (rev 163654)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2014-02-07  Benjamin Poulain  &lt;bpoulain@apple.com&gt;
+
+        [WK2] Add support for text document viewport configuration
+        https://bugs.webkit.org/show_bug.cgi?id=128359
+
+        Reviewed by Simon Fraser.
+
+        Define a set of ViewportParameters suitable for displaying text documents.
+        Add a documents class for text document to differentiate them from other type of documents.
+
+        * WebCore.exp.in:
+        * dom/Document.h:
+        (WebCore::Document::isTextDocument):
+        * html/TextDocument.cpp:
+        (WebCore::TextDocument::TextDocument):
+        * page/ViewportConfiguration.cpp:
+        (WebCore::ViewportConfiguration::ViewportConfiguration):
+        (WebCore::ViewportConfiguration::webpageParameters):
+        (WebCore::ViewportConfiguration::plainTextParameters):
+        * page/ViewportConfiguration.h:
+
</ins><span class="cx"> 2014-02-07  Bem Jones-Bey  &lt;bjonesbe@adobe.com&gt;
</span><span class="cx"> 
</span><span class="cx">         FloatingObject::unsafeClone should not copy m_originatingLine
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (163653 => 163654)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-02-07 23:02:49 UTC (rev 163653)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-02-07 23:03:03 UTC (rev 163654)
</span><span class="lines">@@ -849,6 +849,8 @@
</span><span class="cx"> __ZN7WebCore21URLByRemovingUserInfoEP5NSURL
</span><span class="cx"> __ZN7WebCore21UserContentURLPattern5parseERKN3WTF6StringE
</span><span class="cx"> __ZN7WebCore21ViewportConfiguration15setContentsSizeERKNS_7IntSizeE
</span><ins>+__ZN7WebCore21ViewportConfiguration17webpageParametersEv
+__ZN7WebCore21ViewportConfiguration19plainTextParametersEv
</ins><span class="cx"> __ZN7WebCore21ViewportConfiguration20setMinimumLayoutSizeERKNS_7IntSizeE
</span><span class="cx"> __ZN7WebCore21ViewportConfiguration20setViewportArgumentsERKNS_17ViewportArgumentsE
</span><span class="cx"> __ZN7WebCore21ViewportConfiguration23setDefaultConfigurationERKNS0_10ParametersE
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumenth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.h (163653 => 163654)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.h        2014-02-07 23:02:49 UTC (rev 163653)
+++ trunk/Source/WebCore/dom/Document.h        2014-02-07 23:03:03 UTC (rev 163654)
</span><span class="lines">@@ -240,6 +240,7 @@
</span><span class="cx">     PluginDocumentClass = 1 &lt;&lt; 3,
</span><span class="cx">     MediaDocumentClass = 1 &lt;&lt; 4,
</span><span class="cx">     SVGDocumentClass = 1 &lt;&lt; 5,
</span><ins>+    TextDocumentClass = 1 &lt;&lt; 6
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> typedef unsigned char DocumentClassFlags;
</span><span class="lines">@@ -481,6 +482,7 @@
</span><span class="cx">     bool isSVGDocument() const { return m_documentClasses &amp; SVGDocumentClass; }
</span><span class="cx">     bool isPluginDocument() const { return m_documentClasses &amp; PluginDocumentClass; }
</span><span class="cx">     bool isMediaDocument() const { return m_documentClasses &amp; MediaDocumentClass; }
</span><ins>+    bool isTextDocument() const { return m_documentClasses &amp; TextDocumentClass; }
</ins><span class="cx">     bool hasSVGRootNode() const;
</span><span class="cx">     virtual bool isFrameSet() const { return false; }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlTextDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/TextDocument.cpp (163653 => 163654)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/TextDocument.cpp        2014-02-07 23:02:49 UTC (rev 163653)
+++ trunk/Source/WebCore/html/TextDocument.cpp        2014-02-07 23:03:03 UTC (rev 163654)
</span><span class="lines">@@ -30,7 +30,7 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> TextDocument::TextDocument(Frame* frame, const URL&amp; url)
</span><del>-    : HTMLDocument(frame, url)
</del><ins>+    : HTMLDocument(frame, url, TextDocumentClass)
</ins><span class="cx"> {
</span><span class="cx">     setCompatibilityMode(QuirksMode);
</span><span class="cx">     lockCompatibilityMode();
</span></span></pre></div>
<a id="trunkSourceWebCorepageViewportConfigurationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/ViewportConfiguration.cpp (163653 => 163654)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/ViewportConfiguration.cpp        2014-02-07 23:02:49 UTC (rev 163653)
+++ trunk/Source/WebCore/page/ViewportConfiguration.cpp        2014-02-07 23:03:03 UTC (rev 163654)
</span><span class="lines">@@ -29,6 +29,10 @@
</span><span class="cx"> #include &lt;wtf/Assertions.h&gt;
</span><span class="cx"> #include &lt;wtf/MathExtras.h&gt;
</span><span class="cx"> 
</span><ins>+#if PLATFORM(IOS)
+#include &quot;WebCoreSystemInterface.h&quot;
+#endif
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> #if !ASSERT_DISABLED
</span><span class="lines">@@ -44,11 +48,7 @@
</span><span class="cx"> {
</span><span class="cx">     // Setup a reasonable default configuration to avoid computing infinite scale/sizes.
</span><span class="cx">     // Those are the original iPhone configuration.
</span><del>-    m_defaultConfiguration.width = 980;
-    m_defaultConfiguration.widthIsSet = true;
-    m_defaultConfiguration.allowsUserScaling = true;
-    m_defaultConfiguration.minimumScale = 0.25;
-    m_defaultConfiguration.maximumScale = 5;
</del><ins>+    m_defaultConfiguration = ViewportConfiguration::webpageParameters();
</ins><span class="cx">     updateConfiguration();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -140,6 +140,35 @@
</span><span class="cx">     return minimumScale;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+ViewportConfiguration::Parameters ViewportConfiguration::webpageParameters()
+{
+    Parameters parameters;
+    parameters.width = 980;
+    parameters.widthIsSet = true;
+    parameters.allowsUserScaling = true;
+    parameters.minimumScale = 0.25;
+    parameters.maximumScale = 5;
+    return parameters;
+}
+
+ViewportConfiguration::Parameters ViewportConfiguration::plainTextParameters()
+{
+    Parameters parameters;
+
+#if PLATFORM(IOS)
+    parameters.width = static_cast&lt;int&gt;(wkGetViewportScreenSize().width);
+#else
+    // FIXME: this needs to be unified with ViewportArguments on all ports.
+    parameters.width = 320;
+#endif
+
+    parameters.widthIsSet = true;
+    parameters.allowsUserScaling = true;
+    parameters.minimumScale = 0.25;
+    parameters.maximumScale = 5;
+    return parameters;
+}
+
</ins><span class="cx"> static inline bool viewportArgumentValueIsValid(float value)
</span><span class="cx"> {
</span><span class="cx">     return value &gt; 0;
</span></span></pre></div>
<a id="trunkSourceWebCorepageViewportConfigurationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/ViewportConfiguration.h (163653 => 163654)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/ViewportConfiguration.h        2014-02-07 23:02:49 UTC (rev 163653)
+++ trunk/Source/WebCore/page/ViewportConfiguration.h        2014-02-07 23:03:03 UTC (rev 163654)
</span><span class="lines">@@ -82,6 +82,9 @@
</span><span class="cx">     double maximumScale() const { return m_configuration.maximumScale; }
</span><span class="cx">     bool allowsUserScaling() const { return m_configuration.allowsUserScaling; }
</span><span class="cx"> 
</span><ins>+    static Parameters webpageParameters();
+    static Parameters plainTextParameters();
+
</ins><span class="cx"> private:
</span><span class="cx">     void updateConfiguration();
</span><span class="cx">     int layoutWidth() const;
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (163653 => 163654)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-02-07 23:02:49 UTC (rev 163653)
+++ trunk/Source/WebKit2/ChangeLog        2014-02-07 23:03:03 UTC (rev 163654)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2014-02-07  Benjamin Poulain  &lt;bpoulain@apple.com&gt;
+
+        [WK2] Add support for text document viewport configuration
+        https://bugs.webkit.org/show_bug.cgi?id=128359
+
+        Reviewed by Simon Fraser.
+
+        When a text document is being loaded, use the plainText viewport parameters.
+
+        * UIProcess/API/ios/WKContentView.h:
+        * UIProcess/API/ios/WKContentView.mm:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::didCommitLoad):
+
</ins><span class="cx"> 2014-02-07  Gavin Barraclough  &lt;barraclough@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Should report user input to PageThrottler
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIiosWKContentViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.h (163653 => 163654)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.h        2014-02-07 23:02:49 UTC (rev 163653)
+++ trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.h        2014-02-07 23:03:03 UTC (rev 163654)
</span><span class="lines">@@ -32,13 +32,6 @@
</span><span class="cx"> @class WKContentView;
</span><span class="cx"> @class WKWebViewConfiguration;
</span><span class="cx"> 
</span><del>-typedef NS_ENUM(unsigned, WKContentType)
-{
-    Standard = 0,
-    PlainText,
-    Image
-};
-
</del><span class="cx"> namespace WebKit {
</span><span class="cx"> class RemoteLayerTreeTransaction;
</span><span class="cx"> }
</span><span class="lines">@@ -55,7 +48,6 @@
</span><span class="cx"> @property (readonly, nonatomic) WKBrowsingContextController *browsingContextController;
</span><span class="cx"> 
</span><span class="cx"> @property (nonatomic, assign) id &lt;WKContentViewDelegate&gt; delegate;
</span><del>-@property (nonatomic, readonly) WKContentType contentType;
</del><span class="cx"> 
</span><span class="cx"> @property (readonly) WKPageRef _pageRef;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIiosWKContentViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.mm (163653 => 163654)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.mm        2014-02-07 23:02:49 UTC (rev 163653)
+++ trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.mm        2014-02-07 23:03:03 UTC (rev 163654)
</span><span class="lines">@@ -157,15 +157,6 @@
</span><span class="cx">     return _browsingContextController.get();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (WKContentType)contentType
-{
-    if (_page-&gt;mainFrame()-&gt;mimeType() == &quot;text/plain&quot;)
-        return WKContentType::PlainText;
-    else if (_page-&gt;mainFrame()-&gt;isDisplayingStandaloneImageDocument())
-        return WKContentType::Image;
-    return WKContentType::Standard;
-}
-
</del><span class="cx"> - (WKPageRef)_pageRef
</span><span class="cx"> {
</span><span class="cx">     return toAPI(_page.get());
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (163653 => 163654)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2014-02-07 23:02:49 UTC (rev 163653)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2014-02-07 23:03:03 UTC (rev 163654)
</span><span class="lines">@@ -3959,15 +3959,11 @@
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     m_userHasChangedPageScaleFactor = false;
</span><span class="cx"> 
</span><del>-    // FIXME: Setup a real configuration.
-    ViewportConfiguration::Parameters defaultConfiguration;
-    defaultConfiguration.width = 980;
-    defaultConfiguration.widthIsSet = true;
-    defaultConfiguration.allowsUserScaling = true;
-    defaultConfiguration.minimumScale = 0.25;
-    defaultConfiguration.maximumScale = 5;
</del><ins>+    if (frame-&gt;coreFrame()-&gt;document()-&gt;isTextDocument())
+        m_viewportConfiguration.setDefaultConfiguration(ViewportConfiguration::plainTextParameters());
+    else
+        m_viewportConfiguration.setDefaultConfiguration(ViewportConfiguration::webpageParameters());
</ins><span class="cx"> 
</span><del>-    m_viewportConfiguration.setDefaultConfiguration(defaultConfiguration);
</del><span class="cx">     m_viewportConfiguration.setViewportArguments(ViewportArguments());
</span><span class="cx">     m_viewportConfiguration.setContentsSize(m_viewportConfiguration.minimumLayoutSize());
</span><span class="cx">     viewportConfigurationChanged();
</span></span></pre>
</div>
</div>

</body>
</html>