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

Side by Side Diff: Source/wtf/text/TextPosition.cpp

Issue 835953003: Fix template angle bracket syntax (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 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/wtf/text/TextPosition.h ('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) 2013, Google Inc. All rights reserved. 2 * Copyright (C) 2013, Google 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 12 matching lines...) Expand all
23 */ 23 */
24 24
25 #include "config.h" 25 #include "config.h"
26 #include "wtf/text/TextPosition.h" 26 #include "wtf/text/TextPosition.h"
27 27
28 #include "wtf/PassOwnPtr.h" 28 #include "wtf/PassOwnPtr.h"
29 #include "wtf/StdLibExtras.h" 29 #include "wtf/StdLibExtras.h"
30 30
31 namespace WTF { 31 namespace WTF {
32 32
33 PassOwnPtr<Vector<unsigned> > lineEndings(const String& text) 33 PassOwnPtr<Vector<unsigned>> lineEndings(const String& text)
34 { 34 {
35 OwnPtr<Vector<unsigned> > result(adoptPtr(new Vector<unsigned>())); 35 OwnPtr<Vector<unsigned>> result(adoptPtr(new Vector<unsigned>()));
36 36
37 unsigned start = 0; 37 unsigned start = 0;
38 while (start < text.length()) { 38 while (start < text.length()) {
39 size_t lineEnd = text.find('\n', start); 39 size_t lineEnd = text.find('\n', start);
40 if (lineEnd == kNotFound) 40 if (lineEnd == kNotFound)
41 break; 41 break;
42 42
43 result->append(static_cast<unsigned>(lineEnd)); 43 result->append(static_cast<unsigned>(lineEnd));
44 start = lineEnd + 1; 44 start = lineEnd + 1;
45 } 45 }
(...skipping 11 matching lines...) Expand all
57 TextPosition TextPosition::fromOffsetAndLineEndings(unsigned offset, const Vecto r<unsigned>& lineEndings) 57 TextPosition TextPosition::fromOffsetAndLineEndings(unsigned offset, const Vecto r<unsigned>& lineEndings)
58 { 58 {
59 const unsigned* foundLineEnding = std::lower_bound(lineEndings.begin(), line Endings.end(), offset); 59 const unsigned* foundLineEnding = std::lower_bound(lineEndings.begin(), line Endings.end(), offset);
60 int lineIndex = foundLineEnding - &lineEndings.at(0); 60 int lineIndex = foundLineEnding - &lineEndings.at(0);
61 unsigned lineStartOffset = lineIndex > 0 ? lineEndings.at(lineIndex - 1) + 1 : 0; 61 unsigned lineStartOffset = lineIndex > 0 ? lineEndings.at(lineIndex - 1) + 1 : 0;
62 int column = offset - lineStartOffset; 62 int column = offset - lineStartOffset;
63 return TextPosition(OrdinalNumber::fromZeroBasedInt(lineIndex), OrdinalNumbe r::fromZeroBasedInt(column)); 63 return TextPosition(OrdinalNumber::fromZeroBasedInt(lineIndex), OrdinalNumbe r::fromZeroBasedInt(column));
64 } 64 }
65 65
66 } // namespace WTF 66 } // namespace WTF
OLDNEW
« no previous file with comments | « Source/wtf/text/TextPosition.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698