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

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

Issue 1602843003: Update StyleValue.cssString() to use existing methods instead of rolling our own. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revert TransformValue.html Created 4 years, 11 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
21 PassRefPtrWillBeRawPtr<CSSValue> SimpleLength::toCSSValue() const 13 PassRefPtrWillBeRawPtr<CSSValue> SimpleLength::toCSSValue() const
22 { 14 {
23 // TODO: Don't re-parse the unit. 15 return cssValuePool().createValue(m_value, LengthValue::lengthTypeToPrimitiv eType(m_unit));
24 return cssValuePool().createValue(m_value, CSSPrimitiveValue::fromName(unit( )));
25 } 16 }
26 17
27 LengthValue* SimpleLength::addInternal(const LengthValue* other, ExceptionState& exceptionState) 18 LengthValue* SimpleLength::addInternal(const LengthValue* other, ExceptionState& exceptionState)
28 { 19 {
29 const SimpleLength* o = toSimpleLength(other); 20 const SimpleLength* o = toSimpleLength(other);
30 if (m_unit == o->m_unit) 21 if (m_unit == o->m_unit)
31 return create(m_value + o->value(), m_unit); 22 return create(m_value + o->value(), m_unit);
32 23
33 // Different units resolve to a calc. 24 // Different units resolve to a calc.
34 StyleCalcLength* result = StyleCalcLength::create(this, exceptionState); 25 StyleCalcLength* result = StyleCalcLength::create(this, exceptionState);
(...skipping 15 matching lines...) Expand all
50 { 41 {
51 return create(m_value * x, m_unit); 42 return create(m_value * x, m_unit);
52 } 43 }
53 44
54 LengthValue* SimpleLength::divideInternal(double x, ExceptionState& exceptionSta te) 45 LengthValue* SimpleLength::divideInternal(double x, ExceptionState& exceptionSta te)
55 { 46 {
56 return create(m_value / x, m_unit); 47 return create(m_value / x, m_unit);
57 } 48 }
58 49
59 } // namespace blink 50 } // 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