Index: Source/core/editing/EditingStyle.cpp |
diff --git a/Source/core/editing/EditingStyle.cpp b/Source/core/editing/EditingStyle.cpp |
index 28e6ecd981b444ae7e7a29525bb845611d148b58..9ee281c00c086f859e9469ce5a0fef32f4e9c5d7 100644 |
--- a/Source/core/editing/EditingStyle.cpp |
+++ b/Source/core/editing/EditingStyle.cpp |
@@ -138,7 +138,7 @@ static PassRefPtr<CSSValue> backgroundColorInEffect(Node*); |
class HTMLElementEquivalent { |
WTF_MAKE_FAST_ALLOCATED; |
public: |
- static PassOwnPtr<HTMLElementEquivalent> create(CSSPropertyID propertyID, int primitiveValue, const QualifiedName& tagName) |
+ static PassOwnPtr<HTMLElementEquivalent> create(CSSPropertyID propertyID, CSSValueID primitiveValue, const QualifiedName& tagName) |
{ |
return adoptPtr(new HTMLElementEquivalent(propertyID, primitiveValue, tagName)); |
} |
@@ -153,7 +153,7 @@ public: |
protected: |
HTMLElementEquivalent(CSSPropertyID); |
HTMLElementEquivalent(CSSPropertyID, const QualifiedName& tagName); |
- HTMLElementEquivalent(CSSPropertyID, int primitiveValue, const QualifiedName& tagName); |
+ HTMLElementEquivalent(CSSPropertyID, CSSValueID primitiveValue, const QualifiedName& tagName); |
const CSSPropertyID m_propertyID; |
const RefPtr<CSSPrimitiveValue> m_primitiveValue; |
const QualifiedName* m_tagName; // We can store a pointer because HTML tag names are const global. |
@@ -171,7 +171,7 @@ HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, const QualifiedNa |
{ |
} |
-HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, int primitiveValue, const QualifiedName& tagName) |
+HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, CSSValueID primitiveValue, const QualifiedName& tagName) |
: m_propertyID(id) |
, m_primitiveValue(CSSPrimitiveValue::createIdentifier(primitiveValue)) |
, m_tagName(&tagName) |
@@ -182,7 +182,7 @@ HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, int primitiveValu |
bool HTMLElementEquivalent::valueIsPresentInStyle(Element* element, StylePropertySet* style) const |
{ |
RefPtr<CSSValue> value = style->getPropertyCSSValue(m_propertyID); |
- return matches(element) && value && value->isPrimitiveValue() && static_cast<CSSPrimitiveValue*>(value.get())->getIdent() == m_primitiveValue->getIdent(); |
+ return matches(element) && value && value->isPrimitiveValue() && toCSSPrimitiveValue(value.get())->getValueID() == m_primitiveValue->getValueID(); |
} |
void HTMLElementEquivalent::addToStyle(Element*, EditingStyle* style) const |
@@ -192,7 +192,7 @@ void HTMLElementEquivalent::addToStyle(Element*, EditingStyle* style) const |
class HTMLTextDecorationEquivalent : public HTMLElementEquivalent { |
public: |
- static PassOwnPtr<HTMLElementEquivalent> create(int primitiveValue, const QualifiedName& tagName) |
+ static PassOwnPtr<HTMLElementEquivalent> create(CSSValueID primitiveValue, const QualifiedName& tagName) |
{ |
return adoptPtr(new HTMLTextDecorationEquivalent(primitiveValue, tagName)); |
} |
@@ -200,10 +200,10 @@ public: |
virtual bool valueIsPresentInStyle(Element*, StylePropertySet*) const; |
private: |
- HTMLTextDecorationEquivalent(int primitiveValue, const QualifiedName& tagName); |
+ HTMLTextDecorationEquivalent(CSSValueID primitiveValue, const QualifiedName& tagName); |
}; |
-HTMLTextDecorationEquivalent::HTMLTextDecorationEquivalent(int primitiveValue, const QualifiedName& tagName) |
+HTMLTextDecorationEquivalent::HTMLTextDecorationEquivalent(CSSValueID primitiveValue, const QualifiedName& tagName) |
: HTMLElementEquivalent(CSSPropertyTextDecoration, primitiveValue, tagName) |
// m_propertyID is used in HTMLElementEquivalent::addToStyle |
{ |
@@ -523,13 +523,13 @@ bool EditingStyle::textDirection(WritingDirection& writingDirection) const |
if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) |
return false; |
- int unicodeBidiValue = static_cast<CSSPrimitiveValue*>(unicodeBidi.get())->getIdent(); |
+ CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get())->getValueID(); |
if (unicodeBidiValue == CSSValueEmbed) { |
RefPtr<CSSValue> direction = m_mutableStyle->getPropertyCSSValue(CSSPropertyDirection); |
if (!direction || !direction->isPrimitiveValue()) |
return false; |
- writingDirection = static_cast<CSSPrimitiveValue*>(direction.get())->getIdent() == CSSValueLtr ? LeftToRightWritingDirection : RightToLeftWritingDirection; |
+ writingDirection = toCSSPrimitiveValue(direction.get())->getValueID() == CSSValueLtr ? LeftToRightWritingDirection : RightToLeftWritingDirection; |
return true; |
} |
@@ -953,9 +953,9 @@ void EditingStyle::prepareToApplyAt(const Position& position, ShouldPreserveWrit |
m_mutableStyle->removeProperty(CSSPropertyBackgroundColor); |
if (unicodeBidi && unicodeBidi->isPrimitiveValue()) { |
- m_mutableStyle->setProperty(CSSPropertyUnicodeBidi, static_cast<CSSValueID>(toCSSPrimitiveValue(unicodeBidi.get())->getIdent())); |
+ m_mutableStyle->setProperty(CSSPropertyUnicodeBidi, toCSSPrimitiveValue(unicodeBidi.get())->getValueID()); |
if (direction && direction->isPrimitiveValue()) |
- m_mutableStyle->setProperty(CSSPropertyDirection, static_cast<CSSValueID>(toCSSPrimitiveValue(direction.get())->getIdent())); |
+ m_mutableStyle->setProperty(CSSPropertyDirection, toCSSPrimitiveValue(direction.get())->getValueID()); |
} |
} |
@@ -1273,7 +1273,7 @@ WritingDirection EditingStyle::textDirectionForSelection(const VisibleSelection& |
if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) |
continue; |
- int unicodeBidiValue = static_cast<CSSPrimitiveValue*>(unicodeBidi.get())->getIdent(); |
+ CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get())->getValueID(); |
if (unicodeBidiValue == CSSValueEmbed || unicodeBidiValue == CSSValueBidiOverride) |
return NaturalWritingDirection; |
} |
@@ -1302,7 +1302,7 @@ WritingDirection EditingStyle::textDirectionForSelection(const VisibleSelection& |
if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) |
continue; |
- int unicodeBidiValue = static_cast<CSSPrimitiveValue*>(unicodeBidi.get())->getIdent(); |
+ CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get())->getValueID(); |
if (unicodeBidiValue == CSSValueNormal) |
continue; |
@@ -1314,7 +1314,7 @@ WritingDirection EditingStyle::textDirectionForSelection(const VisibleSelection& |
if (!direction || !direction->isPrimitiveValue()) |
continue; |
- int directionValue = static_cast<CSSPrimitiveValue*>(direction.get())->getIdent(); |
+ int directionValue = toCSSPrimitiveValue(direction.get())->getValueID(); |
if (directionValue != CSSValueLtr && directionValue != CSSValueRtl) |
continue; |
@@ -1481,7 +1481,7 @@ static bool fontWeightIsBold(CSSValue* fontWeight) |
// 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 (static_cast<CSSPrimitiveValue*>(fontWeight)->getIdent()) { |
+ switch (toCSSPrimitiveValue(fontWeight)->getValueID()) { |
case CSSValue100: |
case CSSValue200: |
case CSSValue300: |
@@ -1495,6 +1495,8 @@ static bool fontWeightIsBold(CSSValue* fontWeight) |
case CSSValue800: |
case CSSValue900: |
return true; |
+ default: |
+ break; |
} |
ASSERT_NOT_REACHED(); // For CSSValueBolder and CSSValueLighter |
@@ -1543,24 +1545,24 @@ PassRefPtr<MutableStylePropertySet> getPropertiesNotIn(StylePropertySet* styleWi |
return result.release(); |
} |
-int getIdentifierValue(StylePropertySet* style, CSSPropertyID propertyID) |
+CSSValueID getIdentifierValue(StylePropertySet* style, CSSPropertyID propertyID) |
{ |
if (!style) |
- return 0; |
+ return CSSValueInvalid; |
RefPtr<CSSValue> value = style->getPropertyCSSValue(propertyID); |
if (!value || !value->isPrimitiveValue()) |
- return 0; |
- return static_cast<CSSPrimitiveValue*>(value.get())->getIdent(); |
+ return CSSValueInvalid; |
+ return toCSSPrimitiveValue(value.get())->getValueID(); |
} |
-int getIdentifierValue(CSSStyleDeclaration* style, CSSPropertyID propertyID) |
+CSSValueID getIdentifierValue(CSSStyleDeclaration* style, CSSPropertyID propertyID) |
{ |
if (!style) |
- return 0; |
+ return CSSValueInvalid; |
RefPtr<CSSValue> value = style->getPropertyCSSValueInternal(propertyID); |
if (!value || !value->isPrimitiveValue()) |
- return 0; |
- return static_cast<CSSPrimitiveValue*>(value.get())->getIdent(); |
+ return CSSValueInvalid; |
+ return toCSSPrimitiveValue(value.get())->getValueID(); |
} |
static bool isCSSValueLength(CSSPrimitiveValue* value) |
@@ -1581,8 +1583,8 @@ int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, boo |
return 0; |
} |
- if (CSSValueXSmall <= value->getIdent() && value->getIdent() <= CSSValueWebkitXxxLarge) |
- return value->getIdent() - CSSValueXSmall + 1; |
+ if (CSSValueXSmall <= value->getValueID() && value->getValueID() <= CSSValueWebkitXxxLarge) |
+ return value->getValueID() - CSSValueXSmall + 1; |
return 0; |
} |
@@ -1590,13 +1592,13 @@ int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, boo |
bool isTransparentColorValue(CSSValue* cssValue) |
{ |
if (!cssValue) |
- return true; |
+ return true; |
if (!cssValue->isPrimitiveValue()) |
return false; |
- CSSPrimitiveValue* value = static_cast<CSSPrimitiveValue*>(cssValue); |
+ CSSPrimitiveValue* value = toCSSPrimitiveValue(cssValue); |
if (value->isRGBColor()) |
- return !alphaChannel(value->getRGBA32Value()); |
- return value->getIdent() == CSSValueTransparent; |
+ return !alphaChannel(value->getRGBA32Value()); |
+ return value->getValueID() == CSSValueTransparent; |
} |
bool hasTransparentBackgroundColor(CSSStyleDeclaration* style) |