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

Side by Side Diff: third_party/WebKit/Source/core/css/cssom/CSSCalcLength.cpp

Issue 2403423002: [CSSTypedOM] Computed StylePropertyMap use ComputedStyle for Lengths (Closed)
Patch Set: Use StyleValueFactory & ComputedStyleCSSValueMapping for unsupported Created 3 years, 10 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 unified diff | Download patch
OLDNEW
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 83 }
84 84
85 CSSCalcLength* CSSCalcLength::fromCSSValue(const CSSPrimitiveValue& value) { 85 CSSCalcLength* CSSCalcLength::fromCSSValue(const CSSPrimitiveValue& value) {
86 std::unique_ptr<UnitData> unitData = 86 std::unique_ptr<UnitData> unitData =
87 UnitData::fromExpressionNode(value.cssCalcValue()->expressionNode()); 87 UnitData::fromExpressionNode(value.cssCalcValue()->expressionNode());
88 if (unitData) 88 if (unitData)
89 return new CSSCalcLength(*unitData); 89 return new CSSCalcLength(*unitData);
90 return nullptr; 90 return nullptr;
91 } 91 }
92 92
93 CSSCalcLength* CSSCalcLength::fromLength(const Length& length) {
94 DCHECK(length.isCalculated());
95 PixelsAndPercent values = length.getPixelsAndPercent();
96 UnitData unitData;
97 unitData.set(CSSPrimitiveValue::UnitType::Pixels, values.pixels);
98 unitData.set(CSSPrimitiveValue::UnitType::Percentage, values.percent);
99 CSSCalcLength* result = new CSSCalcLength(unitData);
100 return result;
101 }
102
93 bool CSSCalcLength::containsPercent() const { 103 bool CSSCalcLength::containsPercent() const {
94 return m_unitData.has(CSSPrimitiveValue::UnitType::Percentage); 104 return m_unitData.has(CSSPrimitiveValue::UnitType::Percentage);
95 } 105 }
96 106
97 CSSLengthValue* CSSCalcLength::addInternal(const CSSLengthValue* other) { 107 CSSLengthValue* CSSCalcLength::addInternal(const CSSLengthValue* other) {
98 UnitData result = m_unitData; 108 UnitData result = m_unitData;
99 if (other->type() == SimpleLengthType) { 109 if (other->type() == SimpleLengthType) {
100 const CSSSimpleLength* simpleLength = toCSSSimpleLength(other); 110 const CSSSimpleLength* simpleLength = toCSSSimpleLength(other);
101 result.set( 111 result.set(
102 simpleLength->lengthUnit(), 112 simpleLength->lengthUnit(),
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 void CSSCalcLength::UnitData::divide(double x) { 293 void CSSCalcLength::UnitData::divide(double x) {
284 DCHECK_NE(x, 0); 294 DCHECK_NE(x, 0);
285 for (int i = 0; i < CSSLengthValue::kNumSupportedUnits; ++i) { 295 for (int i = 0; i < CSSLengthValue::kNumSupportedUnits; ++i) {
286 if (hasAtIndex(i)) { 296 if (hasAtIndex(i)) {
287 setAtIndex(i, getAtIndex(i) / x); 297 setAtIndex(i, getAtIndex(i) / x);
288 } 298 }
289 } 299 }
290 } 300 }
291 301
292 } // namespace blink 302 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/cssom/CSSCalcLength.h ('k') | third_party/WebKit/Source/core/css/cssom/CSSKeywordValue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698