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

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

Issue 22438008: Replace static_cast with safe casting methods (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 4 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
« no previous file with comments | « Source/bindings/v8/custom/V8CSSValueCustom.cpp ('k') | Source/core/editing/EditorCommand.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/EditingStyle.cpp
diff --git a/Source/core/editing/EditingStyle.cpp b/Source/core/editing/EditingStyle.cpp
index a343689ca1964a23c7a638076903e9c66816fe31..361b8a6fc93ed2dbf861f0f7350335f93420a615 100644
--- a/Source/core/editing/EditingStyle.cpp
+++ b/Source/core/editing/EditingStyle.cpp
@@ -219,7 +219,7 @@ bool HTMLTextDecorationEquivalent::valueIsPresentInStyle(Element* element, Style
RefPtr<CSSValue> styleValue = style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
if (!styleValue)
styleValue = style->getPropertyCSSValue(CSSPropertyTextDecoration);
- return matches(element) && styleValue && styleValue->isValueList() && static_cast<CSSValueList*>(styleValue.get())->hasValue(m_primitiveValue.get());
+ return matches(element) && styleValue && styleValue->isValueList() && toCSSValueList(styleValue.get())->hasValue(m_primitiveValue.get());
}
class HTMLAttributeEquivalent : public HTMLElementEquivalent {
@@ -367,7 +367,7 @@ static RGBA32 cssValueToRGBA(CSSValue* colorValue)
if (!colorValue || !colorValue->isPrimitiveValue())
return Color::transparent;
- CSSPrimitiveValue* primitiveColor = static_cast<CSSPrimitiveValue*>(colorValue);
+ CSSPrimitiveValue* primitiveColor = toCSSPrimitiveValue(colorValue);
if (primitiveColor->isRGBColor())
return primitiveColor->getRGBA32Value();
@@ -498,7 +498,7 @@ void EditingStyle::extractFontSizeDelta()
if (!value || !value->isPrimitiveValue())
return;
- CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value.get());
+ CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value.get());
// Only PX handled now. If we handle more types in the future, perhaps
// a switch statement here would be more appropriate.
@@ -1085,7 +1085,7 @@ void EditingStyle::mergeStyle(const StylePropertySet* style, CSSPropertyOverride
// text decorations never override values
if ((property.id() == CSSPropertyTextDecoration || property.id() == CSSPropertyWebkitTextDecorationsInEffect) && property.value()->isValueList() && value) {
if (value->isValueList()) {
- mergeTextDecorationValues(static_cast<CSSValueList*>(value.get()), static_cast<CSSValueList*>(property.value()));
+ mergeTextDecorationValues(toCSSValueList(value.get()), toCSSValueList(property.value()));
continue;
}
value = 0; // text-decoration: none is equivalent to not having the property
@@ -1139,7 +1139,7 @@ void EditingStyle::mergeStyleFromRulesForSerialization(Element* element)
CSSValue* value = property.value();
if (!value->isPrimitiveValue())
continue;
- if (static_cast<CSSPrimitiveValue*>(value)->isPercentage()) {
+ if (toCSSPrimitiveValue(value)->isPercentage()) {
if (RefPtr<CSSValue> computedPropertyValue = computedStyleForElement->getPropertyCSSValue(property.id()))
fromComputedStyle->addParsedProperty(CSSProperty(property.id(), computedPropertyValue));
}
@@ -1212,7 +1212,7 @@ int EditingStyle::legacyFontSize(Document* document) const
RefPtr<CSSValue> cssValue = m_mutableStyle->getPropertyCSSValue(CSSPropertyFontSize);
if (!cssValue || !cssValue->isPrimitiveValue())
return 0;
- return legacyFontSizeFromCSSValue(document, static_cast<CSSPrimitiveValue*>(cssValue.get()),
+ return legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(cssValue.get()),
m_shouldUseFixedDefaultFontSize, AlwaysUseLegacyFontSize);
}
@@ -1418,7 +1418,7 @@ void StyleChange::extractTextStyles(Document* document, MutableStylePropertySet*
DEFINE_STATIC_LOCAL(RefPtr<CSSPrimitiveValue>, underline, (CSSPrimitiveValue::createIdentifier(CSSValueUnderline)));
DEFINE_STATIC_LOCAL(RefPtr<CSSPrimitiveValue>, lineThrough, (CSSPrimitiveValue::createIdentifier(CSSValueLineThrough)));
- RefPtr<CSSValueList> newTextDecoration = static_cast<CSSValueList*>(textDecoration.get())->copy();
+ RefPtr<CSSValueList> newTextDecoration = toCSSValueList(textDecoration.get())->copy();
if (newTextDecoration->removeAll(underline.get()))
m_applyUnderline = true;
if (newTextDecoration->removeAll(lineThrough.get()))
@@ -1453,7 +1453,7 @@ void StyleChange::extractTextStyles(Document* document, MutableStylePropertySet*
if (RefPtr<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, static_cast<CSSPrimitiveValue*>(fontSize.get()),
+ else if (int legacyFontSize = legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(fontSize.get()),
shouldUseFixedFontDefaultSize, UseLegacyFontSizeOnlyIfPixelValuesMatch)) {
m_applyFontSize = String::number(legacyFontSize);
style->removeProperty(CSSPropertyFontSize);
@@ -1467,8 +1467,8 @@ static void diffTextDecorations(MutableStylePropertySet* style, CSSPropertyID pr
if (!textDecoration || !textDecoration->isValueList() || !refTextDecoration || !refTextDecoration->isValueList())
return;
- RefPtr<CSSValueList> newTextDecoration = static_cast<CSSValueList*>(textDecoration.get())->copy();
- CSSValueList* valuesInRefTextDecoration = static_cast<CSSValueList*>(refTextDecoration);
+ RefPtr<CSSValueList> newTextDecoration = toCSSValueList(textDecoration.get())->copy();
+ CSSValueList* valuesInRefTextDecoration = toCSSValueList(refTextDecoration);
for (size_t i = 0; i < valuesInRefTextDecoration->length(); i++)
newTextDecoration->removeAll(valuesInRefTextDecoration->item(i));
« no previous file with comments | « Source/bindings/v8/custom/V8CSSValueCustom.cpp ('k') | Source/core/editing/EditorCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698