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

Side by Side Diff: Source/core/layout/PendingSelection.cpp

Issue 1319753004: Introduce composed tree version of VisiblePosition (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-09-07T14:06:02 Rebase for VisibleSelectionChangeObserver and PendingSelection::commit Created 5 years, 3 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/core/editing/serializers/StyledMarkupSerializer.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 template <typename Strategy> 79 template <typename Strategy>
80 VisibleSelection PendingSelection::calcVisibleSelectionAlgorithm() const 80 VisibleSelection PendingSelection::calcVisibleSelectionAlgorithm() const
81 { 81 {
82 using PositionType = typename Strategy::PositionType; 82 using PositionType = typename Strategy::PositionType;
83 83
84 PositionType start = Strategy::selectionStart(m_selection); 84 PositionType start = Strategy::selectionStart(m_selection);
85 PositionType end = Strategy::selectionEnd(m_selection); 85 PositionType end = Strategy::selectionEnd(m_selection);
86 SelectionType selectionType = Strategy::selectionType(m_selection); 86 SelectionType selectionType = Strategy::selectionType(m_selection);
87 TextAffinity affinity = m_selection.affinity(); 87 TextAffinity affinity = m_selection.affinity();
88 88
89 bool paintBlockCursor = m_shouldShowBlockCursor && selectionType == Selectio nType::CaretSelection && !isLogicalEndOfLine(createVisiblePosition(end, affinity )); 89 bool paintBlockCursor = m_shouldShowBlockCursor && selectionType == Selectio nType::CaretSelection && !isLogicalEndOfLine(createVisiblePositionInDOMTree(end, affinity));
90 VisibleSelection selection; 90 VisibleSelection selection;
91 if (enclosingTextFormControl(start.computeContainerNode())) { 91 if (enclosingTextFormControl(start.computeContainerNode())) {
92 // TODO(yosin) We should use |PositionMoveType::Character| to avoid 92 // TODO(yosin) We should use |PositionMoveType::Character| to avoid
93 // ending paint at middle of character. 93 // ending paint at middle of character.
94 PositionType endPosition = paintBlockCursor ? nextPositionOf(Strategy::s electionExtent(m_selection), PositionMoveType::CodePoint) : end; 94 PositionType endPosition = paintBlockCursor ? nextPositionOf(Strategy::s electionExtent(m_selection), PositionMoveType::CodePoint) : end;
95 selection.setWithoutValidation(start, endPosition); 95 selection.setWithoutValidation(start, endPosition);
96 return selection; 96 return selection;
97 } 97 }
98 98
99 VisiblePosition visibleStart = createVisiblePosition(start, selectionType == SelectionType::RangeSelection ? TextAffinity::Downstream : affinity); 99 VisiblePosition visibleStart = createVisiblePositionInDOMTree(start, selecti onType == SelectionType::RangeSelection ? TextAffinity::Downstream : affinity);
100 if (paintBlockCursor) { 100 if (paintBlockCursor) {
101 VisiblePosition visibleExtent = createVisiblePosition(end, affinity); 101 VisiblePosition visibleExtent = createVisiblePositionInDOMTree(end, affi nity);
102 visibleExtent = nextPositionOf(visibleExtent, CanSkipOverEditingBoundary ); 102 visibleExtent = nextPositionOf(visibleExtent, CanSkipOverEditingBoundary );
103 return VisibleSelection(visibleStart, visibleExtent); 103 return VisibleSelection(visibleStart, visibleExtent);
104 } 104 }
105 VisiblePosition visibleEnd = createVisiblePosition(end, selectionType == Sel ectionType::RangeSelection ? TextAffinity::Upstream : affinity); 105 VisiblePosition visibleEnd = createVisiblePositionInDOMTree(end, selectionTy pe == SelectionType::RangeSelection ? TextAffinity::Upstream : affinity);
106 return VisibleSelection(visibleStart, visibleEnd); 106 return VisibleSelection(visibleStart, visibleEnd);
107 } 107 }
108 108
109 template <typename Strategy> 109 template <typename Strategy>
110 void PendingSelection::commitAlgorithm(LayoutView& layoutView) 110 void PendingSelection::commitAlgorithm(LayoutView& layoutView)
111 { 111 {
112 using PositionType = typename Strategy::PositionType; 112 using PositionType = typename Strategy::PositionType;
113 113
114 if (!hasPendingSelection()) 114 if (!hasPendingSelection())
115 return; 115 return;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 return commitAlgorithm<VisibleSelection::InComposedTree>(layoutView); 167 return commitAlgorithm<VisibleSelection::InComposedTree>(layoutView);
168 commitAlgorithm<VisibleSelection::InDOMTree>(layoutView); 168 commitAlgorithm<VisibleSelection::InDOMTree>(layoutView);
169 } 169 }
170 170
171 DEFINE_TRACE(PendingSelection) 171 DEFINE_TRACE(PendingSelection)
172 { 172 {
173 visitor->trace(m_selection); 173 visitor->trace(m_selection);
174 } 174 }
175 175
176 } // namespace blink 176 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/serializers/StyledMarkupSerializer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698