Changeset 147034 in webkit


Ignore:
Timestamp:
Mar 27, 2013 5:25:18 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Add a settings to disallow initializing background-size if background shorthand doesn't include it.
https://bugs.webkit.org/show_bug.cgi?id=113363

Source/WebCore:

Patch by KyungTae Kim <ktf.kim@samsung.com> and Yongjun Zhang <yongjun_zhang@apple.com> on 2013-03-27
Reviewed by David Kilzer.

This is based on KyungTae Kim's patch in https://bugs.webkit.org/show_bug.cgi?id=97761. Many legacy sites set
background-size first and then set background for setting background-image. For backward-compatibility
in some WebKit based clients, if 'background' shorthand have no 'background-size' attribute, we could add
a settings to let the css parser not initialize 'background-size'.

Test: fast/backgrounds/background-shorthand-after-set-backgroundSize.html

  • css/CSSParser.cpp:

(WebCore::CSSParserContext::CSSParserContext): initialize useLegacyBackgroundSizeShorthandBehavior.
(WebCore::operator==):
(WebCore::CSSParser::useLegacyBackgroundSizeShorthandBehavior): add a method to return if we want background-size

to be initialized by background shorthand.

(WebCore):
(WebCore::CSSParser::parseFillShorthand): don't initialize background-size in background shorthand if we have

useLegacyBackgroundSizeShorthandBehavior set to true.

  • css/CSSParser.h:

(CSSParser):

  • css/CSSParserMode.h: add member useLegacyBackgroundSizeShorthandBehavior to CSSParserContext.

(CSSParserContext):

  • page/Settings.in: initialize useLegacyBackgroundSizeShorthandBehavior to false.
  • testing/InternalSettings.cpp:

(WebCore::InternalSettings::Backup::Backup): add the new settings useLegacyBackgroundSizeShorthandBehavior to Backup.
(WebCore::InternalSettings::Backup::restoreTo): restore useLegacyBackgroundSizeShorthandBehavior from Backup.
(WebCore::InternalSettings::setUseLegacyBackgroundSizeShorthandBehavior):
(WebCore):

  • testing/InternalSettings.h:

(Backup):
(InternalSettings):

  • testing/InternalSettings.idl: add a JS testing API setUseLegacyBackgroundSizeShorthandBehavior to turn on/off

the new settings.

LayoutTests:

Patch by Yongjun Zhang <yongjun_zhang@apple.com> on 2013-03-27
Reviewed by David Kilzer.

Add test for the new settings useLegacyBackgroundSizeShorthandBehavior.

  • fast/backgrounds/background-shorthand-after-set-backgroundSize-expected.txt: Added.
  • fast/backgrounds/background-shorthand-after-set-backgroundSize.html: Added.
Location:
trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r147030 r147034  
     12013-03-27  Yongjun Zhang  <yongjun_zhang@apple.com>
     2
     3        Add a settings to disallow initializing background-size if background shorthand doesn't include it.
     4        https://bugs.webkit.org/show_bug.cgi?id=113363
     5
     6        Reviewed by David Kilzer.
     7
     8        Add test for the new settings useLegacyBackgroundSizeShorthandBehavior.
     9
     10        * fast/backgrounds/background-shorthand-after-set-backgroundSize-expected.txt: Added.
     11        * fast/backgrounds/background-shorthand-after-set-backgroundSize.html: Added.
     12
    1132013-03-27  Andrey Lushnikov  <lushnikov@chromium.org>
    214
  • trunk/Source/WebCore/ChangeLog

    r147033 r147034  
     12013-03-27  KyungTae Kim <ktf.kim@samsung.com> and Yongjun Zhang  <yongjun_zhang@apple.com>
     2
     3        Add a settings to disallow initializing background-size if background shorthand doesn't include it.
     4        https://bugs.webkit.org/show_bug.cgi?id=113363
     5
     6        Reviewed by David Kilzer.
     7
     8        This is based on KyungTae Kim's patch in https://bugs.webkit.org/show_bug.cgi?id=97761.  Many legacy sites set
     9        background-size first and then set background for setting background-image.  For backward-compatibility
     10        in some WebKit based clients, if 'background' shorthand have no 'background-size' attribute, we could add
     11        a settings to let the css parser not initialize 'background-size'.
     12
     13        Test: fast/backgrounds/background-shorthand-after-set-backgroundSize.html
     14
     15        * css/CSSParser.cpp:
     16        (WebCore::CSSParserContext::CSSParserContext): initialize useLegacyBackgroundSizeShorthandBehavior.
     17        (WebCore::operator==):
     18        (WebCore::CSSParser::useLegacyBackgroundSizeShorthandBehavior): add a method to return if we want background-size
     19            to be initialized by background shorthand.
     20        (WebCore):
     21        (WebCore::CSSParser::parseFillShorthand): don't initialize background-size in background shorthand if we have
     22            useLegacyBackgroundSizeShorthandBehavior set to true.
     23        * css/CSSParser.h:
     24        (CSSParser):
     25        * css/CSSParserMode.h: add member useLegacyBackgroundSizeShorthandBehavior to CSSParserContext.
     26        (CSSParserContext):
     27        * page/Settings.in: initialize useLegacyBackgroundSizeShorthandBehavior to false.
     28        * testing/InternalSettings.cpp:
     29        (WebCore::InternalSettings::Backup::Backup): add the new settings useLegacyBackgroundSizeShorthandBehavior to Backup.
     30        (WebCore::InternalSettings::Backup::restoreTo): restore useLegacyBackgroundSizeShorthandBehavior from Backup.
     31        (WebCore::InternalSettings::setUseLegacyBackgroundSizeShorthandBehavior):
     32        (WebCore):
     33        * testing/InternalSettings.h:
     34        (Backup):
     35        (InternalSettings):
     36        * testing/InternalSettings.idl: add a JS testing API setUseLegacyBackgroundSizeShorthandBehavior to turn on/off
     37            the new settings.
     38
    1392013-03-27  Florin Malita  <fmalita@chromium.org>
    240
  • trunk/Source/WebCore/css/CSSParser.cpp

    r147028 r147034  
    266266    , needsSiteSpecificQuirks(false)
    267267    , enforcesCSSMIMETypeInNoQuirksMode(true)
     268    , useLegacyBackgroundSizeShorthandBehavior(false)
    268269{
    269270}
     
    284285    , needsSiteSpecificQuirks(document->settings() ? document->settings()->needsSiteSpecificQuirks() : false)
    285286    , enforcesCSSMIMETypeInNoQuirksMode(!document->settings() || document->settings()->enforceCSSMIMETypeInNoQuirksMode())
     287    , useLegacyBackgroundSizeShorthandBehavior(document->settings() ? document->settings()->useLegacyBackgroundSizeShorthandBehavior() : false)
    286288{
    287289}
     
    302304#endif
    303305        && a.needsSiteSpecificQuirks == b.needsSiteSpecificQuirks
    304         && a.enforcesCSSMIMETypeInNoQuirksMode == b.enforcesCSSMIMETypeInNoQuirksMode;
     306        && a.enforcesCSSMIMETypeInNoQuirksMode == b.enforcesCSSMIMETypeInNoQuirksMode
     307        && a.useLegacyBackgroundSizeShorthandBehavior == b.useLegacyBackgroundSizeShorthandBehavior;
    305308}
    306309
     
    31273130}
    31283131
     3132bool CSSParser::useLegacyBackgroundSizeShorthandBehavior() const
     3133{
     3134    return m_context.useLegacyBackgroundSizeShorthandBehavior;
     3135}
     3136
    31293137const int cMaxFillProperties = 9;
    31303138
     
    32573265        } else if ((properties[i] == CSSPropertyBackgroundClip || properties[i] == CSSPropertyWebkitMaskClip) && !foundClip)
    32583266            // Value is already set while updating origin
     3267            continue;
     3268        else if (properties[i] == CSSPropertyBackgroundSize && !parsedProperty[i] && useLegacyBackgroundSizeShorthandBehavior())
    32593269            continue;
    32603270        else
  • trunk/Source/WebCore/css/CSSParser.h

    r146781 r147034  
    598598#endif
    599599
     600    bool useLegacyBackgroundSizeShorthandBehavior() const;
     601
    600602    int (CSSParser::*m_lexFunc)(void*);
    601603
  • trunk/Source/WebCore/css/CSSParserMode.h

    r145784 r147034  
    7575    bool needsSiteSpecificQuirks;
    7676    bool enforcesCSSMIMETypeInNoQuirksMode;
     77    bool useLegacyBackgroundSizeShorthandBehavior;
    7778};
    7879
  • trunk/Source/WebCore/page/Settings.in

    r146924 r147034  
    207207
    208208selectionIncludesAltImageText initial=false
     209useLegacyBackgroundSizeShorthandBehavior initial=false
  • trunk/Source/WebCore/testing/InternalSettings.cpp

    r146924 r147034  
    9999    , m_defaultVideoPosterURL(settings->defaultVideoPosterURL())
    100100    , m_originalTimeWithoutMouseMovementBeforeHidingControls(settings->timeWithoutMouseMovementBeforeHidingControls())
     101    , m_useLegacyBackgroundSizeShorthandBehavior(settings->useLegacyBackgroundSizeShorthandBehavior())
    101102{
    102103}
     
    136137    settings->setDefaultVideoPosterURL(m_defaultVideoPosterURL);
    137138    settings->setTimeWithoutMouseMovementBeforeHidingControls(m_originalTimeWithoutMouseMovementBeforeHidingControls);
     139    settings->setUseLegacyBackgroundSizeShorthandBehavior(m_useLegacyBackgroundSizeShorthandBehavior);
    138140}
    139141
     
    492494}
    493495
    494 }
     496void InternalSettings::setUseLegacyBackgroundSizeShorthandBehavior(bool enabled, ExceptionCode& ec)
     497{
     498    InternalSettingsGuardForSettings();
     499    settings()->setUseLegacyBackgroundSizeShorthandBehavior(enabled);
     500}
     501
     502}
  • trunk/Source/WebCore/testing/InternalSettings.h

    r146924 r147034  
    8484        String m_defaultVideoPosterURL;
    8585        bool m_originalTimeWithoutMouseMovementBeforeHidingControls;
     86        bool m_useLegacyBackgroundSizeShorthandBehavior;
    8687    };
    8788
     
    128129    void setDefaultVideoPosterURL(const String& url, ExceptionCode&);
    129130    void setTimeWithoutMouseMovementBeforeHidingControls(double time, ExceptionCode&);
     131    void setUseLegacyBackgroundSizeShorthandBehavior(bool enabled, ExceptionCode&);
    130132
    131133private:
  • trunk/Source/WebCore/testing/InternalSettings.idl

    r146924 r147034  
    6060    void setDefaultVideoPosterURL(in DOMString poster) raises(DOMException);
    6161    void setTimeWithoutMouseMovementBeforeHidingControls(in double time) raises(DOMException);
     62    void setUseLegacyBackgroundSizeShorthandBehavior(in boolean enabled) raises(DOMException);
    6263};
Note: See TracChangeset for help on using the changeset viewer.