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

Side by Side Diff: Source/web/WebSelection.cpp

Issue 929213004: Plumb selection bounds as a single unit (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: TODO for moving WebSelectionBound Created 5 years, 8 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
« no previous file with comments | « Source/web/ChromeClientImpl.cpp ('k') | Source/web/WebViewImpl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "config.h"
6
7 #include "public/web/WebSelection.h"
8
9 #include "core/editing/SelectionType.h"
10 #include "core/layout/compositing/CompositedSelection.h"
11
12 namespace blink {
13
14 static WebSelectionBound getWebSelectionBound(const CompositedSelection& selecti on, bool isStart)
15 {
16 ASSERT(selection.type != NoSelection);
17 const CompositedSelectionBound& bound = isStart ? selection.start : selectio n.end;
18 ASSERT(bound.layer);
19
20 WebSelectionBound::Type type = WebSelectionBound::Caret;
21 if (selection.type == RangeSelection) {
22 if (isStart)
23 type = bound.isTextDirectionRTL ? WebSelectionBound::SelectionRight : WebSelectionBound::SelectionLeft;
24 else
25 type = bound.isTextDirectionRTL ? WebSelectionBound::SelectionLeft : WebSelectionBound::SelectionRight;
26 }
27
28 WebSelectionBound result(type);
29 result.layerId = bound.layer->platformLayer()->id();
30 result.edgeTopInLayer = roundedIntPoint(bound.edgeTopInLayer);
31 result.edgeBottomInLayer = roundedIntPoint(bound.edgeBottomInLayer);
32 result.isTextDirectionRTL = bound.isTextDirectionRTL;
33 return result;
34 }
35
36 // SelectionType enums have the same values; enforced in AssertMatchingEnums.cpp .
37 WebSelection::WebSelection(const CompositedSelection& selection)
38 : m_selectionType(static_cast<WebSelection::SelectionType>(selection.type))
39 , m_start(getWebSelectionBound(selection, true))
40 , m_end(getWebSelectionBound(selection, false))
41 , m_isEditable(selection.isEditable)
42 , m_isEmptyTextFormControl(selection.isEmptyTextFormControl)
43 {
44 }
45
46 WebSelection::WebSelection(const WebSelection& other)
47 : m_selectionType(other.m_selectionType)
48 , m_start(other.m_start)
49 , m_end(other.m_end)
50 , m_isEditable(other.m_isEditable)
51 , m_isEmptyTextFormControl(other.m_isEmptyTextFormControl)
52 {
53 }
54
55 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/ChromeClientImpl.cpp ('k') | Source/web/WebViewImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698