Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(494)

Unified Diff: third_party/WebKit/Source/core/dom/Element.cpp

Issue 1590193002: Partial implementation of inline StylePropertyMap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@maps
Patch Set: Update tests Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/Element.cpp
diff --git a/third_party/WebKit/Source/core/dom/Element.cpp b/third_party/WebKit/Source/core/dom/Element.cpp
index 35399cff8565c8edc5b25c49a79ad22a1ff3878f..9f369e7ba351efc541bba4232883011b30587b3f 100644
--- a/third_party/WebKit/Source/core/dom/Element.cpp
+++ b/third_party/WebKit/Source/core/dom/Element.cpp
@@ -3384,6 +3384,13 @@ CSSStyleDeclaration* Element::style()
return &ensureElementRareData().ensureInlineCSSStyleDeclaration(this);
}
+StylePropertyMap* Element::styleMap()
+{
+ if (!isStyledElement())
+ return nullptr;
+ return &ensureElementRareData().ensureInlineStylePropertyMap(this);
+}
+
MutableStylePropertySet& Element::ensureMutableInlineStyle()
{
ASSERT(isStyledElement());
@@ -3457,7 +3464,8 @@ void Element::inlineStyleChanged()
bool Element::setInlineStyleProperty(CSSPropertyID propertyID, CSSValueID identifier, bool important)
{
ASSERT(isStyledElement());
- ensureMutableInlineStyle().setProperty(propertyID, cssValuePool().createIdentifierValue(identifier), important);
+ RefPtrWillBeRawPtr<CSSValue> cssValue = cssValuePool().createIdentifierValue(identifier);
Timothy Loh 2016/02/09 07:29:32 (btw at some point you'll want to look over your p
meade_UTC10 2016/02/10 05:55:39 Acknowledged.
+ ensureMutableInlineStyle().setProperty(propertyID, cssValue, important);
inlineStyleChanged();
return true;
}
@@ -3465,7 +3473,8 @@ bool Element::setInlineStyleProperty(CSSPropertyID propertyID, CSSValueID identi
bool Element::setInlineStyleProperty(CSSPropertyID propertyID, double value, CSSPrimitiveValue::UnitType unit, bool important)
{
ASSERT(isStyledElement());
- ensureMutableInlineStyle().setProperty(propertyID, cssValuePool().createValue(value, unit), important);
+ RefPtrWillBeRawPtr<CSSValue> cssValue = cssValuePool().createValue(value, unit);
+ ensureMutableInlineStyle().setProperty(propertyID, cssValue, important);
inlineStyleChanged();
return true;
}
@@ -3473,20 +3482,32 @@ bool Element::setInlineStyleProperty(CSSPropertyID propertyID, double value, CSS
bool Element::setInlineStyleProperty(CSSPropertyID propertyID, const String& value, bool important)
{
ASSERT(isStyledElement());
- bool changes = ensureMutableInlineStyle().setProperty(propertyID, value, important, document().elementSheet().contents());
- if (changes)
+ MutableStylePropertySet& mutableStylePropertySet = ensureMutableInlineStyle();
+ bool changes = mutableStylePropertySet.setProperty(propertyID, value, important, document().elementSheet().contents());
+ if (changes) {
inlineStyleChanged();
+ }
return changes;
}
+bool Element::setInlineStyleProperty(CSSPropertyID propertyID, const PassRefPtrWillBeRawPtr<CSSValue> value, bool important)
+{
+ ASSERT(isStyledElement());
+ ensureMutableInlineStyle().setProperty(propertyID, value);
+ inlineStyleChanged();
+ // This is the hook for InlineStylePropertyMap so don't update it here.
+ return true;
+}
+
bool Element::removeInlineStyleProperty(CSSPropertyID propertyID)
{
ASSERT(isStyledElement());
if (!inlineStyle())
return false;
bool changes = ensureMutableInlineStyle().removeProperty(propertyID);
- if (changes)
+ if (changes) {
inlineStyleChanged();
+ }
return changes;
}
@@ -3508,6 +3529,20 @@ void Element::updatePresentationAttributeStyle()
elementData.m_presentationAttributeStyle = computePresentationAttributeStyle(*this);
}
+void Element::invalidateInlineStylePropertyMap()
+{
+ if (!hasRareData())
+ return;
+ ElementRareData* rareData = elementRareData();
+ InlineStylePropertyMap* inlineStylePropertyMap = rareData->inlineStylePropertyMap();
+ if (!inlineStylePropertyMap) {
+ // Probably it's not being used, so don't bother. If/when one is created it will be filed in.
+ return;
+ }
+
+ inlineStylePropertyMap->invalidate();
+}
+
void Element::addPropertyToPresentationAttributeStyle(MutableStylePropertySet* style, CSSPropertyID propertyID, CSSValueID identifier)
{
ASSERT(isStyledElement());

Powered by Google App Engine
This is Rietveld 408576698