#ifndef EditorState_h
#define EditorState_h
#include "ArgumentCoders.h"
#include <WebCore/IntRect.h>
#include <wtf/text/WTFString.h>
#if PLATFORM(IOS)
#include <WebCore/SelectionRect.h>
#endif
namespace WebKit {
enum TypingAttributes {
AttributeNone = 0,
AttributeBold = 1,
AttributeItalics = 2,
AttributeUnderline = 4
};
struct EditorState {
bool shouldIgnoreCompositionSelectionChange { false };
bool selectionIsNone { true }; bool selectionIsRange { false };
bool isContentEditable { false };
bool isContentRichlyEditable { false };
bool isInPasswordField { false };
bool isInPlugin { false };
bool hasComposition { false };
bool isMissingPostLayoutData { false };
#if PLATFORM(IOS)
WebCore::IntRect firstMarkedRect;
WebCore::IntRect lastMarkedRect;
String markedText;
struct PostLayoutData {
WebCore::IntRect selectionClipRect;
Vector<WebCore::SelectionRect> selectionRects;
WebCore::IntRect caretRectAtStart;
WebCore::IntRect caretRectAtEnd;
String wordAtSelection;
uint64_t selectedTextLength { 0 };
UChar32 characterAfterSelection { 0 };
UChar32 characterBeforeSelection { 0 };
UChar32 twoCharacterBeforeSelection { 0 };
uint32_t typingAttributes { AttributeNone };
bool isReplaceAllowed { false };
bool hasContent { false };
void encode(IPC::ArgumentEncoder&) const;
static bool decode(IPC::ArgumentDecoder&, PostLayoutData&);
};
const PostLayoutData& postLayoutData() const;
PostLayoutData& postLayoutData();
#endif
#if PLATFORM(GTK)
WebCore::IntRect cursorRect;
#endif
void encode(IPC::ArgumentEncoder&) const;
static bool decode(IPC::ArgumentDecoder&, EditorState&);
#if PLATFORM(IOS)
private:
PostLayoutData m_postLayoutData;
#endif
};
#if PLATFORM(IOS)
inline auto EditorState::postLayoutData() -> PostLayoutData&
{
ASSERT_WITH_MESSAGE(!isMissingPostLayoutData, "Attempt to access post layout data before receiving it");
return m_postLayoutData;
}
inline auto EditorState::postLayoutData() const -> const PostLayoutData&
{
ASSERT_WITH_MESSAGE(!isMissingPostLayoutData, "Attempt to access post layout data before receiving it");
return m_postLayoutData;
}
#endif
}
#endif // EditorState_h