Changeset 183017 in webkit


Ignore:
Timestamp:
Apr 20, 2015, 11:31:45 AM (11 years ago)
Author:
Simon Fraser
Message:

Setting inline style to the same value it already has triggers a style recalc
https://bugs.webkit.org/show_bug.cgi?id=143922

Reviewed by Antti Koivisto.

Source/WebCore:

MutableStyleProperties::setProperty() was taking the result of CSSParser::parseValue()
to mean "parsing changed the style", but it actually just means "parsing succeeded".
Add a new out param, piped through various parser functions, to indicate whether
parsing actually changed style, and instead return that from setProperty().

Add internals.startTrackingStyleRecalcs() and internals.styleRecalcCount() so
we can write tests for style recalc.

Test: fast/css/set-inline-style-recalc.html

  • WebCore.xcodeproj/project.pbxproj: Let Xcode have it's way.
  • css/CSSParser.cpp:

(WebCore::parseColorValue):
(WebCore::parseSimpleLengthValue):
(WebCore::parseKeywordValue):
(WebCore::parseTranslateTransformValue):
(WebCore::CSSParser::parseFontFaceValue):
(WebCore::CSSParser::parseValue):

  • css/CSSParser.h:
  • css/CSSProperty.h:

(WebCore::StylePropertyMetadata::operator==):
(WebCore::CSSProperty::operator==):

  • css/DOMWindowCSS.cpp:

(WebCore::DOMWindowCSS::supports):

  • css/StyleProperties.cpp:

(WebCore::MutableStyleProperties::setProperty):
(WebCore::MutableStyleProperties::appendPrefixingVariantProperty):
(WebCore::MutableStyleProperties::addParsedProperties):
(WebCore::MutableStyleProperties::addParsedProperty):

  • css/StyleProperties.h:
  • css/WebKitCSSMatrix.cpp:

(WebCore::WebKitCSSMatrix::setMatrixValue):

  • dom/Document.cpp:

(WebCore::Document::recalcStyle):
(WebCore::Document::startTrackingStyleRecalcs):
(WebCore::Document::styleRecalcCount):

  • dom/Document.h:
  • html/canvas/CanvasRenderingContext2D.cpp:

(WebCore::CanvasRenderingContext2D::setFont):

  • testing/Internals.cpp:

(WebCore::Internals::startTrackingStyleRecalcs):
(WebCore::Internals::styleRecalcCount):

  • testing/Internals.h:
  • testing/Internals.idl:

LayoutTests:

Test that changes inline-style (to test this bug fix), and classes (for
proactive testing) and counts style recalcs.

  • fast/css/set-inline-style-recalc-expected.txt: Added.
  • fast/css/set-inline-style-recalc.html: Added.
Location:
trunk
Files:
2 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r183016 r183017  
     12015-04-20  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Setting inline style to the same value it already has triggers a style recalc
     4        https://bugs.webkit.org/show_bug.cgi?id=143922
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Test that changes inline-style (to test this bug fix), and classes (for
     9        proactive testing) and counts style recalcs.
     10
     11        * fast/css/set-inline-style-recalc-expected.txt: Added.
     12        * fast/css/set-inline-style-recalc.html: Added.
     13
    1142015-04-20  Brady Eidson  <beidson@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r183016 r183017  
     12015-04-20  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Setting inline style to the same value it already has triggers a style recalc
     4        https://bugs.webkit.org/show_bug.cgi?id=143922
     5
     6        Reviewed by Antti Koivisto.
     7
     8        MutableStyleProperties::setProperty() was taking the result of CSSParser::parseValue()
     9        to mean "parsing changed the style", but it actually just means "parsing succeeded".
     10        Add a new out param, piped through various parser functions, to indicate whether
     11        parsing actually changed style, and instead return that from setProperty().
     12
     13        Add internals.startTrackingStyleRecalcs() and internals.styleRecalcCount() so
     14        we can write tests for style recalc.
     15
     16        Test: fast/css/set-inline-style-recalc.html
     17
     18        * WebCore.xcodeproj/project.pbxproj: Let Xcode have it's way.
     19        * css/CSSParser.cpp:
     20        (WebCore::parseColorValue):
     21        (WebCore::parseSimpleLengthValue):
     22        (WebCore::parseKeywordValue):
     23        (WebCore::parseTranslateTransformValue):
     24        (WebCore::CSSParser::parseFontFaceValue):
     25        (WebCore::CSSParser::parseValue):
     26        * css/CSSParser.h:
     27        * css/CSSProperty.h:
     28        (WebCore::StylePropertyMetadata::operator==):
     29        (WebCore::CSSProperty::operator==):
     30        * css/DOMWindowCSS.cpp:
     31        (WebCore::DOMWindowCSS::supports):
     32        * css/StyleProperties.cpp:
     33        (WebCore::MutableStyleProperties::setProperty):
     34        (WebCore::MutableStyleProperties::appendPrefixingVariantProperty):
     35        (WebCore::MutableStyleProperties::addParsedProperties):
     36        (WebCore::MutableStyleProperties::addParsedProperty):
     37        * css/StyleProperties.h:
     38        * css/WebKitCSSMatrix.cpp:
     39        (WebCore::WebKitCSSMatrix::setMatrixValue):
     40        * dom/Document.cpp:
     41        (WebCore::Document::recalcStyle):
     42        (WebCore::Document::startTrackingStyleRecalcs):
     43        (WebCore::Document::styleRecalcCount):
     44        * dom/Document.h:
     45        * html/canvas/CanvasRenderingContext2D.cpp:
     46        (WebCore::CanvasRenderingContext2D::setFont):
     47        * testing/Internals.cpp:
     48        (WebCore::Internals::startTrackingStyleRecalcs):
     49        (WebCore::Internals::styleRecalcCount):
     50        * testing/Internals.h:
     51        * testing/Internals.idl:
     52
    1532015-04-20  Brady Eidson  <beidson@apple.com>
    254
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r183009 r183017  
    1280012800                BC76AC110DD7AD5C00415F34 /* ParserUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParserUtilities.h; sourceTree = "<group>"; };
    1280112801                BC772B360C4EA91E0083285F /* CSSHelper.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSSHelper.h; sourceTree = "<group>"; };
    12802                 BC772B370C4EA91E0083285F /* CSSParser.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CSSParser.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
     12802                BC772B370C4EA91E0083285F /* CSSParser.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CSSParser.cpp; sourceTree = "<group>"; };
    1280312803                BC772B380C4EA91E0083285F /* CSSParser.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSSParser.h; sourceTree = "<group>"; };
    1280412804                BC772C440C4EB2C60083285F /* XMLHttpRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = XMLHttpRequest.cpp; sourceTree = "<group>"; };
  • trunk/Source/WebCore/css/CSSParser.cpp

    r182613 r183017  
    521521}
    522522
    523 static bool parseColorValue(MutableStyleProperties* declaration, CSSPropertyID propertyId, const String& string, bool important, CSSParserMode cssParserMode)
     523static CSSParser::ParseResult parseColorValue(MutableStyleProperties* declaration, CSSPropertyID propertyId, const String& string, bool important, CSSParserMode cssParserMode)
    524524{
    525525    ASSERT(!string.isEmpty());
    526526    bool strict = isStrictParserMode(cssParserMode);
    527527    if (!isColorPropertyID(propertyId))
    528         return false;
     528        return CSSParser::ParseResult::Error;
     529
    529530    CSSParserString cssString;
    530531    cssString.init(string);
     
    532533    if (validPrimitiveValueColor(valueID, strict)) {
    533534        RefPtr<CSSValue> value = cssValuePool().createIdentifierValue(valueID);
    534         declaration->addParsedProperty(CSSProperty(propertyId, value.release(), important));
    535         return true;
     535        return declaration->addParsedProperty(CSSProperty(propertyId, value.release(), important)) ? CSSParser::ParseResult::Changed : CSSParser::ParseResult::Unchanged;
    536536    }
    537537    RGBA32 color;
    538538    if (!CSSParser::fastParseColor(color, string, strict && string[0] != '#'))
    539         return false;
     539        return CSSParser::ParseResult::Error;
     540
    540541    RefPtr<CSSValue> value = cssValuePool().createColorValue(color);
    541     declaration->addParsedProperty(CSSProperty(propertyId, value.release(), important));
    542     return true;
     542    return declaration->addParsedProperty(CSSProperty(propertyId, value.release(), important)) ? CSSParser::ParseResult::Changed : CSSParser::ParseResult::Unchanged;
    543543}
    544544
     
    615615}
    616616
    617 static bool parseSimpleLengthValue(MutableStyleProperties* declaration, CSSPropertyID propertyId, const String& string, bool important, CSSParserMode cssParserMode)
     617static CSSParser::ParseResult parseSimpleLengthValue(MutableStyleProperties* declaration, CSSPropertyID propertyId, const String& string, bool important, CSSParserMode cssParserMode)
    618618{
    619619    ASSERT(!string.isEmpty());
    620620    bool acceptsNegativeNumbers;
    621621    if (!isSimpleLengthPropertyID(propertyId, acceptsNegativeNumbers))
    622         return false;
     622        return CSSParser::ParseResult::Error;
    623623
    624624    unsigned length = string.length();
     
    628628    if (string.is8Bit()) {
    629629        if (!parseSimpleLength(string.characters8(), length, unit, number))
    630             return false;
     630            return CSSParser::ParseResult::Error;
    631631    } else {
    632632        if (!parseSimpleLength(string.characters16(), length, unit, number))
    633             return false;
     633            return CSSParser::ParseResult::Error;
    634634    }
    635635
    636636    if (unit == CSSPrimitiveValue::CSS_NUMBER) {
    637637        if (number && isStrictParserMode(cssParserMode))
    638             return false;
     638            return CSSParser::ParseResult::Error;
    639639        unit = CSSPrimitiveValue::CSS_PX;
    640640    }
    641641    if (number < 0 && !acceptsNegativeNumbers)
    642         return false;
     642        return CSSParser::ParseResult::Error;
    643643    if (std::isinf(number))
    644         return false;
     644        return CSSParser::ParseResult::Error;
    645645
    646646    RefPtr<CSSValue> value = cssValuePool().createValue(number, unit);
    647     declaration->addParsedProperty(CSSProperty(propertyId, value.release(), important));
    648     return true;
     647    return declaration->addParsedProperty(CSSProperty(propertyId, value.release(), important)) ? CSSParser::ParseResult::Changed : CSSParser::ParseResult::Unchanged;
    649648}
    650649
     
    11791178}
    11801179
    1181 static bool parseKeywordValue(MutableStyleProperties* declaration, CSSPropertyID propertyId, const String& string, bool important, const CSSParserContext& parserContext, StyleSheetContents* styleSheetContents)
     1180static CSSParser::ParseResult parseKeywordValue(MutableStyleProperties* declaration, CSSPropertyID propertyId, const String& string, bool important, const CSSParserContext& parserContext, StyleSheetContents* styleSheetContents)
    11821181{
    11831182    ASSERT(!string.isEmpty());
     
    11871186        String lowerCaseString = string.lower();
    11881187        if (lowerCaseString != "initial" && lowerCaseString != "inherit")
    1189             return false;
     1188            return CSSParser::ParseResult::Error;
    11901189
    11911190        // Parse initial/inherit shorthands using the CSSParser.
    11921191        if (shorthandForProperty(propertyId).length())
    1193             return false;
     1192            return CSSParser::ParseResult::Error;
    11941193    }
    11951194
     
    11991198
    12001199    if (!valueID)
    1201         return false;
     1200        return CSSParser::ParseResult::Error;
    12021201
    12031202    RefPtr<CSSValue> value;
     
    12091208        value = cssValuePool().createIdentifierValue(valueID);
    12101209    else
    1211         return false;
    1212 
    1213     declaration->addParsedProperty(CSSProperty(propertyId, value.release(), important));
    1214     return true;
     1210        return CSSParser::ParseResult::Error;
     1211
     1212    return declaration->addParsedProperty(CSSProperty(propertyId, value.release(), important)) ? CSSParser::ParseResult::Changed : CSSParser::ParseResult::Unchanged;
    12151213}
    12161214
     
    12361234}
    12371235
    1238 static bool parseTranslateTransformValue(MutableStyleProperties* properties, CSSPropertyID propertyID, const String& string, bool important)
     1236static CSSParser::ParseResult parseTranslateTransformValue(MutableStyleProperties* properties, CSSPropertyID propertyID, const String& string, bool important)
    12391237{
    12401238    if (propertyID != CSSPropertyTransform)
    1241         return false;
     1239        return CSSParser::ParseResult::Error;
     1240
    12421241    static const unsigned shortestValidTransformStringLength = 12;
    12431242    static const unsigned likelyMultipartTransformStringLengthCutoff = 32;
    12441243    if (string.length() < shortestValidTransformStringLength || string.length() > likelyMultipartTransformStringLengthCutoff)
    1245         return false;
     1244        return CSSParser::ParseResult::Error;
     1245
    12461246    if (!string.startsWith("translate", false))
    1247         return false;
     1247        return CSSParser::ParseResult::Error;
     1248
    12481249    UChar c9 = toASCIILower(string[9]);
    12491250    UChar c10 = toASCIILower(string[10]);
     
    12671268        argumentStart = 12;
    12681269    } else
    1269         return false;
     1270        return CSSParser::ParseResult::Error;
    12701271
    12711272    RefPtr<WebKitCSSTransformValue> transformValue = WebKitCSSTransformValue::create(transformType);
     
    12761277        success = parseTransformTranslateArguments(*transformValue, string.characters16(), string.length(), argumentStart, expectedArgumentCount);
    12771278    if (!success)
    1278         return false;
     1279        return CSSParser::ParseResult::Error;
     1280
    12791281    RefPtr<CSSValueList> result = CSSValueList::createSpaceSeparated();
    12801282    result->append(transformValue.releaseNonNull());
    1281     properties->addParsedProperty(CSSProperty(CSSPropertyTransform, result.release(), important));
    1282     return true;
     1283    return properties->addParsedProperty(CSSProperty(CSSPropertyTransform, result.release(), important)) ? CSSParser::ParseResult::Changed : CSSParser::ParseResult::Unchanged;
    12831284}
    12841285
     
    12881289        return nullptr;
    12891290    RefPtr<MutableStyleProperties> dummyStyle = MutableStyleProperties::create();
    1290     if (!parseValue(dummyStyle.get(), CSSPropertyFontFamily, string, false, CSSQuirksMode, nullptr))
     1291
     1292    if (parseValue(dummyStyle.get(), CSSPropertyFontFamily, string, false, CSSQuirksMode, nullptr) == ParseResult::Error)
    12911293        return nullptr;
    12921294
     
    12971299}
    12981300
    1299 bool CSSParser::parseValue(MutableStyleProperties* declaration, CSSPropertyID propertyID, const String& string, bool important, CSSParserMode cssParserMode, StyleSheetContents* contextStyleSheet)
     1301CSSParser::ParseResult CSSParser::parseValue(MutableStyleProperties* declaration, CSSPropertyID propertyID, const String& string, bool important, CSSParserMode cssParserMode, StyleSheetContents* contextStyleSheet)
    13001302{
    13011303    ASSERT(!string.isEmpty());
    1302     if (parseSimpleLengthValue(declaration, propertyID, string, important, cssParserMode))
    1303         return true;
    1304     if (parseColorValue(declaration, propertyID, string, important, cssParserMode))
    1305         return true;
     1304    CSSParser::ParseResult result = parseSimpleLengthValue(declaration, propertyID, string, important, cssParserMode);
     1305    if (result != ParseResult::Error)
     1306        return result;
     1307
     1308    result = parseColorValue(declaration, propertyID, string, important, cssParserMode);
     1309    if (result != ParseResult::Error)
     1310        return result;
    13061311
    13071312    CSSParserContext context(cssParserMode);
     
    13111316    }
    13121317
    1313     if (parseKeywordValue(declaration, propertyID, string, important, context, contextStyleSheet))
    1314         return true;
    1315     if (parseTranslateTransformValue(declaration, propertyID, string, important))
    1316         return true;
     1318    result = parseKeywordValue(declaration, propertyID, string, important, context, contextStyleSheet);
     1319    if (result != ParseResult::Error)
     1320        return result;
     1321
     1322    result = parseTranslateTransformValue(declaration, propertyID, string, important);
     1323    if (result != ParseResult::Error)
     1324        return result;
    13171325
    13181326    CSSParser parser(context);
     
    13201328}
    13211329
    1322 bool CSSParser::parseValue(MutableStyleProperties* declaration, CSSPropertyID propertyID, const String& string, bool important, StyleSheetContents* contextStyleSheet)
     1330CSSParser::ParseResult CSSParser::parseValue(MutableStyleProperties* declaration, CSSPropertyID propertyID, const String& string, bool important, StyleSheetContents* contextStyleSheet)
    13231331{
    13241332    setStyleSheet(contextStyleSheet);
     
    13331341    m_rule = nullptr;
    13341342
    1335     bool ok = false;
     1343    ParseResult result = ParseResult::Error;
    13361344    if (m_hasFontFaceOnlyValues)
    13371345        deleteFontFaceOnlyValues();
     1346
    13381347    if (!m_parsedProperties.isEmpty()) {
    1339         ok = true;
    1340         declaration->addParsedProperties(m_parsedProperties);
     1348        result = declaration->addParsedProperties(m_parsedProperties) ? ParseResult::Changed : ParseResult::Unchanged;
    13411349        clearProperties();
    13421350    }
    13431351
    1344     return ok;
     1352    return result;
    13451353}
    13461354
  • trunk/Source/WebCore/css/CSSParser.h

    r182613 r183017  
    8282    };
    8383
     84    enum class ParseResult {
     85        Changed,
     86        Unchanged,
     87        Error
     88    };
     89
    8490    class ValueWithCalculation {
    8591    public:
     
    104110
    105111    WEBCORE_EXPORT CSSParser(const CSSParserContext&);
    106 
    107112    WEBCORE_EXPORT ~CSSParser();
    108113
     
    111116    PassRefPtr<StyleKeyframe> parseKeyframeRule(StyleSheetContents*, const String&);
    112117    bool parseSupportsCondition(const String&);
    113     static bool parseValue(MutableStyleProperties*, CSSPropertyID, const String&, bool important, CSSParserMode, StyleSheetContents*);
     118
     119    static ParseResult parseValue(MutableStyleProperties*, CSSPropertyID, const String&, bool important, CSSParserMode, StyleSheetContents*);
     120
    114121    static bool parseColor(RGBA32& color, const String&, bool strict = false);
    115122    static bool parseSystemColor(RGBA32& color, const String&, Document*);
    116123    static PassRefPtr<CSSValueList> parseFontFaceValue(const AtomicString&);
    117124    PassRefPtr<CSSPrimitiveValue> parseValidPrimitive(CSSValueID ident, ValueWithCalculation&);
     125
    118126    WEBCORE_EXPORT bool parseDeclaration(MutableStyleProperties*, const String&, PassRefPtr<CSSRuleSourceData>, StyleSheetContents* contextStyleSheet);
    119127    static Ref<ImmutableStyleProperties> parseInlineStyleDeclaration(const String&, Element*);
     
    550558    bool parseGeneratedImage(CSSParserValueList&, RefPtr<CSSValue>&);
    551559
    552     bool parseValue(MutableStyleProperties*, CSSPropertyID, const String&, bool important, StyleSheetContents* contextStyleSheet);
     560    ParseResult parseValue(MutableStyleProperties*, CSSPropertyID, const String&, bool important, StyleSheetContents* contextStyleSheet);
    553561    Ref<ImmutableStyleProperties> parseDeclaration(const String&, StyleSheetContents* contextStyleSheet);
    554562
  • trunk/Source/WebCore/css/CSSProperty.h

    r182207 r183017  
    4545
    4646    CSSPropertyID shorthandID() const;
     47   
     48    bool operator==(const StylePropertyMetadata& other) const
     49    {
     50        return m_propertyID == other.m_propertyID
     51            && m_isSetFromShorthand == other.m_isSetFromShorthand
     52            && m_indexInShorthandsVector == other.m_indexInShorthandsVector
     53            && m_important == other.m_important
     54            && m_implicit == other.m_implicit
     55            && m_inherited == other.m_inherited;
     56    }
    4757
    4858    uint16_t m_propertyID : 10;
     
    7686
    7787    const StylePropertyMetadata& metadata() const { return m_metadata; }
     88
     89    bool operator==(const CSSProperty& other) const
     90    {
     91        if (!(m_metadata == other.m_metadata))
     92            return false;
     93
     94        if (!m_value && !other.m_value)
     95            return true;
     96
     97        if (!m_value || !other.m_value)
     98            return false;
     99       
     100        return m_value->equals(*other.m_value);
     101    }
    78102
    79103private:
  • trunk/Source/WebCore/css/DOMWindowCSS.cpp

    r177733 r183017  
    7373
    7474    RefPtr<MutableStyleProperties> dummyStyle = MutableStyleProperties::create();
    75     return CSSParser::parseValue(dummyStyle.get(), propertyID, normalizedValue, false, CSSStrictMode, 0);
     75    return CSSParser::parseValue(dummyStyle.get(), propertyID, normalizedValue, false, CSSStrictMode, nullptr) != CSSParser::ParseResult::Error;
    7676}
    7777
  • trunk/Source/WebCore/css/FontLoader.cpp

    r182544 r183017  
    296296    // Interpret fontString in the same way as the 'font' attribute of CanvasRenderingContext2D.
    297297    RefPtr<MutableStyleProperties> parsedStyle = MutableStyleProperties::create();
    298     CSSParser::parseValue(parsedStyle.get(), CSSPropertyFont, fontString, true, CSSStrictMode, 0);
     298    CSSParser::parseValue(parsedStyle.get(), CSSPropertyFont, fontString, true, CSSStrictMode, nullptr);
    299299    if (parsedStyle->isEmpty())
    300300        return false;
  • trunk/Source/WebCore/css/StyleProperties.cpp

    r181832 r183017  
    682682    // When replacing an existing property value, this moves the property to the end of the list.
    683683    // Firefox preserves the position, and MSIE moves the property to the beginning.
    684     return CSSParser::parseValue(this, propertyID, value, important, cssParserMode(), contextStyleSheet);
     684    return CSSParser::parseValue(this, propertyID, value, important, cssParserMode(), contextStyleSheet) == CSSParser::ParseResult::Changed;
    685685}
    686686
     
    700700}
    701701
    702 void MutableStyleProperties::setProperty(const CSSProperty& property, CSSProperty* slot)
     702bool MutableStyleProperties::setProperty(const CSSProperty& property, CSSProperty* slot)
    703703{
    704704    if (!removeShorthandProperty(property.id())) {
    705705        CSSProperty* toReplace = slot ? slot : findCSSPropertyWithID(property.id());
    706706        if (toReplace) {
     707            if (*toReplace == property)
     708                return false;
     709
    707710            *toReplace = property;
    708711            setPrefixingVariantProperty(property);
    709             return;
    710         }
    711     }
    712     appendPrefixingVariantProperty(property);
     712            return true;
     713        }
     714    }
     715
     716    return appendPrefixingVariantProperty(property);
    713717}
    714718
     
    722726}
    723727
    724 void MutableStyleProperties::appendPrefixingVariantProperty(const CSSProperty& property)
     728bool MutableStyleProperties::appendPrefixingVariantProperty(const CSSProperty& property)
    725729{
    726730    m_propertyVector.append(property);
    727731    CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(property.id());
    728732    if (prefixingVariant == property.id())
    729         return;
     733        return true;
    730734
    731735    m_propertyVector.append(CSSProperty(prefixingVariant, property.value(), property.isImportant(), property.isSetFromShorthand(), getIndexInShorthandVectorForPrefixingVariant(property, prefixingVariant), property.metadata().m_implicit));
     736    return true;
    732737}
    733738
     
    742747bool MutableStyleProperties::setProperty(CSSPropertyID propertyID, CSSValueID identifier, bool important)
    743748{
    744     setProperty(CSSProperty(propertyID, cssValuePool().createIdentifierValue(identifier), important));
    745     return true;
     749    return setProperty(CSSProperty(propertyID, cssValuePool().createIdentifierValue(identifier), important));
    746750}
    747751
    748752bool MutableStyleProperties::setProperty(CSSPropertyID propertyID, CSSPropertyID identifier, bool important)
    749753{
    750     setProperty(CSSProperty(propertyID, cssValuePool().createIdentifierValue(identifier), important));
    751     return true;
     754    return setProperty(CSSProperty(propertyID, cssValuePool().createIdentifierValue(identifier), important));
    752755}
    753756
     
    765768}
    766769
    767 void MutableStyleProperties::addParsedProperties(const Vector<CSSProperty>& properties)
    768 {
     770bool MutableStyleProperties::addParsedProperties(const Vector<CSSProperty>& properties)
     771{
     772    bool anyChanged = false;
    769773    m_propertyVector.reserveCapacity(m_propertyVector.size() + properties.size());
    770     for (unsigned i = 0; i < properties.size(); ++i)
    771         addParsedProperty(properties[i]);
    772 }
    773 
    774 void MutableStyleProperties::addParsedProperty(const CSSProperty& property)
     774    for (unsigned i = 0; i < properties.size(); ++i) {
     775        if (addParsedProperty(properties[i]))
     776            anyChanged = true;
     777    }
     778
     779    return anyChanged;
     780}
     781
     782bool MutableStyleProperties::addParsedProperty(const CSSProperty& property)
    775783{
    776784    // Only add properties that have no !important counterpart present
    777785    if (!propertyIsImportant(property.id()) || property.isImportant())
    778         setProperty(property);
     786        return setProperty(property);
     787   
     788    return false;
    779789}
    780790
  • trunk/Source/WebCore/css/StyleProperties.h

    r181209 r183017  
    194194    PropertySetCSSStyleDeclaration* cssStyleDeclaration();
    195195
    196     void addParsedProperties(const Vector<CSSProperty>&);
    197     void addParsedProperty(const CSSProperty&);
     196    bool addParsedProperties(const Vector<CSSProperty>&);
     197    bool addParsedProperty(const CSSProperty&);
    198198
    199199    // These expand shorthand properties into multiple properties.
     
    204204    bool setProperty(CSSPropertyID, CSSValueID identifier, bool important = false);
    205205    bool setProperty(CSSPropertyID, CSSPropertyID identifier, bool important = false);
    206     void appendPrefixingVariantProperty(const CSSProperty&);
     206    bool appendPrefixingVariantProperty(const CSSProperty&);
    207207    void setPrefixingVariantProperty(const CSSProperty&);
    208     void setProperty(const CSSProperty&, CSSProperty* slot = 0);
    209 
    210     bool removeProperty(CSSPropertyID, String* returnText = 0);
     208    bool setProperty(const CSSProperty&, CSSProperty* slot = nullptr);
     209
     210    bool removeProperty(CSSPropertyID, String* returnText = nullptr);
    211211    void removePrefixedOrUnprefixedProperty(CSSPropertyID);
    212212    void removeBlockProperties();
  • trunk/Source/WebCore/css/WebKitCSSMatrix.cpp

    r181832 r183017  
    5858
    5959    RefPtr<MutableStyleProperties> styleDeclaration = MutableStyleProperties::create();
    60     if (CSSParser::parseValue(styleDeclaration.get(), CSSPropertyTransform, string, true, CSSStrictMode, 0)) {
     60    if (CSSParser::parseValue(styleDeclaration.get(), CSSPropertyTransform, string, true, CSSStrictMode, nullptr) != CSSParser::ParseResult::Error) {
    6161        // Convert to TransformOperations. This can fail if a property
    6262        // requires style (i.e., param uses 'ems' or 'exs')
  • trunk/Source/WebCore/dom/Document.cpp

    r182963 r183017  
    17911791        implicitClose();
    17921792    }
     1793   
     1794    ++m_styleRecalcCount;
    17931795
    17941796    InspectorInstrumentation::didRecalculateStyle(cookie);
     
    61406142}
    61416143
     6144void Document::startTrackingStyleRecalcs()
     6145{
     6146    m_styleRecalcCount = 0;
     6147}
     6148
     6149unsigned Document::styleRecalcCount() const
     6150{
     6151    return m_styleRecalcCount;
     6152}
     6153
    61426154DocumentLoader* Document::loader() const
    61436155{
  • trunk/Source/WebCore/dom/Document.h

    r182963 r183017  
    11421142    WEBCORE_EXPORT unsigned touchEventHandlerCount() const;
    11431143
     1144    WEBCORE_EXPORT void startTrackingStyleRecalcs();
     1145    WEBCORE_EXPORT unsigned styleRecalcCount() const;
     1146
    11441147    void didAddTouchEventHandler(Node&);
    11451148    void didRemoveTouchEventHandler(Node&, EventHandlerRemoval = EventHandlerRemoval::One);
     
    14401443    // http://www.whatwg.org/specs/web-apps/current-work/#ignore-destructive-writes-counter
    14411444    unsigned m_ignoreDestructiveWriteCount;
     1445
     1446    unsigned m_styleRecalcCount { 0 };
    14421447
    14431448    StringWithDirection m_title;
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r182750 r183017  
    20762076
    20772077    RefPtr<MutableStyleProperties> parsedStyle = MutableStyleProperties::create();
    2078     CSSParser::parseValue(parsedStyle.get(), CSSPropertyFont, newFont, true, strictToCSSParserMode(!m_usesCSSCompatibilityParseMode), 0);
     2078    CSSParser::parseValue(parsedStyle.get(), CSSPropertyFont, newFont, true, strictToCSSParserMode(!m_usesCSSCompatibilityParseMode), nullptr);
    20792079    if (parsedStyle->isEmpty())
    20802080        return;
  • trunk/Source/WebCore/testing/Internals.cpp

    r182985 r183017  
    20902090}
    20912091
     2092void Internals::startTrackingStyleRecalcs(ExceptionCode& ec)
     2093{
     2094    Document* document = contextDocument();
     2095    if (!document) {
     2096        ec = INVALID_ACCESS_ERR;
     2097        return;
     2098    }
     2099    document->startTrackingStyleRecalcs();
     2100}
     2101
     2102unsigned long Internals::styleRecalcCount(ExceptionCode& ec)
     2103{
     2104    Document* document = contextDocument();
     2105    if (!document) {
     2106        ec = INVALID_ACCESS_ERR;
     2107        return 0;
     2108    }
     2109   
     2110    return document->styleRecalcCount();
     2111}
     2112
    20922113void Internals::updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(ExceptionCode& ec)
    20932114{
  • trunk/Source/WebCore/testing/Internals.h

    r182985 r183017  
    299299    unsigned long layerFlushCount(ExceptionCode&);
    300300   
     301    void startTrackingStyleRecalcs(ExceptionCode&);
     302    unsigned long styleRecalcCount(ExceptionCode&);
     303
    301304    void updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(ExceptionCode&);
    302305    void updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(Node*, ExceptionCode&);
  • trunk/Source/WebCore/testing/Internals.idl

    r182985 r183017  
    278278    [RaisesException] boolean isTimerThrottled(long timerHandle);
    279279
     280    [RaisesException] void startTrackingStyleRecalcs();
     281    [RaisesException] unsigned long styleRecalcCount();
     282
    280283    // |node| should be Document, HTMLIFrameElement, or unspecified.
    281284    // If |node| is an HTMLIFrameElement, it assumes node.contentDocument is
Note: See TracChangeset for help on using the changeset viewer.