• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3  * Copyright (C) 2003, 2004, 2006, 2007, 2009 Apple Inc. All right reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB.  If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  *
20  */
21 
22 #ifndef BidiContext_h
23 #define BidiContext_h
24 
25 #include <wtf/Assertions.h>
26 #include <wtf/PassRefPtr.h>
27 #include <wtf/RefCounted.h>
28 #include <wtf/RefPtr.h>
29 #include <wtf/unicode/Unicode.h>
30 
31 namespace WebCore {
32 
33 // Used to keep track of explicit embeddings.
34 class BidiContext : public RefCounted<BidiContext> {
35 public:
36     static PassRefPtr<BidiContext> create(unsigned char level, WTF::Unicode::Direction direction, bool override = false, BidiContext* parent = 0);
37 
parent()38     BidiContext* parent() const { return m_parent.get(); }
level()39     unsigned char level() const { return m_level; }
dir()40     WTF::Unicode::Direction dir() const { return static_cast<WTF::Unicode::Direction>(m_direction); }
override()41     bool override() const { return m_override; }
42 
43 private:
BidiContext(unsigned char level,WTF::Unicode::Direction direction,bool override,BidiContext * parent)44     BidiContext(unsigned char level, WTF::Unicode::Direction direction, bool override, BidiContext* parent)
45         : m_level(level)
46         , m_direction(direction)
47         , m_override(override)
48         , m_parent(parent)
49     {
50     }
51 
52     unsigned char m_level;
53     unsigned m_direction : 5; // Direction
54     bool m_override : 1;
55     RefPtr<BidiContext> m_parent;
56 };
57 
58 bool operator==(const BidiContext&, const BidiContext&);
59 
60 } // namespace WebCore
61 
62 #endif // BidiContext_h
63