Chromium Code Reviews| 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" | |
|
rjwright
2016/09/29 05:34:42
Do we need this?
meade_UTC10
2016/09/29 05:53:13
Yep, it was previously included transitively throu
| |
| 7 #include "core/css/CSSCalculationValue.h" | 8 #include "core/css/CSSCalculationValue.h" |
| 8 #include "core/css/CSSPrimitiveValue.h" | 9 #include "core/css/CSSPrimitiveValue.h" |
| 9 #include "core/css/cssom/CSSCalcDictionary.h" | 10 #include "core/css/cssom/CSSCalcDictionary.h" |
| 10 #include "core/css/cssom/CSSSimpleLength.h" | 11 #include "core/css/cssom/CSSSimpleLength.h" |
| 11 #include "wtf/Vector.h" | 12 #include "wtf/Vector.h" |
| 12 | 13 |
| 13 namespace blink { | 14 namespace blink { |
| 14 | 15 |
| 15 CSSCalcLength::CSSCalcLength() : m_values(CSSLengthValue::kNumSupportedUnits), m _hasValues(CSSLengthValue::kNumSupportedUnits) {} | 16 CSSCalcLength::CSSCalcLength() : m_values(CSSLengthValue::kNumSupportedUnits), m _hasValues(CSSLengthValue::kNumSupportedUnits) {} |
| 16 | 17 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 setFromDictValue(in, In, Inches) | 62 setFromDictValue(in, In, Inches) |
| 62 setFromDictValue(pc, Pc, Picas) | 63 setFromDictValue(pc, Pc, Picas) |
| 63 setFromDictValue(pt, Pt, Points) | 64 setFromDictValue(pt, Pt, Points) |
| 64 | 65 |
| 65 if (numSet == 0) { | 66 if (numSet == 0) { |
| 66 exceptionState.throwTypeError("Must specify at least one value in CSSCal cDictionary for creating a CSSCalcLength."); | 67 exceptionState.throwTypeError("Must specify at least one value in CSSCal cDictionary for creating a CSSCalcLength."); |
| 67 } | 68 } |
| 68 return result; | 69 return result; |
| 69 } | 70 } |
| 70 | 71 |
| 72 CSSCalcLength* CSSCalcLength::fromCSSValue(const CSSPrimitiveValue&) | |
| 73 { | |
| 74 // TODO(meade): Implement. | |
| 75 return nullptr; | |
| 76 } | |
| 77 | |
| 71 bool CSSCalcLength::containsPercent() const | 78 bool CSSCalcLength::containsPercent() const |
| 72 { | 79 { |
| 73 return has(CSSPrimitiveValue::UnitType::Percentage); | 80 return has(CSSPrimitiveValue::UnitType::Percentage); |
| 74 } | 81 } |
| 75 | 82 |
| 76 CSSLengthValue* CSSCalcLength::addInternal(const CSSLengthValue* other) | 83 CSSLengthValue* CSSCalcLength::addInternal(const CSSLengthValue* other) |
| 77 { | 84 { |
| 78 CSSCalcLength* result = CSSCalcLength::create(other); | 85 CSSCalcLength* result = CSSCalcLength::create(other); |
| 79 for (int i = 0; i < CSSLengthValue::kNumSupportedUnits; ++i) { | 86 for (int i = 0; i < CSSLengthValue::kNumSupportedUnits; ++i) { |
| 80 if (hasAtIndex(i)) { | 87 if (hasAtIndex(i)) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 } | 150 } |
| 144 return CSSPrimitiveValue::create(CSSCalcValue::create(node)); | 151 return CSSPrimitiveValue::create(CSSCalcValue::create(node)); |
| 145 } | 152 } |
| 146 | 153 |
| 147 int CSSCalcLength::indexForUnit(CSSPrimitiveValue::UnitType unit) | 154 int CSSCalcLength::indexForUnit(CSSPrimitiveValue::UnitType unit) |
| 148 { | 155 { |
| 149 return (static_cast<int>(unit) - static_cast<int>(CSSPrimitiveValue::UnitTyp e::Percentage)); | 156 return (static_cast<int>(unit) - static_cast<int>(CSSPrimitiveValue::UnitTyp e::Percentage)); |
| 150 } | 157 } |
| 151 | 158 |
| 152 } // namespace blink | 159 } // namespace blink |
| OLD | NEW |