| 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 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 127 |
| 128 bool NGLogicalOffset::operator<=(const NGLogicalOffset& other) const { | 128 bool NGLogicalOffset::operator<=(const NGLogicalOffset& other) const { |
| 129 return inline_offset <= other.inline_offset && | 129 return inline_offset <= other.inline_offset && |
| 130 block_offset <= other.block_offset; | 130 block_offset <= other.block_offset; |
| 131 } | 131 } |
| 132 | 132 |
| 133 String NGLogicalOffset::ToString() const { | 133 String NGLogicalOffset::ToString() const { |
| 134 return String::format("%dx%d", inline_offset.toInt(), block_offset.toInt()); | 134 return String::format("%dx%d", inline_offset.toInt(), block_offset.toInt()); |
| 135 } | 135 } |
| 136 | 136 |
| 137 NGPhysicalOffset NGPhysicalOffset::operator+( |
| 138 const NGPhysicalOffset& other) const { |
| 139 return NGPhysicalOffset{this->left + other.left, this->top + other.top}; |
| 140 } |
| 141 |
| 142 NGPhysicalOffset& NGPhysicalOffset::operator+=(const NGPhysicalOffset& other) { |
| 143 *this = *this + other; |
| 144 return *this; |
| 145 } |
| 146 |
| 137 bool NGBoxStrut::IsEmpty() const { | 147 bool NGBoxStrut::IsEmpty() const { |
| 138 return *this == NGBoxStrut(); | 148 return *this == NGBoxStrut(); |
| 139 } | 149 } |
| 140 | 150 |
| 141 bool NGBoxStrut::operator==(const NGBoxStrut& other) const { | 151 bool NGBoxStrut::operator==(const NGBoxStrut& other) const { |
| 142 return std::tie(other.inline_start, other.inline_end, other.block_start, | 152 return std::tie(other.inline_start, other.inline_end, other.block_start, |
| 143 other.block_end) == | 153 other.block_end) == |
| 144 std::tie(inline_start, inline_end, block_start, block_end); | 154 std::tie(inline_start, inline_end, block_start, block_end); |
| 145 } | 155 } |
| 146 | 156 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 } | 229 } |
| 220 | 230 |
| 221 bool NGMarginStrut::operator==(const NGMarginStrut& other) const { | 231 bool NGMarginStrut::operator==(const NGMarginStrut& other) const { |
| 222 return std::tie(other.margin_block_start, other.margin_block_end, | 232 return std::tie(other.margin_block_start, other.margin_block_end, |
| 223 other.negative_margin_block_start, | 233 other.negative_margin_block_start, |
| 224 other.negative_margin_block_end) == | 234 other.negative_margin_block_end) == |
| 225 std::tie(margin_block_start, margin_block_end, | 235 std::tie(margin_block_start, margin_block_end, |
| 226 negative_margin_block_start, negative_margin_block_end); | 236 negative_margin_block_start, negative_margin_block_end); |
| 227 } | 237 } |
| 228 | 238 |
| 239 NGStaticPosition NGStaticPosition::Create(NGWritingMode writing_mode, |
| 240 TextDirection direction, |
| 241 NGPhysicalOffset offset) { |
| 242 NGStaticPosition position; |
| 243 position.offset = offset; |
| 244 switch (writing_mode) { |
| 245 case kHorizontalTopBottom: |
| 246 position.type = (direction == LTR) ? kTopLeft : kTopRight; |
| 247 break; |
| 248 case kVerticalRightLeft: |
| 249 case kSidewaysRightLeft: |
| 250 position.type = (direction == LTR) ? kTopRight : kBottomRight; |
| 251 break; |
| 252 case kVerticalLeftRight: |
| 253 position.type = (direction == LTR) ? kTopLeft : kBottomLeft; |
| 254 break; |
| 255 case kSidewaysLeftRight: |
| 256 position.type = (direction == LTR) ? kBottomLeft : kTopLeft; |
| 257 break; |
| 258 } |
| 259 return position; |
| 260 } |
| 261 |
| 229 } // namespace blink | 262 } // namespace blink |
| OLD | NEW |