| Index: Source/core/editing/EditingStyle.cpp
|
| diff --git a/Source/core/editing/EditingStyle.cpp b/Source/core/editing/EditingStyle.cpp
|
| index d19952dffcffc379d73042d7a9befd39c5d83cc8..16e2bcf61ac9825437f68c010054c806b79bdee0 100644
|
| --- a/Source/core/editing/EditingStyle.cpp
|
| +++ b/Source/core/editing/EditingStyle.cpp
|
| @@ -148,13 +148,13 @@ static PassRefPtrWillBeRawPtr<MutableStylePropertySet> editingStyleFromComputedS
|
|
|
| static PassRefPtrWillBeRawPtr<MutableStylePropertySet> getPropertiesNotIn(StylePropertySet* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle);
|
| enum LegacyFontSizeMode { AlwaysUseLegacyFontSize, UseLegacyFontSizeOnlyIfPixelValuesMatch };
|
| -static int legacyFontSizeFromCSSValue(Document*, CSSPrimitiveValue*, bool, LegacyFontSizeMode);
|
| +static int legacyFontSizeFromCSSValue(Document*, CSSPrimitiveValue, bool, LegacyFontSizeMode);
|
| static bool isTransparentColorValue(NullableCSSValue);
|
| static bool hasTransparentBackgroundColor(CSSStyleDeclaration*);
|
| static bool hasTransparentBackgroundColor(StylePropertySet*);
|
| static NullableCSSValue backgroundColorInEffect(Node*);
|
|
|
| -class HTMLElementEquivalent : public NoBaseWillBeGarbageCollected<HTMLElementEquivalent> {
|
| +class HTMLElementEquivalent : public NoBaseWillBeGarbageCollectedFinalized<HTMLElementEquivalent> {
|
| WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(HTMLElementEquivalent);
|
| DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(HTMLElementEquivalent);
|
| public:
|
| @@ -165,7 +165,7 @@ public:
|
|
|
| virtual bool matches(const Element* element) const { return !m_tagName || element->hasTagName(*m_tagName); }
|
| virtual bool hasAttribute() const { return false; }
|
| - virtual bool propertyExistsInStyle(const StylePropertySet* style) const { return style->getPropertyCSSValue(m_propertyID); }
|
| + virtual bool propertyExistsInStyle(const StylePropertySet* style) const { return (bool)style->getPropertyCSSValue(m_propertyID); }
|
| virtual bool valueIsPresentInStyle(HTMLElement*, StylePropertySet*) const;
|
| virtual void addToStyle(Element*, EditingStyle*) const;
|
|
|
| @@ -176,7 +176,7 @@ protected:
|
| HTMLElementEquivalent(CSSPropertyID, const HTMLQualifiedName& tagName);
|
| HTMLElementEquivalent(CSSPropertyID, CSSValueID primitiveValue, const HTMLQualifiedName& tagName);
|
| const CSSPropertyID m_propertyID;
|
| - const RefPtrWillBeMember<CSSPrimitiveValue> m_primitiveValue;
|
| + const NullableCSSValue m_primitiveValue;
|
| const HTMLQualifiedName* m_tagName; // We can store a pointer because HTML tag names are const global.
|
| };
|
|
|
| @@ -205,7 +205,7 @@ HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, CSSValueID primit
|
| bool HTMLElementEquivalent::valueIsPresentInStyle(HTMLElement* element, StylePropertySet* style) const
|
| {
|
| NullableCSSValue 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() == toCSSPrimitiveValue(*m_primitiveValue).getValueID();
|
| }
|
|
|
| void HTMLElementEquivalent::addToStyle(Element*, EditingStyle* style) const
|
| @@ -391,9 +391,9 @@ static RGBA32 cssValueToRGBA(NullableCSSValue colorValue)
|
| if (!colorValue || !colorValue->isPrimitiveValue())
|
| return Color::transparent;
|
|
|
| - CSSPrimitiveValue* primitiveColor = toCSSPrimitiveValue(colorValue);
|
| - if (primitiveColor->isRGBColor())
|
| - return primitiveColor->getRGBA32Value();
|
| + CSSPrimitiveValue primitiveColor = toCSSPrimitiveValue(*colorValue);
|
| + if (primitiveColor.isRGBColor())
|
| + return primitiveColor.getRGBA32Value();
|
|
|
| RGBA32 rgba = 0;
|
| // FIXME: Why ignore the return value?
|
| @@ -523,14 +523,14 @@ void EditingStyle::extractFontSizeDelta()
|
| if (!value || !value->isPrimitiveValue())
|
| return;
|
|
|
| - 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.
|
| - if (!primitiveValue->isPx())
|
| + if (!primitiveValue.isPx())
|
| return;
|
|
|
| - m_fontSizeDelta = primitiveValue->getFloatValue();
|
| + m_fontSizeDelta = primitiveValue.getFloatValue();
|
| m_mutableStyle->removeProperty(CSSPropertyWebkitFontSizeDelta);
|
| }
|
|
|
| @@ -548,13 +548,13 @@ bool EditingStyle::textDirection(WritingDirection& writingDirection) const
|
| if (!unicodeBidi || !unicodeBidi->isPrimitiveValue())
|
| return false;
|
|
|
| - CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getValueID();
|
| + CSSValueID unicodeBidiValue = toCSSPrimitiveValue(*unicodeBidi).getValueID();
|
| if (unicodeBidiValue == CSSValueEmbed) {
|
| NullableCSSValue direction = m_mutableStyle->getPropertyCSSValue(CSSPropertyDirection);
|
| if (!direction || !direction->isPrimitiveValue())
|
| return false;
|
|
|
| - writingDirection = toCSSPrimitiveValue(direction)->getValueID() == CSSValueLtr ? LeftToRightWritingDirection : RightToLeftWritingDirection;
|
| + writingDirection = toCSSPrimitiveValue(*direction).getValueID() == CSSValueLtr ? LeftToRightWritingDirection : RightToLeftWritingDirection;
|
|
|
| return true;
|
| }
|
| @@ -1005,9 +1005,9 @@ void EditingStyle::prepareToApplyAt(const Position& position, ShouldPreserveWrit
|
| m_mutableStyle->removeProperty(CSSPropertyBackgroundColor);
|
|
|
| if (unicodeBidi && unicodeBidi->isPrimitiveValue()) {
|
| - m_mutableStyle->setProperty(CSSPropertyUnicodeBidi, toCSSPrimitiveValue(unicodeBidi)->getValueID());
|
| + m_mutableStyle->setProperty(CSSPropertyUnicodeBidi, toCSSPrimitiveValue(*unicodeBidi).getValueID());
|
| if (direction && direction->isPrimitiveValue())
|
| - m_mutableStyle->setProperty(CSSPropertyDirection, toCSSPrimitiveValue(direction)->getValueID());
|
| + m_mutableStyle->setProperty(CSSPropertyDirection, toCSSPrimitiveValue(*direction).getValueID());
|
| }
|
| }
|
|
|
| @@ -1124,14 +1124,14 @@ PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::wrappingStyleForSerialization
|
|
|
| static void mergeTextDecorationValues(CSSValueList& mergedValue, const CSSValueList& valueToMerge)
|
| {
|
| - DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, underline, (CSSPrimitiveValue::createIdentifier(CSSValueUnderline)));
|
| - DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, lineThrough, (CSSPrimitiveValue::createIdentifier(CSSValueLineThrough)));
|
| + CSSPrimitiveValue underline = CSSPrimitiveValue::createIdentifier(CSSValueUnderline);
|
| + CSSPrimitiveValue lineThrough = CSSPrimitiveValue::createIdentifier(CSSValueLineThrough);
|
|
|
| - if (valueToMerge.hasValue(CSSValue(*underline)) && !mergedValue.hasValue(CSSValue(*underline)))
|
| - mergedValue.append(CSSValue(*underline));
|
| + if (valueToMerge.hasValue(underline) && !mergedValue.hasValue(underline))
|
| + mergedValue.append(underline);
|
|
|
| - if (valueToMerge.hasValue(CSSValue(*lineThrough)) && !mergedValue.hasValue(CSSValue(*lineThrough)))
|
| - mergedValue.append(CSSValue(*lineThrough));
|
| + if (valueToMerge.hasValue(lineThrough) && !mergedValue.hasValue(lineThrough))
|
| + mergedValue.append(lineThrough);
|
| }
|
|
|
| void EditingStyle::mergeStyle(const StylePropertySet* style, CSSPropertyOverrideMode mode)
|
| @@ -1301,7 +1301,7 @@ int EditingStyle::legacyFontSize(Document* document) const
|
| NullableCSSValue cssValue = m_mutableStyle->getPropertyCSSValue(CSSPropertyFontSize);
|
| if (!cssValue || !cssValue->isPrimitiveValue())
|
| return 0;
|
| - return legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(cssValue),
|
| + return legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(*cssValue),
|
| m_isMonospaceFont, AlwaysUseLegacyFontSize);
|
| }
|
|
|
| @@ -1367,7 +1367,7 @@ WritingDirection EditingStyle::textDirectionForSelection(const VisibleSelection&
|
| if (!unicodeBidi || !unicodeBidi->isPrimitiveValue())
|
| continue;
|
|
|
| - CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getValueID();
|
| + CSSValueID unicodeBidiValue = toCSSPrimitiveValue(*unicodeBidi).getValueID();
|
| if (unicodeBidiValue == CSSValueEmbed || unicodeBidiValue == CSSValueBidiOverride)
|
| return NaturalWritingDirection;
|
| }
|
| @@ -1397,7 +1397,7 @@ WritingDirection EditingStyle::textDirectionForSelection(const VisibleSelection&
|
| if (!unicodeBidi || !unicodeBidi->isPrimitiveValue())
|
| continue;
|
|
|
| - CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getValueID();
|
| + CSSValueID unicodeBidiValue = toCSSPrimitiveValue(*unicodeBidi).getValueID();
|
| if (unicodeBidiValue == CSSValueNormal)
|
| continue;
|
|
|
| @@ -1409,7 +1409,7 @@ WritingDirection EditingStyle::textDirectionForSelection(const VisibleSelection&
|
| if (!direction || !direction->isPrimitiveValue())
|
| continue;
|
|
|
| - int directionValue = toCSSPrimitiveValue(direction)->getValueID();
|
| + int directionValue = toCSSPrimitiveValue(*direction).getValueID();
|
| if (directionValue != CSSValueLtr && directionValue != CSSValueRtl)
|
| continue;
|
|
|
| @@ -1511,12 +1511,12 @@ void StyleChange::extractTextStyles(Document* document, MutableStylePropertySet*
|
| // Furthermore, text-decoration: none has been trimmed so that text-decoration property is always a CSSValueList.
|
| NullableCSSValue textDecoration = style->getPropertyCSSValue(textDecorationPropertyForEditing());
|
| if (textDecoration && textDecoration->isValueList()) {
|
| - DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, underline, (CSSPrimitiveValue::createIdentifier(CSSValueUnderline)));
|
| - DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, lineThrough, (CSSPrimitiveValue::createIdentifier(CSSValueLineThrough)));
|
| + CSSPrimitiveValue underline = CSSPrimitiveValue::createIdentifier(CSSValueUnderline);
|
| + CSSPrimitiveValue lineThrough = CSSPrimitiveValue::createIdentifier(CSSValueLineThrough);
|
| RefPtrWillBeRawPtr<CSSValueList> newTextDecoration = toCSSValueList(textDecoration)->copy();
|
| - if (newTextDecoration->removeAll(CSSValue(*underline)))
|
| + if (newTextDecoration->removeAll(underline))
|
| m_applyUnderline = true;
|
| - if (newTextDecoration->removeAll(CSSValue(*lineThrough)))
|
| + if (newTextDecoration->removeAll(lineThrough))
|
| m_applyLineThrough = true;
|
|
|
| // If trimTextDecorations, delete underline and line-through
|
| @@ -1548,7 +1548,7 @@ void StyleChange::extractTextStyles(Document* document, MutableStylePropertySet*
|
| if (NullableCSSValue 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)) {
|
| + } else if (int legacyFontSize = legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(*fontSize), isMonospaceFont, UseLegacyFontSizeOnlyIfPixelValuesMatch)) {
|
| m_applyFontSize = String::number(legacyFontSize);
|
| style->removeProperty(CSSPropertyFontSize);
|
| }
|
| @@ -1647,7 +1647,7 @@ CSSValueID getIdentifierValue(StylePropertySet* style, CSSPropertyID propertyID)
|
| NullableCSSValue value = style->getPropertyCSSValue(propertyID);
|
| if (!value || !value->isPrimitiveValue())
|
| return CSSValueInvalid;
|
| - return toCSSPrimitiveValue(value)->getValueID();
|
| + return toCSSPrimitiveValue(*value).getValueID();
|
| }
|
|
|
| CSSValueID getIdentifierValue(CSSStyleDeclaration* style, CSSPropertyID propertyID)
|
| @@ -1657,16 +1657,16 @@ CSSValueID getIdentifierValue(CSSStyleDeclaration* style, CSSPropertyID property
|
| NullableCSSValue value = style->getPropertyCSSValueInternal(propertyID);
|
| if (!value || !value->isPrimitiveValue())
|
| return CSSValueInvalid;
|
| - return toCSSPrimitiveValue(value)->getValueID();
|
| + return toCSSPrimitiveValue(*value).getValueID();
|
| }
|
|
|
| -int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, bool isMonospaceFont, LegacyFontSizeMode mode)
|
| +int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue value, bool isMonospaceFont, LegacyFontSizeMode mode)
|
| {
|
| CSSPrimitiveValue::LengthUnitType lengthType;
|
| - if (CSSPrimitiveValue::unitTypeToLengthUnitType(value->primitiveType(), lengthType)
|
| + if (CSSPrimitiveValue::unitTypeToLengthUnitType(value.primitiveType(), lengthType)
|
| && lengthType == CSSPrimitiveValue::UnitTypePixels) {
|
| - double conversion = CSSPrimitiveValue::conversionToCanonicalUnitsScaleFactor(value->primitiveType());
|
| - int pixelFontSize = clampTo<int>(value->getDoubleValue() * conversion);
|
| + double conversion = CSSPrimitiveValue::conversionToCanonicalUnitsScaleFactor(value.primitiveType());
|
| + int pixelFontSize = clampTo<int>(value.getDoubleValue() * conversion);
|
| int legacyFontSize = FontSize::legacyFontSize(document, pixelFontSize, isMonospaceFont);
|
| // Use legacy font size only if pixel value matches exactly to that of legacy font size.
|
| if (mode == AlwaysUseLegacyFontSize || FontSize::fontSizeForKeyword(document, legacyFontSize, isMonospaceFont) == pixelFontSize)
|
| @@ -1675,8 +1675,8 @@ int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, boo
|
| return 0;
|
| }
|
|
|
| - if (CSSValueXSmall <= value->getValueID() && value->getValueID() <= CSSValueWebkitXxxLarge)
|
| - return value->getValueID() - CSSValueXSmall + 1;
|
| + if (CSSValueXSmall <= value.getValueID() && value.getValueID() <= CSSValueWebkitXxxLarge)
|
| + return value.getValueID() - CSSValueXSmall + 1;
|
|
|
| return 0;
|
| }
|
| @@ -1687,10 +1687,10 @@ bool isTransparentColorValue(NullableCSSValue cssValue)
|
| return true;
|
| if (!cssValue->isPrimitiveValue())
|
| return false;
|
| - CSSPrimitiveValue* value = toCSSPrimitiveValue(cssValue);
|
| - if (value->isRGBColor())
|
| - return !alphaChannel(value->getRGBA32Value());
|
| - return value->getValueID() == CSSValueTransparent;
|
| + CSSPrimitiveValue value = toCSSPrimitiveValue(*cssValue);
|
| + if (value.isRGBColor())
|
| + return !alphaChannel(value.getRGBA32Value());
|
| + return value.getValueID() == CSSValueTransparent;
|
| }
|
|
|
| bool hasTransparentBackgroundColor(CSSStyleDeclaration* style)
|
|
|