| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/css/cssom/CSSCalcLength.h" | 5 #include "core/css/cssom/CSSCalcLength.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "core/css/CSSCalculationValue.h" | 8 #include "core/css/CSSCalculationValue.h" |
| 9 #include "core/css/CSSPrimitiveValue.h" | 9 #include "core/css/CSSPrimitiveValue.h" |
| 10 #include "core/css/cssom/CSSCalcDictionary.h" | 10 #include "core/css/cssom/CSSCalcDictionary.h" |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 216 |
| 217 CSSCalcExpressionNode* CSSCalcLength::UnitData::toCSSCalcExpressionNode() | 217 CSSCalcExpressionNode* CSSCalcLength::UnitData::toCSSCalcExpressionNode() |
| 218 const { | 218 const { |
| 219 CSSCalcExpressionNode* node = nullptr; | 219 CSSCalcExpressionNode* node = nullptr; |
| 220 for (unsigned i = 0; i < CSSLengthValue::kNumSupportedUnits; ++i) { | 220 for (unsigned i = 0; i < CSSLengthValue::kNumSupportedUnits; ++i) { |
| 221 if (!hasAtIndex(i)) | 221 if (!hasAtIndex(i)) |
| 222 continue; | 222 continue; |
| 223 double value = getAtIndex(i); | 223 double value = getAtIndex(i); |
| 224 if (node) { | 224 if (node) { |
| 225 node = CSSCalcValue::createExpressionNode( | 225 node = CSSCalcValue::createExpressionNode( |
| 226 node, CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create( | 226 node, |
| 227 std::abs(value), unitFromIndex(i))), | 227 CSSCalcValue::createExpressionNode( |
| 228 CSSPrimitiveValue::create(std::abs(value), unitFromIndex(i))), |
| 228 value >= 0 ? CalcAdd : CalcSubtract); | 229 value >= 0 ? CalcAdd : CalcSubtract); |
| 229 } else { | 230 } else { |
| 230 node = CSSCalcValue::createExpressionNode( | 231 node = CSSCalcValue::createExpressionNode( |
| 231 CSSPrimitiveValue::create(value, unitFromIndex(i))); | 232 CSSPrimitiveValue::create(value, unitFromIndex(i))); |
| 232 } | 233 } |
| 233 } | 234 } |
| 234 return node; | 235 return node; |
| 235 } | 236 } |
| 236 | 237 |
| 237 bool CSSCalcLength::UnitData::hasAtIndex(int i) const { | 238 bool CSSCalcLength::UnitData::hasAtIndex(int i) const { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 void CSSCalcLength::UnitData::divide(double x) { | 294 void CSSCalcLength::UnitData::divide(double x) { |
| 294 DCHECK_NE(x, 0); | 295 DCHECK_NE(x, 0); |
| 295 for (int i = 0; i < CSSLengthValue::kNumSupportedUnits; ++i) { | 296 for (int i = 0; i < CSSLengthValue::kNumSupportedUnits; ++i) { |
| 296 if (hasAtIndex(i)) { | 297 if (hasAtIndex(i)) { |
| 297 setAtIndex(i, getAtIndex(i) / x); | 298 setAtIndex(i, getAtIndex(i) / x); |
| 298 } | 299 } |
| 299 } | 300 } |
| 300 } | 301 } |
| 301 | 302 |
| 302 } // namespace blink | 303 } // namespace blink |
| OLD | NEW |