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

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

Issue 2312293003: [CSSTypedOM] Computed StylePropertyMap use ComputedStyle for Lengths (Closed)
Patch Set: rebase Created 4 years, 2 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 "core/css/CSSCalculationValue.h" 7 #include "core/css/CSSCalculationValue.h"
8 #include "core/css/CSSPrimitiveValue.h" 8 #include "core/css/CSSPrimitiveValue.h"
9 #include "core/css/cssom/CSSCalcDictionary.h" 9 #include "core/css/cssom/CSSCalcDictionary.h"
10 #include "core/css/cssom/CSSSimpleLength.h" 10 #include "core/css/cssom/CSSSimpleLength.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 setFromDictValue(in, In, Inches) 61 setFromDictValue(in, In, Inches)
62 setFromDictValue(pc, Pc, Picas) 62 setFromDictValue(pc, Pc, Picas)
63 setFromDictValue(pt, Pt, Points) 63 setFromDictValue(pt, Pt, Points)
64 64
65 if (numSet == 0) { 65 if (numSet == 0) {
66 exceptionState.throwTypeError("Must specify at least one value in CSSCal cDictionary for creating a CSSCalcLength."); 66 exceptionState.throwTypeError("Must specify at least one value in CSSCal cDictionary for creating a CSSCalcLength.");
67 } 67 }
68 return result; 68 return result;
69 } 69 }
70 70
71 CSSCalcLength* CSSCalcLength::fromLength(const Length& length)
meade_UTC10 2016/09/27 04:41:39 [no action required] btw I'm implementing CSSCalcE
72 {
73 DCHECK(length.isCalculated());
74 PixelsAndPercent values = length.getPixelsAndPercent();
75 CSSCalcLength* result = new CSSCalcLength();
76 result->set(values.pixels, CSSPrimitiveValue::UnitType::Pixels);
77 result->set(values.percent, CSSPrimitiveValue::UnitType::Percentage);
78 return result;
79 }
80
71 bool CSSCalcLength::containsPercent() const 81 bool CSSCalcLength::containsPercent() const
72 { 82 {
73 return has(CSSPrimitiveValue::UnitType::Percentage); 83 return has(CSSPrimitiveValue::UnitType::Percentage);
74 } 84 }
75 85
76 CSSLengthValue* CSSCalcLength::addInternal(const CSSLengthValue* other) 86 CSSLengthValue* CSSCalcLength::addInternal(const CSSLengthValue* other)
77 { 87 {
78 CSSCalcLength* result = CSSCalcLength::create(other); 88 CSSCalcLength* result = CSSCalcLength::create(other);
79 for (int i = 0; i < CSSLengthValue::kNumSupportedUnits; ++i) { 89 for (int i = 0; i < CSSLengthValue::kNumSupportedUnits; ++i) {
80 if (hasAtIndex(i)) { 90 if (hasAtIndex(i)) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 } 153 }
144 return CSSPrimitiveValue::create(CSSCalcValue::create(node)); 154 return CSSPrimitiveValue::create(CSSCalcValue::create(node));
145 } 155 }
146 156
147 int CSSCalcLength::indexForUnit(CSSPrimitiveValue::UnitType unit) 157 int CSSCalcLength::indexForUnit(CSSPrimitiveValue::UnitType unit)
148 { 158 {
149 return (static_cast<int>(unit) - static_cast<int>(CSSPrimitiveValue::UnitTyp e::Percentage)); 159 return (static_cast<int>(unit) - static_cast<int>(CSSPrimitiveValue::UnitTyp e::Percentage));
150 } 160 }
151 161
152 } // namespace blink 162 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698