#pragma once
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
#include "LayoutBox.h"
#include "LayoutUnits.h"
namespace WebCore {
namespace Layout {
class InlineItem {
public:
enum class Type : uint8_t { Text, HardLineBreak, SoftLineBreak, Box, Float, ContainerStart, ContainerEnd };
InlineItem(const Box& layoutBox, Type);
Type type() const { return m_type; }
const Box& layoutBox() const { return *m_layoutBox; }
const RenderStyle& style() const { return layoutBox().style(); }
bool isText() const { return type() == Type::Text; }
bool isBox() const { return type() == Type::Box; }
bool isFloat() const { return type() == Type::Float; }
bool isLineBreak() const { return isSoftLineBreak() || isHardLineBreak(); }
bool isSoftLineBreak() const { return type() == Type::SoftLineBreak; }
bool isHardLineBreak() const { return type() == Type::HardLineBreak; }
bool isContainerStart() const { return type() == Type::ContainerStart; }
bool isContainerEnd() const { return type() == Type::ContainerEnd; }
private:
const Box* m_layoutBox { nullptr };
Type m_type { };
protected:
enum class TextItemType : uint8_t { Undefined, Whitespace, NonWhitespace };
TextItemType m_textItemType { TextItemType::Undefined };
bool m_hasWidth { false };
bool m_isCollapsible { false };
InlineLayoutUnit m_width { };
unsigned m_length { 0 };
unsigned m_startOrPosition { 0 };
};
inline InlineItem::InlineItem(const Box& layoutBox, Type type)
: m_layoutBox(&layoutBox)
, m_type(type)
{
}
#define SPECIALIZE_TYPE_TRAITS_INLINE_ITEM(ToValueTypeName, predicate) \
SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::Layout::ToValueTypeName) \
static bool isType(const WebCore::Layout::InlineItem& inlineItem) { return inlineItem.predicate; } \
SPECIALIZE_TYPE_TRAITS_END()
}
}
#endif