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

Side by Side Diff: third_party/WebKit/Source/core/editing/SelectionAdjuster.cpp

Issue 1997563002: Get rid of a redundant function alias positionBeforeNode() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-05-19T22:35:34 rebase Created 4 years, 7 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
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 99
100 Position adjustPositionForEnd(const Position& currentPosition, Node* startContai nerNode) 100 Position adjustPositionForEnd(const Position& currentPosition, Node* startContai nerNode)
101 { 101 {
102 TreeScope& treeScope = startContainerNode->treeScope(); 102 TreeScope& treeScope = startContainerNode->treeScope();
103 103
104 DCHECK(currentPosition.computeContainerNode()->treeScope() != treeScope); 104 DCHECK(currentPosition.computeContainerNode()->treeScope() != treeScope);
105 105
106 if (Node* ancestor = treeScope.ancestorInThisScope(currentPosition.computeCo ntainerNode())) { 106 if (Node* ancestor = treeScope.ancestorInThisScope(currentPosition.computeCo ntainerNode())) {
107 if (ancestor->contains(startContainerNode)) 107 if (ancestor->contains(startContainerNode))
108 return Position::afterNode(ancestor); 108 return Position::afterNode(ancestor);
109 return positionBeforeNode(ancestor); 109 return Position::beforeNode(ancestor);
110 } 110 }
111 111
112 if (Node* lastChild = treeScope.rootNode().lastChild()) 112 if (Node* lastChild = treeScope.rootNode().lastChild())
113 return Position::afterNode(lastChild); 113 return Position::afterNode(lastChild);
114 114
115 return Position(); 115 return Position();
116 } 116 }
117 117
118 PositionInFlatTree adjustPositionInFlatTreeForEnd(const PositionInFlatTree& posi tion, Node* shadowHost) 118 PositionInFlatTree adjustPositionInFlatTreeForEnd(const PositionInFlatTree& posi tion, Node* shadowHost)
119 { 119 {
(...skipping 12 matching lines...) Expand all
132 } 132 }
133 133
134 Position adjustPositionForStart(const Position& currentPosition, Node* endContai nerNode) 134 Position adjustPositionForStart(const Position& currentPosition, Node* endContai nerNode)
135 { 135 {
136 TreeScope& treeScope = endContainerNode->treeScope(); 136 TreeScope& treeScope = endContainerNode->treeScope();
137 137
138 DCHECK(currentPosition.computeContainerNode()->treeScope() != treeScope); 138 DCHECK(currentPosition.computeContainerNode()->treeScope() != treeScope);
139 139
140 if (Node* ancestor = treeScope.ancestorInThisScope(currentPosition.computeCo ntainerNode())) { 140 if (Node* ancestor = treeScope.ancestorInThisScope(currentPosition.computeCo ntainerNode())) {
141 if (ancestor->contains(endContainerNode)) 141 if (ancestor->contains(endContainerNode))
142 return positionBeforeNode(ancestor); 142 return Position::beforeNode(ancestor);
143 return Position::afterNode(ancestor); 143 return Position::afterNode(ancestor);
144 } 144 }
145 145
146 if (Node* firstChild = treeScope.rootNode().firstChild()) 146 if (Node* firstChild = treeScope.rootNode().firstChild())
147 return positionBeforeNode(firstChild); 147 return Position::beforeNode(firstChild);
148 148
149 return Position(); 149 return Position();
150 } 150 }
151 151
152 } // namespace 152 } // namespace
153 153
154 // Updates |selectionInFlatTree| to match with |selection|. 154 // Updates |selectionInFlatTree| to match with |selection|.
155 void SelectionAdjuster::adjustSelectionInFlatTree(VisibleSelectionInFlatTree* se lectionInFlatTree, const VisibleSelection& selection) 155 void SelectionAdjuster::adjustSelectionInFlatTree(VisibleSelectionInFlatTree* se lectionInFlatTree, const VisibleSelection& selection)
156 { 156 {
157 if (selection.isNone()) { 157 if (selection.isNone()) {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 selection->m_end = newEnd; 270 selection->m_end = newEnd;
271 return; 271 return;
272 } 272 }
273 Node* const shadowHost = shadowHostEnd ? shadowHostEnd : shadowHostStart; 273 Node* const shadowHost = shadowHostEnd ? shadowHostEnd : shadowHostStart;
274 const PositionInFlatTree& newStart = adjustPositionInFlatTreeForStart(select ion->start(), shadowHost); 274 const PositionInFlatTree& newStart = adjustPositionInFlatTreeForStart(select ion->start(), shadowHost);
275 selection->m_extent = newStart; 275 selection->m_extent = newStart;
276 selection->m_start = newStart; 276 selection->m_start = newStart;
277 } 277 }
278 278
279 } // namespace blink 279 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/Position.cpp ('k') | third_party/WebKit/Source/core/editing/SelectionModifier.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698