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

Unified Diff: Source/core/editing/CompositionUnderlineRangeFilter.cpp

Issue 1330233003: Revert of Avoid style clobbering in setCompositionFromExistingText. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 3 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/core/editing/CompositionUnderlineRangeFilter.cpp
diff --git a/Source/core/editing/CompositionUnderlineRangeFilter.cpp b/Source/core/editing/CompositionUnderlineRangeFilter.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..083b35bd8847b9fb37f34f1625d75b72783d733c
--- /dev/null
+++ b/Source/core/editing/CompositionUnderlineRangeFilter.cpp
@@ -0,0 +1,39 @@
+// 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 blink {
+
+CompositionUnderlineRangeFilter::CompositionUnderlineRangeFilter(const Vector<CompositionUnderline>& underlines, size_t indexLo, size_t indexHi)
+ : m_underlines(underlines)
+ , m_indexLo(indexLo)
+ , m_indexHi(indexHi)
+ , m_theEnd(this, kNotFound) { }
+
+size_t CompositionUnderlineRangeFilter::seekValidIndex(size_t index)
+{
+ if (index == kNotFound)
+ return kNotFound;
+
+ size_t numUnderlines = m_underlines.size();
+ while (index < numUnderlines) {
+ const CompositionUnderline& underline = m_underlines[index];
+
+ if (underline.endOffset <= m_indexLo) {
+ // |underline| lies before the query range: keep on looking.
+ ++index;
+ } else if (underline.startOffset <= m_indexHi) {
+ // |underline| intersects with the query range: valid, so return.
+ return index;
+ } else {
+ // |underline| is completely after the query range: bail.
+ break;
+ }
+ }
+ return kNotFound;
+}
+
+} // namespace blink
« no previous file with comments | « Source/core/editing/CompositionUnderlineRangeFilter.h ('k') | Source/core/editing/CompositionUnderlineRangeFilterTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698