Title: [124372] trunk
Revision
124372
Author
[email protected]
Date
2012-08-01 15:12:23 -0700 (Wed, 01 Aug 2012)

Log Message

[Text Autosizing] Provide an API for influencing the font scale factor
https://bugs.webkit.org/show_bug.cgi?id=92882

Reviewed by Adam Barth.

Source/WebCore:

Add the font scale factor to settings, and provide an API in
window.internal.settings to change it from layout tests.

The font scale factor applied to Text Autosizing influences the sizing
of text, and will influence the scaling of boosted blocks once the
implementation progresses. For Android, it will be set to the font size
chosen in the user's system-wide preferences.

Test: fast/text-autosizing/font-scale-factor.html

* page/Settings.cpp:
(WebCore::Settings::Settings):
(WebCore):
(WebCore::Settings::setTextAutosizingFontScaleFactor):
* page/Settings.h:
(Settings):
(WebCore::Settings::textAutosizingFontScaleFactor):
* rendering/TextAutosizer.cpp:
(WebCore::TextAutosizer::processBlock):
* testing/InternalSettings.cpp:
(WebCore::InternalSettings::Backup::Backup):
(WebCore::InternalSettings::Backup::restoreTo):
(WebCore::InternalSettings::setTextAutosizingFontScaleFactor):
(WebCore):
* testing/InternalSettings.h:
(Backup):
(InternalSettings):
* testing/InternalSettings.idl:

Source/WebKit/chromium:

Add an API to change Text Autosizing's font scale factor.

The font scale factor applied to Text Autosizing influences the sizing
of text, and will influence the scaling of boosted blocks once the
implementation progresses. For Android, it will be set to the font size
chosen in the user's system-wide preferences.

* public/WebSettings.h:
* src/WebSettingsImpl.cpp:
(WebKit::WebSettingsImpl::setTextAutosizingFontScaleFactor):
(WebKit):
* src/WebSettingsImpl.h:
(WebSettingsImpl):

LayoutTests:

Add a basic test. More usable tests should be added later, as it's
really hard to test this accurately in this phase of the implementation,
and Text Autosizing is still subject to various bugs.

The font scale factor applied to Text Autosizing influences the sizing
of text, and will influence the scaling of boosted blocks once the
implementation progresses. For Android, it will be set to the font size
chosen in the user's system-wide preferences.

* fast/text-autosizing/font-scale-factor-expected.html: Added.
* fast/text-autosizing/font-scale-factor.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (124371 => 124372)


--- trunk/LayoutTests/ChangeLog	2012-08-01 21:34:13 UTC (rev 124371)
+++ trunk/LayoutTests/ChangeLog	2012-08-01 22:12:23 UTC (rev 124372)
@@ -1,3 +1,22 @@
+2012-08-01  Peter Beverloo  <[email protected]>
+
+        [Text Autosizing] Provide an API for influencing the font scale factor
+        https://bugs.webkit.org/show_bug.cgi?id=92882
+
+        Reviewed by Adam Barth.
+
+        Add a basic test. More usable tests should be added later, as it's
+        really hard to test this accurately in this phase of the implementation,
+        and Text Autosizing is still subject to various bugs.
+
+        The font scale factor applied to Text Autosizing influences the sizing
+        of text, and will influence the scaling of boosted blocks once the
+        implementation progresses. For Android, it will be set to the font size
+        chosen in the user's system-wide preferences.
+
+        * fast/text-autosizing/font-scale-factor-expected.html: Added.
+        * fast/text-autosizing/font-scale-factor.html: Added.
+
 2012-08-01  Mike West  <[email protected]>
 
         CSP should correctly block plugin resources rendered in PluginDocuments.

Added: trunk/LayoutTests/fast/text-autosizing/font-scale-factor-expected.html (0 => 124372)


--- trunk/LayoutTests/fast/text-autosizing/font-scale-factor-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text-autosizing/font-scale-factor-expected.html	2012-08-01 22:12:23 UTC (rev 124372)
@@ -0,0 +1,15 @@
+<html>
+  <head>
+    <meta name="viewport" content="width=800" />
+    <style>
+      body {
+        width: 800px;
+        margin: 0px;
+      }
+    </style>
+  </head>
+  <body>
+    <!-- FIXME: The line-height and margin-top shouldn't need to be changed here. The margins are a bug. See http://wkbug.com/91660. -->
+    <p style="font-size: 5rem; line-height: 0.30; margin: 2.20rem 0 1rem 0">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sapien sapien, tempus id egestas a, consectetur et felis. Ut pharetra mi eget lectus laoreet rutrum. Mauris tellus odio, egestas vitae sodales in, vehicula eget ante. Pellentesque id egestas arcu. Quisque tellus quam, rhoncus ac elementum vel, volutpat vel felis. Aliquam ut leo dolor, eget egestas tellus. Nunc ut velit gravida nisl fringilla rutrum eget at arcu. Vivamus et pretium mauris.</p>
+  </body>
+</html>

Added: trunk/LayoutTests/fast/text-autosizing/font-scale-factor.html (0 => 124372)


--- trunk/LayoutTests/fast/text-autosizing/font-scale-factor.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text-autosizing/font-scale-factor.html	2012-08-01 22:12:23 UTC (rev 124372)
@@ -0,0 +1,24 @@
+<html>
+  <head>
+    <meta name="viewport" content="width=800" />
+    <style>
+      body {
+        width: 800px;
+        margin: 0px;
+      }
+    </style>
+    <script>
+      if (window.internals) {
+        window.internals.settings.setTextAutosizingEnabled(true);
+        window.internals.settings.setTextAutosizingWindowSizeOverride(320, 480);
+        window.internals.settings.setTextAutosizingFontScaleFactor(2);
+      } else {
+        console.warn("Please use DumpRenderTree to run this test.");
+      }
+    </script>
+  </head>
+  <body>
+    <!-- FIXME: The line-height and margin-top shouldn't need to be changed here. See http://wkbug.com/91660. -->
+    <p style="line-height: 1.5">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sapien sapien, tempus id egestas a, consectetur et felis. Ut pharetra mi eget lectus laoreet rutrum. Mauris tellus odio, egestas vitae sodales in, vehicula eget ante. Pellentesque id egestas arcu. Quisque tellus quam, rhoncus ac elementum vel, volutpat vel felis. Aliquam ut leo dolor, eget egestas tellus. Nunc ut velit gravida nisl fringilla rutrum eget at arcu. Vivamus et pretium mauris.</p>
+  </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (124371 => 124372)


--- trunk/Source/WebCore/ChangeLog	2012-08-01 21:34:13 UTC (rev 124371)
+++ trunk/Source/WebCore/ChangeLog	2012-08-01 22:12:23 UTC (rev 124372)
@@ -1,3 +1,39 @@
+2012-08-01  Peter Beverloo  <[email protected]>
+
+        [Text Autosizing] Provide an API for influencing the font scale factor
+        https://bugs.webkit.org/show_bug.cgi?id=92882
+
+        Reviewed by Adam Barth.
+
+        Add the font scale factor to settings, and provide an API in
+        window.internal.settings to change it from layout tests.
+
+        The font scale factor applied to Text Autosizing influences the sizing
+        of text, and will influence the scaling of boosted blocks once the
+        implementation progresses. For Android, it will be set to the font size
+        chosen in the user's system-wide preferences.
+
+        Test: fast/text-autosizing/font-scale-factor.html
+
+        * page/Settings.cpp:
+        (WebCore::Settings::Settings):
+        (WebCore):
+        (WebCore::Settings::setTextAutosizingFontScaleFactor):
+        * page/Settings.h:
+        (Settings):
+        (WebCore::Settings::textAutosizingFontScaleFactor):
+        * rendering/TextAutosizer.cpp:
+        (WebCore::TextAutosizer::processBlock):
+        * testing/InternalSettings.cpp:
+        (WebCore::InternalSettings::Backup::Backup):
+        (WebCore::InternalSettings::Backup::restoreTo):
+        (WebCore::InternalSettings::setTextAutosizingFontScaleFactor):
+        (WebCore):
+        * testing/InternalSettings.h:
+        (Backup):
+        (InternalSettings):
+        * testing/InternalSettings.idl:
+
 2012-08-01  Mike West  <[email protected]>
 
         CSP should correctly block plugin resources rendered in PluginDocuments.

Modified: trunk/Source/WebCore/page/Settings.cpp (124371 => 124372)


--- trunk/Source/WebCore/page/Settings.cpp	2012-08-01 21:34:13 UTC (rev 124371)
+++ trunk/Source/WebCore/page/Settings.cpp	2012-08-01 22:12:23 UTC (rev 124372)
@@ -139,6 +139,7 @@
     , m_editingBehaviorType(editingBehaviorTypeForPlatform())
     , m_maximumHTMLParserDOMTreeDepth(defaultMaximumHTMLParserDOMTreeDepth)
 #if ENABLE(TEXT_AUTOSIZING)
+    , m_textAutosizingFontScaleFactor(1)
 #if HACK_FORCE_TEXT_AUTOSIZING_ON_DESKTOP
     , m_textAutosizingWindowSizeOverride(320, 480)
     , m_textAutosizingEnabled(true)
@@ -429,6 +430,13 @@
     m_textAutosizingWindowSizeOverride = textAutosizingWindowSizeOverride;
     m_page->setNeedsRecalcStyleInAllFrames();
 }
+
+void Settings::setTextAutosizingFontScaleFactor(float fontScaleFactor)
+{
+    m_textAutosizingFontScaleFactor = fontScaleFactor;
+    m_page->setNeedsRecalcStyleInAllFrames();
+}
+
 #endif
 
 void Settings::setLoadsImagesAutomatically(bool loadsImagesAutomatically)

Modified: trunk/Source/WebCore/page/Settings.h (124371 => 124372)


--- trunk/Source/WebCore/page/Settings.h	2012-08-01 21:34:13 UTC (rev 124371)
+++ trunk/Source/WebCore/page/Settings.h	2012-08-01 22:12:23 UTC (rev 124372)
@@ -111,6 +111,9 @@
         void setTextAutosizingEnabled(bool);
         bool textAutosizingEnabled() const { return m_textAutosizingEnabled; }
 
+        void setTextAutosizingFontScaleFactor(float);
+        float textAutosizingFontScaleFactor() const { return m_textAutosizingFontScaleFactor; }
+
         // Only set by Layout Tests, and only used if textAutosizingEnabled() returns true.
         void setTextAutosizingWindowSizeOverride(const IntSize&);
         const IntSize& textAutosizingWindowSizeOverride() const { return m_textAutosizingWindowSizeOverride; }
@@ -644,6 +647,7 @@
         unsigned m_editingBehaviorType;
         unsigned m_maximumHTMLParserDOMTreeDepth;
 #if ENABLE(TEXT_AUTOSIZING)
+        float m_textAutosizingFontScaleFactor;
         IntSize m_textAutosizingWindowSizeOverride;
         bool m_textAutosizingEnabled : 1;
 #endif

Modified: trunk/Source/WebCore/rendering/TextAutosizer.cpp (124371 => 124372)


--- trunk/Source/WebCore/rendering/TextAutosizer.cpp	2012-08-01 21:34:13 UTC (rev 124371)
+++ trunk/Source/WebCore/rendering/TextAutosizer.cpp	2012-08-01 22:12:23 UTC (rev 124372)
@@ -68,6 +68,8 @@
 {
     int windowLogicalWidth = block->isHorizontalWritingMode() ? windowSize.width() : windowSize.height();
     float multiplier = static_cast<float>(block->logicalWidth()) / windowLogicalWidth; // FIXME: This is overly simplistic.
+    multiplier *= m_document->settings()->textAutosizingFontScaleFactor();
+
     if (multiplier < 1)
         return;
     for (RenderObject* descendant = traverseNext(block, block, treatAsInline); descendant; descendant = traverseNext(descendant, block, treatAsInline)) {

Modified: trunk/Source/WebCore/testing/InternalSettings.cpp (124371 => 124372)


--- trunk/Source/WebCore/testing/InternalSettings.cpp	2012-08-01 21:34:13 UTC (rev 124371)
+++ trunk/Source/WebCore/testing/InternalSettings.cpp	2012-08-01 22:12:23 UTC (rev 124372)
@@ -91,6 +91,7 @@
 #if ENABLE(TEXT_AUTOSIZING)
     , m_originalTextAutosizingEnabled(settings->textAutosizingEnabled())
     , m_originalTextAutosizingWindowSizeOverride(settings->textAutosizingWindowSizeOverride())
+    , m_originalTextAutosizingFontScaleFactor(settings->textAutosizingFontScaleFactor())
 #endif
 #if ENABLE(DIALOG_ELEMENT)
     , m_originalDialogElementEnabled(RuntimeEnabledFeatures::dialogElementEnabled())
@@ -121,6 +122,7 @@
 #if ENABLE(TEXT_AUTOSIZING)
     settings->setTextAutosizingEnabled(m_originalTextAutosizingEnabled);
     settings->setTextAutosizingWindowSizeOverride(m_originalTextAutosizingWindowSizeOverride);
+    settings->setTextAutosizingFontScaleFactor(m_originalTextAutosizingFontScaleFactor);
 #endif
 #if ENABLE(DIALOG_ELEMENT)
     RuntimeEnabledFeatures::setDialogElementEnabled(m_originalDialogElementEnabled);
@@ -380,6 +382,17 @@
 #endif
 }
 
+void InternalSettings::setTextAutosizingFontScaleFactor(float fontScaleFactor, ExceptionCode& ec)
+{
+#if ENABLE(TEXT_AUTOSIZING)
+    InternalSettingsGuardForSettings();
+    settings()->setTextAutosizingFontScaleFactor(fontScaleFactor);
+#else
+    UNUSED_PARAM(fontScaleFactor);
+    UNUSED_PARAM(ec);
+#endif
+}
+
 void InternalSettings::setEnableScrollAnimator(bool enabled, ExceptionCode& ec)
 {
 #if ENABLE(SMOOTH_SCROLLING)

Modified: trunk/Source/WebCore/testing/InternalSettings.h (124371 => 124372)


--- trunk/Source/WebCore/testing/InternalSettings.h	2012-08-01 21:34:13 UTC (rev 124371)
+++ trunk/Source/WebCore/testing/InternalSettings.h	2012-08-01 22:12:23 UTC (rev 124372)
@@ -73,6 +73,7 @@
 #if ENABLE(TEXT_AUTOSIZING)
         bool m_originalTextAutosizingEnabled;
         IntSize m_originalTextAutosizingWindowSizeOverride;
+        float m_originalTextAutosizingFontScaleFactor;
 #endif
 #if ENABLE(DIALOG_ELEMENT)
         bool m_originalDialogElementEnabled;
@@ -115,6 +116,7 @@
     void setPictographFontFamily(const String& family, const String& script, ExceptionCode&);
     void setTextAutosizingEnabled(bool enabled, ExceptionCode&);
     void setTextAutosizingWindowSizeOverride(int width, int height, ExceptionCode&);
+    void setTextAutosizingFontScaleFactor(float fontScaleFactor, ExceptionCode&);
     void setEnableScrollAnimator(bool enabled, ExceptionCode&);
     bool scrollAnimatorEnabled(ExceptionCode&);
     void setCSSExclusionsEnabled(bool enabled, ExceptionCode&);

Modified: trunk/Source/WebCore/testing/InternalSettings.idl (124371 => 124372)


--- trunk/Source/WebCore/testing/InternalSettings.idl	2012-08-01 21:34:13 UTC (rev 124371)
+++ trunk/Source/WebCore/testing/InternalSettings.idl	2012-08-01 22:12:23 UTC (rev 124372)
@@ -54,6 +54,7 @@
         void setPictographFontFamily(in DOMString family, in DOMString script) raises(DOMException);
         void setTextAutosizingEnabled(in boolean enabled) raises(DOMException);
         void setTextAutosizingWindowSizeOverride(in long width, in long height) raises(DOMException);
+        void setTextAutosizingFontScaleFactor(in float fontScaleFactor) raises(DOMException);
         void setEnableScrollAnimator(in boolean enabled) raises(DOMException);
         boolean scrollAnimatorEnabled() raises(DOMException);
         void setCSSExclusionsEnabled(in boolean enabled) raises(DOMException);

Modified: trunk/Source/WebKit/chromium/ChangeLog (124371 => 124372)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-08-01 21:34:13 UTC (rev 124371)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-08-01 22:12:23 UTC (rev 124372)
@@ -1,3 +1,24 @@
+2012-08-01  Peter Beverloo  <[email protected]>
+
+        [Text Autosizing] Provide an API for influencing the font scale factor
+        https://bugs.webkit.org/show_bug.cgi?id=92882
+
+        Reviewed by Adam Barth.
+
+        Add an API to change Text Autosizing's font scale factor.
+
+        The font scale factor applied to Text Autosizing influences the sizing
+        of text, and will influence the scaling of boosted blocks once the
+        implementation progresses. For Android, it will be set to the font size
+        chosen in the user's system-wide preferences.
+
+        * public/WebSettings.h:
+        * src/WebSettingsImpl.cpp:
+        (WebKit::WebSettingsImpl::setTextAutosizingFontScaleFactor):
+        (WebKit):
+        * src/WebSettingsImpl.h:
+        (WebSettingsImpl):
+
 2012-08-01  Dirk Pranke  <[email protected]>
 
         Roll chromium DEPS to 149416.

Modified: trunk/Source/WebKit/chromium/public/WebSettings.h (124371 => 124372)


--- trunk/Source/WebKit/chromium/public/WebSettings.h	2012-08-01 21:34:13 UTC (rev 124371)
+++ trunk/Source/WebKit/chromium/public/WebSettings.h	2012-08-01 22:12:23 UTC (rev 124372)
@@ -145,6 +145,7 @@
     virtual void setSyncXHRInDocumentsEnabled(bool) = 0;
     virtual void setTextAreasAreResizable(bool) = 0;
     virtual void setTextAutosizingEnabled(bool) = 0;
+    virtual void setTextAutosizingFontScaleFactor(float) = 0;
     virtual void setTextDirectionSubmenuInclusionBehaviorNeverIncluded() = 0;
     virtual void setUnifiedTextCheckerEnabled(bool) = 0;
     virtual void setUserStyleSheetLocation(const WebURL&) = 0;

Modified: trunk/Source/WebKit/chromium/src/WebSettingsImpl.cpp (124371 => 124372)


--- trunk/Source/WebKit/chromium/src/WebSettingsImpl.cpp	2012-08-01 21:34:13 UTC (rev 124371)
+++ trunk/Source/WebKit/chromium/src/WebSettingsImpl.cpp	2012-08-01 22:12:23 UTC (rev 124372)
@@ -149,6 +149,15 @@
 #endif
 }
 
+void WebSettingsImpl::setTextAutosizingFontScaleFactor(float fontScaleFactor)
+{
+#if ENABLE(TEXT_AUTOSIZING)
+    m_settings->setTextAutosizingFontScaleFactor(fontScaleFactor);
+#else
+    UNUSED_PARAM(fontScaleFactor);
+#endif
+}
+
 void WebSettingsImpl::setDefaultTextEncodingName(const WebString& encoding)
 {
     m_settings->setDefaultTextEncodingName((String)encoding);

Modified: trunk/Source/WebKit/chromium/src/WebSettingsImpl.h (124371 => 124372)


--- trunk/Source/WebKit/chromium/src/WebSettingsImpl.h	2012-08-01 21:34:13 UTC (rev 124371)
+++ trunk/Source/WebKit/chromium/src/WebSettingsImpl.h	2012-08-01 22:12:23 UTC (rev 124372)
@@ -140,6 +140,7 @@
     virtual void setSyncXHRInDocumentsEnabled(bool);
     virtual void setTextAreasAreResizable(bool);
     virtual void setTextAutosizingEnabled(bool);
+    virtual void setTextAutosizingFontScaleFactor(float);
     virtual void setTextDirectionSubmenuInclusionBehaviorNeverIncluded();
     virtual void setUnifiedTextCheckerEnabled(bool);
     virtual void setUserStyleSheetLocation(const WebURL&);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to