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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 return bottom; | 69 return bottom; |
70 case WritingMode::kVerticalLr: | 70 case WritingMode::kVerticalLr: |
71 return right; | 71 return right; |
72 case WritingMode::kVerticalRl: | 72 case WritingMode::kVerticalRl: |
73 return left; | 73 return left; |
74 } | 74 } |
75 NOTREACHED(); | 75 NOTREACHED(); |
76 return bottom; | 76 return bottom; |
77 } | 77 } |
78 | 78 |
| 79 const Length& LengthBox::Start(WritingMode writing_mode, |
| 80 TextDirection direction, |
| 81 const Length& top, |
| 82 const Length& left, |
| 83 const Length& right, |
| 84 const Length& bottom) { |
| 85 if (IsHorizontalWritingMode(writing_mode)) |
| 86 return IsLeftToRightDirection(direction) ? left : right; |
| 87 return IsLeftToRightDirection(direction) ? top : bottom; |
| 88 } |
| 89 |
| 90 const Length& LengthBox::End(WritingMode writing_mode, |
| 91 TextDirection direction, |
| 92 const Length& top, |
| 93 const Length& left, |
| 94 const Length& right, |
| 95 const Length& bottom) { |
| 96 if (IsHorizontalWritingMode(writing_mode)) |
| 97 return IsLeftToRightDirection(direction) ? right : left; |
| 98 return IsLeftToRightDirection(direction) ? bottom : top; |
| 99 } |
| 100 |
| 101 const Length& LengthBox::Over(WritingMode writing_mode, |
| 102 const Length& top, |
| 103 const Length& right) { |
| 104 return IsHorizontalWritingMode(writing_mode) ? top : right; |
| 105 } |
| 106 |
| 107 const Length& LengthBox::Under(WritingMode writing_mode, |
| 108 const Length& bottom, |
| 109 const Length& left) { |
| 110 return IsHorizontalWritingMode(writing_mode) ? bottom : left; |
| 111 } |
| 112 |
79 const Length& LengthBox::LogicalLeft(WritingMode writing_mode) const { | 113 const Length& LengthBox::LogicalLeft(WritingMode writing_mode) const { |
80 return LengthBox::LogicalLeft(writing_mode, left_, top_); | 114 return LengthBox::LogicalLeft(writing_mode, left_, top_); |
81 } | 115 } |
82 | 116 |
83 const Length& LengthBox::LogicalRight(WritingMode writing_mode) const { | 117 const Length& LengthBox::LogicalRight(WritingMode writing_mode) const { |
84 return LengthBox::LogicalRight(writing_mode, right_, bottom_); | 118 return LengthBox::LogicalRight(writing_mode, right_, bottom_); |
85 } | 119 } |
86 | 120 |
87 const Length& LengthBox::Before(WritingMode writing_mode) const { | 121 const Length& LengthBox::Before(WritingMode writing_mode) const { |
88 return LengthBox::Before(writing_mode, top_, left_, right_); | 122 return LengthBox::Before(writing_mode, top_, left_, right_); |
89 } | 123 } |
90 | 124 |
91 const Length& LengthBox::After(WritingMode writing_mode) const { | 125 const Length& LengthBox::After(WritingMode writing_mode) const { |
92 return LengthBox::After(writing_mode, bottom_, left_, right_); | 126 return LengthBox::After(writing_mode, bottom_, left_, right_); |
93 } | 127 } |
94 | 128 |
95 const Length& LengthBox::Start(WritingMode writing_mode, | 129 const Length& LengthBox::Start(WritingMode writing_mode, |
96 TextDirection direction) const { | 130 TextDirection direction) const { |
97 if (IsHorizontalWritingMode(writing_mode)) | 131 return LengthBox::Start(writing_mode, direction, top_, left_, right_, |
98 return IsLeftToRightDirection(direction) ? left_ : right_; | 132 bottom_); |
99 return IsLeftToRightDirection(direction) ? top_ : bottom_; | |
100 } | 133 } |
101 | 134 |
102 const Length& LengthBox::end(WritingMode writing_mode, | 135 const Length& LengthBox::end(WritingMode writing_mode, |
103 TextDirection direction) const { | 136 TextDirection direction) const { |
104 if (IsHorizontalWritingMode(writing_mode)) | 137 return LengthBox::End(writing_mode, direction, top_, left_, right_, bottom_); |
105 return IsLeftToRightDirection(direction) ? right_ : left_; | |
106 return IsLeftToRightDirection(direction) ? bottom_ : top_; | |
107 } | 138 } |
108 | 139 |
109 const Length& LengthBox::Over(WritingMode writing_mode) const { | 140 const Length& LengthBox::Over(WritingMode writing_mode) const { |
110 return IsHorizontalWritingMode(writing_mode) ? top_ : right_; | 141 return LengthBox::Over(writing_mode, top_, right_); |
111 } | 142 } |
112 | 143 |
113 const Length& LengthBox::Under(WritingMode writing_mode) const { | 144 const Length& LengthBox::Under(WritingMode writing_mode) const { |
114 return IsHorizontalWritingMode(writing_mode) ? bottom_ : left_; | 145 return LengthBox::Under(writing_mode, bottom_, left_); |
115 } | 146 } |
116 | 147 |
117 } // namespace blink | 148 } // namespace blink |
OLD | NEW |