OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef FloatToLayoutUnit_h | 5 #ifndef FloatToLayoutUnit_h |
6 #define FloatToLayoutUnit_h | 6 #define FloatToLayoutUnit_h |
7 | 7 |
8 #include "platform/LayoutUnit.h" | |
9 | |
8 namespace blink { | 10 namespace blink { |
9 | 11 |
10 #if ENABLE(LAYOUT_UNIT_IN_INLINE_BOXES) | 12 class FloatPoint; |
11 | 13 class FloatRect; |
14 class FloatSize; | |
12 class LayoutUnit; | 15 class LayoutUnit; |
13 class LayoutPoint; | 16 class LayoutPoint; |
14 class LayoutRect; | 17 class LayoutRect; |
15 class LayoutSize; | 18 class LayoutSize; |
16 | 19 |
17 using FloatWillBeLayoutUnit = LayoutUnit; | 20 class FloatLineLayoutUnit { |
18 using FloatPointWillBeLayoutPoint = LayoutPoint; | 21 public: |
19 using FloatRectWillBeLayoutRect = LayoutRect; | 22 FloatLineLayoutUnit() : m_value(0) { } |
20 using FloatSizeWillBeLayoutSize = LayoutSize; | 23 FloatLineLayoutUnit(float f) : m_value(f) { } |
21 | 24 |
22 #define ZERO_LAYOUT_UNIT LayoutUnit(0) | 25 float toFloat() const |
23 #define MINUS_ONE_LAYOUT_UNIT LayoutUnit(-1) | 26 { |
27 return m_value; | |
28 } | |
24 | 29 |
25 #define LAYOUT_UNIT_TO_FLOAT(layoutUnit) (layoutUnit) | 30 LayoutUnit toLayoutUnit() const |
26 #define LAYOUT_UNIT_CEIL(layoutUnit) (layoutUnit.ceil()) | 31 { |
27 #define INT_TO_LAYOUT_UNIT(i) (LayoutUnit(i)) | 32 return LayoutUnit(m_value); |
33 } | |
28 | 34 |
35 public: | |
36 float m_value; | |
37 }; | |
38 | |
39 class LayoutUnitLineLayoutUnit { | |
40 public: | |
41 LayoutUnitLineLayoutUnit() : m_value() { } | |
leviw_travelin_and_unemployed
2014/11/13 19:51:23
Nit: I don't think you even need the m_value() par
hartmanng
2014/11/13 20:03:04
Done.
| |
42 LayoutUnitLineLayoutUnit(LayoutUnit f) : m_value(f) { } | |
43 | |
44 float toFloat() const | |
45 { | |
46 return m_value.toFloat(); | |
47 } | |
48 | |
49 LayoutUnit toLayoutUnit() const | |
50 { | |
51 return m_value; | |
52 } | |
53 | |
54 public: | |
55 LayoutUnit m_value; | |
56 }; | |
57 | |
58 #if ENABLE(LAYOUT_UNIT_IN_INLINE_BOXES) | |
59 using LineLayoutUnit = LayoutUnitLineLayoutUnit; | |
29 #else // ENABLE(LAYOUT_UNIT_IN_INLINE_BOXES) | 60 #else // ENABLE(LAYOUT_UNIT_IN_INLINE_BOXES) |
30 | 61 using LineLayoutUnit = FloatLineLayoutUnit; |
31 class FloatPoint; | 62 #endif // ENABLE(LAYOUT_UNIT_IN_INLINE_BOXES) |
32 class FloatRect; | |
33 class FloatSize; | |
34 | 63 |
35 using FloatWillBeLayoutUnit = float; | 64 using FloatWillBeLayoutUnit = float; |
36 using FloatPointWillBeLayoutPoint = FloatPoint; | 65 using FloatPointWillBeLayoutPoint = FloatPoint; |
37 using FloatRectWillBeLayoutRect = FloatRect; | 66 using FloatRectWillBeLayoutRect = FloatRect; |
38 using FloatSizeWillBeLayoutSize = FloatSize; | 67 using FloatSizeWillBeLayoutSize = FloatSize; |
39 | 68 |
40 #define ZERO_LAYOUT_UNIT 0 | |
41 #define MINUS_ONE_LAYOUT_UNIT -1 | |
42 | |
43 #define LAYOUT_UNIT_TO_FLOAT(layoutUnit) (layoutUnit.toFloat()) | |
44 #define LAYOUT_UNIT_CEIL(layoutUnit) (ceilf(layoutUnit)) | |
45 #define INT_TO_LAYOUT_UNIT(i) (i) | |
46 | |
47 #endif // ENABLE(LAYOUT_UNIT_IN_INLINE_BOXES) | |
48 | |
49 } // namespace blink | 69 } // namespace blink |
50 | 70 |
51 #endif // FloatToLayoutUnit_h | 71 #endif // FloatToLayoutUnit_h |
OLD | NEW |