Debian Codegraph @

intl/components/src/BidiEmbeddingLevel.cpp

raw
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 #include "mozilla/intl/BidiEmbeddingLevel.h"
6 #include "mozilla/Casting.h"
7 #include "mozilla/intl/ICU4CGlue.h"
8
9 namespace mozilla::intl {
10
11 bool BidiEmbeddingLevel::IsDefaultLTR() const { return *this == DefaultLTR(); };
12
13 bool BidiEmbeddingLevel::IsDefaultRTL() const { return *this == DefaultRTL(); };
14
15 bool BidiEmbeddingLevel::IsRTL() const {
16 // If the least significant bit is 1, then the embedding level
17 // is right-to-left.
18 // If the least significant bit is 0, then the embedding level
19 // is left-to-right.
20 return (mValue & 0x1) == 1;
21 };
22
23 bool BidiEmbeddingLevel::IsLTR() const { return !IsRTL(); };
24
25 bool BidiEmbeddingLevel::IsSameDirection(BidiEmbeddingLevel aOther) const {
26 return (((mValue ^ aOther) & 1) == 0);
27 }
28
29 BidiEmbeddingLevel BidiEmbeddingLevel::LTR() { return BidiEmbeddingLevel(0); };
30
31 BidiEmbeddingLevel BidiEmbeddingLevel::RTL() { return BidiEmbeddingLevel(1); };
32
33 BidiEmbeddingLevel BidiEmbeddingLevel::DefaultLTR() {
34 return BidiEmbeddingLevel(kDefaultLTR);
35 };
36
37 BidiEmbeddingLevel BidiEmbeddingLevel::DefaultRTL() {
38 return BidiEmbeddingLevel(kDefaultRTL);
39 };
40
41 BidiDirection BidiEmbeddingLevel::Direction() {
42 return IsRTL() ? BidiDirection::RTL : BidiDirection::LTR;
43 };
44
45 uint8_t BidiEmbeddingLevel::Value() const { return mValue; }
46
47 } // namespace mozilla::intl