OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/layout/ng/geometry/ng_physical_rect.h" | 5 #include "core/layout/ng/geometry/ng_physical_rect.h" |
6 | 6 |
7 #include "wtf/text/WTFString.h" | 7 #include "platform/wtf/text/WTFString.h" |
8 | 8 |
9 namespace blink { | 9 namespace blink { |
10 | 10 |
11 NGPixelSnappedPhysicalRect NGPhysicalRect::SnapToDevicePixels() const { | 11 NGPixelSnappedPhysicalRect NGPhysicalRect::SnapToDevicePixels() const { |
12 NGPixelSnappedPhysicalRect snapped_rect; | 12 NGPixelSnappedPhysicalRect snapped_rect; |
13 snapped_rect.left = RoundToInt(location.left); | 13 snapped_rect.left = RoundToInt(location.left); |
14 snapped_rect.top = RoundToInt(location.top); | 14 snapped_rect.top = RoundToInt(location.top); |
15 snapped_rect.width = SnapSizeToPixel(size.width, location.left); | 15 snapped_rect.width = SnapSizeToPixel(size.width, location.left); |
16 snapped_rect.height = SnapSizeToPixel(size.height, location.top); | 16 snapped_rect.height = SnapSizeToPixel(size.height, location.top); |
17 | 17 |
18 return snapped_rect; | 18 return snapped_rect; |
19 } | 19 } |
20 | 20 |
21 bool NGPhysicalRect::operator==(const NGPhysicalRect& other) const { | 21 bool NGPhysicalRect::operator==(const NGPhysicalRect& other) const { |
22 return other.location == location && other.size == size; | 22 return other.location == location && other.size == size; |
23 } | 23 } |
24 | 24 |
25 String NGPhysicalRect::ToString() const { | 25 String NGPhysicalRect::ToString() const { |
26 return String::Format("%s,%s %sx%s", location.left.ToString().Ascii().Data(), | 26 return String::Format("%s,%s %sx%s", location.left.ToString().Ascii().Data(), |
27 location.top.ToString().Ascii().Data(), | 27 location.top.ToString().Ascii().Data(), |
28 size.width.ToString().Ascii().Data(), | 28 size.width.ToString().Ascii().Data(), |
29 size.height.ToString().Ascii().Data()); | 29 size.height.ToString().Ascii().Data()); |
30 } | 30 } |
31 | 31 |
32 std::ostream& operator<<(std::ostream& os, const NGPhysicalRect& value) { | 32 std::ostream& operator<<(std::ostream& os, const NGPhysicalRect& value) { |
33 return os << value.ToString(); | 33 return os << value.ToString(); |
34 } | 34 } |
35 | 35 |
36 } // namespace blink | 36 } // namespace blink |
OLD | NEW |