| 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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 fragment = createFragmentFromMarkupWithContext( | 440 fragment = createFragmentFromMarkupWithContext( |
| 441 *frame().document(), markup, fragmentStart, fragmentEnd, url, | 441 *frame().document(), markup, fragmentStart, fragmentEnd, url, |
| 442 DisallowScriptingAndPluginContent); | 442 DisallowScriptingAndPluginContent); |
| 443 } | 443 } |
| 444 } | 444 } |
| 445 | 445 |
| 446 if (!fragment) { | 446 if (!fragment) { |
| 447 String text = pasteboard->plainText(); | 447 String text = pasteboard->plainText(); |
| 448 if (!text.isEmpty()) { | 448 if (!text.isEmpty()) { |
| 449 chosePlainText = true; | 449 chosePlainText = true; |
| 450 |
| 451 // TODO(xiaochengh): Use of updateStyleAndLayoutIgnorePendingStylesheets |
| 452 // needs to be audited. See http://crbug.com/590369 for more details. |
| 453 // |selectedRange| requires clean layout for visible selection |
| 454 // normalization. |
| 455 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 456 |
| 450 fragment = createFragmentFromText(selectedRange(), text); | 457 fragment = createFragmentFromText(selectedRange(), text); |
| 451 } | 458 } |
| 452 } | 459 } |
| 453 | 460 |
| 454 if (fragment) | 461 if (fragment) |
| 455 pasteAsFragment(fragment, canSmartReplaceWithPasteboard(pasteboard), | 462 pasteAsFragment(fragment, canSmartReplaceWithPasteboard(pasteboard), |
| 456 chosePlainText); | 463 chosePlainText); |
| 457 } | 464 } |
| 458 | 465 |
| 459 void Editor::writeSelectionToPasteboard() { | 466 void Editor::writeSelectionToPasteboard() { |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 : ScrollAlignment::alignCenterIfNeeded); | 1002 : ScrollAlignment::alignCenterIfNeeded); |
| 996 | 1003 |
| 997 return true; | 1004 return true; |
| 998 } | 1005 } |
| 999 | 1006 |
| 1000 void Editor::cut(EditorCommandSource source) { | 1007 void Editor::cut(EditorCommandSource source) { |
| 1001 if (tryDHTMLCut()) | 1008 if (tryDHTMLCut()) |
| 1002 return; // DHTML did the whole operation | 1009 return; // DHTML did the whole operation |
| 1003 if (!canCut()) | 1010 if (!canCut()) |
| 1004 return; | 1011 return; |
| 1012 |
| 1013 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
| 1014 // needs to be audited. See http://crbug.com/590369 for more details. |
| 1015 // |tryDHTMLCut| dispatches cut event, which may make layout dirty, but we |
| 1016 // need clean layout to obtain the selected content. |
| 1017 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 1018 |
| 1005 // TODO(yosin) We should use early return style here. | 1019 // TODO(yosin) We should use early return style here. |
| 1006 if (canDeleteRange(selectedRange())) { | 1020 if (canDeleteRange(selectedRange())) { |
| 1007 spellChecker().updateMarkersForWordsAffectedByEditing(true); | 1021 spellChecker().updateMarkersForWordsAffectedByEditing(true); |
| 1008 if (enclosingTextFormControl(frame().selection().start())) { | 1022 if (enclosingTextFormControl(frame().selection().start())) { |
| 1009 String plainText = frame().selectedTextForClipboard(); | 1023 String plainText = frame().selectedTextForClipboard(); |
| 1010 Pasteboard::generalPasteboard()->writePlainText( | 1024 Pasteboard::generalPasteboard()->writePlainText( |
| 1011 plainText, canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace | 1025 plainText, canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace |
| 1012 : Pasteboard::CannotSmartReplace); | 1026 : Pasteboard::CannotSmartReplace); |
| 1013 } else { | 1027 } else { |
| 1014 writeSelectionToPasteboard(); | 1028 writeSelectionToPasteboard(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1028 canSmartCopyOrDelete() ? DeleteMode::Smart : DeleteMode::Simple, | 1042 canSmartCopyOrDelete() ? DeleteMode::Smart : DeleteMode::Simple, |
| 1029 InputEvent::InputType::DeleteByCut); | 1043 InputEvent::InputType::DeleteByCut); |
| 1030 } | 1044 } |
| 1031 } | 1045 } |
| 1032 | 1046 |
| 1033 void Editor::copy() { | 1047 void Editor::copy() { |
| 1034 if (tryDHTMLCopy()) | 1048 if (tryDHTMLCopy()) |
| 1035 return; // DHTML did the whole operation | 1049 return; // DHTML did the whole operation |
| 1036 if (!canCopy()) | 1050 if (!canCopy()) |
| 1037 return; | 1051 return; |
| 1052 |
| 1053 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
| 1054 // needs to be audited. See http://crbug.com/590369 for more details. |
| 1055 // |tryDHTMLCopy| dispatches copy event, which may make layout dirty, but |
| 1056 // we need clean layout to obtain the selected content. |
| 1057 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 1058 |
| 1038 if (enclosingTextFormControl(frame().selection().start())) { | 1059 if (enclosingTextFormControl(frame().selection().start())) { |
| 1039 Pasteboard::generalPasteboard()->writePlainText( | 1060 Pasteboard::generalPasteboard()->writePlainText( |
| 1040 frame().selectedTextForClipboard(), | 1061 frame().selectedTextForClipboard(), |
| 1041 canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace | 1062 canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace |
| 1042 : Pasteboard::CannotSmartReplace); | 1063 : Pasteboard::CannotSmartReplace); |
| 1043 } else { | 1064 } else { |
| 1044 Document* document = frame().document(); | 1065 Document* document = frame().document(); |
| 1045 if (HTMLImageElement* imageElement = | 1066 if (HTMLImageElement* imageElement = |
| 1046 imageElementFromImageDocument(document)) | 1067 imageElementFromImageDocument(document)) |
| 1047 writeImageNodeToPasteboard(Pasteboard::generalPasteboard(), imageElement, | 1068 writeImageNodeToPasteboard(Pasteboard::generalPasteboard(), imageElement, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1091 return; | 1112 return; |
| 1092 if (!canPaste()) | 1113 if (!canPaste()) |
| 1093 return; | 1114 return; |
| 1094 spellChecker().updateMarkersForWordsAffectedByEditing(false); | 1115 spellChecker().updateMarkersForWordsAffectedByEditing(false); |
| 1095 pasteAsPlainTextWithPasteboard(Pasteboard::generalPasteboard()); | 1116 pasteAsPlainTextWithPasteboard(Pasteboard::generalPasteboard()); |
| 1096 } | 1117 } |
| 1097 | 1118 |
| 1098 void Editor::performDelete() { | 1119 void Editor::performDelete() { |
| 1099 if (!canDelete()) | 1120 if (!canDelete()) |
| 1100 return; | 1121 return; |
| 1122 |
| 1123 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
| 1124 // needs to be audited. See http://crbug.com/590369 for more details. |
| 1125 // |selectedRange| requires clean layout for visible selection normalization. |
| 1126 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 1127 |
| 1101 addToKillRing(selectedRange()); | 1128 addToKillRing(selectedRange()); |
| 1102 // TODO(chongz): |Editor::performDelete()| has no direction. | 1129 // TODO(chongz): |Editor::performDelete()| has no direction. |
| 1103 // https://github.com/w3c/editing/issues/130 | 1130 // https://github.com/w3c/editing/issues/130 |
| 1104 deleteSelectionWithSmartDelete( | 1131 deleteSelectionWithSmartDelete( |
| 1105 canSmartCopyOrDelete() ? DeleteMode::Smart : DeleteMode::Simple, | 1132 canSmartCopyOrDelete() ? DeleteMode::Smart : DeleteMode::Simple, |
| 1106 InputEvent::InputType::DeleteContentBackward); | 1133 InputEvent::InputType::DeleteContentBackward); |
| 1107 | 1134 |
| 1108 // clear the "start new kill ring sequence" setting, because it was set to | 1135 // clear the "start new kill ring sequence" setting, because it was set to |
| 1109 // true when the selection was updated by deleting the range | 1136 // true when the selection was updated by deleting the range |
| 1110 setStartNewKillRingSequence(false); | 1137 setStartNewKillRingSequence(false); |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1619 } | 1646 } |
| 1620 | 1647 |
| 1621 DEFINE_TRACE(Editor) { | 1648 DEFINE_TRACE(Editor) { |
| 1622 visitor->trace(m_frame); | 1649 visitor->trace(m_frame); |
| 1623 visitor->trace(m_lastEditCommand); | 1650 visitor->trace(m_lastEditCommand); |
| 1624 visitor->trace(m_undoStack); | 1651 visitor->trace(m_undoStack); |
| 1625 visitor->trace(m_mark); | 1652 visitor->trace(m_mark); |
| 1626 } | 1653 } |
| 1627 | 1654 |
| 1628 } // namespace blink | 1655 } // namespace blink |
| OLD | NEW |