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(EwkViewImpl* viewImpl)
53 return adoptPtr(new TextSelection(viewImpl));
57 enum HandleMovingDirection {
58 HandleMovingDirectionNone = 0,
59 HandleMovingDirectionNormal,
60 HandleMovingDirectionReverse,
64 bool isTextSelectionDowned() { return m_isTextSelectionDowned; }
65 void setIsTextSelectionDowned(bool isTextSelectionDowned) { m_isTextSelectionDowned = isTextSelectionDowned; }
66 bool isTextSelectionMode() { return m_isTextSelectionMode; }
67 void setIsTextSelectionMode(bool isTextSelectionMode);
68 bool isMagnifierVisible();
69 void updateHandlesAndContextMenu(bool isShow, bool isScrolling = false);
71 bool isAutomaticClearEnabled();
72 bool textSelectionDown(const WebCore::IntPoint& point);
73 void textSelectionMove(const WebCore::IntPoint& point);
74 void textSelectionUp(const WebCore::IntPoint& point, bool isStaredTextSelectionFromOutside = false);
77 void handleMouseDown(TextSelectionHandle* handle, const WebCore::IntPoint& position);
78 void handleMouseMove(TextSelectionHandle* handle, const WebCore::IntPoint& position);
79 void handleMouseUp(TextSelectionHandle* handle, const WebCore::IntPoint& position);
81 bool isTextSelectionHandleDowned() { return m_leftHandle->isMouseDowned() || m_rightHandle->isMouseDowned(); }
82 #if ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
83 void textSelectionHandleDown(const WebCore::IntPoint& position);
84 void textSelectionHandleMove(const WebCore::IntPoint& position);
85 void textSelectionHandleUp();
89 void initHandlesMouseDownedStatus();
91 void changeContextMenuPosition(WebCore::IntPoint& position);
93 friend class PageClientImpl; // to allow hideHandlers() call while zooming
95 TextSelection(EwkViewImpl*);
98 void updateHandlers();
100 void reloadMagnifier();
101 void showMagnifier();
102 void hideMagnifier();
103 void updateMagnifier(const WebCore::IntPoint& position);
104 void showContextMenu();
105 void hideContextMenu();
106 void setLeftSelectionToEvasPoint(const WebCore::IntPoint& evasPoint);
107 void setRightSelectionToEvasPoint(const WebCore::IntPoint& evasPoint);
109 void startMoveAnimator();
110 void stopMoveAnimator();
111 static void onMouseUp(void* data, Evas*, Evas_Object*, void* eventInfo);
112 static Eina_Bool moveAnimatorCallback(void*);
114 #if ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
115 TextSelectionHandle* getSelectedHandle(const WebCore::IntPoint& position);
118 static Eina_Bool showTimerCallback(void* data);
119 void showHandlesAndContextMenu();
121 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
122 void informTextStyleState();
126 EwkViewImpl* m_viewImpl;
127 TextSelectionHandle* m_leftHandle;
128 TextSelectionHandle* m_rightHandle;
129 TextSelectionMagnifier* m_magnifier;
130 bool m_isTextSelectionDowned;
131 bool m_isTextSelectionMode;
132 Ecore_Animator* m_moveAnimator;
133 Ecore_Timer* m_showTimer;
134 WebCore::IntRect m_lastLeftHandleRect;
135 WebCore::IntRect m_lastRightHandleRect;
136 #if ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
137 TextSelectionHandle* m_selectedHandle;
139 int m_handleMovingDirection;
142 } // namespace WebKit
144 #endif // TIZEN_WEBKIT2_TEXT_SELECTION
145 #endif // TextSelection_h