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

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

Issue 23075004: Fixes a crash when copying elements with font-weight lighter or bolder (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 | « LayoutTests/editing/pasteboard/insert-font-weight-expected.txt ('k') | no next file » | 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 614038c2de9597891c66cd616b64410bf9c9d821..6e34dc978950576d277db9c8fc51457cfa61d900 100644
--- a/Source/core/editing/EditingStyle.cpp
+++ b/Source/core/editing/EditingStyle.cpp
@@ -1492,8 +1492,6 @@ static void diffTextDecorations(MutableStylePropertySet* style, CSSPropertyID pr
static bool fontWeightIsBold(CSSValue* fontWeight)
{
- if (!fontWeight)
- return false;
if (!fontWeight->isPrimitiveValue())
return false;
@@ -1521,18 +1519,13 @@ static bool fontWeightIsBold(CSSValue* fontWeight)
return false;
}
-static bool fontWeightIsBold(CSSStyleDeclaration* style)
+static bool fontWeightNeedsResolving(CSSValue* fontWeight)
{
- ASSERT(style);
- RefPtr<CSSValue> fontWeight = style->getPropertyCSSValueInternal(CSSPropertyFontWeight);
- return fontWeightIsBold(fontWeight.get());
-}
+ if (!fontWeight->isPrimitiveValue())
+ return true;
-static bool fontWeightIsBold(StylePropertySet* style)
-{
- ASSERT(style);
- RefPtr<CSSValue> fontWeight = style->getPropertyCSSValue(CSSPropertyFontWeight);
- return fontWeightIsBold(fontWeight.get());
+ CSSValueID value = toCSSPrimitiveValue(fontWeight)->getValueID();
+ return value == CSSValueLighter || value == CSSValueBolder;
}
PassRefPtr<MutableStylePropertySet> getPropertiesNotIn(StylePropertySet* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle)
@@ -1547,8 +1540,12 @@ PassRefPtr<MutableStylePropertySet> getPropertiesNotIn(StylePropertySet* styleWi
diffTextDecorations(result.get(), CSSPropertyTextDecoration, baseTextDecorationsInEffect.get());
diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect, baseTextDecorationsInEffect.get());
- if (baseStyle->getPropertyCSSValueInternal(CSSPropertyFontWeight) && fontWeightIsBold(result.get()) == fontWeightIsBold(baseStyle))
- result->removeProperty(CSSPropertyFontWeight);
+ if (RefPtr<CSSValue> baseFontWeight = baseStyle->getPropertyCSSValueInternal(CSSPropertyFontWeight)) {
+ if (RefPtr<CSSValue> fontWeight = result->getPropertyCSSValue(CSSPropertyFontWeight)) {
+ if (!fontWeightNeedsResolving(fontWeight.get()) && (fontWeightIsBold(fontWeight.get()) == fontWeightIsBold(baseFontWeight.get())))
rniwa-cr 2013/08/16 05:56:53 This is still incorrect. This function MUST remove
+ result->removeProperty(CSSPropertyFontWeight);
+ }
+ }
if (baseStyle->getPropertyCSSValueInternal(CSSPropertyColor) && getRGBAFontColor(result.get()) == getRGBAFontColor(baseStyle))
result->removeProperty(CSSPropertyColor);
« no previous file with comments | « LayoutTests/editing/pasteboard/insert-font-weight-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698