https://bugs.webkit.org/show_bug.cgi?id=77545
Reviewed by Andreas Kling.
This is the easiest path for eliminating the last remaining subclass of CSSMutableStyleDeclaration.
On negative side this increases memory use of CSSMappedAttributeDeclaration by one ptr and refcount
(it loses the vptr) in total.
This is not meant to be the end state, just an intermediate refactoring step. CSSMappedAttributeDeclaration
should clearly be renamed too but this patch doesn't do that. It might not exist in its current form
much longer.
* css/CSSMutableStyleDeclaration.cpp:
(WebCore::CSSMutableStyleDeclaration::setProperty):
(WebCore::CSSMutableStyleDeclaration::merge):
* css/CSSMutableStyleDeclaration.h:
Remove protected section. No subclasses remain.
Rename setPropertyInternal() to setProperty(). All public methods here are internal.
(CSSMutableStyleDeclaration):
* css/CSSParser.cpp:
(WebCore::CSSParser::parseMappedAttributeValue):
* dom/Attribute.cpp:
(WebCore::Attribute::clone):
* dom/Attribute.h:
(Attribute):
(WebCore::Attribute::decl):
(WebCore::Attribute::mappedAttributeDeclaration):
(WebCore::Attribute::setMappedAttributeDeclaration):
(WebCore::Attribute::Attribute):
* dom/CSSMappedAttributeDeclaration.cpp:
(WebCore::CSSMappedAttributeDeclaration::setMappedImageProperty):
(WebCore::CSSMappedAttributeDeclaration::setMappedProperty):
(WebCore::CSSMappedAttributeDeclaration::removeMappedProperty):
* dom/CSSMappedAttributeDeclaration.h:
(CSSMappedAttributeDeclaration):
(WebCore::CSSMappedAttributeDeclaration::declaration):
(WebCore::CSSMappedAttributeDeclaration::CSSMappedAttributeDeclaration):
Make CSSMutableStyleDeclaration a member instead of the base class.
* dom/StyledElement.cpp:
(WebCore::StyledElement::attributeChanged):
(WebCore::StyledElement::removeCSSProperty):
(WebCore::StyledElement::addCSSProperty):
(WebCore::StyledElement::addCSSImageProperty):
(WebCore::StyledElement::addCSSLength):
(WebCore::StyledElement::addCSSColor):
(WebCore::StyledElement::createMappedDecl):
* svg/SVGStyledElement.cpp:
(WebCore::SVGStyledElement::getPresentationAttribute):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@106471
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-02-01 Antti Koivisto <antti@apple.com>
+
+ Make CSSMappedAttributeDeclaration have CSSMutableStyleDeclaration instead of being one
+ https://bugs.webkit.org/show_bug.cgi?id=77545
+
+ Reviewed by Andreas Kling.
+
+ This is the easiest path for eliminating the last remaining subclass of CSSMutableStyleDeclaration.
+
+ On negative side this increases memory use of CSSMappedAttributeDeclaration by one ptr and refcount
+ (it loses the vptr) in total.
+
+ This is not meant to be the end state, just an intermediate refactoring step. CSSMappedAttributeDeclaration
+ should clearly be renamed too but this patch doesn't do that. It might not exist in its current form
+ much longer.
+
+ * css/CSSMutableStyleDeclaration.cpp:
+ (WebCore::CSSMutableStyleDeclaration::setProperty):
+ (WebCore::CSSMutableStyleDeclaration::merge):
+ * css/CSSMutableStyleDeclaration.h:
+
+ Remove protected section. No subclasses remain.
+ Rename setPropertyInternal() to setProperty(). All public methods here are internal.
+
+ (CSSMutableStyleDeclaration):
+ * css/CSSParser.cpp:
+ (WebCore::CSSParser::parseMappedAttributeValue):
+ * dom/Attribute.cpp:
+ (WebCore::Attribute::clone):
+ * dom/Attribute.h:
+ (Attribute):
+ (WebCore::Attribute::decl):
+ (WebCore::Attribute::mappedAttributeDeclaration):
+ (WebCore::Attribute::setMappedAttributeDeclaration):
+ (WebCore::Attribute::Attribute):
+ * dom/CSSMappedAttributeDeclaration.cpp:
+ (WebCore::CSSMappedAttributeDeclaration::setMappedImageProperty):
+ (WebCore::CSSMappedAttributeDeclaration::setMappedProperty):
+ (WebCore::CSSMappedAttributeDeclaration::removeMappedProperty):
+ * dom/CSSMappedAttributeDeclaration.h:
+ (CSSMappedAttributeDeclaration):
+ (WebCore::CSSMappedAttributeDeclaration::declaration):
+ (WebCore::CSSMappedAttributeDeclaration::CSSMappedAttributeDeclaration):
+
+ Make CSSMutableStyleDeclaration a member instead of the base class.
+
+ * dom/StyledElement.cpp:
+ (WebCore::StyledElement::attributeChanged):
+ (WebCore::StyledElement::removeCSSProperty):
+ (WebCore::StyledElement::addCSSProperty):
+ (WebCore::StyledElement::addCSSImageProperty):
+ (WebCore::StyledElement::addCSSLength):
+ (WebCore::StyledElement::addCSSColor):
+ (WebCore::StyledElement::createMappedDecl):
+ * svg/SVGStyledElement.cpp:
+ (WebCore::SVGStyledElement::getPresentationAttribute):
+
2012-02-01 Allan Sandfeld Jensen <allan.jensen@nokia.com>
[Qt] Set all PlatformTouchPoint values possible from a QTouch event.
return true;
}
-void CSSMutableStyleDeclaration::setPropertyInternal(const CSSProperty& property, CSSProperty* slot)
+void CSSMutableStyleDeclaration::setProperty(const CSSProperty& property, CSSProperty* slot)
{
#if ENABLE(MUTATION_OBSERVERS)
StyleAttributeMutationScope mutationScope(this);
bool CSSMutableStyleDeclaration::setProperty(int propertyID, int value, bool important, bool notifyChanged)
{
CSSProperty property(propertyID, CSSPrimitiveValue::createIdentifier(value), important);
- setPropertyInternal(property);
+ setProperty(property);
if (notifyChanged)
setNeedsStyleRecalc();
return true;
bool CSSMutableStyleDeclaration::setProperty(int propertyID, double value, CSSPrimitiveValue::UnitTypes unit, bool important, bool notifyChanged)
{
CSSProperty property(propertyID, CSSPrimitiveValue::create(value, unit), important);
- setPropertyInternal(property);
+ setProperty(property);
if (notifyChanged)
setNeedsStyleRecalc();
return true;
if (old) {
if (!argOverridesOnConflict && old->value())
continue;
- setPropertyInternal(toMerge, old);
+ setProperty(toMerge, old);
} else
m_properties.append(toMerge);
}
bool setProperty(int propertyID, int value, bool important = false) { return setProperty(propertyID, value, important, true); }
bool setProperty(int propertyId, double value, CSSPrimitiveValue::UnitTypes unit, bool important = false) { return setProperty(propertyId, value, unit, important, true); }
bool setProperty(int propertyID, const String& value, bool important = false) { return setProperty(propertyID, value, important, true); }
-
+ void setProperty(const CSSProperty&, CSSProperty* slot = 0);
+
void removeProperty(int propertyID) { removeProperty(propertyID, true, false); }
+ String removeProperty(int propertyID, bool notifyChanged, bool returnText);
// The following parses an entire new style declaration.
void parseDeclaration(const String& styleDeclaration);
String asText() const;
-protected:
- CSSMutableStyleDeclaration();
-
- void setPropertyInternal(const CSSProperty&, CSSProperty* slot = 0);
- String removeProperty(int propertyID, bool notifyChanged, bool returnText);
-
private:
+ CSSMutableStyleDeclaration();
CSSMutableStyleDeclaration(CSSRule* parentRule);
CSSMutableStyleDeclaration(CSSRule* parentRule, const Vector<CSSProperty>&);
CSSMutableStyleDeclaration(CSSRule* parentRule, const CSSProperty* const *, int numProperties);
return true;
}
-bool CSSParser::parseMappedAttributeValue(CSSMappedAttributeDeclaration* declaration, StyledElement* element, int propertyId, const String& value)
+bool CSSParser::parseMappedAttributeValue(CSSMappedAttributeDeclaration* mappedAttribute, StyledElement* element, int propertyId, const String& value)
{
- ASSERT(declaration);
+ ASSERT(mappedAttribute);
ASSERT(element);
ASSERT(element->document());
CSSStyleSheet* elementSheet = element->document()->elementSheet();
- if (parseSimpleLengthValue(declaration, propertyId, value, false, false, elementSheet))
+ if (parseSimpleLengthValue(mappedAttribute->declaration(), propertyId, value, false, false, elementSheet))
return true;
- if (parseColorValue(declaration, propertyId, value, false, false, elementSheet))
+ if (parseColorValue(mappedAttribute->declaration(), propertyId, value, false, false, elementSheet))
return true;
CSSParser parser(false);
- return parser.parseValue(declaration, propertyId, value, false, elementSheet);
+ return parser.parseValue(mappedAttribute->declaration(), propertyId, value, false, elementSheet);
}
bool CSSParser::parseValue(CSSMutableStyleDeclaration* declaration, int propertyId, const String& string, bool important, bool strict)
PassRefPtr<Attribute> Attribute::clone() const
{
- return adoptRef(new Attribute(m_name, m_value, m_isMappedAttribute, m_styleDecl.get()));
+ return adoptRef(new Attribute(m_name, m_value, m_isMappedAttribute, m_mappedAttributeDeclaration.get()));
}
Attr* Attribute::attr() const
bool isEmpty() const { return m_value.isEmpty(); }
PassRefPtr<Attribute> clone() const;
+
+ CSSMutableStyleDeclaration* decl() const { return m_mappedAttributeDeclaration ? m_mappedAttributeDeclaration->declaration() : 0; }
- CSSMappedAttributeDeclaration* decl() const { return m_styleDecl.get(); }
- void setDecl(PassRefPtr<CSSMappedAttributeDeclaration> decl) { m_styleDecl = decl; }
+ CSSMappedAttributeDeclaration* mappedAttributeDeclaration() const { return m_mappedAttributeDeclaration.get(); }
+ void setMappedAttributeDeclaration(PassRefPtr<CSSMappedAttributeDeclaration> decl) { m_mappedAttributeDeclaration = decl; }
void setValue(const AtomicString& value) { m_value = value; }
void setPrefix(const AtomicString& prefix) { m_name.setPrefix(prefix); }
, m_hasAttr(false)
, m_name(name)
, m_value(value)
- , m_styleDecl(styleDecl)
+ , m_mappedAttributeDeclaration(styleDecl)
{
}
, m_hasAttr(false)
, m_name(nullAtom, name, nullAtom)
, m_value(value)
- , m_styleDecl(styleDecl)
+ , m_mappedAttributeDeclaration(styleDecl)
{
}
QualifiedName m_name;
AtomicString m_value;
- RefPtr<CSSMappedAttributeDeclaration> m_styleDecl;
+ RefPtr<CSSMappedAttributeDeclaration> m_mappedAttributeDeclaration;
};
} // namespace WebCore
void CSSMappedAttributeDeclaration::setMappedImageProperty(StyledElement* element, int propertyId, const String& url)
{
- setPropertyInternal(CSSProperty(propertyId, CSSImageValue::create(url)));
+ m_declaration->setProperty(CSSProperty(propertyId, CSSImageValue::create(url)));
setNeedsStyleRecalc(element);
}
void CSSMappedAttributeDeclaration::setMappedProperty(StyledElement* element, int propertyId, int value)
{
ASSERT(element->document());
- setPropertyInternal(CSSProperty(propertyId, element->document()->cssValuePool()->createIdentifierValue(value)));
+ m_declaration->setProperty(CSSProperty(propertyId, element->document()->cssValuePool()->createIdentifierValue(value)));
setNeedsStyleRecalc(element);
}
void CSSMappedAttributeDeclaration::removeMappedProperty(StyledElement* element, int propertyId)
{
- removeProperty(propertyId, false, false);
+ m_declaration->removeProperty(propertyId, false, false);
setNeedsStyleRecalc(element);
}
class StyledElement;
-class CSSMappedAttributeDeclaration : public CSSMutableStyleDeclaration {
+class CSSMappedAttributeDeclaration : public RefCounted<CSSMappedAttributeDeclaration> {
public:
static PassRefPtr<CSSMappedAttributeDeclaration> create()
{
return adoptRef(new CSSMappedAttributeDeclaration);
}
- virtual ~CSSMappedAttributeDeclaration();
+ ~CSSMappedAttributeDeclaration();
void setMappedState(MappedAttributeEntry type, const QualifiedName& name, const AtomicString& val)
{
void setMappedLengthProperty(StyledElement*, int propertyId, const String& value);
void removeMappedProperty(StyledElement*, int propertyId);
+
+ CSSMutableStyleDeclaration* declaration() const { return m_declaration.get(); }
private:
CSSMappedAttributeDeclaration()
- : CSSMutableStyleDeclaration()
+ : m_declaration(CSSMutableStyleDeclaration::create())
, m_entryType(eNone)
, m_attrName(anyQName())
{
void setNeedsStyleRecalc(StyledElement*);
+ RefPtr<CSSMutableStyleDeclaration> m_declaration;
MappedAttributeEntry m_entryType;
QualifiedName m_attrName;
AtomicString m_attrValue;
return;
}
- if (attr->decl() && !preserveDecls) {
- attr->setDecl(0);
+ if (attr->mappedAttributeDeclaration() && !preserveDecls) {
+ attr->setMappedAttributeDeclaration(0);
setNeedsStyleRecalc();
}
MappedAttributeEntry entry;
bool needToParse = mapToEntry(attr->name(), entry);
if (preserveDecls) {
- if (attr->decl()) {
+ if (attr->mappedAttributeDeclaration()) {
setNeedsStyleRecalc();
checkDecl = false;
}
} else if (!attr->isNull() && entry != eNone) {
CSSMappedAttributeDeclaration* decl = getMappedAttributeDecl(entry, attr);
if (decl) {
- attr->setDecl(decl);
+ attr->setMappedAttributeDeclaration(decl);
setNeedsStyleRecalc();
checkDecl = false;
} else
if (entry == eNone)
recalcStyleIfNeededAfterAttributeChanged(attr);
- if (checkDecl && attr->decl()) {
+ if (checkDecl && attr->mappedAttributeDeclaration()) {
// Add the decl to the table in the appropriate spot.
- setMappedAttributeDecl(entry, attr, attr->decl());
- attr->decl()->setMappedState(entry, attr->name(), attr->value());
+ setMappedAttributeDecl(entry, attr, attr->mappedAttributeDeclaration());
+ attr->mappedAttributeDeclaration()->setMappedState(entry, attr->name(), attr->value());
}
updateAfterAttributeChanged(attr);
void StyledElement::removeCSSProperty(Attribute* attribute, int id)
{
- if (!attribute->decl())
+ if (!attribute->mappedAttributeDeclaration())
createMappedDecl(attribute);
- attribute->decl()->removeMappedProperty(this, id);
+ attribute->mappedAttributeDeclaration()->removeMappedProperty(this, id);
}
void StyledElement::addCSSProperty(Attribute* attribute, int id, const String &value)
{
- if (!attribute->decl())
+ if (!attribute->mappedAttributeDeclaration())
createMappedDecl(attribute);
- attribute->decl()->setMappedProperty(this, id, value);
+ attribute->mappedAttributeDeclaration()->setMappedProperty(this, id, value);
}
void StyledElement::addCSSProperty(Attribute* attribute, int id, int value)
{
- if (!attribute->decl())
+ if (!attribute->mappedAttributeDeclaration())
createMappedDecl(attribute);
- attribute->decl()->setMappedProperty(this, id, value);
+ attribute->mappedAttributeDeclaration()->setMappedProperty(this, id, value);
}
void StyledElement::addCSSImageProperty(Attribute* attribute, int id, const String& url)
{
- if (!attribute->decl())
+ if (!attribute->mappedAttributeDeclaration())
createMappedDecl(attribute);
- attribute->decl()->setMappedImageProperty(this, id, url);
+ attribute->mappedAttributeDeclaration()->setMappedImageProperty(this, id, url);
}
void StyledElement::addCSSLength(Attribute* attribute, int id, const String &value)
{
// FIXME: This function should not spin up the CSS parser, but should instead just figure out the correct
// length unit and make the appropriate parsed value.
- if (!attribute->decl())
+ if (!attribute->mappedAttributeDeclaration())
createMappedDecl(attribute);
// strip attribute garbage..
}
if (l != v->length()) {
- attribute->decl()->setMappedLengthProperty(this, id, v->substring(0, l));
+ attribute->mappedAttributeDeclaration()->setMappedLengthProperty(this, id, v->substring(0, l));
return;
}
}
- attribute->decl()->setMappedLengthProperty(this, id, value);
+ attribute->mappedAttributeDeclaration()->setMappedLengthProperty(this, id, value);
}
static String parseColorStringWithCrazyLegacyRules(const String& colorString)
if (equalIgnoringCase(colorString, "transparent"))
return;
- if (!attribute->decl())
+ if (!attribute->mappedAttributeDeclaration())
createMappedDecl(attribute);
// If the string is a named CSS color or a 3/6-digit hex color, use that.
Color parsedColor(colorString);
if (parsedColor.isValid()) {
- attribute->decl()->setMappedProperty(this, id, colorString);
+ attribute->mappedAttributeDeclaration()->setMappedProperty(this, id, colorString);
return;
}
- attribute->decl()->setMappedProperty(this, id, parseColorStringWithCrazyLegacyRules(colorString));
+ attribute->mappedAttributeDeclaration()->setMappedProperty(this, id, parseColorStringWithCrazyLegacyRules(colorString));
}
void StyledElement::createMappedDecl(Attribute* attr)
{
RefPtr<CSSMappedAttributeDeclaration> decl = CSSMappedAttributeDeclaration::create();
- attr->setDecl(decl);
- ASSERT(!decl->useStrictParsing());
+ attr->setMappedAttributeDeclaration(decl);
+ ASSERT(!decl->declaration()->useStrictParsing());
}
unsigned MappedAttributeHash::hash(const MappedAttributeKey& key)
QualifiedName attributeName(nullAtom, name, nullAtom);
Attribute* attr = attributeMap()->getAttributeItem(attributeName);
- if (!attr || !attr->isMappedAttribute() || !attr->decl())
+ if (!attr || !attr->isMappedAttribute() || !attr->mappedAttributeDeclaration())
return 0;
Attribute* cssSVGAttr = attr;
// before returning so that any modifications to the CSSValue will not affect other attributes.
MappedAttributeEntry entry;
mapToEntry(attributeName, entry);
- if (getMappedAttributeDecl(entry, cssSVGAttr) == cssSVGAttr->decl()) {
- cssSVGAttr->setDecl(0);
+ if (getMappedAttributeDecl(entry, cssSVGAttr) == cssSVGAttr->mappedAttributeDeclaration()) {
+ cssSVGAttr->setMappedAttributeDeclaration(0);
int propId = SVGStyledElement::cssPropertyIdForSVGAttributeName(cssSVGAttr->name());
addCSSProperty(cssSVGAttr, propId, cssSVGAttr->value());
}