Chromium Code Reviews| 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/ng_units.h" | 5 #include "core/layout/ng/ng_units.h" |
| 6 | 6 |
| 7 #include "core/layout/ng/ng_writing_mode.h" | 7 #include "core/layout/ng/ng_writing_mode.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| 11 NGPhysicalSize NGLogicalSize::ConvertToPhysical(NGWritingMode mode) const { | 11 NGPhysicalSize NGLogicalSize::ConvertToPhysical(NGWritingMode mode) const { |
| 12 return mode == HorizontalTopBottom ? NGPhysicalSize(inline_size, block_size) | 12 return mode == HorizontalTopBottom ? NGPhysicalSize(inline_size, block_size) |
| 13 : NGPhysicalSize(block_size, inline_size); | 13 : NGPhysicalSize(block_size, inline_size); |
| 14 } | 14 } |
| 15 | 15 |
| 16 bool NGLogicalSize::operator==(const NGLogicalSize& other) const { | |
| 17 return std::tie(other.inline_size, other.block_size) == | |
| 18 std::tie(inline_size, block_size); | |
| 19 } | |
| 20 | |
| 16 NGLogicalSize NGPhysicalSize::ConvertToLogical(NGWritingMode mode) const { | 21 NGLogicalSize NGPhysicalSize::ConvertToLogical(NGWritingMode mode) const { |
| 17 return mode == HorizontalTopBottom ? NGLogicalSize(width, height) | 22 return mode == HorizontalTopBottom ? NGLogicalSize(width, height) |
| 18 : NGLogicalSize(height, width); | 23 : NGLogicalSize(height, width); |
| 19 } | 24 } |
| 20 | 25 |
| 26 bool NGLogicalRect::IsEmpty() const { | |
| 27 return *this == NGLogicalRect(); | |
|
Gleb Lanbin
2016/10/21 21:06:59
.nit We will need to change that later as it alloc
ikilpatrick
2016/10/21 21:45:27
added TODO
| |
| 28 } | |
| 29 | |
| 30 bool NGLogicalRect::operator==(const NGLogicalRect& other) const { | |
| 31 return std::tie(other.offset, other.size) == std::tie(offset, size); | |
| 32 } | |
| 33 | |
| 34 String NGLogicalRect::ToString() const { | |
| 35 return String::format("%s,%s %sx%s", | |
| 36 offset.inline_offset.toString().ascii().data(), | |
| 37 offset.block_offset.toString().ascii().data(), | |
| 38 size.inline_size.toString().ascii().data(), | |
| 39 size.block_size.toString().ascii().data()); | |
| 40 } | |
| 41 | |
| 21 NGPhysicalOffset NGLogicalOffset::ConvertToPhysical( | 42 NGPhysicalOffset NGLogicalOffset::ConvertToPhysical( |
| 22 NGWritingMode mode, | 43 NGWritingMode mode, |
| 23 NGDirection direction, | 44 NGDirection direction, |
| 24 NGPhysicalSize container_size, | 45 NGPhysicalSize container_size, |
| 25 NGPhysicalSize inner_size) const { | 46 NGPhysicalSize inner_size) const { |
| 26 switch (mode) { | 47 switch (mode) { |
| 27 case HorizontalTopBottom: | 48 case HorizontalTopBottom: |
| 28 if (direction == LeftToRight) | 49 if (direction == LeftToRight) |
| 29 return NGPhysicalOffset(inline_offset, block_offset); | 50 return NGPhysicalOffset(inline_offset, block_offset); |
| 30 else | 51 else |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 54 block_offset, | 75 block_offset, |
| 55 container_size.height - inline_offset - inner_size.height); | 76 container_size.height - inline_offset - inner_size.height); |
| 56 else | 77 else |
| 57 return NGPhysicalOffset(block_offset, inline_offset); | 78 return NGPhysicalOffset(block_offset, inline_offset); |
| 58 default: | 79 default: |
| 59 ASSERT_NOT_REACHED(); | 80 ASSERT_NOT_REACHED(); |
| 60 return NGPhysicalOffset(); | 81 return NGPhysicalOffset(); |
| 61 } | 82 } |
| 62 } | 83 } |
| 63 | 84 |
| 85 bool NGLogicalOffset::operator==(const NGLogicalOffset& other) const { | |
| 86 return std::tie(other.inline_offset, other.block_offset) == | |
| 87 std::tie(inline_offset, block_offset); | |
| 88 } | |
| 89 | |
| 64 bool NGBoxStrut::IsEmpty() const { | 90 bool NGBoxStrut::IsEmpty() const { |
| 65 return *this == NGBoxStrut(); | 91 return *this == NGBoxStrut(); |
| 66 } | 92 } |
| 67 | 93 |
| 68 bool NGBoxStrut::operator==(const NGBoxStrut& other) const { | 94 bool NGBoxStrut::operator==(const NGBoxStrut& other) const { |
| 69 return std::tie(other.inline_start, other.inline_end, other.block_start, | 95 return std::tie(other.inline_start, other.inline_end, other.block_start, |
| 70 other.block_end) == | 96 other.block_end) == |
| 71 std::tie(inline_start, inline_end, block_start, block_end); | 97 std::tie(inline_start, inline_end, block_start, block_end); |
| 72 } | 98 } |
| 73 | 99 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 | 148 |
| 123 bool NGMarginStrut::operator==(const NGMarginStrut& other) const { | 149 bool NGMarginStrut::operator==(const NGMarginStrut& other) const { |
| 124 return std::tie(other.margin_block_start, other.margin_block_end, | 150 return std::tie(other.margin_block_start, other.margin_block_end, |
| 125 other.negative_margin_block_start, | 151 other.negative_margin_block_start, |
| 126 other.negative_margin_block_end) == | 152 other.negative_margin_block_end) == |
| 127 std::tie(margin_block_start, margin_block_end, | 153 std::tie(margin_block_start, margin_block_end, |
| 128 negative_margin_block_start, negative_margin_block_end); | 154 negative_margin_block_start, negative_margin_block_end); |
| 129 } | 155 } |
| 130 | 156 |
| 131 } // namespace blink | 157 } // namespace blink |
| OLD | NEW |