#pragma once
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
#include "LayoutBox.h"
#include <wtf/WeakPtr.h>
namespace WebCore {
namespace Layout {
class InlineItem : public CanMakeWeakPtr<InlineItem> {
WTF_MAKE_FAST_ALLOCATED;
public:
enum class Type { 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 m_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;
const Type m_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