1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
/*
* Copyright (C) 2010, 2011, 2012, 2013 Research In Motion Limited. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef SelectionHandler_h
#define SelectionHandler_h
#include "BlackBerryPlatformIntRectRegion.h"
#include "BlackBerryPlatformPrimitives.h"
#include "BlackBerryPlatformStopWatch.h"
#include "Color.h"
#include "TextGranularity.h"
#include <wtf/Vector.h>
namespace WTF {
class String;
}
namespace WebCore {
class FloatQuad;
class IntPoint;
class IntRect;
class Node;
class VisiblePosition;
class VisibleSelection;
}
namespace BlackBerry {
namespace Platform {
class String;
}
namespace WebKit {
class FatFingersResult;
class WebPagePrivate;
class SelectionHandler {
public:
SelectionHandler(WebPagePrivate*);
~SelectionHandler();
bool isSelectionActive() { return m_selectionActive; }
void setSelectionActive(bool active) { m_selectionActive = active; }
void cancelSelection();
BlackBerry::Platform::String selectedText() const;
bool selectionContains(const WebCore::IntPoint&);
void setSelection(WebCore::IntPoint start, WebCore::IntPoint end);
void selectAtPoint(const WebCore::IntPoint&, SelectionExpansionType);
void selectObject(const WebCore::IntPoint&, WebCore::TextGranularity);
void selectObject(WebCore::TextGranularity);
void selectObject(WebCore::Node*);
void selectionPositionChanged(bool forceUpdateWithoutChange = false);
void setCaretPosition(const WebCore::IntPoint&);
bool lastUpdatedEndPointIsValid() const { return m_lastUpdatedEndPointIsValid; }
void inputHandlerDidFinishProcessingChange();
void expandSelection(bool isScrollStarted);
void setOverlayExpansionHeight(int dy) { m_overlayExpansionHeight = dy; }
void setParagraphExpansionScrollMargin(const WebCore::IntSize&);
void setSelectionViewportSize(const WebCore::IntSize& selectionViewportSize) { m_selectionViewportSize = selectionViewportSize; }
void setSelectionSubframeViewportRect(const WebCore::IntRect& selectionSubframeViewportRect) { m_selectionSubframeViewportRect = selectionSubframeViewportRect; }
WebCore::IntRect selectionViewportRect() const;
private:
void notifyCaretPositionChangedIfNeeded(bool userTouchTriggeredOnTextField);
void caretPositionChanged(bool userTouchTriggered);
void regionForTextQuads(WTF::Vector<WebCore::FloatQuad>&, BlackBerry::Platform::IntRectRegion&, bool shouldClipToVisibleContent = true) const;
WebCore::IntRect clippingRectForVisibleContent() const;
bool updateOrHandleInputSelection(WebCore::VisibleSelection& newSelection, const WebCore::IntPoint& relativeStart, const WebCore::IntPoint& relativeEnd);
WebCore::Node* DOMContainerNodeForVisiblePosition(const WebCore::VisiblePosition&) const;
bool shouldUpdateSelectionOrCaretForPoint(const WebCore::IntPoint&, const WebCore::IntRect&, bool startCaret = true) const;
unsigned extendSelectionToFieldBoundary(bool isStartHandle, const WebCore::IntPoint& selectionPoint, WebCore::VisibleSelection& newSelection);
WebCore::IntPoint clipPointToVisibleContainer(const WebCore::IntPoint&) const;
void selectNextParagraph();
void drawAnimationOverlay(BlackBerry::Platform::IntRectRegion, bool isExpandingOverlayAtConstantRate, bool isStartOfSelection = false);
Platform::IntRectRegion regionForSelectionQuads(WebCore::VisibleSelection);
bool findNextAnimationOverlayRegion();
bool ensureSelectedTextVisible(const WebCore::IntPoint&, bool scrollIfNeeded);
bool expandSelectionToGranularity(WebCore::Frame*, WebCore::VisibleSelection, WebCore::TextGranularity, bool isInputMode);
bool inputNodeOverridesTouch() const;
BlackBerry::Platform::RequestedHandlePosition requestedSelectionHandlePosition(const WebCore::VisibleSelection&) const;
bool selectNodeIfFatFingersResultIsLink(FatFingersResult);
WebCore::IntRect startCaretViewportRect(const WebCore::IntPoint& frameOffset) const;
WebPagePrivate* m_webPage;
bool m_selectionActive;
bool m_caretActive;
bool m_lastUpdatedEndPointIsValid;
bool m_didSuppressCaretPositionChangedNotification;
BlackBerry::Platform::IntRectRegion m_lastSelectionRegion;
WebCore::VisiblePosition m_animationOverlayStartPos;
WebCore::VisiblePosition m_animationOverlayEndPos;
BlackBerry::Platform::IntRectRegion m_currentAnimationOverlayRegion;
BlackBerry::Platform::IntRectRegion m_nextAnimationOverlayRegion;
int m_overlayExpansionHeight;
WebCore::Color m_animationHighlightColor;
BlackBerry::Platform::StopWatch m_timer;
WebCore::IntSize m_scrollMargin;
WebCore::IntSize m_selectionViewportSize;
WebCore::IntRect m_selectionSubframeViewportRect;
WebCore::VisibleSelection m_lastSelection;
};
}
}
#endif // SelectionHandler_h
|