2 * Copyright (C) 2012 Samsung Electronics
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. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef TextSelection_h
27 #define TextSelection_h
29 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
31 #include "PageClientImpl.h"
32 #include "TextSelectionHandle.h"
33 #include "TextSelectionMagnifier.h"
34 #include "WebPageProxy.h"
36 #include <WebCore/IntPoint.h>
37 #include <wtf/PassOwnPtr.h>
38 #include <wtf/text/CString.h>
39 #include <wtf/text/WTFString.h>
45 class TextSelectionHandle;
46 class TextSelectionMagnifier;
51 static PassOwnPtr<TextSelection> create(Evas_Object* evas, WebPageProxy* page, PageClientImpl* pageClient)
53 return adoptPtr(new TextSelection(evas, page, pageClient));
58 bool isTextSelectionDowned() { return m_isTextSelectionDowned; }
59 void setIsTextSelectionDowned(bool isTextSelectionDowned) { m_isTextSelectionDowned = isTextSelectionDowned; }
60 bool isTextSelectionMode() { return m_isTextSelectionMode; }
61 void setIsTextSelectionMode(bool isTextSelectionMode);
62 bool isMagnifierVisible();
63 void updateHandlesAndContextMenu(bool isShow, bool isScrolling = false);
64 bool isTextSelectionEnable() { return m_isTextSelectionEnable; }
65 void setIsTextSelectionEnable(bool isTextSelectionEnable) { m_isTextSelectionEnable = isTextSelectionEnable; }
66 bool autoClearTextSelectionMode() { return m_autoClearTextSelectionMode; }
67 void setAutoClearTextSelectionMode(bool autoClearTextSelectionMode) { m_autoClearTextSelectionMode = autoClearTextSelectionMode; }
68 bool textSelectionDown(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside = false);
69 void textSelectionMove(const WebCore::IntPoint& point, bool isStaredTextSelectionFromOutside = false);
70 void textSelectionUp(const WebCore::IntPoint& point, bool isStaredTextSelectionFromOutside = false);
74 void handleMouseDown(TextSelectionHandle* handle, const WebCore::IntPoint& position);
75 void handleMouseMove(TextSelectionHandle* handle, const WebCore::IntPoint& position);
76 void handleMouseUp(TextSelectionHandle* handle, const WebCore::IntPoint& position);
78 bool isTextSelectionHandleDowned() { return m_leftHandle->isMouseDowned() || m_rightHandle->isMouseDowned(); }
79 #if ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
80 void textSelectionHandleDown(const WebCore::IntPoint& position);
81 void textSelectionHandleMove(const WebCore::IntPoint& position);
82 void textSelectionHandleUp();
85 friend class PageClientImpl; // to allow hideHandlers() call while zooming
87 TextSelection(Evas_Object*, WebPageProxy*, PageClientImpl*);
90 void updateHandlers();
92 void reloadMagnifier();
95 void updateMagnifier(const WebCore::IntPoint& position);
96 void showContextMenu();
97 void hideContextMenu();
98 void setLeftSelectionToEvasPoint(const WebCore::IntPoint& evasPoint);
99 void setRightSelectionToEvasPoint(const WebCore::IntPoint& evasPoint);
101 void startMoveAnimator();
102 void stopMoveAnimator();
103 static void onMouseUp(void* data, Evas*, Evas_Object*, void* eventInfo);
104 static Eina_Bool moveAnimatorCallback(void*);
106 #if ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
107 TextSelectionHandle* getSelectedHandle(const WebCore::IntPoint& position);
111 Evas_Object* m_object;
112 EwkViewImpl* m_viewImpl;
113 TextSelectionHandle* m_leftHandle;
114 TextSelectionHandle* m_rightHandle;
115 TextSelectionMagnifier* m_magnifier;
116 WebPageProxy* m_page;
117 PageClientImpl* m_pageClient;
118 bool m_isTextSelectionDowned;
119 bool m_isTextSelectionMode;
120 bool m_isTextSelectionEnable;
121 bool m_autoClearTextSelectionMode;
122 Ecore_Animator* m_moveAnimator;
125 } // namespace WebKit
127 #endif // TIZEN_WEBKIT2_TEXT_SELECTION
128 #endif // TextSelection_h