Index: Source/core/editing/CompositionUnderlineRangeFilter.cpp |
diff --git a/Source/core/editing/CompositionUnderlineRangeFilter.cpp b/Source/core/editing/CompositionUnderlineRangeFilter.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..cb532ba45f1e2ecd5cb1874bc75c5d250c31fbfa |
--- /dev/null |
+++ b/Source/core/editing/CompositionUnderlineRangeFilter.cpp |
@@ -0,0 +1,35 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "config.h" |
+#include "core/editing/CompositionUnderlineRangeFilter.h" |
+ |
+namespace WebCore { |
+ |
+int CompositionUnderlineRangeFilter::seekValidIndex(int index) |
+{ |
+ if (index < 0) |
+ return ConstIterator::END; |
+ |
+ size_t numUnderlines = m_underlines.size(); |
+ while (static_cast<size_t>(index) < numUnderlines) { |
+ const CompositionUnderline& underline = m_underlines[index]; |
+ |
+ if (underline.endOffset <= m_indexLo) { |
+ // underline is completely before interval. This may be an underline that appear |
huangs
2014/06/06 23:38:32
Remove comments about "runs".
huangs
2014/06/09 06:07:13
Done.
|
+ // before the first run, or may be a underline within current run that got |
+ // skipped due to truncation. |
+ ++index; |
+ } else if (underline.startOffset <= m_indexHi) { |
+ // underline intersects range. Process it. |
+ return index; |
+ } else { |
+ // underline is completely after this run, bail. |
+ break; |
+ } |
+ } |
+ return ConstIterator::END; |
+} |
+ |
+} // namespace WebCore |