#ifndef BidiCharacterRun_h
#define BidiCharacterRun_h
#include "platform/text/BidiContext.h"
#include "platform/text/TextDirection.h"
namespace WebCore {
struct BidiCharacterRun {
BidiCharacterRun(int start, int stop, BidiContext* context, WTF::Unicode::Direction dir)
: m_override(context->override())
, m_next(0)
, m_start(start)
, m_stop(stop)
{
ASSERT(m_start <= m_stop);
if (dir == WTF::Unicode::OtherNeutral)
dir = context->dir();
m_level = context->level();
if (m_level % 2) {
if (dir == WTF::Unicode::LeftToRight || dir == WTF::Unicode::ArabicNumber || dir == WTF::Unicode::EuropeanNumber)
m_level++;
} else {
if (dir == WTF::Unicode::RightToLeft)
m_level++;
else if (dir == WTF::Unicode::ArabicNumber || dir == WTF::Unicode::EuropeanNumber)
m_level += 2;
}
}
PLATFORM_EXPORT void* operator new(size_t);
PLATFORM_EXPORT void operator delete(void*);
int start() const { return m_start; }
int stop() const { return m_stop; }
unsigned char level() const { return m_level; }
bool reversed(bool visuallyOrdered) const { return m_level % 2 && !visuallyOrdered; }
bool dirOverride(bool visuallyOrdered) { return m_override || visuallyOrdered; }
TextDirection direction() const { return reversed(false) ? RTL : LTR; }
BidiCharacterRun* next() const { return m_next; }
void setNext(BidiCharacterRun* next) { m_next = next; }
bool m_override : 1;
bool m_hasHyphen : 1;
bool m_startsSegment : 1;
unsigned char m_level;
BidiCharacterRun* m_next;
int m_start;
int m_stop;
};
}
#endif