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 1389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1400 return; | 1400 return; |
1401 const SelectionInDOMTree newSelection = | 1401 const SelectionInDOMTree newSelection = |
1402 SelectionInDOMTree::Builder().setBaseAndExtent(range).build(); | 1402 SelectionInDOMTree::Builder().setBaseAndExtent(range).build(); |
1403 | 1403 |
1404 // Transpose the two characters. | 1404 // Transpose the two characters. |
1405 String text = plainText(range); | 1405 String text = plainText(range); |
1406 if (text.length() != 2) | 1406 if (text.length() != 2) |
1407 return; | 1407 return; |
1408 String transposed = text.right(1) + text.left(1); | 1408 String transposed = text.right(1) + text.left(1); |
1409 | 1409 |
1410 // Select the two characters. | |
1411 if (createVisibleSelection(newSelection) != | |
1412 frame().selection().computeVisibleSelectionInDOMTreeDeprecated()) | |
1413 frame().selection().setSelection(newSelection); | |
1414 | |
1415 if (dispatchBeforeInputInsertText( | 1410 if (dispatchBeforeInputInsertText( |
1416 eventTargetNodeForDocument(frame().document()), transposed, | 1411 eventTargetNodeForDocument(frame().document()), transposed, |
1417 InputEvent::InputType::InsertTranspose) != | 1412 InputEvent::InputType::InsertTranspose, |
1413 new StaticRangeVector(1, StaticRange::create(range))) != | |
1418 DispatchEventResult::NotCanceled) | 1414 DispatchEventResult::NotCanceled) |
1419 return; | 1415 return; |
1420 | 1416 |
1421 // 'beforeinput' event handler may destroy document. | 1417 // 'beforeinput' event handler may destroy document. |
1422 if (m_frame->document()->frame() != m_frame) | 1418 if (m_frame->document()->frame() != m_frame) |
1423 return; | 1419 return; |
1424 | 1420 |
1425 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets | 1421 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets |
1426 // needs to be audited. see http://crbug.com/590369 for more details. | 1422 // needs to be audited. see http://crbug.com/590369 for more details. |
1427 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets(); | 1423 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
1428 | 1424 |
1425 // Select the two characters. | |
1426 if (createVisibleSelection(newSelection) != | |
1427 frame().selection().computeVisibleSelectionInDOMTreeDeprecated()) | |
yosin_UTC9
2017/03/28 07:08:35
nit: Since L1423 update layout, we don't need to u
chongz
2017/03/28 20:46:47
Done.
| |
1428 frame().selection().setSelection(newSelection); | |
1429 | |
1429 // Insert the transposed characters. | 1430 // Insert the transposed characters. |
1430 replaceSelectionWithText(transposed, false, false, | 1431 replaceSelectionWithText(transposed, false, false, |
1431 InputEvent::InputType::InsertTranspose); | 1432 InputEvent::InputType::InsertTranspose); |
1432 } | 1433 } |
1433 | 1434 |
1434 void Editor::addToKillRing(const EphemeralRange& range) { | 1435 void Editor::addToKillRing(const EphemeralRange& range) { |
1435 if (m_shouldStartNewKillRingSequence) | 1436 if (m_shouldStartNewKillRingSequence) |
1436 killRing().startNewSequence(); | 1437 killRing().startNewSequence(); |
1437 | 1438 |
1438 DCHECK(!frame().document()->needsLayoutTreeUpdate()); | 1439 DCHECK(!frame().document()->needsLayoutTreeUpdate()); |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1795 | 1796 |
1796 DEFINE_TRACE(Editor) { | 1797 DEFINE_TRACE(Editor) { |
1797 visitor->trace(m_frame); | 1798 visitor->trace(m_frame); |
1798 visitor->trace(m_lastEditCommand); | 1799 visitor->trace(m_lastEditCommand); |
1799 visitor->trace(m_undoStack); | 1800 visitor->trace(m_undoStack); |
1800 visitor->trace(m_mark); | 1801 visitor->trace(m_mark); |
1801 visitor->trace(m_typingStyle); | 1802 visitor->trace(m_typingStyle); |
1802 } | 1803 } |
1803 | 1804 |
1804 } // namespace blink | 1805 } // namespace blink |
OLD | NEW |