Move property setting/removing/addParsedProperty/addParsedProperties functions to MutableStylePropertySet.
Move all functions for setting/removing properties from StylePropertySet to MutableStylePropertySet.
Had to change SVGElement::animatedSMILStyleProperties() & friends to hand out MutableStylePropertySet*
which was always the internal type anyway.
Switch EditingStyle::m_mutableStyle to a RefPtr<MutableStylePropertySet>.
This is a backport from WebKit r148400, r148402, 148403. Patches by Andreas Kling reviewed by Anders Carlsson and Antti Koivisto.
Review URL: https://chromiumcodereview.appspot.com/15821009
git-svn-id: svn://svn.chromium.org/blink/trunk@151189 bbb929c8-8fbe-4397-9dbb-9b2b20218538
diff --git a/Source/core/css/CSSParser.cpp b/Source/core/css/CSSParser.cpp
index b63f062..e88369d 100644
--- a/Source/core/css/CSSParser.cpp
+++ b/Source/core/css/CSSParser.cpp
@@ -439,7 +439,7 @@
}
}
-static bool parseColorValue(StylePropertySet* declaration, CSSPropertyID propertyId, const String& string, bool important, CSSParserMode cssParserMode)
+static bool parseColorValue(MutableStylePropertySet* declaration, CSSPropertyID propertyId, const String& string, bool important, CSSParserMode cssParserMode)
{
ASSERT(!string.isEmpty());
bool strict = isStrictParserMode(cssParserMode);
@@ -535,7 +535,7 @@
return ok;
}
-static bool parseSimpleLengthValue(StylePropertySet* declaration, CSSPropertyID propertyId, const String& string, bool important, CSSParserMode cssParserMode)
+static bool parseSimpleLengthValue(MutableStylePropertySet* declaration, CSSPropertyID propertyId, const String& string, bool important, CSSParserMode cssParserMode)
{
ASSERT(!string.isEmpty());
bool acceptsNegativeNumbers;
@@ -1057,7 +1057,7 @@
}
}
-static bool parseKeywordValue(StylePropertySet* declaration, CSSPropertyID propertyId, const String& string, bool important, const CSSParserContext& parserContext)
+static bool parseKeywordValue(MutableStylePropertySet* declaration, CSSPropertyID propertyId, const String& string, bool important, const CSSParserContext& parserContext)
{
ASSERT(!string.isEmpty());
@@ -1114,7 +1114,7 @@
return true;
}
-static bool parseTranslateTransformValue(StylePropertySet* properties, CSSPropertyID propertyID, const String& string, bool important)
+static bool parseTranslateTransformValue(MutableStylePropertySet* properties, CSSPropertyID propertyID, const String& string, bool important)
{
if (propertyID != CSSPropertyWebkitTransform)
return false;
@@ -1171,7 +1171,7 @@
return static_pointer_cast<CSSValueList>(dummyStyle->getPropertyCSSValue(CSSPropertyFontFamily));
}
-bool CSSParser::parseValue(StylePropertySet* declaration, CSSPropertyID propertyID, const String& string, bool important, Document* document)
+bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID propertyID, const String& string, bool important, Document* document)
{
ASSERT(!string.isEmpty());
@@ -1188,7 +1188,7 @@
return parser.parseValue(declaration, propertyID, string, important, static_cast<StyleSheetContents*>(0));
}
-bool CSSParser::parseValue(StylePropertySet* declaration, CSSPropertyID propertyID, const String& string, bool important, CSSParserMode cssParserMode, StyleSheetContents* contextStyleSheet)
+bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID propertyID, const String& string, bool important, CSSParserMode cssParserMode, StyleSheetContents* contextStyleSheet)
{
ASSERT(!string.isEmpty());
if (parseSimpleLengthValue(declaration, propertyID, string, important, cssParserMode))
@@ -1211,7 +1211,7 @@
return parser.parseValue(declaration, propertyID, string, important, contextStyleSheet);
}
-bool CSSParser::parseValue(StylePropertySet* declaration, CSSPropertyID propertyID, const String& string, bool important, StyleSheetContents* contextStyleSheet)
+bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID propertyID, const String& string, bool important, StyleSheetContents* contextStyleSheet)
{
// FIXME: Check RuntimeCSSEnabled::isPropertyEnabled or isValueEnabledForProperty.
@@ -1328,7 +1328,7 @@
}
-bool CSSParser::parseDeclaration(StylePropertySet* declaration, const String& string, SourceDataHandler* sourceDataHandler, StyleSheetContents* contextStyleSheet)
+bool CSSParser::parseDeclaration(MutableStylePropertySet* declaration, const String& string, SourceDataHandler* sourceDataHandler, StyleSheetContents* contextStyleSheet)
{
setStyleSheet(contextStyleSheet);
diff --git a/Source/core/css/CSSParser.h b/Source/core/css/CSSParser.h
index 428dae9..644cc2d 100644
--- a/Source/core/css/CSSParser.h
+++ b/Source/core/css/CSSParser.h
@@ -55,8 +55,8 @@
class ImmutableStylePropertySet;
class MediaQueryExp;
class MediaQuerySet;
+class MutableStylePropertySet;
class StyleKeyframe;
-class StylePropertySet;
class StylePropertyShorthand;
class StyleRuleBase;
class StyleRuleKeyframes;
@@ -93,12 +93,12 @@
PassRefPtr<StyleRuleBase> parseRule(StyleSheetContents*, const String&);
PassRefPtr<StyleKeyframe> parseKeyframeRule(StyleSheetContents*, const String&);
bool parseSupportsCondition(const String&);
- static bool parseValue(StylePropertySet*, CSSPropertyID, const String&, bool important, CSSParserMode, StyleSheetContents*);
+ static bool parseValue(MutableStylePropertySet*, CSSPropertyID, const String&, bool important, CSSParserMode, StyleSheetContents*);
static bool parseColor(RGBA32& color, const String&, bool strict = false);
static bool parseSystemColor(RGBA32& color, const String&, Document*);
static PassRefPtr<CSSValueList> parseFontFaceValue(const AtomicString&);
PassRefPtr<CSSPrimitiveValue> parseValidPrimitive(int ident, CSSParserValue*);
- bool parseDeclaration(StylePropertySet*, const String&, SourceDataHandler*, StyleSheetContents* contextStyleSheet);
+ bool parseDeclaration(MutableStylePropertySet*, const String&, SourceDataHandler*, StyleSheetContents* contextStyleSheet);
static PassRefPtr<ImmutableStylePropertySet> parseInlineStyleDeclaration(const String&, Element*);
PassOwnPtr<MediaQuery> parseMediaQuery(const String&);
@@ -115,7 +115,7 @@
bool parseContent(CSSPropertyID, bool important);
bool parseQuotes(CSSPropertyID, bool important);
- static bool parseValue(StylePropertySet*, CSSPropertyID, const String&, bool important, Document*);
+ static bool parseValue(MutableStylePropertySet*, CSSPropertyID, const String&, bool important, Document*);
bool cssVariablesEnabled() const;
void storeVariableDeclaration(const CSSParserString&, PassOwnPtr<CSSParserValueList>, bool important);
@@ -531,7 +531,7 @@
bool isGeneratedImageValue(CSSParserValue*) const;
bool parseGeneratedImage(CSSParserValueList*, RefPtr<CSSValue>&);
- bool parseValue(StylePropertySet*, CSSPropertyID, const String&, bool important, StyleSheetContents* contextStyleSheet);
+ bool parseValue(MutableStylePropertySet*, CSSPropertyID, const String&, bool important, StyleSheetContents* contextStyleSheet);
PassRefPtr<ImmutableStylePropertySet> parseDeclaration(const String&, StyleSheetContents* contextStyleSheet);
enum SizeParameterType {
diff --git a/Source/core/css/StylePropertySet.cpp b/Source/core/css/StylePropertySet.cpp
index ddc9e23..cc98568 100644
--- a/Source/core/css/StylePropertySet.cpp
+++ b/Source/core/css/StylePropertySet.cpp
@@ -132,9 +132,8 @@
return propertyAt(foundPropertyIndex).value();
}
-bool StylePropertySet::removeShorthandProperty(CSSPropertyID propertyID)
+bool MutableStylePropertySet::removeShorthandProperty(CSSPropertyID propertyID)
{
- ASSERT(isMutable());
StylePropertyShorthand shorthand = shorthandForProperty(propertyID);
if (!shorthand.length())
return false;
@@ -149,9 +148,8 @@
return removePropertiesInSet(shorthandPrefixingVariant.properties(), shorthandPrefixingVariant.length());
}
-bool StylePropertySet::removeProperty(CSSPropertyID propertyID, String* returnText)
+bool MutableStylePropertySet::removeProperty(CSSPropertyID propertyID, String* returnText)
{
- ASSERT(isMutable());
if (removeShorthandProperty(propertyID)) {
// FIXME: Return an equivalent shorthand when possible.
if (returnText)
@@ -178,7 +176,7 @@
return true;
}
-void StylePropertySet::removePrefixedOrUnprefixedProperty(CSSPropertyID propertyID)
+void MutableStylePropertySet::removePrefixedOrUnprefixedProperty(CSSPropertyID propertyID)
{
int foundPropertyIndex = findPropertyIndex(prefixingVariantForPropertyId(propertyID));
if (foundPropertyIndex == -1)
@@ -219,9 +217,8 @@
return propertyAt(foundPropertyIndex).isImplicit();
}
-bool StylePropertySet::setProperty(CSSPropertyID propertyID, const String& value, bool important, StyleSheetContents* contextStyleSheet)
+bool MutableStylePropertySet::setProperty(CSSPropertyID propertyID, const String& value, bool important, StyleSheetContents* contextStyleSheet)
{
- ASSERT(isMutable());
// 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.
if (value.isEmpty())
@@ -232,9 +229,8 @@
return CSSParser::parseValue(this, propertyID, value, important, cssParserMode(), contextStyleSheet);
}
-void StylePropertySet::setProperty(CSSPropertyID propertyID, PassRefPtr<CSSValue> prpValue, bool important)
+void MutableStylePropertySet::setProperty(CSSPropertyID propertyID, PassRefPtr<CSSValue> prpValue, bool important)
{
- ASSERT(isMutable());
StylePropertyShorthand shorthand = shorthandForProperty(propertyID);
if (!shorthand.length()) {
setProperty(CSSProperty(propertyID, prpValue, important));
@@ -248,11 +244,10 @@
mutablePropertyVector().append(CSSProperty(shorthand.properties()[i], value, important));
}
-void StylePropertySet::setProperty(const CSSProperty& property, CSSProperty* slot)
+void MutableStylePropertySet::setProperty(const CSSProperty& property, CSSProperty* slot)
{
- ASSERT(isMutable());
if (!removeShorthandProperty(property.id())) {
- CSSProperty* toReplace = slot ? slot : findMutableCSSPropertyWithID(property.id());
+ CSSProperty* toReplace = slot ? slot : findCSSPropertyWithID(property.id());
if (toReplace) {
*toReplace = property;
setPrefixingVariantProperty(property);
@@ -262,7 +257,7 @@
appendPrefixingVariantProperty(property);
}
-void StylePropertySet::appendPrefixingVariantProperty(const CSSProperty& property)
+void MutableStylePropertySet::appendPrefixingVariantProperty(const CSSProperty& property)
{
mutablePropertyVector().append(property);
CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(property.id());
@@ -271,17 +266,16 @@
mutablePropertyVector().append(CSSProperty(prefixingVariant, property.value(), property.isImportant(), property.shorthandID(), property.metadata().m_implicit));
}
-void StylePropertySet::setPrefixingVariantProperty(const CSSProperty& property)
+void MutableStylePropertySet::setPrefixingVariantProperty(const CSSProperty& property)
{
CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(property.id());
- CSSProperty* toReplace = findMutableCSSPropertyWithID(prefixingVariant);
+ CSSProperty* toReplace = findCSSPropertyWithID(prefixingVariant);
if (toReplace)
*toReplace = CSSProperty(prefixingVariant, property.value(), property.isImportant(), property.shorthandID(), property.metadata().m_implicit);
}
-bool StylePropertySet::setProperty(CSSPropertyID propertyID, int identifier, bool important)
+bool MutableStylePropertySet::setProperty(CSSPropertyID propertyID, int identifier, bool important)
{
- ASSERT(isMutable());
setProperty(CSSProperty(propertyID, cssValuePool().createIdentifierValue(identifier), important));
return true;
}
@@ -300,17 +294,15 @@
parser.parseDeclaration(this, styleDeclaration, 0, contextStyleSheet);
}
-void StylePropertySet::addParsedProperties(const Vector<CSSProperty>& properties)
+void MutableStylePropertySet::addParsedProperties(const Vector<CSSProperty>& properties)
{
- ASSERT(isMutable());
mutablePropertyVector().reserveCapacity(mutablePropertyVector().size() + properties.size());
for (unsigned i = 0; i < properties.size(); ++i)
addParsedProperty(properties[i]);
}
-void StylePropertySet::addParsedProperty(const CSSProperty& property)
+void MutableStylePropertySet::addParsedProperty(const CSSProperty& property)
{
- ASSERT(isMutable());
// Only add properties that have no !important counterpart present
if (!propertyIsImportant(property.id()) || property.isImportant())
setProperty(property);
@@ -321,13 +313,13 @@
return StylePropertySerializer(*this).asText();
}
-void StylePropertySet::mergeAndOverrideOnConflict(const StylePropertySet* other)
+void MutableStylePropertySet::mergeAndOverrideOnConflict(const StylePropertySet* other)
{
ASSERT(isMutable());
unsigned size = other->propertyCount();
for (unsigned n = 0; n < size; ++n) {
PropertyReference toMerge = other->propertyAt(n);
- CSSProperty* old = findMutableCSSPropertyWithID(toMerge.id());
+ CSSProperty* old = findCSSPropertyWithID(toMerge.id());
if (old)
setProperty(toMerge.toCSSProperty(), old);
else
@@ -394,19 +386,18 @@
mutablePropertyVector().clear();
}
-PassRefPtr<StylePropertySet> StylePropertySet::copyBlockProperties() const
+PassRefPtr<MutableStylePropertySet> StylePropertySet::copyBlockProperties() const
{
return copyPropertiesInSet(blockProperties());
}
-void StylePropertySet::removeBlockProperties()
+void MutableStylePropertySet::removeBlockProperties()
{
removePropertiesInSet(blockProperties().data(), blockProperties().size());
}
-bool StylePropertySet::removePropertiesInSet(const CSSPropertyID* set, unsigned length)
+bool MutableStylePropertySet::removePropertiesInSet(const CSSPropertyID* set, unsigned length)
{
- ASSERT(isMutable());
if (mutablePropertyVector().isEmpty())
return false;
@@ -446,9 +437,8 @@
return -1;
}
-CSSProperty* StylePropertySet::findMutableCSSPropertyWithID(CSSPropertyID propertyID)
+CSSProperty* MutableStylePropertySet::findCSSPropertyWithID(CSSPropertyID propertyID)
{
- ASSERT(isMutable());
int foundPropertyIndex = findPropertyIndex(propertyID);
if (foundPropertyIndex == -1)
return 0;
@@ -463,9 +453,8 @@
return propertyAt(foundPropertyIndex).value()->equals(*propertyValue);
}
-void StylePropertySet::removeEquivalentProperties(const StylePropertySet* style)
+void MutableStylePropertySet::removeEquivalentProperties(const StylePropertySet* style)
{
- ASSERT(isMutable());
Vector<CSSPropertyID> propertiesToRemove;
unsigned size = mutablePropertyVector().size();
for (unsigned i = 0; i < size; ++i) {
@@ -478,9 +467,8 @@
removeProperty(propertiesToRemove[i]);
}
-void StylePropertySet::removeEquivalentProperties(const CSSStyleDeclaration* style)
+void MutableStylePropertySet::removeEquivalentProperties(const CSSStyleDeclaration* style)
{
- ASSERT(isMutable());
Vector<CSSPropertyID> propertiesToRemove;
unsigned size = mutablePropertyVector().size();
for (unsigned i = 0; i < size; ++i) {
diff --git a/Source/core/css/StylePropertySet.h b/Source/core/css/StylePropertySet.h
index 553bca6..78ac181 100644
--- a/Source/core/css/StylePropertySet.h
+++ b/Source/core/css/StylePropertySet.h
@@ -105,27 +105,7 @@
CSSPropertyID getPropertyShorthand(CSSPropertyID) const;
bool isPropertyImplicit(CSSPropertyID) const;
- // These expand shorthand properties into multiple properties.
- bool setProperty(CSSPropertyID, const String& value, bool important = false, StyleSheetContents* contextStyleSheet = 0);
- void setProperty(CSSPropertyID, PassRefPtr<CSSValue>, bool important = false);
-
- // These do not. FIXME: This is too messy, we can do better.
- bool setProperty(CSSPropertyID, int identifier, bool important = false);
- void appendPrefixingVariantProperty(const CSSProperty&);
- void setPrefixingVariantProperty(const CSSProperty&);
- void setProperty(const CSSProperty&, CSSProperty* slot = 0);
-
- bool removeProperty(CSSPropertyID, String* returnText = 0);
- void removePrefixedOrUnprefixedProperty(CSSPropertyID);
-
- void addParsedProperties(const Vector<CSSProperty>&);
- void addParsedProperty(const CSSProperty&);
-
- PassRefPtr<StylePropertySet> copyBlockProperties() const;
- void removeBlockProperties();
- bool removePropertiesInSet(const CSSPropertyID* set, unsigned length);
-
- void mergeAndOverrideOnConflict(const StylePropertySet*);
+ PassRefPtr<MutableStylePropertySet> copyBlockProperties() const;
CSSParserMode cssParserMode() const { return static_cast<CSSParserMode>(m_cssParserMode); }
@@ -134,9 +114,6 @@
PassRefPtr<MutableStylePropertySet> mutableCopy() const;
PassRefPtr<ImmutableStylePropertySet> immutableCopyIfNeeded() const;
- void removeEquivalentProperties(const StylePropertySet*);
- void removeEquivalentProperties(const CSSStyleDeclaration*);
-
PassRefPtr<MutableStylePropertySet> copyPropertiesInSet(const Vector<CSSPropertyID>&) const;
String asText() const;
@@ -158,6 +135,8 @@
const CSSValue** immutableValueArray() const;
const StylePropertyMetadata* immutableMetadataArray() const;
+ bool propertyMatches(CSSPropertyID, const CSSValue*) const;
+
protected:
StylePropertySet(CSSParserMode cssParserMode)
: m_cssParserMode(cssParserMode)
@@ -180,12 +159,6 @@
mutable unsigned m_ownsCSSOMWrapper : 1;
mutable unsigned m_isMutable : 1;
unsigned m_arraySize : 28;
-
-private:
- bool removeShorthandProperty(CSSPropertyID);
- bool propertyMatches(CSSPropertyID, const CSSValue*) const;
-
- CSSProperty* findMutableCSSPropertyWithID(CSSPropertyID);
friend class PropertySetCSSStyleDeclaration;
};
@@ -224,6 +197,28 @@
MutableStylePropertySet(const StylePropertySet&);
+ void addParsedProperties(const Vector<CSSProperty>&);
+ void addParsedProperty(const CSSProperty&);
+
+ // These expand shorthand properties into multiple properties.
+ bool setProperty(CSSPropertyID, const String& value, bool important = false, StyleSheetContents* contextStyleSheet = 0);
+ void setProperty(CSSPropertyID, PassRefPtr<CSSValue>, bool important = false);
+
+ // These do not. FIXME: This is too messy, we can do better.
+ bool setProperty(CSSPropertyID, int identifier, bool important = false);
+ void appendPrefixingVariantProperty(const CSSProperty&);
+ void setPrefixingVariantProperty(const CSSProperty&);
+ void setProperty(const CSSProperty&, CSSProperty* slot = 0);
+
+ bool removeProperty(CSSPropertyID, String* returnText = 0);
+ void removePrefixedOrUnprefixedProperty(CSSPropertyID);
+ void removeBlockProperties();
+ bool removePropertiesInSet(const CSSPropertyID* set, unsigned length);
+ void removeEquivalentProperties(const StylePropertySet*);
+ void removeEquivalentProperties(const CSSStyleDeclaration*);
+
+ void mergeAndOverrideOnConflict(const StylePropertySet*);
+
void clear();
void parseDeclaration(const String& styleDeclaration, StyleSheetContents* contextStyleSheet);
@@ -236,7 +231,11 @@
MutableStylePropertySet(CSSParserMode cssParserMode)
: StylePropertySet(cssParserMode)
{ }
+
MutableStylePropertySet(const CSSProperty* properties, unsigned count);
+
+ bool removeShorthandProperty(CSSPropertyID);
+ CSSProperty* findCSSPropertyWithID(CSSPropertyID);
};
inline Vector<CSSProperty, 4>& StylePropertySet::mutablePropertyVector()
diff --git a/Source/core/css/resolver/ViewportStyleResolver.h b/Source/core/css/resolver/ViewportStyleResolver.h
index bdbc150..2b1cd82 100644
--- a/Source/core/css/resolver/ViewportStyleResolver.h
+++ b/Source/core/css/resolver/ViewportStyleResolver.h
@@ -41,8 +41,8 @@
class CSSPrimitiveValue;
class Document;
+class MutableStylePropertySet;
class StyleRuleViewport;
-class StylePropertySet;
class ViewportStyleResolver : public RefCounted<ViewportStyleResolver> {
public:
@@ -64,7 +64,7 @@
float getViewportArgumentValue(CSSPropertyID) const;
Document* m_document;
- RefPtr<StylePropertySet> m_propertySet;
+ RefPtr<MutableStylePropertySet> m_propertySet;
};
} // namespace WebCore
diff --git a/Source/core/editing/ApplyStyleCommand.cpp b/Source/core/editing/ApplyStyleCommand.cpp
index f4d8e7e..4a8dd4c 100644
--- a/Source/core/editing/ApplyStyleCommand.cpp
+++ b/Source/core/editing/ApplyStyleCommand.cpp
@@ -393,7 +393,7 @@
}
lastStyledNode = node;
- RefPtr<StylePropertySet> inlineStyle = copyStyleOrCreateEmpty(element->inlineStyle());
+ RefPtr<MutableStylePropertySet> inlineStyle = copyStyleOrCreateEmpty(element->inlineStyle());
float currentFontSize = computedFontSize(node);
float desiredFontSize = max(MinimumFontSize, startingFontSizes.get(node) + style->fontSizeDelta());
RefPtr<CSSValue> value = inlineStyle->getPropertyCSSValue(CSSPropertyFontSize);
@@ -520,7 +520,7 @@
// other attributes, like we (should) do with B and I elements.
removeNodeAttribute(element, dirAttr);
} else {
- RefPtr<StylePropertySet> inlineStyle = copyStyleOrCreateEmpty(element->inlineStyle());
+ RefPtr<MutableStylePropertySet> inlineStyle = copyStyleOrCreateEmpty(element->inlineStyle());
inlineStyle->setProperty(CSSPropertyUnicodeBidi, CSSValueNormal);
inlineStyle->removeProperty(CSSPropertyDirection);
setNodeAttribute(element, styleAttr, inlineStyle->asText());
@@ -764,7 +764,7 @@
break;
// Add to this element's inline style and skip over its contents.
HTMLElement* element = toHTMLElement(node.get());
- RefPtr<StylePropertySet> inlineStyle = copyStyleOrCreateEmpty(element->inlineStyle());
+ RefPtr<MutableStylePropertySet> inlineStyle = copyStyleOrCreateEmpty(element->inlineStyle());
inlineStyle->mergeAndOverrideOnConflict(style->style());
setNodeAttribute(element, styleAttr, inlineStyle->asText());
next = NodeTraversal::nextSkippingChildren(node.get());
diff --git a/Source/core/editing/EditingStyle.cpp b/Source/core/editing/EditingStyle.cpp
index c1c1415..46b80e5 100644
--- a/Source/core/editing/EditingStyle.cpp
+++ b/Source/core/editing/EditingStyle.cpp
@@ -127,7 +127,7 @@
return copyEditingProperties(style.get(), type);
}
-static PassRefPtr<StylePropertySet> getPropertiesNotIn(StylePropertySet* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle);
+static PassRefPtr<MutableStylePropertySet> getPropertiesNotIn(StylePropertySet* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle);
enum LegacyFontSizeMode { AlwaysUseLegacyFontSize, UseLegacyFontSizeOnlyIfPixelValuesMatch };
static int legacyFontSizeFromCSSValue(Document*, CSSPrimitiveValue*, bool shouldUseFixedFontDefaultSize, LegacyFontSizeMode);
static bool isTransparentColorValue(CSSValue*);
@@ -542,7 +542,7 @@
return false;
}
-void EditingStyle::setStyle(PassRefPtr<StylePropertySet> style)
+void EditingStyle::setStyle(PassRefPtr<MutableStylePropertySet> style)
{
m_mutableStyle = style;
// FIXME: We should be able to figure out whether or not font is fixed width for mutable style.
@@ -671,12 +671,12 @@
{
if (!style || !style->m_mutableStyle)
return FalseTriState;
- return triStateOfStyle(static_pointer_cast<MutableStylePropertySet>(style->m_mutableStyle)->ensureCSSStyleDeclaration(), DoNotIgnoreTextOnlyProperties);
+ return triStateOfStyle(style->m_mutableStyle->ensureCSSStyleDeclaration(), DoNotIgnoreTextOnlyProperties);
}
TriState EditingStyle::triStateOfStyle(CSSStyleDeclaration* styleToCompare, ShouldIgnoreTextOnlyProperties shouldIgnoreTextOnlyProperties) const
{
- RefPtr<StylePropertySet> difference = getPropertiesNotIn(m_mutableStyle.get(), styleToCompare);
+ RefPtr<MutableStylePropertySet> difference = getPropertiesNotIn(m_mutableStyle.get(), styleToCompare);
if (shouldIgnoreTextOnlyProperties == IgnoreTextOnlyProperties)
difference->removePropertiesInSet(textOnlyProperties, WTF_ARRAY_LENGTH(textOnlyProperties));
@@ -1108,7 +1108,7 @@
void EditingStyle::mergeStyleFromRules(StyledElement* element)
{
- RefPtr<StylePropertySet> styleFromMatchedRules = styleFromMatchedRulesForElement(element,
+ RefPtr<MutableStylePropertySet> styleFromMatchedRules = styleFromMatchedRulesForElement(element,
StyleResolver::AuthorCSSRules | StyleResolver::CrossOriginCSSRules);
// Styles from the inline style declaration, held in the variable "style", take precedence
// over those from matched rules.
@@ -1144,7 +1144,7 @@
m_mutableStyle->mergeAndOverrideOnConflict(fromComputedStyle.get());
}
-static void removePropertiesInStyle(StylePropertySet* styleToRemovePropertiesFrom, StylePropertySet* style)
+static void removePropertiesInStyle(MutableStylePropertySet* styleToRemovePropertiesFrom, StylePropertySet* style)
{
unsigned propertyCount = style->propertyCount();
Vector<CSSPropertyID> propertiesToRemove(propertyCount);
@@ -1172,7 +1172,7 @@
computedStyle->m_mutableStyle->setProperty(CSSPropertyBackgroundColor, CSSValueTransparent);
removePropertiesInStyle(computedStyle->m_mutableStyle.get(), styleFromMatchedRules.get());
- m_mutableStyle = getPropertiesNotIn(m_mutableStyle.get(), static_pointer_cast<MutableStylePropertySet>(computedStyle->m_mutableStyle)->ensureCSSStyleDeclaration());
+ m_mutableStyle = getPropertiesNotIn(m_mutableStyle.get(), computedStyle->m_mutableStyle->ensureCSSStyleDeclaration());
}
// 3. If this element is a span and has display: inline or float: none, remove them unless they are overriden by rules.
@@ -1331,7 +1331,7 @@
return foundDirection;
}
-static void reconcileTextDecorationProperties(StylePropertySet* style)
+static void reconcileTextDecorationProperties(MutableStylePropertySet* style)
{
RefPtr<CSSValue> textDecorationsInEffect = style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(CSSPropertyTextDecoration);
@@ -1362,7 +1362,7 @@
RefPtr<CSSComputedStyleDeclaration> computedStyle = position.computedStyle();
// FIXME: take care of background-color in effect
- RefPtr<StylePropertySet> mutableStyle = getPropertiesNotIn(style->style(), computedStyle.get());
+ RefPtr<MutableStylePropertySet> mutableStyle = getPropertiesNotIn(style->style(), computedStyle.get());
reconcileTextDecorationProperties(mutableStyle.get());
if (!document->frame()->editor()->shouldStyleWithCSS())
@@ -1381,7 +1381,7 @@
m_cssStyle = mutableStyle->asText().stripWhiteSpace();
}
-static void setTextDecorationProperty(StylePropertySet* style, const CSSValueList* newTextDecoration, CSSPropertyID propertyID)
+static void setTextDecorationProperty(MutableStylePropertySet* style, const CSSValueList* newTextDecoration, CSSPropertyID propertyID)
{
if (newTextDecoration->length())
style->setProperty(propertyID, newTextDecoration->cssText(), style->propertyIsImportant(propertyID));
@@ -1392,7 +1392,7 @@
}
}
-void StyleChange::extractTextStyles(Document* document, StylePropertySet* style, bool shouldUseFixedFontDefaultSize)
+void StyleChange::extractTextStyles(Document* document, MutableStylePropertySet* style, bool shouldUseFixedFontDefaultSize)
{
ASSERT(style);
@@ -1457,7 +1457,7 @@
}
}
-static void diffTextDecorations(StylePropertySet* style, CSSPropertyID propertID, CSSValue* refTextDecoration)
+static void diffTextDecorations(MutableStylePropertySet* style, CSSPropertyID propertID, CSSValue* refTextDecoration)
{
RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(propertID);
if (!textDecoration || !textDecoration->isValueList() || !refTextDecoration || !refTextDecoration->isValueList())
@@ -1515,7 +1515,7 @@
return fontWeightIsBold(fontWeight.get());
}
-PassRefPtr<StylePropertySet> getPropertiesNotIn(StylePropertySet* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle)
+PassRefPtr<MutableStylePropertySet> getPropertiesNotIn(StylePropertySet* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle)
{
ASSERT(styleWithRedundantProperties);
ASSERT(baseStyle);
@@ -1540,7 +1540,7 @@
if (baseStyle->getPropertyCSSValueInternal(CSSPropertyBackgroundColor) && getRGBABackgroundColor(result.get()) == getRGBABackgroundColor(baseStyle))
result->removeProperty(CSSPropertyBackgroundColor);
- return result;
+ return result.release();
}
int getIdentifierValue(StylePropertySet* style, CSSPropertyID propertyID)
diff --git a/Source/core/editing/EditingStyle.h b/Source/core/editing/EditingStyle.h
index f659453..9ae7ff1 100644
--- a/Source/core/editing/EditingStyle.h
+++ b/Source/core/editing/EditingStyle.h
@@ -50,6 +50,7 @@
class Document;
class Element;
class HTMLElement;
+class MutableStylePropertySet;
class Node;
class Position;
class QualifiedName;
@@ -98,10 +99,10 @@
~EditingStyle();
- StylePropertySet* style() { return m_mutableStyle.get(); }
+ MutableStylePropertySet* style() { return m_mutableStyle.get(); }
bool textDirection(WritingDirection&) const;
bool isEmpty() const;
- void setStyle(PassRefPtr<StylePropertySet>);
+ void setStyle(PassRefPtr<MutableStylePropertySet>);
void overrideWithStyle(const StylePropertySet*);
void clear();
PassRefPtr<EditingStyle> copy() const;
@@ -163,7 +164,7 @@
void mergeInlineAndImplicitStyleOfElement(StyledElement*, CSSPropertyOverrideMode, PropertiesToInclude);
void mergeStyle(const StylePropertySet*, CSSPropertyOverrideMode);
- RefPtr<StylePropertySet> m_mutableStyle;
+ RefPtr<MutableStylePropertySet> m_mutableStyle;
bool m_shouldUseFixedDefaultFontSize;
float m_fontSizeDelta;
@@ -217,7 +218,7 @@
return !(*this == other);
}
private:
- void extractTextStyles(Document*, StylePropertySet*, bool shouldUseFixedFontDefaultSize);
+ void extractTextStyles(Document*, MutableStylePropertySet*, bool shouldUseFixedFontDefaultSize);
String m_cssStyle;
bool m_applyBold;
diff --git a/Source/core/svg/SVGAnimateElement.cpp b/Source/core/svg/SVGAnimateElement.cpp
index b212469..c3d2bf1 100644
--- a/Source/core/svg/SVGAnimateElement.cpp
+++ b/Source/core/svg/SVGAnimateElement.cpp
@@ -239,7 +239,7 @@
{
ASSERT(!targetElement->m_deletionHasBegun);
- StylePropertySet* propertySet = targetElement->ensureAnimatedSMILStyleProperties();
+ MutableStylePropertySet* propertySet = targetElement->ensureAnimatedSMILStyleProperties();
if (!propertySet->setProperty(id, value, false, 0))
return;
diff --git a/Source/core/svg/SVGElement.cpp b/Source/core/svg/SVGElement.cpp
index 4a566a8..8e0a451 100644
--- a/Source/core/svg/SVGElement.cpp
+++ b/Source/core/svg/SVGElement.cpp
@@ -597,14 +597,14 @@
return document()->styleResolver()->styleForElement(correspondingElement(), style, DisallowStyleSharing);
}
-StylePropertySet* SVGElement::animatedSMILStyleProperties() const
+MutableStylePropertySet* SVGElement::animatedSMILStyleProperties() const
{
if (hasSVGRareData())
return svgRareData()->animatedSMILStyleProperties();
return 0;
}
-StylePropertySet* SVGElement::ensureAnimatedSMILStyleProperties()
+MutableStylePropertySet* SVGElement::ensureAnimatedSMILStyleProperties()
{
return ensureSVGRareData()->ensureAnimatedSMILStyleProperties();
}
diff --git a/Source/core/svg/SVGElement.h b/Source/core/svg/SVGElement.h
index d9939fd..a01c378 100644
--- a/Source/core/svg/SVGElement.h
+++ b/Source/core/svg/SVGElement.h
@@ -110,8 +110,8 @@
bool isAnimatableAttribute(const QualifiedName&) const;
#endif
- StylePropertySet* animatedSMILStyleProperties() const;
- StylePropertySet* ensureAnimatedSMILStyleProperties();
+ MutableStylePropertySet* animatedSMILStyleProperties() const;
+ MutableStylePropertySet* ensureAnimatedSMILStyleProperties();
void setUseOverrideComputedStyle(bool);
virtual bool haveLoadedRequiredResources();
diff --git a/Source/core/svg/SVGElementRareData.h b/Source/core/svg/SVGElementRareData.h
index 8adec52..f86b0ab 100644
--- a/Source/core/svg/SVGElementRareData.h
+++ b/Source/core/svg/SVGElementRareData.h
@@ -75,8 +75,8 @@
CSSCursorImageValue* cursorImageValue() const { return m_cursorImageValue; }
void setCursorImageValue(CSSCursorImageValue* cursorImageValue) { m_cursorImageValue = cursorImageValue; }
- StylePropertySet* animatedSMILStyleProperties() const { return m_animatedSMILStyleProperties.get(); }
- StylePropertySet* ensureAnimatedSMILStyleProperties()
+ MutableStylePropertySet* animatedSMILStyleProperties() const { return m_animatedSMILStyleProperties.get(); }
+ MutableStylePropertySet* ensureAnimatedSMILStyleProperties()
{
if (!m_animatedSMILStyleProperties)
m_animatedSMILStyleProperties = MutableStylePropertySet::create(SVGAttributeMode);
@@ -114,7 +114,7 @@
bool m_instancesUpdatesBlocked : 1;
bool m_useOverrideComputedStyle : 1;
bool m_needsOverrideComputedStyleUpdate : 1;
- RefPtr<StylePropertySet> m_animatedSMILStyleProperties;
+ RefPtr<MutableStylePropertySet> m_animatedSMILStyleProperties;
RefPtr<RenderStyle> m_overrideComputedStyle;
};