Text Autosizing: Add test framework and simple test.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Jul 2012 15:38:10 +0000 (15:38 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Jul 2012 15:38:10 +0000 (15:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=90561

Source/WebCore:

Exposes methods allowing Layout Tests to enable Text Autosizing and
get the same results as if they were running on a mobile device.

Patch by John Mellor <johnme@chromium.org> on 2012-07-05
Reviewed by Adam Barth.

Test: fast/text-autosizing/simple-paragraph.html

* page/Settings.cpp:
(WebCore::Settings::Settings):
(WebCore):
(WebCore::Settings::setTextAutosizingWindowSizeOverride):
* page/Settings.h:
(Settings):
(WebCore::Settings::textAutosizingWindowSizeOverride):
* rendering/TextAutosizer.cpp:
(WebCore::TextAutosizer::boostSubtree):
* testing/InternalSettings.cpp:
(WebCore::InternalSettings::InternalSettings):
(WebCore::InternalSettings::restoreTo):
(WebCore::InternalSettings::setTextAutosizingEnabled):
(WebCore):
(WebCore::InternalSettings::setTextAutosizingWindowSizeOverride):
* testing/InternalSettings.h:
(InternalSettings):
* testing/InternalSettings.idl:

Source/WebKit/chromium:

ENABLE(TEXT_AUTOSIZING) is now on in Chromium (but disabled at runtime).
This allows it to be used in Layout Tests (and in future by Web
Inspector's mobile device emulation).

Patch by John Mellor <johnme@chromium.org> on 2012-07-05
Reviewed by Adam Barth.

* features.gypi:

LayoutTests:

Added a RefTest checking that Text Autosizing is active.
Skipped the text-autosizing test directory on platforms that
currently disable ENABLE(TEXT_AUTOSIZING).

Patch by John Mellor <johnme@chromium.org> on 2012-07-05
Reviewed by Adam Barth.

* fast/text-autosizing/simple-paragraph-expected.html: Added.
* fast/text-autosizing/simple-paragraph.html: Added.
* platform/efl/TestExpectations:
* platform/gtk/TestExpectations:
* platform/mac/TestExpectations:
* platform/qt/TestExpectations:
* platform/win/Skipped:
* platform/wincairo/Skipped:
* platform/wk2/Skipped:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@121907 268f45cc-cd09-0410-ab3c-d52691b4dbfc

19 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/text-autosizing/simple-paragraph-expected.html [new file with mode: 0644]
LayoutTests/fast/text-autosizing/simple-paragraph.html [new file with mode: 0644]
LayoutTests/platform/efl/TestExpectations
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/mac/TestExpectations
LayoutTests/platform/qt/TestExpectations
LayoutTests/platform/win/Skipped
LayoutTests/platform/wincairo/Skipped
LayoutTests/platform/wk2/Skipped
Source/WebCore/ChangeLog
Source/WebCore/page/Settings.cpp
Source/WebCore/page/Settings.h
Source/WebCore/rendering/TextAutosizer.cpp
Source/WebCore/testing/InternalSettings.cpp
Source/WebCore/testing/InternalSettings.h
Source/WebCore/testing/InternalSettings.idl
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/features.gypi

index da23f5a..2dedb6c 100644 (file)
@@ -1,3 +1,24 @@
+2012-07-05  John Mellor  <johnme@chromium.org>
+
+        Text Autosizing: Add test framework and simple test.
+        https://bugs.webkit.org/show_bug.cgi?id=90561
+
+        Added a RefTest checking that Text Autosizing is active.
+        Skipped the text-autosizing test directory on platforms that
+        currently disable ENABLE(TEXT_AUTOSIZING).
+
+        Reviewed by Adam Barth.
+
+        * fast/text-autosizing/simple-paragraph-expected.html: Added.
+        * fast/text-autosizing/simple-paragraph.html: Added.
+        * platform/efl/TestExpectations:
+        * platform/gtk/TestExpectations:
+        * platform/mac/TestExpectations:
+        * platform/qt/TestExpectations:
+        * platform/win/Skipped:
+        * platform/wincairo/Skipped:
+        * platform/wk2/Skipped:
+
 2012-07-05  Dongwoo Im  <dw.im@samsung.com>
 
         [EFL] Enable the CUSTOM_SCHEME_HANDLER feature as default.
diff --git a/LayoutTests/fast/text-autosizing/simple-paragraph-expected.html b/LayoutTests/fast/text-autosizing/simple-paragraph-expected.html
new file mode 100644 (file)
index 0000000..21cb9e2
--- /dev/null
@@ -0,0 +1,16 @@
+<html>
+<head>
+
+<meta name="viewport" content="width=800">
+<style type="text/css">
+body { width: 800px; margin: 0; }
+</style>
+
+</head>
+<body>
+
+<!-- The font-size change is intentional; the line-height change is a known FIXME; the margin-top change is a bug -->
+<p style="font-size: 2.5rem; line-height: 0.6; margin-top: 0.8rem">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>
diff --git a/LayoutTests/fast/text-autosizing/simple-paragraph.html b/LayoutTests/fast/text-autosizing/simple-paragraph.html
new file mode 100644 (file)
index 0000000..7080d46
--- /dev/null
@@ -0,0 +1,24 @@
+<html>
+<head>
+
+<meta name="viewport" content="width=800">
+<style type="text/css">
+body { width: 800px; margin: 0; }
+</style>
+
+<script type="text/javascript">
+if (window.internals) {
+    window.internals.settings.setTextAutosizingEnabled(true);
+    window.internals.settings.setTextAutosizingWindowSizeOverride(320, 480);
+} else if (window.console && console.warn) {
+    console.warn("This test depends on the Text Autosizing setting being true, so run it in DumpRenderTree, or manually enable Text Autosizing, and either use a mobile device with 320px device-width (like Nexus S or iPhone), or define HACK_FORCE_TEXT_AUTOSIZING_ON_DESKTOP.");
+}
+</script>
+
+</head>
+<body>
+
+<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>
index 2a2ce10..6c1be3b 100644 (file)
@@ -132,6 +132,9 @@ BUGWK87908 SKIP : editing/undomanager = PASS
 // Disable webaudio codec tests, including proprietary codecs.
 BUGWK88794 SKIP : webaudio/codec-tests = PASS
 
+// Text Autosizing is not yet enabled.
+BUGWK84186 SKIP : fast/text-autosizing = PASS
+
 //////////////////////////////////////////////////////////////////////////////////////////
 // CRASHES
 //////////////////////////////////////////////////////////////////////////////////////////
index 2a33c2c..4e94f40 100644 (file)
@@ -345,6 +345,9 @@ BUGWK88794 SKIP : webaudio/codec-tests = PASS
 // Content Security Policy 1.1 (ENABLE_CSP_NEXT) is not enabled
 BUGWK85558 SKIP : http/tests/security/contentSecurityPolicy/1.1 = TEXT
 
+// Text Autosizing is not yet enabled.
+BUGWK84186 SKIP : fast/text-autosizing = PASS
+
 //////////////////////////////////////////////////////////////////////////////////////////
 // End of Expected failures
 //////////////////////////////////////////////////////////////////////////////////////////
index d296f61..a4ecfe9 100644 (file)
@@ -286,3 +286,6 @@ BUGWK90007 : http/tests/security/mixedContent/insecure-audio-video-in-main-frame
 BUGWK88171 : fast/block/float/independent-align-positioning.html = TEXT
 BUGWK88171 : fast/block/float/010.html = TEXT
 BUGWK88171 : css1/formatting_model/floating_elements.html = TEXT
+
+// Text Autosizing is not enabled.
+BUGWK84186 SKIP : fast/text-autosizing = PASS
index 20937a0..11decdb 100644 (file)
@@ -106,3 +106,6 @@ BUGWK90007 : http/tests/security/mixedContent/insecure-audio-video-in-main-frame
 // Require rebaseline after bug 88171
 BUGWK88171 : fast/block/float/010.html = TEXT
 BUGWK88171 : css1/formatting_model/floating_elements.html = TEXT
+
+// Text Autosizing is not enabled.
+BUGWK84186 SKIP : fast/text-autosizing = PASS
index d9ff3ad..b4abd0c 100644 (file)
@@ -1286,6 +1286,9 @@ fullscreen/
 # viewport meta tag support
 fast/viewport
 
+# Text Autosizing is not enabled (http://webkit.org/b/84186).
+fast/text-autosizing
+
 # https://bugs.webkit.org/show_bug.cgi?id=45983
 media/media-can-play-mpeg4-video.html
 
index 6f8eef6..e8fa77d 100644 (file)
@@ -1794,6 +1794,9 @@ fullscreen/
 # viewport meta tag support
 fast/viewport
 
+# Text Autosizing is not enabled (http://webkit.org/b/84186).
+fast/text-autosizing
+
 # https://bugs.webkit.org/show_bug.cgi?id=45983
 media/media-can-play-mpeg4-video.html
 
index e493e0a..79cbe1d 100644 (file)
@@ -812,6 +812,10 @@ inspector/styles/override-screen-size.html
 # https://bugs.webkit.org/show_bug.cgi?id=86000
 http/tests/security/referrer-policy-redirect-link.html
 
+# Text Autosizing is not yet enabled.
+# https://bugs.webkit.org/show_bug.cgi?id=84186
+fast/text-autosizing
+
 ### END OF (1) Classified failures with bug reports
 ########################################
 
index f7e6a83..683e9c8 100644 (file)
@@ -1,3 +1,34 @@
+2012-07-05  John Mellor  <johnme@chromium.org>
+
+        Text Autosizing: Add test framework and simple test.
+        https://bugs.webkit.org/show_bug.cgi?id=90561
+
+        Exposes methods allowing Layout Tests to enable Text Autosizing and
+        get the same results as if they were running on a mobile device.
+
+        Reviewed by Adam Barth.
+
+        Test: fast/text-autosizing/simple-paragraph.html
+
+        * page/Settings.cpp:
+        (WebCore::Settings::Settings):
+        (WebCore):
+        (WebCore::Settings::setTextAutosizingWindowSizeOverride):
+        * page/Settings.h:
+        (Settings):
+        (WebCore::Settings::textAutosizingWindowSizeOverride):
+        * rendering/TextAutosizer.cpp:
+        (WebCore::TextAutosizer::boostSubtree):
+        * testing/InternalSettings.cpp:
+        (WebCore::InternalSettings::InternalSettings):
+        (WebCore::InternalSettings::restoreTo):
+        (WebCore::InternalSettings::setTextAutosizingEnabled):
+        (WebCore):
+        (WebCore::InternalSettings::setTextAutosizingWindowSizeOverride):
+        * testing/InternalSettings.h:
+        (InternalSettings):
+        * testing/InternalSettings.idl:
+
 2012-07-04  Andrey Kosyakov  <caseq@chromium.org>
 
         Web Inspector: timeline events in the vicinity of event dividers some times are tricky to expand
index 55df3ff..859e844 100644 (file)
@@ -139,7 +139,12 @@ Settings::Settings(Page* page)
     , m_editingBehaviorType(editingBehaviorTypeForPlatform())
     , m_maximumHTMLParserDOMTreeDepth(defaultMaximumHTMLParserDOMTreeDepth)
 #if ENABLE(TEXT_AUTOSIZING)
+#if HACK_FORCE_TEXT_AUTOSIZING_ON_DESKTOP
+    , m_textAutosizingWindowSizeOverride(320, 480)
     , m_textAutosizingEnabled(true)
+#else
+    , m_textAutosizingEnabled(false)
+#endif
 #endif
     , m_isSpatialNavigationEnabled(false)
     , m_isJavaEnabled(false)
@@ -414,6 +419,15 @@ void Settings::setTextAutosizingEnabled(bool textAutosizingEnabled)
     m_textAutosizingEnabled = textAutosizingEnabled;
     m_page->setNeedsRecalcStyleInAllFrames();
 }
+
+void Settings::setTextAutosizingWindowSizeOverride(const IntSize& textAutosizingWindowSizeOverride)
+{
+    if (m_textAutosizingWindowSizeOverride == textAutosizingWindowSizeOverride)
+        return;
+
+    m_textAutosizingWindowSizeOverride = textAutosizingWindowSizeOverride;
+    m_page->setNeedsRecalcStyleInAllFrames();
+}
 #endif
 
 void Settings::setLoadsImagesAutomatically(bool loadsImagesAutomatically)
index 322a5b1..11c8ed4 100644 (file)
 #include <wtf/text/AtomicStringHash.h>
 #include <wtf/unicode/Unicode.h>
 
+#if ENABLE(TEXT_AUTOSIZING)
+#include "IntSize.h"
+#endif
+
 namespace WebCore {
 
     class Page;
@@ -106,6 +110,10 @@ namespace WebCore {
 #if ENABLE(TEXT_AUTOSIZING)
         void setTextAutosizingEnabled(bool);
         bool textAutosizingEnabled() const { return m_textAutosizingEnabled; }
+
+        // Only set by Layout Tests, and only used if textAutosizingEnabled() returns true.
+        void setTextAutosizingWindowSizeOverride(const IntSize&);
+        const IntSize& textAutosizingWindowSizeOverride() const { return m_textAutosizingWindowSizeOverride; }
 #endif
 
         // Unlike areImagesEnabled, this only suppresses the network load of
@@ -634,6 +642,7 @@ namespace WebCore {
         unsigned m_editingBehaviorType;
         unsigned m_maximumHTMLParserDOMTreeDepth;
 #if ENABLE(TEXT_AUTOSIZING)
+        IntSize m_textAutosizingWindowSizeOverride;
         bool m_textAutosizingEnabled : 1;
 #endif
         bool m_isSpatialNavigationEnabled : 1;
index 821668c..127a21c 100644 (file)
@@ -49,13 +49,12 @@ bool TextAutosizer::boostSubtree(RenderObject* layoutRoot)
     if (!m_document->settings() || !m_document->settings()->textAutosizingEnabled() || layoutRoot->view()->printing() || !m_document->page())
         return false;
 
-#ifdef HACK_FORCE_TEXT_AUTOSIZING_ON_DESKTOP
-    IntSize windowSize(320, 480);
-#else
-    Frame* mainFrame = m_document->page()->mainFrame();
-    bool includeScrollbars = !InspectorInstrumentation::shouldApplyScreenWidthOverride(mainFrame);
-    IntSize windowSize = mainFrame->view()->visibleContentRect(includeScrollbars).size(); // FIXME: Check that this is always in logical (density-independent) pixels (see wkbug.com/87440).
-#endif
+    IntSize windowSize = m_document->settings()->textAutosizingWindowSizeOverride();
+    if (windowSize.isEmpty()) {
+        Frame* mainFrame = m_document->page()->mainFrame();
+        bool includeScrollbars = !InspectorInstrumentation::shouldApplyScreenWidthOverride(mainFrame);
+        windowSize = mainFrame->view()->visibleContentRect(includeScrollbars).size(); // FIXME: Check that this is always in logical (density-independent) pixels (see wkbug.com/87440).
+    }
 
     for (RenderObject* descendant = traverseNext(layoutRoot, layoutRoot); descendant; descendant = traverseNext(descendant, layoutRoot)) {
         if (!treatAsInline(descendant))
index bf43923..83d3753 100644 (file)
@@ -107,6 +107,10 @@ InternalSettings::InternalSettings(Frame* frame)
     , m_originalWindowFocusRestricted(settings()->windowFocusRestricted())
     , m_originalDeviceSupportsTouch(settings()->deviceSupportsTouch())
     , m_originalDeviceSupportsMouse(settings()->deviceSupportsMouse())
+#if ENABLE(TEXT_AUTOSIZING)
+    , m_originalTextAutosizingEnabled(settings()->textAutosizingEnabled())
+    , m_originalTextAutosizingWindowSizeOverride(settings()->textAutosizingWindowSizeOverride())
+#endif
 {
 }
 
@@ -128,6 +132,10 @@ void InternalSettings::restoreTo(Settings* settings)
     settings->setWindowFocusRestricted(m_originalWindowFocusRestricted);
     settings->setDeviceSupportsTouch(m_originalDeviceSupportsTouch);
     settings->setDeviceSupportsMouse(m_originalDeviceSupportsMouse);
+#if ENABLE(TEXT_AUTOSIZING)
+    settings->setTextAutosizingEnabled(m_originalTextAutosizingEnabled);
+    settings->setTextAutosizingWindowSizeOverride(m_originalTextAutosizingWindowSizeOverride);
+#endif
 }
 
 Settings* InternalSettings::settings() const
@@ -320,6 +328,29 @@ void InternalSettings::setPictographFontFamily(const String& family, const Strin
     setFontFamily(settings(), family, script, &Settings::setPictographFontFamily);
 }
 
+void InternalSettings::setTextAutosizingEnabled(bool enabled, ExceptionCode& ec)
+{
+#if ENABLE(TEXT_AUTOSIZING)
+    InternalSettingsGuardForSettings();
+    settings()->setTextAutosizingEnabled(enabled);
+#else
+    UNUSED_PARAM(enabled);
+    UNUSED_PARAM(ec);
+#endif
+}
+
+void InternalSettings::setTextAutosizingWindowSizeOverride(int width, int height, ExceptionCode& ec)
+{
+#if ENABLE(TEXT_AUTOSIZING)
+    InternalSettingsGuardForSettings();
+    settings()->setTextAutosizingWindowSizeOverride(IntSize(width, height));
+#else
+    UNUSED_PARAM(width);
+    UNUSED_PARAM(height);
+    UNUSED_PARAM(ec);
+#endif
+}
+
 void InternalSettings::setEnableScrollAnimator(bool enabled, ExceptionCode& ec)
 {
 #if ENABLE(SMOOTH_SCROLLING)
index 127da42..7c3a330 100644 (file)
 #include <wtf/RefCounted.h>
 #include <wtf/text/WTFString.h>
 
+#if ENABLE(TEXT_AUTOSIZING)
+#include "IntSize.h"
+#endif
+
 namespace WebCore {
 
 typedef int ExceptionCode;
@@ -72,6 +76,8 @@ public:
     void setCursiveFontFamily(const String& family, const String& script, ExceptionCode&);
     void setFantasyFontFamily(const String& family, const String& script, ExceptionCode&);
     void setPictographFontFamily(const String& family, const String& script, ExceptionCode&);
+    void setTextAutosizingEnabled(bool enabled, ExceptionCode&);
+    void setTextAutosizingWindowSizeOverride(int width, int height, ExceptionCode&);
     void setEnableScrollAnimator(bool enabled, ExceptionCode&);
     bool scrollAnimatorEnabled(ExceptionCode&);
     void setCSSExclusionsEnabled(bool enabled, ExceptionCode&);
@@ -109,6 +115,10 @@ private:
     bool m_originalWindowFocusRestricted;
     bool m_originalDeviceSupportsTouch;
     bool m_originalDeviceSupportsMouse;
+#if ENABLE(TEXT_AUTOSIZING)
+    bool m_originalTextAutosizingEnabled;
+    IntSize m_originalTextAutosizingWindowSizeOverride;
+#endif
 };
 
 } // namespace WebCore
index 1965f05..57e0f18 100644 (file)
@@ -51,6 +51,8 @@ module window {
         void setCursiveFontFamily(in DOMString family, in DOMString script) raises(DOMException);
         void setFantasyFontFamily(in DOMString family, in DOMString script) raises(DOMException);
         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 setEnableScrollAnimator(in boolean enabled) raises(DOMException);
         boolean scrollAnimatorEnabled() raises(DOMException);
         void setCSSExclusionsEnabled(in boolean enabled) raises(DOMException);
index fa93b68..8c251f9 100644 (file)
@@ -1,3 +1,16 @@
+2012-07-05  John Mellor  <johnme@chromium.org>
+
+        Text Autosizing: Add test framework and simple test.
+        https://bugs.webkit.org/show_bug.cgi?id=90561
+
+        ENABLE(TEXT_AUTOSIZING) is now on in Chromium (but disabled at runtime).
+        This allows it to be used in Layout Tests (and in future by Web
+        Inspector's mobile device emulation).
+
+        Reviewed by Adam Barth.
+
+        * features.gypi:
+
 2012-07-05  Oli Lan  <olilan@chromium.org>
 
         [chromium] Add a method didChangeFormState to WebViewClient.
index 3077d0d..a9803af 100644 (file)
@@ -92,6 +92,7 @@
       'ENABLE_STYLE_SCOPED=1',
       'ENABLE_SVG=<(enable_svg)',
       'ENABLE_SVG_FONTS=<(enable_svg)',
+      'ENABLE_TEXT_AUTOSIZING=1',
       'ENABLE_TOUCH_ADJUSTMENT=1',
       'ENABLE_TOUCH_EVENTS=<(enable_touch_events)',
       'ENABLE_TOUCH_ICON_LOADING=<(enable_touch_icon_loading)',
           # FIXME: Disable once the linking error has been resolved.
           # https://bugs.webkit.org/show_bug.cgi?id=88636
           'ENABLE_SHARED_WORKERS=1',
-          'ENABLE_TEXT_AUTOSIZING=1',
           'ENABLE_WEB_AUDIO=0',
           'WTF_USE_NATIVE_FULLSCREEN_VIDEO=1',
         ],
           'ENABLE_OVERFLOW_SCROLLING=0',
           'ENABLE_PAGE_POPUP=1',
           'ENABLE_SHARED_WORKERS=1',
-          'ENABLE_TEXT_AUTOSIZING=0',
           'ENABLE_WEB_AUDIO=1',
         ],
       }],