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

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

Issue 313233002: Adding backgroundColor to WebCompositionUnderline and using it for InlineTextBox drawing. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removing over-eager cleanups; adding CompositionUnderlineRangeFilter::operator->(). Created 6 years, 6 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..e87f0e52696b23aea88dd70fa9b0f49e23ce9907
--- /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 WebCore {
+
+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 (static_cast<size_t>(index) < numUnderlines) {
tkent 2014/06/13 04:31:43 static_cast<> is unnecessary.
huangs 2014/06/13 17:22:24 Done.
+ 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

Powered by Google App Engine
This is Rietveld 408576698