Title: [163654] trunk/Source
Revision
163654
Author
benja...@webkit.org
Date
2014-02-07 15:03:03 -0800 (Fri, 07 Feb 2014)

Log Message

[WK2] Add support for text document viewport configuration
https://bugs.webkit.org/show_bug.cgi?id=128359

Patch by Benjamin Poulain <bpoul...@apple.com> 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (163653 => 163654)


--- 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)
@@ -1,3 +1,24 @@
+2014-02-07  Benjamin Poulain  <bpoul...@apple.com>
+
+        [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:
+
 2014-02-07  Bem Jones-Bey  <bjone...@adobe.com>
 
         FloatingObject::unsafeClone should not copy m_originatingLine

Modified: trunk/Source/WebCore/WebCore.exp.in (163653 => 163654)


--- 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)
@@ -849,6 +849,8 @@
 __ZN7WebCore21URLByRemovingUserInfoEP5NSURL
 __ZN7WebCore21UserContentURLPattern5parseERKN3WTF6StringE
 __ZN7WebCore21ViewportConfiguration15setContentsSizeERKNS_7IntSizeE
+__ZN7WebCore21ViewportConfiguration17webpageParametersEv
+__ZN7WebCore21ViewportConfiguration19plainTextParametersEv
 __ZN7WebCore21ViewportConfiguration20setMinimumLayoutSizeERKNS_7IntSizeE
 __ZN7WebCore21ViewportConfiguration20setViewportArgumentsERKNS_17ViewportArgumentsE
 __ZN7WebCore21ViewportConfiguration23setDefaultConfigurationERKNS0_10ParametersE

Modified: trunk/Source/WebCore/dom/Document.h (163653 => 163654)


--- 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)
@@ -240,6 +240,7 @@
     PluginDocumentClass = 1 << 3,
     MediaDocumentClass = 1 << 4,
     SVGDocumentClass = 1 << 5,
+    TextDocumentClass = 1 << 6
 };
 
 typedef unsigned char DocumentClassFlags;
@@ -481,6 +482,7 @@
     bool isSVGDocument() const { return m_documentClasses & SVGDocumentClass; }
     bool isPluginDocument() const { return m_documentClasses & PluginDocumentClass; }
     bool isMediaDocument() const { return m_documentClasses & MediaDocumentClass; }
+    bool isTextDocument() const { return m_documentClasses & TextDocumentClass; }
     bool hasSVGRootNode() const;
     virtual bool isFrameSet() const { return false; }
 

Modified: trunk/Source/WebCore/html/TextDocument.cpp (163653 => 163654)


--- 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)
@@ -30,7 +30,7 @@
 namespace WebCore {
 
 TextDocument::TextDocument(Frame* frame, const URL& url)
-    : HTMLDocument(frame, url)
+    : HTMLDocument(frame, url, TextDocumentClass)
 {
     setCompatibilityMode(QuirksMode);
     lockCompatibilityMode();

Modified: trunk/Source/WebCore/page/ViewportConfiguration.cpp (163653 => 163654)


--- 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)
@@ -29,6 +29,10 @@
 #include <wtf/Assertions.h>
 #include <wtf/MathExtras.h>
 
+#if PLATFORM(IOS)
+#include "WebCoreSystemInterface.h"
+#endif
+
 namespace WebCore {
 
 #if !ASSERT_DISABLED
@@ -44,11 +48,7 @@
 {
     // Setup a reasonable default configuration to avoid computing infinite scale/sizes.
     // Those are the original iPhone configuration.
-    m_defaultConfiguration.width = 980;
-    m_defaultConfiguration.widthIsSet = true;
-    m_defaultConfiguration.allowsUserScaling = true;
-    m_defaultConfiguration.minimumScale = 0.25;
-    m_defaultConfiguration.maximumScale = 5;
+    m_defaultConfiguration = ViewportConfiguration::webpageParameters();
     updateConfiguration();
 }
 
@@ -140,6 +140,35 @@
     return minimumScale;
 }
 
+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<int>(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;
+}
+
 static inline bool viewportArgumentValueIsValid(float value)
 {
     return value > 0;

Modified: trunk/Source/WebCore/page/ViewportConfiguration.h (163653 => 163654)


--- 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)
@@ -82,6 +82,9 @@
     double maximumScale() const { return m_configuration.maximumScale; }
     bool allowsUserScaling() const { return m_configuration.allowsUserScaling; }
 
+    static Parameters webpageParameters();
+    static Parameters plainTextParameters();
+
 private:
     void updateConfiguration();
     int layoutWidth() const;

Modified: trunk/Source/WebKit2/ChangeLog (163653 => 163654)


--- 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)
@@ -1,3 +1,17 @@
+2014-02-07  Benjamin Poulain  <bpoul...@apple.com>
+
+        [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):
+
 2014-02-07  Gavin Barraclough  <barraclo...@apple.com>
 
         Should report user input to PageThrottler

Modified: trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.h (163653 => 163654)


--- 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)
@@ -32,13 +32,6 @@
 @class WKContentView;
 @class WKWebViewConfiguration;
 
-typedef NS_ENUM(unsigned, WKContentType)
-{
-    Standard = 0,
-    PlainText,
-    Image
-};
-
 namespace WebKit {
 class RemoteLayerTreeTransaction;
 }
@@ -55,7 +48,6 @@
 @property (readonly, nonatomic) WKBrowsingContextController *browsingContextController;
 
 @property (nonatomic, assign) id <WKContentViewDelegate> delegate;
-@property (nonatomic, readonly) WKContentType contentType;
 
 @property (readonly) WKPageRef _pageRef;
 

Modified: trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.mm (163653 => 163654)


--- 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)
@@ -157,15 +157,6 @@
     return _browsingContextController.get();
 }
 
-- (WKContentType)contentType
-{
-    if (_page->mainFrame()->mimeType() == "text/plain")
-        return WKContentType::PlainText;
-    else if (_page->mainFrame()->isDisplayingStandaloneImageDocument())
-        return WKContentType::Image;
-    return WKContentType::Standard;
-}
-
 - (WKPageRef)_pageRef
 {
     return toAPI(_page.get());

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (163653 => 163654)


--- 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)
@@ -3959,15 +3959,11 @@
 #if PLATFORM(IOS)
     m_userHasChangedPageScaleFactor = false;
 
-    // FIXME: Setup a real configuration.
-    ViewportConfiguration::Parameters defaultConfiguration;
-    defaultConfiguration.width = 980;
-    defaultConfiguration.widthIsSet = true;
-    defaultConfiguration.allowsUserScaling = true;
-    defaultConfiguration.minimumScale = 0.25;
-    defaultConfiguration.maximumScale = 5;
+    if (frame->coreFrame()->document()->isTextDocument())
+        m_viewportConfiguration.setDefaultConfiguration(ViewportConfiguration::plainTextParameters());
+    else
+        m_viewportConfiguration.setDefaultConfiguration(ViewportConfiguration::webpageParameters());
 
-    m_viewportConfiguration.setDefaultConfiguration(defaultConfiguration);
     m_viewportConfiguration.setViewportArguments(ViewportArguments());
     m_viewportConfiguration.setContentsSize(m_viewportConfiguration.minimumLayoutSize());
     viewportConfigurationChanged();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to