| 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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 // to override checks. See <http://bugs.webkit.org/show_bug.cgi?id=15781> | 240 // to override checks. See <http://bugs.webkit.org/show_bug.cgi?id=15781> |
| 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 const String& composing = composingText(); |
| 251 |
| 250 if (confirmBehavior == KeepSelection) { | 252 if (confirmBehavior == KeepSelection) { |
| 251 PlainTextRange oldOffsets = getSelectionOffsets(); | 253 PlainTextRange oldOffsets = getSelectionOffsets(); |
| 252 Editor::RevealSelectionScope revealSelectionScope(&editor()); | 254 Editor::RevealSelectionScope revealSelectionScope(&editor()); |
| 253 | 255 |
| 254 bool result = replaceComposition(composingText()); | 256 clear(); |
| 255 | 257 |
| 256 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | 258 dispatchCompositionEndEvent(frame(), composing); |
| 257 // needs to be audited. see http://crbug.com/590369 for more details. | |
| 258 document().updateStyleAndLayoutIgnorePendingStylesheets(); | |
| 259 | |
| 260 setSelectionOffsets(oldOffsets); | 259 setSelectionOffsets(oldOffsets); |
| 261 return result; | 260 return true; |
| 262 } | 261 } |
| 263 | 262 |
| 264 return replaceCompositionAndMoveCaret(composingText(), 0, | 263 Element* rootEditableElement = frame().selection().rootEditableElement(); |
| 265 Vector<CompositionUnderline>()); | 264 if (!rootEditableElement) |
| 265 return false; |
| 266 PlainTextRange compositionRange = |
| 267 PlainTextRange::create(*rootEditableElement, *m_compositionRange); |
| 268 if (compositionRange.isNull()) |
| 269 return false; |
| 270 |
| 271 clear(); |
| 272 |
| 273 if (!moveCaret(compositionRange.end())) |
| 274 return false; |
| 275 |
| 276 dispatchCompositionEndEvent(frame(), composing); |
| 277 return true; |
| 266 } | 278 } |
| 267 | 279 |
| 268 bool InputMethodController::commitText( | 280 bool InputMethodController::commitText( |
| 269 const String& text, | 281 const String& text, |
| 270 const Vector<CompositionUnderline>& underlines, | 282 const Vector<CompositionUnderline>& underlines, |
| 271 int relativeCaretPosition) { | 283 int relativeCaretPosition) { |
| 272 if (hasComposition()) { | 284 if (hasComposition()) { |
| 273 return replaceCompositionAndMoveCaret(text, relativeCaretPosition, | 285 return replaceCompositionAndMoveCaret(text, relativeCaretPosition, |
| 274 underlines); | 286 underlines); |
| 275 } | 287 } |
| (...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1067 frame().chromeClient().resetInputMethod(); | 1079 frame().chromeClient().resetInputMethod(); |
| 1068 } | 1080 } |
| 1069 | 1081 |
| 1070 DEFINE_TRACE(InputMethodController) { | 1082 DEFINE_TRACE(InputMethodController) { |
| 1071 visitor->trace(m_frame); | 1083 visitor->trace(m_frame); |
| 1072 visitor->trace(m_compositionRange); | 1084 visitor->trace(m_compositionRange); |
| 1073 SynchronousMutationObserver::trace(visitor); | 1085 SynchronousMutationObserver::trace(visitor); |
| 1074 } | 1086 } |
| 1075 | 1087 |
| 1076 } // namespace blink | 1088 } // namespace blink |
| OLD | NEW |