#pragma once
#include <unicode/uchar.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
namespace WebCore {
enum BidiEmbeddingSource { FromStyleOrDOM, FromUnicode };
class BidiContext : public RefCounted<BidiContext> {
public:
WEBCORE_EXPORT static Ref<BidiContext> create(unsigned char level, UCharDirection, bool override = false, BidiEmbeddingSource = FromStyleOrDOM, BidiContext* parent = nullptr);
BidiContext* parent() const { return m_parent.get(); }
unsigned char level() const { return m_level; }
UCharDirection dir() const { return static_cast<UCharDirection>(m_direction); }
bool override() const { return m_override; }
BidiEmbeddingSource source() const { return static_cast<BidiEmbeddingSource>(m_source); }
WEBCORE_EXPORT Ref<BidiContext> copyStackRemovingUnicodeEmbeddingContexts();
private:
BidiContext(unsigned char level, UCharDirection, bool override, BidiEmbeddingSource, BidiContext* parent);
static Ref<BidiContext> createUncached(unsigned char level, UCharDirection, bool override, BidiEmbeddingSource, BidiContext* parent);
unsigned m_level : 6; unsigned m_direction : 5; unsigned m_override : 1;
unsigned m_source : 1; RefPtr<BidiContext> m_parent;
};
inline unsigned char nextGreaterOddLevel(unsigned char level)
{
return (level + 1) | 1;
}
inline unsigned char nextGreaterEvenLevel(unsigned char level)
{
return (level + 2) & ~1;
}
bool operator==(const BidiContext&, const BidiContext&);
}