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

Unified Diff: third_party/WebKit/Source/core/css/cssom/StyleCalcLength.cpp

Issue 1602843003: Update StyleValue.cssString() to use existing methods instead of rolling our own. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revert TransformValue.html Created 4 years, 11 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/cssom/StyleCalcLength.cpp
diff --git a/third_party/WebKit/Source/core/css/cssom/StyleCalcLength.cpp b/third_party/WebKit/Source/core/css/cssom/StyleCalcLength.cpp
index 45b75ef53d0d75f7f5af3ca9771732ec3723aae7..a66b6e73e95c21efc727343971b6e241b4b1ecf7 100644
--- a/third_party/WebKit/Source/core/css/cssom/StyleCalcLength.cpp
+++ b/third_party/WebKit/Source/core/css/cssom/StyleCalcLength.cpp
@@ -124,29 +124,6 @@ LengthValue* StyleCalcLength::divideInternal(double x, ExceptionState& exception
return result;
}
-String StyleCalcLength::cssString() const
-{
- StringBuilder builder;
- builder.appendLiteral("calc(");
- for (unsigned i = 0; i < LengthUnit::Count; ++i) {
- LengthUnit lengthUnit = static_cast<LengthUnit>(i);
- if (has(lengthUnit)) {
- double value = get(lengthUnit);
- if (value >= 0 && i > 0) {
- builder.appendLiteral(" + ");
- } else if (value < 0 && i > 0) {
- builder.appendLiteral(" - ");
- } else if (value < 0) {
- builder.append('-');
- }
- builder.appendNumber(std::abs(get(lengthUnit)));
- builder.append(lengthTypeToString(lengthUnit));
- }
- }
- builder.append(')');
- return builder.toString();
-}
-
PassRefPtrWillBeRawPtr<CSSValue> StyleCalcLength::toCSSValue() const
{
// Create a CSS Calc Value, then put it into a CSSPrimitiveValue
@@ -154,20 +131,14 @@ PassRefPtrWillBeRawPtr<CSSValue> StyleCalcLength::toCSSValue() const
for (unsigned i = 0; i < LengthUnit::Count; ++i) {
LengthUnit lengthUnit = static_cast<LengthUnit>(i);
if (!has(lengthUnit))
- break;
+ continue;
double value = get(lengthUnit);
- CSSPrimitiveValue::UnitType primitiveUnit;
- if (lengthUnit == LengthUnit::Percent) {
- primitiveUnit = CSSPrimitiveValue::UnitType::Percentage;
- } else {
- // TODO: Don't re-parse the unit here.
- primitiveUnit = CSSPrimitiveValue::fromName(lengthTypeToString(lengthUnit));
- }
+ CSSPrimitiveValue::UnitType primitiveUnit = lengthTypeToPrimitiveType(lengthUnit);
if (node) {
node = CSSCalcValue::createExpressionNode(
node,
- CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(value, primitiveUnit)),
- CalcAdd);
+ CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(std::abs(value), primitiveUnit)),
+ value >= 0 ? CalcAdd : CalcSubtract);
} else {
node = CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(value, primitiveUnit));
}
« no previous file with comments | « third_party/WebKit/Source/core/css/cssom/StyleCalcLength.h ('k') | third_party/WebKit/Source/core/css/cssom/StyleValue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698