OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012, Google Inc. All rights reserved. | 2 * Copyright (c) 2012, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 AspectRatioFitShrink, | 44 AspectRatioFitShrink, |
45 AspectRatioFitGrow | 45 AspectRatioFitGrow |
46 }; | 46 }; |
47 | 47 |
48 class LayoutSize { | 48 class LayoutSize { |
49 DISALLOW_NEW(); | 49 DISALLOW_NEW(); |
50 public: | 50 public: |
51 LayoutSize() { } | 51 LayoutSize() { } |
52 explicit LayoutSize(const IntSize& size) : m_width(size.width()), m_height(s
ize.height()) { } | 52 explicit LayoutSize(const IntSize& size) : m_width(size.width()), m_height(s
ize.height()) { } |
53 LayoutSize(LayoutUnit width, LayoutUnit height) : m_width(width), m_height(h
eight) { } | 53 LayoutSize(LayoutUnit width, LayoutUnit height) : m_width(width), m_height(h
eight) { } |
| 54 LayoutSize(int width, int height) : m_width(LayoutUnit(width)), m_height(Lay
outUnit(height)) { } |
| 55 LayoutSize(float width, float height) : m_width(LayoutUnit(width)), m_height
(LayoutUnit(height)) { } |
54 | 56 |
55 explicit LayoutSize(const FloatSize& size) : m_width(size.width()), m_height
(size.height()) { } | 57 explicit LayoutSize(const FloatSize& size) : m_width(size.width()), m_height
(size.height()) { } |
56 explicit LayoutSize(const DoubleSize& size) : m_width(size.width()), m_heigh
t(size.height()) { } | 58 explicit LayoutSize(const DoubleSize& size) : m_width(size.width()), m_heigh
t(size.height()) { } |
57 | 59 |
58 LayoutUnit width() const { return m_width; } | 60 LayoutUnit width() const { return m_width; } |
59 LayoutUnit height() const { return m_height; } | 61 LayoutUnit height() const { return m_height; } |
60 | 62 |
61 void setWidth(LayoutUnit width) { m_width = width; } | 63 void setWidth(LayoutUnit width) { m_width = width; } |
62 void setHeight(LayoutUnit height) { m_height = height; } | 64 void setHeight(LayoutUnit height) { m_height = height; } |
63 | 65 |
64 bool isEmpty() const { return m_width.rawValue() <= 0 || m_height.rawValue()
<= 0; } | 66 bool isEmpty() const { return m_width.rawValue() <= 0 || m_height.rawValue()
<= 0; } |
65 bool isZero() const { return !m_width && !m_height; } | 67 bool isZero() const { return !m_width && !m_height; } |
66 | 68 |
67 float aspectRatio() const { return m_width.toFloat() / m_height.toFloat(); } | 69 float aspectRatio() const { return m_width.toFloat() / m_height.toFloat(); } |
68 | 70 |
69 void expand(LayoutUnit width, LayoutUnit height) | 71 void expand(LayoutUnit width, LayoutUnit height) |
70 { | 72 { |
71 m_width += width; | 73 m_width += width; |
72 m_height += height; | 74 m_height += height; |
73 } | 75 } |
74 | 76 |
| 77 void expand(int width, int height) { expand(LayoutUnit(width), LayoutUnit(he
ight)); } |
| 78 |
| 79 void shrink(int width, int height) { shrink(LayoutUnit(width), LayoutUnit(he
ight)); } |
| 80 |
75 void shrink(LayoutUnit width, LayoutUnit height) | 81 void shrink(LayoutUnit width, LayoutUnit height) |
76 { | 82 { |
77 m_width -= width; | 83 m_width -= width; |
78 m_height -= height; | 84 m_height -= height; |
79 } | 85 } |
80 | 86 |
81 void scale(float scale) | 87 void scale(float scale) |
82 { | 88 { |
83 m_width *= scale; | 89 m_width *= scale; |
84 m_height *= scale; | 90 m_height *= scale; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 } | 223 } |
218 | 224 |
219 inline LayoutSize roundedLayoutSize(const FloatSize& s) | 225 inline LayoutSize roundedLayoutSize(const FloatSize& s) |
220 { | 226 { |
221 return LayoutSize(s); | 227 return LayoutSize(s); |
222 } | 228 } |
223 | 229 |
224 } // namespace blink | 230 } // namespace blink |
225 | 231 |
226 #endif // LayoutSize_h | 232 #endif // LayoutSize_h |
OLD | NEW |