From edaa96fb1362454ec9cdb54ec9a7a30184327e0b Mon Sep 17 00:00:00 2001 From: "commit-queue@webkit.org" Date: Thu, 5 Jul 2012 15:38:10 +0000 Subject: [PATCH] Text Autosizing: Add test framework and simple test. 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 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 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 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: http://svn.webkit.org/repository/webkit/trunk@121907 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- LayoutTests/ChangeLog | 21 +++++++++++++++ .../text-autosizing/simple-paragraph-expected.html | 16 +++++++++++ .../fast/text-autosizing/simple-paragraph.html | 24 +++++++++++++++++ LayoutTests/platform/efl/TestExpectations | 3 +++ LayoutTests/platform/gtk/TestExpectations | 3 +++ LayoutTests/platform/mac/TestExpectations | 3 +++ LayoutTests/platform/qt/TestExpectations | 3 +++ LayoutTests/platform/win/Skipped | 3 +++ LayoutTests/platform/wincairo/Skipped | 3 +++ LayoutTests/platform/wk2/Skipped | 4 +++ Source/WebCore/ChangeLog | 31 ++++++++++++++++++++++ Source/WebCore/page/Settings.cpp | 14 ++++++++++ Source/WebCore/page/Settings.h | 9 +++++++ Source/WebCore/rendering/TextAutosizer.cpp | 13 +++++---- Source/WebCore/testing/InternalSettings.cpp | 31 ++++++++++++++++++++++ Source/WebCore/testing/InternalSettings.h | 10 +++++++ Source/WebCore/testing/InternalSettings.idl | 2 ++ Source/WebKit/chromium/ChangeLog | 13 +++++++++ Source/WebKit/chromium/features.gypi | 3 +-- 19 files changed, 200 insertions(+), 9 deletions(-) create mode 100644 LayoutTests/fast/text-autosizing/simple-paragraph-expected.html create mode 100644 LayoutTests/fast/text-autosizing/simple-paragraph.html diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index da23f5a..2dedb6c 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,24 @@ +2012-07-05 John Mellor + + 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 [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 index 0000000..21cb9e2 --- /dev/null +++ b/LayoutTests/fast/text-autosizing/simple-paragraph-expected.html @@ -0,0 +1,16 @@ + + + + + + + + + + +

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.

+ + + diff --git a/LayoutTests/fast/text-autosizing/simple-paragraph.html b/LayoutTests/fast/text-autosizing/simple-paragraph.html new file mode 100644 index 0000000..7080d46 --- /dev/null +++ b/LayoutTests/fast/text-autosizing/simple-paragraph.html @@ -0,0 +1,24 @@ + + + + + + + + + + + +

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.

+ + + diff --git a/LayoutTests/platform/efl/TestExpectations b/LayoutTests/platform/efl/TestExpectations index 2a2ce10..6c1be3b 100644 --- a/LayoutTests/platform/efl/TestExpectations +++ b/LayoutTests/platform/efl/TestExpectations @@ -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 ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/LayoutTests/platform/gtk/TestExpectations b/LayoutTests/platform/gtk/TestExpectations index 2a33c2c..4e94f40 100644 --- a/LayoutTests/platform/gtk/TestExpectations +++ b/LayoutTests/platform/gtk/TestExpectations @@ -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 ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/LayoutTests/platform/mac/TestExpectations b/LayoutTests/platform/mac/TestExpectations index d296f61..a4ecfe9 100644 --- a/LayoutTests/platform/mac/TestExpectations +++ b/LayoutTests/platform/mac/TestExpectations @@ -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 diff --git a/LayoutTests/platform/qt/TestExpectations b/LayoutTests/platform/qt/TestExpectations index 20937a0..11decdb 100644 --- a/LayoutTests/platform/qt/TestExpectations +++ b/LayoutTests/platform/qt/TestExpectations @@ -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 diff --git a/LayoutTests/platform/win/Skipped b/LayoutTests/platform/win/Skipped index d9ff3ad..b4abd0c 100644 --- a/LayoutTests/platform/win/Skipped +++ b/LayoutTests/platform/win/Skipped @@ -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 diff --git a/LayoutTests/platform/wincairo/Skipped b/LayoutTests/platform/wincairo/Skipped index 6f8eef6..e8fa77d 100644 --- a/LayoutTests/platform/wincairo/Skipped +++ b/LayoutTests/platform/wincairo/Skipped @@ -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 diff --git a/LayoutTests/platform/wk2/Skipped b/LayoutTests/platform/wk2/Skipped index e493e0a..79cbe1d 100644 --- a/LayoutTests/platform/wk2/Skipped +++ b/LayoutTests/platform/wk2/Skipped @@ -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 ######################################## diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index f7e6a83..683e9c8 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,34 @@ +2012-07-05 John Mellor + + 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 Web Inspector: timeline events in the vicinity of event dividers some times are tricky to expand diff --git a/Source/WebCore/page/Settings.cpp b/Source/WebCore/page/Settings.cpp index 55df3ff..859e844 100644 --- a/Source/WebCore/page/Settings.cpp +++ b/Source/WebCore/page/Settings.cpp @@ -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) diff --git a/Source/WebCore/page/Settings.h b/Source/WebCore/page/Settings.h index 322a5b1..11c8ed4 100644 --- a/Source/WebCore/page/Settings.h +++ b/Source/WebCore/page/Settings.h @@ -36,6 +36,10 @@ #include #include +#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; diff --git a/Source/WebCore/rendering/TextAutosizer.cpp b/Source/WebCore/rendering/TextAutosizer.cpp index 821668c..127a21c 100644 --- a/Source/WebCore/rendering/TextAutosizer.cpp +++ b/Source/WebCore/rendering/TextAutosizer.cpp @@ -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)) diff --git a/Source/WebCore/testing/InternalSettings.cpp b/Source/WebCore/testing/InternalSettings.cpp index bf43923..83d3753 100644 --- a/Source/WebCore/testing/InternalSettings.cpp +++ b/Source/WebCore/testing/InternalSettings.cpp @@ -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) diff --git a/Source/WebCore/testing/InternalSettings.h b/Source/WebCore/testing/InternalSettings.h index 127da42..7c3a330 100644 --- a/Source/WebCore/testing/InternalSettings.h +++ b/Source/WebCore/testing/InternalSettings.h @@ -32,6 +32,10 @@ #include #include +#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 diff --git a/Source/WebCore/testing/InternalSettings.idl b/Source/WebCore/testing/InternalSettings.idl index 1965f05..57e0f18 100644 --- a/Source/WebCore/testing/InternalSettings.idl +++ b/Source/WebCore/testing/InternalSettings.idl @@ -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); diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog index fa93b68..8c251f9 100644 --- a/Source/WebKit/chromium/ChangeLog +++ b/Source/WebKit/chromium/ChangeLog @@ -1,3 +1,16 @@ +2012-07-05 John Mellor + + 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 [chromium] Add a method didChangeFormState to WebViewClient. diff --git a/Source/WebKit/chromium/features.gypi b/Source/WebKit/chromium/features.gypi index 3077d0d..a9803af 100644 --- a/Source/WebKit/chromium/features.gypi +++ b/Source/WebKit/chromium/features.gypi @@ -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)', @@ -153,7 +154,6 @@ # 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', ], @@ -172,7 +172,6 @@ 'ENABLE_OVERFLOW_SCROLLING=0', 'ENABLE_PAGE_POPUP=1', 'ENABLE_SHARED_WORKERS=1', - 'ENABLE_TEXT_AUTOSIZING=0', 'ENABLE_WEB_AUDIO=1', ], }], -- 2.7.4