| 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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 return insertTextAndMoveCaret(text, relativeCaretPosition, underlines); | 319 return insertTextAndMoveCaret(text, relativeCaretPosition, underlines); |
| 320 } | 320 } |
| 321 | 321 |
| 322 bool InputMethodController::replaceComposition(const String& text) { | 322 bool InputMethodController::replaceComposition(const String& text) { |
| 323 if (!hasComposition()) | 323 if (!hasComposition()) |
| 324 return false; | 324 return false; |
| 325 | 325 |
| 326 // Select the text that will be deleted or replaced. | 326 // Select the text that will be deleted or replaced. |
| 327 selectComposition(); | 327 selectComposition(); |
| 328 | 328 |
| 329 if (frame().selection().isNone()) | 329 if (frame().selection().computeVisibleSelectionInDOMTreeDeprecated().isNone()) |
| 330 return false; | 330 return false; |
| 331 | 331 |
| 332 if (!isAvailable()) | 332 if (!isAvailable()) |
| 333 return false; | 333 return false; |
| 334 | 334 |
| 335 clear(); | 335 clear(); |
| 336 | 336 |
| 337 insertTextDuringCompositionWithEvents( | 337 insertTextDuringCompositionWithEvents( |
| 338 frame(), text, 0, | 338 frame(), text, 0, |
| 339 TypingCommand::TextCompositionType::TextCompositionConfirm); | 339 TypingCommand::TextCompositionType::TextCompositionConfirm); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 textStart, text.length(), relativeCaretPosition); | 440 textStart, text.length(), relativeCaretPosition); |
| 441 return moveCaret(absoluteCaretPosition); | 441 return moveCaret(absoluteCaretPosition); |
| 442 } | 442 } |
| 443 | 443 |
| 444 void InputMethodController::cancelComposition() { | 444 void InputMethodController::cancelComposition() { |
| 445 if (!hasComposition()) | 445 if (!hasComposition()) |
| 446 return; | 446 return; |
| 447 | 447 |
| 448 Editor::RevealSelectionScope revealSelectionScope(&editor()); | 448 Editor::RevealSelectionScope revealSelectionScope(&editor()); |
| 449 | 449 |
| 450 if (frame().selection().isNone()) | 450 if (frame().selection().computeVisibleSelectionInDOMTreeDeprecated().isNone()) |
| 451 return; | 451 return; |
| 452 | 452 |
| 453 clear(); | 453 clear(); |
| 454 | 454 |
| 455 insertTextDuringCompositionWithEvents( | 455 insertTextDuringCompositionWithEvents( |
| 456 frame(), emptyString, 0, | 456 frame(), emptyString, 0, |
| 457 TypingCommand::TextCompositionType::TextCompositionCancel); | 457 TypingCommand::TextCompositionType::TextCompositionCancel); |
| 458 // Event handler might destroy document. | 458 // Event handler might destroy document. |
| 459 if (!isAvailable()) | 459 if (!isAvailable()) |
| 460 return; | 460 return; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 int selectionEnd) { | 500 int selectionEnd) { |
| 501 Editor::RevealSelectionScope revealSelectionScope(&editor()); | 501 Editor::RevealSelectionScope revealSelectionScope(&editor()); |
| 502 | 502 |
| 503 // Updates styles before setting selection for composition to prevent | 503 // Updates styles before setting selection for composition to prevent |
| 504 // inserting the previous composition text into text nodes oddly. | 504 // inserting the previous composition text into text nodes oddly. |
| 505 // See https://bugs.webkit.org/show_bug.cgi?id=46868 | 505 // See https://bugs.webkit.org/show_bug.cgi?id=46868 |
| 506 document().updateStyleAndLayoutTree(); | 506 document().updateStyleAndLayoutTree(); |
| 507 | 507 |
| 508 selectComposition(); | 508 selectComposition(); |
| 509 | 509 |
| 510 if (frame().selection().isNone()) | 510 if (frame().selection().computeVisibleSelectionInDOMTreeDeprecated().isNone()) |
| 511 return; | 511 return; |
| 512 | 512 |
| 513 Element* target = document().focusedElement(); | 513 Element* target = document().focusedElement(); |
| 514 if (!target) | 514 if (!target) |
| 515 return; | 515 return; |
| 516 | 516 |
| 517 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | 517 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
| 518 // needs to be audited. see http://crbug.com/590369 for more details. | 518 // needs to be audited. see http://crbug.com/590369 for more details. |
| 519 document().updateStyleAndLayoutIgnorePendingStylesheets(); | 519 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| 520 | 520 |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1124 finishComposingText(KeepSelection); | 1124 finishComposingText(KeepSelection); |
| 1125 } | 1125 } |
| 1126 | 1126 |
| 1127 DEFINE_TRACE(InputMethodController) { | 1127 DEFINE_TRACE(InputMethodController) { |
| 1128 visitor->trace(m_frame); | 1128 visitor->trace(m_frame); |
| 1129 visitor->trace(m_compositionRange); | 1129 visitor->trace(m_compositionRange); |
| 1130 SynchronousMutationObserver::trace(visitor); | 1130 SynchronousMutationObserver::trace(visitor); |
| 1131 } | 1131 } |
| 1132 | 1132 |
| 1133 } // namespace blink | 1133 } // namespace blink |
| OLD | NEW |