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 LineLayoutUnit { |
leviw_travelin_and_unemployed
2014/11/12 21:27:45
This may be easier if you create 2 separate classe
hartmanng
2014/11/13 16:08:26
Done.
I did go with the hideous LayoutUnitLineLay
| |
18 using FloatPointWillBeLayoutPoint = LayoutPoint; | 21 public: |
19 using FloatRectWillBeLayoutRect = LayoutRect; | 22 #if ENABLE(LAYOUT_UNIT_IN_INLINE_BOXES) |
20 using FloatSizeWillBeLayoutSize = LayoutSize; | 23 LineLayoutUnit(LayoutUnit f) : m_data(f) { } |
24 #else // ENABLE(LAYOUT_UNIT_IN_INLINE_BOXES) | |
25 LineLayoutUnit(float f) : m_data(f) { } | |
26 #endif // ENABLE(LAYOUT_UNIT_IN_INLINE_BOXES) | |
21 | 27 |
22 #define ZERO_LAYOUT_UNIT LayoutUnit(0) | 28 float toFloat() const |
23 #define MINUS_ONE_LAYOUT_UNIT LayoutUnit(-1) | 29 { |
30 #if ENABLE(LAYOUT_UNIT_IN_INLINE_BOXES) | |
31 return m_data.toFloat(); | |
32 #else // ENABLE(LAYOUT_UNIT_IN_INLINE_BOXES) | |
33 return m_data; | |
34 #endif // ENABLE(LAYOUT_UNIT_IN_INLINE_BOXES) | |
35 } | |
24 | 36 |
25 #define LAYOUT_UNIT_TO_FLOAT(layoutUnit) (layoutUnit) | 37 LayoutUnit toLayoutUnit() const |
26 #define LAYOUT_UNIT_CEIL(layoutUnit) (layoutUnit.ceil()) | 38 { |
27 #define INT_TO_LAYOUT_UNIT(i) (LayoutUnit(i)) | 39 #if ENABLE(LAYOUT_UNIT_IN_INLINE_BOXES) |
40 return m_data; | |
41 #else // ENABLE(LAYOUT_UNIT_IN_INLINE_BOXES) | |
42 return LayoutUnit(m_data); | |
43 #endif // ENABLE(LAYOUT_UNIT_IN_INLINE_BOXES) | |
44 } | |
28 | 45 |
46 public: | |
47 #if ENABLE(LAYOUT_UNIT_IN_INLINE_BOXES) | |
48 LayoutUnit m_data; | |
29 #else // ENABLE(LAYOUT_UNIT_IN_INLINE_BOXES) | 49 #else // ENABLE(LAYOUT_UNIT_IN_INLINE_BOXES) |
30 | 50 float m_data; |
31 class FloatPoint; | 51 #endif // ENABLE(LAYOUT_UNIT_IN_INLINE_BOXES) |
32 class FloatRect; | 52 }; |
33 class FloatSize; | |
34 | 53 |
35 using FloatWillBeLayoutUnit = float; | 54 using FloatWillBeLayoutUnit = float; |
36 using FloatPointWillBeLayoutPoint = FloatPoint; | 55 using FloatPointWillBeLayoutPoint = FloatPoint; |
37 using FloatRectWillBeLayoutRect = FloatRect; | 56 using FloatRectWillBeLayoutRect = FloatRect; |
38 using FloatSizeWillBeLayoutSize = FloatSize; | 57 using FloatSizeWillBeLayoutSize = FloatSize; |
39 | 58 |
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 | 59 } // namespace blink |
50 | 60 |
51 #endif // FloatToLayoutUnit_h | 61 #endif // FloatToLayoutUnit_h |
OLD | NEW |