Commit 897d431a authored by meade's avatar meade Committed by Commit bot

Resubmission of sashab's patch: Make CSSComputedStyledeclaration::getPropertyCSSValue return const

Make CSSComputedStyledeclaration::getPropertyCSSValue() return a const
CSSValue* instead of a regular CSSValue*. This required changing
CSSStyleDeclaration::getPropertyCSSValueInternal() return a const
CSSValue* as well, and marking CSSValueList::copy() as a const method
(which it already was, it was just missing the const modifier). This is
pre-work for making CSSValueList store const CSSValues.

This patch is mostly mechanical changes, but does contain one logic
change: the static method mergeTextDecorationValues in EditingStyle
needs to be changed since it modifies a CSSValueList that points inside
the mutable style. Instead, the function is changed to take two
CSSValueLists and return a new one, and the callsite is changed to
replace the old CSSValueList with the new one in the style rather than
modifying the old CSSValueList in-place.

Original patch is here:
https://codereview.chromium.org/2034013002

BUG=526586

Review-Url: https://codereview.chromium.org/2046463003
Cr-Commit-Position: refs/heads/master@{#398235}
parent 3b4f64f3
...@@ -195,7 +195,7 @@ void V8CSSStyleDeclaration::namedPropertyGetterCustom(v8::Local<v8::Name> name, ...@@ -195,7 +195,7 @@ void V8CSSStyleDeclaration::namedPropertyGetterCustom(v8::Local<v8::Name> name,
CSSStyleDeclaration* impl = V8CSSStyleDeclaration::toImpl(info.Holder()); CSSStyleDeclaration* impl = V8CSSStyleDeclaration::toImpl(info.Holder());
// TODO(leviw): This API doesn't support custom properties. // TODO(leviw): This API doesn't support custom properties.
CSSValue* cssValue = impl->getPropertyCSSValueInternal(resolvedProperty); const CSSValue* cssValue = impl->getPropertyCSSValueInternal(resolvedProperty);
if (cssValue) { if (cssValue) {
v8SetReturnValueStringOrNull(info, cssValue->cssText(), info.GetIsolate()); v8SetReturnValueStringOrNull(info, cssValue->cssText(), info.GetIsolate());
return; return;
......
...@@ -401,7 +401,7 @@ inline static CSSPrimitiveValue* zoomAdjustedPixelValue(double value, const Comp ...@@ -401,7 +401,7 @@ inline static CSSPrimitiveValue* zoomAdjustedPixelValue(double value, const Comp
return CSSPrimitiveValue::create(adjustFloatForAbsoluteZoom(value, style), CSSPrimitiveValue::UnitType::Pixels); return CSSPrimitiveValue::create(adjustFloatForAbsoluteZoom(value, style), CSSPrimitiveValue::UnitType::Pixels);
} }
CSSValue* CSSComputedStyleDeclaration::getFontSizeCSSValuePreferringKeyword() const const CSSValue* CSSComputedStyleDeclaration::getFontSizeCSSValuePreferringKeyword() const
{ {
if (!m_node) if (!m_node)
return nullptr; return nullptr;
...@@ -514,7 +514,7 @@ Node* CSSComputedStyleDeclaration::styledNode() const ...@@ -514,7 +514,7 @@ Node* CSSComputedStyleDeclaration::styledNode() const
return m_node.get(); return m_node.get();
} }
CSSValue* CSSComputedStyleDeclaration::getPropertyCSSValue(AtomicString customPropertyName) const const CSSValue* CSSComputedStyleDeclaration::getPropertyCSSValue(AtomicString customPropertyName) const
{ {
Node* styledNode = this->styledNode(); Node* styledNode = this->styledNode();
if (!styledNode) if (!styledNode)
...@@ -536,7 +536,7 @@ std::unique_ptr<HashMap<AtomicString, RefPtr<CSSVariableData>>> CSSComputedStyle ...@@ -536,7 +536,7 @@ std::unique_ptr<HashMap<AtomicString, RefPtr<CSSVariableData>>> CSSComputedStyle
return ComputedStyleCSSValueMapping::getVariables(*style); return ComputedStyleCSSValueMapping::getVariables(*style);
} }
CSSValue* CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propertyID) const const CSSValue* CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propertyID) const
{ {
Node* styledNode = this->styledNode(); Node* styledNode = this->styledNode();
if (!styledNode) if (!styledNode)
...@@ -576,7 +576,7 @@ CSSValue* CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propert ...@@ -576,7 +576,7 @@ CSSValue* CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propert
String CSSComputedStyleDeclaration::getPropertyValue(CSSPropertyID propertyID) const String CSSComputedStyleDeclaration::getPropertyValue(CSSPropertyID propertyID) const
{ {
CSSValue* value = getPropertyCSSValue(propertyID); const CSSValue* value = getPropertyCSSValue(propertyID);
if (value) if (value)
return value->cssText(); return value->cssText();
return ""; return "";
...@@ -610,7 +610,7 @@ bool CSSComputedStyleDeclaration::cssPropertyMatches(CSSPropertyID propertyID, c ...@@ -610,7 +610,7 @@ bool CSSComputedStyleDeclaration::cssPropertyMatches(CSSPropertyID propertyID, c
return true; return true;
} }
} }
CSSValue* value = getPropertyCSSValue(propertyID); const CSSValue* value = getPropertyCSSValue(propertyID);
return value && propertyValue && value->equals(*propertyValue); return value && propertyValue && value->equals(*propertyValue);
} }
...@@ -624,7 +624,7 @@ MutableStylePropertySet* CSSComputedStyleDeclaration::copyPropertiesInSet(const ...@@ -624,7 +624,7 @@ MutableStylePropertySet* CSSComputedStyleDeclaration::copyPropertiesInSet(const
HeapVector<CSSProperty, 256> list; HeapVector<CSSProperty, 256> list;
list.reserveInitialCapacity(properties.size()); list.reserveInitialCapacity(properties.size());
for (unsigned i = 0; i < properties.size(); ++i) { for (unsigned i = 0; i < properties.size(); ++i) {
CSSValue* value = getPropertyCSSValue(properties[i]); const CSSValue* value = getPropertyCSSValue(properties[i]);
if (value) if (value)
list.append(CSSProperty(properties[i], value, false)); list.append(CSSProperty(properties[i], value, false));
} }
...@@ -641,7 +641,7 @@ String CSSComputedStyleDeclaration::getPropertyValue(const String& propertyName) ...@@ -641,7 +641,7 @@ String CSSComputedStyleDeclaration::getPropertyValue(const String& propertyName)
CSSPropertyID propertyID = cssPropertyID(propertyName); CSSPropertyID propertyID = cssPropertyID(propertyName);
if (!propertyID) { if (!propertyID) {
if (RuntimeEnabledFeatures::cssVariablesEnabled() && CSSVariableParser::isValidVariableName(propertyName)) { if (RuntimeEnabledFeatures::cssVariablesEnabled() && CSSVariableParser::isValidVariableName(propertyName)) {
CSSValue* value = getPropertyCSSValue(AtomicString(propertyName)); const CSSValue* value = getPropertyCSSValue(AtomicString(propertyName));
if (value) if (value)
return value->cssText(); return value->cssText();
} }
...@@ -678,7 +678,7 @@ String CSSComputedStyleDeclaration::removeProperty(const String& name, Exception ...@@ -678,7 +678,7 @@ String CSSComputedStyleDeclaration::removeProperty(const String& name, Exception
return String(); return String();
} }
CSSValue* CSSComputedStyleDeclaration::getPropertyCSSValueInternal(CSSPropertyID propertyID) const CSSValue* CSSComputedStyleDeclaration::getPropertyCSSValueInternal(CSSPropertyID propertyID)
{ {
return getPropertyCSSValue(propertyID); return getPropertyCSSValue(propertyID);
} }
......
...@@ -58,11 +58,11 @@ public: ...@@ -58,11 +58,11 @@ public:
MutableStylePropertySet* copyProperties() const; MutableStylePropertySet* copyProperties() const;
CSSValue* getPropertyCSSValue(CSSPropertyID) const; const CSSValue* getPropertyCSSValue(CSSPropertyID) const;
CSSValue* getPropertyCSSValue(AtomicString customPropertyName) const; const CSSValue* getPropertyCSSValue(AtomicString customPropertyName) const;
std::unique_ptr<HashMap<AtomicString, RefPtr<CSSVariableData>>> getVariables() const; std::unique_ptr<HashMap<AtomicString, RefPtr<CSSVariableData>>> getVariables() const;
CSSValue* getFontSizeCSSValuePreferringKeyword() const; const CSSValue* getFontSizeCSSValuePreferringKeyword() const;
bool isMonospaceFont() const; bool isMonospaceFont() const;
MutableStylePropertySet* copyPropertiesInSet(const Vector<CSSPropertyID>&) const; MutableStylePropertySet* copyPropertiesInSet(const Vector<CSSPropertyID>&) const;
...@@ -94,7 +94,7 @@ private: ...@@ -94,7 +94,7 @@ private:
void setCSSFloat(const String&, ExceptionState&); void setCSSFloat(const String&, ExceptionState&);
String cssText() const override; String cssText() const override;
void setCSSText(const String&, ExceptionState&) override; void setCSSText(const String&, ExceptionState&) override;
CSSValue* getPropertyCSSValueInternal(CSSPropertyID) override; const CSSValue* getPropertyCSSValueInternal(CSSPropertyID) override;
String getPropertyValueInternal(CSSPropertyID) override; String getPropertyValueInternal(CSSPropertyID) override;
void setPropertyInternal(CSSPropertyID, const String& customPropertyName, const String& value, bool important, ExceptionState&) override; void setPropertyInternal(CSSPropertyID, const String& customPropertyName, const String& value, bool important, ExceptionState&) override;
......
...@@ -65,7 +65,7 @@ public: ...@@ -65,7 +65,7 @@ public:
// CSSPropertyID versions of the CSSOM functions to support bindings and editing. // CSSPropertyID versions of the CSSOM functions to support bindings and editing.
// Use the non-virtual methods in the concrete subclasses when possible. // Use the non-virtual methods in the concrete subclasses when possible.
// The CSSValue returned by this function should not be exposed to the web as it may be used by multiple documents at the same time. // The CSSValue returned by this function should not be exposed to the web as it may be used by multiple documents at the same time.
virtual CSSValue* getPropertyCSSValueInternal(CSSPropertyID) = 0; virtual const CSSValue* getPropertyCSSValueInternal(CSSPropertyID) = 0;
virtual String getPropertyValueInternal(CSSPropertyID) = 0; virtual String getPropertyValueInternal(CSSPropertyID) = 0;
virtual void setPropertyInternal(CSSPropertyID, const String& propertyValue, const String& value, bool important, ExceptionState&) = 0; virtual void setPropertyInternal(CSSPropertyID, const String& propertyValue, const String& value, bool important, ExceptionState&) = 0;
......
...@@ -62,7 +62,7 @@ bool CSSValueList::hasValue(const CSSValue& val) const ...@@ -62,7 +62,7 @@ bool CSSValueList::hasValue(const CSSValue& val) const
return false; return false;
} }
CSSValueList* CSSValueList::copy() CSSValueList* CSSValueList::copy() const
{ {
CSSValueList* newList = nullptr; CSSValueList* newList = nullptr;
switch (m_valueListSeparator) { switch (m_valueListSeparator) {
......
...@@ -63,7 +63,7 @@ public: ...@@ -63,7 +63,7 @@ public:
void append(CSSValue* value) { m_values.append(value); } void append(CSSValue* value) { m_values.append(value); }
bool removeAll(const CSSValue&); bool removeAll(const CSSValue&);
bool hasValue(const CSSValue&) const; bool hasValue(const CSSValue&) const;
CSSValueList* copy(); CSSValueList* copy() const;
String customCSSText() const; String customCSSText() const;
bool equals(const CSSValueList&) const; bool equals(const CSSValueList&) const;
......
...@@ -258,7 +258,7 @@ String AbstractPropertySetCSSStyleDeclaration::removeProperty(const String& prop ...@@ -258,7 +258,7 @@ String AbstractPropertySetCSSStyleDeclaration::removeProperty(const String& prop
return result; return result;
} }
CSSValue* AbstractPropertySetCSSStyleDeclaration::getPropertyCSSValueInternal(CSSPropertyID propertyID) const CSSValue* AbstractPropertySetCSSStyleDeclaration::getPropertyCSSValueInternal(CSSPropertyID propertyID)
{ {
return propertySet().getPropertyCSSValue(propertyID); return propertySet().getPropertyCSSValue(propertyID);
} }
......
...@@ -60,7 +60,7 @@ private: ...@@ -60,7 +60,7 @@ private:
void setCSSFloat(const String&, ExceptionState&); void setCSSFloat(const String&, ExceptionState&);
String cssText() const final; String cssText() const final;
void setCSSText(const String&, ExceptionState&) final; void setCSSText(const String&, ExceptionState&) final;
CSSValue* getPropertyCSSValueInternal(CSSPropertyID) final; const CSSValue* getPropertyCSSValueInternal(CSSPropertyID) final;
String getPropertyValueInternal(CSSPropertyID) final; String getPropertyValueInternal(CSSPropertyID) final;
void setPropertyInternal(CSSPropertyID, const String& customPropertyName, const String& value, bool important, ExceptionState&) final; void setPropertyInternal(CSSPropertyID, const String& customPropertyName, const String& value, bool important, ExceptionState&) final;
......
...@@ -11,7 +11,7 @@ namespace blink { ...@@ -11,7 +11,7 @@ namespace blink {
StylePropertyMap::StyleValueVector ComputedStylePropertyMap::getAll(CSSPropertyID propertyID) StylePropertyMap::StyleValueVector ComputedStylePropertyMap::getAll(CSSPropertyID propertyID)
{ {
CSSValue* cssValue = m_computedStyleDeclaration->getPropertyCSSValueInternal(propertyID); const CSSValue* cssValue = m_computedStyleDeclaration->getPropertyCSSValueInternal(propertyID);
if (!cssValue) if (!cssValue)
return StylePropertyMap::StyleValueVector(); return StylePropertyMap::StyleValueVector();
return cssValueToStyleValueVector(propertyID, *cssValue); return cssValueToStyleValueVector(propertyID, *cssValue);
......
...@@ -160,11 +160,11 @@ static CSSComputedStyleDeclaration* ensureComputedStyle(const Position& position ...@@ -160,11 +160,11 @@ static CSSComputedStyleDeclaration* ensureComputedStyle(const Position& position
static MutableStylePropertySet* getPropertiesNotIn(StylePropertySet* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle); static MutableStylePropertySet* getPropertiesNotIn(StylePropertySet* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle);
enum LegacyFontSizeMode { AlwaysUseLegacyFontSize, UseLegacyFontSizeOnlyIfPixelValuesMatch }; enum LegacyFontSizeMode { AlwaysUseLegacyFontSize, UseLegacyFontSizeOnlyIfPixelValuesMatch };
static int legacyFontSizeFromCSSValue(Document*, CSSPrimitiveValue*, bool, LegacyFontSizeMode); static int legacyFontSizeFromCSSValue(Document*, const CSSPrimitiveValue*, bool, LegacyFontSizeMode);
static bool isTransparentColorValue(CSSValue*); static bool isTransparentColorValue(const CSSValue*);
static bool hasTransparentBackgroundColor(CSSStyleDeclaration*); static bool hasTransparentBackgroundColor(CSSStyleDeclaration*);
static bool hasTransparentBackgroundColor(StylePropertySet*); static bool hasTransparentBackgroundColor(StylePropertySet*);
static CSSValue* backgroundColorValueInEffect(Node*); static const CSSValue* backgroundColorValueInEffect(Node*);
static bool hasAncestorVerticalAlignStyle(Node&, CSSValueID); static bool hasAncestorVerticalAlignStyle(Node&, CSSValueID);
class HTMLElementEquivalent : public GarbageCollected<HTMLElementEquivalent> { class HTMLElementEquivalent : public GarbageCollected<HTMLElementEquivalent> {
...@@ -213,7 +213,7 @@ HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, CSSValueID primit ...@@ -213,7 +213,7 @@ HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, CSSValueID primit
bool HTMLElementEquivalent::valueIsPresentInStyle(HTMLElement* element, StylePropertySet* style) const bool HTMLElementEquivalent::valueIsPresentInStyle(HTMLElement* element, StylePropertySet* style) const
{ {
CSSValue* value = style->getPropertyCSSValue(m_propertyID); const CSSValue* value = style->getPropertyCSSValue(m_propertyID);
return matches(element) && value && value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValueID() == m_primitiveValue->getValueID(); return matches(element) && value && value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValueID() == m_primitiveValue->getValueID();
} }
...@@ -251,7 +251,7 @@ bool HTMLTextDecorationEquivalent::propertyExistsInStyle(const StylePropertySet* ...@@ -251,7 +251,7 @@ bool HTMLTextDecorationEquivalent::propertyExistsInStyle(const StylePropertySet*
bool HTMLTextDecorationEquivalent::valueIsPresentInStyle(HTMLElement* element, StylePropertySet* style) const bool HTMLTextDecorationEquivalent::valueIsPresentInStyle(HTMLElement* element, StylePropertySet* style) const
{ {
CSSValue* styleValue = style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect); const CSSValue* styleValue = style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
if (!styleValue) if (!styleValue)
styleValue = style->getPropertyCSSValue(textDecorationPropertyForEditing()); styleValue = style->getPropertyCSSValue(textDecorationPropertyForEditing());
return matches(element) && styleValue && styleValue->isValueList() && toCSSValueList(styleValue)->hasValue(*m_primitiveValue); return matches(element) && styleValue && styleValue->isValueList() && toCSSValueList(styleValue)->hasValue(*m_primitiveValue);
...@@ -298,7 +298,7 @@ HTMLAttributeEquivalent::HTMLAttributeEquivalent(CSSPropertyID id, const Qualifi ...@@ -298,7 +298,7 @@ HTMLAttributeEquivalent::HTMLAttributeEquivalent(CSSPropertyID id, const Qualifi
bool HTMLAttributeEquivalent::valueIsPresentInStyle(HTMLElement* element, StylePropertySet* style) const bool HTMLAttributeEquivalent::valueIsPresentInStyle(HTMLElement* element, StylePropertySet* style) const
{ {
CSSValue* value = attributeValueAsCSSValue(element); CSSValue* value = attributeValueAsCSSValue(element);
CSSValue* styleValue = style->getPropertyCSSValue(m_propertyID); const CSSValue* styleValue = style->getPropertyCSSValue(m_propertyID);
return compareCSSValuePtr(value, styleValue); return compareCSSValuePtr(value, styleValue);
} }
...@@ -378,7 +378,7 @@ EditingStyle::EditingStyle(CSSPropertyID propertyID, const String& value) ...@@ -378,7 +378,7 @@ EditingStyle::EditingStyle(CSSPropertyID propertyID, const String& value)
m_isVerticalAlign = propertyID == CSSPropertyVerticalAlign && (value == "sub" || value == "super"); m_isVerticalAlign = propertyID == CSSPropertyVerticalAlign && (value == "sub" || value == "super");
} }
static Color cssValueToColor(CSSValue* colorValue) static Color cssValueToColor(const CSSValue* colorValue)
{ {
if (!colorValue || (!colorValue->isColorValue() && !colorValue->isPrimitiveValue())) if (!colorValue || (!colorValue->isColorValue() && !colorValue->isPrimitiveValue()))
return Color::transparent; return Color::transparent;
...@@ -456,9 +456,9 @@ void EditingStyle::init(Node* node, PropertiesToInclude propertiesToInclude) ...@@ -456,9 +456,9 @@ void EditingStyle::init(Node* node, PropertiesToInclude propertiesToInclude)
m_mutableStyle = propertiesToInclude == AllProperties && computedStyleAtPosition ? computedStyleAtPosition->copyProperties() : editingStyleFromComputedStyle(computedStyleAtPosition); m_mutableStyle = propertiesToInclude == AllProperties && computedStyleAtPosition ? computedStyleAtPosition->copyProperties() : editingStyleFromComputedStyle(computedStyleAtPosition);
if (propertiesToInclude == EditingPropertiesInEffect) { if (propertiesToInclude == EditingPropertiesInEffect) {
if (CSSValue* value = backgroundColorValueInEffect(node)) if (const CSSValue* value = backgroundColorValueInEffect(node))
m_mutableStyle->setProperty(CSSPropertyBackgroundColor, value->cssText()); m_mutableStyle->setProperty(CSSPropertyBackgroundColor, value->cssText());
if (CSSValue* value = computedStyleAtPosition->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect)) if (const CSSValue* value = computedStyleAtPosition->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect))
m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssText()); m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssText());
} }
...@@ -510,11 +510,11 @@ void EditingStyle::extractFontSizeDelta() ...@@ -510,11 +510,11 @@ void EditingStyle::extractFontSizeDelta()
} }
// Get the adjustment amount out of the style. // Get the adjustment amount out of the style.
CSSValue* value = m_mutableStyle->getPropertyCSSValue(CSSPropertyWebkitFontSizeDelta); const CSSValue* value = m_mutableStyle->getPropertyCSSValue(CSSPropertyWebkitFontSizeDelta);
if (!value || !value->isPrimitiveValue()) if (!value || !value->isPrimitiveValue())
return; return;
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
// Only PX handled now. If we handle more types in the future, perhaps // Only PX handled now. If we handle more types in the future, perhaps
// a switch statement here would be more appropriate. // a switch statement here would be more appropriate.
...@@ -535,13 +535,13 @@ bool EditingStyle::textDirection(WritingDirection& writingDirection) const ...@@ -535,13 +535,13 @@ bool EditingStyle::textDirection(WritingDirection& writingDirection) const
if (!m_mutableStyle) if (!m_mutableStyle)
return false; return false;
CSSValue* unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi); const CSSValue* unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi);
if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) if (!unicodeBidi || !unicodeBidi->isPrimitiveValue())
return false; return false;
CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getValueID(); CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getValueID();
if (isEmbedOrIsolate(unicodeBidiValue)) { if (isEmbedOrIsolate(unicodeBidiValue)) {
CSSValue* direction = m_mutableStyle->getPropertyCSSValue(CSSPropertyDirection); const CSSValue* direction = m_mutableStyle->getPropertyCSSValue(CSSPropertyDirection);
if (!direction || !direction->isPrimitiveValue()) if (!direction || !direction->isPrimitiveValue())
return false; return false;
...@@ -682,7 +682,7 @@ void EditingStyle::collapseTextDecorationProperties() ...@@ -682,7 +682,7 @@ void EditingStyle::collapseTextDecorationProperties()
if (!m_mutableStyle) if (!m_mutableStyle)
return; return;
CSSValue* textDecorationsInEffect = m_mutableStyle->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect); const CSSValue* textDecorationsInEffect = m_mutableStyle->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
if (!textDecorationsInEffect) if (!textDecorationsInEffect)
return; return;
...@@ -755,7 +755,7 @@ TriState EditingStyle::triStateOfStyle(const VisibleSelection& selection) const ...@@ -755,7 +755,7 @@ TriState EditingStyle::triStateOfStyle(const VisibleSelection& selection) const
// style(vertical-align) to it so that document.queryCommandState() works with the style. // style(vertical-align) to it so that document.queryCommandState() works with the style.
// See bug http://crbug.com/582225. // See bug http://crbug.com/582225.
if (m_isVerticalAlign && getIdentifierValue(nodeStyle, CSSPropertyVerticalAlign) == CSSValueBaseline) { if (m_isVerticalAlign && getIdentifierValue(nodeStyle, CSSPropertyVerticalAlign) == CSSValueBaseline) {
CSSPrimitiveValue* verticalAlign = toCSSPrimitiveValue(m_mutableStyle->getPropertyCSSValue(CSSPropertyVerticalAlign)); const CSSPrimitiveValue* verticalAlign = toCSSPrimitiveValue(m_mutableStyle->getPropertyCSSValue(CSSPropertyVerticalAlign));
if (hasAncestorVerticalAlignStyle(node, verticalAlign->getValueID())) if (hasAncestorVerticalAlignStyle(node, verticalAlign->getValueID()))
node.mutableComputedStyle()->setVerticalAlign(verticalAlign->convertTo<EVerticalAlign>()); node.mutableComputedStyle()->setVerticalAlign(verticalAlign->convertTo<EVerticalAlign>());
} }
...@@ -1001,8 +1001,8 @@ void EditingStyle::prepareToApplyAt(const Position& position, ShouldPreserveWrit ...@@ -1001,8 +1001,8 @@ void EditingStyle::prepareToApplyAt(const Position& position, ShouldPreserveWrit
EditingStyle* editingStyleAtPosition = EditingStyle::create(position, EditingPropertiesInEffect); EditingStyle* editingStyleAtPosition = EditingStyle::create(position, EditingPropertiesInEffect);
StylePropertySet* styleAtPosition = editingStyleAtPosition->m_mutableStyle.get(); StylePropertySet* styleAtPosition = editingStyleAtPosition->m_mutableStyle.get();
CSSValue* unicodeBidi = nullptr; const CSSValue* unicodeBidi = nullptr;
CSSValue* direction = nullptr; const CSSValue* direction = nullptr;
if (shouldPreserveWritingDirection == PreserveWritingDirection) { if (shouldPreserveWritingDirection == PreserveWritingDirection) {
unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi); unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi);
direction = m_mutableStyle->getPropertyCSSValue(CSSPropertyDirection); direction = m_mutableStyle->getPropertyCSSValue(CSSPropertyDirection);
...@@ -1141,15 +1141,18 @@ EditingStyle* EditingStyle::wrappingStyleForSerialization(ContainerNode* context ...@@ -1141,15 +1141,18 @@ EditingStyle* EditingStyle::wrappingStyleForSerialization(ContainerNode* context
return wrappingStyle; return wrappingStyle;
} }
static void mergeTextDecorationValues(CSSValueList* mergedValue, const CSSValueList* valueToMerge) static CSSValueList* mergeTextDecorationValues(const CSSValueList* mergedValue, const CSSValueList* valueToMerge)
{ {
DEFINE_STATIC_LOCAL(CSSPrimitiveValue, underline, (CSSPrimitiveValue::createIdentifier(CSSValueUnderline))); DEFINE_STATIC_LOCAL(CSSPrimitiveValue, underline, (CSSPrimitiveValue::createIdentifier(CSSValueUnderline)));
DEFINE_STATIC_LOCAL(CSSPrimitiveValue, lineThrough, (CSSPrimitiveValue::createIdentifier(CSSValueLineThrough))); DEFINE_STATIC_LOCAL(CSSPrimitiveValue, lineThrough, (CSSPrimitiveValue::createIdentifier(CSSValueLineThrough)));
CSSValueList* result = mergedValue->copy();
if (valueToMerge->hasValue(underline) && !mergedValue->hasValue(underline)) if (valueToMerge->hasValue(underline) && !mergedValue->hasValue(underline))
mergedValue->append(&underline); result->append(&underline);
if (valueToMerge->hasValue(lineThrough) && !mergedValue->hasValue(lineThrough)) if (valueToMerge->hasValue(lineThrough) && !mergedValue->hasValue(lineThrough))
mergedValue->append(&lineThrough); result->append(&lineThrough);
return result;
} }
void EditingStyle::mergeStyle(const StylePropertySet* style, CSSPropertyOverrideMode mode) void EditingStyle::mergeStyle(const StylePropertySet* style, CSSPropertyOverrideMode mode)
...@@ -1165,12 +1168,13 @@ void EditingStyle::mergeStyle(const StylePropertySet* style, CSSPropertyOverride ...@@ -1165,12 +1168,13 @@ void EditingStyle::mergeStyle(const StylePropertySet* style, CSSPropertyOverride
unsigned propertyCount = style->propertyCount(); unsigned propertyCount = style->propertyCount();
for (unsigned i = 0; i < propertyCount; ++i) { for (unsigned i = 0; i < propertyCount; ++i) {
StylePropertySet::PropertyReference property = style->propertyAt(i); StylePropertySet::PropertyReference property = style->propertyAt(i);
CSSValue* value = m_mutableStyle->getPropertyCSSValue(property.id()); const CSSValue* value = m_mutableStyle->getPropertyCSSValue(property.id());
// text decorations never override values // text decorations never override values
if ((property.id() == textDecorationPropertyForEditing() || property.id() == CSSPropertyWebkitTextDecorationsInEffect) && property.value()->isValueList() && value) { if ((property.id() == textDecorationPropertyForEditing() || property.id() == CSSPropertyWebkitTextDecorationsInEffect) && property.value()->isValueList() && value) {
if (value->isValueList()) { if (value->isValueList()) {
mergeTextDecorationValues(toCSSValueList(value), toCSSValueList(property.value())); CSSValueList* result = mergeTextDecorationValues(toCSSValueList(value), toCSSValueList(property.value()));
m_mutableStyle->setProperty(property.id(), result, property.isImportant());
continue; continue;
} }
value = nullptr; // text-decoration: none is equivalent to not having the property value = nullptr; // text-decoration: none is equivalent to not having the property
...@@ -1222,7 +1226,7 @@ void EditingStyle::mergeStyleFromRulesForSerialization(Element* element) ...@@ -1222,7 +1226,7 @@ void EditingStyle::mergeStyleFromRulesForSerialization(Element* element)
if (!value->isPrimitiveValue()) if (!value->isPrimitiveValue())
continue; continue;
if (toCSSPrimitiveValue(value)->isPercentage()) { if (toCSSPrimitiveValue(value)->isPercentage()) {
if (CSSValue* computedPropertyValue = computedStyleForElement->getPropertyCSSValue(property.id())) if (const CSSValue* computedPropertyValue = computedStyleForElement->getPropertyCSSValue(property.id()))
fromComputedStyle->addRespectingCascade(CSSProperty(property.id(), computedPropertyValue)); fromComputedStyle->addRespectingCascade(CSSProperty(property.id(), computedPropertyValue));
} }
} }
...@@ -1316,7 +1320,7 @@ void EditingStyle::forceInline() ...@@ -1316,7 +1320,7 @@ void EditingStyle::forceInline()
int EditingStyle::legacyFontSize(Document* document) const int EditingStyle::legacyFontSize(Document* document) const
{ {
CSSValue* cssValue = m_mutableStyle->getPropertyCSSValue(CSSPropertyFontSize); const CSSValue* cssValue = m_mutableStyle->getPropertyCSSValue(CSSPropertyFontSize);
if (!cssValue || !cssValue->isPrimitiveValue()) if (!cssValue || !cssValue->isPrimitiveValue())
return 0; return 0;
return legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(cssValue), return legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(cssValue),
...@@ -1361,7 +1365,7 @@ EditingStyle* EditingStyle::styleAtSelectionStart(const VisibleSelection& select ...@@ -1361,7 +1365,7 @@ EditingStyle* EditingStyle::styleAtSelectionStart(const VisibleSelection& select
// and find the background color of the common ancestor. // and find the background color of the common ancestor.
if (shouldUseBackgroundColorInEffect && (selection.isRange() || hasTransparentBackgroundColor(style->m_mutableStyle.get()))) { if (shouldUseBackgroundColorInEffect && (selection.isRange() || hasTransparentBackgroundColor(style->m_mutableStyle.get()))) {
const EphemeralRange range(selection.toNormalizedEphemeralRange()); const EphemeralRange range(selection.toNormalizedEphemeralRange());
if (CSSValue* value = backgroundColorValueInEffect(Range::commonAncestorContainer(range.startPosition().computeContainerNode(), range.endPosition().computeContainerNode()))) if (const CSSValue* value = backgroundColorValueInEffect(Range::commonAncestorContainer(range.startPosition().computeContainerNode(), range.endPosition().computeContainerNode())))
style->setProperty(CSSPropertyBackgroundColor, value->cssText()); style->setProperty(CSSPropertyBackgroundColor, value->cssText());
} }
...@@ -1399,7 +1403,7 @@ WritingDirection EditingStyle::textDirectionForSelection(const VisibleSelection& ...@@ -1399,7 +1403,7 @@ WritingDirection EditingStyle::textDirectionForSelection(const VisibleSelection&
continue; continue;
CSSComputedStyleDeclaration* style = CSSComputedStyleDeclaration::create(n); CSSComputedStyleDeclaration* style = CSSComputedStyleDeclaration::create(n);
CSSValue* unicodeBidi = style->getPropertyCSSValue(CSSPropertyUnicodeBidi); const CSSValue* unicodeBidi = style->getPropertyCSSValue(CSSPropertyUnicodeBidi);
if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) if (!unicodeBidi || !unicodeBidi->isPrimitiveValue())
continue; continue;
...@@ -1432,7 +1436,7 @@ WritingDirection EditingStyle::textDirectionForSelection(const VisibleSelection& ...@@ -1432,7 +1436,7 @@ WritingDirection EditingStyle::textDirectionForSelection(const VisibleSelection&
Element* element = &toElement(runner); Element* element = &toElement(runner);
CSSComputedStyleDeclaration* style = CSSComputedStyleDeclaration::create(element); CSSComputedStyleDeclaration* style = CSSComputedStyleDeclaration::create(element);
CSSValue* unicodeBidi = style->getPropertyCSSValue(CSSPropertyUnicodeBidi); const CSSValue* unicodeBidi = style->getPropertyCSSValue(CSSPropertyUnicodeBidi);
if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) if (!unicodeBidi || !unicodeBidi->isPrimitiveValue())
continue; continue;
...@@ -1444,7 +1448,7 @@ WritingDirection EditingStyle::textDirectionForSelection(const VisibleSelection& ...@@ -1444,7 +1448,7 @@ WritingDirection EditingStyle::textDirectionForSelection(const VisibleSelection&
return NaturalWritingDirection; return NaturalWritingDirection;
DCHECK(isEmbedOrIsolate(unicodeBidiValue)) << unicodeBidiValue; DCHECK(isEmbedOrIsolate(unicodeBidiValue)) << unicodeBidiValue;
CSSValue* direction = style->getPropertyCSSValue(CSSPropertyDirection); const CSSValue* direction = style->getPropertyCSSValue(CSSPropertyDirection);
if (!direction || !direction->isPrimitiveValue()) if (!direction || !direction->isPrimitiveValue())
continue; continue;
...@@ -1472,8 +1476,8 @@ DEFINE_TRACE(EditingStyle) ...@@ -1472,8 +1476,8 @@ DEFINE_TRACE(EditingStyle)
static void reconcileTextDecorationProperties(MutableStylePropertySet* style) static void reconcileTextDecorationProperties(MutableStylePropertySet* style)
{ {
CSSValue* textDecorationsInEffect = style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect); const CSSValue* textDecorationsInEffect = style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
CSSValue* textDecoration = style->getPropertyCSSValue(textDecorationPropertyForEditing()); const CSSValue* textDecoration = style->getPropertyCSSValue(textDecorationPropertyForEditing());
// We shouldn't have both text-decoration and -webkit-text-decorations-in-effect because that wouldn't make sense. // We shouldn't have both text-decoration and -webkit-text-decorations-in-effect because that wouldn't make sense.
DCHECK(!textDecorationsInEffect || !textDecoration); DCHECK(!textDecorationsInEffect || !textDecoration);
if (textDecorationsInEffect) { if (textDecorationsInEffect) {
...@@ -1549,7 +1553,7 @@ void StyleChange::extractTextStyles(Document* document, MutableStylePropertySet* ...@@ -1549,7 +1553,7 @@ void StyleChange::extractTextStyles(Document* document, MutableStylePropertySet*
// Assuming reconcileTextDecorationProperties has been called, there should not be -webkit-text-decorations-in-effect // Assuming reconcileTextDecorationProperties has been called, there should not be -webkit-text-decorations-in-effect
// Furthermore, text-decoration: none has been trimmed so that text-decoration property is always a CSSValueList. // Furthermore, text-decoration: none has been trimmed so that text-decoration property is always a CSSValueList.
CSSValue* textDecoration = style->getPropertyCSSValue(textDecorationPropertyForEditing()); const CSSValue* textDecoration = style->getPropertyCSSValue(textDecorationPropertyForEditing());
if (textDecoration && textDecoration->isValueList()) { if (textDecoration && textDecoration->isValueList()) {
DEFINE_STATIC_LOCAL(CSSPrimitiveValue, underline, (CSSPrimitiveValue::createIdentifier(CSSValueUnderline))); DEFINE_STATIC_LOCAL(CSSPrimitiveValue, underline, (CSSPrimitiveValue::createIdentifier(CSSValueUnderline)));
DEFINE_STATIC_LOCAL(CSSPrimitiveValue, lineThrough, (CSSPrimitiveValue::createIdentifier(CSSValueLineThrough))); DEFINE_STATIC_LOCAL(CSSPrimitiveValue, lineThrough, (CSSPrimitiveValue::createIdentifier(CSSValueLineThrough)));
...@@ -1585,7 +1589,7 @@ void StyleChange::extractTextStyles(Document* document, MutableStylePropertySet* ...@@ -1585,7 +1589,7 @@ void StyleChange::extractTextStyles(Document* document, MutableStylePropertySet*
m_applyFontFace.replace('"', ""); m_applyFontFace.replace('"', "");
style->removeProperty(CSSPropertyFontFamily); style->removeProperty(CSSPropertyFontFamily);
if (CSSValue* fontSize = style->getPropertyCSSValue(CSSPropertyFontSize)) { if (const CSSValue* fontSize = style->getPropertyCSSValue(CSSPropertyFontSize)) {
if (!fontSize->isPrimitiveValue()) { if (!fontSize->isPrimitiveValue()) {
style->removeProperty(CSSPropertyFontSize); // Can't make sense of the number. Put no font size. style->removeProperty(CSSPropertyFontSize); // Can't make sense of the number. Put no font size.
} else if (int legacyFontSize = legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(fontSize), isMonospaceFont, UseLegacyFontSizeOnlyIfPixelValuesMatch)) { } else if (int legacyFontSize = legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(fontSize), isMonospaceFont, UseLegacyFontSizeOnlyIfPixelValuesMatch)) {
...@@ -1595,22 +1599,22 @@ void StyleChange::extractTextStyles(Document* document, MutableStylePropertySet* ...@@ -1595,22 +1599,22 @@ void StyleChange::extractTextStyles(Document* document, MutableStylePropertySet*
} }
} }
static void diffTextDecorations(MutableStylePropertySet* style, CSSPropertyID propertID, CSSValue* refTextDecoration) static void diffTextDecorations(MutableStylePropertySet* style, CSSPropertyID propertyID, const CSSValue* refTextDecoration)
{ {
CSSValue* textDecoration = style->getPropertyCSSValue(propertID); const CSSValue* textDecoration = style->getPropertyCSSValue(propertyID);
if (!textDecoration || !textDecoration->isValueList() || !refTextDecoration || !refTextDecoration->isValueList()) if (!textDecoration || !textDecoration->isValueList() || !refTextDecoration || !refTextDecoration->isValueList())
return; return;
CSSValueList* newTextDecoration = toCSSValueList(textDecoration)->copy(); CSSValueList* newTextDecoration = toCSSValueList(textDecoration)->copy();
CSSValueList* valuesInRefTextDecoration = toCSSValueList(refTextDecoration); const CSSValueList* valuesInRefTextDecoration = toCSSValueList(refTextDecoration);
for (size_t i = 0; i < valuesInRefTextDecoration->length(); i++) for (size_t i = 0; i < valuesInRefTextDecoration->length(); i++)
newTextDecoration->removeAll(*valuesInRefTextDecoration->item(i)); newTextDecoration->removeAll(*valuesInRefTextDecoration->item(i));
setTextDecorationProperty(style, newTextDecoration, propertID); setTextDecorationProperty(style, newTextDecoration, propertyID);
} }
static bool fontWeightIsBold(CSSValue* fontWeight) static bool fontWeightIsBold(const CSSValue* fontWeight)
{ {
if (!fontWeight->isPrimitiveValue()) if (!fontWeight->isPrimitiveValue())
return false; return false;
...@@ -1639,12 +1643,12 @@ static bool fontWeightIsBold(CSSValue* fontWeight) ...@@ -1639,12 +1643,12 @@ static bool fontWeightIsBold(CSSValue* fontWeight)
return false; return false;
} }
static bool fontWeightNeedsResolving(CSSValue* fontWeight) static bool fontWeightNeedsResolving(const CSSValue* fontWeight)
{ {
if (!fontWeight->isPrimitiveValue()) if (!fontWeight->isPrimitiveValue())
return true; return true;
CSSValueID value = toCSSPrimitiveValue(fontWeight)->getValueID(); const CSSValueID value = toCSSPrimitiveValue(fontWeight)->getValueID();
return value == CSSValueLighter || value == CSSValueBolder; return value == CSSValueLighter || value == CSSValueBolder;
} }
...@@ -1656,11 +1660,11 @@ MutableStylePropertySet* getPropertiesNotIn(StylePropertySet* styleWithRedundant ...@@ -1656,11 +1660,11 @@ MutableStylePropertySet* getPropertiesNotIn(StylePropertySet* styleWithRedundant
result->removeEquivalentProperties(baseStyle); result->removeEquivalentProperties(baseStyle);
CSSValue* baseTextDecorationsInEffect = baseStyle->getPropertyCSSValueInternal(CSSPropertyWebkitTextDecorationsInEffect); const CSSValue* baseTextDecorationsInEffect = baseStyle->getPropertyCSSValueInternal(CSSPropertyWebkitTextDecorationsInEffect);
diffTextDecorations(result, textDecorationPropertyForEditing(), baseTextDecorationsInEffect); diffTextDecorations(result, textDecorationPropertyForEditing(), baseTextDecorationsInEffect);
diffTextDecorations(result, CSSPropertyWebkitTextDecorationsInEffect, baseTextDecorationsInEffect); diffTextDecorations(result, CSSPropertyWebkitTextDecorationsInEffect, baseTextDecorationsInEffect);
if (CSSValue* baseFontWeight = baseStyle->getPropertyCSSValueInternal(CSSPropertyFontWeight)) { if (const CSSValue* baseFontWeight = baseStyle->getPropertyCSSValueInternal(CSSPropertyFontWeight)) {
if (CSSValue* fontWeight = result->getPropertyCSSValue(CSSPropertyFontWeight)) { if (CSSValue* fontWeight = result->getPropertyCSSValue(CSSPropertyFontWeight)) {
if (!fontWeightNeedsResolving(fontWeight) && !fontWeightNeedsResolving(baseFontWeight) if (!fontWeightNeedsResolving(fontWeight) && !fontWeightNeedsResolving(baseFontWeight)
&& (fontWeightIsBold(fontWeight) == fontWeightIsBold(baseFontWeight))) && (fontWeightIsBold(fontWeight) == fontWeightIsBold(baseFontWeight)))
...@@ -1685,7 +1689,7 @@ CSSValueID getIdentifierValue(StylePropertySet* style, CSSPropertyID propertyID) ...@@ -1685,7 +1689,7 @@ CSSValueID getIdentifierValue(StylePropertySet* style, CSSPropertyID propertyID)
{ {
if (!style) if (!style)
return CSSValueInvalid; return CSSValueInvalid;
CSSValue* value = style->getPropertyCSSValue(propertyID); const CSSValue* value = style->getPropertyCSSValue(propertyID);
if (!value || !value->isPrimitiveValue()) if (!value || !value->isPrimitiveValue())
return CSSValueInvalid; return CSSValueInvalid;
return toCSSPrimitiveValue(value)->getValueID(); return toCSSPrimitiveValue(value)->getValueID();
...@@ -1695,13 +1699,13 @@ CSSValueID getIdentifierValue(CSSStyleDeclaration* style, CSSPropertyID property ...@@ -1695,13 +1699,13 @@ CSSValueID getIdentifierValue(CSSStyleDeclaration* style, CSSPropertyID property
{ {
if (!style) if (!style)
return CSSValueInvalid; return CSSValueInvalid;
CSSValue* value = style->getPropertyCSSValueInternal(propertyID); const CSSValue* value = style->getPropertyCSSValueInternal(propertyID);
if (!value || !value->isPrimitiveValue()) if (!value || !value->isPrimitiveValue())
return CSSValueInvalid; return CSSValueInvalid;
return toCSSPrimitiveValue(value)->getValueID(); return toCSSPrimitiveValue(value)->getValueID();
} }
int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, bool isMonospaceFont, LegacyFontSizeMode mode) int legacyFontSizeFromCSSValue(Document* document, const CSSPrimitiveValue* value, bool isMonospaceFont, LegacyFontSizeMode mode)
{ {
CSSPrimitiveValue::LengthUnitType lengthType; CSSPrimitiveValue::LengthUnitType lengthType;
if (CSSPrimitiveValue::unitTypeToLengthUnitType(value->typeWithCalcResolved(), lengthType) if (CSSPrimitiveValue::unitTypeToLengthUnitType(value->typeWithCalcResolved(), lengthType)
...@@ -1722,7 +1726,7 @@ int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, boo ...@@ -1722,7 +1726,7 @@ int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, boo
return 0; return 0;
} }
bool isTransparentColorValue(CSSValue* cssValue) bool isTransparentColorValue(const CSSValue* cssValue)
{ {
if (!cssValue) if (!cssValue)
return true; return true;
...@@ -1730,23 +1734,23 @@ bool isTransparentColorValue(CSSValue* cssValue) ...@@ -1730,23 +1734,23 @@ bool isTransparentColorValue(CSSValue* cssValue)
return !toCSSColorValue(cssValue)->value().alpha(); return !toCSSColorValue(cssValue)->value().alpha();
if (!cssValue->isPrimitiveValue()) if (!cssValue->isPrimitiveValue())
return false; return false;
CSSPrimitiveValue* value = toCSSPrimitiveValue(cssValue); const CSSPrimitiveValue* value = toCSSPrimitiveValue(cssValue);
return value->getValueID() == CSSValueTransparent; return value->getValueID() == CSSValueTransparent;
} }
bool hasTransparentBackgroundColor(CSSStyleDeclaration* style) bool hasTransparentBackgroundColor(CSSStyleDeclaration* style)
{ {
CSSValue* cssValue = style->getPropertyCSSValueInternal(CSSPropertyBackgroundColor); const CSSValue* cssValue = style->getPropertyCSSValueInternal(CSSPropertyBackgroundColor);
return isTransparentColorValue(cssValue); return isTransparentColorValue(cssValue);
} }
bool hasTransparentBackgroundColor(StylePropertySet* style) bool hasTransparentBackgroundColor(StylePropertySet* style)
{ {
CSSValue* cssValue = style->getPropertyCSSValue(CSSPropertyBackgroundColor); const CSSValue* cssValue = style->getPropertyCSSValue(CSSPropertyBackgroundColor);
return isTransparentColorValue(cssValue); return isTransparentColorValue(cssValue);
} }
CSSValue* backgroundColorValueInEffect(Node* node) const CSSValue* backgroundColorValueInEffect(Node* node)
{ {
for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) {
CSSComputedStyleDeclaration* ancestorStyle = CSSComputedStyleDeclaration::create(ancestor); CSSComputedStyleDeclaration* ancestorStyle = CSSComputedStyleDeclaration::create(ancestor);
......
...@@ -1682,7 +1682,7 @@ float ApplyStyleCommand::computedFontSize(Node* node) ...@@ -1682,7 +1682,7 @@ float ApplyStyleCommand::computedFontSize(Node* node)
if (!style) if (!style)
return 0; return 0;
CSSPrimitiveValue* value = toCSSPrimitiveValue(style->getPropertyCSSValue(CSSPropertyFontSize)); const CSSPrimitiveValue* value = toCSSPrimitiveValue(style->getPropertyCSSValue(CSSPropertyFontSize));
if (!value) if (!value)
return 0; return 0;
......
...@@ -187,20 +187,20 @@ void LayoutEditor::rebuild() ...@@ -187,20 +187,20 @@ void LayoutEditor::rebuild()
editableSelectorUpdated(false); editableSelectorUpdated(false);
} }
CSSPrimitiveValue* LayoutEditor::getPropertyCSSValue(CSSPropertyID property) const const CSSPrimitiveValue* LayoutEditor::getPropertyCSSValue(CSSPropertyID property) const
{ {
CSSStyleDeclaration* style = m_cssAgent->findEffectiveDeclaration(property, m_matchedStyles); CSSStyleDeclaration* style = m_cssAgent->findEffectiveDeclaration(property, m_matchedStyles);
if (!style) if (!style)
return nullptr; return nullptr;
CSSValue* cssValue = style->getPropertyCSSValueInternal(property); const CSSValue* cssValue = style->getPropertyCSSValueInternal(property);
if (!cssValue || !cssValue->isPrimitiveValue()) if (!cssValue || !cssValue->isPrimitiveValue())
return nullptr; return nullptr;
return toCSSPrimitiveValue(cssValue); return toCSSPrimitiveValue(cssValue);
} }
bool LayoutEditor::growInside(String propertyName, CSSPrimitiveValue* value) bool LayoutEditor::growInside(String propertyName, const CSSPrimitiveValue* value)
{ {
FloatQuad content1, padding1, border1, margin1; FloatQuad content1, padding1, border1, margin1;
InspectorHighlight::buildNodeQuads(m_element.get(), &content1, &padding1, &border1, &margin1); InspectorHighlight::buildNodeQuads(m_element.get(), &content1, &padding1, &border1, &margin1);
...@@ -254,7 +254,7 @@ bool LayoutEditor::growInside(String propertyName, CSSPrimitiveValue* value) ...@@ -254,7 +254,7 @@ bool LayoutEditor::growInside(String propertyName, CSSPrimitiveValue* value)
std::unique_ptr<protocol::DictionaryValue> LayoutEditor::createValueDescription(const String& propertyName) std::unique_ptr<protocol::DictionaryValue> LayoutEditor::createValueDescription(const String& propertyName)
{ {
CSSPrimitiveValue* cssValue = getPropertyCSSValue(cssPropertyID(propertyName)); const CSSPrimitiveValue* cssValue = getPropertyCSSValue(cssPropertyID(propertyName));
if (cssValue && !(cssValue->isLength() || cssValue->isPercentage())) if (cssValue && !(cssValue->isLength() || cssValue->isPercentage()))
return nullptr; return nullptr;
...@@ -284,7 +284,7 @@ void LayoutEditor::overlayStartedPropertyChange(const String& anchorName) ...@@ -284,7 +284,7 @@ void LayoutEditor::overlayStartedPropertyChange(const String& anchorName)
if (!m_changingProperty) if (!m_changingProperty)
return; return;
CSSPrimitiveValue* cssValue = getPropertyCSSValue(m_changingProperty); const CSSPrimitiveValue* cssValue = getPropertyCSSValue(m_changingProperty);
m_valueUnitType = cssValue ? cssValue->typeWithCalcResolved() : CSSPrimitiveValue::UnitType::Pixels; m_valueUnitType = cssValue ? cssValue->typeWithCalcResolved() : CSSPrimitiveValue::UnitType::Pixels;
if (!isMutableUnitType(m_valueUnitType)) if (!isMutableUnitType(m_valueUnitType))
return; return;
......
...@@ -45,14 +45,14 @@ public: ...@@ -45,14 +45,14 @@ public:
private: private:
LayoutEditor(Element*, InspectorCSSAgent*, InspectorDOMAgent*, ScriptController*); LayoutEditor(Element*, InspectorCSSAgent*, InspectorDOMAgent*, ScriptController*);
CSSPrimitiveValue* getPropertyCSSValue(CSSPropertyID) const; const CSSPrimitiveValue* getPropertyCSSValue(CSSPropertyID) const;
std::unique_ptr<protocol::DictionaryValue> createValueDescription(const String&); std::unique_ptr<protocol::DictionaryValue> createValueDescription(const String&);
void appendAnchorFor(protocol::ListValue*, const String&, const String&); void appendAnchorFor(protocol::ListValue*, const String&, const String&);
bool setCSSPropertyValueInCurrentRule(const String&); bool setCSSPropertyValueInCurrentRule(const String&);
void editableSelectorUpdated(bool hasChanged) const; void editableSelectorUpdated(bool hasChanged) const;
void evaluateInOverlay(const String&, std::unique_ptr<protocol::Value>) const; void evaluateInOverlay(const String&, std::unique_ptr<protocol::Value>) const;
std::unique_ptr<protocol::DictionaryValue> currentSelectorInfo(CSSStyleDeclaration*) const; std::unique_ptr<protocol::DictionaryValue> currentSelectorInfo(CSSStyleDeclaration*) const;
bool growInside(String propertyName, CSSPrimitiveValue*); bool growInside(String propertyName, const CSSPrimitiveValue*);
Member<Element> m_element; Member<Element> m_element;
Member<InspectorCSSAgent> m_cssAgent; Member<InspectorCSSAgent> m_cssAgent;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment