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

Unified Diff: third_party/WebKit/Source/core/editing/InputMethodController.cpp

Issue 2650113004: [WIP] Add support for Android SuggestionSpans when editing text (Closed)
Patch Set: Uploading the latest version from my repo so I can reference it Created 3 years, 8 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: third_party/WebKit/Source/core/editing/InputMethodController.cpp
diff --git a/third_party/WebKit/Source/core/editing/InputMethodController.cpp b/third_party/WebKit/Source/core/editing/InputMethodController.cpp
index 25da582651273e7d468b5a740df367e8e6e3667a..a556f7af02c9ecc122b93c8d40fbcd97c1b8f093 100644
--- a/third_party/WebKit/Source/core/editing/InputMethodController.cpp
+++ b/third_party/WebKit/Source/core/editing/InputMethodController.cpp
@@ -33,6 +33,7 @@
#include "core/dom/Text.h"
#include "core/editing/EditingUtilities.h"
#include "core/editing/Editor.h"
+#include "core/editing/TextSuggestionController.h"
#include "core/editing/commands/TypingCommand.h"
#include "core/editing/markers/DocumentMarkerController.h"
#include "core/editing/state_machines/BackwardCodePointStateMachine.h"
@@ -71,10 +72,6 @@ void dispatchCompositionEndEvent(LocalFrame& frame, const String& text) {
}
bool needsIncrementalInsertion(const LocalFrame& frame, const String& newText) {
- // No need to apply incremental insertion if it doesn't support formated text.
- if (!frame.editor().canEditRichly())
- return false;
-
// No need to apply incremental insertion if the old text (text to be
// replaced) or the new text (text to be inserted) is empty.
if (frame.selectedText().isEmpty() || newText.isEmpty())
@@ -443,9 +440,16 @@ void InputMethodController::addCompositionUnderlines(
if (ephemeralLineRange.isNull())
continue;
- document().markers().addCompositionMarker(
- ephemeralLineRange, underline.color(), underline.thick(),
- underline.backgroundColor());
+ if (underline.suggestions().isEmpty()) {
+ document().markers().addCompositionMarker(
+ ephemeralLineRange, underline.color(), underline.thick(),
+ underline.backgroundColor());
+ } else {
+ document().markers().addSuggestionMarker(
+ ephemeralLineRange,
+ underline.color(), underline.thick(), underline.backgroundColor(),
+ underline.suggestions());
+ }
}
}
@@ -465,6 +469,7 @@ bool InputMethodController::replaceCompositionAndMoveCaret(
PlainTextRange::create(*rootEditableElement, *m_compositionRange);
if (compositionRange.isNull())
return false;
+
int textStart = compositionRange.start();
if (!replaceComposition(text))
@@ -496,6 +501,7 @@ bool InputMethodController::insertTextAndMoveCaret(
PlainTextRange selectionRange = getSelectionOffsets();
if (selectionRange.isNull())
return false;
+
int textStart = selectionRange.start();
if (text.length()) {
@@ -690,6 +696,11 @@ void InputMethodController::setComposition(
setEditableSelectionOffsets(selectedRange, NotUserTriggered);
if (underlines.isEmpty()) {
+ // Don't add black underline when suggestion menu is open, the suggestion
+ // range already gets an underline
+ if (frame().textSuggestionController().suggestionMenuIsOpen())
+ return;
+
document().markers().addCompositionMarker(
EphemeralRange(m_compositionRange), Color::black, false,
LayoutTheme::theme().platformDefaultCompositionBackgroundColor());

Powered by Google App Engine
This is Rietveld 408576698