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

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

Issue 172593003: DevTools: [CSS] Add CSS.editRangeInStyleSheetText() to the protocol (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix glitch Created 6 years, 9 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
Index: Source/wtf/text/TextPosition.cpp
diff --git a/Source/wtf/text/TextPosition.cpp b/Source/wtf/text/TextPosition.cpp
index d220fcb74776102becf428697bb88b18aa6afab7..774e2ed0ab3211c832cc196874c5ce620c4a1a86 100644
--- a/Source/wtf/text/TextPosition.cpp
+++ b/Source/wtf/text/TextPosition.cpp
@@ -48,6 +48,12 @@ PassOwnPtr<Vector<unsigned> > lineEndings(const String& text)
return result.release();
}
+OrdinalNumber TextPosition::toOffsetPosition(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);
« Source/core/inspector/InspectorStyleSheet.cpp ('K') | « Source/wtf/text/TextPosition.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698