Changeset 206753 in webkit


Ignore:
Timestamp:
Oct 3, 2016 2:52:37 PM (8 years ago)
Author:
Antti Koivisto
Message:

Remove Document::elementSheet()
https://bugs.webkit.org/show_bug.cgi?id=162876

Reviewed by Andreas Kling.

This is a Document owned stylesheet that exists as a context for parsing element inline style.
It never contains any rules and is generally confusing.

This patch removes the requirement for a stylesheet to be present for CSSParser to operate in
the correct context. Inline style is now parsed without stylesheet and a context object is
passed instead.

  • bindings/js/JSCSSStyleDeclarationCustom.cpp:

(WebCore::root):

  • bindings/js/JSCSSStyleDeclarationCustom.h:

(WebCore::root): Deleted.

  • css/PropertySetCSSStyleDeclaration.cpp:

(WebCore::PropertySetCSSStyleDeclaration::setCssText):
(WebCore::PropertySetCSSStyleDeclaration::setProperty):
(WebCore::PropertySetCSSStyleDeclaration::setPropertyInternal):
(WebCore::PropertySetCSSStyleDeclaration::cssParserContext):
(WebCore::StyleRuleCSSStyleDeclaration::parentStyleSheet):
(WebCore::StyleRuleCSSStyleDeclaration::cssParserContext):
(WebCore::InlineCSSStyleDeclaration::parentStyleSheet):
(WebCore::InlineCSSStyleDeclaration::cssParserContext):

  • css/PropertySetCSSStyleDeclaration.h:

(WebCore::PropertySetCSSStyleDeclaration::didMutate): Deleted.

  • css/StyleProperties.cpp:

(WebCore::MutableStyleProperties::setProperty):
(WebCore::MutableStyleProperties::setCustomProperty):
(WebCore::MutableStyleProperties::parseDeclaration):

  • css/parser/CSSParser.cpp:

(WebCore::CSSParser::parseValue):
(WebCore::CSSParser::parseCustomPropertyValue):
(WebCore::CSSParser::parseInlineStyleDeclaration):

  • css/parser/CSSParser.h:
  • css/parser/CSSParserImpl.cpp:

(WebCore::CSSParserImpl::parseInlineStyleDeclaration):

  • dom/Document.cpp:

(WebCore::Document::~Document):
(WebCore::Document::updateBaseURL):
(WebCore::Document::usesStyleBasedEditability):
(WebCore::Document::setHasElementUsingStyleBasedEditability):
(WebCore::Document::elementSheet): Deleted.

  • dom/Document.h:
  • dom/StyledElement.cpp:

(WebCore::StyledElement::setInlineStyleFromString):
(WebCore::StyledElement::invalidateStyleAttribute):

The usesStyleBasedEditability bit used to be set via the elementSheet. Instead check for it after inline style mutations.

(WebCore::StyledElement::setInlineStyleProperty):
(WebCore::StyledElement::addPropertyToPresentationAttributeStyle):

  • dom/StyledElement.h:

(WebCore::StyledElement::invalidateStyleAttribute): Deleted.

  • inspector/InspectorStyleSheet.cpp:

(WebCore::InspectorStyleSheetForInlineStyle::getStyleAttributeRanges):

  • svg/SVGAnimateElementBase.cpp:

(WebCore::applyCSSPropertyToTarget):

Location:
trunk/Source/WebCore
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r206751 r206753  
     12016-10-03  Antti Koivisto  <antti@apple.com>
     2
     3        Remove Document::elementSheet()
     4        https://bugs.webkit.org/show_bug.cgi?id=162876
     5
     6        Reviewed by Andreas Kling.
     7
     8        This is a Document owned stylesheet that exists as a context for parsing element inline style.
     9        It never contains any rules and is generally confusing.
     10
     11        This patch removes the requirement for a stylesheet to be present for CSSParser to operate in
     12        the correct context. Inline style is now parsed without stylesheet and a context object is
     13        passed instead.
     14
     15        * bindings/js/JSCSSStyleDeclarationCustom.cpp:
     16        (WebCore::root):
     17        * bindings/js/JSCSSStyleDeclarationCustom.h:
     18        (WebCore::root): Deleted.
     19        * css/PropertySetCSSStyleDeclaration.cpp:
     20        (WebCore::PropertySetCSSStyleDeclaration::setCssText):
     21        (WebCore::PropertySetCSSStyleDeclaration::setProperty):
     22        (WebCore::PropertySetCSSStyleDeclaration::setPropertyInternal):
     23        (WebCore::PropertySetCSSStyleDeclaration::cssParserContext):
     24        (WebCore::StyleRuleCSSStyleDeclaration::parentStyleSheet):
     25        (WebCore::StyleRuleCSSStyleDeclaration::cssParserContext):
     26        (WebCore::InlineCSSStyleDeclaration::parentStyleSheet):
     27        (WebCore::InlineCSSStyleDeclaration::cssParserContext):
     28        * css/PropertySetCSSStyleDeclaration.h:
     29        (WebCore::PropertySetCSSStyleDeclaration::didMutate): Deleted.
     30        * css/StyleProperties.cpp:
     31        (WebCore::MutableStyleProperties::setProperty):
     32        (WebCore::MutableStyleProperties::setCustomProperty):
     33        (WebCore::MutableStyleProperties::parseDeclaration):
     34        * css/parser/CSSParser.cpp:
     35        (WebCore::CSSParser::parseValue):
     36        (WebCore::CSSParser::parseCustomPropertyValue):
     37        (WebCore::CSSParser::parseInlineStyleDeclaration):
     38        * css/parser/CSSParser.h:
     39        * css/parser/CSSParserImpl.cpp:
     40        (WebCore::CSSParserImpl::parseInlineStyleDeclaration):
     41        * dom/Document.cpp:
     42        (WebCore::Document::~Document):
     43        (WebCore::Document::updateBaseURL):
     44        (WebCore::Document::usesStyleBasedEditability):
     45        (WebCore::Document::setHasElementUsingStyleBasedEditability):
     46        (WebCore::Document::elementSheet): Deleted.
     47        * dom/Document.h:
     48        * dom/StyledElement.cpp:
     49        (WebCore::StyledElement::setInlineStyleFromString):
     50        (WebCore::StyledElement::invalidateStyleAttribute):
     51
     52            The usesStyleBasedEditability bit used to be set via the elementSheet. Instead check for it after inline style mutations.
     53
     54        (WebCore::StyledElement::setInlineStyleProperty):
     55        (WebCore::StyledElement::addPropertyToPresentationAttributeStyle):
     56        * dom/StyledElement.h:
     57        (WebCore::StyledElement::invalidateStyleAttribute): Deleted.
     58        * inspector/InspectorStyleSheet.cpp:
     59        (WebCore::InspectorStyleSheetForInlineStyle::getStyleAttributeRanges):
     60        * svg/SVGAnimateElementBase.cpp:
     61        (WebCore::applyCSSPropertyToTarget):
     62
    1632016-10-03  Brent Fulgham  <bfulgham@apple.com>
    264
  • trunk/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp

    r206386 r206753  
    3030#include "CSSPrimitiveValue.h"
    3131#include "CSSPropertyNames.h"
     32#include "CSSRule.h"
     33#include "CSSStyleDeclaration.h"
     34#include "CSSStyleSheet.h"
    3235#include "CSSValue.h"
    3336#include "HashTools.h"
     37#include "JSCSSStyleDeclaration.h"
    3438#include "JSCSSValue.h"
    3539#include "JSNode.h"
     40#include "JSStyleSheetCustom.h"
    3641#include "RuntimeEnabledFeatures.h"
    3742#include "Settings.h"
     
    4853
    4954namespace WebCore {
     55
     56void* root(CSSStyleDeclaration* style)
     57{
     58    if (auto* parentRule = style->parentRule())
     59        return root(parentRule);
     60    if (auto* styleSheet = style->parentStyleSheet())
     61        return root(styleSheet);
     62    if (auto* parentElement = style->parentElement())
     63        return root(parentElement);
     64    return style;
     65}
    5066
    5167void JSCSSStyleDeclaration::visitAdditionalChildren(SlotVisitor& visitor)
  • trunk/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.h

    r143863 r206753  
    2727#define JSCSSStyleDeclarationCustom_h
    2828
    29 #include "CSSRule.h"
    30 #include "CSSStyleDeclaration.h"
    31 #include "CSSStyleSheet.h"
    32 #include "JSCSSStyleDeclaration.h"
    33 #include "JSStyleSheetCustom.h"
    34 
    3529namespace WebCore {
    3630
    37 inline void* root(CSSStyleDeclaration* style)
    38 {
    39     if (CSSRule* parentRule = style->parentRule())
    40         return root(parentRule);
    41     if (CSSStyleSheet* styleSheet = style->parentStyleSheet())
    42         return root(styleSheet);
    43     return style;
    44 }
     31class CSSStyleDeclaration;
     32
     33void* root(CSSStyleDeclaration*);
    4534
    4635}
  • trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp

    r205809 r206753  
    3232#include "MutationRecord.h"
    3333#include "StyleProperties.h"
     34#include "StyleSheetContents.h"
    3435#include "StyledElement.h"
    3536
     
    154155        return;
    155156
    156     bool changed = m_propertySet->parseDeclaration(text, contextStyleSheet());
     157    bool changed = m_propertySet->parseDeclaration(text, cssParserContext(), contextStyleSheet());
    157158
    158159    didMutate(changed ? PropertyChanged : NoChanges);
     
    232233
    233234    ec = 0;
    234     bool changed = propertyID != CSSPropertyCustom ? m_propertySet->setProperty(propertyID, value, important, contextStyleSheet()) : m_propertySet->setCustomProperty(propertyName, value, important, contextStyleSheet());
     235
     236    bool changed;
     237    if (propertyID == CSSPropertyCustom)
     238        changed = m_propertySet->setCustomProperty(propertyName, value, important, cssParserContext(), contextStyleSheet());
     239    else
     240        changed = m_propertySet->setProperty(propertyID, value, important, cssParserContext(), contextStyleSheet());
    235241
    236242    didMutate(changed ? PropertyChanged : NoChanges);
     
    291297
    292298    ec = 0;
    293     bool changed = m_propertySet->setProperty(propertyID, value, important, contextStyleSheet());
     299    bool changed = m_propertySet->setProperty(propertyID, value, important, cssParserContext(), contextStyleSheet());
    294300
    295301    didMutate(changed ? PropertyChanged : NoChanges);
     
    322328}
    323329
     330CSSParserContext PropertySetCSSStyleDeclaration::cssParserContext() const
     331{
     332    return CSSParserContext(m_propertySet->cssParserMode());
     333}
     334
    324335Ref<MutableStyleProperties> PropertySetCSSStyleDeclaration::copyProperties() const
    325336{
     
    374385CSSStyleSheet* StyleRuleCSSStyleDeclaration::parentStyleSheet() const
    375386{
    376     return m_parentRule ? m_parentRule->parentStyleSheet() : 0;
     387    return m_parentRule ? m_parentRule->parentStyleSheet() : nullptr;
     388}
     389
     390CSSParserContext StyleRuleCSSStyleDeclaration::cssParserContext() const
     391{
     392    auto* styleSheet = contextStyleSheet();
     393    if (!styleSheet)
     394        return PropertySetCSSStyleDeclaration::cssParserContext();
     395
     396    return styleSheet->parserContext();
    377397}
    378398
     
    400420CSSStyleSheet* InlineCSSStyleDeclaration::parentStyleSheet() const
    401421{
    402     return m_parentElement ? &m_parentElement->document().elementSheet() : 0;
     422    return nullptr;
     423}
     424
     425CSSParserContext InlineCSSStyleDeclaration::cssParserContext() const
     426{
     427    if (!m_parentElement)
     428        return PropertySetCSSStyleDeclaration::cssParserContext();
     429
     430    CSSParserContext context(m_parentElement->document());
     431    context.mode = m_propertySet->cssParserMode();
     432    return context;
    403433}
    404434
  • trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.h

    r205093 r206753  
    2727#define PropertySetCSSStyleDeclaration_h
    2828
     29#include "CSSParserMode.h"
    2930#include "CSSStyleDeclaration.h"
    3031#include <memory>
     
    7677    virtual bool willMutate() WARN_UNUSED_RETURN { return true; }
    7778    virtual void didMutate(MutationType) { }
     79    virtual CSSParserContext cssParserContext() const;
    7880
    7981    MutableStyleProperties* m_propertySet;
     
    106108    bool willMutate() final WARN_UNUSED_RETURN;
    107109    void didMutate(MutationType) final;
     110    CSSParserContext cssParserContext() const final;
    108111
    109112    unsigned m_refCount;
     
    126129
    127130    void didMutate(MutationType) final;
     131    CSSParserContext cssParserContext() const final;
    128132
    129133    StyledElement* m_parentElement;
  • trunk/Source/WebCore/css/StyleProperties.cpp

    r206603 r206753  
    726726}
    727727
    728 bool MutableStyleProperties::setProperty(CSSPropertyID propertyID, const String& value, bool important, StyleSheetContents* contextStyleSheet)
     728bool MutableStyleProperties::setProperty(CSSPropertyID propertyID, const String& value, bool important, CSSParserContext parserContext, StyleSheetContents* contextStyleSheet)
    729729{
    730730    // Setting the value to an empty string just removes the property in both IE and Gecko.
     
    733733        return removeProperty(propertyID);
    734734
     735    parserContext.mode = cssParserMode();
     736
    735737    // When replacing an existing property value, this moves the property to the end of the list.
    736738    // Firefox preserves the position, and MSIE moves the property to the beginning.
    737     return CSSParser::parseValue(*this, propertyID, value, important, cssParserMode(), contextStyleSheet) == CSSParser::ParseResult::Changed;
    738 }
    739 
    740 bool MutableStyleProperties::setCustomProperty(const String& propertyName, const String& value, bool important, StyleSheetContents* contextStyleSheet)
     739    return CSSParser::parseValue(*this, propertyID, value, important, parserContext, contextStyleSheet) == CSSParser::ParseResult::Changed;
     740}
     741
     742bool MutableStyleProperties::setProperty(CSSPropertyID propertyID, const String& value, bool important)
     743{
     744    CSSParserContext parserContext(cssParserMode());
     745    return setProperty(propertyID, value, important, parserContext);
     746}
     747
     748bool MutableStyleProperties::setCustomProperty(const String& propertyName, const String& value, bool important, CSSParserContext parserContext, StyleSheetContents* contextStyleSheet)
    741749{
    742750    // Setting the value to an empty string just removes the property in both IE and Gecko.
     
    745753        return removeCustomProperty(propertyName);
    746754
     755    parserContext.mode = cssParserMode();
    747756    // When replacing an existing property value, this moves the property to the end of the list.
    748757    // Firefox preserves the position, and MSIE moves the property to the beginning.
    749     return CSSParser::parseCustomPropertyValue(*this, propertyName, value, important, cssParserMode(), contextStyleSheet) == CSSParser::ParseResult::Changed;
     758    return CSSParser::parseCustomPropertyValue(*this, propertyName, value, important, parserContext, contextStyleSheet) == CSSParser::ParseResult::Changed;
    750759}
    751760
     
    799808}
    800809
    801 bool MutableStyleProperties::parseDeclaration(const String& styleDeclaration, StyleSheetContents* contextStyleSheet)
     810bool MutableStyleProperties::parseDeclaration(const String& styleDeclaration, CSSParserContext context, StyleSheetContents* contextStyleSheet)
    802811{
    803812    auto oldProperties = WTFMove(m_propertyVector);
    804813    m_propertyVector.clear();
    805814
    806     CSSParserContext context(cssParserMode());
    807     if (contextStyleSheet) {
    808         context = contextStyleSheet->parserContext();
    809         context.mode = cssParserMode();
    810     }
     815    context.mode = cssParserMode();
     816
    811817    CSSParser parser(context);
    812818    parser.parseDeclaration(*this, styleDeclaration, 0, contextStyleSheet);
  • trunk/Source/WebCore/css/StyleProperties.h

    r206603 r206753  
    200200
    201201    // These expand shorthand properties into multiple properties.
    202     bool setProperty(CSSPropertyID, const String& value, bool important = false, StyleSheetContents* contextStyleSheet = 0);
     202    bool setProperty(CSSPropertyID, const String& value, bool important, CSSParserContext, StyleSheetContents* = nullptr);
     203    bool setProperty(CSSPropertyID, const String& value, bool important = false);
    203204    void setProperty(CSSPropertyID, RefPtr<CSSValue>&&, bool important = false);
    204205
     
    215216
    216217    void clear();
    217     bool parseDeclaration(const String& styleDeclaration, StyleSheetContents* contextStyleSheet);
     218    bool parseDeclaration(const String& styleDeclaration, CSSParserContext, StyleSheetContents* = nullptr);
    218219
    219220    WEBCORE_EXPORT CSSStyleDeclaration* ensureCSSStyleDeclaration();
     
    226227
    227228    // Methods for querying and altering CSS custom properties.
    228     bool setCustomProperty(const String& propertyName, const String& value, bool important = false, StyleSheetContents* contextStyleSheet = 0);
     229    bool setCustomProperty(const String& propertyName, const String& value, bool important, CSSParserContext, StyleSheetContents* = nullptr);
    229230    bool removeCustomProperty(const String& propertyName, String* returnText = nullptr);
    230231
  • trunk/Source/WebCore/css/parser/CSSParser.cpp

    r206736 r206753  
    13131313}
    13141314
    1315 CSSParser::ParseResult CSSParser::parseValue(MutableStyleProperties& declaration, CSSPropertyID propertyID, const String& string, bool important, CSSParserMode cssParserMode, StyleSheetContents* contextStyleSheet)
     1315CSSParser::ParseResult CSSParser::parseValue(MutableStyleProperties& declaration, CSSPropertyID propertyID, const String& string, bool important, const CSSParserContext& context, StyleSheetContents* contextStyleSheet)
    13161316{
    13171317    ASSERT(!string.isEmpty());
    1318     CSSParser::ParseResult result = parseSimpleLengthValue(declaration, propertyID, string, important, cssParserMode);
     1318    CSSParser::ParseResult result = parseSimpleLengthValue(declaration, propertyID, string, important, context.mode);
    13191319    if (result != ParseResult::Error)
    13201320        return result;
    13211321
    1322     result = parseColorValue(declaration, propertyID, string, important, cssParserMode);
     1322    result = parseColorValue(declaration, propertyID, string, important,  context.mode);
    13231323    if (result != ParseResult::Error)
    13241324        return result;
    1325 
    1326     CSSParserContext context(cssParserMode);
    1327     if (contextStyleSheet) {
    1328         context = contextStyleSheet->parserContext();
    1329         context.mode = cssParserMode;
    1330     }
    13311325
    13321326    result = parseKeywordValue(declaration, propertyID, string, important, context, contextStyleSheet);
     
    13421336}
    13431337
    1344 CSSParser::ParseResult CSSParser::parseCustomPropertyValue(MutableStyleProperties& declaration, const AtomicString& propertyName, const String& string, bool important, CSSParserMode cssParserMode, StyleSheetContents* contextStyleSheet)
    1345 {
    1346     CSSParserContext context(cssParserMode);
    1347     if (contextStyleSheet) {
    1348         context = contextStyleSheet->parserContext();
    1349         context.mode = cssParserMode;
    1350     }
    1351 
     1338CSSParser::ParseResult CSSParser::parseCustomPropertyValue(MutableStyleProperties& declaration, const AtomicString& propertyName, const String& string, bool important, const CSSParserContext& context, StyleSheetContents* contextStyleSheet)
     1339{
    13521340    CSSParser parser(context);
    13531341    parser.setCustomPropertyName(propertyName);
     
    14481436Ref<ImmutableStyleProperties> CSSParser::parseInlineStyleDeclaration(const String& string, Element* element)
    14491437{
    1450     CSSParserContext context = element->document().elementSheet().contents().parserContext();
     1438    CSSParserContext context(element->document());
    14511439    context.mode = strictToCSSParserMode(element->isHTMLElement() && !element->document().inQuirksMode());
    1452     return CSSParser(context).parseDeclaration(string, &element->document().elementSheet().contents());
     1440    return CSSParser(context).parseDeclaration(string, nullptr);
    14531441}
    14541442
  • trunk/Source/WebCore/css/parser/CSSParser.h

    r206679 r206753  
    132132    bool parseSupportsCondition(const String&);
    133133
    134     static ParseResult parseValue(MutableStyleProperties&, CSSPropertyID, const String&, bool important, CSSParserMode, StyleSheetContents*);
    135     static ParseResult parseCustomPropertyValue(MutableStyleProperties&, const AtomicString& propertyName, const String&, bool important, CSSParserMode, StyleSheetContents* contextStyleSheet);
     134    static ParseResult parseValue(MutableStyleProperties&, CSSPropertyID, const String&, bool important, const CSSParserContext&, StyleSheetContents*);
     135    static ParseResult parseCustomPropertyValue(MutableStyleProperties&, const AtomicString& propertyName, const String&, bool important, const CSSParserContext&, StyleSheetContents* contextStyleSheet);
    136136
    137137    static bool parseColor(RGBA32& color, const String&, bool strict = false);
  • trunk/Source/WebCore/css/parser/CSSParserImpl.cpp

    r205869 r206753  
    136136Ref<ImmutableStyleProperties> CSSParserImpl::parseInlineStyleDeclaration(const String& string, Element* element)
    137137{
    138     Document& document = element->document();
    139     CSSParserContext context = CSSParserContext(document.elementSheet().contents().parserContext());
    140     CSSParserMode mode = element->isHTMLElement() && !document.inQuirksMode() ? HTMLStandardMode : HTMLQuirksMode;
    141     context.mode = mode;
    142     CSSParserImpl parser(context, &document.elementSheet().contents());
     138    CSSParserContext context(element->document());
     139    context.mode = strictToCSSParserMode(element->isHTMLElement() && !element->document().inQuirksMode());
     140
     141    CSSParserImpl parser(context);
    143142    CSSTokenizer::Scope scope(string);
    144143    parser.consumeDeclarationList(scope.tokenRange(), StyleRule::Style);
    145     return createStyleProperties(parser.m_parsedProperties, mode);
     144    return createStyleProperties(parser.m_parsedProperties, context.mode);
    146145}
    147146
  • trunk/Source/WebCore/dom/Document.cpp

    r206641 r206753  
    630630        m_styleSheetList->detachFromDocument();
    631631
    632     if (m_elementSheet)
    633         m_elementSheet->detachFromDocument();
    634632    extensionStyleSheets().detachFromDocument();
    635633
     
    29642962        m_baseURL = URL();
    29652963
    2966     if (m_elementSheet) {
    2967         // Element sheet is silly. It never contains anything.
    2968         ASSERT(!m_elementSheet->contents().ruleCount());
    2969         bool usesStyleBasedEditability = m_elementSheet->contents().usesStyleBasedEditability();
    2970         m_elementSheet = CSSStyleSheet::createInline(*this, m_baseURL);
    2971         // FIXME: So we are not really the parser. The right fix is to eliminate the element sheet completely.
    2972         if (usesStyleBasedEditability)
    2973             m_elementSheet->contents().parserSetUsesStyleBasedEditability();
    2974     }
    2975 
    29762964    if (!equalIgnoringFragmentIdentifier(oldBaseURL, m_baseURL)) {
    29772965        // Base URL change changes any relative visited links.
     
    31593147}
    31603148
    3161 CSSStyleSheet& Document::elementSheet()
    3162 {
    3163     if (!m_elementSheet)
    3164         m_elementSheet = CSSStyleSheet::createInline(*this, m_baseURL);
    3165     return *m_elementSheet;
    3166 }
    3167 
    31683149bool Document::usesStyleBasedEditability() const
    31693150{
    3170     if (m_elementSheet && m_elementSheet->contents().usesStyleBasedEditability())
     3151    if (m_hasElementUsingStyleBasedEditability)
    31713152        return true;
    31723153
     
    31773158    authorSheets.flushPendingUpdate();
    31783159    return authorSheets.usesStyleBasedEditability();
     3160}
     3161
     3162void Document::setHasElementUsingStyleBasedEditability()
     3163{
     3164    m_hasElementUsingStyleBasedEditability = true;
    31793165}
    31803166
  • trunk/Source/WebCore/dom/Document.h

    r206538 r206753  
    649649    Frame* findUnsafeParentScrollPropagationBoundary();
    650650
    651     CSSStyleSheet& elementSheet();
    652651    bool usesStyleBasedEditability() const;
     652    void setHasElementUsingStyleBasedEditability();
    653653   
    654654    virtual Ref<DocumentParser> createParser();
     
    14471447    std::unique_ptr<DOMImplementation> m_implementation;
    14481448
    1449     RefPtr<CSSStyleSheet> m_elementSheet;
     1449    bool m_hasElementUsingStyleBasedEditability { false };
    14501450
    14511451    bool m_printing;
  • trunk/Source/WebCore/dom/StyledElement.cpp

    r206603 r206753  
    175175}
    176176
    177 inline void StyledElement::setInlineStyleFromString(const AtomicString& newStyleString)
     177static bool usesStyleBasedEditability(const StyleProperties& properties)
     178{
     179    return properties.getPropertyCSSValue(CSSPropertyWebkitUserModify);
     180}
     181
     182void StyledElement::setInlineStyleFromString(const AtomicString& newStyleString)
    178183{
    179184    RefPtr<StyleProperties>& inlineStyle = elementData()->m_inlineStyle;
     
    191196        inlineStyle = CSSParser::parseInlineStyleDeclaration(newStyleString, this);
    192197    else
    193         downcast<MutableStyleProperties>(*inlineStyle).parseDeclaration(newStyleString, &document().elementSheet().contents());
     198        downcast<MutableStyleProperties>(*inlineStyle).parseDeclaration(newStyleString, document());
     199
     200    if (usesStyleBasedEditability(*inlineStyle))
     201        document().setHasElementUsingStyleBasedEditability();
    194202}
    195203
     
    213221}
    214222
     223void StyledElement::invalidateStyleAttribute()
     224{
     225    if (usesStyleBasedEditability(*inlineStyle()))
     226        document().setHasElementUsingStyleBasedEditability();
     227
     228    elementData()->setStyleAttributeIsDirty(true);
     229    setNeedsStyleRecalc(InlineStyleChange);
     230}
     231
    215232void StyledElement::inlineStyleChanged()
    216233{
     
    242259bool StyledElement::setInlineStyleProperty(CSSPropertyID propertyID, const String& value, bool important)
    243260{
    244     bool changes = ensureMutableInlineStyle().setProperty(propertyID, value, important, &document().elementSheet().contents());
     261    bool changes = ensureMutableInlineStyle().setProperty(propertyID, value, important, CSSParserContext(document()));
    245262    if (changes)
    246263        inlineStyleChanged();
     
    377394void StyledElement::addPropertyToPresentationAttributeStyle(MutableStyleProperties& style, CSSPropertyID propertyID, const String& value)
    378395{
    379     style.setProperty(propertyID, value, false, &document().elementSheet().contents());
    380 }
    381 
    382 }
     396    style.setProperty(propertyID, value, false, CSSParserContext(document()));
     397}
     398
     399}
  • trunk/Source/WebCore/dom/StyledElement.h

    r197779 r206753  
    9494};
    9595
    96 inline void StyledElement::invalidateStyleAttribute()
    97 {
    98     ASSERT(elementData());
    99     elementData()->setStyleAttributeIsDirty(true);
    100     setNeedsStyleRecalc(InlineStyleChange);
    101 }
    102 
    10396inline const StyleProperties* StyledElement::presentationAttributeStyle() const
    10497{
  • trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp

    r203322 r206753  
    13671367
    13681368    auto tempDeclaration = MutableStyleProperties::create();
    1369     createCSSParser(&m_element->document())->parseDeclaration(tempDeclaration, m_styleText, result, &m_element->document().elementSheet().contents());
     1369    createCSSParser(&m_element->document())->parseDeclaration(tempDeclaration, m_styleText, result, nullptr);
    13701370    return true;
    13711371}
  • trunk/Source/WebCore/svg/SVGAnimateElementBase.cpp

    r193809 r206753  
    237237    ASSERT(!targetElement.m_deletionHasBegun);
    238238
    239     if (!targetElement.ensureAnimatedSMILStyleProperties().setProperty(id, value, false, 0))
     239    if (!targetElement.ensureAnimatedSMILStyleProperties().setProperty(id, value, false))
    240240        return;
    241241
Note: See TracChangeset for help on using the changeset viewer.