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

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

Issue 1642473002: Revert "Update StyleValue.cssString() to use existing methods instead of rolling our… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make sure it compiles Created 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/SimpleLength.h" 5 #include "core/css/cssom/SimpleLength.h"
6 6
7 #include "core/css/CSSPrimitiveValue.h" 7 #include "core/css/CSSPrimitiveValue.h"
8 #include "core/css/cssom/StyleCalcLength.h" 8 #include "core/css/cssom/StyleCalcLength.h"
9 #include "wtf/text/StringBuilder.h" 9 #include "wtf/text/StringBuilder.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 String SimpleLength::cssString() const
14 {
15 StringBuilder s;
16 s.appendNumber(m_value);
17 s.append(unit());
18 return s.toString();
19 }
20
13 PassRefPtrWillBeRawPtr<CSSValue> SimpleLength::toCSSValue() const 21 PassRefPtrWillBeRawPtr<CSSValue> SimpleLength::toCSSValue() const
14 { 22 {
15 return cssValuePool().createValue(m_value, LengthValue::lengthTypeToPrimitiv eType(m_unit)); 23 // TODO: Don't re-parse the unit.
24 return cssValuePool().createValue(m_value, CSSPrimitiveValue::fromName(unit( )));
16 } 25 }
17 26
18 LengthValue* SimpleLength::addInternal(const LengthValue* other, ExceptionState& exceptionState) 27 LengthValue* SimpleLength::addInternal(const LengthValue* other, ExceptionState& exceptionState)
19 { 28 {
20 const SimpleLength* o = toSimpleLength(other); 29 const SimpleLength* o = toSimpleLength(other);
21 if (m_unit == o->m_unit) 30 if (m_unit == o->m_unit)
22 return create(m_value + o->value(), m_unit); 31 return create(m_value + o->value(), m_unit);
23 32
24 // Different units resolve to a calc. 33 // Different units resolve to a calc.
25 StyleCalcLength* result = StyleCalcLength::create(this, exceptionState); 34 StyleCalcLength* result = StyleCalcLength::create(this, exceptionState);
(...skipping 15 matching lines...) Expand all
41 { 50 {
42 return create(m_value * x, m_unit); 51 return create(m_value * x, m_unit);
43 } 52 }
44 53
45 LengthValue* SimpleLength::divideInternal(double x, ExceptionState& exceptionSta te) 54 LengthValue* SimpleLength::divideInternal(double x, ExceptionState& exceptionSta te)
46 { 55 {
47 return create(m_value / x, m_unit); 56 return create(m_value / x, m_unit);
48 } 57 }
49 58
50 } // namespace blink 59 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/cssom/SimpleLength.h ('k') | third_party/WebKit/Source/core/css/cssom/StyleCalcLength.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698