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..79eabf13d51518b68072f545921572f4ce71bdb3 |
--- /dev/null |
+++ b/Source/core/editing/CompositionUnderlineRangeFilter.cpp |
@@ -0,0 +1,33 @@ |
+// 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 { |
+ |
+size_t CompositionUnderlineRangeFilter::seekValidIndex(size_t index) |
+{ |
+ if (index == kNotFound) |
+ return kNotFound; |
+ |
+ 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 the query range: keep on looking. |
+ ++index; |
+ } else if (underline.startOffset <= m_indexHi) { |
+ // |underline| intersects with the query range: found valid and return. |
+ return index; |
+ } else { |
+ // |underline| is completely after the query range: bail. |
+ break; |
+ } |
+ } |
+ return kNotFound; |
+} |
+ |
+} // namespace WebCore |