BidiEmbeddingLevel.cpp (1478B)
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/intl/ICU4CGlue.h" 7 8 namespace mozilla::intl { 9 10 bool BidiEmbeddingLevel::IsDefaultLTR() const { return *this == DefaultLTR(); }; 11 12 bool BidiEmbeddingLevel::IsDefaultRTL() const { return *this == DefaultRTL(); }; 13 14 bool BidiEmbeddingLevel::IsRTL() const { 15 // If the least significant bit is 1, then the embedding level 16 // is right-to-left. 17 // If the least significant bit is 0, then the embedding level 18 // is left-to-right. 19 return (mValue & 0x1) == 1; 20 }; 21 22 bool BidiEmbeddingLevel::IsLTR() const { return !IsRTL(); }; 23 24 bool BidiEmbeddingLevel::IsSameDirection(BidiEmbeddingLevel aOther) const { 25 return (((mValue ^ aOther) & 1) == 0); 26 } 27 28 BidiEmbeddingLevel BidiEmbeddingLevel::LTR() { return BidiEmbeddingLevel(0); }; 29 30 BidiEmbeddingLevel BidiEmbeddingLevel::RTL() { return BidiEmbeddingLevel(1); }; 31 32 BidiEmbeddingLevel BidiEmbeddingLevel::DefaultLTR() { 33 return BidiEmbeddingLevel(kDefaultLTR); 34 }; 35 36 BidiEmbeddingLevel BidiEmbeddingLevel::DefaultRTL() { 37 return BidiEmbeddingLevel(kDefaultRTL); 38 }; 39 40 BidiDirection BidiEmbeddingLevel::Direction() { 41 return IsRTL() ? BidiDirection::RTL : BidiDirection::LTR; 42 }; 43 44 uint8_t BidiEmbeddingLevel::Value() const { return mValue; } 45 46 } // namespace mozilla::intl