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

Unified Diff: third_party/WebKit/Source/core/css/resolver/StyleBuilderConverter.h

Issue 2346193002: Split CSSPrimitiveValue into CSSPrimitiveValue and CSSIdentifierValue (Closed)
Patch Set: Rebase please work Created 4 years, 3 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
Index: third_party/WebKit/Source/core/css/resolver/StyleBuilderConverter.h
diff --git a/third_party/WebKit/Source/core/css/resolver/StyleBuilderConverter.h b/third_party/WebKit/Source/core/css/resolver/StyleBuilderConverter.h
index b652d4e4fdbfe71acaa925e3795f92bdca8e0c85..9734d122388d396f7f4124623a683d9017b98a3a 100644
--- a/third_party/WebKit/Source/core/css/resolver/StyleBuilderConverter.h
+++ b/third_party/WebKit/Source/core/css/resolver/StyleBuilderConverter.h
@@ -27,6 +27,7 @@
#ifndef StyleBuilderConverter_h
#define StyleBuilderConverter_h
+#include "core/css/CSSIdentifierValue.h"
#include "core/css/CSSStringValue.h"
#include "core/css/CSSValue.h"
#include "core/css/CSSValueList.h"
@@ -136,37 +137,37 @@ template <typename T>
T StyleBuilderConverter::convertFlags(StyleResolverState& state, const CSSValue& value)
{
T flags = static_cast<T>(0);
- if (value.isPrimitiveValue() && toCSSPrimitiveValue(value).getValueID() == CSSValueNone)
+ if (value.isIdentifierValue() && toCSSIdentifierValue(value).getValueID() == CSSValueNone)
return flags;
for (auto& flagValue : toCSSValueList(value))
- flags |= toCSSPrimitiveValue(*flagValue).convertTo<T>();
+ flags |= toCSSIdentifierValue(*flagValue).convertTo<T>();
return flags;
}
template <typename T>
T StyleBuilderConverter::convertLineWidth(StyleResolverState& state, const CSSValue& value)
{
- const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
- CSSValueID valueID = primitiveValue.getValueID();
- if (valueID == CSSValueThin)
- return 1;
- if (valueID == CSSValueMedium)
- return 3;
- if (valueID == CSSValueThick)
- return 5;
- if (valueID == CSSValueInvalid) {
- // FIXME: We are moving to use the full page zoom implementation to handle high-dpi.
- // In that case specyfing a border-width of less than 1px would result in a border that is one device pixel thick.
- // With this change that would instead be rounded up to 2 device pixels.
- // Consider clamping it to device pixels or zoom adjusted CSS pixels instead of raw CSS pixels.
- // Reference crbug.com/485650 and crbug.com/382483
- double result = primitiveValue.computeLength<double>(state.cssToLengthConversionData());
- if (result > 0.0 && result < 1.0)
- return 1.0;
- return clampTo<T>(roundForImpreciseConversion<T>(result), defaultMinimumForClamp<T>(), defaultMaximumForClamp<T>());
+ if (value.isIdentifierValue()) {
+ CSSValueID valueID = toCSSIdentifierValue(value).getValueID();
+ if (valueID == CSSValueThin)
+ return 1;
+ if (valueID == CSSValueMedium)
+ return 3;
+ if (valueID == CSSValueThick)
+ return 5;
+ NOTREACHED();
+ return 0;
}
- ASSERT_NOT_REACHED();
- return 0;
+ const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
+ // FIXME: We are moving to use the full page zoom implementation to handle high-dpi.
+ // In that case specyfing a border-width of less than 1px would result in a border that is one device pixel thick.
+ // With this change that would instead be rounded up to 2 device pixels.
+ // Consider clamping it to device pixels or zoom adjusted CSS pixels instead of raw CSS pixels.
+ // Reference crbug.com/485650 and crbug.com/382483
+ double result = primitiveValue.computeLength<double>(state.cssToLengthConversionData());
+ if (result > 0.0 && result < 1.0)
+ return 1.0;
+ return clampTo<T>(roundForImpreciseConversion<T>(result), defaultMinimumForClamp<T>(), defaultMaximumForClamp<T>());
}
template <CSSValueID IdForNone>
@@ -174,7 +175,7 @@ AtomicString StyleBuilderConverter::convertString(StyleResolverState&, const CSS
{
if (value.isStringValue())
return AtomicString(toCSSStringValue(value).value());
- ASSERT(toCSSPrimitiveValue(value).getValueID() == IdForNone);
+ DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), IdForNone);
return nullAtom;
}

Powered by Google App Engine
This is Rietveld 408576698