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 class DoubleRect; | 44 class DoubleRect; |
45 | 45 |
46 class PLATFORM_EXPORT LayoutRect { | 46 class PLATFORM_EXPORT LayoutRect { |
47 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 47 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
48 public: | 48 public: |
49 LayoutRect() { } | 49 LayoutRect() { } |
50 LayoutRect(const LayoutPoint& location, const LayoutSize& size) | 50 LayoutRect(const LayoutPoint& location, const LayoutSize& size) |
51 : m_location(location), m_size(size) { } | 51 : m_location(location), m_size(size) { } |
52 LayoutRect(LayoutUnit x, LayoutUnit y, LayoutUnit width, LayoutUnit height) | 52 LayoutRect(LayoutUnit x, LayoutUnit y, LayoutUnit width, LayoutUnit height) |
53 : m_location(LayoutPoint(x, y)), m_size(LayoutSize(width, height)) { } | 53 : m_location(LayoutPoint(x, y)), m_size(LayoutSize(width, height)) { } |
54 LayoutRect(int x, int y, int width, int height) | |
eae
2016/02/12 01:14:59
...and here
| |
55 : m_location(LayoutPoint(x, y)), m_size(LayoutSize(width, height)) { } | |
54 LayoutRect(const FloatPoint& location, const FloatSize& size) | 56 LayoutRect(const FloatPoint& location, const FloatSize& size) |
55 : m_location(location), m_size(size) { } | 57 : m_location(location), m_size(size) { } |
56 LayoutRect(const DoublePoint& location, const DoubleSize& size) | 58 LayoutRect(const DoublePoint& location, const DoubleSize& size) |
57 : m_location(location), m_size(size) { } | 59 : m_location(location), m_size(size) { } |
58 LayoutRect(const IntPoint& location, const IntSize& size) | 60 LayoutRect(const IntPoint& location, const IntSize& size) |
59 : m_location(location), m_size(size) { } | 61 : m_location(location), m_size(size) { } |
60 explicit LayoutRect(const IntRect& rect) : m_location(rect.location()), m_si ze(rect.size()) { } | 62 explicit LayoutRect(const IntRect& rect) : m_location(rect.location()), m_si ze(rect.size()) { } |
61 | 63 |
62 explicit LayoutRect(const FloatRect&); // don't do this implicitly since it' s lossy | 64 explicit LayoutRect(const FloatRect&); // don't do this implicitly since it' s lossy |
63 explicit LayoutRect(const DoubleRect&); // don't do this implicitly since it 's lossy | 65 explicit LayoutRect(const DoubleRect&); // don't do this implicitly since it 's lossy |
(...skipping 26 matching lines...) Expand all Loading... | |
90 | 92 |
91 // NOTE: The result is rounded to integer values, and thus may be not the ex act | 93 // NOTE: The result is rounded to integer values, and thus may be not the ex act |
92 // center point. | 94 // center point. |
93 LayoutPoint center() const { return LayoutPoint(x() + width() / 2, y() + hei ght() / 2); } | 95 LayoutPoint center() const { return LayoutPoint(x() + width() / 2, y() + hei ght() / 2); } |
94 | 96 |
95 void move(const LayoutSize& size) { m_location += size; } | 97 void move(const LayoutSize& size) { m_location += size; } |
96 void move(const IntSize& size) { m_location.move(LayoutUnit(size.width()), L ayoutUnit(size.height())); } | 98 void move(const IntSize& size) { m_location.move(LayoutUnit(size.width()), L ayoutUnit(size.height())); } |
97 void moveBy(const LayoutPoint& offset) { m_location.move(offset.x(), offset. y()); } | 99 void moveBy(const LayoutPoint& offset) { m_location.move(offset.x(), offset. y()); } |
98 void moveBy(const IntPoint& offset) { m_location.move(LayoutUnit(offset.x()) , LayoutUnit(offset.y())); } | 100 void moveBy(const IntPoint& offset) { m_location.move(LayoutUnit(offset.x()) , LayoutUnit(offset.y())); } |
99 void move(LayoutUnit dx, LayoutUnit dy) { m_location.move(dx, dy); } | 101 void move(LayoutUnit dx, LayoutUnit dy) { m_location.move(dx, dy); } |
102 void move(int dx, int dy) { m_location.move(LayoutUnit(dx), LayoutUnit(dy)); } | |
100 | 103 |
101 void expand(const LayoutSize& size) { m_size += size; } | 104 void expand(const LayoutSize& size) { m_size += size; } |
102 void expand(const LayoutRectOutsets& box) | 105 void expand(const LayoutRectOutsets& box) |
103 { | 106 { |
104 m_location.move(-box.left(), -box.top()); | 107 m_location.move(-box.left(), -box.top()); |
105 m_size.expand(box.left() + box.right(), box.top() + box.bottom()); | 108 m_size.expand(box.left() + box.right(), box.top() + box.bottom()); |
106 } | 109 } |
107 void expand(LayoutUnit dw, LayoutUnit dh) { m_size.expand(dw, dh); } | 110 void expand(LayoutUnit dw, LayoutUnit dh) { m_size.expand(dw, dh); } |
108 void expandEdges(LayoutUnit top, LayoutUnit right, LayoutUnit bottom, Layout Unit left) | 111 void expandEdges(LayoutUnit top, LayoutUnit right, LayoutUnit bottom, Layout Unit left) |
109 { | 112 { |
110 m_location.move(-left, -top); | 113 m_location.move(-left, -top); |
111 m_size.expand(left + right, top + bottom); | 114 m_size.expand(left + right, top + bottom); |
112 } | 115 } |
113 void contract(const LayoutSize& size) { m_size -= size; } | 116 void contract(const LayoutSize& size) { m_size -= size; } |
114 void contract(LayoutUnit dw, LayoutUnit dh) { m_size.expand(-dw, -dh); } | 117 void contract(LayoutUnit dw, LayoutUnit dh) { m_size.expand(-dw, -dh); } |
118 void contract(int dw, int dh) { m_size.expand(-dw, -dh); } | |
115 void contractEdges(LayoutUnit top, LayoutUnit right, LayoutUnit bottom, Layo utUnit left) | 119 void contractEdges(LayoutUnit top, LayoutUnit right, LayoutUnit bottom, Layo utUnit left) |
116 { | 120 { |
117 m_location.move(left, top); | 121 m_location.move(left, top); |
118 m_size.shrink(left + right, top + bottom); | 122 m_size.shrink(left + right, top + bottom); |
119 } | 123 } |
120 | 124 |
121 void shiftXEdgeTo(LayoutUnit edge) | 125 void shiftXEdgeTo(LayoutUnit edge) |
122 { | 126 { |
123 LayoutUnit delta = edge - x(); | 127 LayoutUnit delta = edge - x(); |
124 setX(edge); | 128 setX(edge); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 { | 171 { |
168 m_location.setX(m_location.x() - dx); | 172 m_location.setX(m_location.x() - dx); |
169 m_size.setWidth(m_size.width() + dx + dx); | 173 m_size.setWidth(m_size.width() + dx + dx); |
170 } | 174 } |
171 void inflateY(LayoutUnit dy) | 175 void inflateY(LayoutUnit dy) |
172 { | 176 { |
173 m_location.setY(m_location.y() - dy); | 177 m_location.setY(m_location.y() - dy); |
174 m_size.setHeight(m_size.height() + dy + dy); | 178 m_size.setHeight(m_size.height() + dy + dy); |
175 } | 179 } |
176 void inflate(LayoutUnit d) { inflateX(d); inflateY(d); } | 180 void inflate(LayoutUnit d) { inflateX(d); inflateY(d); } |
181 void inflate(int d) { inflate(LayoutUnit(d)); } | |
177 void scale(float s); | 182 void scale(float s); |
178 void scale(float xAxisScale, float yAxisScale); | 183 void scale(float xAxisScale, float yAxisScale); |
179 | 184 |
180 LayoutRect transposedRect() const { return LayoutRect(m_location.transposedP oint(), m_size.transposedSize()); } | 185 LayoutRect transposedRect() const { return LayoutRect(m_location.transposedP oint(), m_size.transposedSize()); } |
181 | 186 |
182 static IntRect infiniteIntRect() | 187 static IntRect infiniteIntRect() |
183 { | 188 { |
184 // Due to saturated arithemetic this value is not the same as LayoutRect (IntRect(INT_MIN/2, INT_MIN/2, INT_MAX, INT_MAX)). | 189 // Due to saturated arithemetic this value is not the same as LayoutRect (IntRect(INT_MIN/2, INT_MIN/2, INT_MAX, INT_MAX)). |
185 static IntRect infiniteIntRect(LayoutRect(LayoutUnit::nearlyMin() / 2, L ayoutUnit::nearlyMin() / 2, LayoutUnit::nearlyMax(), LayoutUnit::nearlyMax())); | 190 static IntRect infiniteIntRect(LayoutRect(LayoutUnit::nearlyMin() / 2, L ayoutUnit::nearlyMin() / 2, LayoutUnit::nearlyMax(), LayoutUnit::nearlyMax())); |
186 return infiniteIntRect; | 191 return infiniteIntRect; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
256 return IntRect(roundedIntPoint(location), pixelSnappedIntSize(size, location )); | 261 return IntRect(roundedIntPoint(location), pixelSnappedIntSize(size, location )); |
257 } | 262 } |
258 | 263 |
259 // Redeclared here to avoid ODR issues. | 264 // Redeclared here to avoid ODR issues. |
260 // See platform/testing/GeometryPrinters.h. | 265 // See platform/testing/GeometryPrinters.h. |
261 void PrintTo(const LayoutRect&, std::ostream*); | 266 void PrintTo(const LayoutRect&, std::ostream*); |
262 | 267 |
263 } // namespace blink | 268 } // namespace blink |
264 | 269 |
265 #endif // LayoutRect_h | 270 #endif // LayoutRect_h |
OLD | NEW |