OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "core/layout/ng/ng_units.h" |
| 6 |
| 7 #include "core/layout/ng/ng_writing_mode.h" |
| 8 |
| 9 namespace blink { |
| 10 |
| 11 NGPhysicalSize NGLogicalSize::ConvertToPhysical(NGWritingMode mode) const { |
| 12 return mode == HorizontalTopBottom ? NGPhysicalSize(inline_size, block_size) |
| 13 : NGPhysicalSize(block_size, inline_size); |
| 14 } |
| 15 |
| 16 NGLogicalSize NGPhysicalSize::ConvertToLogical(NGWritingMode mode) const { |
| 17 return mode == HorizontalTopBottom ? NGLogicalSize(width, height) |
| 18 : NGLogicalSize(height, width); |
| 19 } |
| 20 |
| 21 NGPhysicalOffset NGLogicalOffset::ConvertToPhysical( |
| 22 NGWritingMode mode, |
| 23 NGDirection direction, |
| 24 NGPhysicalSize container_size, |
| 25 NGPhysicalSize inner_size) const { |
| 26 switch (mode) { |
| 27 case HorizontalTopBottom: |
| 28 if (direction == LeftToRight) |
| 29 return NGPhysicalOffset(inline_offset, block_offset); |
| 30 else |
| 31 return NGPhysicalOffset( |
| 32 container_size.width - inline_offset - inner_size.width, |
| 33 block_offset); |
| 34 case VerticalRightLeft: |
| 35 case SidewaysRightLeft: |
| 36 if (direction == LeftToRight) |
| 37 return NGPhysicalOffset( |
| 38 container_size.width - block_offset - inner_size.width, |
| 39 inline_offset); |
| 40 else |
| 41 return NGPhysicalOffset( |
| 42 container_size.width - block_offset - inner_size.width, |
| 43 container_size.height - inline_offset - inner_size.height); |
| 44 case VerticalLeftRight: |
| 45 if (direction == LeftToRight) |
| 46 return NGPhysicalOffset(block_offset, inline_offset); |
| 47 else |
| 48 return NGPhysicalOffset( |
| 49 block_offset, |
| 50 container_size.height - inline_offset - inner_size.height); |
| 51 case SidewaysLeftRight: |
| 52 if (direction == LeftToRight) |
| 53 return NGPhysicalOffset( |
| 54 block_offset, |
| 55 container_size.height - inline_offset - inner_size.height); |
| 56 else |
| 57 return NGPhysicalOffset(block_offset, inline_offset); |
| 58 default: |
| 59 ASSERT_NOT_REACHED(); |
| 60 return NGPhysicalOffset(); |
| 61 } |
| 62 } |
| 63 |
| 64 } // namespace blink |
OLD | NEW |