#pragma once
#include "DictationAlternative.h"
#include "TextEventInputType.h"
#include "UIEvent.h"
namespace WebCore {
class DocumentFragment;
enum class MailBlockquoteHandling;
class TextEvent final : public UIEvent {
public:
static Ref<TextEvent> create(DOMWindow*, const String& data, TextEventInputType = TextEventInputKeyboard);
static Ref<TextEvent> createForBindings();
static Ref<TextEvent> createForPlainTextPaste(DOMWindow*, const String& data, bool shouldSmartReplace);
static Ref<TextEvent> createForFragmentPaste(DOMWindow*, RefPtr<DocumentFragment>&& data, bool shouldSmartReplace, bool shouldMatchStyle, MailBlockquoteHandling);
static Ref<TextEvent> createForDrop(DOMWindow*, const String& data);
static Ref<TextEvent> createForDictation(DOMWindow*, const String& data, const Vector<DictationAlternative>& dictationAlternatives);
virtual ~TextEvent();
WEBCORE_EXPORT void initTextEvent(const AtomicString& type, bool canBubble, bool cancelable, DOMWindow*, const String& data);
String data() const { return m_data; }
EventInterface eventInterface() const override;
bool isLineBreak() const { return m_inputType == TextEventInputLineBreak; }
bool isComposition() const { return m_inputType == TextEventInputComposition; }
bool isBackTab() const { return m_inputType == TextEventInputBackTab; }
bool isPaste() const { return m_inputType == TextEventInputPaste; }
bool isDrop() const { return m_inputType == TextEventInputDrop; }
bool isDictation() const { return m_inputType == TextEventInputDictation; }
bool isAutocompletion() const { return m_inputType == TextEventInputAutocompletion; }
bool isKeyboard() const { return m_inputType == TextEventInputKeyboard; }
bool shouldSmartReplace() const { return m_shouldSmartReplace; }
bool shouldMatchStyle() const { return m_shouldMatchStyle; }
MailBlockquoteHandling mailBlockquoteHandling() const { return m_mailBlockquoteHandling; }
DocumentFragment* pastingFragment() const { return m_pastingFragment.get(); }
const Vector<DictationAlternative>& dictationAlternatives() const { return m_dictationAlternatives; }
private:
TextEvent();
TextEvent(DOMWindow*, const String& data, TextEventInputType = TextEventInputKeyboard);
TextEvent(DOMWindow*, const String& data, RefPtr<DocumentFragment>&&, bool shouldSmartReplace, bool shouldMatchStyle, MailBlockquoteHandling);
TextEvent(DOMWindow*, const String& data, const Vector<DictationAlternative>& dictationAlternatives);
bool isTextEvent() const override;
TextEventInputType m_inputType;
String m_data;
RefPtr<DocumentFragment> m_pastingFragment;
bool m_shouldSmartReplace;
bool m_shouldMatchStyle;
MailBlockquoteHandling m_mailBlockquoteHandling;
Vector<DictationAlternative> m_dictationAlternatives;
};
}
SPECIALIZE_TYPE_TRAITS_EVENT(TextEvent)