| Index: Source/core/editing/EditingStyle.cpp
|
| diff --git a/Source/core/editing/EditingStyle.cpp b/Source/core/editing/EditingStyle.cpp
|
| index 52a3c39c96301892632d7f7bacee2d4b5bc6184c..83df68c9aabdc0c24be08cf4a31afafc970edbfb 100644
|
| --- a/Source/core/editing/EditingStyle.cpp
|
| +++ b/Source/core/editing/EditingStyle.cpp
|
| @@ -149,10 +149,10 @@ static PassRefPtrWillBeRawPtr<MutableStylePropertySet> editingStyleFromComputedS
|
| static PassRefPtrWillBeRawPtr<MutableStylePropertySet> getPropertiesNotIn(StylePropertySet* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle);
|
| enum LegacyFontSizeMode { AlwaysUseLegacyFontSize, UseLegacyFontSizeOnlyIfPixelValuesMatch };
|
| static int legacyFontSizeFromCSSValue(Document*, CSSPrimitiveValue*, bool, LegacyFontSizeMode);
|
| -static bool isTransparentColorValue(CSSValue*);
|
| +static bool isTransparentColorValue(NullableCSSValue);
|
| static bool hasTransparentBackgroundColor(CSSStyleDeclaration*);
|
| static bool hasTransparentBackgroundColor(StylePropertySet*);
|
| -static PassRefPtrWillBeRawPtr<CSSValue> backgroundColorInEffect(Node*);
|
| +static NullableCSSValue backgroundColorInEffect(Node*);
|
|
|
| class HTMLElementEquivalent : public NoBaseWillBeGarbageCollected<HTMLElementEquivalent> {
|
| WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(HTMLElementEquivalent);
|
| @@ -204,8 +204,8 @@ HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, CSSValueID primit
|
|
|
| bool HTMLElementEquivalent::valueIsPresentInStyle(HTMLElement* element, StylePropertySet* style) const
|
| {
|
| - RefPtrWillBeRawPtr<CSSValue> value = style->getPropertyCSSValue(m_propertyID);
|
| - return matches(element) && value && value->isPrimitiveValue() && toCSSPrimitiveValue(value.get())->getValueID() == m_primitiveValue->getValueID();
|
| + NullableCSSValue value = style->getPropertyCSSValue(m_propertyID);
|
| + return matches(element) && value && value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValueID() == m_primitiveValue->getValueID();
|
| }
|
|
|
| void HTMLElementEquivalent::addToStyle(Element*, EditingStyle* style) const
|
| @@ -242,10 +242,10 @@ bool HTMLTextDecorationEquivalent::propertyExistsInStyle(const StylePropertySet*
|
|
|
| bool HTMLTextDecorationEquivalent::valueIsPresentInStyle(HTMLElement* element, StylePropertySet* style) const
|
| {
|
| - RefPtrWillBeRawPtr<CSSValue> styleValue = style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
|
| + NullableCSSValue styleValue = style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
|
| if (!styleValue)
|
| styleValue = style->getPropertyCSSValue(textDecorationPropertyForEditing());
|
| - return matches(element) && styleValue && styleValue->isValueList() && toCSSValueList(styleValue.get())->hasValue(m_primitiveValue.get());
|
| + return matches(element) && styleValue && styleValue->isValueList() && toCSSValueList(styleValue)->hasValue(CSSValue(*m_primitiveValue.get()));
|
| }
|
|
|
| class HTMLAttributeEquivalent : public HTMLElementEquivalent {
|
| @@ -263,7 +263,7 @@ public:
|
| virtual bool hasAttribute() const override { return true; }
|
| virtual bool valueIsPresentInStyle(HTMLElement*, StylePropertySet*) const override;
|
| virtual void addToStyle(Element*, EditingStyle*) const override;
|
| - virtual PassRefPtrWillBeRawPtr<CSSValue> attributeValueAsCSSValue(Element*) const;
|
| + virtual NullableCSSValue attributeValueAsCSSValue(Element*) const;
|
| inline const QualifiedName& attributeName() const { return m_attrName; }
|
|
|
| DEFINE_INLINE_VIRTUAL_TRACE() { HTMLElementEquivalent::trace(visitor); }
|
| @@ -288,19 +288,19 @@ HTMLAttributeEquivalent::HTMLAttributeEquivalent(CSSPropertyID id, const Qualifi
|
|
|
| bool HTMLAttributeEquivalent::valueIsPresentInStyle(HTMLElement* element, StylePropertySet* style) const
|
| {
|
| - RefPtrWillBeRawPtr<CSSValue> value = attributeValueAsCSSValue(element);
|
| - RefPtrWillBeRawPtr<CSSValue> styleValue = style->getPropertyCSSValue(m_propertyID);
|
| + NullableCSSValue value = attributeValueAsCSSValue(element);
|
| + NullableCSSValue styleValue = style->getPropertyCSSValue(m_propertyID);
|
|
|
| - return compareCSSValuePtr(value, styleValue);
|
| + return value == styleValue;
|
| }
|
|
|
| void HTMLAttributeEquivalent::addToStyle(Element* element, EditingStyle* style) const
|
| {
|
| - if (RefPtrWillBeRawPtr<CSSValue> value = attributeValueAsCSSValue(element))
|
| + if (NullableCSSValue value = attributeValueAsCSSValue(element))
|
| style->setProperty(m_propertyID, value->cssText());
|
| }
|
|
|
| -PassRefPtrWillBeRawPtr<CSSValue> HTMLAttributeEquivalent::attributeValueAsCSSValue(Element* element) 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());
|
| }
|
| - virtual PassRefPtrWillBeRawPtr<CSSValue> attributeValueAsCSSValue(Element*) const override;
|
| + virtual NullableCSSValue attributeValueAsCSSValue(Element*) const override;
|
|
|
| DEFINE_INLINE_VIRTUAL_TRACE() { HTMLAttributeEquivalent::trace(visitor); }
|
|
|
| @@ -332,7 +332,7 @@ HTMLFontSizeEquivalent::HTMLFontSizeEquivalent()
|
| {
|
| }
|
|
|
| -PassRefPtrWillBeRawPtr<CSSValue> HTMLFontSizeEquivalent::attributeValueAsCSSValue(Element* element) const
|
| +NullableCSSValue HTMLFontSizeEquivalent::attributeValueAsCSSValue(Element* element) const
|
| {
|
| ASSERT(element);
|
| const AtomicString& value = element->getAttribute(m_attrName);
|
| @@ -386,7 +386,7 @@ EditingStyle::~EditingStyle()
|
| {
|
| }
|
|
|
| -static RGBA32 cssValueToRGBA(CSSValue* colorValue)
|
| +static RGBA32 cssValueToRGBA(NullableCSSValue colorValue)
|
| {
|
| if (!colorValue || !colorValue->isPrimitiveValue())
|
| return Color::transparent;
|
| @@ -403,27 +403,27 @@ static RGBA32 cssValueToRGBA(CSSValue* colorValue)
|
|
|
| static inline RGBA32 getRGBAFontColor(CSSStyleDeclaration* style)
|
| {
|
| - return cssValueToRGBA(style->getPropertyCSSValueInternal(CSSPropertyColor).get());
|
| + return cssValueToRGBA(style->getPropertyCSSValueInternal(CSSPropertyColor));
|
| }
|
|
|
| static inline RGBA32 getRGBAFontColor(StylePropertySet* style)
|
| {
|
| - return cssValueToRGBA(style->getPropertyCSSValue(CSSPropertyColor).get());
|
| + return cssValueToRGBA(style->getPropertyCSSValue(CSSPropertyColor));
|
| }
|
|
|
| static inline RGBA32 getRGBABackgroundColor(CSSStyleDeclaration* style)
|
| {
|
| - return cssValueToRGBA(style->getPropertyCSSValueInternal(CSSPropertyBackgroundColor).get());
|
| + return cssValueToRGBA(style->getPropertyCSSValueInternal(CSSPropertyBackgroundColor));
|
| }
|
|
|
| static inline RGBA32 getRGBABackgroundColor(StylePropertySet* style)
|
| {
|
| - return cssValueToRGBA(style->getPropertyCSSValue(CSSPropertyBackgroundColor).get());
|
| + return cssValueToRGBA(style->getPropertyCSSValue(CSSPropertyBackgroundColor));
|
| }
|
|
|
| static inline RGBA32 rgbaBackgroundColorInEffect(Node* node)
|
| {
|
| - return cssValueToRGBA(backgroundColorInEffect(node).get());
|
| + return cssValueToRGBA(backgroundColorInEffect(node));
|
| }
|
|
|
| static int textAlignResolvingStartAndEnd(int textAlign, int direction)
|
| @@ -465,9 +465,9 @@ void EditingStyle::init(Node* node, PropertiesToInclude propertiesToInclude)
|
| m_mutableStyle = propertiesToInclude == AllProperties && computedStyleAtPosition ? computedStyleAtPosition->copyProperties() : editingStyleFromComputedStyle(computedStyleAtPosition);
|
|
|
| if (propertiesToInclude == EditingPropertiesInEffect) {
|
| - if (RefPtrWillBeRawPtr<CSSValue> value = backgroundColorInEffect(node))
|
| + if (NullableCSSValue value = backgroundColorInEffect(node))
|
| m_mutableStyle->setProperty(CSSPropertyBackgroundColor, value->cssText());
|
| - if (RefPtrWillBeRawPtr<CSSValue> value = computedStyleAtPosition->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect))
|
| + if (NullableCSSValue value = computedStyleAtPosition->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect))
|
| m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssText());
|
| }
|
|
|
| @@ -519,11 +519,11 @@ void EditingStyle::extractFontSizeDelta()
|
| }
|
|
|
| // Get the adjustment amount out of the style.
|
| - RefPtrWillBeRawPtr<CSSValue> value = m_mutableStyle->getPropertyCSSValue(CSSPropertyWebkitFontSizeDelta);
|
| + NullableCSSValue value = m_mutableStyle->getPropertyCSSValue(CSSPropertyWebkitFontSizeDelta);
|
| if (!value || !value->isPrimitiveValue())
|
| return;
|
|
|
| - CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value.get());
|
| + 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;
|
|
|
| - RefPtrWillBeRawPtr<CSSValue> unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi);
|
| + NullableCSSValue unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi);
|
| if (!unicodeBidi || !unicodeBidi->isPrimitiveValue())
|
| return false;
|
|
|
| - CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get())->getValueID();
|
| + CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getValueID();
|
| if (unicodeBidiValue == CSSValueEmbed) {
|
| - RefPtrWillBeRawPtr<CSSValue> direction = m_mutableStyle->getPropertyCSSValue(CSSPropertyDirection);
|
| + NullableCSSValue direction = m_mutableStyle->getPropertyCSSValue(CSSPropertyDirection);
|
| if (!direction || !direction->isPrimitiveValue())
|
| return false;
|
|
|
| - writingDirection = toCSSPrimitiveValue(direction.get())->getValueID() == CSSValueLtr ? LeftToRightWritingDirection : RightToLeftWritingDirection;
|
| + writingDirection = toCSSPrimitiveValue(direction)->getValueID() == CSSValueLtr ? LeftToRightWritingDirection : RightToLeftWritingDirection;
|
|
|
| return true;
|
| }
|
| @@ -688,7 +688,7 @@ void EditingStyle::collapseTextDecorationProperties()
|
| if (!m_mutableStyle)
|
| return;
|
|
|
| - RefPtrWillBeRawPtr<CSSValue> textDecorationsInEffect = m_mutableStyle->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
|
| + NullableCSSValue textDecorationsInEffect = m_mutableStyle->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
|
| if (!textDecorationsInEffect)
|
| return;
|
|
|
| @@ -985,8 +985,8 @@ void EditingStyle::prepareToApplyAt(const Position& position, ShouldPreserveWrit
|
| RefPtrWillBeRawPtr<EditingStyle> editingStyleAtPosition = EditingStyle::create(position, EditingPropertiesInEffect);
|
| StylePropertySet* styleAtPosition = editingStyleAtPosition->m_mutableStyle.get();
|
|
|
| - RefPtrWillBeRawPtr<CSSValue> unicodeBidi = nullptr;
|
| - RefPtrWillBeRawPtr<CSSValue> direction = nullptr;
|
| + NullableCSSValue unicodeBidi;
|
| + NullableCSSValue direction;
|
| if (shouldPreserveWritingDirection == PreserveWritingDirection) {
|
| unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi);
|
| direction = m_mutableStyle->getPropertyCSSValue(CSSPropertyDirection);
|
| @@ -1001,13 +1001,13 @@ void EditingStyle::prepareToApplyAt(const Position& position, ShouldPreserveWrit
|
| m_mutableStyle->removeProperty(CSSPropertyColor);
|
|
|
| if (hasTransparentBackgroundColor(m_mutableStyle.get())
|
| - || cssValueToRGBA(m_mutableStyle->getPropertyCSSValue(CSSPropertyBackgroundColor).get()) == rgbaBackgroundColorInEffect(position.containerNode()))
|
| + || cssValueToRGBA(m_mutableStyle->getPropertyCSSValue(CSSPropertyBackgroundColor)) == rgbaBackgroundColorInEffect(position.containerNode()))
|
| m_mutableStyle->removeProperty(CSSPropertyBackgroundColor);
|
|
|
| if (unicodeBidi && unicodeBidi->isPrimitiveValue()) {
|
| - m_mutableStyle->setProperty(CSSPropertyUnicodeBidi, toCSSPrimitiveValue(unicodeBidi.get())->getValueID());
|
| + m_mutableStyle->setProperty(CSSPropertyUnicodeBidi, toCSSPrimitiveValue(unicodeBidi)->getValueID());
|
| if (direction && direction->isPrimitiveValue())
|
| - m_mutableStyle->setProperty(CSSPropertyDirection, toCSSPrimitiveValue(direction.get())->getValueID());
|
| + m_mutableStyle->setProperty(CSSPropertyDirection, toCSSPrimitiveValue(direction)->getValueID());
|
| }
|
| }
|
|
|
| @@ -1122,15 +1122,16 @@ PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::wrappingStyleForSerialization
|
| }
|
|
|
|
|
| -static void mergeTextDecorationValues(CSSValueList* mergedValue, const CSSValueList* valueToMerge)
|
| +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)));
|
| - if (valueToMerge->hasValue(underline) && !mergedValue->hasValue(underline))
|
| - mergedValue->append(underline);
|
|
|
| - if (valueToMerge->hasValue(lineThrough) && !mergedValue->hasValue(lineThrough))
|
| - mergedValue->append(lineThrough);
|
| + if (valueToMerge.hasValue(CSSValue(*underline)) && !mergedValue.hasValue(CSSValue(*underline)))
|
| + mergedValue.append(CSSValue(*underline));
|
| +
|
| + if (valueToMerge.hasValue(CSSValue(*lineThrough)) && !mergedValue.hasValue(CSSValue(*lineThrough)))
|
| + mergedValue.append(CSSValue(*lineThrough));
|
| }
|
|
|
| void EditingStyle::mergeStyle(const StylePropertySet* style, CSSPropertyOverrideMode mode)
|
| @@ -1146,19 +1147,19 @@ void EditingStyle::mergeStyle(const StylePropertySet* style, CSSPropertyOverride
|
| unsigned propertyCount = style->propertyCount();
|
| for (unsigned i = 0; i < propertyCount; ++i) {
|
| StylePropertySet::PropertyReference property = style->propertyAt(i);
|
| - RefPtrWillBeRawPtr<CSSValue> value = m_mutableStyle->getPropertyCSSValue(property.id());
|
| + NullableCSSValue 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()) {
|
| - mergeTextDecorationValues(toCSSValueList(value.get()), toCSSValueList(property.value()));
|
| + if ((property.id() == textDecorationPropertyForEditing() || property.id() == CSSPropertyWebkitTextDecorationsInEffect) && property.value().isValueList() && value) {
|
| + if (value && value->isValueList()) {
|
| + mergeTextDecorationValues(*toCSSValueList(value), toCSSValueList(property.value()));
|
| continue;
|
| }
|
| value = nullptr; // text-decoration: none is equivalent to not having the property
|
| }
|
|
|
| if (mode == OverrideValues || (mode == DoNotOverrideValues && !value))
|
| - m_mutableStyle->setProperty(property.id(), property.value()->cssText(), property.isImportant());
|
| + m_mutableStyle->setProperty(property.id(), property.value().cssText(), property.isImportant());
|
| }
|
| }
|
|
|
| @@ -1199,12 +1200,12 @@ 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();
|
| - if (!value->isPrimitiveValue())
|
| + CSSValue value = property.value();
|
| + if (!value.isPrimitiveValue())
|
| continue;
|
| - if (toCSSPrimitiveValue(value)->isPercentage()) {
|
| - if (RefPtrWillBeRawPtr<CSSValue> computedPropertyValue = computedStyleForElement->getPropertyCSSValue(property.id()))
|
| - fromComputedStyle->addRespectingCascade(CSSProperty(property.id(), computedPropertyValue));
|
| + if (toCSSPrimitiveValue(value).isPercentage()) {
|
| + if (NullableCSSValue computedPropertyValue = computedStyleForElement->getPropertyCSSValue(property.id()))
|
| + fromComputedStyle->addRespectingCascade(CSSProperty(property.id(), *computedPropertyValue));
|
| }
|
| }
|
| }
|
| @@ -1297,10 +1298,10 @@ void EditingStyle::forceInline()
|
|
|
| int EditingStyle::legacyFontSize(Document* document) const
|
| {
|
| - RefPtrWillBeRawPtr<CSSValue> cssValue = m_mutableStyle->getPropertyCSSValue(CSSPropertyFontSize);
|
| + NullableCSSValue cssValue = m_mutableStyle->getPropertyCSSValue(CSSPropertyFontSize);
|
| if (!cssValue || !cssValue->isPrimitiveValue())
|
| return 0;
|
| - return legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(cssValue.get()),
|
| + return legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(cssValue),
|
| m_isMonospaceFont, AlwaysUseLegacyFontSize);
|
| }
|
|
|
| @@ -1331,7 +1332,7 @@ PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::styleAtSelectionStart(const V
|
| // and find the background color of the common ancestor.
|
| if (shouldUseBackgroundColorInEffect && (selection.isRange() || hasTransparentBackgroundColor(style->m_mutableStyle.get()))) {
|
| RefPtrWillBeRawPtr<Range> range(selection.toNormalizedRange());
|
| - if (PassRefPtrWillBeRawPtr<CSSValue> value = backgroundColorInEffect(range->commonAncestorContainer()))
|
| + if (NullableCSSValue value = backgroundColorInEffect(range->commonAncestorContainer()))
|
| style->setProperty(CSSPropertyBackgroundColor, value->cssText());
|
| }
|
|
|
| @@ -1362,11 +1363,11 @@ WritingDirection EditingStyle::textDirectionForSelection(const VisibleSelection&
|
| continue;
|
|
|
| RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style = CSSComputedStyleDeclaration::create(n);
|
| - RefPtrWillBeRawPtr<CSSValue> unicodeBidi = style->getPropertyCSSValue(CSSPropertyUnicodeBidi);
|
| + NullableCSSValue unicodeBidi = style->getPropertyCSSValue(CSSPropertyUnicodeBidi);
|
| if (!unicodeBidi || !unicodeBidi->isPrimitiveValue())
|
| continue;
|
|
|
| - CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get())->getValueID();
|
| + CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getValueID();
|
| if (unicodeBidiValue == CSSValueEmbed || unicodeBidiValue == CSSValueBidiOverride)
|
| return NaturalWritingDirection;
|
| }
|
| @@ -1392,11 +1393,11 @@ WritingDirection EditingStyle::textDirectionForSelection(const VisibleSelection&
|
|
|
| Element* element = toElement(node);
|
| RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style = CSSComputedStyleDeclaration::create(element);
|
| - RefPtrWillBeRawPtr<CSSValue> unicodeBidi = style->getPropertyCSSValue(CSSPropertyUnicodeBidi);
|
| + NullableCSSValue unicodeBidi = style->getPropertyCSSValue(CSSPropertyUnicodeBidi);
|
| if (!unicodeBidi || !unicodeBidi->isPrimitiveValue())
|
| continue;
|
|
|
| - CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get())->getValueID();
|
| + CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getValueID();
|
| if (unicodeBidiValue == CSSValueNormal)
|
| continue;
|
|
|
| @@ -1404,11 +1405,11 @@ WritingDirection EditingStyle::textDirectionForSelection(const VisibleSelection&
|
| return NaturalWritingDirection;
|
|
|
| ASSERT(unicodeBidiValue == CSSValueEmbed);
|
| - RefPtrWillBeRawPtr<CSSValue> direction = style->getPropertyCSSValue(CSSPropertyDirection);
|
| + NullableCSSValue direction = style->getPropertyCSSValue(CSSPropertyDirection);
|
| if (!direction || !direction->isPrimitiveValue())
|
| continue;
|
|
|
| - int directionValue = toCSSPrimitiveValue(direction.get())->getValueID();
|
| + int directionValue = toCSSPrimitiveValue(direction)->getValueID();
|
| if (directionValue != CSSValueLtr && directionValue != CSSValueRtl)
|
| continue;
|
|
|
| @@ -1432,8 +1433,8 @@ DEFINE_TRACE(EditingStyle)
|
|
|
| static void reconcileTextDecorationProperties(MutableStylePropertySet* style)
|
| {
|
| - RefPtrWillBeRawPtr<CSSValue> textDecorationsInEffect = style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
|
| - RefPtrWillBeRawPtr<CSSValue> textDecoration = style->getPropertyCSSValue(textDecorationPropertyForEditing());
|
| + 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);
|
| if (textDecorationsInEffect) {
|
| @@ -1508,14 +1509,14 @@ 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.
|
| - RefPtrWillBeRawPtr<CSSValue> textDecoration = style->getPropertyCSSValue(textDecorationPropertyForEditing());
|
| + 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)));
|
| - RefPtrWillBeRawPtr<CSSValueList> newTextDecoration = toCSSValueList(textDecoration.get())->copy();
|
| - if (newTextDecoration->removeAll(underline))
|
| + RefPtrWillBeRawPtr<CSSValueList> newTextDecoration = toCSSValueList(textDecoration)->copy();
|
| + if (newTextDecoration->removeAll(CSSValue(*underline)))
|
| m_applyUnderline = true;
|
| - if (newTextDecoration->removeAll(lineThrough))
|
| + if (newTextDecoration->removeAll(CSSValue(*lineThrough)))
|
| m_applyLineThrough = true;
|
|
|
| // If trimTextDecorations, delete underline and line-through
|
| @@ -1544,39 +1545,39 @@ void StyleChange::extractTextStyles(Document* document, MutableStylePropertySet*
|
| m_applyFontFace.replaceWithLiteral('\'', "");
|
| style->removeProperty(CSSPropertyFontFamily);
|
|
|
| - if (RefPtrWillBeRawPtr<CSSValue> fontSize = style->getPropertyCSSValue(CSSPropertyFontSize)) {
|
| + 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.get()), isMonospaceFont, UseLegacyFontSizeOnlyIfPixelValuesMatch)) {
|
| + } else if (int legacyFontSize = legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(fontSize), isMonospaceFont, UseLegacyFontSizeOnlyIfPixelValuesMatch)) {
|
| m_applyFontSize = String::number(legacyFontSize);
|
| style->removeProperty(CSSPropertyFontSize);
|
| }
|
| }
|
| }
|
|
|
| -static void diffTextDecorations(MutableStylePropertySet* style, CSSPropertyID propertID, CSSValue* refTextDecoration)
|
| +static void diffTextDecorations(MutableStylePropertySet* style, CSSPropertyID propertyID, NullableCSSValue refTextDecoration)
|
| {
|
| - RefPtrWillBeRawPtr<CSSValue> textDecoration = style->getPropertyCSSValue(propertID);
|
| + NullableCSSValue textDecoration = style->getPropertyCSSValue(propertyID);
|
| if (!textDecoration || !textDecoration->isValueList() || !refTextDecoration || !refTextDecoration->isValueList())
|
| return;
|
|
|
| - RefPtrWillBeRawPtr<CSSValueList> newTextDecoration = toCSSValueList(textDecoration.get())->copy();
|
| + RefPtrWillBeRawPtr<CSSValueList> newTextDecoration = toCSSValueList(textDecoration)->copy();
|
| CSSValueList* valuesInRefTextDecoration = toCSSValueList(refTextDecoration);
|
|
|
| for (size_t i = 0; i < valuesInRefTextDecoration->length(); i++)
|
| newTextDecoration->removeAll(valuesInRefTextDecoration->item(i));
|
|
|
| - setTextDecorationProperty(style, newTextDecoration.get(), propertID);
|
| + setTextDecorationProperty(style, newTextDecoration.get(), propertyID);
|
| }
|
|
|
| -static bool fontWeightIsBold(CSSValue* fontWeight)
|
| +static bool fontWeightIsBold(CSSValue fontWeight)
|
| {
|
| - if (!fontWeight->isPrimitiveValue())
|
| + if (!fontWeight.isPrimitiveValue())
|
| return false;
|
|
|
| // Because b tag can only bold text, there are only two states in plain html: bold and not bold.
|
| // Collapse all other values to either one of these two states for editing purposes.
|
| - switch (toCSSPrimitiveValue(fontWeight)->getValueID()) {
|
| + switch (toCSSPrimitiveValue(fontWeight).getValueID()) {
|
| case CSSValue100:
|
| case CSSValue200:
|
| case CSSValue300:
|
| @@ -1598,12 +1599,12 @@ static bool fontWeightIsBold(CSSValue* fontWeight)
|
| return false;
|
| }
|
|
|
| -static bool fontWeightNeedsResolving(CSSValue* fontWeight)
|
| +static bool fontWeightNeedsResolving(CSSValue fontWeight)
|
| {
|
| - if (!fontWeight->isPrimitiveValue())
|
| + if (!fontWeight.isPrimitiveValue())
|
| return true;
|
|
|
| - CSSValueID value = toCSSPrimitiveValue(fontWeight)->getValueID();
|
| + CSSValueID value = toCSSPrimitiveValue(fontWeight).getValueID();
|
| return value == CSSValueLighter || value == CSSValueBolder;
|
| }
|
|
|
| @@ -1615,13 +1616,13 @@ PassRefPtrWillBeRawPtr<MutableStylePropertySet> getPropertiesNotIn(StyleProperty
|
|
|
| result->removeEquivalentProperties(baseStyle);
|
|
|
| - RefPtrWillBeRawPtr<CSSValue> baseTextDecorationsInEffect = baseStyle->getPropertyCSSValueInternal(CSSPropertyWebkitTextDecorationsInEffect);
|
| - diffTextDecorations(result.get(), textDecorationPropertyForEditing(), baseTextDecorationsInEffect.get());
|
| - diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect, baseTextDecorationsInEffect.get());
|
| + NullableCSSValue baseTextDecorationsInEffect = baseStyle->getPropertyCSSValueInternal(CSSPropertyWebkitTextDecorationsInEffect);
|
| + diffTextDecorations(result.get(), textDecorationPropertyForEditing(), baseTextDecorationsInEffect);
|
| + diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect, baseTextDecorationsInEffect);
|
|
|
| - if (RefPtrWillBeRawPtr<CSSValue> baseFontWeight = baseStyle->getPropertyCSSValueInternal(CSSPropertyFontWeight)) {
|
| - if (RefPtrWillBeRawPtr<CSSValue> fontWeight = result->getPropertyCSSValue(CSSPropertyFontWeight)) {
|
| - if (!fontWeightNeedsResolving(fontWeight.get()) && (fontWeightIsBold(fontWeight.get()) == fontWeightIsBold(baseFontWeight.get())))
|
| + if (NullableCSSValue baseFontWeight = baseStyle->getPropertyCSSValueInternal(CSSPropertyFontWeight)) {
|
| + if (NullableCSSValue fontWeight = result->getPropertyCSSValue(CSSPropertyFontWeight)) {
|
| + if (!fontWeightNeedsResolving(*fontWeight) && (fontWeightIsBold(*fontWeight) == fontWeightIsBold(*baseFontWeight)))
|
| result->removeProperty(CSSPropertyFontWeight);
|
| }
|
| }
|
| @@ -1643,20 +1644,20 @@ CSSValueID getIdentifierValue(StylePropertySet* style, CSSPropertyID propertyID)
|
| {
|
| if (!style)
|
| return CSSValueInvalid;
|
| - RefPtrWillBeRawPtr<CSSValue> value = style->getPropertyCSSValue(propertyID);
|
| + NullableCSSValue value = style->getPropertyCSSValue(propertyID);
|
| if (!value || !value->isPrimitiveValue())
|
| return CSSValueInvalid;
|
| - return toCSSPrimitiveValue(value.get())->getValueID();
|
| + return toCSSPrimitiveValue(value)->getValueID();
|
| }
|
|
|
| CSSValueID getIdentifierValue(CSSStyleDeclaration* style, CSSPropertyID propertyID)
|
| {
|
| if (!style)
|
| return CSSValueInvalid;
|
| - RefPtrWillBeRawPtr<CSSValue> value = style->getPropertyCSSValueInternal(propertyID);
|
| + NullableCSSValue value = style->getPropertyCSSValueInternal(propertyID);
|
| if (!value || !value->isPrimitiveValue())
|
| return CSSValueInvalid;
|
| - return toCSSPrimitiveValue(value.get())->getValueID();
|
| + return toCSSPrimitiveValue(value)->getValueID();
|
| }
|
|
|
| int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, bool isMonospaceFont, LegacyFontSizeMode mode)
|
| @@ -1680,7 +1681,7 @@ int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, boo
|
| return 0;
|
| }
|
|
|
| -bool isTransparentColorValue(CSSValue* cssValue)
|
| +bool isTransparentColorValue(NullableCSSValue cssValue)
|
| {
|
| if (!cssValue)
|
| return true;
|
| @@ -1694,17 +1695,17 @@ bool isTransparentColorValue(CSSValue* cssValue)
|
|
|
| bool hasTransparentBackgroundColor(CSSStyleDeclaration* style)
|
| {
|
| - RefPtrWillBeRawPtr<CSSValue> cssValue = style->getPropertyCSSValueInternal(CSSPropertyBackgroundColor);
|
| - return isTransparentColorValue(cssValue.get());
|
| + NullableCSSValue cssValue = style->getPropertyCSSValueInternal(CSSPropertyBackgroundColor);
|
| + return isTransparentColorValue(cssValue);
|
| }
|
|
|
| bool hasTransparentBackgroundColor(StylePropertySet* style)
|
| {
|
| - RefPtrWillBeRawPtr<CSSValue> cssValue = style->getPropertyCSSValue(CSSPropertyBackgroundColor);
|
| - return isTransparentColorValue(cssValue.get());
|
| + NullableCSSValue cssValue = style->getPropertyCSSValue(CSSPropertyBackgroundColor);
|
| + return isTransparentColorValue(cssValue);
|
| }
|
|
|
| -PassRefPtrWillBeRawPtr<CSSValue> backgroundColorInEffect(Node* node)
|
| +NullableCSSValue backgroundColorInEffect(Node* node)
|
| {
|
| for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) {
|
| RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSComputedStyleDeclaration::create(ancestor);
|
|
|