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

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

Issue 342883004: Using Enum in place of bool for better code readability (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Comment fixes Created 6 years, 6 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/core/editing/EditingStyle.h ('k') | Source/platform/blink_platform.gypi » ('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 c0fdd1fb75bf2c76455952fe50cd93c9095a3841..43fc4d481a0131b2dc89578c6f0bc8347669bf47 100644
--- a/Source/core/editing/EditingStyle.cpp
+++ b/Source/core/editing/EditingStyle.cpp
@@ -143,7 +143,7 @@ static PassRefPtrWillBeRawPtr<MutableStylePropertySet> editingStyleFromComputedS
static PassRefPtrWillBeRawPtr<MutableStylePropertySet> getPropertiesNotIn(StylePropertySet* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle);
enum LegacyFontSizeMode { AlwaysUseLegacyFontSize, UseLegacyFontSizeOnlyIfPixelValuesMatch };
-static int legacyFontSizeFromCSSValue(Document*, CSSPrimitiveValue*, bool shouldUseFixedFontDefaultSize, LegacyFontSizeMode);
+static int legacyFontSizeFromCSSValue(Document*, CSSPrimitiveValue*, FixedPitchFontType, LegacyFontSizeMode);
static bool isTransparentColorValue(CSSValue*);
static bool hasTransparentBackgroundColor(CSSStyleDeclaration*);
static bool hasTransparentBackgroundColor(StylePropertySet*);
@@ -342,20 +342,20 @@ PassRefPtrWillBeRawPtr<CSSValue> HTMLFontSizeEquivalent::attributeValueAsCSSValu
float EditingStyle::NoFontDelta = 0.0f;
EditingStyle::EditingStyle()
- : m_shouldUseFixedDefaultFontSize(false)
+ : m_fixedPitchFontType(NonFixedPitchFont)
, m_fontSizeDelta(NoFontDelta)
{
}
EditingStyle::EditingStyle(Node* node, PropertiesToInclude propertiesToInclude)
- : m_shouldUseFixedDefaultFontSize(false)
+ : m_fixedPitchFontType(NonFixedPitchFont)
, m_fontSizeDelta(NoFontDelta)
{
init(node, propertiesToInclude);
}
EditingStyle::EditingStyle(const Position& position, PropertiesToInclude propertiesToInclude)
- : m_shouldUseFixedDefaultFontSize(false)
+ : m_fixedPitchFontType(NonFixedPitchFont)
, m_fontSizeDelta(NoFontDelta)
{
init(position.deprecatedNode(), propertiesToInclude);
@@ -363,7 +363,7 @@ EditingStyle::EditingStyle(const Position& position, PropertiesToInclude propert
EditingStyle::EditingStyle(const StylePropertySet* style)
: m_mutableStyle(style ? style->mutableCopy() : nullptr)
- , m_shouldUseFixedDefaultFontSize(false)
+ , m_fixedPitchFontType(NonFixedPitchFont)
, m_fontSizeDelta(NoFontDelta)
{
extractFontSizeDelta();
@@ -371,7 +371,7 @@ EditingStyle::EditingStyle(const StylePropertySet* style)
EditingStyle::EditingStyle(CSSPropertyID propertyID, const String& value)
: m_mutableStyle(nullptr)
- , m_shouldUseFixedDefaultFontSize(false)
+ , m_fixedPitchFontType(NonFixedPitchFont)
, m_fontSizeDelta(NoFontDelta)
{
setProperty(propertyID, value);
@@ -471,7 +471,7 @@ void EditingStyle::init(Node* node, PropertiesToInclude propertiesToInclude)
replaceFontSizeByKeywordIfPossible(renderStyle, computedStyleAtPosition.get());
}
- m_shouldUseFixedDefaultFontSize = computedStyleAtPosition->useFixedFontDefaultSize();
+ m_fixedPitchFontType = computedStyleAtPosition->fixedPitchFontType();
extractFontSizeDelta();
}
@@ -574,7 +574,7 @@ void EditingStyle::overrideWithStyle(const StylePropertySet* style)
void EditingStyle::clear()
{
m_mutableStyle.clear();
- m_shouldUseFixedDefaultFontSize = false;
+ m_fixedPitchFontType = NonFixedPitchFont;
m_fontSizeDelta = NoFontDelta;
}
@@ -583,7 +583,7 @@ PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::copy() const
RefPtrWillBeRawPtr<EditingStyle> copy = EditingStyle::create();
if (m_mutableStyle)
copy->m_mutableStyle = m_mutableStyle->mutableCopy();
- copy->m_shouldUseFixedDefaultFontSize = m_shouldUseFixedDefaultFontSize;
+ copy->m_fixedPitchFontType = m_fixedPitchFontType;
copy->m_fontSizeDelta = m_fontSizeDelta;
return copy;
}
@@ -1246,7 +1246,7 @@ int EditingStyle::legacyFontSize(Document* document) const
if (!cssValue || !cssValue->isPrimitiveValue())
return 0;
return legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(cssValue.get()),
- m_shouldUseFixedDefaultFontSize, AlwaysUseLegacyFontSize);
+ m_fixedPitchFontType, AlwaysUseLegacyFontSize);
}
PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::styleAtSelectionStart(const VisibleSelection& selection, bool shouldUseBackgroundColorInEffect)
@@ -1409,7 +1409,7 @@ StyleChange::StyleChange(EditingStyle* style, const Position& position)
reconcileTextDecorationProperties(mutableStyle.get());
if (!document->frame()->editor().shouldStyleWithCSS())
- extractTextStyles(document, mutableStyle.get(), computedStyle->useFixedFontDefaultSize());
+ extractTextStyles(document, mutableStyle.get(), computedStyle->fixedPitchFontType());
// Changing the whitespace style in a tab span would collapse the tab into a space.
if (isTabSpanTextNode(position.deprecatedNode()) || isTabSpanNode((position.deprecatedNode())))
@@ -1434,7 +1434,7 @@ static void setTextDecorationProperty(MutableStylePropertySet* style, const CSSV
}
}
-void StyleChange::extractTextStyles(Document* document, MutableStylePropertySet* style, bool shouldUseFixedFontDefaultSize)
+void StyleChange::extractTextStyles(Document* document, MutableStylePropertySet* style, FixedPitchFontType fixedPitchFontType)
{
ASSERT(style);
@@ -1493,10 +1493,9 @@ void StyleChange::extractTextStyles(Document* document, MutableStylePropertySet*
style->removeProperty(CSSPropertyFontFamily);
if (RefPtrWillBeRawPtr<CSSValue> fontSize = style->getPropertyCSSValue(CSSPropertyFontSize)) {
- if (!fontSize->isPrimitiveValue())
+ 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()),
- shouldUseFixedFontDefaultSize, UseLegacyFontSizeOnlyIfPixelValuesMatch)) {
+ } else if (int legacyFontSize = legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(fontSize.get()), fixedPitchFontType, UseLegacyFontSizeOnlyIfPixelValuesMatch)) {
m_applyFontSize = String::number(legacyFontSize);
style->removeProperty(CSSPropertyFontSize);
}
@@ -1613,14 +1612,14 @@ static bool isCSSValueLength(CSSPrimitiveValue* value)
return value->isFontIndependentLength();
}
-int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, bool shouldUseFixedFontDefaultSize, LegacyFontSizeMode mode)
+int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, FixedPitchFontType fixedPitchFontType, LegacyFontSizeMode mode)
{
if (isCSSValueLength(value)) {
int pixelFontSize = value->getIntValue(CSSPrimitiveValue::CSS_PX);
- int legacyFontSize = FontSize::legacyFontSize(document, pixelFontSize, shouldUseFixedFontDefaultSize);
+ int legacyFontSize = FontSize::legacyFontSize(document, pixelFontSize, fixedPitchFontType);
// Use legacy font size only if pixel value matches exactly to that of legacy font size.
- int cssPrimitiveEquivalent = legacyFontSize - 1 + CSSValueXSmall;
- if (mode == AlwaysUseLegacyFontSize || FontSize::fontSizeForKeyword(document, cssPrimitiveEquivalent, shouldUseFixedFontDefaultSize) == pixelFontSize)
+ CSSValueID cssPrimitiveEquivalent = static_cast<CSSValueID>(legacyFontSize - 1 + CSSValueXSmall);
+ if (mode == AlwaysUseLegacyFontSize || FontSize::fontSizeForKeyword(document, cssPrimitiveEquivalent, fixedPitchFontType) == pixelFontSize)
return legacyFontSize;
return 0;
« no previous file with comments | « Source/core/editing/EditingStyle.h ('k') | Source/platform/blink_platform.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698