#ifndef BIDI_H
#define BIDI_H
#include <unicode/uchar.h>
namespace WebCore {
class RenderArena;
class RenderBlock;
class RenderObject;
class InlineBox;
struct BidiStatus {
BidiStatus() : eor(U_OTHER_NEUTRAL), lastStrong(U_OTHER_NEUTRAL), last(U_OTHER_NEUTRAL) {}
UCharDirection eor;
UCharDirection lastStrong;
UCharDirection last;
};
class BidiContext {
public:
BidiContext(unsigned char level, UCharDirection embedding, BidiContext* parent = 0, bool override = false);
~BidiContext();
void ref() const;
void deref() const;
UCharDirection dir() const { return static_cast<UCharDirection>(m_dir); }
UCharDirection basicDir() const { return static_cast<UCharDirection>(m_basicDir); }
unsigned char level;
bool override : 1;
unsigned m_dir : 5; unsigned m_basicDir : 5;
BidiContext* parent;
mutable int count;
};
struct BidiRun {
BidiRun(int start_, int stop_, RenderObject* o, BidiContext* context, UCharDirection dir)
: start(start_), stop(stop_), obj(o), box(0), override(context->override), nextRun(0)
{
if (dir == U_OTHER_NEUTRAL)
dir = context->dir();
level = context->level;
if (level % 2) {
if(dir == U_LEFT_TO_RIGHT || dir == U_ARABIC_NUMBER || dir == U_EUROPEAN_NUMBER)
level++;
} else {
if (dir == U_RIGHT_TO_LEFT)
level++;
else if (dir == U_ARABIC_NUMBER || dir == U_EUROPEAN_NUMBER)
level += 2;
}
}
void destroy(RenderArena*);
void* operator new(size_t, RenderArena*) throw();
void operator delete(void*, size_t);
private:
void* operator new(size_t) throw();
public:
int start;
int stop;
RenderObject *obj;
InlineBox* box;
unsigned char level;
bool override : 1;
bool compact : 1;
BidiRun* nextRun;
};
struct BidiIterator;
struct BidiState;
};
#endif