| 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 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1409 String text = plainText(range); | 1409 String text = plainText(range); |
| 1410 if (text.length() != 2) | 1410 if (text.length() != 2) |
| 1411 return; | 1411 return; |
| 1412 String transposed = text.right(1) + text.left(1); | 1412 String transposed = text.right(1) + text.left(1); |
| 1413 | 1413 |
| 1414 // Select the two characters. | 1414 // Select the two characters. |
| 1415 if (createVisibleSelection(newSelection) != | 1415 if (createVisibleSelection(newSelection) != |
| 1416 frame().selection().computeVisibleSelectionInDOMTreeDeprecated()) | 1416 frame().selection().computeVisibleSelectionInDOMTreeDeprecated()) |
| 1417 frame().selection().setSelection(newSelection); | 1417 frame().selection().setSelection(newSelection); |
| 1418 | 1418 |
| 1419 if (dispatchBeforeInputInsertText( |
| 1420 eventTargetNodeForDocument(frame().document()), transposed, |
| 1421 InputEvent::InputType::InsertTranspose) != |
| 1422 DispatchEventResult::NotCanceled) |
| 1423 return; |
| 1424 |
| 1425 // 'beforeinput' event handler may destroy document. |
| 1426 if (m_frame->document()->frame() != m_frame) |
| 1427 return; |
| 1428 |
| 1429 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets |
| 1430 // needs to be audited. see http://crbug.com/590369 for more details. |
| 1431 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 1432 |
| 1419 // Insert the transposed characters. | 1433 // Insert the transposed characters. |
| 1420 // TODO(chongz): Once we add |InsertTranspose| in |InputEvent::InputType|, we | |
| 1421 // should use it instead of |InsertFromPaste|. | |
| 1422 replaceSelectionWithText(transposed, false, false, | 1434 replaceSelectionWithText(transposed, false, false, |
| 1423 InputEvent::InputType::InsertFromPaste); | 1435 InputEvent::InputType::InsertTranspose); |
| 1424 } | 1436 } |
| 1425 | 1437 |
| 1426 void Editor::addToKillRing(const EphemeralRange& range) { | 1438 void Editor::addToKillRing(const EphemeralRange& range) { |
| 1427 if (m_shouldStartNewKillRingSequence) | 1439 if (m_shouldStartNewKillRingSequence) |
| 1428 killRing().startNewSequence(); | 1440 killRing().startNewSequence(); |
| 1429 | 1441 |
| 1430 DCHECK(!frame().document()->needsLayoutTreeUpdate()); | 1442 DCHECK(!frame().document()->needsLayoutTreeUpdate()); |
| 1431 String text = plainText(range); | 1443 String text = plainText(range); |
| 1432 killRing().append(text); | 1444 killRing().append(text); |
| 1433 m_shouldStartNewKillRingSequence = false; | 1445 m_shouldStartNewKillRingSequence = false; |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1787 | 1799 |
| 1788 DEFINE_TRACE(Editor) { | 1800 DEFINE_TRACE(Editor) { |
| 1789 visitor->trace(m_frame); | 1801 visitor->trace(m_frame); |
| 1790 visitor->trace(m_lastEditCommand); | 1802 visitor->trace(m_lastEditCommand); |
| 1791 visitor->trace(m_undoStack); | 1803 visitor->trace(m_undoStack); |
| 1792 visitor->trace(m_mark); | 1804 visitor->trace(m_mark); |
| 1793 visitor->trace(m_typingStyle); | 1805 visitor->trace(m_typingStyle); |
| 1794 } | 1806 } |
| 1795 | 1807 |
| 1796 } // namespace blink | 1808 } // namespace blink |
| OLD | NEW |