KHTML
BidiContext.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef BidiContext_h
00023 #define BidiContext_h
00024
00025 #include <wtf/Assertions.h>
00026 #include <wtf/RefPtr.h>
00027 #include <wtf/unicode/Unicode.h>
00028 #include <QChar>
00029
00030 namespace WTF {
00031 namespace Unicode {
00032 enum Direction {
00033 LeftToRight = QChar::DirL,
00034 RightToLeft = QChar::DirR,
00035 EuropeanNumber = QChar::DirEN,
00036 EuropeanNumberSeparator = QChar::DirES,
00037 EuropeanNumberTerminator = QChar::DirET,
00038 ArabicNumber = QChar::DirAN,
00039 CommonNumberSeparator = QChar::DirCS,
00040 BlockSeparator = QChar::DirB,
00041 SegmentSeparator = QChar::DirS,
00042 WhiteSpaceNeutral = QChar::DirWS,
00043 OtherNeutral = QChar::DirON,
00044 LeftToRightEmbedding = QChar::DirLRE,
00045 LeftToRightOverride = QChar::DirLRO,
00046 RightToLeftArabic = QChar::DirAL,
00047 RightToLeftEmbedding = QChar::DirRLE,
00048 RightToLeftOverride = QChar::DirRLO,
00049 PopDirectionalFormat = QChar::DirPDF,
00050 NonSpacingMark = QChar::DirNSM,
00051 BoundaryNeutral = QChar::DirBN
00052 };
00053 inline Direction direction(unsigned c) { return (Direction)QChar::direction(c); }
00054 }
00055 }
00056
00057 namespace WebCore {
00058
00059
00060 class BidiContext {
00061 public:
00062 BidiContext(unsigned char level, WTF::Unicode::Direction direction, bool override = false, BidiContext* parent = 0)
00063 : m_level(level)
00064 , m_direction(direction)
00065 , m_override(override)
00066 , m_parent(parent)
00067 , m_refCount(0)
00068 {
00069 ASSERT(direction == WTF::Unicode::LeftToRight || direction == WTF::Unicode::RightToLeft);
00070 }
00071
00072 void ref() const { m_refCount++; }
00073 void deref() const
00074 {
00075 m_refCount--;
00076 if (m_refCount <= 0)
00077 delete this;
00078 }
00079
00080 BidiContext* parent() const { return m_parent.get(); }
00081 unsigned char level() const { return m_level; }
00082 WTF::Unicode::Direction dir() const { return static_cast<WTF::Unicode::Direction>(m_direction); }
00083 bool override() const { return m_override; }
00084
00085 private:
00086 unsigned char m_level;
00087 unsigned m_direction : 5;
00088 bool m_override : 1;
00089 RefPtr<BidiContext> m_parent;
00090 mutable int m_refCount;
00091 };
00092
00093 bool operator==(const BidiContext&, const BidiContext&);
00094
00095 }
00096
00097 #endif // BidiContext_h