#include "config.h"
#include "TextEvent.h"
#include "DocumentFragment.h"
#include "Editor.h"
namespace WebCore {
Ref<TextEvent> TextEvent::create()
{
return adoptRef(*new TextEvent);
}
Ref<TextEvent> TextEvent::create(PassRefPtr<AbstractView> view, const String& data, TextEventInputType inputType)
{
return adoptRef(*new TextEvent(view, data, inputType));
}
Ref<TextEvent> TextEvent::createForPlainTextPaste(PassRefPtr<AbstractView> view, const String& data, bool shouldSmartReplace)
{
return adoptRef(*new TextEvent(view, data, 0, shouldSmartReplace, false, MailBlockquoteHandling::RespectBlockquote));
}
Ref<TextEvent> TextEvent::createForFragmentPaste(PassRefPtr<AbstractView> view, PassRefPtr<DocumentFragment> data, bool shouldSmartReplace, bool shouldMatchStyle, MailBlockquoteHandling mailBlockquoteHandling)
{
return adoptRef(*new TextEvent(view, "", data, shouldSmartReplace, shouldMatchStyle, mailBlockquoteHandling));
}
Ref<TextEvent> TextEvent::createForDrop(PassRefPtr<AbstractView> view, const String& data)
{
return adoptRef(*new TextEvent(view, data, TextEventInputDrop));
}
Ref<TextEvent> TextEvent::createForDictation(PassRefPtr<AbstractView> view, const String& data, const Vector<DictationAlternative>& dictationAlternatives)
{
return adoptRef(*new TextEvent(view, data, dictationAlternatives));
}
TextEvent::TextEvent()
: m_inputType(TextEventInputKeyboard)
, m_shouldSmartReplace(false)
, m_shouldMatchStyle(false)
, m_mailBlockquoteHandling(MailBlockquoteHandling::RespectBlockquote)
{
}
TextEvent::TextEvent(PassRefPtr<AbstractView> view, const String& data, TextEventInputType inputType)
: UIEvent(eventNames().textInputEvent, true, true, view, 0)
, m_inputType(inputType)
, m_data(data)
, m_pastingFragment(0)
, m_shouldSmartReplace(false)
, m_shouldMatchStyle(false)
, m_mailBlockquoteHandling(MailBlockquoteHandling::RespectBlockquote)
{
}
TextEvent::TextEvent(PassRefPtr<AbstractView> view, const String& data, PassRefPtr<DocumentFragment> pastingFragment, bool shouldSmartReplace, bool shouldMatchStyle, MailBlockquoteHandling mailBlockquoteHandling)
: UIEvent(eventNames().textInputEvent, true, true, view, 0)
, m_inputType(TextEventInputPaste)
, m_data(data)
, m_pastingFragment(pastingFragment)
, m_shouldSmartReplace(shouldSmartReplace)
, m_shouldMatchStyle(shouldMatchStyle)
, m_mailBlockquoteHandling(mailBlockquoteHandling)
{
}
TextEvent::TextEvent(PassRefPtr<AbstractView> view, const String& data, const Vector<DictationAlternative>& dictationAlternatives)
: UIEvent(eventNames().textInputEvent, true, true, view, 0)
, m_inputType(TextEventInputDictation)
, m_data(data)
, m_shouldSmartReplace(false)
, m_shouldMatchStyle(false)
, m_mailBlockquoteHandling(MailBlockquoteHandling::RespectBlockquote)
, m_dictationAlternatives(dictationAlternatives)
{
}
TextEvent::~TextEvent()
{
}
void TextEvent::initTextEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView> view, const String& data)
{
if (dispatched())
return;
initUIEvent(type, canBubble, cancelable, view, 0);
m_data = data;
}
EventInterface TextEvent::eventInterface() const
{
return TextEventInterfaceType;
}
bool TextEvent::isTextEvent() const
{
return true;
}
}