Changeset 198284 in webkit


Ignore:
Timestamp:
Mar 16, 2016, 9:46:12 AM (9 years ago)
Author:
Antti Koivisto
Message:

Don't invalidate style unnecessarily when setting inline style cssText
https://bugs.webkit.org/show_bug.cgi?id=155541
rdar://problem/23318893

Reviewed by Simon Fraser.

Source/WebCore:

We currently invalidate style when cssText is set whether the style declaration changed or not.

Based on a patch by Simon.

Test: fast/css/style-invalidation-inline-csstext.html

  • css/PropertySetCSSStyleDeclaration.cpp:

(WebCore::PropertySetCSSStyleDeclaration::cssText):
(WebCore::PropertySetCSSStyleDeclaration::setCssText):

Invalidate only if the parsed style changed.

  • css/StyleProperties.cpp:

(WebCore::MutableStyleProperties::parseDeclaration):

Compare the original and new style after parsing, return result.

  • css/StyleProperties.h:

LayoutTests:

  • fast/css/style-invalidation-inline-csstext-expected.txt: Added.
  • fast/css/style-invalidation-inline-csstext.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/LayoutTests/ChangeLog

    r198283 r198284  
     12016-03-16  Antti Koivisto  <antti@apple.com>
     2
     3        Don't invalidate style unnecessarily when setting inline style cssText
     4        https://bugs.webkit.org/show_bug.cgi?id=155541
     5        rdar://problem/23318893
     6
     7        Reviewed by Simon Fraser.
     8
     9        * fast/css/style-invalidation-inline-csstext-expected.txt: Added.
     10        * fast/css/style-invalidation-inline-csstext.html: Added.
     11
    1122016-03-16  Ryan Haddad  <ryanhaddad@apple.com>
    213
  • TabularUnified trunk/Source/WebCore/ChangeLog

    r198269 r198284  
     12016-03-16  Antti Koivisto  <antti@apple.com>
     2
     3        Don't invalidate style unnecessarily when setting inline style cssText
     4        https://bugs.webkit.org/show_bug.cgi?id=155541
     5        rdar://problem/23318893
     6
     7        Reviewed by Simon Fraser.
     8
     9        We currently invalidate style when cssText is set whether the style declaration changed or not.
     10
     11        Based on a patch by Simon.
     12
     13        Test: fast/css/style-invalidation-inline-csstext.html
     14
     15        * css/PropertySetCSSStyleDeclaration.cpp:
     16        (WebCore::PropertySetCSSStyleDeclaration::cssText):
     17        (WebCore::PropertySetCSSStyleDeclaration::setCssText):
     18
     19            Invalidate only if the parsed style changed.
     20
     21        * css/StyleProperties.cpp:
     22        (WebCore::MutableStyleProperties::parseDeclaration):
     23
     24            Compare the original and new style after parsing, return result.
     25
     26        * css/StyleProperties.h:
     27
    1282016-03-16  Carlos Garcia Campos  <cgarcia@igalia.com>
    229
  • TabularUnified trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp

    r190209 r198284  
    146146    return m_propertySet->asText();
    147147}
    148    
    149 void PropertySetCSSStyleDeclaration::setCssText(const String& text, ExceptionCode& ec)
     148
     149void PropertySetCSSStyleDeclaration::setCssText(const String& text, ExceptionCode&)
    150150{
    151151    StyleAttributeMutationScope mutationScope(this);
     
    153153        return;
    154154
    155     ec = 0;
    156     // FIXME: Detect syntax errors and set ec.
    157     m_propertySet->parseDeclaration(text, contextStyleSheet());
    158 
    159     didMutate(PropertyChanged);
     155    bool changed = m_propertySet->parseDeclaration(text, contextStyleSheet());
     156
     157    didMutate(changed ? PropertyChanged : NoChanges);
    160158
    161159    mutationScope.enqueueMutationRecord();   
  • TabularUnified trunk/Source/WebCore/css/StyleProperties.cpp

    r195304 r198284  
    844844}
    845845
    846 void MutableStyleProperties::parseDeclaration(const String& styleDeclaration, StyleSheetContents* contextStyleSheet)
    847 {
     846bool MutableStyleProperties::parseDeclaration(const String& styleDeclaration, StyleSheetContents* contextStyleSheet)
     847{
     848    auto oldProperties = WTFMove(m_propertyVector);
    848849    m_propertyVector.clear();
    849850
     
    855856    CSSParser parser(context);
    856857    parser.parseDeclaration(this, styleDeclaration, 0, contextStyleSheet);
     858
     859    // We could do better. Just changing property order does not require style invalidation.
     860    return oldProperties != m_propertyVector;
    857861}
    858862
  • TabularUnified trunk/Source/WebCore/css/StyleProperties.h

    r195304 r198284  
    224224
    225225    void clear();
    226     void parseDeclaration(const String& styleDeclaration, StyleSheetContents* contextStyleSheet);
     226    bool parseDeclaration(const String& styleDeclaration, StyleSheetContents* contextStyleSheet);
    227227
    228228    WEBCORE_EXPORT CSSStyleDeclaration* ensureCSSStyleDeclaration();
Note: See TracChangeset for help on using the changeset viewer.