| 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 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1367 isEndOfParagraph(caret) ? caret : nextPositionOf(caret); | 1367 isEndOfParagraph(caret) ? caret : nextPositionOf(caret); |
| 1368 VisiblePosition previous = previousPositionOf(next); | 1368 VisiblePosition previous = previousPositionOf(next); |
| 1369 if (next.deepEquivalent() == previous.deepEquivalent()) | 1369 if (next.deepEquivalent() == previous.deepEquivalent()) |
| 1370 return; | 1370 return; |
| 1371 previous = previousPositionOf(previous); | 1371 previous = previousPositionOf(previous); |
| 1372 if (!inSameParagraph(next, previous)) | 1372 if (!inSameParagraph(next, previous)) |
| 1373 return; | 1373 return; |
| 1374 const EphemeralRange range = makeRange(previous, next); | 1374 const EphemeralRange range = makeRange(previous, next); |
| 1375 if (range.isNull()) | 1375 if (range.isNull()) |
| 1376 return; | 1376 return; |
| 1377 VisibleSelection newSelection = createVisibleSelection( | 1377 const SelectionInDOMTree newSelection = |
| 1378 SelectionInDOMTree::Builder().setBaseAndExtent(range).build()); | 1378 SelectionInDOMTree::Builder().setBaseAndExtent(range).build(); |
| 1379 | 1379 |
| 1380 // Transpose the two characters. | 1380 // Transpose the two characters. |
| 1381 String text = plainText(range); | 1381 String text = plainText(range); |
| 1382 if (text.length() != 2) | 1382 if (text.length() != 2) |
| 1383 return; | 1383 return; |
| 1384 String transposed = text.right(1) + text.left(1); | 1384 String transposed = text.right(1) + text.left(1); |
| 1385 | 1385 |
| 1386 // Select the two characters. | 1386 // Select the two characters. |
| 1387 if (newSelection != | 1387 if (createVisibleSelection(newSelection) != |
| 1388 frame().selection().computeVisibleSelectionInDOMTreeDeprecated()) | 1388 frame().selection().computeVisibleSelectionInDOMTreeDeprecated()) |
| 1389 frame().selection().setSelection(newSelection); | 1389 frame().selection().setSelection(newSelection); |
| 1390 | 1390 |
| 1391 // Insert the transposed characters. | 1391 // Insert the transposed characters. |
| 1392 // TODO(chongz): Once we add |InsertTranspose| in |InputEvent::InputType|, we | 1392 // TODO(chongz): Once we add |InsertTranspose| in |InputEvent::InputType|, we |
| 1393 // should use it instead of |InsertFromPaste|. | 1393 // should use it instead of |InsertFromPaste|. |
| 1394 replaceSelectionWithText(transposed, false, false, | 1394 replaceSelectionWithText(transposed, false, false, |
| 1395 InputEvent::InputType::InsertFromPaste); | 1395 InputEvent::InputType::InsertFromPaste); |
| 1396 } | 1396 } |
| 1397 | 1397 |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1759 | 1759 |
| 1760 DEFINE_TRACE(Editor) { | 1760 DEFINE_TRACE(Editor) { |
| 1761 visitor->trace(m_frame); | 1761 visitor->trace(m_frame); |
| 1762 visitor->trace(m_lastEditCommand); | 1762 visitor->trace(m_lastEditCommand); |
| 1763 visitor->trace(m_undoStack); | 1763 visitor->trace(m_undoStack); |
| 1764 visitor->trace(m_mark); | 1764 visitor->trace(m_mark); |
| 1765 visitor->trace(m_typingStyle); | 1765 visitor->trace(m_typingStyle); |
| 1766 } | 1766 } |
| 1767 | 1767 |
| 1768 } // namespace blink | 1768 } // namespace blink |
| OLD | NEW |