18e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/* 28e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 38e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 48e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Redistribution and use in source and binary forms, with or without 58e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * modification, are permitted provided that the following conditions 68e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * are met: 78e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 1. Redistributions of source code must retain the above copyright 88e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * notice, this list of conditions and the following disclaimer. 98e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 2. Redistributions in binary form must reproduce the above copyright 108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * notice, this list of conditions and the following disclaimer in the 118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * documentation and/or other materials provided with the distribution. 128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 228e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 238e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 248e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 258e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */ 268e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 278e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#ifndef TextEvent_h 288e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#define TextEvent_h 298e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 30dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch#include "DocumentFragment.h" 31ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch#include "TextEventInputType.h" 328e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "UIEvent.h" 338e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 348e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectnamespace WebCore { 358e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 368e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project class TextEvent : public UIEvent { 378e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project public: 38f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick 39dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch static PassRefPtr<TextEvent> create(); 40ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch static PassRefPtr<TextEvent> create(PassRefPtr<AbstractView>, const String& data, TextEventInputType = TextEventInputKeyboard); 41dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch static PassRefPtr<TextEvent> createForPlainTextPaste(PassRefPtr<AbstractView> view, const String& data, bool shouldSmartReplace); 42dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch static PassRefPtr<TextEvent> createForFragmentPaste(PassRefPtr<AbstractView> view, PassRefPtr<DocumentFragment> data, bool shouldSmartReplace, bool shouldMatchStyle); 43f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick static PassRefPtr<TextEvent> createForDrop(PassRefPtr<AbstractView> view, const String& data); 44dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch 458e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project virtual ~TextEvent(); 468e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 478e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project void initTextEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView>, const String& data); 488e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 498e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project String data() const { return m_data; } 508e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 518e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project virtual bool isTextEvent() const; 528e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 53ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch bool isLineBreak() const { return m_inputType == TextEventInputLineBreak; } 542fc2651226baac27029e38c9d6ef883fa32084dbSteve Block bool isComposition() const { return m_inputType == TextEventInputComposition; } 55ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch bool isBackTab() const { return m_inputType == TextEventInputBackTab; } 56ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch bool isPaste() const { return m_inputType == TextEventInputPaste; } 57ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch bool isDrop() const { return m_inputType == TextEventInputDrop; } 588e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 59dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch bool shouldSmartReplace() const { return m_shouldSmartReplace; } 60dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch bool shouldMatchStyle() const { return m_shouldMatchStyle; } 61dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch DocumentFragment* pastingFragment() const { return m_pastingFragment.get(); } 62dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch 638e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project private: 648e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project TextEvent(); 658e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 66ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch TextEvent(PassRefPtr<AbstractView>, const String& data, TextEventInputType = TextEventInputKeyboard); 67f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick TextEvent(PassRefPtr<AbstractView>, const String& data, PassRefPtr<DocumentFragment>, 68f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick bool shouldSmartReplace, bool shouldMatchStyle); 69f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick 70ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch TextEventInputType m_inputType; 718e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project String m_data; 72dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch 73dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch RefPtr<DocumentFragment> m_pastingFragment; 74dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch bool m_shouldSmartReplace; 75dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch bool m_shouldMatchStyle; 768e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project }; 778e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 788e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project} // namespace WebCore 798e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 808e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#endif // TextEvent_h 81