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

Unified Diff: third_party/WebKit/Source/core/editing/EditingStyle.cpp

Issue 2042113002: Revert of Make CSSComputedStyledeclaration::getPropertyCSSValue return const (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@_make_cssproperty_store_const
Patch Set: Created 4 years, 6 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/editing/EditingStyle.cpp
diff --git a/third_party/WebKit/Source/core/editing/EditingStyle.cpp b/third_party/WebKit/Source/core/editing/EditingStyle.cpp
index 3a880b1d1d27b3fabb960b3efc897d12d39ace30..c4fc5e8fbdcba08d4dd3aee3f9c47e785a203d6f 100644
--- a/third_party/WebKit/Source/core/editing/EditingStyle.cpp
+++ b/third_party/WebKit/Source/core/editing/EditingStyle.cpp
@@ -160,11 +160,11 @@
static MutableStylePropertySet* getPropertiesNotIn(StylePropertySet* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle);
enum LegacyFontSizeMode { AlwaysUseLegacyFontSize, UseLegacyFontSizeOnlyIfPixelValuesMatch };
-static int legacyFontSizeFromCSSValue(Document*, const CSSPrimitiveValue*, bool, LegacyFontSizeMode);
-static bool isTransparentColorValue(const CSSValue*);
+static int legacyFontSizeFromCSSValue(Document*, CSSPrimitiveValue*, bool, LegacyFontSizeMode);
+static bool isTransparentColorValue(CSSValue*);
static bool hasTransparentBackgroundColor(CSSStyleDeclaration*);
static bool hasTransparentBackgroundColor(StylePropertySet*);
-static const CSSValue* backgroundColorValueInEffect(Node*);
+static CSSValue* backgroundColorValueInEffect(Node*);
static bool hasAncestorVerticalAlignStyle(Node&, CSSValueID);
class HTMLElementEquivalent : public GarbageCollected<HTMLElementEquivalent> {
@@ -213,7 +213,7 @@
bool HTMLElementEquivalent::valueIsPresentInStyle(HTMLElement* element, StylePropertySet* style) const
{
- const CSSValue* value = style->getPropertyCSSValue(m_propertyID);
+ CSSValue* value = style->getPropertyCSSValue(m_propertyID);
return matches(element) && value && value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValueID() == m_primitiveValue->getValueID();
}
@@ -251,7 +251,7 @@
bool HTMLTextDecorationEquivalent::valueIsPresentInStyle(HTMLElement* element, StylePropertySet* style) const
{
- const CSSValue* styleValue = style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
+ CSSValue* styleValue = style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
if (!styleValue)
styleValue = style->getPropertyCSSValue(textDecorationPropertyForEditing());
return matches(element) && styleValue && styleValue->isValueList() && toCSSValueList(styleValue)->hasValue(*m_primitiveValue);
@@ -298,7 +298,7 @@
bool HTMLAttributeEquivalent::valueIsPresentInStyle(HTMLElement* element, StylePropertySet* style) const
{
CSSValue* value = attributeValueAsCSSValue(element);
- const CSSValue* styleValue = style->getPropertyCSSValue(m_propertyID);
+ CSSValue* styleValue = style->getPropertyCSSValue(m_propertyID);
return compareCSSValuePtr(value, styleValue);
}
@@ -392,7 +392,7 @@
m_isVerticalAlign = propertyID == CSSPropertyVerticalAlign && (value == "sub" || value == "super");
}
-static Color cssValueToColor(const CSSValue* colorValue)
+static Color cssValueToColor(CSSValue* colorValue)
{
if (!colorValue || (!colorValue->isColorValue() && !colorValue->isPrimitiveValue()))
return Color::transparent;
@@ -470,9 +470,9 @@
m_mutableStyle = propertiesToInclude == AllProperties && computedStyleAtPosition ? computedStyleAtPosition->copyProperties() : editingStyleFromComputedStyle(computedStyleAtPosition);
if (propertiesToInclude == EditingPropertiesInEffect) {
- if (const CSSValue* value = backgroundColorValueInEffect(node))
+ if (CSSValue* value = backgroundColorValueInEffect(node))
m_mutableStyle->setProperty(CSSPropertyBackgroundColor, value->cssText());
- if (const CSSValue* value = computedStyleAtPosition->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect))
+ if (CSSValue* value = computedStyleAtPosition->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect))
m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssText());
}
@@ -524,11 +524,11 @@
}
// Get the adjustment amount out of the style.
- const CSSValue* value = m_mutableStyle->getPropertyCSSValue(CSSPropertyWebkitFontSizeDelta);
+ CSSValue* value = m_mutableStyle->getPropertyCSSValue(CSSPropertyWebkitFontSizeDelta);
if (!value || !value->isPrimitiveValue())
return;
- const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
+ CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
// Only PX handled now. If we handle more types in the future, perhaps
// a switch statement here would be more appropriate.
@@ -549,13 +549,13 @@
if (!m_mutableStyle)
return false;
- const CSSValue* unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi);
+ CSSValue* unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi);
if (!unicodeBidi || !unicodeBidi->isPrimitiveValue())
return false;
CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getValueID();
if (isEmbedOrIsolate(unicodeBidiValue)) {
- const CSSValue* direction = m_mutableStyle->getPropertyCSSValue(CSSPropertyDirection);
+ CSSValue* direction = m_mutableStyle->getPropertyCSSValue(CSSPropertyDirection);
if (!direction || !direction->isPrimitiveValue())
return false;
@@ -696,7 +696,7 @@
if (!m_mutableStyle)
return;
- const CSSValue* textDecorationsInEffect = m_mutableStyle->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
+ CSSValue* textDecorationsInEffect = m_mutableStyle->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
if (!textDecorationsInEffect)
return;
@@ -769,7 +769,7 @@
// style(vertical-align) to it so that document.queryCommandState() works with the style.
// See bug http://crbug.com/582225.
if (m_isVerticalAlign && getIdentifierValue(nodeStyle, CSSPropertyVerticalAlign) == CSSValueBaseline) {
- const CSSPrimitiveValue* verticalAlign = toCSSPrimitiveValue(m_mutableStyle->getPropertyCSSValue(CSSPropertyVerticalAlign));
+ CSSPrimitiveValue* verticalAlign = toCSSPrimitiveValue(m_mutableStyle->getPropertyCSSValue(CSSPropertyVerticalAlign));
if (hasAncestorVerticalAlignStyle(node, verticalAlign->getValueID()))
node.mutableComputedStyle()->setVerticalAlign(verticalAlign->convertTo<EVerticalAlign>());
}
@@ -1015,8 +1015,8 @@
EditingStyle* editingStyleAtPosition = EditingStyle::create(position, EditingPropertiesInEffect);
StylePropertySet* styleAtPosition = editingStyleAtPosition->m_mutableStyle.get();
- const CSSValue* unicodeBidi = nullptr;
- const CSSValue* direction = nullptr;
+ CSSValue* unicodeBidi = nullptr;
+ CSSValue* direction = nullptr;
if (shouldPreserveWritingDirection == PreserveWritingDirection) {
unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi);
direction = m_mutableStyle->getPropertyCSSValue(CSSPropertyDirection);
@@ -1155,18 +1155,15 @@
return wrappingStyle;
}
-static CSSValueList* mergeTextDecorationValues(const CSSValueList* mergedValue, const CSSValueList* valueToMerge)
+static void mergeTextDecorationValues(CSSValueList* mergedValue, const CSSValueList* valueToMerge)
{
DEFINE_STATIC_LOCAL(CSSPrimitiveValue, underline, (CSSPrimitiveValue::createIdentifier(CSSValueUnderline)));
DEFINE_STATIC_LOCAL(CSSPrimitiveValue, lineThrough, (CSSPrimitiveValue::createIdentifier(CSSValueLineThrough)));
- CSSValueList* result = mergedValue->copy();
if (valueToMerge->hasValue(underline) && !mergedValue->hasValue(underline))
- result->append(&underline);
+ mergedValue->append(&underline);
if (valueToMerge->hasValue(lineThrough) && !mergedValue->hasValue(lineThrough))
- result->append(&lineThrough);
-
- return result;
+ mergedValue->append(&lineThrough);
}
void EditingStyle::mergeStyle(const StylePropertySet* style, CSSPropertyOverrideMode mode)
@@ -1182,13 +1179,12 @@
unsigned propertyCount = style->propertyCount();
for (unsigned i = 0; i < propertyCount; ++i) {
StylePropertySet::PropertyReference property = style->propertyAt(i);
- const CSSValue* value = m_mutableStyle->getPropertyCSSValue(property.id());
+ CSSValue* value = m_mutableStyle->getPropertyCSSValue(property.id());
// text decorations never override values
if ((property.id() == textDecorationPropertyForEditing() || property.id() == CSSPropertyWebkitTextDecorationsInEffect) && property.value()->isValueList() && value) {
if (value->isValueList()) {
- CSSValueList* result = mergeTextDecorationValues(toCSSValueList(value), toCSSValueList(property.value()));
- m_mutableStyle->setProperty(property.id(), result, property.isImportant());
+ mergeTextDecorationValues(toCSSValueList(value), toCSSValueList(property.value()));
continue;
}
value = nullptr; // text-decoration: none is equivalent to not having the property
@@ -1240,7 +1236,7 @@
if (!value->isPrimitiveValue())
continue;
if (toCSSPrimitiveValue(value)->isPercentage()) {
- if (const CSSValue* computedPropertyValue = computedStyleForElement->getPropertyCSSValue(property.id()))
+ if (CSSValue* computedPropertyValue = computedStyleForElement->getPropertyCSSValue(property.id()))
fromComputedStyle->addRespectingCascade(CSSProperty(property.id(), computedPropertyValue));
}
}
@@ -1334,7 +1330,7 @@
int EditingStyle::legacyFontSize(Document* document) const
{
- const CSSValue* cssValue = m_mutableStyle->getPropertyCSSValue(CSSPropertyFontSize);
+ CSSValue* cssValue = m_mutableStyle->getPropertyCSSValue(CSSPropertyFontSize);
if (!cssValue || !cssValue->isPrimitiveValue())
return 0;
return legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(cssValue),
@@ -1379,7 +1375,7 @@
// and find the background color of the common ancestor.
if (shouldUseBackgroundColorInEffect && (selection.isRange() || hasTransparentBackgroundColor(style->m_mutableStyle.get()))) {
const EphemeralRange range(selection.toNormalizedEphemeralRange());
- if (const CSSValue* value = backgroundColorValueInEffect(Range::commonAncestorContainer(range.startPosition().computeContainerNode(), range.endPosition().computeContainerNode())))
+ if (CSSValue* value = backgroundColorValueInEffect(Range::commonAncestorContainer(range.startPosition().computeContainerNode(), range.endPosition().computeContainerNode())))
style->setProperty(CSSPropertyBackgroundColor, value->cssText());
}
@@ -1417,7 +1413,7 @@
continue;
CSSComputedStyleDeclaration* style = CSSComputedStyleDeclaration::create(n);
- const CSSValue* unicodeBidi = style->getPropertyCSSValue(CSSPropertyUnicodeBidi);
+ CSSValue* unicodeBidi = style->getPropertyCSSValue(CSSPropertyUnicodeBidi);
if (!unicodeBidi || !unicodeBidi->isPrimitiveValue())
continue;
@@ -1450,7 +1446,7 @@
Element* element = &toElement(runner);
CSSComputedStyleDeclaration* style = CSSComputedStyleDeclaration::create(element);
- const CSSValue* unicodeBidi = style->getPropertyCSSValue(CSSPropertyUnicodeBidi);
+ CSSValue* unicodeBidi = style->getPropertyCSSValue(CSSPropertyUnicodeBidi);
if (!unicodeBidi || !unicodeBidi->isPrimitiveValue())
continue;
@@ -1462,7 +1458,7 @@
return NaturalWritingDirection;
DCHECK(isEmbedOrIsolate(unicodeBidiValue)) << unicodeBidiValue;
- const CSSValue* direction = style->getPropertyCSSValue(CSSPropertyDirection);
+ CSSValue* direction = style->getPropertyCSSValue(CSSPropertyDirection);
if (!direction || !direction->isPrimitiveValue())
continue;
@@ -1490,8 +1486,8 @@
static void reconcileTextDecorationProperties(MutableStylePropertySet* style)
{
- const CSSValue* textDecorationsInEffect = style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
- const CSSValue* textDecoration = style->getPropertyCSSValue(textDecorationPropertyForEditing());
+ CSSValue* textDecorationsInEffect = style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
+ CSSValue* textDecoration = style->getPropertyCSSValue(textDecorationPropertyForEditing());
// We shouldn't have both text-decoration and -webkit-text-decorations-in-effect because that wouldn't make sense.
DCHECK(!textDecorationsInEffect || !textDecoration);
if (textDecorationsInEffect) {
@@ -1567,7 +1563,7 @@
// 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.
- const CSSValue* textDecoration = style->getPropertyCSSValue(textDecorationPropertyForEditing());
+ CSSValue* textDecoration = style->getPropertyCSSValue(textDecorationPropertyForEditing());
if (textDecoration && textDecoration->isValueList()) {
DEFINE_STATIC_LOCAL(CSSPrimitiveValue, underline, (CSSPrimitiveValue::createIdentifier(CSSValueUnderline)));
DEFINE_STATIC_LOCAL(CSSPrimitiveValue, lineThrough, (CSSPrimitiveValue::createIdentifier(CSSValueLineThrough)));
@@ -1603,7 +1599,7 @@
m_applyFontFace.replace('"', "");
style->removeProperty(CSSPropertyFontFamily);
- if (const CSSValue* fontSize = style->getPropertyCSSValue(CSSPropertyFontSize)) {
+ if (CSSValue* fontSize = style->getPropertyCSSValue(CSSPropertyFontSize)) {
if (!fontSize->isPrimitiveValue()) {
style->removeProperty(CSSPropertyFontSize); // Can't make sense of the number. Put no font size.
} else if (int legacyFontSize = legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(fontSize), isMonospaceFont, UseLegacyFontSizeOnlyIfPixelValuesMatch)) {
@@ -1613,22 +1609,22 @@
}
}
-static void diffTextDecorations(MutableStylePropertySet* style, CSSPropertyID propertyID, const CSSValue* refTextDecoration)
-{
- const CSSValue* textDecoration = style->getPropertyCSSValue(propertyID);
+static void diffTextDecorations(MutableStylePropertySet* style, CSSPropertyID propertID, CSSValue* refTextDecoration)
+{
+ CSSValue* textDecoration = style->getPropertyCSSValue(propertID);
if (!textDecoration || !textDecoration->isValueList() || !refTextDecoration || !refTextDecoration->isValueList())
return;
CSSValueList* newTextDecoration = toCSSValueList(textDecoration)->copy();
- const CSSValueList* valuesInRefTextDecoration = toCSSValueList(refTextDecoration);
+ CSSValueList* valuesInRefTextDecoration = toCSSValueList(refTextDecoration);
for (size_t i = 0; i < valuesInRefTextDecoration->length(); i++)
newTextDecoration->removeAll(*valuesInRefTextDecoration->item(i));
- setTextDecorationProperty(style, newTextDecoration, propertyID);
-}
-
-static bool fontWeightIsBold(const CSSValue* fontWeight)
+ setTextDecorationProperty(style, newTextDecoration, propertID);
+}
+
+static bool fontWeightIsBold(CSSValue* fontWeight)
{
if (!fontWeight->isPrimitiveValue())
return false;
@@ -1657,12 +1653,12 @@
return false;
}
-static bool fontWeightNeedsResolving(const CSSValue* fontWeight)
+static bool fontWeightNeedsResolving(CSSValue* fontWeight)
{
if (!fontWeight->isPrimitiveValue())
return true;
- const CSSValueID value = toCSSPrimitiveValue(fontWeight)->getValueID();
+ CSSValueID value = toCSSPrimitiveValue(fontWeight)->getValueID();
return value == CSSValueLighter || value == CSSValueBolder;
}
@@ -1674,11 +1670,11 @@
result->removeEquivalentProperties(baseStyle);
- const CSSValue* baseTextDecorationsInEffect = baseStyle->getPropertyCSSValueInternal(CSSPropertyWebkitTextDecorationsInEffect);
+ CSSValue* baseTextDecorationsInEffect = baseStyle->getPropertyCSSValueInternal(CSSPropertyWebkitTextDecorationsInEffect);
diffTextDecorations(result, textDecorationPropertyForEditing(), baseTextDecorationsInEffect);
diffTextDecorations(result, CSSPropertyWebkitTextDecorationsInEffect, baseTextDecorationsInEffect);
- if (const CSSValue* baseFontWeight = baseStyle->getPropertyCSSValueInternal(CSSPropertyFontWeight)) {
+ if (CSSValue* baseFontWeight = baseStyle->getPropertyCSSValueInternal(CSSPropertyFontWeight)) {
if (CSSValue* fontWeight = result->getPropertyCSSValue(CSSPropertyFontWeight)) {
if (!fontWeightNeedsResolving(fontWeight) && !fontWeightNeedsResolving(baseFontWeight)
&& (fontWeightIsBold(fontWeight) == fontWeightIsBold(baseFontWeight)))
@@ -1703,7 +1699,7 @@
{
if (!style)
return CSSValueInvalid;
- const CSSValue* value = style->getPropertyCSSValue(propertyID);
+ CSSValue* value = style->getPropertyCSSValue(propertyID);
if (!value || !value->isPrimitiveValue())
return CSSValueInvalid;
return toCSSPrimitiveValue(value)->getValueID();
@@ -1713,13 +1709,13 @@
{
if (!style)
return CSSValueInvalid;
- const CSSValue* value = style->getPropertyCSSValueInternal(propertyID);
+ CSSValue* value = style->getPropertyCSSValueInternal(propertyID);
if (!value || !value->isPrimitiveValue())
return CSSValueInvalid;
return toCSSPrimitiveValue(value)->getValueID();
}
-int legacyFontSizeFromCSSValue(Document* document, const CSSPrimitiveValue* value, bool isMonospaceFont, LegacyFontSizeMode mode)
+int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, bool isMonospaceFont, LegacyFontSizeMode mode)
{
CSSPrimitiveValue::LengthUnitType lengthType;
if (CSSPrimitiveValue::unitTypeToLengthUnitType(value->typeWithCalcResolved(), lengthType)
@@ -1740,7 +1736,7 @@
return 0;
}
-bool isTransparentColorValue(const CSSValue* cssValue)
+bool isTransparentColorValue(CSSValue* cssValue)
{
if (!cssValue)
return true;
@@ -1748,23 +1744,23 @@
return !toCSSColorValue(cssValue)->value().alpha();
if (!cssValue->isPrimitiveValue())
return false;
- const CSSPrimitiveValue* value = toCSSPrimitiveValue(cssValue);
+ CSSPrimitiveValue* value = toCSSPrimitiveValue(cssValue);
return value->getValueID() == CSSValueTransparent;
}
bool hasTransparentBackgroundColor(CSSStyleDeclaration* style)
{
- const CSSValue* cssValue = style->getPropertyCSSValueInternal(CSSPropertyBackgroundColor);
+ CSSValue* cssValue = style->getPropertyCSSValueInternal(CSSPropertyBackgroundColor);
return isTransparentColorValue(cssValue);
}
bool hasTransparentBackgroundColor(StylePropertySet* style)
{
- const CSSValue* cssValue = style->getPropertyCSSValue(CSSPropertyBackgroundColor);
+ CSSValue* cssValue = style->getPropertyCSSValue(CSSPropertyBackgroundColor);
return isTransparentColorValue(cssValue);
}
-const CSSValue* backgroundColorValueInEffect(Node* node)
+CSSValue* backgroundColorValueInEffect(Node* node)
{
for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) {
CSSComputedStyleDeclaration* ancestorStyle = CSSComputedStyleDeclaration::create(ancestor);

Powered by Google App Engine
This is Rietveld 408576698