| 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 else | 278 else |
| 279 event = CompositionEvent::create(EventTypeNames::compositionend,
frame().domWindow(), text); | 279 event = CompositionEvent::create(EventTypeNames::compositionend,
frame().domWindow(), text); |
| 280 } | 280 } |
| 281 if (event) | 281 if (event) |
| 282 target->dispatchEvent(event); | 282 target->dispatchEvent(event); |
| 283 } | 283 } |
| 284 | 284 |
| 285 // If text is empty, then delete the old composition here. If text is non-em
pty, InsertTextCommand::input | 285 // If text is empty, then delete the old composition here. If text is non-em
pty, InsertTextCommand::input |
| 286 // will delete the old composition with an optimized replace operation. | 286 // will delete the old composition with an optimized replace operation. |
| 287 if (text.isEmpty()) { | 287 if (text.isEmpty()) { |
| 288 ASSERT(frame().document()); | 288 DCHECK(frame().document()); |
| 289 TypingCommand::deleteSelection(*frame().document(), TypingCommand::Preve
ntSpellChecking); | 289 TypingCommand::deleteSelection(*frame().document(), TypingCommand::Preve
ntSpellChecking); |
| 290 } | 290 } |
| 291 | 291 |
| 292 clear(); | 292 clear(); |
| 293 | 293 |
| 294 if (text.isEmpty()) | 294 if (text.isEmpty()) |
| 295 return; | 295 return; |
| 296 ASSERT(frame().document()); | 296 DCHECK(frame().document()); |
| 297 TypingCommand::insertText(*frame().document(), text, TypingCommand::SelectIn
sertedText | TypingCommand::PreventSpellChecking, TypingCommand::TextComposition
Update); | 297 TypingCommand::insertText(*frame().document(), text, TypingCommand::SelectIn
sertedText | TypingCommand::PreventSpellChecking, TypingCommand::TextComposition
Update); |
| 298 | 298 |
| 299 // Find out what node has the composition now. | 299 // Find out what node has the composition now. |
| 300 Position base = mostForwardCaretPosition(frame().selection().base()); | 300 Position base = mostForwardCaretPosition(frame().selection().base()); |
| 301 Node* baseNode = base.anchorNode(); | 301 Node* baseNode = base.anchorNode(); |
| 302 if (!baseNode || !baseNode->isTextNode()) | 302 if (!baseNode || !baseNode->isTextNode()) |
| 303 return; | 303 return; |
| 304 | 304 |
| 305 Position extent = frame().selection().extent(); | 305 Position extent = frame().selection().extent(); |
| 306 Node* extentNode = extent.anchorNode(); | 306 Node* extentNode = extent.anchorNode(); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 { | 393 { |
| 394 return plainText(compositionEphemeralRange(), TextIteratorEmitsOriginalText)
; | 394 return plainText(compositionEphemeralRange(), TextIteratorEmitsOriginalText)
; |
| 395 } | 395 } |
| 396 | 396 |
| 397 PlainTextRange InputMethodController::getSelectionOffsets() const | 397 PlainTextRange InputMethodController::getSelectionOffsets() const |
| 398 { | 398 { |
| 399 EphemeralRange range = firstEphemeralRangeOf(frame().selection().selection()
); | 399 EphemeralRange range = firstEphemeralRangeOf(frame().selection().selection()
); |
| 400 if (range.isNull()) | 400 if (range.isNull()) |
| 401 return PlainTextRange(); | 401 return PlainTextRange(); |
| 402 ContainerNode* editable = frame().selection().rootEditableElementOrTreeScope
RootNode(); | 402 ContainerNode* editable = frame().selection().rootEditableElementOrTreeScope
RootNode(); |
| 403 ASSERT(editable); | 403 DCHECK(editable); |
| 404 return PlainTextRange::create(*editable, range); | 404 return PlainTextRange::create(*editable, range); |
| 405 } | 405 } |
| 406 | 406 |
| 407 bool InputMethodController::setSelectionOffsets(const PlainTextRange& selectionO
ffsets) | 407 bool InputMethodController::setSelectionOffsets(const PlainTextRange& selectionO
ffsets) |
| 408 { | 408 { |
| 409 if (selectionOffsets.isNull()) | 409 if (selectionOffsets.isNull()) |
| 410 return false; | 410 return false; |
| 411 Element* rootEditableElement = frame().selection().rootEditableElement(); | 411 Element* rootEditableElement = frame().selection().rootEditableElement(); |
| 412 if (!rootEditableElement) | 412 if (!rootEditableElement) |
| 413 return false; | 413 return false; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 TypingCommand::deleteSelection(*frame().document()); | 456 TypingCommand::deleteSelection(*frame().document()); |
| 457 } | 457 } |
| 458 | 458 |
| 459 DEFINE_TRACE(InputMethodController) | 459 DEFINE_TRACE(InputMethodController) |
| 460 { | 460 { |
| 461 visitor->trace(m_frame); | 461 visitor->trace(m_frame); |
| 462 visitor->trace(m_compositionRange); | 462 visitor->trace(m_compositionRange); |
| 463 } | 463 } |
| 464 | 464 |
| 465 } // namespace blink | 465 } // namespace blink |
| OLD | NEW |