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

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

Issue 1406713002: Make queryCommandSupported(copy|cut|paste) always return true (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2015-10-15T17:15:20 Created 5 years, 2 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 | « third_party/WebKit/LayoutTests/editing/pasteboard/copy-cut-paste-supported.html ('k') | 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 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 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 * Copyright (C) 2009 Igalia S.L. 4 * Copyright (C) 2009 Igalia S.L.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 class EditorInternalCommand { 73 class EditorInternalCommand {
74 public: 74 public:
75 int idForUserMetrics; 75 int idForUserMetrics;
76 bool (*execute)(LocalFrame&, Event*, EditorCommandSource, const String&); 76 bool (*execute)(LocalFrame&, Event*, EditorCommandSource, const String&);
77 bool (*isSupportedFromDOM)(LocalFrame*); 77 bool (*isSupportedFromDOM)(LocalFrame*);
78 bool (*isEnabled)(LocalFrame&, Event*, EditorCommandSource); 78 bool (*isEnabled)(LocalFrame&, Event*, EditorCommandSource);
79 TriState (*state)(LocalFrame&, Event*); 79 TriState (*state)(LocalFrame&, Event*);
80 String (*value)(LocalFrame&, Event*); 80 String (*value)(LocalFrame&, Event*);
81 bool isTextInsertion; 81 bool isTextInsertion;
82 // TODO(yosin) We should have |canExecute()|, which checks clipboard
83 // accessibility to simplify |Editor::Command::execute()|.
82 bool allowExecutionWhenDisabled; 84 bool allowExecutionWhenDisabled;
83 }; 85 };
84 86
85 typedef HashMap<String, const EditorInternalCommand*, CaseFoldingHash> CommandMa p; 87 typedef HashMap<String, const EditorInternalCommand*, CaseFoldingHash> CommandMa p;
86 88
87 static const bool notTextInsertion = false; 89 static const bool notTextInsertion = false;
88 static const bool isTextInsertion = true; 90 static const bool isTextInsertion = true;
89 91
90 static const bool allowExecutionWhenDisabled = true; 92 static const bool allowExecutionWhenDisabled = true;
91 static const bool doNotAllowExecutionWhenDisabled = false; 93 static const bool doNotAllowExecutionWhenDisabled = false;
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 return EphemeralRange(startPosition, endPosition); 290 return EphemeralRange(startPosition, endPosition);
289 } 291 }
290 292
291 // Execute command functions 293 // Execute command functions
292 294
293 static bool executeBackColor(LocalFrame& frame, Event*, EditorCommandSource sour ce, const String& value) 295 static bool executeBackColor(LocalFrame& frame, Event*, EditorCommandSource sour ce, const String& value)
294 { 296 {
295 return executeApplyStyle(frame, source, EditActionSetBackgroundColor, CSSPro pertyBackgroundColor, value); 297 return executeApplyStyle(frame, source, EditActionSetBackgroundColor, CSSPro pertyBackgroundColor, value);
296 } 298 }
297 299
298 static bool executeCopy(LocalFrame& frame, Event*, EditorCommandSource, const St ring&) 300 static bool canWriteClipboard(LocalFrame& frame, EditorCommandSource source)
299 { 301 {
302 if (source == CommandFromMenuOrKeyBinding)
303 return true;
304 Settings* settings = frame.settings();
305 bool defaultValue = (settings && settings->javaScriptCanAccessClipboard()) | | UserGestureIndicator::processingUserGesture();
306 return frame.editor().client().canCopyCut(&frame, defaultValue);
307 }
308
309 static bool executeCopy(LocalFrame& frame, Event*, EditorCommandSource source, c onst String&)
310 {
311 // To support |allowExecutionWhenDisabled|, we need to check clipboard
312 // accessibility here rather than |Editor::Command::execute()|.
313 // TODO(yosin) We should move checking |canWriteClipboard()| to
314 // |Editor::Command::execute()| with introducing appropriate predicate, e.g.
315 // |canExecute()|. See also "Cut", and "Paste" command.
316 if (!canWriteClipboard(frame, source))
317 return false;
300 frame.editor().copy(); 318 frame.editor().copy();
301 return true; 319 return true;
302 } 320 }
303 321
304 static bool executeCreateLink(LocalFrame& frame, Event*, EditorCommandSource, co nst String& value) 322 static bool executeCreateLink(LocalFrame& frame, Event*, EditorCommandSource, co nst String& value)
305 { 323 {
306 if (value.isEmpty()) 324 if (value.isEmpty())
307 return false; 325 return false;
308 ASSERT(frame.document()); 326 ASSERT(frame.document());
309 CreateLinkCommand::create(*frame.document(), value)->apply(); 327 CreateLinkCommand::create(*frame.document(), value)->apply();
310 return true; 328 return true;
311 } 329 }
312 330
313 static bool executeCut(LocalFrame& frame, Event*, EditorCommandSource, const Str ing&) 331 static bool executeCut(LocalFrame& frame, Event*, EditorCommandSource source, co nst String&)
314 { 332 {
333 // To support |allowExecutionWhenDisabled|, we need to check clipboard
334 // accessibility here rather than |Editor::Command::execute()|.
335 // TODO(yosin) We should move checking |canWriteClipboard()| to
336 // |Editor::Command::execute()| with introducing appropriate predicate, e.g.
337 // |canExecute()|. See also "Copy", and "Paste" command.
338 if (!canWriteClipboard(frame, source))
339 return false;
315 frame.editor().cut(); 340 frame.editor().cut();
316 return true; 341 return true;
317 } 342 }
318 343
319 static bool executeDefaultParagraphSeparator(LocalFrame& frame, Event*, EditorCo mmandSource, const String& value) 344 static bool executeDefaultParagraphSeparator(LocalFrame& frame, Event*, EditorCo mmandSource, const String& value)
320 { 345 {
321 if (equalIgnoringCase(value, "div")) 346 if (equalIgnoringCase(value, "div"))
322 frame.editor().setDefaultParagraphSeparator(EditorParagraphSeparatorIsDi v); 347 frame.editor().setDefaultParagraphSeparator(EditorParagraphSeparatorIsDi v);
323 else if (equalIgnoringCase(value, "p")) 348 else if (equalIgnoringCase(value, "p"))
324 frame.editor().setDefaultParagraphSeparator(EditorParagraphSeparatorIsP) ; 349 frame.editor().setDefaultParagraphSeparator(EditorParagraphSeparatorIsP) ;
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 IndentOutdentCommand::create(*frame.document(), IndentOutdentCommand::Outden t)->apply(); 959 IndentOutdentCommand::create(*frame.document(), IndentOutdentCommand::Outden t)->apply();
935 return true; 960 return true;
936 } 961 }
937 962
938 static bool executeToggleOverwrite(LocalFrame& frame, Event*, EditorCommandSourc e, const String&) 963 static bool executeToggleOverwrite(LocalFrame& frame, Event*, EditorCommandSourc e, const String&)
939 { 964 {
940 frame.editor().toggleOverwriteModeEnabled(); 965 frame.editor().toggleOverwriteModeEnabled();
941 return true; 966 return true;
942 } 967 }
943 968
944 static bool executePaste(LocalFrame& frame, Event*, EditorCommandSource, const S tring&) 969 static bool canReadClipboard(LocalFrame& frame, EditorCommandSource source)
945 { 970 {
971 if (source == CommandFromMenuOrKeyBinding)
972 return true;
973 Settings* settings = frame.settings();
974 bool defaultValue = settings && settings->javaScriptCanAccessClipboard() && settings->DOMPasteAllowed();
975 return frame.editor().client().canPaste(&frame, defaultValue);
976 }
977
978 static bool executePaste(LocalFrame& frame, Event*, EditorCommandSource source, const String&)
979 {
980 // To support |allowExecutionWhenDisabled|, we need to check clipboard
981 // accessibility here rather than |Editor::Command::execute()|.
982 // TODO(yosin) We should move checking |canReadClipboard()| to
983 // |Editor::Command::execute()| with introducing appropriate predicate, e.g.
984 // |canExecute()|. See also "Copy", and "Cut" command.
985 if (!canReadClipboard(frame, source))
986 return false;
946 frame.editor().paste(); 987 frame.editor().paste();
947 return true; 988 return true;
948 } 989 }
949 990
950 static bool executePasteGlobalSelection(LocalFrame& frame, Event*, EditorCommand Source source, const String&) 991 static bool executePasteGlobalSelection(LocalFrame& frame, Event*, EditorCommand Source source, const String&)
951 { 992 {
993 // To support |allowExecutionWhenDisabled|, we need to check clipboard
994 // accessibility here rather than |Editor::Command::execute()|.
995 // TODO(yosin) We should move checking |canReadClipboard()| to
996 // |Editor::Command::execute()| with introducing appropriate predicate, e.g.
997 // |canExecute()|. See also "Copy", and "Cut" command.
998 if (!canReadClipboard(frame, source))
999 return false;
952 if (!frame.editor().behavior().supportsGlobalSelection()) 1000 if (!frame.editor().behavior().supportsGlobalSelection())
953 return false; 1001 return false;
954 ASSERT_UNUSED(source, source == CommandFromMenuOrKeyBinding); 1002 ASSERT_UNUSED(source, source == CommandFromMenuOrKeyBinding);
955 1003
956 bool oldSelectionMode = Pasteboard::generalPasteboard()->isSelectionMode(); 1004 bool oldSelectionMode = Pasteboard::generalPasteboard()->isSelectionMode();
957 Pasteboard::generalPasteboard()->setSelectionMode(true); 1005 Pasteboard::generalPasteboard()->setSelectionMode(true);
958 frame.editor().paste(); 1006 frame.editor().paste();
959 Pasteboard::generalPasteboard()->setSelectionMode(oldSelectionMode); 1007 Pasteboard::generalPasteboard()->setSelectionMode(oldSelectionMode);
960 return true; 1008 return true;
961 } 1009 }
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 static bool supported(LocalFrame*) 1211 static bool supported(LocalFrame*)
1164 { 1212 {
1165 return true; 1213 return true;
1166 } 1214 }
1167 1215
1168 static bool supportedFromMenuOrKeyBinding(LocalFrame*) 1216 static bool supportedFromMenuOrKeyBinding(LocalFrame*)
1169 { 1217 {
1170 return false; 1218 return false;
1171 } 1219 }
1172 1220
1173 static bool supportedCopyCut(LocalFrame* frame)
1174 {
1175 if (!frame)
1176 return false;
1177
1178 Settings* settings = frame->settings();
1179 bool defaultValue = (settings && settings->javaScriptCanAccessClipboard()) | | UserGestureIndicator::processingUserGesture();
1180 return frame->editor().client().canCopyCut(frame, defaultValue);
1181 }
1182
1183 static bool supportedPaste(LocalFrame* frame)
1184 {
1185 if (!frame)
1186 return false;
1187
1188 Settings* settings = frame->settings();
1189 bool defaultValue = settings && settings->javaScriptCanAccessClipboard() && settings->DOMPasteAllowed();
1190 return frame->editor().client().canPaste(frame, defaultValue);
1191 }
1192
1193 // Enabled functions 1221 // Enabled functions
1194 1222
1195 static bool enabled(LocalFrame&, Event*, EditorCommandSource) 1223 static bool enabled(LocalFrame&, Event*, EditorCommandSource)
1196 { 1224 {
1197 return true; 1225 return true;
1198 } 1226 }
1199 1227
1200 static bool enabledVisibleSelection(LocalFrame& frame, Event* event, EditorComma ndSource) 1228 static bool enabledVisibleSelection(LocalFrame& frame, Event* event, EditorComma ndSource)
1201 { 1229 {
1202 // The term "visible" here includes a caret in editable text or a range in a ny text. 1230 // The term "visible" here includes a caret in editable text or a range in a ny text.
(...skipping 20 matching lines...) Expand all
1223 return ((selection.isCaret() && selection.isContentEditable()) || selection. isRange()) 1251 return ((selection.isCaret() && selection.isContentEditable()) || selection. isRange())
1224 && frame.editor().mark().isCaretOrRange(); 1252 && frame.editor().mark().isCaretOrRange();
1225 } 1253 }
1226 1254
1227 static bool enableCaretInEditableText(LocalFrame& frame, Event* event, EditorCom mandSource) 1255 static bool enableCaretInEditableText(LocalFrame& frame, Event* event, EditorCom mandSource)
1228 { 1256 {
1229 const VisibleSelection& selection = frame.editor().selectionForCommand(event ); 1257 const VisibleSelection& selection = frame.editor().selectionForCommand(event );
1230 return selection.isCaret() && selection.isContentEditable(); 1258 return selection.isCaret() && selection.isContentEditable();
1231 } 1259 }
1232 1260
1233 static bool enabledCopy(LocalFrame& frame, Event*, EditorCommandSource) 1261 static bool enabledCopy(LocalFrame& frame, Event*, EditorCommandSource source)
1234 { 1262 {
1263 if (!canWriteClipboard(frame, source))
1264 return false;
1235 return frame.editor().canDHTMLCopy() || frame.editor().canCopy(); 1265 return frame.editor().canDHTMLCopy() || frame.editor().canCopy();
1236 } 1266 }
1237 1267
1238 static bool enabledCut(LocalFrame& frame, Event*, EditorCommandSource) 1268 static bool enabledCut(LocalFrame& frame, Event*, EditorCommandSource source)
1239 { 1269 {
1270 if (!canWriteClipboard(frame, source))
1271 return false;
1240 return frame.editor().canDHTMLCut() || frame.editor().canCut(); 1272 return frame.editor().canDHTMLCut() || frame.editor().canCut();
1241 } 1273 }
1242 1274
1243 static bool enabledInEditableText(LocalFrame& frame, Event* event, EditorCommand Source) 1275 static bool enabledInEditableText(LocalFrame& frame, Event* event, EditorCommand Source)
1244 { 1276 {
1245 return frame.editor().selectionForCommand(event).rootEditableElement(); 1277 return frame.editor().selectionForCommand(event).rootEditableElement();
1246 } 1278 }
1247 1279
1248 static bool enabledDelete(LocalFrame& frame, Event* event, EditorCommandSource s ource) 1280 static bool enabledDelete(LocalFrame& frame, Event* event, EditorCommandSource s ource)
1249 { 1281 {
(...skipping 13 matching lines...) Expand all
1263 { 1295 {
1264 // The EditorCommandSource parameter is unused in enabledInEditableText, so just pass a dummy variable 1296 // The EditorCommandSource parameter is unused in enabledInEditableText, so just pass a dummy variable
1265 return caretBrowsingEnabled(frame) || enabledInEditableText(frame, event, du mmyEditorCommandSource); 1297 return caretBrowsingEnabled(frame) || enabledInEditableText(frame, event, du mmyEditorCommandSource);
1266 } 1298 }
1267 1299
1268 static bool enabledInRichlyEditableText(LocalFrame& frame, Event*, EditorCommand Source) 1300 static bool enabledInRichlyEditableText(LocalFrame& frame, Event*, EditorCommand Source)
1269 { 1301 {
1270 return frame.selection().isCaretOrRange() && frame.selection().isContentRich lyEditable() && frame.selection().rootEditableElement(); 1302 return frame.selection().isCaretOrRange() && frame.selection().isContentRich lyEditable() && frame.selection().rootEditableElement();
1271 } 1303 }
1272 1304
1273 static bool enabledPaste(LocalFrame& frame, Event*, EditorCommandSource) 1305 static bool enabledPaste(LocalFrame& frame, Event*, EditorCommandSource source)
1274 { 1306 {
1307 if (!canReadClipboard(frame, source))
1308 return false;
1275 return frame.editor().canPaste(); 1309 return frame.editor().canPaste();
1276 } 1310 }
1277 1311
1278 static bool enabledRangeInEditableText(LocalFrame& frame, Event*, EditorCommandS ource) 1312 static bool enabledRangeInEditableText(LocalFrame& frame, Event*, EditorCommandS ource)
1279 { 1313 {
1280 return frame.selection().isRange() && frame.selection().isContentEditable(); 1314 return frame.selection().isRange() && frame.selection().isContentEditable();
1281 } 1315 }
1282 1316
1283 static bool enabledRangeInRichlyEditableText(LocalFrame& frame, Event*, EditorCo mmandSource) 1317 static bool enabledRangeInRichlyEditableText(LocalFrame& frame, Event*, EditorCo mmandSource)
1284 { 1318 {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 // If you add new commands, you should assign new Id to each idForUserMetric s and update MappedEditingCommands 1484 // If you add new commands, you should assign new Id to each idForUserMetric s and update MappedEditingCommands
1451 // in chrome/trunk/src/tools/metrics/histograms/histograms.xml. 1485 // in chrome/trunk/src/tools/metrics/histograms/histograms.xml.
1452 static const CommandEntry commands[] = { 1486 static const CommandEntry commands[] = {
1453 { "AlignCenter", {139, executeJustifyCenter, supportedFromMenuOrKeyBindi ng, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAl lowExecutionWhenDisabled } }, 1487 { "AlignCenter", {139, executeJustifyCenter, supportedFromMenuOrKeyBindi ng, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAl lowExecutionWhenDisabled } },
1454 { "AlignJustified", {1, executeJustifyFull, supportedFromMenuOrKeyBindin g, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAll owExecutionWhenDisabled } }, 1488 { "AlignJustified", {1, executeJustifyFull, supportedFromMenuOrKeyBindin g, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAll owExecutionWhenDisabled } },
1455 { "AlignLeft", {2, executeJustifyLeft, supportedFromMenuOrKeyBinding, en abledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExe cutionWhenDisabled } }, 1489 { "AlignLeft", {2, executeJustifyLeft, supportedFromMenuOrKeyBinding, en abledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExe cutionWhenDisabled } },
1456 { "AlignRight", {3, executeJustifyRight, supportedFromMenuOrKeyBinding, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAllowE xecutionWhenDisabled } }, 1490 { "AlignRight", {3, executeJustifyRight, supportedFromMenuOrKeyBinding, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAllowE xecutionWhenDisabled } },
1457 { "BackColor", {4, executeBackColor, supported, enabledInRichlyEditableT ext, stateNone, valueBackColor, notTextInsertion, doNotAllowExecutionWhenDisable d } }, 1491 { "BackColor", {4, executeBackColor, supported, enabledInRichlyEditableT ext, stateNone, valueBackColor, notTextInsertion, doNotAllowExecutionWhenDisable d } },
1458 { "BackwardDelete", {5, executeDeleteBackward, supportedFromMenuOrKeyBin ding, enabledInEditableText, stateNone, valueNull, notTextInsertion, doNotAllowE xecutionWhenDisabled } }, // FIXME: remove BackwardDelete when Safari for Window s stops using it. 1492 { "BackwardDelete", {5, executeDeleteBackward, supportedFromMenuOrKeyBin ding, enabledInEditableText, stateNone, valueNull, notTextInsertion, doNotAllowE xecutionWhenDisabled } }, // FIXME: remove BackwardDelete when Safari for Window s stops using it.
1459 { "Bold", {6, executeToggleBold, supported, enabledInRichlyEditableText, stateBold, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } }, 1493 { "Bold", {6, executeToggleBold, supported, enabledInRichlyEditableText, stateBold, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
1460 { "Copy", {7, executeCopy, supportedCopyCut, enabledCopy, stateNone, val ueNull, notTextInsertion, allowExecutionWhenDisabled } }, 1494 { "Copy", {7, executeCopy, supported, enabledCopy, stateNone, valueNull, notTextInsertion, allowExecutionWhenDisabled } },
1461 { "CreateLink", {8, executeCreateLink, supported, enabledInRichlyEditabl eText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } }, 1495 { "CreateLink", {8, executeCreateLink, supported, enabledInRichlyEditabl eText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
1462 { "Cut", {9, executeCut, supportedCopyCut, enabledCut, stateNone, valueN ull, notTextInsertion, allowExecutionWhenDisabled } }, 1496 { "Cut", {9, executeCut, supported, enabledCut, stateNone, valueNull, no tTextInsertion, allowExecutionWhenDisabled } },
1463 { "DefaultParagraphSeparator", {10, executeDefaultParagraphSeparator, su pported, enabled, stateNone, valueDefaultParagraphSeparator, notTextInsertion, d oNotAllowExecutionWhenDisabled} }, 1497 { "DefaultParagraphSeparator", {10, executeDefaultParagraphSeparator, su pported, enabled, stateNone, valueDefaultParagraphSeparator, notTextInsertion, d oNotAllowExecutionWhenDisabled} },
1464 { "Delete", {11, executeDelete, supported, enabledDelete, stateNone, val ueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } }, 1498 { "Delete", {11, executeDelete, supported, enabledDelete, stateNone, val ueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
1465 { "DeleteBackward", {12, executeDeleteBackward, supportedFromMenuOrKeyBi nding, enabledInEditableText, stateNone, valueNull, notTextInsertion, doNotAllow ExecutionWhenDisabled } }, 1499 { "DeleteBackward", {12, executeDeleteBackward, supportedFromMenuOrKeyBi nding, enabledInEditableText, stateNone, valueNull, notTextInsertion, doNotAllow ExecutionWhenDisabled } },
1466 { "DeleteBackwardByDecomposingPreviousCharacter", {13, executeDeleteBack wardByDecomposingPreviousCharacter, supportedFromMenuOrKeyBinding, enabledInEdit ableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisable d } }, 1500 { "DeleteBackwardByDecomposingPreviousCharacter", {13, executeDeleteBack wardByDecomposingPreviousCharacter, supportedFromMenuOrKeyBinding, enabledInEdit ableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisable d } },
1467 { "DeleteForward", {14, executeDeleteForward, supportedFromMenuOrKeyBind ing, enabledInEditableText, stateNone, valueNull, notTextInsertion, doNotAllowEx ecutionWhenDisabled } }, 1501 { "DeleteForward", {14, executeDeleteForward, supportedFromMenuOrKeyBind ing, enabledInEditableText, stateNone, valueNull, notTextInsertion, doNotAllowEx ecutionWhenDisabled } },
1468 { "DeleteToBeginningOfLine", {15, executeDeleteToBeginningOfLine, suppor tedFromMenuOrKeyBinding, enabledInEditableText, stateNone, valueNull, notTextIns ertion, doNotAllowExecutionWhenDisabled } }, 1502 { "DeleteToBeginningOfLine", {15, executeDeleteToBeginningOfLine, suppor tedFromMenuOrKeyBinding, enabledInEditableText, stateNone, valueNull, notTextIns ertion, doNotAllowExecutionWhenDisabled } },
1469 { "DeleteToBeginningOfParagraph", {16, executeDeleteToBeginningOfParagra ph, supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } }, 1503 { "DeleteToBeginningOfParagraph", {16, executeDeleteToBeginningOfParagra ph, supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
1470 { "DeleteToEndOfLine", {17, executeDeleteToEndOfLine, supportedFromMenuO rKeyBinding, enabledInEditableText, stateNone, valueNull, notTextInsertion, doNo tAllowExecutionWhenDisabled } }, 1504 { "DeleteToEndOfLine", {17, executeDeleteToEndOfLine, supportedFromMenuO rKeyBinding, enabledInEditableText, stateNone, valueNull, notTextInsertion, doNo tAllowExecutionWhenDisabled } },
1471 { "DeleteToEndOfParagraph", {18, executeDeleteToEndOfParagraph, supporte dFromMenuOrKeyBinding, enabledInEditableText, stateNone, valueNull, notTextInser tion, doNotAllowExecutionWhenDisabled } }, 1505 { "DeleteToEndOfParagraph", {18, executeDeleteToEndOfParagraph, supporte dFromMenuOrKeyBinding, enabledInEditableText, stateNone, valueNull, notTextInser tion, doNotAllowExecutionWhenDisabled } },
1472 { "DeleteToMark", {19, executeDeleteToMark, supportedFromMenuOrKeyBindin g, enabledInEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExec utionWhenDisabled } }, 1506 { "DeleteToMark", {19, executeDeleteToMark, supportedFromMenuOrKeyBindin g, enabledInEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExec utionWhenDisabled } },
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1546 { "MoveWordBackward", {93, executeMoveWordBackward, supportedFromMenuOrK eyBinding, enabledInEditableTextOrCaretBrowsing, stateNone, valueNull, notTextIn sertion, doNotAllowExecutionWhenDisabled } }, 1580 { "MoveWordBackward", {93, executeMoveWordBackward, supportedFromMenuOrK eyBinding, enabledInEditableTextOrCaretBrowsing, stateNone, valueNull, notTextIn sertion, doNotAllowExecutionWhenDisabled } },
1547 { "MoveWordBackwardAndModifySelection", {94, executeMoveWordBackwardAndM odifySelection, supportedFromMenuOrKeyBinding, enabledVisibleSelectionOrCaretBro wsing, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } }, 1581 { "MoveWordBackwardAndModifySelection", {94, executeMoveWordBackwardAndM odifySelection, supportedFromMenuOrKeyBinding, enabledVisibleSelectionOrCaretBro wsing, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
1548 { "MoveWordForward", {95, executeMoveWordForward, supportedFromMenuOrKey Binding, enabledInEditableTextOrCaretBrowsing, stateNone, valueNull, notTextInse rtion, doNotAllowExecutionWhenDisabled } }, 1582 { "MoveWordForward", {95, executeMoveWordForward, supportedFromMenuOrKey Binding, enabledInEditableTextOrCaretBrowsing, stateNone, valueNull, notTextInse rtion, doNotAllowExecutionWhenDisabled } },
1549 { "MoveWordForwardAndModifySelection", {96, executeMoveWordForwardAndMod ifySelection, supportedFromMenuOrKeyBinding, enabledVisibleSelectionOrCaretBrows ing, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } } , 1583 { "MoveWordForwardAndModifySelection", {96, executeMoveWordForwardAndMod ifySelection, supportedFromMenuOrKeyBinding, enabledVisibleSelectionOrCaretBrows ing, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } } ,
1550 { "MoveWordLeft", {97, executeMoveWordLeft, supportedFromMenuOrKeyBindin g, enabledInEditableTextOrCaretBrowsing, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } }, 1584 { "MoveWordLeft", {97, executeMoveWordLeft, supportedFromMenuOrKeyBindin g, enabledInEditableTextOrCaretBrowsing, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
1551 { "MoveWordLeftAndModifySelection", {98, executeMoveWordLeftAndModifySel ection, supportedFromMenuOrKeyBinding, enabledVisibleSelectionOrCaretBrowsing, s tateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } }, 1585 { "MoveWordLeftAndModifySelection", {98, executeMoveWordLeftAndModifySel ection, supportedFromMenuOrKeyBinding, enabledVisibleSelectionOrCaretBrowsing, s tateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
1552 { "MoveWordRight", {99, executeMoveWordRight, supportedFromMenuOrKeyBind ing, enabledInEditableTextOrCaretBrowsing, stateNone, valueNull, notTextInsertio n, doNotAllowExecutionWhenDisabled } }, 1586 { "MoveWordRight", {99, executeMoveWordRight, supportedFromMenuOrKeyBind ing, enabledInEditableTextOrCaretBrowsing, stateNone, valueNull, notTextInsertio n, doNotAllowExecutionWhenDisabled } },
1553 { "MoveWordRightAndModifySelection", {100, executeMoveWordRightAndModify Selection, supportedFromMenuOrKeyBinding, enabledVisibleSelectionOrCaretBrowsing , stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } }, 1587 { "MoveWordRightAndModifySelection", {100, executeMoveWordRightAndModify Selection, supportedFromMenuOrKeyBinding, enabledVisibleSelectionOrCaretBrowsing , stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
1554 { "Outdent", {101, executeOutdent, supported, enabledInRichlyEditableTex t, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } }, 1588 { "Outdent", {101, executeOutdent, supported, enabledInRichlyEditableTex t, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
1555 { "OverWrite", {102, executeToggleOverwrite, supportedFromMenuOrKeyBindi ng, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAl lowExecutionWhenDisabled } }, 1589 { "OverWrite", {102, executeToggleOverwrite, supportedFromMenuOrKeyBindi ng, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAl lowExecutionWhenDisabled } },
1556 { "Paste", {103, executePaste, supportedPaste, enabledPaste, stateNone, valueNull, notTextInsertion, allowExecutionWhenDisabled } }, 1590 { "Paste", {103, executePaste, supported, enabledPaste, stateNone, value Null, notTextInsertion, allowExecutionWhenDisabled } },
1557 { "PasteAndMatchStyle", {104, executePasteAndMatchStyle, supportedPaste, enabledPaste, stateNone, valueNull, notTextInsertion, allowExecutionWhenDisable d } }, 1591 { "PasteAndMatchStyle", {104, executePasteAndMatchStyle, supported, enab ledPaste, stateNone, valueNull, notTextInsertion, allowExecutionWhenDisabled } } ,
1558 { "PasteGlobalSelection", {105, executePasteGlobalSelection, supportedFr omMenuOrKeyBinding, enabledPaste, stateNone, valueNull, notTextInsertion, allowE xecutionWhenDisabled } }, 1592 { "PasteGlobalSelection", {105, executePasteGlobalSelection, supportedFr omMenuOrKeyBinding, enabledPaste, stateNone, valueNull, notTextInsertion, allowE xecutionWhenDisabled } },
1559 { "Print", {106, executePrint, supported, enabled, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } }, 1593 { "Print", {106, executePrint, supported, enabled, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
1560 { "Redo", {107, executeRedo, supported, enabledRedo, stateNone, valueNul l, notTextInsertion, doNotAllowExecutionWhenDisabled } }, 1594 { "Redo", {107, executeRedo, supported, enabledRedo, stateNone, valueNul l, notTextInsertion, doNotAllowExecutionWhenDisabled } },
1561 { "RemoveFormat", {108, executeRemoveFormat, supported, enabledRangeInEd itableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisab led } }, 1595 { "RemoveFormat", {108, executeRemoveFormat, supported, enabledRangeInEd itableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisab led } },
1562 { "ScrollPageBackward", {109, executeScrollPageBackward, supportedFromMe nuOrKeyBinding, enabled, stateNone, valueNull, notTextInsertion, doNotAllowExecu tionWhenDisabled } }, 1596 { "ScrollPageBackward", {109, executeScrollPageBackward, supportedFromMe nuOrKeyBinding, enabled, stateNone, valueNull, notTextInsertion, doNotAllowExecu tionWhenDisabled } },
1563 { "ScrollPageForward", {110, executeScrollPageForward, supportedFromMenu OrKeyBinding, enabled, stateNone, valueNull, notTextInsertion, doNotAllowExecuti onWhenDisabled } }, 1597 { "ScrollPageForward", {110, executeScrollPageForward, supportedFromMenu OrKeyBinding, enabled, stateNone, valueNull, notTextInsertion, doNotAllowExecuti onWhenDisabled } },
1564 { "ScrollLineUp", {111, executeScrollLineUp, supportedFromMenuOrKeyBindi ng, enabled, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisa bled } }, 1598 { "ScrollLineUp", {111, executeScrollLineUp, supportedFromMenuOrKeyBindi ng, enabled, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisa bled } },
1565 { "ScrollLineDown", {112, executeScrollLineDown, supportedFromMenuOrKeyB inding, enabled, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhen Disabled } }, 1599 { "ScrollLineDown", {112, executeScrollLineDown, supportedFromMenuOrKeyB inding, enabled, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhen Disabled } },
1566 { "ScrollToBeginningOfDocument", {113, executeScrollToBeginningOfDocumen t, supportedFromMenuOrKeyBinding, enabled, stateNone, valueNull, notTextInsertio n, doNotAllowExecutionWhenDisabled } }, 1600 { "ScrollToBeginningOfDocument", {113, executeScrollToBeginningOfDocumen t, supportedFromMenuOrKeyBinding, enabled, stateNone, valueNull, notTextInsertio n, doNotAllowExecutionWhenDisabled } },
1567 { "ScrollToEndOfDocument", {114, executeScrollToEndOfDocument, supported FromMenuOrKeyBinding, enabled, stateNone, valueNull, notTextInsertion, doNotAllo wExecutionWhenDisabled } }, 1601 { "ScrollToEndOfDocument", {114, executeScrollToEndOfDocument, supported FromMenuOrKeyBinding, enabled, stateNone, valueNull, notTextInsertion, doNotAllo wExecutionWhenDisabled } },
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 { 1758 {
1725 // Use separate assertions so we can tell which bad thing happened. 1759 // Use separate assertions so we can tell which bad thing happened.
1726 if (!command) 1760 if (!command)
1727 ASSERT(!m_frame); 1761 ASSERT(!m_frame);
1728 else 1762 else
1729 ASSERT(m_frame); 1763 ASSERT(m_frame);
1730 } 1764 }
1731 1765
1732 bool Editor::Command::execute(const String& parameter, Event* triggeringEvent) c onst 1766 bool Editor::Command::execute(const String& parameter, Event* triggeringEvent) c onst
1733 { 1767 {
1768 // TODO(yosin) We should move this logic into |canExecute()| member function
1769 // in |EditorInternalCommand| to replace |allowExecutionWhenDisabled|.
1770 // |allowExecutionWhenDisabled| is for "Copy", "Cut" and "Paste" commands
1771 // only.
1734 if (!isEnabled(triggeringEvent)) { 1772 if (!isEnabled(triggeringEvent)) {
1735 // Let certain commands be executed when performed explicitly even if th ey are disabled. 1773 // Let certain commands be executed when performed explicitly even if th ey are disabled.
1736 if (!isSupported() || !m_frame || !m_command->allowExecutionWhenDisabled ) 1774 if (!isSupported() || !m_frame || !m_command->allowExecutionWhenDisabled )
1737 return false; 1775 return false;
1738 } 1776 }
1739 frame().document()->updateLayoutIgnorePendingStylesheets(); 1777 frame().document()->updateLayoutIgnorePendingStylesheets();
1740 Platform::current()->histogramSparse("WebCore.Editing.Commands", m_command-> idForUserMetrics); 1778 Platform::current()->histogramSparse("WebCore.Editing.Commands", m_command-> idForUserMetrics);
1741 return m_command->execute(*m_frame, triggeringEvent, m_source, parameter); 1779 return m_command->execute(*m_frame, triggeringEvent, m_source, parameter);
1742 } 1780 }
1743 1781
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1787 { 1825 {
1788 return m_command && m_command->isTextInsertion; 1826 return m_command && m_command->isTextInsertion;
1789 } 1827 }
1790 1828
1791 int Editor::Command::idForHistogram() const 1829 int Editor::Command::idForHistogram() const
1792 { 1830 {
1793 return isSupported() ? m_command->idForUserMetrics : 0; 1831 return isSupported() ? m_command->idForUserMetrics : 0;
1794 } 1832 }
1795 1833
1796 } // namespace blink 1834 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/editing/pasteboard/copy-cut-paste-supported.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698