Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: public/web/WebSelection.h

Issue 929213004: Plumb selection bounds as a single unit (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix test Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef WebSelection_h
6 #define WebSelection_h
7
8 #include "../platform/WebCommon.h"
9 #include "../platform/WebSelectionBound.h"
10
11 namespace blink {
12
13 struct CompositedSelection;
14
15 // The active selection region, containing compositing data for the selection
16 // end points as well as metadata for the selection region.
17 class BLINK_EXPORT WebSelection {
18 public:
19 enum SelectionType { NoSelection, CaretSelection, RangeSelection };
20
21 #if INSIDE_BLINK
22 explicit WebSelection(const CompositedSelection&);
23 #endif
24 WebSelection(const WebSelection&);
25
26 const WebSelectionBound& base() const { return m_base; }
27 const WebSelectionBound& extent() const { return m_extent; }
28 const WebSelectionBound& start() const { return isBaseFirst() ? base() : ext ent(); }
29 const WebSelectionBound& end() const { return isBaseFirst() ? extent() : bas e(); }
30
31 bool isNone() const { return selectionType() == NoSelection; }
32 bool isCaret() const { return selectionType() == CaretSelection; }
33 bool isRange() const { return selectionType() == RangeSelection; }
34
35 bool isBaseFirst() const { return m_isBaseFirst; }
36 bool isEditable() const { return m_isEditable; }
37 bool isEmptyTextFormControl() const { return m_isEmptyTextFormControl; }
38
39 private:
40 SelectionType selectionType() const { return m_selectionType; }
41
42 SelectionType m_selectionType;
43
44 WebSelectionBound m_base;
45 WebSelectionBound m_extent;
46
47 // Whether |m_base| comes before |m_extent| in document position order.
48 bool m_isBaseFirst;
49
50 // Whether the selection region consists of editable text.
51 bool m_isEditable;
52
53 // Whether the selection resides in an empty text form control. Note that
54 // this only applies to caret-type selections.
55 bool m_isEmptyTextFormControl;
56 };
57
58 } // namespace blink
59
60 #endif // WebSelection_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698