+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
void CSSFontFaceRule::addSubresourceStyleURLs(ListHashSet<KURL>& urls)
{
if (m_style)
- m_style->addSubresourceStyleURLs(urls);
+ m_style->addSubresourceStyleURLs(urls, parentStyleSheet());
}
} // namespace WebCore
}
}
-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;
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;
}
}
}
-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();
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, "} ");
// 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();
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) {
}
}
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());
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());
}
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();
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;
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,
void CSSStyleRule::addSubresourceStyleURLs(ListHashSet<KURL>& urls)
{
if (m_style)
- m_style->addSubresourceStyleURLs(urls);
+ m_style->addSubresourceStyleURLs(urls, parentStyleSheet());
}
} // namespace WebCore
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(); }
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;
virtual CSSRule* parentRule() const { return m_parentRule; };
virtual void clearParentRule() { m_parentRule = 0; }
virtual void setNeedsStyleRecalc();
+ virtual CSSStyleSheet* contextStyleSheet() const;
CSSRule* m_parentRule;
};
virtual StyledElement* parentElement() const { return m_parentElement; }
virtual void clearParentElement() { m_parentElement = 0; }
virtual void setNeedsStyleRecalc();
+ virtual CSSStyleSheet* contextStyleSheet() const;
StyledElement* m_parentElement;
};
StylePropertySet::StylePropertySet()
: m_strictParsing(false)
, m_hasCSSOMWrapper(false)
- , m_contextStyleSheet(0)
{
}
: 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;
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.
// 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)
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);
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)
}
}
-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.
void StylePropertySet::clearParentRule(CSSRule* rule)
{
- m_contextStyleSheet = 0;
if (!m_hasCSSOMWrapper)
return;
ASSERT_UNUSED(rule, static_cast<CSSStyleDeclaration*>(propertySetCSSOMWrapperMap().get(this))->parentRule() == rule);
void StylePropertySet::clearParentElement(StyledElement* element)
{
- m_contextStyleSheet = 0;
if (!m_hasCSSOMWrapper)
return;
ASSERT_UNUSED(element, propertySetCSSOMWrapperMap().get(this)->parentElement() == element);
#endif
ec = 0;
// FIXME: Detect syntax errors and set ec.
- m_propertySet->parseDeclaration(text);
+ m_propertySet->parseDeclaration(text, contextStyleSheet());
setNeedsStyleRecalc();
#if ENABLE(MUTATION_OBSERVERS)
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>.
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)
CSSStyleSheet* PropertySetCSSStyleDeclaration::parentStyleSheet() const
{
- return m_propertySet->contextStyleSheet();
+ return contextStyleSheet();
}
PassRefPtr<StylePropertySet> PropertySetCSSStyleDeclaration::copy() const
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()
{
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);
{
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)
{
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.
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().
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;
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();
bool m_strictParsing : 1;
mutable bool m_hasCSSOMWrapper : 1;
-
- CSSStyleSheet* m_contextStyleSheet;
friend class PropertySetCSSStyleDeclaration;
};
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);
{
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();
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()))
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);
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;
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;
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;
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());
// 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);
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;
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
// <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);
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);
}
{
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);
}
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)
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);
}
}
{
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);
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
}
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)
// 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)
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*);
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);
}
{
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;
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
} 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);
}
{
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);
}
} 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);
}
{
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);
}
{
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);
}
{
if (attr->name() == alignAttr) {
if (!attr->isEmpty())
- style->setProperty(CSSPropertyCaptionSide, attr->value());
+ addPropertyToAttributeStyle(style, CSSPropertyCaptionSide, attr->value());
} else
HTMLElement::collectStyleForAttribute(attr, style);
}
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();
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());
} 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);
} 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());
{
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);
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);
}
String declarationText("font: ");
declarationText += newFont;
- parser.parseDeclaration(tempDecl.get(), declarationText);
+ parser.parseDeclaration(tempDecl.get(), declarationText, 0, 0);
if (tempDecl->isEmpty())
return;
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);
SVGElement::insertedIntoDocument();
document()->mappedElementSheet()->append(m_fontFaceRule);
m_fontFaceRule->setParentStyleSheet(document()->mappedElementSheet());
- m_fontFaceRule->declaration()->setContextStyleSheet(document()->mappedElementSheet());
rebuildFontFace();
}
{
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)
break;
}
}
- m_fontFaceRule->declaration()->setContextStyleSheet(0);
document()->styleSelectorChanged(DeferRecalcStyle);
}
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)
{
int propertyID = SVGStyledElement::cssPropertyIdForSVGAttributeName(attr->name());
if (propertyID > 0)
- style->setProperty(propertyID, attr->value());
+ addPropertyToAttributeStyle(style, propertyID, attr->value());
}
void SVGStyledElement::parseAttribute(Attribute* attr)
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);
}
}