Remove stylesheet pointer from StylePropertySet
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Feb 2012 13:49:15 +0000 (13:49 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Feb 2012 13:49:15 +0000 (13:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=79092

Reviewed by Andreas Kling.

The context should be passed as an argument for CSS parser invoking setters that actually need it.

- Remove the context stylesheet pointer.
- Add context stylesheet argument to setters.
- Drop an unnecessary StylePropertySet constructor, pass strict parsing flag directly.
- Adapt to changes by passing in the context stylesheet where needed.
- Add StyledElement::applyPresentationAttributeToStyle helpers for building up the attribute style.

* css/CSSFontFaceRule.cpp:
(WebCore::CSSFontFaceRule::addSubresourceStyleURLs):
* css/CSSParser.cpp:
(WebCore::parseColorValue):
(WebCore::parseSimpleLengthValue):
(WebCore::CSSParser::parseValue):
(WebCore::CSSParser::parseDeclaration):
(WebCore::CSSParser::createStyleRule):
(WebCore::CSSParser::createFontFaceRule):
(WebCore::CSSParser::createPageRule):
(WebCore::CSSParser::createKeyframeRule):
* css/CSSParser.h:
(CSSParser):
* css/CSSStyleRule.cpp:
(WebCore::CSSStyleRule::addSubresourceStyleURLs):
* css/StylePropertySet.cpp:
(WebCore::PropertySetCSSStyleDeclaration::contextStyleSheet):
(WebCore::PropertySetCSSStyleDeclaration::setNeedsStyleRecalc):
(RuleCSSStyleDeclaration):
(InlineCSSStyleDeclaration):
(WebCore):
(WebCore::StylePropertySet::StylePropertySet):
(WebCore::StylePropertySet::setProperty):
(WebCore::StylePropertySet::parseDeclaration):
(WebCore::StylePropertySet::addSubresourceStyleURLs):
(WebCore::StylePropertySet::clearParentRule):
(WebCore::StylePropertySet::clearParentElement):
(WebCore::PropertySetCSSStyleDeclaration::setCssText):
(WebCore::PropertySetCSSStyleDeclaration::setProperty):
(WebCore::PropertySetCSSStyleDeclaration::setPropertyInternal):
(WebCore::PropertySetCSSStyleDeclaration::parentStyleSheet):
(WebCore::RuleCSSStyleDeclaration::setNeedsStyleRecalc):
(WebCore::RuleCSSStyleDeclaration::contextStyleSheet):
(WebCore::InlineCSSStyleDeclaration::contextStyleSheet):
(SameSizeAsStylePropertySet):
* css/StylePropertySet.h:
(WebCore::StylePropertySet::create):
(StylePropertySet):
* css/WebKitCSSMatrix.cpp:
(WebCore::WebKitCSSMatrix::setMatrixValue):
* dom/ElementAttributeData.cpp:
(WebCore::ElementAttributeData::ensureInlineStyleDecl):
* dom/StyledElement.cpp:
(WebCore):
(WebCore::StyledElement::parseAttribute):
(WebCore::StyledElement::setInlineStyleProperty):
(WebCore::StyledElement::addSubresourceAttributeURLs):
(WebCore::StyledElement::updateAttributeStyle):
* dom/StyledElement.h:
(StyledElement):
(WebCore::StyledElement::applyPresentationAttributeToStyle):
(WebCore):
* html/HTMLBRElement.cpp:
(WebCore::HTMLBRElement::collectStyleForAttribute):
* html/HTMLBodyElement.cpp:
(WebCore::HTMLBodyElement::collectStyleForAttribute):
* html/HTMLDivElement.cpp:
(WebCore::HTMLDivElement::collectStyleForAttribute):
* html/HTMLElement.cpp:
(WebCore::HTMLElement::applyBorderAttributeToStyle):
(WebCore::HTMLElement::mapLanguageAttributeToLocale):
(WebCore::HTMLElement::collectStyleForAttribute):
(WebCore::HTMLElement::applyAlignmentAttributeToStyle):
(WebCore::HTMLElement::addHTMLLengthToStyle):
(WebCore::HTMLElement::addHTMLColorToStyle):
* html/HTMLElement.h:
(HTMLElement):
* html/HTMLFontElement.cpp:
(WebCore::HTMLFontElement::collectStyleForAttribute):
* html/HTMLHRElement.cpp:
(WebCore::HTMLHRElement::collectStyleForAttribute):
* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::collectStyleForAttribute):
* html/HTMLLIElement.cpp:
(WebCore::HTMLLIElement::collectStyleForAttribute):
* html/HTMLMarqueeElement.cpp:
(WebCore::HTMLMarqueeElement::collectStyleForAttribute):
* html/HTMLOListElement.cpp:
(WebCore::HTMLOListElement::collectStyleForAttribute):
* html/HTMLParagraphElement.cpp:
(WebCore::HTMLParagraphElement::collectStyleForAttribute):
* html/HTMLTableCaptionElement.cpp:
(WebCore::HTMLTableCaptionElement::collectStyleForAttribute):
* html/HTMLTableCellElement.cpp:
(WebCore::HTMLTableCellElement::collectStyleForAttribute):
* html/HTMLTableElement.cpp:
(WebCore::HTMLTableElement::collectStyleForAttribute):
* html/HTMLTablePartElement.cpp:
(WebCore::HTMLTablePartElement::collectStyleForAttribute):
* html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::collectStyleForAttribute):
* html/HTMLUListElement.cpp:
(WebCore::HTMLUListElement::collectStyleForAttribute):
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::setFont):
* mathml/MathMLElement.cpp:
(WebCore::MathMLElement::collectStyleForAttribute):
* svg/SVGFontFaceElement.cpp:
(WebCore::SVGFontFaceElement::insertedIntoDocument):
(WebCore::SVGFontFaceElement::removedFromDocument):
(WebCore::SVGFontFaceElement::removeFromMappedElementSheet):
* svg/SVGImageElement.cpp:
(WebCore::SVGImageElement::collectStyleForAttribute):
* svg/SVGStyledElement.cpp:
(WebCore::SVGStyledElement::collectStyleForAttribute):
* svg/SVGTextContentElement.cpp:
(WebCore::SVGTextContentElement::collectStyleForAttribute):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@108345 268f45cc-cd09-0410-ab3c-d52691b4dbfc

35 files changed:
Source/WebCore/ChangeLog
Source/WebCore/css/CSSFontFaceRule.cpp
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSParser.h
Source/WebCore/css/CSSStyleRule.cpp
Source/WebCore/css/StylePropertySet.cpp
Source/WebCore/css/StylePropertySet.h
Source/WebCore/css/WebKitCSSMatrix.cpp
Source/WebCore/dom/ElementAttributeData.cpp
Source/WebCore/dom/StyledElement.cpp
Source/WebCore/dom/StyledElement.h
Source/WebCore/html/HTMLBRElement.cpp
Source/WebCore/html/HTMLBodyElement.cpp
Source/WebCore/html/HTMLDivElement.cpp
Source/WebCore/html/HTMLElement.cpp
Source/WebCore/html/HTMLElement.h
Source/WebCore/html/HTMLFontElement.cpp
Source/WebCore/html/HTMLHRElement.cpp
Source/WebCore/html/HTMLImageElement.cpp
Source/WebCore/html/HTMLLIElement.cpp
Source/WebCore/html/HTMLMarqueeElement.cpp
Source/WebCore/html/HTMLOListElement.cpp
Source/WebCore/html/HTMLParagraphElement.cpp
Source/WebCore/html/HTMLTableCaptionElement.cpp
Source/WebCore/html/HTMLTableCellElement.cpp
Source/WebCore/html/HTMLTableElement.cpp
Source/WebCore/html/HTMLTablePartElement.cpp
Source/WebCore/html/HTMLTextAreaElement.cpp
Source/WebCore/html/HTMLUListElement.cpp
Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
Source/WebCore/mathml/MathMLElement.cpp
Source/WebCore/svg/SVGFontFaceElement.cpp
Source/WebCore/svg/SVGImageElement.cpp
Source/WebCore/svg/SVGStyledElement.cpp
Source/WebCore/svg/SVGTextContentElement.cpp

index 7501d4a..07d42df 100644 (file)
@@ -1,3 +1,126 @@
+2012-02-21  Antti Koivisto  <antti@apple.com>
+
+        Remove stylesheet pointer from StylePropertySet
+        https://bugs.webkit.org/show_bug.cgi?id=79092
+
+        Reviewed by Andreas Kling.
+
+        The context should be passed as an argument for CSS parser invoking setters that actually need it.
+        
+        - Remove the context stylesheet pointer.
+        - Add context stylesheet argument to setters.
+        - Drop an unnecessary StylePropertySet constructor, pass strict parsing flag directly.
+        - Adapt to changes by passing in the context stylesheet where needed.
+        - Add StyledElement::applyPresentationAttributeToStyle helpers for building up the attribute style.
+
+        * css/CSSFontFaceRule.cpp:
+        (WebCore::CSSFontFaceRule::addSubresourceStyleURLs):
+        * css/CSSParser.cpp:
+        (WebCore::parseColorValue):
+        (WebCore::parseSimpleLengthValue):
+        (WebCore::CSSParser::parseValue):
+        (WebCore::CSSParser::parseDeclaration):
+        (WebCore::CSSParser::createStyleRule):
+        (WebCore::CSSParser::createFontFaceRule):
+        (WebCore::CSSParser::createPageRule):
+        (WebCore::CSSParser::createKeyframeRule):
+        * css/CSSParser.h:
+        (CSSParser):
+        * css/CSSStyleRule.cpp:
+        (WebCore::CSSStyleRule::addSubresourceStyleURLs):
+        * css/StylePropertySet.cpp:
+        (WebCore::PropertySetCSSStyleDeclaration::contextStyleSheet):
+        (WebCore::PropertySetCSSStyleDeclaration::setNeedsStyleRecalc):
+        (RuleCSSStyleDeclaration):
+        (InlineCSSStyleDeclaration):
+        (WebCore):
+        (WebCore::StylePropertySet::StylePropertySet):
+        (WebCore::StylePropertySet::setProperty):
+        (WebCore::StylePropertySet::parseDeclaration):
+        (WebCore::StylePropertySet::addSubresourceStyleURLs):
+        (WebCore::StylePropertySet::clearParentRule):
+        (WebCore::StylePropertySet::clearParentElement):
+        (WebCore::PropertySetCSSStyleDeclaration::setCssText):
+        (WebCore::PropertySetCSSStyleDeclaration::setProperty):
+        (WebCore::PropertySetCSSStyleDeclaration::setPropertyInternal):
+        (WebCore::PropertySetCSSStyleDeclaration::parentStyleSheet):
+        (WebCore::RuleCSSStyleDeclaration::setNeedsStyleRecalc):
+        (WebCore::RuleCSSStyleDeclaration::contextStyleSheet):
+        (WebCore::InlineCSSStyleDeclaration::contextStyleSheet):
+        (SameSizeAsStylePropertySet):
+        * css/StylePropertySet.h:
+        (WebCore::StylePropertySet::create):
+        (StylePropertySet):
+        * css/WebKitCSSMatrix.cpp:
+        (WebCore::WebKitCSSMatrix::setMatrixValue):
+        * dom/ElementAttributeData.cpp:
+        (WebCore::ElementAttributeData::ensureInlineStyleDecl):
+        * dom/StyledElement.cpp:
+        (WebCore):
+        (WebCore::StyledElement::parseAttribute):
+        (WebCore::StyledElement::setInlineStyleProperty):
+        (WebCore::StyledElement::addSubresourceAttributeURLs):
+        (WebCore::StyledElement::updateAttributeStyle):
+        * dom/StyledElement.h:
+        (StyledElement):
+        (WebCore::StyledElement::applyPresentationAttributeToStyle):
+        (WebCore):
+        * html/HTMLBRElement.cpp:
+        (WebCore::HTMLBRElement::collectStyleForAttribute):
+        * html/HTMLBodyElement.cpp:
+        (WebCore::HTMLBodyElement::collectStyleForAttribute):
+        * html/HTMLDivElement.cpp:
+        (WebCore::HTMLDivElement::collectStyleForAttribute):
+        * html/HTMLElement.cpp:
+        (WebCore::HTMLElement::applyBorderAttributeToStyle):
+        (WebCore::HTMLElement::mapLanguageAttributeToLocale):
+        (WebCore::HTMLElement::collectStyleForAttribute):
+        (WebCore::HTMLElement::applyAlignmentAttributeToStyle):
+        (WebCore::HTMLElement::addHTMLLengthToStyle):
+        (WebCore::HTMLElement::addHTMLColorToStyle):
+        * html/HTMLElement.h:
+        (HTMLElement):
+        * html/HTMLFontElement.cpp:
+        (WebCore::HTMLFontElement::collectStyleForAttribute):
+        * html/HTMLHRElement.cpp:
+        (WebCore::HTMLHRElement::collectStyleForAttribute):
+        * html/HTMLImageElement.cpp:
+        (WebCore::HTMLImageElement::collectStyleForAttribute):
+        * html/HTMLLIElement.cpp:
+        (WebCore::HTMLLIElement::collectStyleForAttribute):
+        * html/HTMLMarqueeElement.cpp:
+        (WebCore::HTMLMarqueeElement::collectStyleForAttribute):
+        * html/HTMLOListElement.cpp:
+        (WebCore::HTMLOListElement::collectStyleForAttribute):
+        * html/HTMLParagraphElement.cpp:
+        (WebCore::HTMLParagraphElement::collectStyleForAttribute):
+        * html/HTMLTableCaptionElement.cpp:
+        (WebCore::HTMLTableCaptionElement::collectStyleForAttribute):
+        * html/HTMLTableCellElement.cpp:
+        (WebCore::HTMLTableCellElement::collectStyleForAttribute):
+        * html/HTMLTableElement.cpp:
+        (WebCore::HTMLTableElement::collectStyleForAttribute):
+        * html/HTMLTablePartElement.cpp:
+        (WebCore::HTMLTablePartElement::collectStyleForAttribute):
+        * html/HTMLTextAreaElement.cpp:
+        (WebCore::HTMLTextAreaElement::collectStyleForAttribute):
+        * html/HTMLUListElement.cpp:
+        (WebCore::HTMLUListElement::collectStyleForAttribute):
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::setFont):
+        * mathml/MathMLElement.cpp:
+        (WebCore::MathMLElement::collectStyleForAttribute):
+        * svg/SVGFontFaceElement.cpp:
+        (WebCore::SVGFontFaceElement::insertedIntoDocument):
+        (WebCore::SVGFontFaceElement::removedFromDocument):
+        (WebCore::SVGFontFaceElement::removeFromMappedElementSheet):
+        * svg/SVGImageElement.cpp:
+        (WebCore::SVGImageElement::collectStyleForAttribute):
+        * svg/SVGStyledElement.cpp:
+        (WebCore::SVGStyledElement::collectStyleForAttribute):
+        * svg/SVGTextContentElement.cpp:
+        (WebCore::SVGTextContentElement::collectStyleForAttribute):
+
 2012-02-21  Yury Semikhatsky  <yurys@chromium.org>
 
         [V8] Web Inspector: set breakpoint/pause doesn't work when worker is in a tight loop
index 54aa2b4..0972a4b 100644 (file)
@@ -49,7 +49,7 @@ String CSSFontFaceRule::cssText() const
 void CSSFontFaceRule::addSubresourceStyleURLs(ListHashSet<KURL>& urls)
 {
     if (m_style)
-        m_style->addSubresourceStyleURLs(urls);
+        m_style->addSubresourceStyleURLs(urls, parentStyleSheet());
 }
 
 } // namespace WebCore
index c2577c0..4e2eca4 100644 (file)
@@ -326,7 +326,7 @@ static inline bool isColorPropertyID(int propertyId)
     }
 }
 
-static bool parseColorValue(StylePropertySet* declaration, int propertyId, const String& string, bool important, bool strict, CSSStyleSheet* contextStyleSheet = 0)
+static bool parseColorValue(StylePropertySet* declaration, int propertyId, const String& string, bool important, bool strict, CSSStyleSheet* contextStyleSheet)
 {
     if (!string.length())
         return false;
@@ -346,22 +346,17 @@ static bool parseColorValue(StylePropertySet* declaration, int propertyId, const
         validPrimitive = true;
     }
 
-    CSSStyleSheet* styleSheet = contextStyleSheet ? contextStyleSheet : declaration->contextStyleSheet();
-    if (!styleSheet)
-        return false;
-    Document* document = styleSheet->findDocument();
-    if (!document)
-        return false;
+    Document* document = contextStyleSheet->findDocument();
     if (validPrimitive) {
-        CSSProperty property(propertyId, document->cssValuePool()->createIdentifierValue(valueID), important);
-        declaration->addParsedProperty(property);
+        RefPtr<CSSValue> value = document ? document->cssValuePool()->createIdentifierValue(valueID) : CSSPrimitiveValue::createIdentifier(valueID);
+        declaration->addParsedProperty(CSSProperty(propertyId, value.release(), important));
         return true;
     }
     RGBA32 color;
     if (!CSSParser::fastParseColor(color, string, strict && string[0] != '#'))
         return false;
-    CSSProperty property(propertyId, document->cssValuePool()->createColorValue(color), important);
-    declaration->addParsedProperty(property);
+    RefPtr<CSSValue> value = document ? document->cssValuePool()->createColorValue(color) : CSSPrimitiveValue::createColor(color);
+    declaration->addParsedProperty(CSSProperty(propertyId, value.release(), important));
     return true;
 }
 
@@ -409,7 +404,7 @@ static inline bool isSimpleLengthPropertyID(int propertyId, bool& acceptsNegativ
     }
 }
 
-static bool parseSimpleLengthValue(StylePropertySet* declaration, int propertyId, const String& string, bool important, bool strict)
+static bool parseSimpleLengthValue(StylePropertySet* declaration, int propertyId, const String& string, bool important, bool strict, CSSStyleSheet* contextStyleSheet)
 {
     bool acceptsNegativeNumbers;
     unsigned length = string.length();
@@ -473,33 +468,25 @@ static bool parseSimpleLengthValue(StylePropertySet* declaration, int propertyId
     if (number < 0 && !acceptsNegativeNumbers)
         return false;
 
-    CSSStyleSheet* styleSheet = declaration->contextStyleSheet();
-    if (!styleSheet)
-        return false;
-    Document* document = styleSheet->findDocument();
-    if (!document)
-        return false;
-    CSSProperty property(propertyId, document->cssValuePool()->createValue(number, unit), important);
-    declaration->addParsedProperty(property);
+    Document* document = contextStyleSheet->findDocument();
+    RefPtr<CSSValue> value = document ? document->cssValuePool()->createValue(number, unit) : CSSPrimitiveValue::create(number, unit);
+    declaration->addParsedProperty(CSSProperty(propertyId, value.release(), important));
     return true;
 }
 
-bool CSSParser::parseValue(StylePropertySet* declaration, int propertyId, const String& string, bool important, bool strict)
+bool CSSParser::parseValue(StylePropertySet* declaration, int propertyId, const String& string, bool important, bool strict, CSSStyleSheet* contextStyleSheet)
 {
-    if (parseSimpleLengthValue(declaration, propertyId, string, important, strict))
+    if (parseSimpleLengthValue(declaration, propertyId, string, important, strict, contextStyleSheet))
         return true;
-    if (parseColorValue(declaration, propertyId, string, important, strict))
+    if (parseColorValue(declaration, propertyId, string, important, strict, contextStyleSheet))
         return true;
     CSSParser parser(strict);
-    return parser.parseValue(declaration, propertyId, string, important);
+    return parser.parseValue(declaration, propertyId, string, important, contextStyleSheet);
 }
 
 bool CSSParser::parseValue(StylePropertySet* declaration, int propertyId, const String& string, bool important, CSSStyleSheet* contextStyleSheet)
 {
-    if (contextStyleSheet)
-        setStyleSheet(contextStyleSheet);
-    else
-        setStyleSheet(declaration->contextStyleSheet());
+    setStyleSheet(contextStyleSheet);
 
     setupParser("@-webkit-value{", string, "} ");
 
@@ -599,10 +586,8 @@ bool CSSParser::parseDeclaration(StylePropertySet* declaration, const String& st
     // Length of the "@-webkit-decls{" prefix.
     static const unsigned prefixLength = 15;
 
-    if (contextStyleSheet)
-        setStyleSheet(contextStyleSheet);
-    else
-        setStyleSheet(declaration->contextStyleSheet());
+    setStyleSheet(contextStyleSheet);
+
     if (styleSourceData) {
         m_currentRuleData = CSSRuleSourceData::create();
         m_currentRuleData->styleSourceData = CSSStyleSourceData::create();
@@ -8821,7 +8806,7 @@ CSSRule* CSSParser::createStyleRule(Vector<OwnPtr<CSSParserSelector> >* selector
         rule->adoptSelectorVector(*selectors);
         if (m_hasFontFaceOnlyValues)
             deleteFontFaceOnlyValues();
-        rule->setDeclaration(StylePropertySet::create(m_styleSheet, m_parsedProperties, m_numParsedProperties));
+        rule->setDeclaration(StylePropertySet::create(m_parsedProperties, m_numParsedProperties, m_strict));
         result = rule.get();
         m_parsedRules.append(rule.release());
         if (m_ruleRangeMap) {
@@ -8860,7 +8845,7 @@ CSSRule* CSSParser::createFontFaceRule()
         }
     }
     RefPtr<CSSFontFaceRule> rule = CSSFontFaceRule::create(m_styleSheet);
-    rule->setDeclaration(StylePropertySet::create(m_styleSheet, m_parsedProperties, m_numParsedProperties));
+    rule->setDeclaration(StylePropertySet::create(m_parsedProperties, m_numParsedProperties, m_strict));
     clearProperties();
     CSSFontFaceRule* result = rule.get();
     m_parsedRules.append(rule.release());
@@ -8931,7 +8916,7 @@ CSSRule* CSSParser::createPageRule(PassOwnPtr<CSSParserSelector> pageSelector)
         Vector<OwnPtr<CSSParserSelector> > selectorVector;
         selectorVector.append(pageSelector);
         rule->adoptSelectorVector(selectorVector);
-        rule->setDeclaration(StylePropertySet::create(m_styleSheet, m_parsedProperties, m_numParsedProperties));
+        rule->setDeclaration(StylePropertySet::create(m_parsedProperties, m_numParsedProperties, m_strict));
         pageRule = rule.get();
         m_parsedRules.append(rule.release());
     }
@@ -9015,7 +9000,7 @@ WebKitCSSKeyframeRule* CSSParser::createKeyframeRule(CSSParserValueList* keys)
 
     RefPtr<WebKitCSSKeyframeRule> keyframe = WebKitCSSKeyframeRule::create(m_styleSheet);
     keyframe->setKeyText(keyString);
-    keyframe->setDeclaration(StylePropertySet::create(m_styleSheet, m_parsedProperties, m_numParsedProperties));
+    keyframe->setDeclaration(StylePropertySet::create(m_parsedProperties, m_numParsedProperties, m_strict));
 
     clearProperties();
 
index 87d52f5..a1350e9 100644 (file)
@@ -69,11 +69,11 @@ public:
     void parseSheet(CSSStyleSheet*, const String&, int startLineNumber = 0, StyleRuleRangeMap* ruleRangeMap = 0);
     PassRefPtr<CSSRule> parseRule(CSSStyleSheet*, const String&);
     PassRefPtr<WebKitCSSKeyframeRule> parseKeyframeRule(CSSStyleSheet*, const String&);
-    static bool parseValue(StylePropertySet*, int propId, const String&, bool important, bool strict);
+    static bool parseValue(StylePropertySet*, int propId, const String&, bool important, bool strict, CSSStyleSheet* contextStyleSheet);
     static bool parseColor(RGBA32& color, const String&, bool strict = false);
     static bool parseSystemColor(RGBA32& color, const String&, Document*);
     PassRefPtr<CSSPrimitiveValue> parseValidPrimitive(int propId, CSSParserValue*);
-    bool parseDeclaration(StylePropertySet*, const String&, RefPtr<CSSStyleSourceData>* = 0, CSSStyleSheet* contextStyleSheet = 0);
+    bool parseDeclaration(StylePropertySet*, const String&, RefPtr<CSSStyleSourceData>*, CSSStyleSheet* contextStyleSheet);
     bool parseMediaQuery(MediaList*, const String&);
 
     Document* findDocument() const;
@@ -355,7 +355,7 @@ private:
     bool isGeneratedImageValue(CSSParserValue*) const;
     bool parseGeneratedImage(CSSParserValueList*, RefPtr<CSSValue>&);
 
-    bool parseValue(StylePropertySet*, int propId, const String&, bool important, CSSStyleSheet* contextStyleSheet = 0);
+    bool parseValue(StylePropertySet*, int propId, const String&, bool important, CSSStyleSheet* contextStyleSheet);
 
     enum SizeParameterType {
         None,
index fc4ba7e..7a1d66f 100644 (file)
@@ -133,7 +133,7 @@ String CSSStyleRule::cssText() const
 void CSSStyleRule::addSubresourceStyleURLs(ListHashSet<KURL>& urls)
 {
     if (m_style)
-        m_style->addSubresourceStyleURLs(urls);
+        m_style->addSubresourceStyleURLs(urls, parentStyleSheet());
 }
 
 } // namespace WebCore
index d2d540d..a74c5c0 100644 (file)
@@ -60,6 +60,7 @@ public:
     virtual StyledElement* parentElement() const { return 0; }
     virtual void clearParentRule() { ASSERT_NOT_REACHED(); }
     virtual void clearParentElement() { ASSERT_NOT_REACHED(); }
+    virtual CSSStyleSheet* contextStyleSheet() const { return 0; }
 
 private:
     virtual void ref() OVERRIDE { m_propertySet->ref(); }
@@ -85,7 +86,7 @@ private:
     virtual CSSStyleSheet* parentStyleSheet() const OVERRIDE;
     virtual PassRefPtr<StylePropertySet> copy() const OVERRIDE;
     virtual PassRefPtr<StylePropertySet> makeMutable() OVERRIDE;
-    virtual void setNeedsStyleRecalc() { };
+    virtual void setNeedsStyleRecalc() { }    
 
 protected:
     StylePropertySet* m_propertySet;
@@ -104,6 +105,7 @@ private:
     virtual CSSRule* parentRule() const { return m_parentRule; };
     virtual void clearParentRule() { m_parentRule = 0; }
     virtual void setNeedsStyleRecalc();
+    virtual CSSStyleSheet* contextStyleSheet() const;
     
     CSSRule* m_parentRule;
 };
@@ -121,6 +123,7 @@ private:
     virtual StyledElement* parentElement() const { return m_parentElement; }
     virtual void clearParentElement() { m_parentElement = 0; }
     virtual void setNeedsStyleRecalc();
+    virtual CSSStyleSheet* contextStyleSheet() const;
 
     StyledElement* m_parentElement;
 };
@@ -213,7 +216,6 @@ bool StyleAttributeMutationScope::s_shouldDeliver = false;
 StylePropertySet::StylePropertySet()
     : m_strictParsing(false)
     , m_hasCSSOMWrapper(false)
-    , m_contextStyleSheet(0)
 {
 }
 
@@ -221,22 +223,13 @@ StylePropertySet::StylePropertySet(const Vector<CSSProperty>& properties)
     : m_properties(properties)
     , m_strictParsing(true)
     , m_hasCSSOMWrapper(false)
-    , m_contextStyleSheet(0)
 {
     m_properties.shrinkToFit();
 }
 
-StylePropertySet::StylePropertySet(CSSStyleSheet* contextStyleSheet)
-    : m_strictParsing(!contextStyleSheet || contextStyleSheet->useStrictParsing())
+StylePropertySet::StylePropertySet(const CSSProperty* const * properties, int numProperties, bool useStrictParsing)
+    : m_strictParsing(useStrictParsing)
     , m_hasCSSOMWrapper(false)
-    , m_contextStyleSheet(contextStyleSheet)
-{
-}
-
-StylePropertySet::StylePropertySet(CSSStyleSheet* contextStyleSheet, const CSSProperty* const * properties, int numProperties)
-    : m_strictParsing(!contextStyleSheet || contextStyleSheet->useStrictParsing())
-    , m_hasCSSOMWrapper(false)
-    , m_contextStyleSheet(contextStyleSheet)
 {
     m_properties.reserveInitialCapacity(numProperties);
     HashMap<int, bool> candidates;
@@ -745,7 +738,7 @@ bool StylePropertySet::isPropertyImplicit(int propertyID) const
     return property ? property->isImplicit() : false;
 }
 
-bool StylePropertySet::setProperty(int propertyID, const String& value, bool important)
+bool StylePropertySet::setProperty(int propertyID, const String& value, bool important, CSSStyleSheet* contextStyleSheet)
 {
     // Setting the value to an empty string just removes the property in both IE and Gecko.
     // Setting it to null seems to produce less consistent results, but we treat it just the same.
@@ -756,7 +749,7 @@ bool StylePropertySet::setProperty(int propertyID, const String& value, bool imp
 
     // When replacing an existing property value, this moves the property to the end of the list.
     // Firefox preserves the position, and MSIE moves the property to the beginning.
-    return CSSParser::parseValue(this, propertyID, value, important, useStrictParsing());
+    return CSSParser::parseValue(this, propertyID, value, important, useStrictParsing(), contextStyleSheet);
 }
 
 void StylePropertySet::setProperty(const CSSProperty& property, CSSProperty* slot)
@@ -771,10 +764,10 @@ void StylePropertySet::setProperty(const CSSProperty& property, CSSProperty* slo
     m_properties.append(property);
 }
 
-bool StylePropertySet::setProperty(int propertyID, int identifier, bool important)
+bool StylePropertySet::setProperty(int propertyID, int identifier, bool important, CSSStyleSheet* contextStyleSheet)
 {
     RefPtr<CSSPrimitiveValue> value;    
-    if (Document* document = m_contextStyleSheet ? m_contextStyleSheet->findDocument() : 0)
+    if (Document* document = contextStyleSheet ? contextStyleSheet->findDocument() : 0)
         value = document->cssValuePool()->createIdentifierValue(identifier);
     else
         value = CSSPrimitiveValue::createIdentifier(identifier);
@@ -783,18 +776,22 @@ bool StylePropertySet::setProperty(int propertyID, int identifier, bool importan
     return true;
 }
 
-bool StylePropertySet::setProperty(int propertyID, double value, CSSPrimitiveValue::UnitTypes unit, bool important)
+bool StylePropertySet::setProperty(int propertyID, double number, CSSPrimitiveValue::UnitTypes unit, bool important, CSSStyleSheet* contextStyleSheet)
 {
-    CSSProperty property(propertyID, CSSPrimitiveValue::create(value, unit), important);
-    setProperty(property);
+    RefPtr<CSSPrimitiveValue> value;    
+    if (Document* document = contextStyleSheet ? contextStyleSheet->findDocument() : 0)
+        value = document->cssValuePool()->createValue(number, unit);
+    else
+        value = CSSPrimitiveValue::create(number, unit);
+    setProperty(CSSProperty(propertyID, value, important));
     return true;
 }
 
-void StylePropertySet::parseDeclaration(const String& styleDeclaration)
+void StylePropertySet::parseDeclaration(const String& styleDeclaration, CSSStyleSheet* contextStyleSheet)
 {
     m_properties.clear();
     CSSParser parser(useStrictParsing());
-    parser.parseDeclaration(this, styleDeclaration);
+    parser.parseDeclaration(this, styleDeclaration, 0, contextStyleSheet);
 }
 
 void StylePropertySet::addParsedProperties(const CSSProperty* const* properties, int numProperties)
@@ -890,12 +887,11 @@ void StylePropertySet::merge(const StylePropertySet* other, bool argOverridesOnC
     }
 }
 
-void StylePropertySet::addSubresourceStyleURLs(ListHashSet<KURL>& urls)
+void StylePropertySet::addSubresourceStyleURLs(ListHashSet<KURL>& urls, CSSStyleSheet* contextStyleSheet)
 {
-    CSSStyleSheet* sheet = contextStyleSheet();
     size_t size = m_properties.size();
     for (size_t i = 0; i < size; ++i)
-        m_properties[i].value()->addSubresourceStyleURLs(urls, sheet);
+        m_properties[i].value()->addSubresourceStyleURLs(urls, contextStyleSheet);
 }
 
 // This is the list of properties we want to copy in the copyBlockProperties() function.
@@ -1073,7 +1069,6 @@ CSSStyleDeclaration* StylePropertySet::ensureInlineCSSStyleDeclaration(const Sty
 
 void StylePropertySet::clearParentRule(CSSRule* rule)
 {
-    m_contextStyleSheet = 0;
     if (!m_hasCSSOMWrapper)
         return;
     ASSERT_UNUSED(rule, static_cast<CSSStyleDeclaration*>(propertySetCSSOMWrapperMap().get(this))->parentRule() == rule);
@@ -1082,7 +1077,6 @@ void StylePropertySet::clearParentRule(CSSRule* rule)
 
 void StylePropertySet::clearParentElement(StyledElement* element)
 {
-    m_contextStyleSheet = 0;
     if (!m_hasCSSOMWrapper)
         return;
     ASSERT_UNUSED(element, propertySetCSSOMWrapperMap().get(this)->parentElement() == element);
@@ -1113,7 +1107,7 @@ void PropertySetCSSStyleDeclaration::setCssText(const String& text, ExceptionCod
 #endif
     ec = 0;
     // FIXME: Detect syntax errors and set ec.
-    m_propertySet->parseDeclaration(text);
+    m_propertySet->parseDeclaration(text, contextStyleSheet());
 
     setNeedsStyleRecalc();
 #if ENABLE(MUTATION_OBSERVERS)
@@ -1174,7 +1168,7 @@ void PropertySetCSSStyleDeclaration::setProperty(const String& propertyName, con
         return;
     bool important = priority.find("important", 0, false) != notFound;
     ec = 0;
-    bool changed = m_propertySet->setProperty(propertyID, value, important);
+    bool changed = m_propertySet->setProperty(propertyID, value, important, contextStyleSheet());
     if (changed) {
         // CSS DOM requires raising SYNTAX_ERR of parsing failed, but this is too dangerous for compatibility,
         // see <http://bugs.webkit.org/show_bug.cgi?id=7296>.
@@ -1221,7 +1215,7 @@ void PropertySetCSSStyleDeclaration::setPropertyInternal(CSSPropertyID propertyI
     StyleAttributeMutationScope mutationScope(this);
 #endif
     ec = 0;
-    bool changed = m_propertySet->setProperty(propertyID, value, important);
+    bool changed = m_propertySet->setProperty(propertyID, value, important, contextStyleSheet());
     if (changed) {
         setNeedsStyleRecalc();
 #if ENABLE(MUTATION_OBSERVERS)
@@ -1232,7 +1226,7 @@ void PropertySetCSSStyleDeclaration::setPropertyInternal(CSSPropertyID propertyI
 
 CSSStyleSheet* PropertySetCSSStyleDeclaration::parentStyleSheet() const
 { 
-    return m_propertySet->contextStyleSheet(); 
+    return contextStyleSheet(); 
 }
 
 PassRefPtr<StylePropertySet> PropertySetCSSStyleDeclaration::copy() const
@@ -1252,11 +1246,16 @@ bool PropertySetCSSStyleDeclaration::cssPropertyMatches(const CSSProperty* prope
 
 void RuleCSSStyleDeclaration::setNeedsStyleRecalc()
 {
-    if (CSSStyleSheet* styleSheet = m_propertySet->contextStyleSheet()) {
+    if (CSSStyleSheet* styleSheet = contextStyleSheet()) {
         if (Document* document = styleSheet->findDocument())
             document->styleSelectorChanged(DeferRecalcStyle);
     }
 }
+    
+CSSStyleSheet* RuleCSSStyleDeclaration::contextStyleSheet() const
+{
+    return m_parentRule ? m_parentRule->parentStyleSheet() : 0;
+}
 
 void InlineCSSStyleDeclaration::setNeedsStyleRecalc()
 {
@@ -1268,10 +1267,14 @@ void InlineCSSStyleDeclaration::setNeedsStyleRecalc()
     return;
 }
 
+CSSStyleSheet* InlineCSSStyleDeclaration::contextStyleSheet() const
+{
+    return m_parentElement ? m_parentElement->document()->elementSheet() : 0;
+}
+
 class SameSizeAsStylePropertySet : public RefCounted<SameSizeAsStylePropertySet> {
     Vector<CSSProperty, 4> properties;
     unsigned bitfield;
-    void* parent;
 };
 COMPILE_ASSERT(sizeof(StylePropertySet) == sizeof(SameSizeAsStylePropertySet), style_property_set_should_stay_small);
 
index 96db5d2..68ed6fa 100644 (file)
@@ -42,13 +42,9 @@ public:
     {
         return adoptRef(new StylePropertySet);
     }
-    static PassRefPtr<StylePropertySet> create(CSSStyleSheet* contextStyleSheet)
+    static PassRefPtr<StylePropertySet> create(const CSSProperty* const* properties, int numProperties, bool useStrictParsing)
     {
-        return adoptRef(new StylePropertySet(contextStyleSheet));
-    }
-    static PassRefPtr<StylePropertySet> create(CSSStyleSheet* contextStyleSheet, const CSSProperty* const* properties, int numProperties)
-    {
-        return adoptRef(new StylePropertySet(contextStyleSheet, properties, numProperties));
+        return adoptRef(new StylePropertySet(properties, numProperties, useStrictParsing));
     }
     static PassRefPtr<StylePropertySet> create(const Vector<CSSProperty>& properties)
     {
@@ -65,15 +61,15 @@ public:
     int getPropertyShorthand(int propertyID) const;
     bool isPropertyImplicit(int propertyID) const;
 
-    bool setProperty(int propertyID, int value, bool important = false);
-    bool setProperty(int propertyId, double value, CSSPrimitiveValue::UnitTypes unit, bool important = false);
-    bool setProperty(int propertyID, const String& value, bool important = false);
+    bool setProperty(int propertyID, int value, bool important = false, CSSStyleSheet* contextStyleSheet = 0);
+    bool setProperty(int propertyId, double value, CSSPrimitiveValue::UnitTypes, bool important = false, CSSStyleSheet* contextStyleSheet = 0);
+    bool setProperty(int propertyID, const String& value, bool important = false, CSSStyleSheet* contextStyleSheet = 0);
     void setProperty(const CSSProperty&, CSSProperty* slot = 0);
     
     bool removeProperty(int propertyID, String* returnText = 0);
 
     // The following parses an entire new style declaration.
-    void parseDeclaration(const String& styleDeclaration);
+    void parseDeclaration(const String& styleDeclaration, CSSStyleSheet* contextStyleSheet);
 
     // Besides adding the properties, this also removes any existing properties with these IDs.
     // It does no notification since it's called by the parser.
@@ -90,7 +86,7 @@ public:
     void setStrictParsing(bool b) { m_strictParsing = b; }
     bool useStrictParsing() const { return m_strictParsing; }
 
-    void addSubresourceStyleURLs(ListHashSet<KURL>&);
+    void addSubresourceStyleURLs(ListHashSet<KURL>&, CSSStyleSheet* contextStyleSheet);
 
     PassRefPtr<StylePropertySet> copy() const;
     // Used by StyledElement::copyNonAttributeProperties().
@@ -100,9 +96,6 @@ public:
     void removeEquivalentProperties(const CSSStyleDeclaration*);
 
     PassRefPtr<StylePropertySet> copyPropertiesInSet(const int* set, unsigned length) const;
-
-    CSSStyleSheet* contextStyleSheet() const { return m_contextStyleSheet; }
-    void setContextStyleSheet(CSSStyleSheet* styleSheet) { m_contextStyleSheet = styleSheet; }
     
     String asText() const;
     
@@ -116,8 +109,7 @@ public:
 private:
     StylePropertySet();
     StylePropertySet(const Vector<CSSProperty>&);
-    StylePropertySet(CSSStyleSheet* parentStyleSheet);
-    StylePropertySet(CSSStyleSheet* parentStyleSheet, const CSSProperty* const *, int numProperties);
+    StylePropertySet(const CSSProperty* const *, int numProperties, bool useStrictParsing);
 
     void setNeedsStyleRecalc();
 
@@ -143,8 +135,6 @@ private:
 
     bool m_strictParsing : 1;
     mutable bool m_hasCSSOMWrapper : 1;
-
-    CSSStyleSheet* m_contextStyleSheet;
     
     friend class PropertySetCSSStyleDeclaration;
 };
index 86e88b2..9aeea77 100644 (file)
@@ -53,7 +53,7 @@ WebKitCSSMatrix::~WebKitCSSMatrix()
 void WebKitCSSMatrix::setMatrixValue(const String& string, ExceptionCode& ec)
 {
     RefPtr<StylePropertySet> styleDeclaration = StylePropertySet::create();
-    if (CSSParser::parseValue(styleDeclaration.get(), CSSPropertyWebkitTransform, string, true, true)) {
+    if (CSSParser::parseValue(styleDeclaration.get(), CSSPropertyWebkitTransform, string, true, true, 0)) {
         // Convert to TransformOperations. This can fail if a property
         // requires style (i.e., param uses 'ems' or 'exs')
         RefPtr<CSSValue> value = styleDeclaration->getPropertyCSSValue(CSSPropertyWebkitTransform);
index cb000a9..71457f4 100644 (file)
@@ -45,7 +45,7 @@ StylePropertySet* ElementAttributeData::ensureInlineStyleDecl(StyledElement* ele
 {
     if (!m_inlineStyleDecl) {
         ASSERT(element->isStyledElement());
-        m_inlineStyleDecl = StylePropertySet::create(element->document()->elementSheet());
+        m_inlineStyleDecl = StylePropertySet::create();
         m_inlineStyleDecl->setStrictParsing(element->isHTMLElement() && !element->document()->inQuirksMode());
     }
     return m_inlineStyleDecl.get();
index 20e2932..817ff48 100644 (file)
@@ -61,26 +61,6 @@ StyledElement::~StyledElement()
     destroyInlineStyleDecl();
 }
 
-void StyledElement::insertedIntoDocument()
-{
-    Element::insertedIntoDocument();
-
-    if (StylePropertySet* inlineStyle = inlineStyleDecl())
-        inlineStyle->setContextStyleSheet(document()->elementSheet());
-    if (StylePropertySet* attributeStyle = attributeData() ? attributeData()->attributeStyle() : 0)
-        attributeStyle->setContextStyleSheet(document()->elementSheet());
-}
-
-void StyledElement::removedFromDocument()
-{
-    Element::removedFromDocument();
-
-    if (StylePropertySet* inlineStyle = inlineStyleDecl())
-        inlineStyle->setContextStyleSheet(0);
-    if (StylePropertySet* attributeStyle = attributeData() ? attributeData()->attributeStyle() : 0)
-        attributeStyle->setContextStyleSheet(0);
-}
-
 void StyledElement::attributeChanged(Attribute* attr)
 {
     if (!(attr->name() == styleAttr && isSynchronizingStyleAttribute()))
@@ -123,7 +103,7 @@ void StyledElement::parseAttribute(Attribute* attr)
         if (attr->isNull())
             destroyInlineStyleDecl();
         else if (document()->contentSecurityPolicy()->allowInlineStyle())
-            ensureInlineStyleDecl()->parseDeclaration(attr->value());
+            ensureInlineStyleDecl()->parseDeclaration(attr->value(), document()->elementSheet());
         setIsStyleAttributeValid();
         setNeedsStyleRecalc();
         InspectorInstrumentation::didInvalidateStyleAttr(document(), this);
@@ -139,7 +119,7 @@ void StyledElement::inlineStyleChanged()
     
 bool StyledElement::setInlineStyleProperty(int propertyID, int value, bool important)
 {
-    bool changes = ensureInlineStyleDecl()->setProperty(propertyID, value, important);
+    bool changes = ensureInlineStyleDecl()->setProperty(propertyID, value, important, document()->elementSheet());
     if (changes)
         inlineStyleChanged();
     return changes;
@@ -147,7 +127,7 @@ bool StyledElement::setInlineStyleProperty(int propertyID, int value, bool impor
 
 bool StyledElement::setInlineStyleProperty(int propertyID, double value, CSSPrimitiveValue::UnitTypes unit, bool important)
 {
-    bool changes = ensureInlineStyleDecl()->setProperty(propertyID, value, unit, important);
+    bool changes = ensureInlineStyleDecl()->setProperty(propertyID, value, unit, important, document()->elementSheet());
     if (changes)
         inlineStyleChanged();
     return changes;
@@ -155,7 +135,7 @@ bool StyledElement::setInlineStyleProperty(int propertyID, double value, CSSPrim
 
 bool StyledElement::setInlineStyleProperty(int propertyID, const String& value, bool important)
 {
-    bool changes = ensureInlineStyleDecl()->setProperty(propertyID, value, important);
+    bool changes = ensureInlineStyleDecl()->setProperty(propertyID, value, important, document()->elementSheet());
     if (changes)
         inlineStyleChanged();
     return changes;
@@ -172,12 +152,12 @@ bool StyledElement::removeInlineStyleProperty(int propertyID)
 void StyledElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
 {
     if (StylePropertySet* inlineStyle = inlineStyleDecl())
-        inlineStyle->addSubresourceStyleURLs(urls);
+        inlineStyle->addSubresourceStyleURLs(urls, document()->elementSheet());
 }
 
 void StyledElement::updateAttributeStyle()
 {
-    RefPtr<StylePropertySet> style = StylePropertySet::create(document()->elementSheet());
+    RefPtr<StylePropertySet> style = StylePropertySet::create();
     for (unsigned i = 0; i < attributeCount(); ++i) {
         Attribute* attribute = attributeItem(i);
         collectStyleForAttribute(attribute, style.get());
index 17bdf71..76d4544 100644 (file)
@@ -44,7 +44,7 @@ public:
     
     // Unlike StylePropertySet setters, these implement invalidation.
     bool setInlineStyleProperty(int propertyID, int value, bool important = false);
-    bool setInlineStyleProperty(int propertyID, double value, CSSPrimitiveValue::UnitTypes unit, bool important = false);
+    bool setInlineStyleProperty(int propertyID, double value, CSSPrimitiveValue::UnitTypes, bool important = false);
     bool setInlineStyleProperty(int propertyID, const String& value, bool important = false);
     bool removeInlineStyleProperty(int propertyID);
     
@@ -67,15 +67,16 @@ protected:
     virtual bool isPresentationAttribute(Attribute*) const { return false; }
     virtual void collectStyleForAttribute(Attribute*, StylePropertySet*) { }
 
+    void addPropertyToAttributeStyle(StylePropertySet*, int propertyID, int value);
+    void addPropertyToAttributeStyle(StylePropertySet*, int propertyID, double value, CSSPrimitiveValue::UnitTypes);
+    void addPropertyToAttributeStyle(StylePropertySet*, int propertyID, const String& value);
+
     virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
 
     // classAttributeChanged() exists to share code between
     // parseAttribute (called via setAttribute()) and
     // svgAttributeChanged (called when element.className.baseValue is set)
     void classAttributeChanged(const AtomicString& newClassString);
-    
-    virtual void insertedIntoDocument();
-    virtual void removedFromDocument();
 
 private:
     virtual void updateStyleAttribute() const;
@@ -109,6 +110,21 @@ inline StylePropertySet* StyledElement::attributeStyle()
     return attributeData() ? attributeData()->attributeStyle() : 0;
 }
 
+inline void StyledElement::addPropertyToAttributeStyle(StylePropertySet* style, int propertyID, int value)
+{
+    style->setProperty(propertyID, value, false, document()->elementSheet());
+}
+
+inline void StyledElement::addPropertyToAttributeStyle(StylePropertySet* style, int propertyID, double value, CSSPrimitiveValue::UnitTypes unit)
+{
+    style->setProperty(propertyID, value, unit, false, document()->elementSheet());
+}
+
+inline void StyledElement::addPropertyToAttributeStyle(StylePropertySet* style, int propertyID, const String& value)
+{
+    style->setProperty(propertyID, value, false, document()->elementSheet());
+}
+
 } //namespace
 
 #endif
index 051db5f..33f0c53 100644 (file)
@@ -62,9 +62,9 @@ void HTMLBRElement::collectStyleForAttribute(Attribute* attr, StylePropertySet*
         // <br clear> and <br clear=""> are just treated like <br> by Gecko, Mac IE, etc. -dwh
         if (!attr->isEmpty()) {
             if (equalIgnoringCase(attr->value(), "all"))
-                style->setProperty(CSSPropertyClear, "both");
+                addPropertyToAttributeStyle(style, CSSPropertyClear, "both");
             else
-                style->setProperty(CSSPropertyClear, attr->value());
+                addPropertyToAttributeStyle(style, CSSPropertyClear, attr->value());
         }
     } else
         HTMLElement::collectStyleForAttribute(attr, style);
index 63182cd..34d2924 100644 (file)
@@ -86,7 +86,7 @@ void HTMLBodyElement::collectStyleForAttribute(Attribute* attr, StylePropertySet
         addHTMLColorToStyle(style, CSSPropertyColor, attr->value());
     } else if (attr->name() == bgpropertiesAttr) {
         if (equalIgnoringCase(attr->value(), "fixed"))
-           style->setProperty(CSSPropertyBackgroundAttachment, CSSValueFixed);
+           addPropertyToAttributeStyle(style, CSSPropertyBackgroundAttachment, CSSValueFixed);
     } else
         HTMLElement::collectStyleForAttribute(attr, style);
 }
index e793ad0..bd15ae2 100644 (file)
@@ -59,13 +59,13 @@ void HTMLDivElement::collectStyleForAttribute(Attribute* attr, StylePropertySet*
 {
     if (attr->name() == alignAttr) {
         if (equalIgnoringCase(attr->value(), "middle") || equalIgnoringCase(attr->value(), "center"))
-            style->setProperty(CSSPropertyTextAlign, CSSValueWebkitCenter);
+            addPropertyToAttributeStyle(style, CSSPropertyTextAlign, CSSValueWebkitCenter);
         else if (equalIgnoringCase(attr->value(), "left"))
-            style->setProperty(CSSPropertyTextAlign, CSSValueWebkitLeft);
+            addPropertyToAttributeStyle(style, CSSPropertyTextAlign, CSSValueWebkitLeft);
         else if (equalIgnoringCase(attr->value(), "right"))
-            style->setProperty(CSSPropertyTextAlign, CSSValueWebkitRight);
+            addPropertyToAttributeStyle(style, CSSPropertyTextAlign, CSSValueWebkitRight);
         else
-            style->setProperty(CSSPropertyTextAlign, attr->value());
+            addPropertyToAttributeStyle(style, CSSPropertyTextAlign, attr->value());
     } else
         HTMLElement::collectStyleForAttribute(attr, style);
 }
index 7c52727..d042b81 100644 (file)
@@ -142,11 +142,11 @@ static unsigned parseBorderWidthAttribute(Attribute* attr)
 
 void HTMLElement::applyBorderAttributeToStyle(Attribute* attr, StylePropertySet* style)
 {
-    style->setProperty(CSSPropertyBorderWidth, String::number(parseBorderWidthAttribute(attr)));
-    style->setProperty(CSSPropertyBorderTopStyle, CSSValueSolid);
-    style->setProperty(CSSPropertyBorderRightStyle, CSSValueSolid);
-    style->setProperty(CSSPropertyBorderBottomStyle, CSSValueSolid);
-    style->setProperty(CSSPropertyBorderLeftStyle, CSSValueSolid);
+    addPropertyToAttributeStyle(style, CSSPropertyBorderWidth, String::number(parseBorderWidthAttribute(attr)));
+    addPropertyToAttributeStyle(style, CSSPropertyBorderTopStyle, CSSValueSolid);
+    addPropertyToAttributeStyle(style, CSSPropertyBorderRightStyle, CSSValueSolid);
+    addPropertyToAttributeStyle(style, CSSPropertyBorderBottomStyle, CSSValueSolid);
+    addPropertyToAttributeStyle(style, CSSPropertyBorderLeftStyle, CSSValueSolid);
 }
 
 void HTMLElement::mapLanguageAttributeToLocale(Attribute* attribute, StylePropertySet* style)
@@ -154,10 +154,10 @@ void HTMLElement::mapLanguageAttributeToLocale(Attribute* attribute, StyleProper
     ASSERT(attribute && (attribute->name() == langAttr || attribute->name().matches(XMLNames::langAttr)));
     if (!attribute->isEmpty()) {
         // Have to quote so the locale id is treated as a string instead of as a CSS keyword.
-        style->setProperty(CSSPropertyWebkitLocale, quoteCSSString(attribute->value()));
+        addPropertyToAttributeStyle(style, CSSPropertyWebkitLocale, quoteCSSString(attribute->value()));
     } else {
         // The empty string means the language is explicitly unknown.
-        style->setProperty(CSSPropertyWebkitLocale, CSSValueAuto);
+        addPropertyToAttributeStyle(style, CSSPropertyWebkitLocale, CSSValueAuto);
     }
 }
 
@@ -172,37 +172,37 @@ void HTMLElement::collectStyleForAttribute(Attribute* attr, StylePropertySet* st
 {
     if (attr->name() == alignAttr) {
         if (equalIgnoringCase(attr->value(), "middle"))
-            style->setProperty(CSSPropertyTextAlign, "center");
+            addPropertyToAttributeStyle(style, CSSPropertyTextAlign, "center");
         else
-            style->setProperty(CSSPropertyTextAlign, attr->value());
+            addPropertyToAttributeStyle(style, CSSPropertyTextAlign, attr->value());
     } else if (attr->name() == contenteditableAttr) {
         if (attr->isEmpty() || equalIgnoringCase(attr->value(), "true")) {
-            style->setProperty(CSSPropertyWebkitUserModify, CSSValueReadWrite);
-            style->setProperty(CSSPropertyWordWrap, CSSValueBreakWord);
-            style->setProperty(CSSPropertyWebkitNbspMode, CSSValueSpace);
-            style->setProperty(CSSPropertyWebkitLineBreak, CSSValueAfterWhiteSpace);
+            addPropertyToAttributeStyle(style, CSSPropertyWebkitUserModify, CSSValueReadWrite);
+            addPropertyToAttributeStyle(style, CSSPropertyWordWrap, CSSValueBreakWord);
+            addPropertyToAttributeStyle(style, CSSPropertyWebkitNbspMode, CSSValueSpace);
+            addPropertyToAttributeStyle(style, CSSPropertyWebkitLineBreak, CSSValueAfterWhiteSpace);
         } else if (equalIgnoringCase(attr->value(), "plaintext-only")) {
-            style->setProperty(CSSPropertyWebkitUserModify, CSSValueReadWritePlaintextOnly);
-            style->setProperty(CSSPropertyWordWrap, CSSValueBreakWord);
-            style->setProperty(CSSPropertyWebkitNbspMode, CSSValueSpace);
-            style->setProperty(CSSPropertyWebkitLineBreak, CSSValueAfterWhiteSpace);
+            addPropertyToAttributeStyle(style, CSSPropertyWebkitUserModify, CSSValueReadWritePlaintextOnly);
+            addPropertyToAttributeStyle(style, CSSPropertyWordWrap, CSSValueBreakWord);
+            addPropertyToAttributeStyle(style, CSSPropertyWebkitNbspMode, CSSValueSpace);
+            addPropertyToAttributeStyle(style, CSSPropertyWebkitLineBreak, CSSValueAfterWhiteSpace);
         } else if (equalIgnoringCase(attr->value(), "false"))
-            style->setProperty(CSSPropertyWebkitUserModify, CSSValueReadOnly);
+            addPropertyToAttributeStyle(style, CSSPropertyWebkitUserModify, CSSValueReadOnly);
     } else if (attr->name() == hiddenAttr) {
-        style->setProperty(CSSPropertyDisplay, CSSValueNone);
+        addPropertyToAttributeStyle(style, CSSPropertyDisplay, CSSValueNone);
     } else if (attr->name() == draggableAttr) {
         if (equalIgnoringCase(attr->value(), "true")) {
-            style->setProperty(CSSPropertyWebkitUserDrag, CSSValueElement);
-            style->setProperty(CSSPropertyWebkitUserSelect, CSSValueNone);
+            addPropertyToAttributeStyle(style, CSSPropertyWebkitUserDrag, CSSValueElement);
+            addPropertyToAttributeStyle(style, CSSPropertyWebkitUserSelect, CSSValueNone);
         } else if (equalIgnoringCase(attr->value(), "false"))
-            style->setProperty(CSSPropertyWebkitUserDrag, CSSValueNone);
+            addPropertyToAttributeStyle(style, CSSPropertyWebkitUserDrag, CSSValueNone);
     } else if (attr->name() == dirAttr) {
         if (equalIgnoringCase(attr->value(), "auto"))
-            style->setProperty(CSSPropertyUnicodeBidi, unicodeBidiAttributeForDirAuto(this));
+            addPropertyToAttributeStyle(style, CSSPropertyUnicodeBidi, unicodeBidiAttributeForDirAuto(this));
         else {
-            style->setProperty(CSSPropertyDirection, attr->value());
+            addPropertyToAttributeStyle(style, CSSPropertyDirection, attr->value());
             if (!hasTagName(bdiTag) && !hasTagName(bdoTag) && !hasTagName(outputTag))
-                style->setProperty(CSSPropertyUnicodeBidi, CSSValueEmbed);
+                addPropertyToAttributeStyle(style, CSSPropertyUnicodeBidi, CSSValueEmbed);
         }
     } else if (attr->name().matches(XMLNames::langAttr)) {
         mapLanguageAttributeToLocale(attr, style);
@@ -711,10 +711,10 @@ void HTMLElement::applyAlignmentAttributeToStyle(Attribute* attr, StylePropertyS
         verticalAlignValue = CSSValueTextTop;
 
     if (floatValue != CSSValueInvalid)
-        style->setProperty(CSSPropertyFloat, floatValue);
+        addPropertyToAttributeStyle(style, CSSPropertyFloat, floatValue);
 
     if (verticalAlignValue != CSSValueInvalid)
-        style->setProperty(CSSPropertyVerticalAlign, verticalAlignValue);
+        addPropertyToAttributeStyle(style, CSSPropertyVerticalAlign, verticalAlignValue);
 }
 
 bool HTMLElement::supportsFocus() const
@@ -1095,12 +1095,12 @@ void HTMLElement::addHTMLLengthToStyle(StylePropertySet* style, int propertyID,
         }
 
         if (l != v->length()) {
-            style->setProperty(propertyID, v->substring(0, l));
+            addPropertyToAttributeStyle(style, propertyID, v->substring(0, l));
             return;
         }
     }
 
-    style->setProperty(propertyID, value);
+    addPropertyToAttributeStyle(style, propertyID, value);
 }
 
 static String parseColorStringWithCrazyLegacyRules(const String& colorString)
@@ -1171,11 +1171,11 @@ void HTMLElement::addHTMLColorToStyle(StylePropertySet* style, int propertyID, c
     // If the string is a named CSS color or a 3/6-digit hex color, use that.
     Color parsedColor(colorString);
     if (parsedColor.isValid()) {
-        style->setProperty(propertyID, colorString);
+        addPropertyToAttributeStyle(style, propertyID, colorString);
         return;
     }
 
-    style->setProperty(propertyID, parseColorStringWithCrazyLegacyRules(colorString));
+    addPropertyToAttributeStyle(style, propertyID, parseColorStringWithCrazyLegacyRules(colorString));
 }
 
 void StyledElement::copyNonAttributeProperties(const Element* sourceElement)
index bd9be7d..9d463cd 100644 (file)
@@ -100,8 +100,8 @@ public:
 protected:
     HTMLElement(const QualifiedName& tagName, Document*);
 
-    static void addHTMLLengthToStyle(StylePropertySet*, int propertyID, const String& value);
-    static void addHTMLColorToStyle(StylePropertySet*, int propertyID, const String& color);
+    void addHTMLLengthToStyle(StylePropertySet*, int propertyID, const String& value);
+    void addHTMLColorToStyle(StylePropertySet*, int propertyID, const String& color);
 
     void applyAlignmentAttributeToStyle(Attribute*, StylePropertySet*);
     void applyBorderAttributeToStyle(Attribute*, StylePropertySet*);
index a5da483..ea04017 100644 (file)
@@ -170,11 +170,11 @@ void HTMLFontElement::collectStyleForAttribute(Attribute* attr, StylePropertySet
     if (attr->name() == sizeAttr) {
         int size = 0;
         if (cssValueFromFontSizeNumber(attr->value(), size))
-            style->setProperty(CSSPropertyFontSize, size);
+            addPropertyToAttributeStyle(style, CSSPropertyFontSize, size);
     } else if (attr->name() == colorAttr)
         addHTMLColorToStyle(style, CSSPropertyColor, attr->value());
     else if (attr->name() == faceAttr)
-        style->setProperty(CSSPropertyFontFamily, attr->value());
+        addPropertyToAttributeStyle(style, CSSPropertyFontFamily, attr->value());
     else
         HTMLElement::collectStyleForAttribute(attr, style);
 }
index 90d929b..47120e2 100644 (file)
@@ -59,14 +59,14 @@ void HTMLHRElement::collectStyleForAttribute(Attribute* attr, StylePropertySet*
 {
     if (attr->name() == alignAttr) {
         if (equalIgnoringCase(attr->value(), "left")) {
-            style->setProperty(CSSPropertyMarginLeft, "0"); // FIXME: Pass as integer.
-            style->setProperty(CSSPropertyMarginRight, CSSValueAuto);
+            addPropertyToAttributeStyle(style, CSSPropertyMarginLeft, "0"); // FIXME: Pass as integer.
+            addPropertyToAttributeStyle(style, CSSPropertyMarginRight, CSSValueAuto);
         } else if (equalIgnoringCase(attr->value(), "right")) {
-            style->setProperty(CSSPropertyMarginLeft, CSSValueAuto);
-            style->setProperty(CSSPropertyMarginRight, "0"); // FIXME: Pass as integer.
+            addPropertyToAttributeStyle(style, CSSPropertyMarginLeft, CSSValueAuto);
+            addPropertyToAttributeStyle(style, CSSPropertyMarginRight, "0"); // FIXME: Pass as integer.
         } else {
-            style->setProperty(CSSPropertyMarginLeft, CSSValueAuto);
-            style->setProperty(CSSPropertyMarginRight, CSSValueAuto);
+            addPropertyToAttributeStyle(style, CSSPropertyMarginLeft, CSSValueAuto);
+            addPropertyToAttributeStyle(style, CSSPropertyMarginRight, CSSValueAuto);
         }
     } else if (attr->name() == widthAttr) {
         bool ok;
@@ -76,24 +76,24 @@ void HTMLHRElement::collectStyleForAttribute(Attribute* attr, StylePropertySet*
         else
             addHTMLLengthToStyle(style, CSSPropertyWidth, attr->value());
     } else if (attr->name() == colorAttr) {
-        style->setProperty(CSSPropertyBorderTopStyle, CSSValueSolid);
-        style->setProperty(CSSPropertyBorderRightStyle, CSSValueSolid);
-        style->setProperty(CSSPropertyBorderBottomStyle, CSSValueSolid);
-        style->setProperty(CSSPropertyBorderLeftStyle, CSSValueSolid);
+        addPropertyToAttributeStyle(style, CSSPropertyBorderTopStyle, CSSValueSolid);
+        addPropertyToAttributeStyle(style, CSSPropertyBorderRightStyle, CSSValueSolid);
+        addPropertyToAttributeStyle(style, CSSPropertyBorderBottomStyle, CSSValueSolid);
+        addPropertyToAttributeStyle(style, CSSPropertyBorderLeftStyle, CSSValueSolid);
         addHTMLColorToStyle(style, CSSPropertyBorderColor, attr->value());
         addHTMLColorToStyle(style, CSSPropertyBackgroundColor, attr->value());
     } else if (attr->name() == noshadeAttr) {
-        style->setProperty(CSSPropertyBorderTopStyle, CSSValueSolid);
-        style->setProperty(CSSPropertyBorderRightStyle, CSSValueSolid);
-        style->setProperty(CSSPropertyBorderBottomStyle, CSSValueSolid);
-        style->setProperty(CSSPropertyBorderLeftStyle, CSSValueSolid);
+        addPropertyToAttributeStyle(style, CSSPropertyBorderTopStyle, CSSValueSolid);
+        addPropertyToAttributeStyle(style, CSSPropertyBorderRightStyle, CSSValueSolid);
+        addPropertyToAttributeStyle(style, CSSPropertyBorderBottomStyle, CSSValueSolid);
+        addPropertyToAttributeStyle(style, CSSPropertyBorderLeftStyle, CSSValueSolid);
         addHTMLColorToStyle(style, CSSPropertyBorderColor, String("grey")); // FIXME: Pass as rgb() value.
         addHTMLColorToStyle(style, CSSPropertyBackgroundColor, String("grey")); // FIXME: Pass as rgb() value.
     } else if (attr->name() == sizeAttr) {
         StringImpl* si = attr->value().impl();
         int size = si->toInt();
         if (size <= 1)
-            style->setProperty(CSSPropertyBorderBottomWidth, String("0")); // FIXME: Pass as integer.
+            addPropertyToAttributeStyle(style, CSSPropertyBorderBottomWidth, String("0")); // FIXME: Pass as integer.
         else
             addHTMLLengthToStyle(style, CSSPropertyHeight, String::number(size - 2)); // FIXME: Pass as integer.
     } else
index f8a8fd3..583a23f 100644 (file)
@@ -102,7 +102,7 @@ void HTMLImageElement::collectStyleForAttribute(Attribute* attr, StylePropertySe
     } else if (attr->name() == alignAttr)
         applyAlignmentAttributeToStyle(attr, style);
     else if (attr->name() == valignAttr)
-        style->setProperty(CSSPropertyVerticalAlign, attr->value());
+        addPropertyToAttributeStyle(style, CSSPropertyVerticalAlign, attr->value());
     else
         HTMLElement::collectStyleForAttribute(attr, style);
 }
index c845612..ec7824e 100644 (file)
@@ -60,17 +60,17 @@ void HTMLLIElement::collectStyleForAttribute(Attribute* attr, StylePropertySet*
 {
     if (attr->name() == typeAttr) {
         if (attr->value() == "a")
-            style->setProperty(CSSPropertyListStyleType, CSSValueLowerAlpha);
+            addPropertyToAttributeStyle(style, CSSPropertyListStyleType, CSSValueLowerAlpha);
         else if (attr->value() == "A")
-            style->setProperty(CSSPropertyListStyleType, CSSValueUpperAlpha);
+            addPropertyToAttributeStyle(style, CSSPropertyListStyleType, CSSValueUpperAlpha);
         else if (attr->value() == "i")
-            style->setProperty(CSSPropertyListStyleType, CSSValueLowerRoman);
+            addPropertyToAttributeStyle(style, CSSPropertyListStyleType, CSSValueLowerRoman);
         else if (attr->value() == "I")
-            style->setProperty(CSSPropertyListStyleType, CSSValueUpperRoman);
+            addPropertyToAttributeStyle(style, CSSPropertyListStyleType, CSSValueUpperRoman);
         else if (attr->value() == "1")
-            style->setProperty(CSSPropertyListStyleType, CSSValueDecimal);
+            addPropertyToAttributeStyle(style, CSSPropertyListStyleType, CSSValueDecimal);
         else
-            style->setProperty(CSSPropertyListStyleType, attr->value());
+            addPropertyToAttributeStyle(style, CSSPropertyListStyleType, attr->value());
     } else
         HTMLElement::collectStyleForAttribute(attr, style);
 }
index 70edab3..a1445ad 100644 (file)
@@ -95,16 +95,16 @@ void HTMLMarqueeElement::collectStyleForAttribute(Attribute* attr, StyleProperty
     } else if (attr->name() == loopAttr) {
         if (!attr->value().isEmpty()) {
             if (attr->value() == "-1" || equalIgnoringCase(attr->value(), "infinite"))
-                style->setProperty(CSSPropertyWebkitMarqueeRepetition, CSSValueInfinite);
+                addPropertyToAttributeStyle(style, CSSPropertyWebkitMarqueeRepetition, CSSValueInfinite);
             else
                 addHTMLLengthToStyle(style, CSSPropertyWebkitMarqueeRepetition, attr->value());
         }
     } else if (attr->name() == behaviorAttr) {
         if (!attr->value().isEmpty())
-            style->setProperty(CSSPropertyWebkitMarqueeStyle, attr->value());
+            addPropertyToAttributeStyle(style, CSSPropertyWebkitMarqueeStyle, attr->value());
     } else if (attr->name() == directionAttr) {
         if (!attr->value().isEmpty())
-            style->setProperty(CSSPropertyWebkitMarqueeDirection, attr->value());
+            addPropertyToAttributeStyle(style, CSSPropertyWebkitMarqueeDirection, attr->value());
     } else
         HTMLElement::collectStyleForAttribute(attr, style);
 }
index 8b7c373..1f7e28d 100644 (file)
@@ -65,15 +65,15 @@ void HTMLOListElement::collectStyleForAttribute(Attribute* attr, StylePropertySe
 {
     if (attr->name() == typeAttr) {
         if (attr->value() == "a")
-            style->setProperty(CSSPropertyListStyleType, CSSValueLowerAlpha);
+            addPropertyToAttributeStyle(style, CSSPropertyListStyleType, CSSValueLowerAlpha);
         else if (attr->value() == "A")
-            style->setProperty(CSSPropertyListStyleType, CSSValueUpperAlpha);
+            addPropertyToAttributeStyle(style, CSSPropertyListStyleType, CSSValueUpperAlpha);
         else if (attr->value() == "i")
-            style->setProperty(CSSPropertyListStyleType, CSSValueLowerRoman);
+            addPropertyToAttributeStyle(style, CSSPropertyListStyleType, CSSValueLowerRoman);
         else if (attr->value() == "I")
-            style->setProperty(CSSPropertyListStyleType, CSSValueUpperRoman);
+            addPropertyToAttributeStyle(style, CSSPropertyListStyleType, CSSValueUpperRoman);
         else if (attr->value() == "1")
-            style->setProperty(CSSPropertyListStyleType, CSSValueDecimal);
+            addPropertyToAttributeStyle(style, CSSPropertyListStyleType, CSSValueDecimal);
     } else
         HTMLElement::collectStyleForAttribute(attr, style);
 }
index a70edc0..c8f6ad3 100644 (file)
@@ -55,13 +55,13 @@ void HTMLParagraphElement::collectStyleForAttribute(Attribute* attr, StyleProper
 {
     if (attr->name() == alignAttr) {
         if (equalIgnoringCase(attr->value(), "middle") || equalIgnoringCase(attr->value(), "center"))
-            style->setProperty(CSSPropertyTextAlign, CSSValueWebkitCenter);
+            addPropertyToAttributeStyle(style, CSSPropertyTextAlign, CSSValueWebkitCenter);
         else if (equalIgnoringCase(attr->value(), "left"))
-            style->setProperty(CSSPropertyTextAlign, CSSValueWebkitLeft);
+            addPropertyToAttributeStyle(style, CSSPropertyTextAlign, CSSValueWebkitLeft);
         else if (equalIgnoringCase(attr->value(), "right"))
-            style->setProperty(CSSPropertyTextAlign, CSSValueWebkitRight);
+            addPropertyToAttributeStyle(style, CSSPropertyTextAlign, CSSValueWebkitRight);
         else
-            style->setProperty(CSSPropertyTextAlign, attr->value());
+            addPropertyToAttributeStyle(style, CSSPropertyTextAlign, attr->value());
     } else
         HTMLElement::collectStyleForAttribute(attr, style);
 }
index 047c3a0..c327d0f 100644 (file)
@@ -55,7 +55,7 @@ void HTMLTableCaptionElement::collectStyleForAttribute(Attribute* attr, StylePro
 {
     if (attr->name() == alignAttr) {
         if (!attr->isEmpty())
-            style->setProperty(CSSPropertyCaptionSide, attr->value());
+            addPropertyToAttributeStyle(style, CSSPropertyCaptionSide, attr->value());
     } else
         HTMLElement::collectStyleForAttribute(attr, style);
 }
index f96292f..7664673 100644 (file)
@@ -85,7 +85,7 @@ bool HTMLTableCellElement::isPresentationAttribute(Attribute* attr) const
 void HTMLTableCellElement::collectStyleForAttribute(Attribute* attr, StylePropertySet* style)
 {
     if (attr->name() == nowrapAttr) {
-        style->setProperty(CSSPropertyWhiteSpace, CSSValueWebkitNowrap);
+        addPropertyToAttributeStyle(style, CSSPropertyWhiteSpace, CSSValueWebkitNowrap);
     } else if (attr->name() == widthAttr) {
         if (!attr->value().isEmpty()) {
             int widthInt = attr->value().toInt();
index e9d55a4..4f65062 100644 (file)
@@ -313,7 +313,7 @@ void HTMLTableElement::collectStyleForAttribute(Attribute* attr, StylePropertySe
             style->setProperty(CSSProperty(CSSPropertyBackgroundImage, CSSImageValue::create(document()->completeURL(url).string())));
     } else if (attr->name() == valignAttr) {
         if (!attr->isEmpty())
-            style->setProperty(CSSPropertyVerticalAlign, attr->value());
+            addPropertyToAttributeStyle(style, CSSPropertyVerticalAlign, attr->value());
     } else if (attr->name() == cellspacingAttr) {
         if (!attr->isEmpty())
             addHTMLLengthToStyle(style, CSSPropertyBorderSpacing, attr->value());
@@ -326,29 +326,29 @@ void HTMLTableElement::collectStyleForAttribute(Attribute* attr, StylePropertySe
     } else if (attr->name() == alignAttr) {
         if (!attr->value().isEmpty()) {
             if (equalIgnoringCase(attr->value(), "center")) {
-                style->setProperty(CSSPropertyWebkitMarginStart, CSSValueAuto);
-                style->setProperty(CSSPropertyWebkitMarginEnd, CSSValueAuto);
+                addPropertyToAttributeStyle(style, CSSPropertyWebkitMarginStart, CSSValueAuto);
+                addPropertyToAttributeStyle(style, CSSPropertyWebkitMarginEnd, CSSValueAuto);
             } else
-                style->setProperty(CSSPropertyFloat, attr->value());
+                addPropertyToAttributeStyle(style, CSSPropertyFloat, attr->value());
         }
     } else if (attr->name() == rulesAttr) {
         // The presence of a valid rules attribute causes border collapsing to be enabled.
         if (m_rulesAttr != UnsetRules)
-            style->setProperty(CSSPropertyBorderCollapse, CSSValueCollapse);
+            addPropertyToAttributeStyle(style, CSSPropertyBorderCollapse, CSSValueCollapse);
     } else if (attr->name() == frameAttr) {
         bool borderTop;
         bool borderRight;
         bool borderBottom;
         bool borderLeft;
         if (getBordersFromFrameAttributeValue(attr->value(), borderTop, borderRight, borderBottom, borderLeft)) {
-            style->setProperty(CSSPropertyBorderTopWidth, CSSValueThin);
-            style->setProperty(CSSPropertyBorderBottomWidth, CSSValueThin);
-            style->setProperty(CSSPropertyBorderLeftWidth, CSSValueThin);
-            style->setProperty(CSSPropertyBorderRightWidth, CSSValueThin);
-            style->setProperty(CSSPropertyBorderTopStyle, borderTop ? CSSValueSolid : CSSValueHidden);
-            style->setProperty(CSSPropertyBorderBottomStyle, borderBottom ? CSSValueSolid : CSSValueHidden);
-            style->setProperty(CSSPropertyBorderLeftStyle, borderLeft ? CSSValueSolid : CSSValueHidden);
-            style->setProperty(CSSPropertyBorderRightStyle, borderRight ? CSSValueSolid : CSSValueHidden);
+            addPropertyToAttributeStyle(style, CSSPropertyBorderTopWidth, CSSValueThin);
+            addPropertyToAttributeStyle(style, CSSPropertyBorderBottomWidth, CSSValueThin);
+            addPropertyToAttributeStyle(style, CSSPropertyBorderLeftWidth, CSSValueThin);
+            addPropertyToAttributeStyle(style, CSSPropertyBorderRightWidth, CSSValueThin);
+            addPropertyToAttributeStyle(style, CSSPropertyBorderTopStyle, borderTop ? CSSValueSolid : CSSValueHidden);
+            addPropertyToAttributeStyle(style, CSSPropertyBorderBottomStyle, borderBottom ? CSSValueSolid : CSSValueHidden);
+            addPropertyToAttributeStyle(style, CSSPropertyBorderLeftStyle, borderLeft ? CSSValueSolid : CSSValueHidden);
+            addPropertyToAttributeStyle(style, CSSPropertyBorderRightStyle, borderRight ? CSSValueSolid : CSSValueHidden);
         }
     } else
         HTMLElement::collectStyleForAttribute(attr, style);
index c5b04fb..3583c0c 100644 (file)
@@ -56,25 +56,25 @@ void HTMLTablePartElement::collectStyleForAttribute(Attribute* attr, StyleProper
     } else if (attr->name() == bordercolorAttr) {
         if (!attr->value().isEmpty()) {
             addHTMLColorToStyle(style, CSSPropertyBorderColor, attr->value());
-            style->setProperty(CSSPropertyBorderTopStyle, CSSValueSolid);
-            style->setProperty(CSSPropertyBorderBottomStyle, CSSValueSolid);
-            style->setProperty(CSSPropertyBorderLeftStyle, CSSValueSolid);
-            style->setProperty(CSSPropertyBorderRightStyle, CSSValueSolid);
+            addPropertyToAttributeStyle(style, CSSPropertyBorderTopStyle, CSSValueSolid);
+            addPropertyToAttributeStyle(style, CSSPropertyBorderBottomStyle, CSSValueSolid);
+            addPropertyToAttributeStyle(style, CSSPropertyBorderLeftStyle, CSSValueSolid);
+            addPropertyToAttributeStyle(style, CSSPropertyBorderRightStyle, CSSValueSolid);
         }
     } else if (attr->name() == valignAttr) {
         if (!attr->value().isEmpty())
-            style->setProperty(CSSPropertyVerticalAlign, attr->value());
+            addPropertyToAttributeStyle(style, CSSPropertyVerticalAlign, attr->value());
     } else if (attr->name() == alignAttr) {
         if (equalIgnoringCase(attr->value(), "middle") || equalIgnoringCase(attr->value(), "center"))
-            style->setProperty(CSSPropertyTextAlign, CSSValueWebkitCenter);
+            addPropertyToAttributeStyle(style, CSSPropertyTextAlign, CSSValueWebkitCenter);
         else if (equalIgnoringCase(attr->value(), "absmiddle"))
-            style->setProperty(CSSPropertyTextAlign, CSSValueCenter);
+            addPropertyToAttributeStyle(style, CSSPropertyTextAlign, CSSValueCenter);
         else if (equalIgnoringCase(attr->value(), "left"))
-            style->setProperty(CSSPropertyTextAlign, CSSValueWebkitLeft);
+            addPropertyToAttributeStyle(style, CSSPropertyTextAlign, CSSValueWebkitLeft);
         else if (equalIgnoringCase(attr->value(), "right"))
-            style->setProperty(CSSPropertyTextAlign, CSSValueWebkitRight);
+            addPropertyToAttributeStyle(style, CSSPropertyTextAlign, CSSValueWebkitRight);
         else
-            style->setProperty(CSSPropertyTextAlign, attr->value());
+            addPropertyToAttributeStyle(style, CSSPropertyTextAlign, attr->value());
     } else if (attr->name() == heightAttr) {
         if (!attr->value().isEmpty())
             addHTMLLengthToStyle(style, CSSPropertyHeight, attr->value());
index 59ce80e..f110ef6 100644 (file)
@@ -136,11 +136,11 @@ void HTMLTextAreaElement::collectStyleForAttribute(Attribute* attr, StylePropert
 {
     if (attr->name() == wrapAttr) {
         if (shouldWrapText()) {
-            style->setProperty(CSSPropertyWhiteSpace, CSSValuePreWrap);
-            style->setProperty(CSSPropertyWordWrap, CSSValueBreakWord);
+            addPropertyToAttributeStyle(style, CSSPropertyWhiteSpace, CSSValuePreWrap);
+            addPropertyToAttributeStyle(style, CSSPropertyWordWrap, CSSValueBreakWord);
         } else {
-            style->setProperty(CSSPropertyWhiteSpace, CSSValuePre);
-            style->setProperty(CSSPropertyWordWrap, CSSValueNormal);
+            addPropertyToAttributeStyle(style, CSSPropertyWhiteSpace, CSSValuePre);
+            addPropertyToAttributeStyle(style, CSSPropertyWordWrap, CSSValueNormal);
         }
     } else
         HTMLTextFormControlElement::collectStyleForAttribute(attr, style);
index 9ad9a14..e18d2a7 100644 (file)
@@ -57,7 +57,7 @@ bool HTMLUListElement::isPresentationAttribute(Attribute* attr) const
 void HTMLUListElement::collectStyleForAttribute(Attribute* attr, StylePropertySet* style)
 {
     if (attr->name() == typeAttr)
-        style->setProperty(CSSPropertyListStyleType, attr->value());
+        addPropertyToAttributeStyle(style, CSSPropertyListStyleType, attr->value());
     else
         HTMLElement::collectStyleForAttribute(attr, style);
 }
index b0e053f..aa15577 100644 (file)
@@ -1920,7 +1920,7 @@ void CanvasRenderingContext2D::setFont(const String& newFont)
 
     String declarationText("font: ");
     declarationText += newFont;
-    parser.parseDeclaration(tempDecl.get(), declarationText);
+    parser.parseDeclaration(tempDecl.get(), declarationText, 0, 0);
     if (tempDecl->isEmpty())
         return;
 
index 3e2082a..4c00def 100644 (file)
@@ -58,26 +58,26 @@ bool MathMLElement::isPresentationAttribute(Attribute* attr) const
 void MathMLElement::collectStyleForAttribute(Attribute* attr, StylePropertySet* style)
 {
     if (attr->name() == mathbackgroundAttr)
-        style->setProperty(CSSPropertyBackgroundColor, attr->value());
+        addPropertyToAttributeStyle(style, CSSPropertyBackgroundColor, attr->value());
     else if (attr->name() == mathsizeAttr) {
         // The following three values of mathsize are handled in WebCore/css/mathml.css
         if (attr->value() != "normal" && attr->value() != "small" && attr->value() != "big")
-            style->setProperty(CSSPropertyFontSize, attr->value());
+            addPropertyToAttributeStyle(style, CSSPropertyFontSize, attr->value());
     } else if (attr->name() == mathcolorAttr)
-        style->setProperty(CSSPropertyColor, attr->value());
+        addPropertyToAttributeStyle(style, CSSPropertyColor, attr->value());
     // FIXME: deprecated attributes that should loose in a conflict with a non deprecated attribute
     else if (attr->name() == fontsizeAttr)
-        style->setProperty(CSSPropertyFontSize, attr->value());
+        addPropertyToAttributeStyle(style, CSSPropertyFontSize, attr->value());
     else if (attr->name() == backgroundAttr)
-        style->setProperty(CSSPropertyBackgroundColor, attr->value());
+        addPropertyToAttributeStyle(style, CSSPropertyBackgroundColor, attr->value());
     else if (attr->name() == colorAttr)
-        style->setProperty(CSSPropertyColor, attr->value());
+        addPropertyToAttributeStyle(style, CSSPropertyColor, attr->value());
     else if (attr->name() == fontstyleAttr)
-        style->setProperty(CSSPropertyFontStyle, attr->value());
+        addPropertyToAttributeStyle(style, CSSPropertyFontStyle, attr->value());
     else if (attr->name() == fontweightAttr)
-        style->setProperty(CSSPropertyFontWeight, attr->value());
+        addPropertyToAttributeStyle(style, CSSPropertyFontWeight, attr->value());
     else if (attr->name() == fontfamilyAttr)
-        style->setProperty(CSSPropertyFontFamily, attr->value());
+        addPropertyToAttributeStyle(style, CSSPropertyFontFamily, attr->value());
     else {
         ASSERT(!isPresentationAttribute(attr));
         StyledElement::collectStyleForAttribute(attr, style);
index 51cb732..98518de 100644 (file)
@@ -321,7 +321,6 @@ void SVGFontFaceElement::insertedIntoDocument()
     SVGElement::insertedIntoDocument();
     document()->mappedElementSheet()->append(m_fontFaceRule);
     m_fontFaceRule->setParentStyleSheet(document()->mappedElementSheet());
-    m_fontFaceRule->declaration()->setContextStyleSheet(document()->mappedElementSheet());
     rebuildFontFace();
 }
 
@@ -329,7 +328,7 @@ void SVGFontFaceElement::removedFromDocument()
 {
     removeFromMappedElementSheet();
     SVGElement::removedFromDocument();
-    m_fontFaceRule->declaration()->parseDeclaration(emptyString());
+    m_fontFaceRule->declaration()->parseDeclaration(emptyString(), 0);
 }
 
 void SVGFontFaceElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
@@ -350,7 +349,6 @@ void SVGFontFaceElement::removeFromMappedElementSheet()
             break;
         }
     }
-    m_fontFaceRule->declaration()->setContextStyleSheet(0);
     document()->styleSelectorChanged(DeferRecalcStyle);
 }
 
index 786f144..6f7fe9d 100644 (file)
@@ -103,9 +103,9 @@ void SVGImageElement::collectStyleForAttribute(Attribute* attr, StylePropertySet
     if (!isSupportedAttribute(attr->name()))
         SVGStyledTransformableElement::collectStyleForAttribute(attr, style);
     else if (attr->name() == SVGNames::widthAttr)
-        style->setProperty(CSSPropertyWidth, attr->value());
+        addPropertyToAttributeStyle(style, CSSPropertyWidth, attr->value());
     else if (attr->name() == SVGNames::heightAttr)
-        style->setProperty(CSSPropertyHeight, attr->value());
+        addPropertyToAttributeStyle(style, CSSPropertyHeight, attr->value());
 }
 
 void SVGImageElement::parseAttribute(Attribute* attr)
index 376551e..dd159a0 100644 (file)
@@ -303,7 +303,7 @@ void SVGStyledElement::collectStyleForAttribute(Attribute* attr, StylePropertySe
 {
     int propertyID = SVGStyledElement::cssPropertyIdForSVGAttributeName(attr->name());
     if (propertyID > 0)
-        style->setProperty(propertyID, attr->value());
+        addPropertyToAttributeStyle(style, propertyID, attr->value());
 }
 
 void SVGStyledElement::parseAttribute(Attribute* attr)
index e5ba499..1efedac 100644 (file)
@@ -243,9 +243,9 @@ void SVGTextContentElement::collectStyleForAttribute(Attribute* attr, StylePrope
         DEFINE_STATIC_LOCAL(const AtomicString, preserveString, ("preserve"));
 
         if (attr->value() == preserveString)
-            style->setProperty(CSSPropertyWhiteSpace, CSSValuePre);
+            addPropertyToAttributeStyle(style, CSSPropertyWhiteSpace, CSSValuePre);
         else
-            style->setProperty(CSSPropertyWhiteSpace, CSSValueNowrap);
+            addPropertyToAttributeStyle(style, CSSPropertyWhiteSpace, CSSValueNowrap);
     }
 }