Changeset 124372 in webkit


Ignore:
Timestamp:
Aug 1, 2012 3:12:23 PM (12 years ago)
Author:
peter@chromium.org
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.
Location:
trunk
Files:
2 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r124371 r124372  
     12012-08-01  Peter Beverloo  <peter@chromium.org>
     2
     3        [Text Autosizing] Provide an API for influencing the font scale factor
     4        https://bugs.webkit.org/show_bug.cgi?id=92882
     5
     6        Reviewed by Adam Barth.
     7
     8        Add a basic test. More usable tests should be added later, as it's
     9        really hard to test this accurately in this phase of the implementation,
     10        and Text Autosizing is still subject to various bugs.
     11
     12        The font scale factor applied to Text Autosizing influences the sizing
     13        of text, and will influence the scaling of boosted blocks once the
     14        implementation progresses. For Android, it will be set to the font size
     15        chosen in the user's system-wide preferences.
     16
     17        * fast/text-autosizing/font-scale-factor-expected.html: Added.
     18        * fast/text-autosizing/font-scale-factor.html: Added.
     19
    1202012-08-01  Mike West  <mkwst@chromium.org>
    221
  • trunk/Source/WebCore/ChangeLog

    r124371 r124372  
     12012-08-01  Peter Beverloo  <peter@chromium.org>
     2
     3        [Text Autosizing] Provide an API for influencing the font scale factor
     4        https://bugs.webkit.org/show_bug.cgi?id=92882
     5
     6        Reviewed by Adam Barth.
     7
     8        Add the font scale factor to settings, and provide an API in
     9        window.internal.settings to change it from layout tests.
     10
     11        The font scale factor applied to Text Autosizing influences the sizing
     12        of text, and will influence the scaling of boosted blocks once the
     13        implementation progresses. For Android, it will be set to the font size
     14        chosen in the user's system-wide preferences.
     15
     16        Test: fast/text-autosizing/font-scale-factor.html
     17
     18        * page/Settings.cpp:
     19        (WebCore::Settings::Settings):
     20        (WebCore):
     21        (WebCore::Settings::setTextAutosizingFontScaleFactor):
     22        * page/Settings.h:
     23        (Settings):
     24        (WebCore::Settings::textAutosizingFontScaleFactor):
     25        * rendering/TextAutosizer.cpp:
     26        (WebCore::TextAutosizer::processBlock):
     27        * testing/InternalSettings.cpp:
     28        (WebCore::InternalSettings::Backup::Backup):
     29        (WebCore::InternalSettings::Backup::restoreTo):
     30        (WebCore::InternalSettings::setTextAutosizingFontScaleFactor):
     31        (WebCore):
     32        * testing/InternalSettings.h:
     33        (Backup):
     34        (InternalSettings):
     35        * testing/InternalSettings.idl:
     36
    1372012-08-01  Mike West  <mkwst@chromium.org>
    238
  • trunk/Source/WebCore/page/Settings.cpp

    r123856 r124372  
    140140    , m_maximumHTMLParserDOMTreeDepth(defaultMaximumHTMLParserDOMTreeDepth)
    141141#if ENABLE(TEXT_AUTOSIZING)
     142    , m_textAutosizingFontScaleFactor(1)
    142143#if HACK_FORCE_TEXT_AUTOSIZING_ON_DESKTOP
    143144    , m_textAutosizingWindowSizeOverride(320, 480)
     
    430431    m_page->setNeedsRecalcStyleInAllFrames();
    431432}
     433
     434void Settings::setTextAutosizingFontScaleFactor(float fontScaleFactor)
     435{
     436    m_textAutosizingFontScaleFactor = fontScaleFactor;
     437    m_page->setNeedsRecalcStyleInAllFrames();
     438}
     439
    432440#endif
    433441
  • trunk/Source/WebCore/page/Settings.h

    r123856 r124372  
    111111        void setTextAutosizingEnabled(bool);
    112112        bool textAutosizingEnabled() const { return m_textAutosizingEnabled; }
     113
     114        void setTextAutosizingFontScaleFactor(float);
     115        float textAutosizingFontScaleFactor() const { return m_textAutosizingFontScaleFactor; }
    113116
    114117        // Only set by Layout Tests, and only used if textAutosizingEnabled() returns true.
     
    645648        unsigned m_maximumHTMLParserDOMTreeDepth;
    646649#if ENABLE(TEXT_AUTOSIZING)
     650        float m_textAutosizingFontScaleFactor;
    647651        IntSize m_textAutosizingWindowSizeOverride;
    648652        bool m_textAutosizingEnabled : 1;
  • trunk/Source/WebCore/rendering/TextAutosizer.cpp

    r121920 r124372  
    6969    int windowLogicalWidth = block->isHorizontalWritingMode() ? windowSize.width() : windowSize.height();
    7070    float multiplier = static_cast<float>(block->logicalWidth()) / windowLogicalWidth; // FIXME: This is overly simplistic.
     71    multiplier *= m_document->settings()->textAutosizingFontScaleFactor();
     72
    7173    if (multiplier < 1)
    7274        return;
  • trunk/Source/WebCore/testing/InternalSettings.cpp

    r124304 r124372  
    9292    , m_originalTextAutosizingEnabled(settings->textAutosizingEnabled())
    9393    , m_originalTextAutosizingWindowSizeOverride(settings->textAutosizingWindowSizeOverride())
     94    , m_originalTextAutosizingFontScaleFactor(settings->textAutosizingFontScaleFactor())
    9495#endif
    9596#if ENABLE(DIALOG_ELEMENT)
     
    122123    settings->setTextAutosizingEnabled(m_originalTextAutosizingEnabled);
    123124    settings->setTextAutosizingWindowSizeOverride(m_originalTextAutosizingWindowSizeOverride);
     125    settings->setTextAutosizingFontScaleFactor(m_originalTextAutosizingFontScaleFactor);
    124126#endif
    125127#if ENABLE(DIALOG_ELEMENT)
     
    377379    UNUSED_PARAM(width);
    378380    UNUSED_PARAM(height);
     381    UNUSED_PARAM(ec);
     382#endif
     383}
     384
     385void InternalSettings::setTextAutosizingFontScaleFactor(float fontScaleFactor, ExceptionCode& ec)
     386{
     387#if ENABLE(TEXT_AUTOSIZING)
     388    InternalSettingsGuardForSettings();
     389    settings()->setTextAutosizingFontScaleFactor(fontScaleFactor);
     390#else
     391    UNUSED_PARAM(fontScaleFactor);
    379392    UNUSED_PARAM(ec);
    380393#endif
  • trunk/Source/WebCore/testing/InternalSettings.h

    r124304 r124372  
    7474        bool m_originalTextAutosizingEnabled;
    7575        IntSize m_originalTextAutosizingWindowSizeOverride;
     76        float m_originalTextAutosizingFontScaleFactor;
    7677#endif
    7778#if ENABLE(DIALOG_ELEMENT)
     
    116117    void setTextAutosizingEnabled(bool enabled, ExceptionCode&);
    117118    void setTextAutosizingWindowSizeOverride(int width, int height, ExceptionCode&);
     119    void setTextAutosizingFontScaleFactor(float fontScaleFactor, ExceptionCode&);
    118120    void setEnableScrollAnimator(bool enabled, ExceptionCode&);
    119121    bool scrollAnimatorEnabled(ExceptionCode&);
  • trunk/Source/WebCore/testing/InternalSettings.idl

    r124304 r124372  
    5555        void setTextAutosizingEnabled(in boolean enabled) raises(DOMException);
    5656        void setTextAutosizingWindowSizeOverride(in long width, in long height) raises(DOMException);
     57        void setTextAutosizingFontScaleFactor(in float fontScaleFactor) raises(DOMException);
    5758        void setEnableScrollAnimator(in boolean enabled) raises(DOMException);
    5859        boolean scrollAnimatorEnabled() raises(DOMException);
  • trunk/Source/WebKit/chromium/ChangeLog

    r124348 r124372  
     12012-08-01  Peter Beverloo  <peter@chromium.org>
     2
     3        [Text Autosizing] Provide an API for influencing the font scale factor
     4        https://bugs.webkit.org/show_bug.cgi?id=92882
     5
     6        Reviewed by Adam Barth.
     7
     8        Add an API to change Text Autosizing's font scale factor.
     9
     10        The font scale factor applied to Text Autosizing influences the sizing
     11        of text, and will influence the scaling of boosted blocks once the
     12        implementation progresses. For Android, it will be set to the font size
     13        chosen in the user's system-wide preferences.
     14
     15        * public/WebSettings.h:
     16        * src/WebSettingsImpl.cpp:
     17        (WebKit::WebSettingsImpl::setTextAutosizingFontScaleFactor):
     18        (WebKit):
     19        * src/WebSettingsImpl.h:
     20        (WebSettingsImpl):
     21
    1222012-08-01  Dirk Pranke  <dpranke@chromium.org>
    223
  • trunk/Source/WebKit/chromium/public/WebSettings.h

    r124097 r124372  
    146146    virtual void setTextAreasAreResizable(bool) = 0;
    147147    virtual void setTextAutosizingEnabled(bool) = 0;
     148    virtual void setTextAutosizingFontScaleFactor(float) = 0;
    148149    virtual void setTextDirectionSubmenuInclusionBehaviorNeverIncluded() = 0;
    149150    virtual void setUnifiedTextCheckerEnabled(bool) = 0;
  • trunk/Source/WebKit/chromium/src/WebSettingsImpl.cpp

    r124097 r124372  
    150150}
    151151
     152void WebSettingsImpl::setTextAutosizingFontScaleFactor(float fontScaleFactor)
     153{
     154#if ENABLE(TEXT_AUTOSIZING)
     155    m_settings->setTextAutosizingFontScaleFactor(fontScaleFactor);
     156#else
     157    UNUSED_PARAM(fontScaleFactor);
     158#endif
     159}
     160
    152161void WebSettingsImpl::setDefaultTextEncodingName(const WebString& encoding)
    153162{
  • trunk/Source/WebKit/chromium/src/WebSettingsImpl.h

    r124097 r124372  
    141141    virtual void setTextAreasAreResizable(bool);
    142142    virtual void setTextAutosizingEnabled(bool);
     143    virtual void setTextAutosizingFontScaleFactor(float);
    143144    virtual void setTextDirectionSubmenuInclusionBehaviorNeverIncluded();
    144145    virtual void setUnifiedTextCheckerEnabled(bool);
Note: See TracChangeset for help on using the changeset viewer.