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
|
/*
* Copyright (C) 2010, 2011, 2012 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 "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 WebKit {
class WebPagePrivate;
class WebString;
class SelectionHandler {
public:
SelectionHandler(WebPagePrivate*);
~SelectionHandler();
bool isSelectionActive() { return m_selectionActive; }
void setSelectionActive(bool active) { m_selectionActive = active; }
void cancelSelection();
WebString selectedText() const;
bool selectionContains(const WebCore::IntPoint&);
void setSelection(const WebCore::IntPoint& start, const WebCore::IntPoint& end);
void selectAtPoint(const WebCore::IntPoint&);
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; }
private:
void caretPositionChanged();
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 short extendSelectionToFieldBoundary(bool isStartHandle, const WebCore::IntPoint& selectionPoint, WebCore::VisibleSelection& newSelection);
WebCore::IntPoint clipPointToVisibleContainer(const WebCore::IntPoint&) const;
bool inputNodeOverridesTouch() const;
WebPagePrivate* m_webPage;
bool m_selectionActive;
bool m_caretActive;
bool m_lastUpdatedEndPointIsValid;
BlackBerry::Platform::IntRectRegion m_lastSelectionRegion;
BlackBerry::Platform::StopWatch m_timer;
};
}
}
#endif // SelectionHandler_h
|