https://bugs.webkit.org/show_bug.cgi?id=78589
Reviewed by Ryosuke Niwa.
StylePropertySet should be independent of its context so that they can in the future
be shared between documents. The context invalidation code should move to the CSSOM wrapper.
Parent rule and parent element pointers move to the CSSOM wrapper classes.
The wrapper is responsible of invalidating the element or document style on mutation.
In case of internal mutation of style attribute, StyledElement takes care of the
invalidation.
The StylePropertySet will still have a pointer to the context stylesheet so the patch
doesn't actually reduce memory usage. That pointer will be factored out later.
* css/CSSFontFaceRule.cpp:
(WebCore::CSSFontFaceRule::~CSSFontFaceRule):
* css/CSSFontFaceRule.h:
(WebCore::CSSFontFaceRule::style):
* css/CSSPageRule.cpp:
(WebCore::CSSPageRule::~CSSPageRule):
* css/CSSPageRule.h:
(WebCore::CSSPageRule::style):
(WebCore::CSSPageRule::setDeclaration):
* css/CSSParser.cpp:
(WebCore::CSSParser::createStyleRule):
(WebCore::CSSParser::createFontFaceRule):
(WebCore::CSSParser::createPageRule):
(WebCore::CSSParser::createKeyframeRule):
* css/CSSStyleRule.cpp:
(WebCore::CSSStyleRule::~CSSStyleRule):
* css/CSSStyleRule.h:
(WebCore::CSSStyleRule::style):
(WebCore::CSSStyleRule::setDeclaration):
* css/StylePropertySet.cpp:
(PropertySetCSSStyleDeclaration):
(WebCore::PropertySetCSSStyleDeclaration::parentElement):
(WebCore::PropertySetCSSStyleDeclaration::clearParentRule):
(WebCore::PropertySetCSSStyleDeclaration::clearParentElement):
(WebCore::PropertySetCSSStyleDeclaration::setNeedsStyleRecalc):
(RuleCSSStyleDeclaration):
(WebCore::RuleCSSStyleDeclaration::RuleCSSStyleDeclaration):
(WebCore::RuleCSSStyleDeclaration::parentRule):
(WebCore::RuleCSSStyleDeclaration::clearParentRule):
(WebCore):
(InlineCSSStyleDeclaration):
(WebCore::InlineCSSStyleDeclaration::InlineCSSStyleDeclaration):
(WebCore::InlineCSSStyleDeclaration::parentElement):
(WebCore::InlineCSSStyleDeclaration::clearParentElement):
(WebCore::StylePropertySet::StylePropertySet):
(WebCore::StylePropertySet::removeShorthandProperty):
(WebCore::StylePropertySet::removeProperty):
(WebCore::StylePropertySet::setProperty):
(WebCore::StylePropertySet::parseDeclaration):
(WebCore::StylePropertySet::addParsedProperties):
(WebCore::StylePropertySet::addParsedProperty):
(WebCore::StylePropertySet::merge):
(WebCore::StylePropertySet::removePropertiesInSet):
(WebCore::StylePropertySet::copy):
(WebCore::StylePropertySet::ensureCSSStyleDeclaration):
(WebCore::StylePropertySet::ensureRuleCSSStyleDeclaration):
(WebCore::StylePropertySet::ensureInlineCSSStyleDeclaration):
(WebCore::StylePropertySet::clearParentRule):
(WebCore::StylePropertySet::clearParentElement):
(WebCore::PropertySetCSSStyleDeclaration::setCssText):
(WebCore::PropertySetCSSStyleDeclaration::setProperty):
(WebCore::PropertySetCSSStyleDeclaration::removeProperty):
(WebCore::PropertySetCSSStyleDeclaration::setPropertyInternal):
(WebCore::RuleCSSStyleDeclaration::setNeedsStyleRecalc):
(WebCore::InlineCSSStyleDeclaration::setNeedsStyleRecalc):
* css/StylePropertySet.h:
(WebCore::StylePropertySet::create):
(StylePropertySet):
(WebCore::StylePropertySet::useStrictParsing):
(WebCore::StylePropertySet::contextStyleSheet):
(WebCore::StylePropertySet::setContextStyleSheet):
* css/WebKitCSSKeyframeRule.cpp:
(WebCore::WebKitCSSKeyframeRule::~WebKitCSSKeyframeRule):
(WebCore::WebKitCSSKeyframeRule::setDeclaration):
* css/WebKitCSSKeyframeRule.h:
(WebCore::WebKitCSSKeyframeRule::style):
* dom/ElementAttributeData.cpp:
(WebCore::ElementAttributeData::ensureInlineStyleDecl):
(WebCore::ElementAttributeData::destroyInlineStyleDecl):
* dom/ElementAttributeData.h:
(ElementAttributeData):
* dom/StyledElement.cpp:
(WebCore::StyledElement::insertedIntoDocument):
(WebCore):
(WebCore::StyledElement::removedFromDocument):
(WebCore::StyledElement::parseAttribute):
(WebCore::StyledElement::inlineStyleChanged):
(WebCore::StyledElement::setInlineStyleProperty):
(WebCore::StyledElement::removeInlineStyleProperty):
(WebCore::StyledElement::updateAttributeStyle):
* dom/StyledElement.h:
(StyledElement):
(WebCore::StyledElement::destroyInlineStyleDecl):
* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::applyRelativeFontStyleChange):
* editing/DeleteButtonController.cpp:
(WebCore::DeleteButtonController::createDeletionUI):
(WebCore::DeleteButtonController::show):
(WebCore::DeleteButtonController::hide):
* editing/Editor.cpp:
(WebCore::Editor::applyEditingStyleToElement):
* editing/RemoveCSSPropertyCommand.cpp:
(WebCore::RemoveCSSPropertyCommand::doApply):
(WebCore::RemoveCSSPropertyCommand::doUnapply):
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline):
* html/ColorInputType.cpp:
(WebCore::ColorInputType::updateColorSwatch):
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::updatePlaceholderVisibility):
* html/ImageDocument.cpp:
(WebCore::ImageDocument::resizeImageToFit):
(WebCore::ImageDocument::restoreImageSize):
(WebCore::ImageDocument::windowSizeChanged):
* html/ValidationMessage.cpp:
(WebCore::adjustBubblePosition):
(WebCore::ValidationMessage::buildBubbleTree):
* html/shadow/MediaControlElements.cpp:
(WebCore::MediaControlElement::show):
(WebCore::MediaControlElement::hide):
(WebCore::MediaControlPanelElement::setPosition):
(WebCore::MediaControlPanelElement::resetPosition):
(WebCore::MediaControlPanelElement::makeOpaque):
(WebCore::MediaControlPanelElement::makeTransparent):
(WebCore::MediaControlInputElement::show):
(WebCore::MediaControlInputElement::hide):
(WebCore::MediaControlTextTrackContainerElement::updateSizes):
* html/shadow/MeterShadowElement.cpp:
(WebCore::MeterValueElement::setWidthPercentage):
* html/shadow/ProgressShadowElement.cpp:
(WebCore::ProgressValueElement::setWidthPercentage):
* html/shadow/SliderThumbElement.cpp:
(WebCore::TrackLimiterElement::create):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::resize):
* rendering/RenderTextControlSingleLine.cpp:
(WebCore::RenderTextControlSingleLine::styleDidChange):
* svg/SVGFontFaceElement.cpp:
(WebCore::SVGFontFaceElement::SVGFontFaceElement):
(WebCore::SVGFontFaceElement::insertedIntoDocument):
(WebCore::SVGFontFaceElement::removeFromMappedElementSheet):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@107899
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-02-15 Antti Koivisto <antti@apple.com>
+
+ Move the context invalidation code out from StylePropertySet
+ https://bugs.webkit.org/show_bug.cgi?id=78589
+
+ Reviewed by Ryosuke Niwa.
+
+ StylePropertySet should be independent of its context so that they can in the future
+ be shared between documents. The context invalidation code should move to the CSSOM wrapper.
+
+ Parent rule and parent element pointers move to the CSSOM wrapper classes.
+
+ The wrapper is responsible of invalidating the element or document style on mutation.
+ In case of internal mutation of style attribute, StyledElement takes care of the
+ invalidation.
+
+ The StylePropertySet will still have a pointer to the context stylesheet so the patch
+ doesn't actually reduce memory usage. That pointer will be factored out later.
+
+ * css/CSSFontFaceRule.cpp:
+ (WebCore::CSSFontFaceRule::~CSSFontFaceRule):
+ * css/CSSFontFaceRule.h:
+ (WebCore::CSSFontFaceRule::style):
+ * css/CSSPageRule.cpp:
+ (WebCore::CSSPageRule::~CSSPageRule):
+ * css/CSSPageRule.h:
+ (WebCore::CSSPageRule::style):
+ (WebCore::CSSPageRule::setDeclaration):
+ * css/CSSParser.cpp:
+ (WebCore::CSSParser::createStyleRule):
+ (WebCore::CSSParser::createFontFaceRule):
+ (WebCore::CSSParser::createPageRule):
+ (WebCore::CSSParser::createKeyframeRule):
+ * css/CSSStyleRule.cpp:
+ (WebCore::CSSStyleRule::~CSSStyleRule):
+ * css/CSSStyleRule.h:
+ (WebCore::CSSStyleRule::style):
+ (WebCore::CSSStyleRule::setDeclaration):
+ * css/StylePropertySet.cpp:
+ (PropertySetCSSStyleDeclaration):
+ (WebCore::PropertySetCSSStyleDeclaration::parentElement):
+ (WebCore::PropertySetCSSStyleDeclaration::clearParentRule):
+ (WebCore::PropertySetCSSStyleDeclaration::clearParentElement):
+ (WebCore::PropertySetCSSStyleDeclaration::setNeedsStyleRecalc):
+ (RuleCSSStyleDeclaration):
+ (WebCore::RuleCSSStyleDeclaration::RuleCSSStyleDeclaration):
+ (WebCore::RuleCSSStyleDeclaration::parentRule):
+ (WebCore::RuleCSSStyleDeclaration::clearParentRule):
+ (WebCore):
+ (InlineCSSStyleDeclaration):
+ (WebCore::InlineCSSStyleDeclaration::InlineCSSStyleDeclaration):
+ (WebCore::InlineCSSStyleDeclaration::parentElement):
+ (WebCore::InlineCSSStyleDeclaration::clearParentElement):
+ (WebCore::StylePropertySet::StylePropertySet):
+ (WebCore::StylePropertySet::removeShorthandProperty):
+ (WebCore::StylePropertySet::removeProperty):
+ (WebCore::StylePropertySet::setProperty):
+ (WebCore::StylePropertySet::parseDeclaration):
+ (WebCore::StylePropertySet::addParsedProperties):
+ (WebCore::StylePropertySet::addParsedProperty):
+ (WebCore::StylePropertySet::merge):
+ (WebCore::StylePropertySet::removePropertiesInSet):
+ (WebCore::StylePropertySet::copy):
+ (WebCore::StylePropertySet::ensureCSSStyleDeclaration):
+ (WebCore::StylePropertySet::ensureRuleCSSStyleDeclaration):
+ (WebCore::StylePropertySet::ensureInlineCSSStyleDeclaration):
+ (WebCore::StylePropertySet::clearParentRule):
+ (WebCore::StylePropertySet::clearParentElement):
+ (WebCore::PropertySetCSSStyleDeclaration::setCssText):
+ (WebCore::PropertySetCSSStyleDeclaration::setProperty):
+ (WebCore::PropertySetCSSStyleDeclaration::removeProperty):
+ (WebCore::PropertySetCSSStyleDeclaration::setPropertyInternal):
+ (WebCore::RuleCSSStyleDeclaration::setNeedsStyleRecalc):
+ (WebCore::InlineCSSStyleDeclaration::setNeedsStyleRecalc):
+ * css/StylePropertySet.h:
+ (WebCore::StylePropertySet::create):
+ (StylePropertySet):
+ (WebCore::StylePropertySet::useStrictParsing):
+ (WebCore::StylePropertySet::contextStyleSheet):
+ (WebCore::StylePropertySet::setContextStyleSheet):
+ * css/WebKitCSSKeyframeRule.cpp:
+ (WebCore::WebKitCSSKeyframeRule::~WebKitCSSKeyframeRule):
+ (WebCore::WebKitCSSKeyframeRule::setDeclaration):
+ * css/WebKitCSSKeyframeRule.h:
+ (WebCore::WebKitCSSKeyframeRule::style):
+ * dom/ElementAttributeData.cpp:
+ (WebCore::ElementAttributeData::ensureInlineStyleDecl):
+ (WebCore::ElementAttributeData::destroyInlineStyleDecl):
+ * dom/ElementAttributeData.h:
+ (ElementAttributeData):
+ * dom/StyledElement.cpp:
+ (WebCore::StyledElement::insertedIntoDocument):
+ (WebCore):
+ (WebCore::StyledElement::removedFromDocument):
+ (WebCore::StyledElement::parseAttribute):
+ (WebCore::StyledElement::inlineStyleChanged):
+ (WebCore::StyledElement::setInlineStyleProperty):
+ (WebCore::StyledElement::removeInlineStyleProperty):
+ (WebCore::StyledElement::updateAttributeStyle):
+ * dom/StyledElement.h:
+ (StyledElement):
+ (WebCore::StyledElement::destroyInlineStyleDecl):
+ * editing/ApplyStyleCommand.cpp:
+ (WebCore::ApplyStyleCommand::applyRelativeFontStyleChange):
+ * editing/DeleteButtonController.cpp:
+ (WebCore::DeleteButtonController::createDeletionUI):
+ (WebCore::DeleteButtonController::show):
+ (WebCore::DeleteButtonController::hide):
+ * editing/Editor.cpp:
+ (WebCore::Editor::applyEditingStyleToElement):
+ * editing/RemoveCSSPropertyCommand.cpp:
+ (WebCore::RemoveCSSPropertyCommand::doApply):
+ (WebCore::RemoveCSSPropertyCommand::doUnapply):
+ * editing/ReplaceSelectionCommand.cpp:
+ (WebCore::ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline):
+ * html/ColorInputType.cpp:
+ (WebCore::ColorInputType::updateColorSwatch):
+ * html/HTMLTextFormControlElement.cpp:
+ (WebCore::HTMLTextFormControlElement::updatePlaceholderVisibility):
+ * html/ImageDocument.cpp:
+ (WebCore::ImageDocument::resizeImageToFit):
+ (WebCore::ImageDocument::restoreImageSize):
+ (WebCore::ImageDocument::windowSizeChanged):
+ * html/ValidationMessage.cpp:
+ (WebCore::adjustBubblePosition):
+ (WebCore::ValidationMessage::buildBubbleTree):
+ * html/shadow/MediaControlElements.cpp:
+ (WebCore::MediaControlElement::show):
+ (WebCore::MediaControlElement::hide):
+ (WebCore::MediaControlPanelElement::setPosition):
+ (WebCore::MediaControlPanelElement::resetPosition):
+ (WebCore::MediaControlPanelElement::makeOpaque):
+ (WebCore::MediaControlPanelElement::makeTransparent):
+ (WebCore::MediaControlInputElement::show):
+ (WebCore::MediaControlInputElement::hide):
+ (WebCore::MediaControlTextTrackContainerElement::updateSizes):
+ * html/shadow/MeterShadowElement.cpp:
+ (WebCore::MeterValueElement::setWidthPercentage):
+ * html/shadow/ProgressShadowElement.cpp:
+ (WebCore::ProgressValueElement::setWidthPercentage):
+ * html/shadow/SliderThumbElement.cpp:
+ (WebCore::TrackLimiterElement::create):
+ * rendering/RenderLayer.cpp:
+ (WebCore::RenderLayer::resize):
+ * rendering/RenderTextControlSingleLine.cpp:
+ (WebCore::RenderTextControlSingleLine::styleDidChange):
+ * svg/SVGFontFaceElement.cpp:
+ (WebCore::SVGFontFaceElement::SVGFontFaceElement):
+ (WebCore::SVGFontFaceElement::insertedIntoDocument):
+ (WebCore::SVGFontFaceElement::removeFromMappedElementSheet):
+
2012-02-15 Daniel Cheng <dcheng@chromium.org>
dataTransfer.types (HTML5 drag & drop) should return DOMStringList
CSSFontFaceRule::~CSSFontFaceRule()
{
if (m_style)
- m_style->clearParentRule();
+ m_style->clearParentRule(this);
}
String CSSFontFaceRule::cssText() const
~CSSFontFaceRule();
- CSSStyleDeclaration* style() const { return m_style->ensureCSSStyleDeclaration(); }
+ CSSStyleDeclaration* style() const { return m_style->ensureRuleCSSStyleDeclaration(this); }
String cssText() const;
CSSPageRule::~CSSPageRule()
{
+ m_style->clearParentRule(this);
}
String CSSPageRule::selectorText() const
}
~CSSPageRule();
- CSSStyleDeclaration* style() const { return m_style->ensureCSSStyleDeclaration(); }
+ CSSStyleDeclaration* style() const { return m_style->ensureRuleCSSStyleDeclaration(this); }
String selectorText() const;
void setSelectorText(const String&);
StylePropertySet* properties() const { return m_style.get(); }
void adoptSelectorVector(Vector<OwnPtr<CSSParserSelector> >& selectors) { m_selectorList.adoptSelectorVector(selectors); }
- void setDeclaration(PassRefPtr<StylePropertySet> style) { ASSERT(style->parentRuleInternal() == this); m_style = style; }
+ void setDeclaration(PassRefPtr<StylePropertySet> style) { m_style = style; }
private:
CSSPageRule(CSSStyleSheet* parent, int sourceLine);
rule->adoptSelectorVector(*selectors);
if (m_hasFontFaceOnlyValues)
deleteFontFaceOnlyValues();
- rule->setDeclaration(StylePropertySet::create(rule.get(), m_parsedProperties, m_numParsedProperties));
+ rule->setDeclaration(StylePropertySet::create(m_styleSheet, m_parsedProperties, m_numParsedProperties));
result = rule.get();
m_parsedRules.append(rule.release());
if (m_ruleRangeMap) {
}
}
RefPtr<CSSFontFaceRule> rule = CSSFontFaceRule::create(m_styleSheet);
- rule->setDeclaration(StylePropertySet::create(rule.get(), m_parsedProperties, m_numParsedProperties));
+ rule->setDeclaration(StylePropertySet::create(m_styleSheet, m_parsedProperties, m_numParsedProperties));
clearProperties();
CSSFontFaceRule* result = rule.get();
m_parsedRules.append(rule.release());
Vector<OwnPtr<CSSParserSelector> > selectorVector;
selectorVector.append(pageSelector);
rule->adoptSelectorVector(selectorVector);
- rule->setDeclaration(StylePropertySet::create(rule.get(), m_parsedProperties, m_numParsedProperties));
+ rule->setDeclaration(StylePropertySet::create(m_styleSheet, m_parsedProperties, m_numParsedProperties));
pageRule = rule.get();
m_parsedRules.append(rule.release());
}
RefPtr<WebKitCSSKeyframeRule> keyframe = WebKitCSSKeyframeRule::create(m_styleSheet);
keyframe->setKeyText(keyString);
- keyframe->setDeclaration(StylePropertySet::create(keyframe.get(), m_parsedProperties, m_numParsedProperties));
+ keyframe->setDeclaration(StylePropertySet::create(m_styleSheet, m_parsedProperties, m_numParsedProperties));
clearProperties();
CSSStyleRule::~CSSStyleRule()
{
if (m_style)
- m_style->clearParentRule();
+ m_style->clearParentRule(this);
cleanup();
}
String selectorText() const;
void setSelectorText(const String&);
- CSSStyleDeclaration* style() const { return m_style->ensureCSSStyleDeclaration(); }
+ CSSStyleDeclaration* style() const { return m_style->ensureRuleCSSStyleDeclaration(this); }
String cssText() const;
void adoptSelectorVector(Vector<OwnPtr<CSSParserSelector> >& selectors) { m_selectorList.adoptSelectorVector(selectors); }
- void setDeclaration(PassRefPtr<StylePropertySet> style) { ASSERT(style->parentRuleInternal() == this); m_style = style; }
+ void setDeclaration(PassRefPtr<StylePropertySet> style) { m_style = style; }
const CSSSelectorList& selectorList() const { return m_selectorList; }
StylePropertySet* declaration() const { return m_style.get(); }
class PropertySetCSSStyleDeclaration : public CSSStyleDeclaration {
public:
PropertySetCSSStyleDeclaration(StylePropertySet* propertySet) : m_propertySet(propertySet) { }
+
+ virtual StyledElement* parentElement() const { return 0; }
+ virtual void clearParentRule() { ASSERT_NOT_REACHED(); }
+ virtual void clearParentElement() { ASSERT_NOT_REACHED(); }
private:
virtual void ref() OVERRIDE { m_propertySet->ref(); }
virtual void deref() OVERRIDE { m_propertySet->deref(); }
- virtual CSSRule* parentRule() const OVERRIDE;
+ virtual CSSRule* parentRule() const OVERRIDE { return 0; };
virtual unsigned length() const OVERRIDE;
virtual String item(unsigned index) const OVERRIDE;
virtual PassRefPtr<CSSValue> getPropertyCSSValue(const String& propertyName) OVERRIDE;
virtual CSSStyleSheet* parentStyleSheet() const OVERRIDE;
virtual PassRefPtr<StylePropertySet> copy() const OVERRIDE;
virtual PassRefPtr<StylePropertySet> makeMutable() OVERRIDE;
-
+ virtual void setNeedsStyleRecalc() { };
+
+protected:
StylePropertySet* m_propertySet;
};
+class RuleCSSStyleDeclaration : public PropertySetCSSStyleDeclaration
+{
+public:
+ RuleCSSStyleDeclaration(StylePropertySet* propertySet, CSSRule* parentRule)
+ : PropertySetCSSStyleDeclaration(propertySet)
+ , m_parentRule(parentRule)
+ {
+ }
+
+private:
+ virtual CSSRule* parentRule() const { return m_parentRule; };
+ virtual void clearParentRule() { m_parentRule = 0; }
+ virtual void setNeedsStyleRecalc();
+
+ CSSRule* m_parentRule;
+};
+
+class InlineCSSStyleDeclaration : public PropertySetCSSStyleDeclaration
+{
+public:
+ InlineCSSStyleDeclaration(StylePropertySet* propertySet, StyledElement* parentElement)
+ : PropertySetCSSStyleDeclaration(propertySet)
+ , m_parentElement(parentElement)
+ {
+ }
+
+private:
+ virtual StyledElement* parentElement() const { return m_parentElement; }
+ virtual void clearParentElement() { m_parentElement = 0; }
+ virtual void setNeedsStyleRecalc();
+
+ StyledElement* m_parentElement;
+};
+
namespace {
class StyleAttributeMutationScope {
WTF_MAKE_NONCOPYABLE(StyleAttributeMutationScope);
public:
- StyleAttributeMutationScope(StylePropertySet* decl)
+ StyleAttributeMutationScope(PropertySetCSSStyleDeclaration* decl)
{
++s_scopeCount;
s_currentDecl = decl;
#if ENABLE(MUTATION_OBSERVERS)
- if (!s_currentDecl->isInlineStyleDeclaration())
- return;
if (!s_currentDecl->parentElement())
return;
m_mutationRecipients = MutationObserverInterestGroup::createForAttributesMutation(s_currentDecl->parentElement(), HTMLNames::styleAttr);
return;
}
// We have to clear internal state before calling Inspector's code.
- StylePropertySet* localCopyStyleDecl = s_currentDecl;
+ PropertySetCSSStyleDeclaration* localCopyStyleDecl = s_currentDecl;
s_currentDecl = 0;
s_shouldNotifyInspector = false;
- if (localCopyStyleDecl->isInlineStyleDeclaration() && localCopyStyleDecl->parentElement() && localCopyStyleDecl->parentElement()->document())
+ if (localCopyStyleDecl->parentElement() && localCopyStyleDecl->parentElement()->document())
InspectorInstrumentation::didInvalidateStyleAttr(localCopyStyleDecl->parentElement()->document(), localCopyStyleDecl->parentElement());
}
void didInvalidateStyleAttr()
{
- ASSERT(s_currentDecl->isInlineStyleDeclaration());
s_shouldNotifyInspector = true;
}
private:
static unsigned s_scopeCount;
- static StylePropertySet* s_currentDecl;
+ static PropertySetCSSStyleDeclaration* s_currentDecl;
static bool s_shouldNotifyInspector;
#if ENABLE(MUTATION_OBSERVERS)
static bool s_shouldDeliver;
};
unsigned StyleAttributeMutationScope::s_scopeCount = 0;
-StylePropertySet* StyleAttributeMutationScope::s_currentDecl = 0;
+PropertySetCSSStyleDeclaration* StyleAttributeMutationScope::s_currentDecl = 0;
bool StyleAttributeMutationScope::s_shouldNotifyInspector = false;
#if ENABLE(MUTATION_OBSERVERS)
bool StyleAttributeMutationScope::s_shouldDeliver = false;
StylePropertySet::StylePropertySet()
: m_strictParsing(false)
- , m_parentIsElement(false)
- , m_isInlineStyleDeclaration(false)
, m_hasCSSOMWrapper(false)
- , m_parent(static_cast<CSSRule*>(0))
+ , m_contextStyleSheet(0)
{
}
-StylePropertySet::StylePropertySet(CSSRule* parentRule)
- : m_strictParsing(!parentRule || parentRule->useStrictParsing())
- , m_parentIsElement(false)
- , m_isInlineStyleDeclaration(false)
+StylePropertySet::StylePropertySet(const Vector<CSSProperty>& properties)
+ : m_properties(properties)
+ , m_strictParsing(true)
, m_hasCSSOMWrapper(false)
- , m_parent(parentRule)
+ , m_contextStyleSheet(0)
{
+ m_properties.shrinkToFit();
}
-StylePropertySet::StylePropertySet(CSSRule* parentRule, const Vector<CSSProperty>& properties)
- : m_properties(properties)
- , m_strictParsing(!parentRule || parentRule->useStrictParsing())
- , m_parentIsElement(false)
- , m_isInlineStyleDeclaration(false)
+StylePropertySet::StylePropertySet(CSSStyleSheet* contextStyleSheet)
+ : m_strictParsing(!contextStyleSheet || contextStyleSheet->useStrictParsing())
, m_hasCSSOMWrapper(false)
- , m_parent(parentRule)
+ , m_contextStyleSheet(contextStyleSheet)
{
- m_properties.shrinkToFit();
}
-StylePropertySet::StylePropertySet(CSSRule* parentRule, const CSSProperty* const * properties, int numProperties)
- : m_strictParsing(!parentRule || parentRule->useStrictParsing())
- , m_parentIsElement(false)
- , m_isInlineStyleDeclaration(false)
+StylePropertySet::StylePropertySet(CSSStyleSheet* contextStyleSheet, const CSSProperty* const * properties, int numProperties)
+ : m_strictParsing(!contextStyleSheet || contextStyleSheet->useStrictParsing())
, m_hasCSSOMWrapper(false)
- , m_parent(parentRule)
+ , m_contextStyleSheet(contextStyleSheet)
{
m_properties.reserveInitialCapacity(numProperties);
HashMap<int, bool> candidates;
if (it != candidates.end()) {
if (!important && it->second)
continue;
- removeProperty(property->id(), false, false);
+ removeProperty(property->id());
}
m_properties.append(*property);
}
}
-StylePropertySet::StylePropertySet(StyledElement* parentElement, bool isInlineStyle)
- : m_strictParsing(false)
- , m_parentIsElement(true)
- , m_isInlineStyleDeclaration(isInlineStyle)
- , m_hasCSSOMWrapper(false)
- , m_parent(parentElement)
-{
-}
-
StylePropertySet::~StylePropertySet()
{
ASSERT(!m_hasCSSOMWrapper || propertySetCSSOMWrapperMap().contains(this));
propertySetCSSOMWrapperMap().remove(this);
}
-CSSStyleSheet* StylePropertySet::contextStyleSheet() const
-{
- if (m_parentIsElement) {
- Document* document = m_parent.element ? m_parent.element->document() : 0;
- return document ? document->elementSheet() : 0;
- }
- return m_parent.rule ? m_parent.rule->parentStyleSheet() : 0;
-}
-
void StylePropertySet::copyPropertiesFrom(const StylePropertySet& other)
{
m_properties = other.m_properties;
return property ? property->value() : 0;
}
-bool StylePropertySet::removeShorthandProperty(int propertyID, bool notifyChanged)
+bool StylePropertySet::removeShorthandProperty(int propertyID)
{
CSSPropertyLonghand longhand = longhandForProperty(propertyID);
if (!longhand.length())
return false;
- return removePropertiesInSet(longhand.properties(), longhand.length(), notifyChanged);
+ return removePropertiesInSet(longhand.properties(), longhand.length());
}
-String StylePropertySet::removeProperty(int propertyID, bool notifyChanged, bool returnText)
+bool StylePropertySet::removeProperty(int propertyID, String* returnText)
{
-#if ENABLE(MUTATION_OBSERVERS)
- StyleAttributeMutationScope mutationScope(this);
-#endif
-
- if (removeShorthandProperty(propertyID, notifyChanged)) {
+ if (removeShorthandProperty(propertyID)) {
// FIXME: Return an equivalent shorthand when possible.
- return String();
+ if (returnText)
+ *returnText = "";
+ return true;
}
CSSProperty* foundProperty = findPropertyWithId(propertyID);
- if (!foundProperty)
- return String();
+ if (!foundProperty) {
+ if (returnText)
+ *returnText = "";
+ return false;
+ }
- String value = returnText ? foundProperty->value()->cssText() : String();
+ if (returnText)
+ *returnText = foundProperty->value()->cssText();
// A more efficient removal strategy would involve marking entries as empty
// and sweeping them when the vector grows too big.
m_properties.remove(foundProperty - m_properties.data());
-
-#if ENABLE(MUTATION_OBSERVERS)
- mutationScope.enqueueMutationRecord();
-#endif
-
- if (notifyChanged)
- setNeedsStyleRecalc();
-
- return value;
-}
-
-void StylePropertySet::setNeedsStyleRecalc()
-{
- if (m_parentIsElement) {
- StyledElement* element = parentElement();
- if (!element)
- return;
-
- if (!m_isInlineStyleDeclaration) {
- // If this is not an inline style, it's an attribute style, and we shouldn't mark the element for style recalc
- // as that is handled by StyledElement::attributeChanged().
- return;
- }
-
- element->setNeedsStyleRecalc(InlineStyleChange);
- element->invalidateStyleAttribute();
- StyleAttributeMutationScope(this).didInvalidateStyleAttr();
- return;
- }
-
- if (CSSStyleSheet* styleSheet = contextStyleSheet()) {
- if (Document* document = styleSheet->findDocument())
- document->styleSelectorChanged(DeferRecalcStyle);
- }
+
+ return true;
}
bool StylePropertySet::propertyIsImportant(int propertyID) const
return property ? property->isImplicit() : false;
}
-bool StylePropertySet::setProperty(int propertyID, const String& value, bool important, bool notifyChanged)
+bool StylePropertySet::setProperty(int propertyID, const String& value, bool important)
{
-#if ENABLE(MUTATION_OBSERVERS)
- StyleAttributeMutationScope mutationScope(this);
-#endif
-
// 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()) {
- removeProperty(propertyID, notifyChanged, false);
+ removeProperty(propertyID);
return true;
}
// 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.
- bool success = CSSParser::parseValue(this, propertyID, value, important, useStrictParsing());
- if (!success) {
- // CSS DOM requires raising SYNTAX_ERR here, but this is too dangerous for compatibility,
- // see <http://bugs.webkit.org/show_bug.cgi?id=7296>.
- return false;
- }
-
-#if ENABLE(MUTATION_OBSERVERS)
- mutationScope.enqueueMutationRecord();
-#endif
-
- if (notifyChanged)
- setNeedsStyleRecalc();
-
- return true;
+ return CSSParser::parseValue(this, propertyID, value, important, useStrictParsing());
}
void StylePropertySet::setProperty(const CSSProperty& property, CSSProperty* slot)
{
-#if ENABLE(MUTATION_OBSERVERS)
- StyleAttributeMutationScope mutationScope(this);
-#endif
-
- if (!removeShorthandProperty(property.id(), false)) {
+ if (!removeShorthandProperty(property.id())) {
CSSProperty* toReplace = slot ? slot : findPropertyWithId(property.id());
if (toReplace) {
*toReplace = property;
}
}
m_properties.append(property);
-
-#if ENABLE(MUTATION_OBSERVERS)
- mutationScope.enqueueMutationRecord();
-#endif
}
-bool StylePropertySet::setProperty(int propertyID, int identifier, bool important, bool notifyChanged)
+bool StylePropertySet::setProperty(int propertyID, int identifier, bool important)
{
- RefPtr<CSSPrimitiveValue> value;
- if (m_parentIsElement && parentElement() && parentElement()->document())
- value = parentElement()->document()->cssValuePool()->createIdentifierValue(identifier);
+ RefPtr<CSSPrimitiveValue> value;
+ if (Document* document = m_contextStyleSheet ? m_contextStyleSheet->findDocument() : 0)
+ value = document->cssValuePool()->createIdentifierValue(identifier);
else
value = CSSPrimitiveValue::createIdentifier(identifier);
setProperty(CSSProperty(propertyID, value.release(), important));
- if (notifyChanged)
- setNeedsStyleRecalc();
return true;
}
-bool StylePropertySet::setProperty(int propertyID, double value, CSSPrimitiveValue::UnitTypes unit, bool important, bool notifyChanged)
+bool StylePropertySet::setProperty(int propertyID, double value, CSSPrimitiveValue::UnitTypes unit, bool important)
{
CSSProperty property(propertyID, CSSPrimitiveValue::create(value, unit), important);
setProperty(property);
- if (notifyChanged)
- setNeedsStyleRecalc();
return true;
}
void StylePropertySet::parseDeclaration(const String& styleDeclaration)
{
-#if ENABLE(MUTATION_OBSERVERS)
- StyleAttributeMutationScope mutationScope(this);
-#endif
-
m_properties.clear();
CSSParser parser(useStrictParsing());
parser.parseDeclaration(this, styleDeclaration);
-
-#if ENABLE(MUTATION_OBSERVERS)
- mutationScope.enqueueMutationRecord();
-#endif
-
- setNeedsStyleRecalc();
}
void StylePropertySet::addParsedProperties(const CSSProperty* const* properties, int numProperties)
{
-#if ENABLE(MUTATION_OBSERVERS)
- StyleAttributeMutationScope mutationScope(this);
-#endif
-
m_properties.reserveCapacity(numProperties);
for (int i = 0; i < numProperties; ++i)
addParsedProperty(*properties[i]);
-
-#if ENABLE(MUTATION_OBSERVERS)
- mutationScope.enqueueMutationRecord();
-#endif
-
- // FIXME: This probably should have a call to setNeedsStyleRecalc() if something changed. We may also wish to add
- // a notifyChanged argument to this function to follow the model of other functions in this class.
}
void StylePropertySet::addParsedProperty(const CSSProperty& property)
{
-#if ENABLE(MUTATION_OBSERVERS)
- StyleAttributeMutationScope mutationScope(this);
-#endif
-
// Only add properties that have no !important counterpart present
if (!propertyIsImportant(property.id()) || property.isImportant()) {
- removeProperty(property.id(), false, false);
+ removeProperty(property.id());
m_properties.append(property);
}
-
-#if ENABLE(MUTATION_OBSERVERS)
- mutationScope.enqueueMutationRecord();
-#endif
}
String StylePropertySet::asText() const
void StylePropertySet::merge(const StylePropertySet* other, bool argOverridesOnConflict)
{
-#if ENABLE(MUTATION_OBSERVERS)
- StyleAttributeMutationScope mutationScope(this);
-#endif
-
unsigned size = other->m_properties.size();
for (unsigned n = 0; n < size; ++n) {
const CSSProperty& toMerge = other->m_properties[n];
} else
m_properties.append(toMerge);
}
-
-#if ENABLE(MUTATION_OBSERVERS)
- mutationScope.enqueueMutationRecord();
-#endif
-
- // FIXME: This probably should have a call to setNeedsStyleRecalc() if something changed. We may also wish to add
- // a notifyChanged argument to this function to follow the model of other functions in this class.
}
void StylePropertySet::addSubresourceStyleURLs(ListHashSet<KURL>& urls)
removePropertiesInSet(blockProperties, numBlockProperties);
}
-bool StylePropertySet::removePropertiesInSet(const int* set, unsigned length, bool notifyChanged)
+bool StylePropertySet::removePropertiesInSet(const int* set, unsigned length)
{
if (m_properties.isEmpty())
return false;
-#if ENABLE(MUTATION_OBSERVERS)
- StyleAttributeMutationScope mutationScope(this);
-#endif
-
// FIXME: This is always used with static sets and in that case constructing the hash repeatedly is pretty pointless.
HashSet<int> toRemove;
for (unsigned i = 0; i < length; ++i)
bool changed = newProperties.size() != m_properties.size();
m_properties = newProperties;
-
- if (notifyChanged) {
-#if ENABLE(MUTATION_OBSERVERS)
- mutationScope.enqueueMutationRecord();
-#endif
- setNeedsStyleRecalc();
- }
-
return changed;
}
PassRefPtr<StylePropertySet> StylePropertySet::copy() const
{
- return adoptRef(new StylePropertySet(0, m_properties));
+ return adoptRef(new StylePropertySet(m_properties));
}
PassRefPtr<StylePropertySet> StylePropertySet::copyPropertiesInSet(const int* set, unsigned length) const
CSSStyleDeclaration* StylePropertySet::ensureCSSStyleDeclaration() const
{
- if (m_hasCSSOMWrapper)
+ if (m_hasCSSOMWrapper) {
+ ASSERT(!static_cast<CSSStyleDeclaration*>(propertySetCSSOMWrapperMap().get(this))->parentRule());
+ ASSERT(!propertySetCSSOMWrapperMap().get(this)->parentElement());
return propertySetCSSOMWrapperMap().get(this);
+ }
m_hasCSSOMWrapper = true;
PropertySetCSSStyleDeclaration* cssomWrapper = new PropertySetCSSStyleDeclaration(const_cast<StylePropertySet*>(this));
propertySetCSSOMWrapperMap().add(this, adoptPtr(cssomWrapper));
return cssomWrapper;
}
+CSSStyleDeclaration* StylePropertySet::ensureRuleCSSStyleDeclaration(const CSSRule* parentRule) const
+{
+ if (m_hasCSSOMWrapper) {
+ ASSERT(static_cast<CSSStyleDeclaration*>(propertySetCSSOMWrapperMap().get(this))->parentRule() == parentRule);
+ return propertySetCSSOMWrapperMap().get(this);
+ }
+ m_hasCSSOMWrapper = true;
+ PropertySetCSSStyleDeclaration* cssomWrapper = new RuleCSSStyleDeclaration(const_cast<StylePropertySet*>(this), const_cast<CSSRule*>(parentRule));
+ propertySetCSSOMWrapperMap().add(this, adoptPtr(cssomWrapper));
+ return cssomWrapper;
+}
+
+CSSStyleDeclaration* StylePropertySet::ensureInlineCSSStyleDeclaration(const StyledElement* parentElement) const
+{
+ if (m_hasCSSOMWrapper) {
+ ASSERT(propertySetCSSOMWrapperMap().get(this)->parentElement() == parentElement);
+ return propertySetCSSOMWrapperMap().get(this);
+ }
+ m_hasCSSOMWrapper = true;
+ PropertySetCSSStyleDeclaration* cssomWrapper = new InlineCSSStyleDeclaration(const_cast<StylePropertySet*>(this), const_cast<StyledElement*>(parentElement));
+ propertySetCSSOMWrapperMap().add(this, adoptPtr(cssomWrapper));
+ return cssomWrapper;
+}
+
+void StylePropertySet::clearParentRule(CSSRule* rule)
+{
+ m_contextStyleSheet = 0;
+ if (!m_hasCSSOMWrapper)
+ return;
+ ASSERT_UNUSED(rule, static_cast<CSSStyleDeclaration*>(propertySetCSSOMWrapperMap().get(this))->parentRule() == rule);
+ propertySetCSSOMWrapperMap().get(this)->clearParentRule();
+}
+
+void StylePropertySet::clearParentElement(StyledElement* element)
+{
+ m_contextStyleSheet = 0;
+ if (!m_hasCSSOMWrapper)
+ return;
+ ASSERT_UNUSED(element, propertySetCSSOMWrapperMap().get(this)->parentElement() == element);
+ propertySetCSSOMWrapperMap().get(this)->clearParentElement();
+}
+
unsigned PropertySetCSSStyleDeclaration::length() const
{
return m_propertySet->propertyCount();
return getPropertyName(static_cast<CSSPropertyID>(m_propertySet->propertyAt(i).id()));
}
-CSSRule* PropertySetCSSStyleDeclaration::parentRule() const
-{
- return m_propertySet->parentRuleInternal();
-}
-
String PropertySetCSSStyleDeclaration::cssText() const
{
return m_propertySet->asText();
void PropertySetCSSStyleDeclaration::setCssText(const String& text, ExceptionCode& ec)
{
+#if ENABLE(MUTATION_OBSERVERS)
+ StyleAttributeMutationScope mutationScope(this);
+#endif
ec = 0;
// FIXME: Detect syntax errors and set ec.
m_propertySet->parseDeclaration(text);
+
+ setNeedsStyleRecalc();
+#if ENABLE(MUTATION_OBSERVERS)
+ mutationScope.enqueueMutationRecord();
+#endif
}
PassRefPtr<CSSValue> PropertySetCSSStyleDeclaration::getPropertyCSSValue(const String& propertyName)
void PropertySetCSSStyleDeclaration::setProperty(const String& propertyName, const String& value, const String& priority, ExceptionCode& ec)
{
+#if ENABLE(MUTATION_OBSERVERS)
+ StyleAttributeMutationScope mutationScope(this);
+#endif
int propertyID = cssPropertyID(propertyName);
if (!propertyID)
return;
bool important = priority.find("important", 0, false) != notFound;
ec = 0;
- m_propertySet->setProperty(propertyID, value, important, true);
+ bool changed = m_propertySet->setProperty(propertyID, value, important);
+ 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>.
+ setNeedsStyleRecalc();
+#if ENABLE(MUTATION_OBSERVERS)
+ mutationScope.enqueueMutationRecord();
+#endif
+ }
}
String PropertySetCSSStyleDeclaration::removeProperty(const String& propertyName, ExceptionCode& ec)
{
+#if ENABLE(MUTATION_OBSERVERS)
+ StyleAttributeMutationScope mutationScope(this);
+#endif
int propertyID = cssPropertyID(propertyName);
if (!propertyID)
return String();
ec = 0;
- return m_propertySet->removeProperty(propertyID, true, true);
+ String result;
+ bool changes = m_propertySet->removeProperty(propertyID, &result);
+ if (changes) {
+ setNeedsStyleRecalc();
+#if ENABLE(MUTATION_OBSERVERS)
+ mutationScope.enqueueMutationRecord();
+#endif
+ }
+ return result;
}
PassRefPtr<CSSValue> PropertySetCSSStyleDeclaration::getPropertyCSSValueInternal(CSSPropertyID propertyID)
void PropertySetCSSStyleDeclaration::setPropertyInternal(CSSPropertyID propertyID, const String& value, bool important, ExceptionCode& ec)
{
+#if ENABLE(MUTATION_OBSERVERS)
+ StyleAttributeMutationScope mutationScope(this);
+#endif
ec = 0;
- m_propertySet->setProperty(propertyID, value, important, true);
+ bool changed = m_propertySet->setProperty(propertyID, value, important);
+ if (changed) {
+ setNeedsStyleRecalc();
+#if ENABLE(MUTATION_OBSERVERS)
+ mutationScope.enqueueMutationRecord();
+#endif
+ }
}
CSSStyleSheet* PropertySetCSSStyleDeclaration::parentStyleSheet() const
return m_propertySet->propertyMatches(property);
}
+void RuleCSSStyleDeclaration::setNeedsStyleRecalc()
+{
+ if (CSSStyleSheet* styleSheet = m_propertySet->contextStyleSheet()) {
+ if (Document* document = styleSheet->findDocument())
+ document->styleSelectorChanged(DeferRecalcStyle);
+ }
+}
+
+void InlineCSSStyleDeclaration::setNeedsStyleRecalc()
+{
+ if (!m_parentElement)
+ return;
+ m_parentElement->setNeedsStyleRecalc(InlineStyleChange);
+ m_parentElement->invalidateStyleAttribute();
+ StyleAttributeMutationScope(this).didInvalidateStyleAttr();
+ return;
+}
+
class SameSizeAsStylePropertySet : public RefCounted<SameSizeAsStylePropertySet> {
Vector<CSSProperty, 4> properties;
unsigned bitfield;
{
return adoptRef(new StylePropertySet);
}
- static PassRefPtr<StylePropertySet> create(CSSRule* parentRule)
+ static PassRefPtr<StylePropertySet> create(CSSStyleSheet* contextStyleSheet)
{
- return adoptRef(new StylePropertySet(parentRule));
+ return adoptRef(new StylePropertySet(contextStyleSheet));
}
- static PassRefPtr<StylePropertySet> create(CSSRule* parentRule, const CSSProperty* const* properties, int numProperties)
+ static PassRefPtr<StylePropertySet> create(CSSStyleSheet* contextStyleSheet, const CSSProperty* const* properties, int numProperties)
{
- return adoptRef(new StylePropertySet(parentRule, properties, numProperties));
+ return adoptRef(new StylePropertySet(contextStyleSheet, properties, numProperties));
}
static PassRefPtr<StylePropertySet> create(const Vector<CSSProperty>& properties)
{
- return adoptRef(new StylePropertySet(0, properties));
- }
- static PassRefPtr<StylePropertySet> createInline(StyledElement* element)
- {
- return adoptRef(new StylePropertySet(element, /*isInlineStyle*/ true));
- }
- static PassRefPtr<StylePropertySet> createAttributeStyle(StyledElement* element)
- {
- return adoptRef(new StylePropertySet(element, /*isInlineStyle*/ false));
+ return adoptRef(new StylePropertySet(properties));
}
unsigned propertyCount() const { return m_properties.size(); }
int getPropertyShorthand(int propertyID) const;
bool isPropertyImplicit(int propertyID) const;
- 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); }
+ 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);
void setProperty(const CSSProperty&, CSSProperty* slot = 0);
- void removeProperty(int propertyID) { removeProperty(propertyID, true, false); }
- String removeProperty(int propertyID, bool notifyChanged, bool returnText);
+ bool removeProperty(int propertyID, String* returnText = 0);
// The following parses an entire new style declaration.
void parseDeclaration(const String& styleDeclaration);
PassRefPtr<StylePropertySet> copyBlockProperties() const;
void removeBlockProperties();
- void removePropertiesInSet(const int* set, unsigned length) { removePropertiesInSet(set, length, true); }
+ bool removePropertiesInSet(const int* set, unsigned length);
void merge(const StylePropertySet*, bool argOverridesOnConflict = true);
void setStrictParsing(bool b) { m_strictParsing = b; }
bool useStrictParsing() const { return m_strictParsing; }
- bool isInlineStyleDeclaration() const { return m_isInlineStyleDeclaration; }
void addSubresourceStyleURLs(ListHashSet<KURL>&);
PassRefPtr<StylePropertySet> copyPropertiesInSet(const int* set, unsigned length) const;
- CSSRule* parentRuleInternal() const { return m_parentIsElement ? 0 : m_parent.rule; }
- void clearParentRule() { ASSERT(!m_parentIsElement); m_parent.rule = 0; }
-
- StyledElement* parentElement() const { ASSERT(m_parentIsElement); return m_parent.element; }
- void clearParentElement() { ASSERT(m_parentIsElement); m_parent.element = 0; }
-
- CSSStyleSheet* contextStyleSheet() const;
+ CSSStyleSheet* contextStyleSheet() const { return m_contextStyleSheet; }
+ void setContextStyleSheet(CSSStyleSheet* styleSheet) { m_contextStyleSheet = styleSheet; }
String asText() const;
+ void clearParentRule(CSSRule* rule);
+ void clearParentElement(StyledElement* element);
+
CSSStyleDeclaration* ensureCSSStyleDeclaration() const;
+ CSSStyleDeclaration* ensureRuleCSSStyleDeclaration(const CSSRule* parentRule) const;
+ CSSStyleDeclaration* ensureInlineCSSStyleDeclaration(const StyledElement* parentElement) const;
private:
StylePropertySet();
- StylePropertySet(CSSRule* parentRule);
- StylePropertySet(CSSRule* parentRule, const Vector<CSSProperty>&);
- StylePropertySet(CSSRule* parentRule, const CSSProperty* const *, int numProperties);
- StylePropertySet(StyledElement*, bool isInlineStyle);
+ StylePropertySet(const Vector<CSSProperty>&);
+ StylePropertySet(CSSStyleSheet* parentStyleSheet);
+ StylePropertySet(CSSStyleSheet* parentStyleSheet, const CSSProperty* const *, int numProperties);
void setNeedsStyleRecalc();
template<size_t size> String getCommonValue(const int (&properties)[size]) const { return getCommonValue(properties, size); }
template<size_t size> String getLayeredShorthandValue(const int (&properties)[size]) const { return getLayeredShorthandValue(properties, size); }
- bool setProperty(int propertyID, int value, bool important, bool notifyChanged);
- bool setProperty(int propertyId, double value, CSSPrimitiveValue::UnitTypes, bool important, bool notifyChanged);
- bool setProperty(int propertyID, const String& value, bool important, bool notifyChanged);
- bool removeShorthandProperty(int propertyID, bool notifyChanged);
- bool removePropertiesInSet(const int* set, unsigned length, bool notifyChanged);
+ bool removeShorthandProperty(int propertyID);
bool propertyMatches(const CSSProperty*) const;
const CSSProperty* findPropertyWithId(int propertyId) const;
Vector<CSSProperty, 4> m_properties;
bool m_strictParsing : 1;
- bool m_parentIsElement : 1;
- bool m_isInlineStyleDeclaration : 1;
mutable bool m_hasCSSOMWrapper : 1;
- union Parent {
- Parent(CSSRule* rule) : rule(rule) { }
- Parent(StyledElement* element) : element(element) { }
- CSSRule* rule;
- StyledElement* element;
- } m_parent;
+ CSSStyleSheet* m_contextStyleSheet;
friend class PropertySetCSSStyleDeclaration;
};
WebKitCSSKeyframeRule::~WebKitCSSKeyframeRule()
{
if (m_style)
- m_style->clearParentRule();
+ m_style->clearParentRule(this);
}
String WebKitCSSKeyframeRule::cssText() const
void WebKitCSSKeyframeRule::setDeclaration(PassRefPtr<StylePropertySet> style)
{
- ASSERT(style->parentRuleInternal() == this);
m_style = style;
}
void getKeys(Vector<float>& keys) const { parseKeyString(m_key, keys); }
- CSSStyleDeclaration* style() const { return m_style ? m_style->ensureCSSStyleDeclaration() : 0; }
+ CSSStyleDeclaration* style() const { return m_style ? m_style->ensureRuleCSSStyleDeclaration(this) : 0; }
String cssText() const;
{
if (!m_inlineStyleDecl) {
ASSERT(element->isStyledElement());
- m_inlineStyleDecl = StylePropertySet::createInline(static_cast<StyledElement*>(element));
+ m_inlineStyleDecl = StylePropertySet::create(element->document()->elementSheet());
m_inlineStyleDecl->setStrictParsing(element->isHTMLElement() && !element->document()->inQuirksMode());
}
return m_inlineStyleDecl.get();
}
-void ElementAttributeData::destroyInlineStyleDecl()
+void ElementAttributeData::destroyInlineStyleDecl(StyledElement* element)
{
if (!m_inlineStyleDecl)
return;
- m_inlineStyleDecl->clearParentElement();
+ m_inlineStyleDecl->clearParentElement(element);
m_inlineStyleDecl = 0;
}
StylePropertySet* inlineStyleDecl() { return m_inlineStyleDecl.get(); }
StylePropertySet* ensureInlineStyleDecl(StyledElement*);
- void destroyInlineStyleDecl();
+ void destroyInlineStyleDecl(StyledElement* element);
StylePropertySet* attributeStyle() const { return m_attributeStyle.get(); }
void setAttributeStyle(PassRefPtr<StylePropertySet> style) { m_attributeStyle = style; }
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()))
ensureInlineStyleDecl()->parseDeclaration(attr->value());
setIsStyleAttributeValid();
setNeedsStyleRecalc();
+ InspectorInstrumentation::didInvalidateStyleAttr(document(), this);
}
}
+void StyledElement::inlineStyleChanged()
+{
+ setNeedsStyleRecalc(InlineStyleChange);
+ setIsStyleAttributeValid(false);
+ InspectorInstrumentation::didInvalidateStyleAttr(document(), this);
+}
+
+bool StyledElement::setInlineStyleProperty(int propertyID, int value, bool important)
+{
+ bool changes = ensureInlineStyleDecl()->setProperty(propertyID, value, important);
+ 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);
+ if (changes)
+ inlineStyleChanged();
+ return changes;
+}
+
+bool StyledElement::setInlineStyleProperty(int propertyID, const String& value, bool important)
+{
+ bool changes = ensureInlineStyleDecl()->setProperty(propertyID, value, important);
+ if (changes)
+ inlineStyleChanged();
+ return changes;
+}
+
+bool StyledElement::removeInlineStyleProperty(int propertyID)
+{
+ bool changes = ensureInlineStyleDecl()->removeProperty(propertyID);
+ if (changes)
+ inlineStyleChanged();
+ return changes;
+}
+
void StyledElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
{
if (StylePropertySet* inlineStyle = inlineStyleDecl())
void StyledElement::updateAttributeStyle()
{
- RefPtr<StylePropertySet> style = StylePropertySet::createAttributeStyle(this);
+ RefPtr<StylePropertySet> style = StylePropertySet::create(document()->elementSheet());
for (unsigned i = 0; i < attributeCount(); ++i) {
Attribute* attribute = attributeItem(i);
collectStyleForAttribute(attribute, style.get());
StylePropertySet* inlineStyleDecl() const { return attributeData() ? attributeData()->inlineStyleDecl() : 0; }
StylePropertySet* ensureInlineStyleDecl() { return ensureAttributeData()->ensureInlineStyleDecl(this); }
- virtual CSSStyleDeclaration* style() OVERRIDE { return ensureInlineStyleDecl()->ensureCSSStyleDeclaration(); }
+
+ // 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, const String& value, bool important = false);
+ bool removeInlineStyleProperty(int propertyID);
+
+ virtual CSSStyleDeclaration* style() OVERRIDE { return ensureInlineStyleDecl()->ensureInlineCSSStyleDeclaration(this); }
StylePropertySet* attributeStyle();
// 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;
+ void inlineStyleChanged();
void updateAttributeStyle();
void destroyInlineStyleDecl()
{
if (attributeData())
- attributeData()->destroyInlineStyleDecl();
+ attributeData()->destroyInlineStyleDecl(this);
}
};
float desiredFontSize = max(MinimumFontSize, startingFontSizes.get(node) + style->fontSizeDelta());
RefPtr<CSSValue> value = inlineStyleDecl->getPropertyCSSValue(CSSPropertyFontSize);
if (value) {
- inlineStyleDecl->removeProperty(CSSPropertyFontSize);
+ element->removeInlineStyleProperty(CSSPropertyFontSize);
currentFontSize = computedFontSize(node);
}
if (currentFontSize != desiredFontSize) {
RefPtr<HTMLDivElement> container = HTMLDivElement::create(m_target->document());
container->setIdAttribute(containerElementIdentifier);
- StylePropertySet* style = container->ensureInlineStyleDecl();
- style->setProperty(CSSPropertyWebkitUserDrag, CSSValueNone);
- style->setProperty(CSSPropertyWebkitUserSelect, CSSValueNone);
- style->setProperty(CSSPropertyWebkitUserModify, CSSValueReadOnly);
- style->setProperty(CSSPropertyVisibility, CSSValueHidden);
- style->setProperty(CSSPropertyPosition, CSSValueAbsolute);
- style->setProperty(CSSPropertyCursor, CSSValueDefault);
- style->setProperty(CSSPropertyTop, "0");
- style->setProperty(CSSPropertyRight, "0");
- style->setProperty(CSSPropertyBottom, "0");
- style->setProperty(CSSPropertyLeft, "0");
+ container->setInlineStyleProperty(CSSPropertyWebkitUserDrag, CSSValueNone);
+ container->setInlineStyleProperty(CSSPropertyWebkitUserSelect, CSSValueNone);
+ container->setInlineStyleProperty(CSSPropertyWebkitUserModify, CSSValueReadOnly);
+ container->setInlineStyleProperty(CSSPropertyVisibility, CSSValueHidden);
+ container->setInlineStyleProperty(CSSPropertyPosition, CSSValueAbsolute);
+ container->setInlineStyleProperty(CSSPropertyCursor, CSSValueDefault);
+ container->setInlineStyleProperty(CSSPropertyTop, "0");
+ container->setInlineStyleProperty(CSSPropertyRight, "0");
+ container->setInlineStyleProperty(CSSPropertyBottom, "0");
+ container->setInlineStyleProperty(CSSPropertyLeft, "0");
RefPtr<HTMLDivElement> outline = HTMLDivElement::create(m_target->document());
outline->setIdAttribute(outlineElementIdentifier);
const int borderWidth = 4;
const int borderRadius = 6;
- style = outline->ensureInlineStyleDecl();
- style->setProperty(CSSPropertyPosition, CSSValueAbsolute);
- style->setProperty(CSSPropertyZIndex, String::number(-1000000));
- style->setProperty(CSSPropertyTop, String::number(-borderWidth - m_target->renderBox()->borderTop()) + "px");
- style->setProperty(CSSPropertyRight, String::number(-borderWidth - m_target->renderBox()->borderRight()) + "px");
- style->setProperty(CSSPropertyBottom, String::number(-borderWidth - m_target->renderBox()->borderBottom()) + "px");
- style->setProperty(CSSPropertyLeft, String::number(-borderWidth - m_target->renderBox()->borderLeft()) + "px");
- style->setProperty(CSSPropertyBorder, String::number(borderWidth) + "px solid rgba(0, 0, 0, 0.6)");
- style->setProperty(CSSPropertyWebkitBorderRadius, String::number(borderRadius) + "px");
- style->setProperty(CSSPropertyVisibility, CSSValueVisible);
+ outline->setInlineStyleProperty(CSSPropertyPosition, CSSValueAbsolute);
+ outline->setInlineStyleProperty(CSSPropertyZIndex, String::number(-1000000));
+ outline->setInlineStyleProperty(CSSPropertyTop, String::number(-borderWidth - m_target->renderBox()->borderTop()) + "px");
+ outline->setInlineStyleProperty(CSSPropertyRight, String::number(-borderWidth - m_target->renderBox()->borderRight()) + "px");
+ outline->setInlineStyleProperty(CSSPropertyBottom, String::number(-borderWidth - m_target->renderBox()->borderBottom()) + "px");
+ outline->setInlineStyleProperty(CSSPropertyLeft, String::number(-borderWidth - m_target->renderBox()->borderLeft()) + "px");
+ outline->setInlineStyleProperty(CSSPropertyBorder, String::number(borderWidth) + "px solid rgba(0, 0, 0, 0.6)");
+ outline->setInlineStyleProperty(CSSPropertyWebkitBorderRadius, String::number(borderRadius) + "px");
+ outline->setInlineStyleProperty(CSSPropertyVisibility, CSSValueVisible);
ExceptionCode ec = 0;
container->appendChild(outline.get(), ec);
const int buttonHeight = 30;
const int buttonBottomShadowOffset = 2;
- style = button->ensureInlineStyleDecl();
- style->setProperty(CSSPropertyPosition, CSSValueAbsolute);
- style->setProperty(CSSPropertyZIndex, String::number(1000000));
- style->setProperty(CSSPropertyTop, String::number((-buttonHeight / 2) - m_target->renderBox()->borderTop() - (borderWidth / 2) + buttonBottomShadowOffset) + "px");
- style->setProperty(CSSPropertyLeft, String::number((-buttonWidth / 2) - m_target->renderBox()->borderLeft() - (borderWidth / 2)) + "px");
- style->setProperty(CSSPropertyWidth, String::number(buttonWidth) + "px");
- style->setProperty(CSSPropertyHeight, String::number(buttonHeight) + "px");
- style->setProperty(CSSPropertyVisibility, CSSValueVisible);
+ button->setInlineStyleProperty(CSSPropertyPosition, CSSValueAbsolute);
+ button->setInlineStyleProperty(CSSPropertyZIndex, String::number(1000000));
+ button->setInlineStyleProperty(CSSPropertyTop, String::number((-buttonHeight / 2) - m_target->renderBox()->borderTop() - (borderWidth / 2) + buttonBottomShadowOffset) + "px");
+ button->setInlineStyleProperty(CSSPropertyLeft, String::number((-buttonWidth / 2) - m_target->renderBox()->borderLeft() - (borderWidth / 2)) + "px");
+ button->setInlineStyleProperty(CSSPropertyWidth, String::number(buttonWidth) + "px");
+ button->setInlineStyleProperty(CSSPropertyHeight, String::number(buttonHeight) + "px");
+ button->setInlineStyleProperty(CSSPropertyVisibility, CSSValueVisible);
float deviceScaleFactor = WebCore::deviceScaleFactor(m_frame);
RefPtr<Image> buttonImage;
}
if (m_target->renderer()->style()->position() == StaticPosition) {
- m_target->ensureInlineStyleDecl()->setProperty(CSSPropertyPosition, CSSValueRelative);
+ m_target->setInlineStyleProperty(CSSPropertyPosition, CSSValueRelative);
m_wasStaticPositioned = true;
}
if (m_target->renderer()->style()->hasAutoZIndex()) {
- m_target->ensureInlineStyleDecl()->setProperty(CSSPropertyZIndex, "0");
+ m_target->setInlineStyleProperty(CSSPropertyZIndex, "0");
m_wasAutoZIndex = true;
}
}
if (m_target) {
if (m_wasStaticPositioned)
- m_target->ensureInlineStyleDecl()->setProperty(CSSPropertyPosition, CSSValueStatic);
+ m_target->setInlineStyleProperty(CSSPropertyPosition, CSSValueStatic);
if (m_wasAutoZIndex)
- m_target->ensureInlineStyleDecl()->setProperty(CSSPropertyZIndex, CSSValueAuto);
+ m_target->setInlineStyleProperty(CSSPropertyZIndex, CSSValueAuto);
}
m_wasStaticPositioned = false;
ASSERT(element->isStyledElement());
if (!element->isStyledElement())
return;
- StylePropertySet* style = static_cast<StyledElement*>(element)->ensureInlineStyleDecl();
- style->setProperty(CSSPropertyWordWrap, "break-word", false);
- style->setProperty(CSSPropertyWebkitNbspMode, "space", false);
- style->setProperty(CSSPropertyWebkitLineBreak, "after-white-space", false);
+
+ // Mutate using the CSSOM wrapper so we get the same event behavior as a script.
+ CSSStyleDeclaration* style = static_cast<StyledElement*>(element)->style();
+ ExceptionCode ec;
+ style->setPropertyInternal(CSSPropertyWordWrap, "break-word", false, ec);
+ style->setPropertyInternal(CSSPropertyWebkitNbspMode, "space", false, ec);
+ style->setPropertyInternal(CSSPropertyWebkitLineBreak, "after-white-space", false, ec);
}
// Searches from the beginning of the document if nothing is selected.
StylePropertySet* style = m_element->inlineStyleDecl();
m_oldValue = style->getPropertyValue(m_property);
m_important = style->propertyIsImportant(m_property);
- style->removeProperty(m_property);
+
+ // Mutate using the CSSOM wrapper so we get the same event behavior as a script.
+ ExceptionCode ec;
+ // Setting to null string removes the property. We don't have internal version of removeProperty.
+ m_element->style()->setPropertyInternal(m_property, String(), false, ec);
}
void RemoveCSSPropertyCommand::doUnapply()
{
- StylePropertySet* style = m_element->inlineStyleDecl();
- style->setProperty(m_property, m_oldValue, m_important);
+ ExceptionCode ec;
+ m_element->style()->setPropertyInternal(m_property, m_oldValue, m_important, ec);
}
#ifndef NDEBUG
// FIXME: Hyatt is concerned that selectively using display:inline will give inconsistent
// results. We already know one issue because td elements ignore their display property
// in quirks mode (which Mail.app is always in). We should look for an alternative.
+
+ // Mutate using the CSSOM wrapper so we get the same event behavior as a script.
+ ExceptionCode ec;
if (isBlock(element))
- element->ensureInlineStyleDecl()->setProperty(CSSPropertyDisplay, CSSValueInline);
+ element->style()->setPropertyInternal(CSSPropertyDisplay, "inline", false, ec);
if (element->renderer() && element->renderer()->style()->isFloating())
- element->ensureInlineStyleDecl()->setProperty(CSSPropertyFloat, CSSValueNone);
+ element->style()->setPropertyInternal(CSSPropertyFloat, "none", false, ec);
}
}
}
if (!colorSwatch)
return;
- colorSwatch->ensureInlineStyleDecl()->setProperty(CSSPropertyBackgroundColor, element()->value(), false);
+ colorSwatch->setInlineStyleProperty(CSSPropertyBackgroundColor, element()->value(), false);
}
HTMLElement* ColorInputType::shadowColorSwatch() const
if (!placeholder)
return;
ExceptionCode ec = 0;
- placeholder->ensureInlineStyleDecl()->setProperty(CSSPropertyVisibility, placeholderShouldBeVisible() ? "visible" : "hidden", ec);
+ placeholder->setInlineStyleProperty(CSSPropertyVisibility, placeholderShouldBeVisible() ? "visible" : "hidden", ec);
ASSERT(!ec);
}
m_imageElement->setWidth(static_cast<int>(imageSize.width() * scale));
m_imageElement->setHeight(static_cast<int>(imageSize.height() * scale));
- m_imageElement->ensureInlineStyleDecl()->setProperty(CSSPropertyCursor, "-webkit-zoom-in", false);
+ m_imageElement->setInlineStyleProperty(CSSPropertyCursor, "-webkit-zoom-in", false);
}
void ImageDocument::imageClicked(int x, int y)
m_imageElement->setHeight(imageSize.height());
if (imageFitsInWindow())
- m_imageElement->ensureInlineStyleDecl()->removeProperty(CSSPropertyCursor);
+ m_imageElement->removeInlineStyleProperty(CSSPropertyCursor);
else
- m_imageElement->ensureInlineStyleDecl()->setProperty(CSSPropertyCursor, "-webkit-zoom-out", false);
+ m_imageElement->setInlineStyleProperty(CSSPropertyCursor, "-webkit-zoom-out", false);
m_didShrinkImage = false;
}
// and set it to a zoom out cursor if the image doesn't fit
if (!m_shouldShrinkImage) {
if (fitsInWindow)
- m_imageElement->ensureInlineStyleDecl()->removeProperty(CSSPropertyCursor);
+ m_imageElement->removeInlineStyleProperty(CSSPropertyCursor);
else
- m_imageElement->ensureInlineStyleDecl()->setProperty(CSSPropertyCursor, "-webkit-zoom-out", false);
+ m_imageElement->setInlineStyleProperty(CSSPropertyCursor, "-webkit-zoom-out", false);
return;
}
hostY -= containerLocation.y() + container->borderTop();
}
- StylePropertySet* style = bubble->ensureInlineStyleDecl();
- style->setProperty(CSSPropertyTop, hostY + hostRect.height(), CSSPrimitiveValue::CSS_PX);
+ bubble->setInlineStyleProperty(CSSPropertyTop, hostY + hostRect.height(), CSSPrimitiveValue::CSS_PX);
// The 'left' value of ::-webkit-validation-bubble-arrow.
const int bubbleArrowTopOffset = 32;
double bubbleX = hostX;
if (hostRect.width() / 2 < bubbleArrowTopOffset)
bubbleX = max(hostX + hostRect.width() / 2 - bubbleArrowTopOffset, 0.0);
- style->setProperty(CSSPropertyLeft, bubbleX, CSSPrimitiveValue::CSS_PX);
+ bubble->setInlineStyleProperty(CSSPropertyLeft, bubbleX, CSSPrimitiveValue::CSS_PX);
}
void ValidationMessage::buildBubbleTree(Timer<ValidationMessage>*)
m_bubble->setShadowPseudoId("-webkit-validation-bubble");
// Need to force position:absolute because RenderMenuList doesn't assume it
// contains non-absolute or non-fixed renderers as children.
- m_bubble->ensureInlineStyleDecl()->setProperty(CSSPropertyPosition, CSSValueAbsolute);
+ m_bubble->setInlineStyleProperty(CSSPropertyPosition, CSSValueAbsolute);
ExceptionCode ec = 0;
host->ensureShadowRoot()->appendChild(m_bubble.get(), ec);
ASSERT(!ec);
void MediaControlElement::show()
{
- ensureInlineStyleDecl()->removeProperty(CSSPropertyDisplay);
+ removeInlineStyleProperty(CSSPropertyDisplay);
}
void MediaControlElement::hide()
{
- ensureInlineStyleDecl()->setProperty(CSSPropertyDisplay, CSSValueNone);
+ setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone);
}
// ----------------------------
void MediaControlPanelElement::setPosition(const LayoutPoint& position)
{
- StylePropertySet* style = ensureInlineStyleDecl();
-
double left = position.x();
double top = position.y();
// Set the left and top to control the panel's position; this depends on it being absolute positioned.
// Set the margin to zero since the position passed in will already include the effect of the margin.
- style->setProperty(CSSPropertyLeft, left, CSSPrimitiveValue::CSS_PX);
- style->setProperty(CSSPropertyTop, top, CSSPrimitiveValue::CSS_PX);
- style->setProperty(CSSPropertyMarginLeft, 0.0, CSSPrimitiveValue::CSS_PX);
- style->setProperty(CSSPropertyMarginTop, 0.0, CSSPrimitiveValue::CSS_PX);
+ setInlineStyleProperty(CSSPropertyLeft, left, CSSPrimitiveValue::CSS_PX);
+ setInlineStyleProperty(CSSPropertyTop, top, CSSPrimitiveValue::CSS_PX);
+ setInlineStyleProperty(CSSPropertyMarginLeft, 0.0, CSSPrimitiveValue::CSS_PX);
+ setInlineStyleProperty(CSSPropertyMarginTop, 0.0, CSSPrimitiveValue::CSS_PX);
ExceptionCode ignored;
classList()->add("dragged", ignored);
void MediaControlPanelElement::resetPosition()
{
- StylePropertySet* style = ensureInlineStyleDecl();
-
- style->removeProperty(CSSPropertyLeft);
- style->removeProperty(CSSPropertyTop);
- style->removeProperty(CSSPropertyMarginLeft);
- style->removeProperty(CSSPropertyMarginTop);
+ removeInlineStyleProperty(CSSPropertyLeft);
+ removeInlineStyleProperty(CSSPropertyTop);
+ removeInlineStyleProperty(CSSPropertyMarginLeft);
+ removeInlineStyleProperty(CSSPropertyMarginTop);
ExceptionCode ignored;
classList()->remove("dragged", ignored);
double duration = document()->page() ? document()->page()->theme()->mediaControlsFadeInDuration() : 0;
- StylePropertySet* style = ensureInlineStyleDecl();
- style->setProperty(CSSPropertyWebkitTransitionProperty, CSSPropertyOpacity);
- style->setProperty(CSSPropertyWebkitTransitionDuration, duration, CSSPrimitiveValue::CSS_S);
- style->setProperty(CSSPropertyOpacity, 1.0, CSSPrimitiveValue::CSS_NUMBER);
+ setInlineStyleProperty(CSSPropertyWebkitTransitionProperty, CSSPropertyOpacity);
+ setInlineStyleProperty(CSSPropertyWebkitTransitionDuration, duration, CSSPrimitiveValue::CSS_S);
+ setInlineStyleProperty(CSSPropertyOpacity, 1.0, CSSPrimitiveValue::CSS_NUMBER);
m_opaque = true;
}
if (!m_opaque)
return;
- StylePropertySet* style = ensureInlineStyleDecl();
- style->setProperty(CSSPropertyWebkitTransitionProperty, CSSPropertyOpacity);
- style->setProperty(CSSPropertyWebkitTransitionDuration, document()->page()->theme()->mediaControlsFadeOutDuration(), CSSPrimitiveValue::CSS_S);
- style->setProperty(CSSPropertyOpacity, 0.0, CSSPrimitiveValue::CSS_NUMBER);
+ setInlineStyleProperty(CSSPropertyWebkitTransitionProperty, CSSPropertyOpacity);
+ setInlineStyleProperty(CSSPropertyWebkitTransitionDuration, document()->page()->theme()->mediaControlsFadeOutDuration(), CSSPrimitiveValue::CSS_S);
+ setInlineStyleProperty(CSSPropertyOpacity, 0.0, CSSPrimitiveValue::CSS_NUMBER);
m_opaque = false;
}
void MediaControlInputElement::show()
{
- ensureInlineStyleDecl()->removeProperty(CSSPropertyDisplay);
+ removeInlineStyleProperty(CSSPropertyDisplay);
}
void MediaControlInputElement::hide()
{
- ensureInlineStyleDecl()->setProperty(CSSPropertyDisplay, CSSValueNone);
+ setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone);
}
float fontSize = m_videoDisplaySize.size().height() * videoHeightFontSizePercentage;
if (fontSize != m_fontSize) {
m_fontSize = fontSize;
- ensureInlineStyleDecl()->setProperty(CSSPropertyFontSize, String::number(fontSize) + "px");
+ setInlineStyleProperty(CSSPropertyFontSize, String::number(fontSize) + "px");
}
LayoutUnit bottom = static_cast<LayoutUnit>(m_videoDisplaySize.y() + m_videoDisplaySize.height() - (m_videoDisplaySize.height() * trackBottomMultiplier));
if (bottom != m_bottom) {
m_bottom = bottom;
- ensureInlineStyleDecl()->setProperty(CSSPropertyBottom, String::number(bottom) + "px");
+ setInlineStyleProperty(CSSPropertyBottom, String::number(bottom) + "px");
}
}
void MeterValueElement::setWidthPercentage(double width)
{
- ensureInlineStyleDecl()->setProperty(CSSPropertyWidth, width, CSSPrimitiveValue::CSS_PERCENTAGE);
+ setInlineStyleProperty(CSSPropertyWidth, width, CSSPrimitiveValue::CSS_PERCENTAGE);
}
void ProgressValueElement::setWidthPercentage(double width)
{
- ensureInlineStyleDecl()->setProperty(CSSPropertyWidth, width, CSSPrimitiveValue::CSS_PERCENTAGE);
+ setInlineStyleProperty(CSSPropertyWidth, width, CSSPrimitiveValue::CSS_PERCENTAGE);
}
}
{
RefPtr<TrackLimiterElement> element = adoptRef(new TrackLimiterElement(document));
- StylePropertySet* style = element->ensureInlineStyleDecl();
- style->setProperty(CSSPropertyVisibility, CSSValueHidden);
- style->setProperty(CSSPropertyPosition, CSSValueStatic);
+ element->setInlineStyleProperty(CSSPropertyVisibility, CSSValueHidden);
+ element->setInlineStyleProperty(CSSPropertyPosition, CSSValueStatic);
return element.release();
}
LayoutSize difference = (currentSize + newOffset - adjustedOldOffset).expandedTo(minimumSize) - currentSize;
ASSERT(element->isStyledElement());
- StylePropertySet* styleDeclaration = static_cast<StyledElement*>(element)->ensureInlineStyleDecl();
+ StyledElement* styledElement = static_cast<StyledElement*>(element);
bool isBoxSizingBorder = renderer->style()->boxSizing() == BORDER_BOX;
if (resize != RESIZE_VERTICAL && difference.width()) {
if (element->isFormControlElement()) {
// Make implicit margins from the theme explicit (see <http://bugs.webkit.org/show_bug.cgi?id=9547>).
- styleDeclaration->setProperty(CSSPropertyMarginLeft, String::number(renderer->marginLeft() / zoomFactor) + "px", false);
- styleDeclaration->setProperty(CSSPropertyMarginRight, String::number(renderer->marginRight() / zoomFactor) + "px", false);
+ styledElement->setInlineStyleProperty(CSSPropertyMarginLeft, String::number(renderer->marginLeft() / zoomFactor) + "px", false);
+ styledElement->setInlineStyleProperty(CSSPropertyMarginRight, String::number(renderer->marginRight() / zoomFactor) + "px", false);
}
LayoutUnit baseWidth = renderer->width() - (isBoxSizingBorder ? zeroLayoutUnit : renderer->borderAndPaddingWidth());
baseWidth = baseWidth / zoomFactor;
- styleDeclaration->setProperty(CSSPropertyWidth, String::number(baseWidth + difference.width()) + "px", false);
+ styledElement->setInlineStyleProperty(CSSPropertyWidth, String::number(baseWidth + difference.width()) + "px", false);
}
if (resize != RESIZE_HORIZONTAL && difference.height()) {
if (element->isFormControlElement()) {
// Make implicit margins from the theme explicit (see <http://bugs.webkit.org/show_bug.cgi?id=9547>).
- styleDeclaration->setProperty(CSSPropertyMarginTop, String::number(renderer->marginTop() / zoomFactor) + "px", false);
- styleDeclaration->setProperty(CSSPropertyMarginBottom, String::number(renderer->marginBottom() / zoomFactor) + "px", false);
+ styledElement->setInlineStyleProperty(CSSPropertyMarginTop, String::number(renderer->marginTop() / zoomFactor) + "px", false);
+ styledElement->setInlineStyleProperty(CSSPropertyMarginBottom, String::number(renderer->marginBottom() / zoomFactor) + "px", false);
}
LayoutUnit baseHeight = renderer->height() - (isBoxSizingBorder ? zeroLayoutUnit : renderer->borderAndPaddingHeight());
baseHeight = baseHeight / zoomFactor;
- styleDeclaration->setProperty(CSSPropertyHeight, String::number(baseHeight + difference.height()) + "px", false);
+ styledElement->setInlineStyleProperty(CSSPropertyHeight, String::number(baseHeight + difference.height()) + "px", false);
}
document->updateLayout();
containerRenderer->style()->setWidth(Length());
}
if (HTMLElement* placeholder = inputElement()->placeholderElement())
- placeholder->ensureInlineStyleDecl()->setProperty(CSSPropertyTextOverflow, textShouldBeTruncated() ? CSSValueEllipsis : CSSValueClip);
+ placeholder->setInlineStyleProperty(CSSPropertyTextOverflow, textShouldBeTruncated() ? CSSValueEllipsis : CSSValueClip);
setHasOverflowClip(false);
}
, m_fontFaceRule(CSSFontFaceRule::create())
{
ASSERT(hasTagName(font_faceTag));
- RefPtr<StylePropertySet> styleDeclaration = StylePropertySet::create(m_fontFaceRule.get());
+ RefPtr<StylePropertySet> styleDeclaration = StylePropertySet::create();
styleDeclaration->setStrictParsing(true);
m_fontFaceRule->setDeclaration(styleDeclaration.release());
}
SVGElement::insertedIntoDocument();
document()->mappedElementSheet()->append(m_fontFaceRule);
m_fontFaceRule->setParentStyleSheet(document()->mappedElementSheet());
+ m_fontFaceRule->declaration()->setContextStyleSheet(document()->mappedElementSheet());
rebuildFontFace();
}
break;
}
}
+ m_fontFaceRule->declaration()->setContextStyleSheet(0);
document()->styleSelectorChanged(DeferRecalcStyle);
}