| Index: Source/core/editing/EditingStyle.cpp
|
| diff --git a/Source/core/editing/EditingStyle.cpp b/Source/core/editing/EditingStyle.cpp
|
| index 16e2bcf61ac9825437f68c010054c806b79bdee0..ea56ab39fd049251d08dfc239ae73d4b220b5a26 100644
|
| --- a/Source/core/editing/EditingStyle.cpp
|
| +++ b/Source/core/editing/EditingStyle.cpp
|
| @@ -204,8 +204,8 @@ 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() == toCSSPrimitiveValue(*m_primitiveValue).getValueID();
|
| + const NullableCSSValue &value = style->getPropertyCSSValue(m_propertyID);
|
| + return matches(element) && value && value->isPrimitiveValue() && toCSSPrimitiveValue(value).getValueID() == toCSSPrimitiveValue(m_primitiveValue).getValueID();
|
| }
|
|
|
| void HTMLElementEquivalent::addToStyle(Element*, EditingStyle* style) const
|
| @@ -263,7 +263,7 @@ public:
|
| bool hasAttribute() const override { return true; }
|
| bool valueIsPresentInStyle(HTMLElement*, StylePropertySet*) const override;
|
| void addToStyle(Element*, EditingStyle*) const override;
|
| - virtual NullableCSSValue attributeValueAsCSSValue(Element*) const;
|
| + virtual const NullableCSSValue attributeValueAsCSSValue(Element*) const;
|
| inline const QualifiedName& attributeName() const { return m_attrName; }
|
|
|
| DEFINE_INLINE_VIRTUAL_TRACE() { HTMLElementEquivalent::trace(visitor); }
|
| @@ -288,8 +288,8 @@ HTMLAttributeEquivalent::HTMLAttributeEquivalent(CSSPropertyID id, const Qualifi
|
|
|
| bool HTMLAttributeEquivalent::valueIsPresentInStyle(HTMLElement* element, StylePropertySet* style) const
|
| {
|
| - NullableCSSValue value = attributeValueAsCSSValue(element);
|
| - NullableCSSValue styleValue = style->getPropertyCSSValue(m_propertyID);
|
| + const NullableCSSValue& value = attributeValueAsCSSValue(element);
|
| + const NullableCSSValue& styleValue = style->getPropertyCSSValue(m_propertyID);
|
|
|
| return value == styleValue;
|
| }
|
| @@ -300,7 +300,7 @@ void HTMLAttributeEquivalent::addToStyle(Element* element, EditingStyle* style)
|
| style->setProperty(m_propertyID, value->cssText());
|
| }
|
|
|
| -NullableCSSValue HTMLAttributeEquivalent::attributeValueAsCSSValue(Element* element) const
|
| +const NullableCSSValue HTMLAttributeEquivalent::attributeValueAsCSSValue(Element* element) const
|
| {
|
| ASSERT(element);
|
| const AtomicString& value = element->getAttribute(m_attrName);
|
| @@ -319,7 +319,7 @@ public:
|
| {
|
| return adoptPtrWillBeNoop(new HTMLFontSizeEquivalent());
|
| }
|
| - NullableCSSValue attributeValueAsCSSValue(Element*) const override;
|
| + const NullableCSSValue attributeValueAsCSSValue(Element*) const override;
|
|
|
| DEFINE_INLINE_VIRTUAL_TRACE() { HTMLAttributeEquivalent::trace(visitor); }
|
|
|
| @@ -332,7 +332,7 @@ HTMLFontSizeEquivalent::HTMLFontSizeEquivalent()
|
| {
|
| }
|
|
|
| -NullableCSSValue HTMLFontSizeEquivalent::attributeValueAsCSSValue(Element* element) const
|
| +const NullableCSSValue HTMLFontSizeEquivalent::attributeValueAsCSSValue(Element* element) const
|
| {
|
| ASSERT(element);
|
| const AtomicString& value = element->getAttribute(m_attrName);
|
| @@ -391,7 +391,7 @@ static RGBA32 cssValueToRGBA(NullableCSSValue colorValue)
|
| if (!colorValue || !colorValue->isPrimitiveValue())
|
| return Color::transparent;
|
|
|
| - CSSPrimitiveValue primitiveColor = toCSSPrimitiveValue(*colorValue);
|
| + const CSSPrimitiveValue& primitiveColor = toCSSPrimitiveValue(colorValue);
|
| if (primitiveColor.isRGBColor())
|
| return primitiveColor.getRGBA32Value();
|
|
|
| @@ -519,11 +519,11 @@ void EditingStyle::extractFontSizeDelta()
|
| }
|
|
|
| // Get the adjustment amount out of the style.
|
| - NullableCSSValue value = m_mutableStyle->getPropertyCSSValue(CSSPropertyWebkitFontSizeDelta);
|
| + const NullableCSSValue& value = m_mutableStyle->getPropertyCSSValue(CSSPropertyWebkitFontSizeDelta);
|
| if (!value || !value->isPrimitiveValue())
|
| return;
|
|
|
| - CSSPrimitiveValue primitiveValue = toCSSPrimitiveValue(*value);
|
| + const 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.
|
| @@ -544,17 +544,17 @@ bool EditingStyle::textDirection(WritingDirection& writingDirection) const
|
| if (!m_mutableStyle)
|
| return false;
|
|
|
| - NullableCSSValue unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi);
|
| + const NullableCSSValue& unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi);
|
| 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);
|
| + const 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;
|
| }
|
| @@ -688,7 +688,7 @@ void EditingStyle::collapseTextDecorationProperties()
|
| if (!m_mutableStyle)
|
| return;
|
|
|
| - NullableCSSValue textDecorationsInEffect = m_mutableStyle->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
|
| + const NullableCSSValue& textDecorationsInEffect = m_mutableStyle->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
|
| if (!textDecorationsInEffect)
|
| return;
|
|
|
| @@ -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());
|
| }
|
| }
|
|
|
| @@ -1200,7 +1200,7 @@ void EditingStyle::mergeStyleFromRulesForSerialization(Element* element)
|
| unsigned propertyCount = m_mutableStyle->propertyCount();
|
| for (unsigned i = 0; i < propertyCount; ++i) {
|
| StylePropertySet::PropertyReference property = m_mutableStyle->propertyAt(i);
|
| - CSSValue value = property.value();
|
| + const CSSValue& value = property.value();
|
| if (!value.isPrimitiveValue())
|
| continue;
|
| if (toCSSPrimitiveValue(value).isPercentage()) {
|
| @@ -1298,10 +1298,10 @@ void EditingStyle::forceInline()
|
|
|
| int EditingStyle::legacyFontSize(Document* document) const
|
| {
|
| - NullableCSSValue cssValue = m_mutableStyle->getPropertyCSSValue(CSSPropertyFontSize);
|
| + 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;
|
|
|
| @@ -1433,7 +1433,7 @@ DEFINE_TRACE(EditingStyle)
|
|
|
| static void reconcileTextDecorationProperties(MutableStylePropertySet* style)
|
| {
|
| - NullableCSSValue textDecorationsInEffect = style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
|
| + const NullableCSSValue& textDecorationsInEffect = style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
|
| NullableCSSValue textDecoration = style->getPropertyCSSValue(textDecorationPropertyForEditing());
|
| // We shouldn't have both text-decoration and -webkit-text-decorations-in-effect because that wouldn't make sense.
|
| ASSERT(!textDecorationsInEffect || !textDecoration);
|
| @@ -1509,7 +1509,7 @@ void StyleChange::extractTextStyles(Document* document, MutableStylePropertySet*
|
|
|
| // 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.
|
| - NullableCSSValue textDecoration = style->getPropertyCSSValue(textDecorationPropertyForEditing());
|
| + const NullableCSSValue& textDecoration = style->getPropertyCSSValue(textDecorationPropertyForEditing());
|
| if (textDecoration && textDecoration->isValueList()) {
|
| CSSPrimitiveValue underline = CSSPrimitiveValue::createIdentifier(CSSValueUnderline);
|
| CSSPrimitiveValue lineThrough = CSSPrimitiveValue::createIdentifier(CSSValueLineThrough);
|
| @@ -1545,10 +1545,10 @@ void StyleChange::extractTextStyles(Document* document, MutableStylePropertySet*
|
| m_applyFontFace.replaceWithLiteral('\'', "");
|
| style->removeProperty(CSSPropertyFontFamily);
|
|
|
| - if (NullableCSSValue fontSize = style->getPropertyCSSValue(CSSPropertyFontSize)) {
|
| + if (const 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);
|
| }
|
| @@ -1557,7 +1557,7 @@ void StyleChange::extractTextStyles(Document* document, MutableStylePropertySet*
|
|
|
| static void diffTextDecorations(MutableStylePropertySet* style, CSSPropertyID propertyID, NullableCSSValue refTextDecoration)
|
| {
|
| - NullableCSSValue textDecoration = style->getPropertyCSSValue(propertyID);
|
| + const NullableCSSValue& textDecoration = style->getPropertyCSSValue(propertyID);
|
| if (!textDecoration || !textDecoration->isValueList() || !refTextDecoration || !refTextDecoration->isValueList())
|
| return;
|
|
|
| @@ -1621,7 +1621,7 @@ PassRefPtrWillBeRawPtr<MutableStylePropertySet> getPropertiesNotIn(StyleProperty
|
| diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect, baseTextDecorationsInEffect);
|
|
|
| if (NullableCSSValue baseFontWeight = baseStyle->getPropertyCSSValueInternal(CSSPropertyFontWeight)) {
|
| - if (NullableCSSValue fontWeight = result->getPropertyCSSValue(CSSPropertyFontWeight)) {
|
| + if (const NullableCSSValue& fontWeight = result->getPropertyCSSValue(CSSPropertyFontWeight)) {
|
| if (!fontWeightNeedsResolving(*fontWeight) && (fontWeightIsBold(*fontWeight) == fontWeightIsBold(*baseFontWeight)))
|
| result->removeProperty(CSSPropertyFontWeight);
|
| }
|
| @@ -1644,10 +1644,10 @@ CSSValueID getIdentifierValue(StylePropertySet* style, CSSPropertyID propertyID)
|
| {
|
| if (!style)
|
| return CSSValueInvalid;
|
| - NullableCSSValue value = style->getPropertyCSSValue(propertyID);
|
| + const 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,7 +1657,7 @@ 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)
|
| @@ -1687,7 +1687,7 @@ bool isTransparentColorValue(NullableCSSValue cssValue)
|
| return true;
|
| if (!cssValue->isPrimitiveValue())
|
| return false;
|
| - CSSPrimitiveValue value = toCSSPrimitiveValue(*cssValue);
|
| + const CSSPrimitiveValue& value = toCSSPrimitiveValue(cssValue);
|
| if (value.isRGBColor())
|
| return !alphaChannel(value.getRGBA32Value());
|
| return value.getValueID() == CSSValueTransparent;
|
| @@ -1701,7 +1701,7 @@ bool hasTransparentBackgroundColor(CSSStyleDeclaration* style)
|
|
|
| bool hasTransparentBackgroundColor(StylePropertySet* style)
|
| {
|
| - NullableCSSValue cssValue = style->getPropertyCSSValue(CSSPropertyBackgroundColor);
|
| + const NullableCSSValue& cssValue = style->getPropertyCSSValue(CSSPropertyBackgroundColor);
|
| return isTransparentColorValue(cssValue);
|
| }
|
|
|
|
|