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

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

Issue 1984593002: Remove OwnPtr::release() calls in web/ & wtf/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with trunk. 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
« no previous file with comments | « third_party/WebKit/Source/wtf/VectorTest.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) 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 27 matching lines...) Expand all
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 }
46 result->append(text.length()); 46 result->append(text.length());
47 47
48 return result.release(); 48 return result;
49 } 49 }
50 50
51 OrdinalNumber TextPosition::toOffset(const Vector<unsigned>& lineEndings) 51 OrdinalNumber TextPosition::toOffset(const Vector<unsigned>& lineEndings)
52 { 52 {
53 unsigned lineStartOffset = m_line != OrdinalNumber::first() ? lineEndings.at (m_line.zeroBasedInt() - 1) + 1 : 0; 53 unsigned lineStartOffset = m_line != OrdinalNumber::first() ? lineEndings.at (m_line.zeroBasedInt() - 1) + 1 : 0;
54 return OrdinalNumber::fromZeroBasedInt(lineStartOffset + m_column.zeroBasedI nt()); 54 return OrdinalNumber::fromZeroBasedInt(lineStartOffset + m_column.zeroBasedI nt());
55 } 55 }
56 56
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 | « third_party/WebKit/Source/wtf/VectorTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698