| 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 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 return; | 476 return; |
| 477 | 477 |
| 478 // An open typing command that disagrees about current selection would cause | 478 // An open typing command that disagrees about current selection would cause |
| 479 // issues with typing later on. | 479 // issues with typing later on. |
| 480 TypingCommand::closeTyping(m_frame); | 480 TypingCommand::closeTyping(m_frame); |
| 481 | 481 |
| 482 // No DOM update after 'compositionend'. | 482 // No DOM update after 'compositionend'. |
| 483 dispatchCompositionEndEvent(frame(), emptyString); | 483 dispatchCompositionEndEvent(frame(), emptyString); |
| 484 } | 484 } |
| 485 | 485 |
| 486 void InputMethodController::cancelCompositionIfSelectionIsInvalid() { | |
| 487 if (!hasComposition() || editor().preventRevealSelection()) | |
| 488 return; | |
| 489 | |
| 490 // Check if selection start and selection end are valid. | |
| 491 FrameSelection& selection = frame().selection(); | |
| 492 if (!selection.isNone() && !m_compositionRange->collapsed()) { | |
| 493 if (selection.start().compareTo(m_compositionRange->startPosition()) >= 0 && | |
| 494 selection.end().compareTo(m_compositionRange->endPosition()) <= 0) | |
| 495 return; | |
| 496 } | |
| 497 | |
| 498 cancelComposition(); | |
| 499 frame().chromeClient().didCancelCompositionOnSelectionChange(); | |
| 500 } | |
| 501 | |
| 502 // If current position is at grapheme boundary, return 0; otherwise, return the | 486 // If current position is at grapheme boundary, return 0; otherwise, return the |
| 503 // distance to its nearest left grapheme boundary. | 487 // distance to its nearest left grapheme boundary. |
| 504 static size_t computeDistanceToLeftGraphemeBoundary(const Position& position) { | 488 static size_t computeDistanceToLeftGraphemeBoundary(const Position& position) { |
| 505 const Position& adjustedPosition = previousPositionOf( | 489 const Position& adjustedPosition = previousPositionOf( |
| 506 nextPositionOf(position, PositionMoveType::GraphemeCluster), | 490 nextPositionOf(position, PositionMoveType::GraphemeCluster), |
| 507 PositionMoveType::GraphemeCluster); | 491 PositionMoveType::GraphemeCluster); |
| 508 DCHECK_EQ(position.anchorNode(), adjustedPosition.anchorNode()); | 492 DCHECK_EQ(position.anchorNode(), adjustedPosition.anchorNode()); |
| 509 DCHECK_GE(position.computeOffsetInContainerNode(), | 493 DCHECK_GE(position.computeOffsetInContainerNode(), |
| 510 adjustedPosition.computeOffsetInContainerNode()); | 494 adjustedPosition.computeOffsetInContainerNode()); |
| 511 return static_cast<size_t>(position.computeOffsetInContainerNode() - | 495 return static_cast<size_t>(position.computeOffsetInContainerNode() - |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1124 frame().chromeClient().resetInputMethod(); | 1108 frame().chromeClient().resetInputMethod(); |
| 1125 } | 1109 } |
| 1126 | 1110 |
| 1127 DEFINE_TRACE(InputMethodController) { | 1111 DEFINE_TRACE(InputMethodController) { |
| 1128 visitor->trace(m_frame); | 1112 visitor->trace(m_frame); |
| 1129 visitor->trace(m_compositionRange); | 1113 visitor->trace(m_compositionRange); |
| 1130 SynchronousMutationObserver::trace(visitor); | 1114 SynchronousMutationObserver::trace(visitor); |
| 1131 } | 1115 } |
| 1132 | 1116 |
| 1133 } // namespace blink | 1117 } // namespace blink |
| OLD | NEW |