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
00029 namespace WebCore {
00030
00031
00032 class BidiContext {
00033 public:
00034 BidiContext(unsigned char level, WTF::Unicode::Direction direction, bool override = false, BidiContext* parent = 0)
00035 : m_level(level)
00036 , m_direction(direction)
00037 , m_override(override)
00038 , m_parent(parent)
00039 , m_refCount(0)
00040 {
00041 ASSERT(direction == WTF::Unicode::LeftToRight || direction == WTF::Unicode::RightToLeft);
00042 }
00043
00044 void ref() const { m_refCount++; }
00045 void deref() const
00046 {
00047 m_refCount--;
00048 if (m_refCount <= 0)
00049 delete this;
00050 }
00051
00052 BidiContext* parent() const { return m_parent.get(); }
00053 unsigned char level() const { return m_level; }
00054 WTF::Unicode::Direction dir() const { return static_cast<WTF::Unicode::Direction>(m_direction); }
00055 bool override() const { return m_override; }
00056
00057 private:
00058 unsigned char m_level;
00059 unsigned m_direction : 5;
00060 bool m_override : 1;
00061 RefPtr<BidiContext> m_parent;
00062 mutable int m_refCount;
00063 };
00064
00065 bool operator==(const BidiContext&, const BidiContext&);
00066
00067 }
00068
00069 #endif // BidiContext_h