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

Side by Side Diff: third_party/WebKit/Source/core/editing/InputMethodController.cpp

Issue 2611813002: Add support for persisting CompositionUnderlines in InputMethodController (Closed)
Patch Set: Try one more time Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 unsigned underlineEnd = offset + underline.endOffset(); 339 unsigned underlineEnd = offset + underline.endOffset();
340 340
341 EphemeralRange ephemeralLineRange = 341 EphemeralRange ephemeralLineRange =
342 PlainTextRange(underlineStart, underlineEnd) 342 PlainTextRange(underlineStart, underlineEnd)
343 .createRange(*rootEditableElement); 343 .createRange(*rootEditableElement);
344 if (ephemeralLineRange.isNull()) 344 if (ephemeralLineRange.isNull())
345 continue; 345 continue;
346 346
347 document().markers().addCompositionMarker( 347 document().markers().addCompositionMarker(
348 ephemeralLineRange.startPosition(), ephemeralLineRange.endPosition(), 348 ephemeralLineRange.startPosition(), ephemeralLineRange.endPosition(),
349 underline.color(), underline.thick(), underline.backgroundColor()); 349 underline.color(), underline.thick(), underline.backgroundColor(),
350 underline.persist());
350 } 351 }
351 } 352 }
352 353
353 bool InputMethodController::replaceCompositionAndMoveCaret( 354 bool InputMethodController::replaceCompositionAndMoveCaret(
354 const String& text, 355 const String& text,
355 int relativeCaretPosition, 356 int relativeCaretPosition,
356 const Vector<CompositionUnderline>& underlines) { 357 const Vector<CompositionUnderline>& underlines) {
357 Element* rootEditableElement = frame().selection().rootEditableElement(); 358 Element* rootEditableElement = frame().selection().rootEditableElement();
358 if (!rootEditableElement) 359 if (!rootEditableElement)
359 return false; 360 return false;
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 // needs to be audited. see http://crbug.com/590369 for more details. 605 // needs to be audited. see http://crbug.com/590369 for more details.
605 document().updateStyleAndLayoutIgnorePendingStylesheets(); 606 document().updateStyleAndLayoutIgnorePendingStylesheets();
606 607
607 // We shouldn't close typing in the middle of setComposition. 608 // We shouldn't close typing in the middle of setComposition.
608 setEditableSelectionOffsets(selectedRange, NotUserTriggered); 609 setEditableSelectionOffsets(selectedRange, NotUserTriggered);
609 610
610 if (underlines.isEmpty()) { 611 if (underlines.isEmpty()) {
611 document().markers().addCompositionMarker( 612 document().markers().addCompositionMarker(
612 m_compositionRange->startPosition(), m_compositionRange->endPosition(), 613 m_compositionRange->startPosition(), m_compositionRange->endPosition(),
613 Color::black, false, 614 Color::black, false,
614 LayoutTheme::theme().platformDefaultCompositionBackgroundColor()); 615 LayoutTheme::theme().platformDefaultCompositionBackgroundColor(),
616 false);
615 return; 617 return;
616 } 618 }
617 619
618 // Can't use addCompositionUnderlines here because the ranges are constructed 620 // Can't use addCompositionUnderlines here because the ranges are constructed
619 // differently 621 // differently
620 for (const auto& underline : underlines) { 622 for (const auto& underline : underlines) {
621 unsigned underlineStart = baseOffset + underline.startOffset(); 623 unsigned underlineStart = baseOffset + underline.startOffset();
622 unsigned underlineEnd = baseOffset + underline.endOffset(); 624 unsigned underlineEnd = baseOffset + underline.endOffset();
623 EphemeralRange ephemeralLineRange = EphemeralRange( 625 EphemeralRange ephemeralLineRange = EphemeralRange(
624 Position(baseNode, underlineStart), Position(baseNode, underlineEnd)); 626 Position(baseNode, underlineStart), Position(baseNode, underlineEnd));
625 if (ephemeralLineRange.isNull()) 627 if (ephemeralLineRange.isNull())
626 continue; 628 continue;
627 document().markers().addCompositionMarker( 629 document().markers().addCompositionMarker(
628 ephemeralLineRange.startPosition(), ephemeralLineRange.endPosition(), 630 ephemeralLineRange.startPosition(), ephemeralLineRange.endPosition(),
629 underline.color(), underline.thick(), underline.backgroundColor()); 631 underline.color(), underline.thick(), underline.backgroundColor(),
632 underline.persist());
630 } 633 }
631 } 634 }
632 635
633 PlainTextRange InputMethodController::createSelectionRangeForSetComposition( 636 PlainTextRange InputMethodController::createSelectionRangeForSetComposition(
634 int selectionStart, 637 int selectionStart,
635 int selectionEnd, 638 int selectionEnd,
636 size_t textLength) const { 639 size_t textLength) const {
637 const int selectionOffsetsStart = 640 const int selectionOffsetsStart =
638 static_cast<int>(getSelectionOffsets().start()); 641 static_cast<int>(getSelectionOffsets().start());
639 const int start = selectionOffsetsStart + selectionStart; 642 const int start = selectionOffsetsStart + selectionStart;
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 frame().chromeClient().resetInputMethod(); 1095 frame().chromeClient().resetInputMethod();
1093 } 1096 }
1094 1097
1095 DEFINE_TRACE(InputMethodController) { 1098 DEFINE_TRACE(InputMethodController) {
1096 visitor->trace(m_frame); 1099 visitor->trace(m_frame);
1097 visitor->trace(m_compositionRange); 1100 visitor->trace(m_compositionRange);
1098 SynchronousMutationObserver::trace(visitor); 1101 SynchronousMutationObserver::trace(visitor);
1099 } 1102 }
1100 1103
1101 } // namespace blink 1104 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698