Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: third_party/WebKit/Source/core/editing/Editor.cpp

Issue 2578753002: [EditCommandSource] Rename and move |EditorCommandSource| to "CompositeEditCommand.h" (1/3) (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 EditingState editingState; 1017 EditingState editingState;
1018 if (!TypingCommand::insertParagraphSeparator(*frame().document())) 1018 if (!TypingCommand::insertParagraphSeparator(*frame().document()))
1019 return false; 1019 return false;
1020 revealSelectionAfterEditingOperation( 1020 revealSelectionAfterEditingOperation(
1021 alignToEdge ? ScrollAlignment::alignToEdgeIfNeeded 1021 alignToEdge ? ScrollAlignment::alignToEdgeIfNeeded
1022 : ScrollAlignment::alignCenterIfNeeded); 1022 : ScrollAlignment::alignCenterIfNeeded);
1023 1023
1024 return true; 1024 return true;
1025 } 1025 }
1026 1026
1027 void Editor::cut(EditorCommandSource source) { 1027 void Editor::cut(CommandSource source) {
1028 if (tryDHTMLCut()) 1028 if (tryDHTMLCut())
1029 return; // DHTML did the whole operation 1029 return; // DHTML did the whole operation
1030 if (!canCut()) 1030 if (!canCut())
1031 return; 1031 return;
1032 1032
1033 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets 1033 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
1034 // needs to be audited. See http://crbug.com/590369 for more details. 1034 // needs to be audited. See http://crbug.com/590369 for more details.
1035 // |tryDHTMLCut| dispatches cut event, which may make layout dirty, but we 1035 // |tryDHTMLCut| dispatches cut event, which may make layout dirty, but we
1036 // need clean layout to obtain the selected content. 1036 // need clean layout to obtain the selected content.
1037 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets(); 1037 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets();
1038 1038
1039 // TODO(yosin) We should use early return style here. 1039 // TODO(yosin) We should use early return style here.
1040 if (canDeleteRange(selectedRange())) { 1040 if (canDeleteRange(selectedRange())) {
1041 spellChecker().updateMarkersForWordsAffectedByEditing(true); 1041 spellChecker().updateMarkersForWordsAffectedByEditing(true);
1042 if (enclosingTextControl(frame().selection().start())) { 1042 if (enclosingTextControl(frame().selection().start())) {
1043 String plainText = frame().selectedTextForClipboard(); 1043 String plainText = frame().selectedTextForClipboard();
1044 Pasteboard::generalPasteboard()->writePlainText( 1044 Pasteboard::generalPasteboard()->writePlainText(
1045 plainText, canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace 1045 plainText, canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace
1046 : Pasteboard::CannotSmartReplace); 1046 : Pasteboard::CannotSmartReplace);
1047 } else { 1047 } else {
1048 writeSelectionToPasteboard(); 1048 writeSelectionToPasteboard();
1049 } 1049 }
1050 1050
1051 if (source == CommandFromMenuOrKeyBinding) { 1051 if (source == CommandSource::MenuOrKeyBinding) {
1052 if (dispatchBeforeInputDataTransfer(findEventTargetFromSelection(), 1052 if (dispatchBeforeInputDataTransfer(findEventTargetFromSelection(),
1053 InputEvent::InputType::DeleteByCut, 1053 InputEvent::InputType::DeleteByCut,
1054 nullptr, nullptr) != 1054 nullptr, nullptr) !=
1055 DispatchEventResult::NotCanceled) 1055 DispatchEventResult::NotCanceled)
1056 return; 1056 return;
1057 // 'beforeinput' event handler may destroy target frame. 1057 // 'beforeinput' event handler may destroy target frame.
1058 if (m_frame->document()->frame() != m_frame) 1058 if (m_frame->document()->frame() != m_frame)
1059 return; 1059 return;
1060 } 1060 }
1061 deleteSelectionWithSmartDelete( 1061 deleteSelectionWithSmartDelete(
(...skipping 23 matching lines...) Expand all
1085 Document* document = frame().document(); 1085 Document* document = frame().document();
1086 if (HTMLImageElement* imageElement = 1086 if (HTMLImageElement* imageElement =
1087 imageElementFromImageDocument(document)) 1087 imageElementFromImageDocument(document))
1088 writeImageNodeToPasteboard(Pasteboard::generalPasteboard(), imageElement, 1088 writeImageNodeToPasteboard(Pasteboard::generalPasteboard(), imageElement,
1089 document->title()); 1089 document->title());
1090 else 1090 else
1091 writeSelectionToPasteboard(); 1091 writeSelectionToPasteboard();
1092 } 1092 }
1093 } 1093 }
1094 1094
1095 void Editor::paste(EditorCommandSource source) { 1095 void Editor::paste(CommandSource source) {
1096 DCHECK(frame().document()); 1096 DCHECK(frame().document());
1097 if (tryDHTMLPaste(AllMimeTypes)) 1097 if (tryDHTMLPaste(AllMimeTypes))
1098 return; // DHTML did the whole operation 1098 return; // DHTML did the whole operation
1099 if (!canPaste()) 1099 if (!canPaste())
1100 return; 1100 return;
1101 spellChecker().updateMarkersForWordsAffectedByEditing(false); 1101 spellChecker().updateMarkersForWordsAffectedByEditing(false);
1102 ResourceFetcher* loader = frame().document()->fetcher(); 1102 ResourceFetcher* loader = frame().document()->fetcher();
1103 ResourceCacheValidationSuppressor validationSuppressor(loader); 1103 ResourceCacheValidationSuppressor validationSuppressor(loader);
1104 1104
1105 PasteMode pasteMode = frame().selection().isContentRichlyEditable() 1105 PasteMode pasteMode = frame().selection().isContentRichlyEditable()
1106 ? AllMimeTypes 1106 ? AllMimeTypes
1107 : PlainTextOnly; 1107 : PlainTextOnly;
1108 1108
1109 if (source == CommandFromMenuOrKeyBinding) { 1109 if (source == CommandSource::MenuOrKeyBinding) {
1110 DataTransfer* dataTransfer = 1110 DataTransfer* dataTransfer =
1111 DataTransfer::create(DataTransfer::CopyAndPaste, DataTransferReadable, 1111 DataTransfer::create(DataTransfer::CopyAndPaste, DataTransferReadable,
1112 DataObject::createFromPasteboard(pasteMode)); 1112 DataObject::createFromPasteboard(pasteMode));
1113 1113
1114 if (dispatchBeforeInputDataTransfer(findEventTargetFromSelection(), 1114 if (dispatchBeforeInputDataTransfer(findEventTargetFromSelection(),
1115 InputEvent::InputType::InsertFromPaste, 1115 InputEvent::InputType::InsertFromPaste,
1116 dataTransfer, nullptr) != 1116 dataTransfer, nullptr) !=
1117 DispatchEventResult::NotCanceled) 1117 DispatchEventResult::NotCanceled)
1118 return; 1118 return;
1119 // 'beforeinput' event handler may destroy target frame. 1119 // 'beforeinput' event handler may destroy target frame.
1120 if (m_frame->document()->frame() != m_frame) 1120 if (m_frame->document()->frame() != m_frame)
1121 return; 1121 return;
1122 } 1122 }
1123 1123
1124 if (pasteMode == AllMimeTypes) 1124 if (pasteMode == AllMimeTypes)
1125 pasteWithPasteboard(Pasteboard::generalPasteboard()); 1125 pasteWithPasteboard(Pasteboard::generalPasteboard());
1126 else 1126 else
1127 pasteAsPlainTextWithPasteboard(Pasteboard::generalPasteboard()); 1127 pasteAsPlainTextWithPasteboard(Pasteboard::generalPasteboard());
1128 } 1128 }
1129 1129
1130 void Editor::pasteAsPlainText(EditorCommandSource source) { 1130 void Editor::pasteAsPlainText(CommandSource source) {
1131 if (tryDHTMLPaste(PlainTextOnly)) 1131 if (tryDHTMLPaste(PlainTextOnly))
1132 return; 1132 return;
1133 if (!canPaste()) 1133 if (!canPaste())
1134 return; 1134 return;
1135 spellChecker().updateMarkersForWordsAffectedByEditing(false); 1135 spellChecker().updateMarkersForWordsAffectedByEditing(false);
1136 pasteAsPlainTextWithPasteboard(Pasteboard::generalPasteboard()); 1136 pasteAsPlainTextWithPasteboard(Pasteboard::generalPasteboard());
1137 } 1137 }
1138 1138
1139 void Editor::performDelete() { 1139 void Editor::performDelete() {
1140 if (!canDelete()) 1140 if (!canDelete())
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
1666 } 1666 }
1667 1667
1668 DEFINE_TRACE(Editor) { 1668 DEFINE_TRACE(Editor) {
1669 visitor->trace(m_frame); 1669 visitor->trace(m_frame);
1670 visitor->trace(m_lastEditCommand); 1670 visitor->trace(m_lastEditCommand);
1671 visitor->trace(m_undoStack); 1671 visitor->trace(m_undoStack);
1672 visitor->trace(m_mark); 1672 visitor->trace(m_mark);
1673 } 1673 }
1674 1674
1675 } // namespace blink 1675 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698