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

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

Issue 1305963003: Introduce {next,previous}PositionOf() as replacement of {next,previous}() member functions in Positi (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-22T00:12:04 Rebase Created 5 years, 4 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/commands/TypingCommand.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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 using PositionType = typename Strategy::PositionType; 80 using PositionType = typename Strategy::PositionType;
81 81
82 PositionType start = Strategy::selectionStart(m_selection); 82 PositionType start = Strategy::selectionStart(m_selection);
83 PositionType end = Strategy::selectionEnd(m_selection); 83 PositionType end = Strategy::selectionEnd(m_selection);
84 SelectionType selectionType = VisibleSelection::selectionType(start, end); 84 SelectionType selectionType = VisibleSelection::selectionType(start, end);
85 TextAffinity affinity = m_selection.affinity(); 85 TextAffinity affinity = m_selection.affinity();
86 86
87 bool paintBlockCursor = m_shouldShowBlockCursor && selectionType == Selectio nType::CaretSelection && !isLogicalEndOfLine(VisiblePosition(end, affinity)); 87 bool paintBlockCursor = m_shouldShowBlockCursor && selectionType == Selectio nType::CaretSelection && !isLogicalEndOfLine(VisiblePosition(end, affinity));
88 VisibleSelection selection; 88 VisibleSelection selection;
89 if (enclosingTextFormControl(start.computeContainerNode())) { 89 if (enclosingTextFormControl(start.computeContainerNode())) {
90 PositionType endPosition = paintBlockCursor ? Strategy::selectionExtent( m_selection).next() : end; 90 // TODO(yosin) We should use |PositionMoveType::Character| to avoid
91 // ending paint at middle of character.
92 PositionType endPosition = paintBlockCursor ? nextPositionOf(Strategy::s electionExtent(m_selection), PositionMoveType::CodePoint) : end;
91 selection.setWithoutValidation(start, endPosition); 93 selection.setWithoutValidation(start, endPosition);
92 return selection; 94 return selection;
93 } 95 }
94 96
95 VisiblePosition visibleStart = VisiblePosition(start, selectionType == Selec tionType::RangeSelection ? TextAffinity::Downstream : affinity); 97 VisiblePosition visibleStart = VisiblePosition(start, selectionType == Selec tionType::RangeSelection ? TextAffinity::Downstream : affinity);
96 if (paintBlockCursor) { 98 if (paintBlockCursor) {
97 VisiblePosition visibleExtent(end, affinity); 99 VisiblePosition visibleExtent(end, affinity);
98 visibleExtent = visibleExtent.next(CanSkipOverEditingBoundary); 100 visibleExtent = visibleExtent.next(CanSkipOverEditingBoundary);
99 return VisibleSelection(visibleStart, visibleExtent); 101 return VisibleSelection(visibleStart, visibleExtent);
100 } 102 }
101 VisiblePosition visibleEnd(end, selectionType == SelectionType::RangeSelecti on ? TextAffinity::Upstream : affinity); 103 VisiblePosition visibleEnd(end, selectionType == SelectionType::RangeSelecti on ? TextAffinity::Upstream : affinity);
102 return VisibleSelection(visibleStart, visibleEnd); 104 return VisibleSelection(visibleStart, visibleEnd);
103 } 105 }
104 106
105 VisibleSelection PendingSelection::calcVisibleSelection() const 107 VisibleSelection PendingSelection::calcVisibleSelection() const
106 { 108 {
107 if (RuntimeEnabledFeatures::selectionForComposedTreeEnabled()) 109 if (RuntimeEnabledFeatures::selectionForComposedTreeEnabled())
108 return calcVisibleSelectionAlgorithm<VisibleSelection::InComposedTree>() ; 110 return calcVisibleSelectionAlgorithm<VisibleSelection::InComposedTree>() ;
109 return calcVisibleSelectionAlgorithm<VisibleSelection::InDOMTree>(); 111 return calcVisibleSelectionAlgorithm<VisibleSelection::InDOMTree>();
110 } 112 }
111 113
112 DEFINE_TRACE(PendingSelection) 114 DEFINE_TRACE(PendingSelection)
113 { 115 {
114 visitor->trace(m_selection); 116 visitor->trace(m_selection);
115 } 117 }
116 118
117 } // namespace blink 119 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/commands/TypingCommand.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698