Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 frame().selection().setSelection( | 241 frame().selection().setSelection( |
| 242 SelectionInDOMTree::Builder().setBaseAndExtent(range).build(), 0); | 242 SelectionInDOMTree::Builder().setBaseAndExtent(range).build(), 0); |
| 243 } | 243 } |
| 244 | 244 |
| 245 bool InputMethodController::finishComposingText( | 245 bool InputMethodController::finishComposingText( |
| 246 ConfirmCompositionBehavior confirmBehavior) { | 246 ConfirmCompositionBehavior confirmBehavior) { |
| 247 if (!hasComposition()) | 247 if (!hasComposition()) |
| 248 return false; | 248 return false; |
| 249 | 249 |
| 250 if (confirmBehavior == KeepSelection) { | 250 if (confirmBehavior == KeepSelection) { |
| 251 PlainTextRange oldOffsets = getSelectionOffsets(); | 251 // Do not dismiss handles even if we are moving selection, because we will |
| 252 // eventually move back to the old selection offsets. | |
| 253 bool isHandleVisible = frame().selection().isHandleVisible(); | |
|
yosin_UTC9
2017/01/25 03:49:08
s/bool/const bool/
Changwan Ryu
2017/02/08 00:40:33
Done.
| |
| 254 EphemeralRange oldSelectionRange = | |
|
yosin_UTC9
2017/01/25 03:49:08
s/EphemeralRange/const EphemeralRange&/
Changwan Ryu
2017/02/08 00:40:33
Done.
| |
| 255 ephemeralRangeForOffsets(getSelectionOffsets()); | |
| 256 | |
| 252 Editor::RevealSelectionScope revealSelectionScope(&editor()); | 257 Editor::RevealSelectionScope revealSelectionScope(&editor()); |
| 253 | 258 |
| 254 bool result = replaceComposition(composingText()); | 259 bool result = replaceComposition(composingText()); |
| 255 | 260 |
| 256 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | 261 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
| 257 // needs to be audited. see http://crbug.com/590369 for more details. | 262 // needs to be audited. see http://crbug.com/590369 for more details. |
| 258 document().updateStyleAndLayoutIgnorePendingStylesheets(); | 263 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| 259 | 264 |
| 260 setSelectionOffsets(oldOffsets); | 265 if (oldSelectionRange.isNull()) |
| 266 return false; | |
| 267 const SelectionInDOMTree& selection = | |
| 268 SelectionInDOMTree::Builder() | |
| 269 .setBaseAndExtent(oldSelectionRange) | |
| 270 .setIsHandleVisible(isHandleVisible) | |
| 271 .build(); | |
| 272 | |
| 273 frame().selection().setSelection(selection, FrameSelection::CloseTyping); | |
|
yosin_UTC9
2017/01/25 03:49:08
We'll get rid of |CloseTyping| option[1]
[1] http
Changwan Ryu
2017/02/08 00:40:33
Acknowledged.
| |
| 261 return result; | 274 return result; |
| 262 } | 275 } |
| 263 | 276 |
| 264 return replaceCompositionAndMoveCaret(composingText(), 0, | 277 return replaceCompositionAndMoveCaret(composingText(), 0, |
| 265 Vector<CompositionUnderline>()); | 278 Vector<CompositionUnderline>()); |
| 266 } | 279 } |
| 267 | 280 |
| 268 bool InputMethodController::commitText( | 281 bool InputMethodController::commitText( |
| 269 const String& text, | 282 const String& text, |
| 270 const Vector<CompositionUnderline>& underlines, | 283 const Vector<CompositionUnderline>& underlines, |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 672 PlainTextRange InputMethodController::getSelectionOffsets() const { | 685 PlainTextRange InputMethodController::getSelectionOffsets() const { |
| 673 EphemeralRange range = firstEphemeralRangeOf(frame().selection().selection()); | 686 EphemeralRange range = firstEphemeralRangeOf(frame().selection().selection()); |
| 674 if (range.isNull()) | 687 if (range.isNull()) |
| 675 return PlainTextRange(); | 688 return PlainTextRange(); |
| 676 ContainerNode* editable = | 689 ContainerNode* editable = |
| 677 frame().selection().rootEditableElementOrTreeScopeRootNode(); | 690 frame().selection().rootEditableElementOrTreeScopeRootNode(); |
| 678 DCHECK(editable); | 691 DCHECK(editable); |
| 679 return PlainTextRange::create(*editable, range); | 692 return PlainTextRange::create(*editable, range); |
| 680 } | 693 } |
| 681 | 694 |
| 695 EphemeralRange InputMethodController::ephemeralRangeForOffsets( | |
| 696 const PlainTextRange& offsets) const { | |
| 697 if (offsets.isNull()) | |
| 698 return EphemeralRange(); | |
| 699 Element* rootEditableElement = frame().selection().rootEditableElement(); | |
| 700 if (!rootEditableElement) | |
| 701 return EphemeralRange(); | |
| 702 | |
| 703 DCHECK(!document().needsLayoutTreeUpdate()); | |
| 704 | |
| 705 return offsets.createRange(*rootEditableElement); | |
| 706 } | |
| 707 | |
| 682 bool InputMethodController::setSelectionOffsets( | 708 bool InputMethodController::setSelectionOffsets( |
|
yosin_UTC9
2017/01/25 03:49:08
It is not you due, but we miss comment for |bool|
Changwan Ryu
2017/02/08 00:40:33
Done.
| |
| 683 const PlainTextRange& selectionOffsets, | 709 const PlainTextRange& selectionOffsets, |
| 684 FrameSelection::SetSelectionOptions options) { | 710 FrameSelection::SetSelectionOptions options) { |
| 685 if (selectionOffsets.isNull()) | 711 const EphemeralRange range = ephemeralRangeForOffsets(selectionOffsets); |
| 686 return false; | |
| 687 Element* rootEditableElement = frame().selection().rootEditableElement(); | |
| 688 if (!rootEditableElement) | |
| 689 return false; | |
| 690 | |
| 691 DCHECK(!document().needsLayoutTreeUpdate()); | |
| 692 | |
| 693 const EphemeralRange range = | |
| 694 selectionOffsets.createRange(*rootEditableElement); | |
| 695 if (range.isNull()) | 712 if (range.isNull()) |
| 696 return false; | 713 return false; |
| 697 | 714 |
| 698 return frame().selection().setSelectedRange( | 715 return frame().selection().setSelectedRange( |
| 699 range, VP_DEFAULT_AFFINITY, SelectionDirectionalMode::NonDirectional, | 716 range, VP_DEFAULT_AFFINITY, SelectionDirectionalMode::NonDirectional, |
| 700 options); | 717 options); |
| 701 } | 718 } |
| 702 | 719 |
| 703 bool InputMethodController::setEditableSelectionOffsets( | 720 bool InputMethodController::setEditableSelectionOffsets( |
| 704 const PlainTextRange& selectionOffsets, | 721 const PlainTextRange& selectionOffsets, |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1067 frame().chromeClient().resetInputMethod(); | 1084 frame().chromeClient().resetInputMethod(); |
| 1068 } | 1085 } |
| 1069 | 1086 |
| 1070 DEFINE_TRACE(InputMethodController) { | 1087 DEFINE_TRACE(InputMethodController) { |
| 1071 visitor->trace(m_frame); | 1088 visitor->trace(m_frame); |
| 1072 visitor->trace(m_compositionRange); | 1089 visitor->trace(m_compositionRange); |
| 1073 SynchronousMutationObserver::trace(visitor); | 1090 SynchronousMutationObserver::trace(visitor); |
| 1074 } | 1091 } |
| 1075 | 1092 |
| 1076 } // namespace blink | 1093 } // namespace blink |
| OLD | NEW |