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

Side by Side Diff: Source/core/editing/Editor.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/EditingUtilities.cpp ('k') | Source/core/editing/Position.h » ('j') | 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) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 return nullptr; 1195 return nullptr;
1196 1196
1197 RefPtrWillBeRawPtr<Range> rangeObject = Range::create(resultRange.docume nt(), toPositionInDOMTree(resultRange.startPosition()), toPositionInDOMTree(resu ltRange.endPosition())); 1197 RefPtrWillBeRawPtr<Range> rangeObject = Range::create(resultRange.docume nt(), toPositionInDOMTree(resultRange.startPosition()), toPositionInDOMTree(resu ltRange.endPosition()));
1198 if (!rangeObject->collapsed()) 1198 if (!rangeObject->collapsed())
1199 return rangeObject.release(); 1199 return rangeObject.release();
1200 1200
1201 // Found text spans over multiple TreeScopes. Since it's impossible to 1201 // Found text spans over multiple TreeScopes. Since it's impossible to
1202 // return such section as a Range, we skip this match and seek for the 1202 // return such section as a Range, we skip this match and seek for the
1203 // next occurrence. 1203 // next occurrence.
1204 // TODO(yosin) Handle this case. 1204 // TODO(yosin) Handle this case.
1205 if (forward) 1205 if (forward) {
1206 searchRange = EphemeralRangeTemplate<Strategy>(resultRange.startPosi tion().next(), searchRange.endPosition()); 1206 // TODO(yosin) We should use |PositionMoveType::Character|
1207 else 1207 // for |nextPositionOf()|.
1208 searchRange = EphemeralRangeTemplate<Strategy>(searchRange.startPosi tion(), resultRange.endPosition().previous()); 1208 searchRange = EphemeralRangeTemplate<Strategy>(nextPositionOf(result Range.startPosition(), PositionMoveType::CodePoint), searchRange.endPosition());
1209 } else {
1210 // TODO(yosin) We should use |PositionMoveType::Character|
1211 // for |previousPositionOf()|.
1212 searchRange = EphemeralRangeTemplate<Strategy>(searchRange.startPosi tion(), previousPositionOf(resultRange.endPosition(), PositionMoveType::CodePoin t));
1213 }
1209 } 1214 }
1210 1215
1211 ASSERT_NOT_REACHED(); 1216 ASSERT_NOT_REACHED();
1212 return nullptr; 1217 return nullptr;
1213 } 1218 }
1214 1219
1215 template <typename Strategy> 1220 template <typename Strategy>
1216 static PassRefPtrWillBeRawPtr<Range> findRangeOfStringAlgorithm(Document& docume nt, const String& target, const EphemeralRangeTemplate<Strategy>& referenceRange , FindOptions options) 1221 static PassRefPtrWillBeRawPtr<Range> findRangeOfStringAlgorithm(Document& docume nt, const String& target, const EphemeralRangeTemplate<Strategy>& referenceRange , FindOptions options)
1217 { 1222 {
1218 if (target.isEmpty()) 1223 if (target.isEmpty())
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 } 1301 }
1297 1302
1298 DEFINE_TRACE(Editor) 1303 DEFINE_TRACE(Editor)
1299 { 1304 {
1300 visitor->trace(m_frame); 1305 visitor->trace(m_frame);
1301 visitor->trace(m_lastEditCommand); 1306 visitor->trace(m_lastEditCommand);
1302 visitor->trace(m_mark); 1307 visitor->trace(m_mark);
1303 } 1308 }
1304 1309
1305 } // namespace blink 1310 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/EditingUtilities.cpp ('k') | Source/core/editing/Position.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698