[BlackBerry] Fix usage of HitTestRequest::RequestType
[WebKit-https.git] / Source / WebKit / blackberry / WebKitSupport / SelectionHandler.h
1 /*
2  * Copyright (C) 2010, 2011, 2012 Research In Motion Limited. All rights reserved.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17  */
18
19 #ifndef SelectionHandler_h
20 #define SelectionHandler_h
21
22 #include "BlackBerryPlatformIntRectRegion.h"
23 #include "BlackBerryPlatformPrimitives.h"
24 #include "BlackBerryPlatformStopWatch.h"
25 #include "TextGranularity.h"
26
27 #include <wtf/Vector.h>
28
29 namespace WTF {
30 class String;
31 }
32
33 namespace WebCore {
34 class FloatQuad;
35 class IntPoint;
36 class IntRect;
37 class Node;
38 class VisiblePosition;
39 class VisibleSelection;
40 }
41
42 namespace BlackBerry {
43 namespace Platform {
44 class String;
45 }
46
47 namespace WebKit {
48
49 class FatFingersResult;
50 class WebPagePrivate;
51
52 class SelectionHandler {
53 public:
54     SelectionHandler(WebPagePrivate*);
55     ~SelectionHandler();
56
57     bool isSelectionActive() { return m_selectionActive; }
58     void setSelectionActive(bool active) { m_selectionActive = active; }
59
60     void cancelSelection();
61     BlackBerry::Platform::String selectedText() const;
62
63     bool selectionContains(const WebCore::IntPoint&);
64
65     void setSelection(const WebCore::IntPoint& start, const WebCore::IntPoint& end);
66     void selectAtPoint(const WebCore::IntPoint&);
67     void selectObject(const WebCore::IntPoint&, WebCore::TextGranularity);
68     void selectObject(WebCore::TextGranularity);
69     void selectObject(WebCore::Node*);
70
71     void selectionPositionChanged(bool forceUpdateWithoutChange = false);
72
73     void setCaretPosition(const WebCore::IntPoint&);
74
75     bool lastUpdatedEndPointIsValid() const { return m_lastUpdatedEndPointIsValid; }
76
77     void inputHandlerDidFinishProcessingChange();
78
79 private:
80     void notifyCaretPositionChangedIfNeeded(bool userTouchTriggered = true);
81     void caretPositionChanged(bool userTouchTriggered);
82     void regionForTextQuads(WTF::Vector<WebCore::FloatQuad>&, BlackBerry::Platform::IntRectRegion&, bool shouldClipToVisibleContent = true) const;
83     WebCore::IntRect clippingRectForVisibleContent() const;
84     bool updateOrHandleInputSelection(WebCore::VisibleSelection& newSelection, const WebCore::IntPoint& relativeStart
85                                       , const WebCore::IntPoint& relativeEnd);
86     WebCore::Node* DOMContainerNodeForVisiblePosition(const WebCore::VisiblePosition&) const;
87     bool shouldUpdateSelectionOrCaretForPoint(const WebCore::IntPoint&, const WebCore::IntRect&, bool startCaret = true) const;
88     unsigned extendSelectionToFieldBoundary(bool isStartHandle, const WebCore::IntPoint& selectionPoint, WebCore::VisibleSelection& newSelection);
89     WebCore::IntPoint clipPointToVisibleContainer(const WebCore::IntPoint&) const;
90
91     bool inputNodeOverridesTouch() const;
92
93     bool selectNodeIfFatFingersResultIsLink(FatFingersResult);
94
95     WebPagePrivate* m_webPage;
96
97     bool m_selectionActive;
98     bool m_caretActive;
99     bool m_lastUpdatedEndPointIsValid;
100     bool m_didSuppressCaretPositionChangedNotification;
101     BlackBerry::Platform::IntRectRegion m_lastSelectionRegion;
102
103     BlackBerry::Platform::StopWatch m_timer;
104 };
105
106 }
107 }
108
109 #endif // SelectionHandler_h