2 * Copyright (C) 2007 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #include "TextEvent.h"
30 #include "DocumentFragment.h"
35 Ref<TextEvent> TextEvent::create()
37 return adoptRef(*new TextEvent);
40 Ref<TextEvent> TextEvent::create(AbstractView* view, const String& data, TextEventInputType inputType)
42 return adoptRef(*new TextEvent(view, data, inputType));
45 Ref<TextEvent> TextEvent::createForPlainTextPaste(AbstractView* view, const String& data, bool shouldSmartReplace)
47 return adoptRef(*new TextEvent(view, data, 0, shouldSmartReplace, false, MailBlockquoteHandling::RespectBlockquote));
50 Ref<TextEvent> TextEvent::createForFragmentPaste(AbstractView* view, RefPtr<DocumentFragment>&& data, bool shouldSmartReplace, bool shouldMatchStyle, MailBlockquoteHandling mailBlockquoteHandling)
52 return adoptRef(*new TextEvent(view, emptyString(), WTFMove(data), shouldSmartReplace, shouldMatchStyle, mailBlockquoteHandling));
55 Ref<TextEvent> TextEvent::createForDrop(AbstractView* view, const String& data)
57 return adoptRef(*new TextEvent(view, data, TextEventInputDrop));
60 Ref<TextEvent> TextEvent::createForDictation(AbstractView* view, const String& data, const Vector<DictationAlternative>& dictationAlternatives)
62 return adoptRef(*new TextEvent(view, data, dictationAlternatives));
65 TextEvent::TextEvent()
66 : m_inputType(TextEventInputKeyboard)
67 , m_shouldSmartReplace(false)
68 , m_shouldMatchStyle(false)
69 , m_mailBlockquoteHandling(MailBlockquoteHandling::RespectBlockquote)
73 TextEvent::TextEvent(AbstractView* view, const String& data, TextEventInputType inputType)
74 : UIEvent(eventNames().textInputEvent, true, true, view, 0)
75 , m_inputType(inputType)
77 , m_shouldSmartReplace(false)
78 , m_shouldMatchStyle(false)
79 , m_mailBlockquoteHandling(MailBlockquoteHandling::RespectBlockquote)
83 TextEvent::TextEvent(AbstractView* view, const String& data, RefPtr<DocumentFragment>&& pastingFragment, bool shouldSmartReplace, bool shouldMatchStyle, MailBlockquoteHandling mailBlockquoteHandling)
84 : UIEvent(eventNames().textInputEvent, true, true, view, 0)
85 , m_inputType(TextEventInputPaste)
87 , m_pastingFragment(WTFMove(pastingFragment))
88 , m_shouldSmartReplace(shouldSmartReplace)
89 , m_shouldMatchStyle(shouldMatchStyle)
90 , m_mailBlockquoteHandling(mailBlockquoteHandling)
94 TextEvent::TextEvent(AbstractView* view, const String& data, const Vector<DictationAlternative>& dictationAlternatives)
95 : UIEvent(eventNames().textInputEvent, true, true, view, 0)
96 , m_inputType(TextEventInputDictation)
98 , m_shouldSmartReplace(false)
99 , m_shouldMatchStyle(false)
100 , m_mailBlockquoteHandling(MailBlockquoteHandling::RespectBlockquote)
101 , m_dictationAlternatives(dictationAlternatives)
105 TextEvent::~TextEvent()
109 void TextEvent::initTextEvent(const AtomicString& type, bool canBubble, bool cancelable, AbstractView* view, const String& data)
114 initUIEvent(type, canBubble, cancelable, view, 0);
119 EventInterface TextEvent::eventInterface() const
121 return TextEventInterfaceType;
124 bool TextEvent::isTextEvent() const
129 } // namespace WebCore