Diff
Modified: trunk/Source/WebCore/ChangeLog (108666 => 108667)
--- trunk/Source/WebCore/ChangeLog 2012-02-23 21:09:18 UTC (rev 108666)
+++ trunk/Source/WebCore/ChangeLog 2012-02-23 21:15:16 UTC (rev 108667)
@@ -1,3 +1,38 @@
+2012-02-23 Andreas Kling <[email protected]>
+
+ Make use of StylePropertySet::setProperty(propertyID, CSSValue).
+ <http://webkit.org/b/79374>
+
+ Reviewed by Antti Koivisto.
+
+ Use the new setProperty() overload that takes a CSSValue in more places. This allows us
+ to get rid of 1/3 setProperty() overloads that don't expand shorthands.
+
+ * css/StylePropertySet.h:
+ * css/StylePropertySet.cpp:
+
+ Remove the setProperty() overload for specific primitive value types. StyledElement
+ can take care of this without help from StylePropertySet.
+
+ * dom/StyledElement.h:
+ * dom/StyledElement.cpp:
+ (WebCore::StyledElement::setInlineStyleProperty):
+ (WebCore::StyledElement::addPropertyToAttributeStyle):
+
+ Switch some functions over to using the setProperty() overload that takes a CSSValue.
+
+ * html/HTMLElement.cpp:
+ (WebCore::HTMLElement::applyBorderAttributeToStyle):
+ * html/HTMLHRElement.cpp:
+ (WebCore::HTMLHRElement::collectStyleForAttribute):
+ * html/HTMLTableElement.cpp:
+ (WebCore::HTMLTableElement::collectStyleForAttribute):
+ * html/HTMLTablePartElement.cpp:
+ (WebCore::HTMLTablePartElement::collectStyleForAttribute):
+
+ Use shorthands where possible to shrink the code a bit. Pass border widths as CSS_PX
+ values directly instead of making a CSSParser round-trip.
+
2012-02-23 Kevin Ollivier <[email protected]>
[wx] Build fix, use the strings in LocalizedStrings.cpp.
Modified: trunk/Source/WebCore/css/StylePropertySet.cpp (108666 => 108667)
--- trunk/Source/WebCore/css/StylePropertySet.cpp 2012-02-23 21:09:18 UTC (rev 108666)
+++ trunk/Source/WebCore/css/StylePropertySet.cpp 2012-02-23 21:15:16 UTC (rev 108667)
@@ -621,17 +621,6 @@
return true;
}
-bool StylePropertySet::setProperty(int propertyID, double number, CSSPrimitiveValue::UnitTypes unit, bool important, CSSStyleSheet* contextStyleSheet)
-{
- 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, CSSStyleSheet* contextStyleSheet)
{
m_properties.clear();
Modified: trunk/Source/WebCore/css/StylePropertySet.h (108666 => 108667)
--- trunk/Source/WebCore/css/StylePropertySet.h 2012-02-23 21:09:18 UTC (rev 108666)
+++ trunk/Source/WebCore/css/StylePropertySet.h 2012-02-23 21:15:16 UTC (rev 108667)
@@ -70,7 +70,6 @@
// These do not. FIXME: This is too messy, we can do better.
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);
void setProperty(const CSSProperty&, CSSProperty* slot = 0);
bool removeProperty(int propertyID, String* returnText = 0);
Modified: trunk/Source/WebCore/dom/StyledElement.cpp (108666 => 108667)
--- trunk/Source/WebCore/dom/StyledElement.cpp 2012-02-23 21:09:18 UTC (rev 108666)
+++ trunk/Source/WebCore/dom/StyledElement.cpp 2012-02-23 21:15:16 UTC (rev 108667)
@@ -116,20 +116,18 @@
InspectorInstrumentation::didInvalidateStyleAttr(document(), this);
}
-bool StyledElement::setInlineStyleProperty(int propertyID, int value, bool important)
+bool StyledElement::setInlineStyleProperty(int propertyID, int identifier, bool important)
{
- bool changes = ensureInlineStyleDecl()->setProperty(propertyID, value, important, document()->elementSheet());
- if (changes)
- inlineStyleChanged();
- return changes;
+ ensureInlineStyleDecl()->setProperty(propertyID, document()->cssValuePool()->createIdentifierValue(identifier), important);
+ inlineStyleChanged();
+ return true;
}
bool StyledElement::setInlineStyleProperty(int propertyID, double value, CSSPrimitiveValue::UnitTypes unit, bool important)
{
- bool changes = ensureInlineStyleDecl()->setProperty(propertyID, value, unit, important, document()->elementSheet());
- if (changes)
- inlineStyleChanged();
- return changes;
+ ensureInlineStyleDecl()->setProperty(propertyID, document()->cssValuePool()->createValue(value, unit), important);
+ inlineStyleChanged();
+ return true;
}
bool StyledElement::setInlineStyleProperty(int propertyID, const String& value, bool important)
@@ -171,4 +169,14 @@
}
}
+void StyledElement::addPropertyToAttributeStyle(StylePropertySet* style, int propertyID, int identifier)
+{
+ style->setProperty(propertyID, document()->cssValuePool()->createIdentifierValue(identifier));
}
+
+void StyledElement::addPropertyToAttributeStyle(StylePropertySet* style, int propertyID, double value, CSSPrimitiveValue::UnitTypes unit)
+{
+ style->setProperty(propertyID, document()->cssValuePool()->createValue(value, unit));
+}
+
+}
Modified: trunk/Source/WebCore/dom/StyledElement.h (108666 => 108667)
--- trunk/Source/WebCore/dom/StyledElement.h 2012-02-23 21:09:18 UTC (rev 108666)
+++ trunk/Source/WebCore/dom/StyledElement.h 2012-02-23 21:15:16 UTC (rev 108667)
@@ -43,7 +43,7 @@
StylePropertySet* ensureInlineStyleDecl() { return ensureAttributeData()->ensureInlineStyleDecl(this); }
// Unlike StylePropertySet setters, these implement invalidation.
- bool setInlineStyleProperty(int propertyID, int value, bool important = false);
+ bool setInlineStyleProperty(int propertyID, int identifier, 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,7 +67,7 @@
virtual bool isPresentationAttribute(Attribute*) const { return false; }
virtual void collectStyleForAttribute(Attribute*, StylePropertySet*) { }
- void addPropertyToAttributeStyle(StylePropertySet*, int propertyID, int value);
+ void addPropertyToAttributeStyle(StylePropertySet*, int propertyID, int identifier);
void addPropertyToAttributeStyle(StylePropertySet*, int propertyID, double value, CSSPrimitiveValue::UnitTypes);
void addPropertyToAttributeStyle(StylePropertySet*, int propertyID, const String& value);
@@ -110,16 +110,6 @@
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());
Modified: trunk/Source/WebCore/html/HTMLElement.cpp (108666 => 108667)
--- trunk/Source/WebCore/html/HTMLElement.cpp 2012-02-23 21:09:18 UTC (rev 108666)
+++ trunk/Source/WebCore/html/HTMLElement.cpp 2012-02-23 21:15:16 UTC (rev 108667)
@@ -143,11 +143,8 @@
void HTMLElement::applyBorderAttributeToStyle(Attribute* attr, StylePropertySet* style)
{
- addPropertyToAttributeStyle(style, CSSPropertyBorderWidth, String::number(parseBorderWidthAttribute(attr)));
- addPropertyToAttributeStyle(style, CSSPropertyBorderTopStyle, CSSValueSolid);
- addPropertyToAttributeStyle(style, CSSPropertyBorderRightStyle, CSSValueSolid);
- addPropertyToAttributeStyle(style, CSSPropertyBorderBottomStyle, CSSValueSolid);
- addPropertyToAttributeStyle(style, CSSPropertyBorderLeftStyle, CSSValueSolid);
+ addPropertyToAttributeStyle(style, CSSPropertyBorderWidth, parseBorderWidthAttribute(attr), CSSPrimitiveValue::CSS_PX);
+ addPropertyToAttributeStyle(style, CSSPropertyBorderStyle, CSSValueSolid);
}
void HTMLElement::mapLanguageAttributeToLocale(Attribute* attribute, StylePropertySet* style)
Modified: trunk/Source/WebCore/html/HTMLHRElement.cpp (108666 => 108667)
--- trunk/Source/WebCore/html/HTMLHRElement.cpp 2012-02-23 21:09:18 UTC (rev 108666)
+++ trunk/Source/WebCore/html/HTMLHRElement.cpp 2012-02-23 21:15:16 UTC (rev 108667)
@@ -26,6 +26,7 @@
#include "Attribute.h"
#include "CSSPropertyNames.h"
#include "CSSValueKeywords.h"
+#include "CSSValuePool.h"
#include "HTMLNames.h"
namespace WebCore {
@@ -76,19 +77,15 @@
else
addHTMLLengthToStyle(style, CSSPropertyWidth, attr->value());
} else if (attr->name() == colorAttr) {
- addPropertyToAttributeStyle(style, CSSPropertyBorderTopStyle, CSSValueSolid);
- addPropertyToAttributeStyle(style, CSSPropertyBorderRightStyle, CSSValueSolid);
- addPropertyToAttributeStyle(style, CSSPropertyBorderBottomStyle, CSSValueSolid);
- addPropertyToAttributeStyle(style, CSSPropertyBorderLeftStyle, CSSValueSolid);
+ addPropertyToAttributeStyle(style, CSSPropertyBorderStyle, CSSValueSolid);
addHTMLColorToStyle(style, CSSPropertyBorderColor, attr->value());
addHTMLColorToStyle(style, CSSPropertyBackgroundColor, attr->value());
} else if (attr->name() == noshadeAttr) {
- 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.
+ addPropertyToAttributeStyle(style, CSSPropertyBorderStyle, CSSValueSolid);
+
+ RefPtr<CSSPrimitiveValue> darkGrayValue = document()->cssValuePool()->createColorValue(Color::darkGray);
+ style->setProperty(CSSPropertyBorderColor, darkGrayValue);
+ style->setProperty(CSSPropertyBackgroundColor, darkGrayValue);
} else if (attr->name() == sizeAttr) {
StringImpl* si = attr->value().impl();
int size = si->toInt();
Modified: trunk/Source/WebCore/html/HTMLTableElement.cpp (108666 => 108667)
--- trunk/Source/WebCore/html/HTMLTableElement.cpp 2012-02-23 21:09:18 UTC (rev 108666)
+++ trunk/Source/WebCore/html/HTMLTableElement.cpp 2012-02-23 21:15:16 UTC (rev 108667)
@@ -341,10 +341,7 @@
bool borderBottom;
bool borderLeft;
if (getBordersFromFrameAttributeValue(attr->value(), borderTop, borderRight, borderBottom, borderLeft)) {
- addPropertyToAttributeStyle(style, CSSPropertyBorderTopWidth, CSSValueThin);
- addPropertyToAttributeStyle(style, CSSPropertyBorderBottomWidth, CSSValueThin);
- addPropertyToAttributeStyle(style, CSSPropertyBorderLeftWidth, CSSValueThin);
- addPropertyToAttributeStyle(style, CSSPropertyBorderRightWidth, CSSValueThin);
+ addPropertyToAttributeStyle(style, CSSPropertyBorderWidth, CSSValueThin);
addPropertyToAttributeStyle(style, CSSPropertyBorderTopStyle, borderTop ? CSSValueSolid : CSSValueHidden);
addPropertyToAttributeStyle(style, CSSPropertyBorderBottomStyle, borderBottom ? CSSValueSolid : CSSValueHidden);
addPropertyToAttributeStyle(style, CSSPropertyBorderLeftStyle, borderLeft ? CSSValueSolid : CSSValueHidden);
Modified: trunk/Source/WebCore/html/HTMLTablePartElement.cpp (108666 => 108667)
--- trunk/Source/WebCore/html/HTMLTablePartElement.cpp 2012-02-23 21:09:18 UTC (rev 108666)
+++ trunk/Source/WebCore/html/HTMLTablePartElement.cpp 2012-02-23 21:15:16 UTC (rev 108667)
@@ -56,10 +56,7 @@
} else if (attr->name() == bordercolorAttr) {
if (!attr->value().isEmpty()) {
addHTMLColorToStyle(style, CSSPropertyBorderColor, attr->value());
- addPropertyToAttributeStyle(style, CSSPropertyBorderTopStyle, CSSValueSolid);
- addPropertyToAttributeStyle(style, CSSPropertyBorderBottomStyle, CSSValueSolid);
- addPropertyToAttributeStyle(style, CSSPropertyBorderLeftStyle, CSSValueSolid);
- addPropertyToAttributeStyle(style, CSSPropertyBorderRightStyle, CSSValueSolid);
+ addPropertyToAttributeStyle(style, CSSPropertyBorderStyle, CSSValueSolid);
}
} else if (attr->name() == valignAttr) {
if (!attr->value().isEmpty())