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

Unified Diff: third_party/WebKit/Source/wtf/text/TextPosition.cpp

Issue 1611343002: wtf reformat test Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pydent Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/wtf/text/TextPosition.h ('k') | third_party/WebKit/Source/wtf/text/UTF8.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/text/TextPosition.cpp
diff --git a/third_party/WebKit/Source/wtf/text/TextPosition.cpp b/third_party/WebKit/Source/wtf/text/TextPosition.cpp
index 27e79f8d5fca42c7418318940319d1b6e9b7ebb8..2f2e1430f3f4d232bfc07c68d44ee6bd701eb9f2 100644
--- a/third_party/WebKit/Source/wtf/text/TextPosition.cpp
+++ b/third_party/WebKit/Source/wtf/text/TextPosition.cpp
@@ -30,37 +30,42 @@
namespace WTF {
-PassOwnPtr<Vector<unsigned>> lineEndings(const String& text)
-{
- OwnPtr<Vector<unsigned>> result(adoptPtr(new Vector<unsigned>()));
+PassOwnPtr<Vector<unsigned>> lineEndings(const String& text) {
+ OwnPtr<Vector<unsigned>> result(adoptPtr(new Vector<unsigned>()));
- unsigned start = 0;
- while (start < text.length()) {
- size_t lineEnd = text.find('\n', start);
- if (lineEnd == kNotFound)
- break;
+ unsigned start = 0;
+ while (start < text.length()) {
+ size_t lineEnd = text.find('\n', start);
+ if (lineEnd == kNotFound)
+ break;
- result->append(static_cast<unsigned>(lineEnd));
- start = lineEnd + 1;
- }
- result->append(text.length());
+ result->append(static_cast<unsigned>(lineEnd));
+ start = lineEnd + 1;
+ }
+ result->append(text.length());
- return result.release();
+ return result.release();
}
-OrdinalNumber TextPosition::toOffset(const Vector<unsigned>& lineEndings)
-{
- unsigned lineStartOffset = m_line != OrdinalNumber::first() ? lineEndings.at(m_line.zeroBasedInt() - 1) + 1 : 0;
- return OrdinalNumber::fromZeroBasedInt(lineStartOffset + m_column.zeroBasedInt());
+OrdinalNumber TextPosition::toOffset(const Vector<unsigned>& lineEndings) {
+ unsigned lineStartOffset = m_line != OrdinalNumber::first()
+ ? lineEndings.at(m_line.zeroBasedInt() - 1) + 1
+ : 0;
+ return OrdinalNumber::fromZeroBasedInt(lineStartOffset +
+ m_column.zeroBasedInt());
}
-TextPosition TextPosition::fromOffsetAndLineEndings(unsigned offset, const Vector<unsigned>& lineEndings)
-{
- const unsigned* foundLineEnding = std::lower_bound(lineEndings.begin(), lineEndings.end(), offset);
- int lineIndex = foundLineEnding - &lineEndings.at(0);
- unsigned lineStartOffset = lineIndex > 0 ? lineEndings.at(lineIndex - 1) + 1 : 0;
- int column = offset - lineStartOffset;
- return TextPosition(OrdinalNumber::fromZeroBasedInt(lineIndex), OrdinalNumber::fromZeroBasedInt(column));
+TextPosition TextPosition::fromOffsetAndLineEndings(
+ unsigned offset,
+ const Vector<unsigned>& lineEndings) {
+ const unsigned* foundLineEnding =
+ std::lower_bound(lineEndings.begin(), lineEndings.end(), offset);
+ int lineIndex = foundLineEnding - &lineEndings.at(0);
+ unsigned lineStartOffset =
+ lineIndex > 0 ? lineEndings.at(lineIndex - 1) + 1 : 0;
+ int column = offset - lineStartOffset;
+ return TextPosition(OrdinalNumber::fromZeroBasedInt(lineIndex),
+ OrdinalNumber::fromZeroBasedInt(column));
}
-} // namespace WTF
+} // namespace WTF
« no previous file with comments | « third_party/WebKit/Source/wtf/text/TextPosition.h ('k') | third_party/WebKit/Source/wtf/text/UTF8.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698