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

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

Issue 2011833002: Typed CSSOM: Rename CalcLength and StyleCalcLength to CSSCalcLength (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 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/CSSSimpleLength.h" 5 #include "core/css/cssom/CSSSimpleLength.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/CSSCalcLength.h"
9 #include "wtf/text/StringBuilder.h" 9 #include "wtf/text/StringBuilder.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 CSSValue* CSSSimpleLength::toCSSValue() const 13 CSSValue* CSSSimpleLength::toCSSValue() const
14 { 14 {
15 return cssValuePool().createValue(m_value, m_unit); 15 return cssValuePool().createValue(m_value, m_unit);
16 } 16 }
17 17
18 bool CSSSimpleLength::containsPercent() const 18 bool CSSSimpleLength::containsPercent() const
19 { 19 {
20 return lengthUnit() == CSSPrimitiveValue::UnitType::Percentage; 20 return lengthUnit() == CSSPrimitiveValue::UnitType::Percentage;
21 } 21 }
22 22
23 CSSLengthValue* CSSSimpleLength::addInternal(const CSSLengthValue* other, Except ionState& exceptionState) 23 CSSLengthValue* CSSSimpleLength::addInternal(const CSSLengthValue* other, Except ionState& exceptionState)
24 { 24 {
25 const CSSSimpleLength* o = toCSSSimpleLength(other); 25 const CSSSimpleLength* o = toCSSSimpleLength(other);
26 if (m_unit == o->m_unit) 26 if (m_unit == o->m_unit)
27 return create(m_value + o->value(), m_unit); 27 return create(m_value + o->value(), m_unit);
28 28
29 // Different units resolve to a calc. 29 // Different units resolve to a calc.
30 StyleCalcLength* result = StyleCalcLength::create(this, exceptionState); 30 CSSCalcLength* result = CSSCalcLength::create(this, exceptionState);
31 return result->add(other, exceptionState); 31 return result->add(other, exceptionState);
32 } 32 }
33 33
34 CSSLengthValue* CSSSimpleLength::subtractInternal(const CSSLengthValue* other, E xceptionState& exceptionState) 34 CSSLengthValue* CSSSimpleLength::subtractInternal(const CSSLengthValue* other, E xceptionState& exceptionState)
35 { 35 {
36 const CSSSimpleLength* o = toCSSSimpleLength(other); 36 const CSSSimpleLength* o = toCSSSimpleLength(other);
37 if (m_unit == o->m_unit) 37 if (m_unit == o->m_unit)
38 return create(m_value - o->value(), m_unit); 38 return create(m_value - o->value(), m_unit);
39 39
40 // Different units resolve to a calc. 40 // Different units resolve to a calc.
41 StyleCalcLength* result = StyleCalcLength::create(this, exceptionState); 41 CSSCalcLength* result = CSSCalcLength::create(this, exceptionState);
42 return result->subtract(other, exceptionState); 42 return result->subtract(other, exceptionState);
43 } 43 }
44 44
45 CSSLengthValue* CSSSimpleLength::multiplyInternal(double x, ExceptionState& exce ptionState) 45 CSSLengthValue* CSSSimpleLength::multiplyInternal(double x, ExceptionState& exce ptionState)
46 { 46 {
47 return create(m_value * x, m_unit); 47 return create(m_value * x, m_unit);
48 } 48 }
49 49
50 CSSLengthValue* CSSSimpleLength::divideInternal(double x, ExceptionState& except ionState) 50 CSSLengthValue* CSSSimpleLength::divideInternal(double x, ExceptionState& except ionState)
51 { 51 {
52 return create(m_value / x, m_unit); 52 return create(m_value / x, m_unit);
53 } 53 }
54 54
55 } // namespace blink 55 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/cssom/CSSLengthValue.cpp ('k') | third_party/WebKit/Source/core/css/cssom/CalcLength.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698