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

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

Issue 2847813005: Prune ComputeVisibleSelectionInDOMTree from Editor::Cut/Copy/Paste (Closed)
Patch Set: Created 3 years, 7 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 // needs to be audited. See http://crbug.com/590369 for more details. 1138 // needs to be audited. See http://crbug.com/590369 for more details.
1139 // |tryDHTMLCut| dispatches cut event, which may make layout dirty, but we 1139 // |tryDHTMLCut| dispatches cut event, which may make layout dirty, but we
1140 // need clean layout to obtain the selected content. 1140 // need clean layout to obtain the selected content.
1141 GetFrame().GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets(); 1141 GetFrame().GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets();
1142 1142
1143 // TODO(yosin) We should use early return style here. 1143 // TODO(yosin) We should use early return style here.
1144 if (CanDeleteRange(SelectedRange())) { 1144 if (CanDeleteRange(SelectedRange())) {
1145 GetSpellChecker().UpdateMarkersForWordsAffectedByEditing(true); 1145 GetSpellChecker().UpdateMarkersForWordsAffectedByEditing(true);
1146 if (EnclosingTextControl(GetFrame() 1146 if (EnclosingTextControl(GetFrame()
1147 .Selection() 1147 .Selection()
1148 .ComputeVisibleSelectionInDOMTreeDeprecated() 1148 .ComputeVisibleSelectionInDOMTree()
1149 .Start())) { 1149 .Start())) {
1150 String plain_text = GetFrame().SelectedTextForClipboard(); 1150 String plain_text = GetFrame().SelectedTextForClipboard();
1151 Pasteboard::GeneralPasteboard()->WritePlainText( 1151 Pasteboard::GeneralPasteboard()->WritePlainText(
1152 plain_text, CanSmartCopyOrDelete() ? Pasteboard::kCanSmartReplace 1152 plain_text, CanSmartCopyOrDelete() ? Pasteboard::kCanSmartReplace
1153 : Pasteboard::kCannotSmartReplace); 1153 : Pasteboard::kCannotSmartReplace);
1154 } else { 1154 } else {
1155 WriteSelectionToPasteboard(); 1155 WriteSelectionToPasteboard();
1156 } 1156 }
1157 1157
1158 if (source == kCommandFromMenuOrKeyBinding) { 1158 if (source == kCommandFromMenuOrKeyBinding) {
(...skipping 17 matching lines...) Expand all
1176 return; // DHTML did the whole operation 1176 return; // DHTML did the whole operation
1177 if (!CanCopy()) 1177 if (!CanCopy())
1178 return; 1178 return;
1179 1179
1180 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets 1180 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets
1181 // needs to be audited. See http://crbug.com/590369 for more details. 1181 // needs to be audited. See http://crbug.com/590369 for more details.
1182 // |tryDHTMLCopy| dispatches copy event, which may make layout dirty, but 1182 // |tryDHTMLCopy| dispatches copy event, which may make layout dirty, but
1183 // we need clean layout to obtain the selected content. 1183 // we need clean layout to obtain the selected content.
1184 GetFrame().GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets(); 1184 GetFrame().GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets();
1185 1185
1186 if (EnclosingTextControl(GetFrame() 1186 if (EnclosingTextControl(
1187 .Selection() 1187 GetFrame().Selection().ComputeVisibleSelectionInDOMTree().Start())) {
1188 .ComputeVisibleSelectionInDOMTreeDeprecated()
1189 .Start())) {
1190 Pasteboard::GeneralPasteboard()->WritePlainText( 1188 Pasteboard::GeneralPasteboard()->WritePlainText(
1191 GetFrame().SelectedTextForClipboard(), 1189 GetFrame().SelectedTextForClipboard(),
1192 CanSmartCopyOrDelete() ? Pasteboard::kCanSmartReplace 1190 CanSmartCopyOrDelete() ? Pasteboard::kCanSmartReplace
1193 : Pasteboard::kCannotSmartReplace); 1191 : Pasteboard::kCannotSmartReplace);
1194 } else { 1192 } else {
1195 Document* document = GetFrame().GetDocument(); 1193 Document* document = GetFrame().GetDocument();
1196 if (HTMLImageElement* image_element = 1194 if (HTMLImageElement* image_element =
1197 ImageElementFromImageDocument(document)) 1195 ImageElementFromImageDocument(document))
1198 WriteImageNodeToPasteboard(Pasteboard::GeneralPasteboard(), image_element, 1196 WriteImageNodeToPasteboard(Pasteboard::GeneralPasteboard(), image_element,
1199 document->title()); 1197 document->title());
1200 else 1198 else
1201 WriteSelectionToPasteboard(); 1199 WriteSelectionToPasteboard();
1202 } 1200 }
1203 } 1201 }
1204 1202
1205 void Editor::Paste(EditorCommandSource source) { 1203 void Editor::Paste(EditorCommandSource source) {
1206 DCHECK(GetFrame().GetDocument()); 1204 DCHECK(GetFrame().GetDocument());
1207 if (TryDHTMLPaste(kAllMimeTypes)) 1205 if (TryDHTMLPaste(kAllMimeTypes))
1208 return; // DHTML did the whole operation 1206 return; // DHTML did the whole operation
1209 if (!CanPaste()) 1207 if (!CanPaste())
1210 return; 1208 return;
1211 GetSpellChecker().UpdateMarkersForWordsAffectedByEditing(false); 1209 GetSpellChecker().UpdateMarkersForWordsAffectedByEditing(false);
1212 ResourceFetcher* loader = GetFrame().GetDocument()->Fetcher(); 1210 ResourceFetcher* loader = GetFrame().GetDocument()->Fetcher();
1213 ResourceCacheValidationSuppressor validation_suppressor(loader); 1211 ResourceCacheValidationSuppressor validation_suppressor(loader);
1214 1212
1215 PasteMode paste_mode = GetFrame() 1213 PasteMode paste_mode = GetFrame()
1216 .Selection() 1214 .Selection()
1217 .ComputeVisibleSelectionInDOMTreeDeprecated() 1215 .ComputeVisibleSelectionInDOMTree()
1218 .IsContentRichlyEditable() 1216 .IsContentRichlyEditable()
1219 ? kAllMimeTypes 1217 ? kAllMimeTypes
1220 : kPlainTextOnly; 1218 : kPlainTextOnly;
1221 1219
1222 if (source == kCommandFromMenuOrKeyBinding) { 1220 if (source == kCommandFromMenuOrKeyBinding) {
1223 DataTransfer* data_transfer = 1221 DataTransfer* data_transfer =
1224 DataTransfer::Create(DataTransfer::kCopyAndPaste, kDataTransferReadable, 1222 DataTransfer::Create(DataTransfer::kCopyAndPaste, kDataTransferReadable,
1225 DataObject::CreateFromPasteboard(paste_mode)); 1223 DataObject::CreateFromPasteboard(paste_mode));
1226 1224
1227 if (DispatchBeforeInputDataTransfer(FindEventTargetFromSelection(), 1225 if (DispatchBeforeInputDataTransfer(FindEventTargetFromSelection(),
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
1820 1818
1821 DEFINE_TRACE(Editor) { 1819 DEFINE_TRACE(Editor) {
1822 visitor->Trace(frame_); 1820 visitor->Trace(frame_);
1823 visitor->Trace(last_edit_command_); 1821 visitor->Trace(last_edit_command_);
1824 visitor->Trace(undo_stack_); 1822 visitor->Trace(undo_stack_);
1825 visitor->Trace(mark_); 1823 visitor->Trace(mark_);
1826 visitor->Trace(typing_style_); 1824 visitor->Trace(typing_style_);
1827 } 1825 }
1828 1826
1829 } // namespace blink 1827 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698