OLD | NEW |
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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 case CommandType::DeleteToBeginningOfParagraph: | 153 case CommandType::DeleteToBeginningOfParagraph: |
154 case CommandType::DeleteToEndOfParagraph: | 154 case CommandType::DeleteToEndOfParagraph: |
155 case CommandType::DeleteToMark: | 155 case CommandType::DeleteToMark: |
156 return InputType::None; | 156 return InputType::None; |
157 | 157 |
158 // Command. | 158 // Command. |
159 case CommandType::Undo: | 159 case CommandType::Undo: |
160 return InputType::Undo; | 160 return InputType::Undo; |
161 case CommandType::Redo: | 161 case CommandType::Redo: |
162 return InputType::Redo; | 162 return InputType::Redo; |
163 case CommandType::Copy: | 163 // Cut and Paste will be handled in |Editor::dispatchCPPEvent()|. |
164 return InputType::Copy; | |
165 case CommandType::Cut: | |
166 return InputType::Cut; | |
167 case CommandType::Paste: | |
168 return InputType::Paste; | |
169 | 164 |
170 // Styling. | 165 // Styling. |
171 case CommandType::Bold: | 166 case CommandType::Bold: |
172 case CommandType::ToggleBold: | 167 case CommandType::ToggleBold: |
173 return InputType::Bold; | 168 return InputType::Bold; |
174 case CommandType::Italic: | 169 case CommandType::Italic: |
175 case CommandType::ToggleItalic: | 170 case CommandType::ToggleItalic: |
176 return InputType::Italic; | 171 return InputType::Italic; |
177 case CommandType::Underline: | 172 case CommandType::Underline: |
178 case CommandType::ToggleUnderline: | 173 case CommandType::ToggleUnderline: |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 | 455 |
461 static bool executeCut(LocalFrame& frame, Event*, EditorCommandSource source, co
nst String&) | 456 static bool executeCut(LocalFrame& frame, Event*, EditorCommandSource source, co
nst String&) |
462 { | 457 { |
463 // To support |allowExecutionWhenDisabled|, we need to check clipboard | 458 // To support |allowExecutionWhenDisabled|, we need to check clipboard |
464 // accessibility here rather than |Editor::Command::execute()|. | 459 // accessibility here rather than |Editor::Command::execute()|. |
465 // TODO(yosin) We should move checking |canWriteClipboard()| to | 460 // TODO(yosin) We should move checking |canWriteClipboard()| to |
466 // |Editor::Command::execute()| with introducing appropriate predicate, e.g. | 461 // |Editor::Command::execute()| with introducing appropriate predicate, e.g. |
467 // |canExecute()|. See also "Copy", and "Paste" command. | 462 // |canExecute()|. See also "Copy", and "Paste" command. |
468 if (!canWriteClipboard(frame, source)) | 463 if (!canWriteClipboard(frame, source)) |
469 return false; | 464 return false; |
470 frame.editor().cut(); | 465 frame.editor().cut(source); |
471 return true; | 466 return true; |
472 } | 467 } |
473 | 468 |
474 static bool executeDefaultParagraphSeparator(LocalFrame& frame, Event*, EditorCo
mmandSource, const String& value) | 469 static bool executeDefaultParagraphSeparator(LocalFrame& frame, Event*, EditorCo
mmandSource, const String& value) |
475 { | 470 { |
476 if (equalIgnoringCase(value, "div")) | 471 if (equalIgnoringCase(value, "div")) |
477 frame.editor().setDefaultParagraphSeparator(EditorParagraphSeparatorIsDi
v); | 472 frame.editor().setDefaultParagraphSeparator(EditorParagraphSeparatorIsDi
v); |
478 else if (equalIgnoringCase(value, "p")) | 473 else if (equalIgnoringCase(value, "p")) |
479 frame.editor().setDefaultParagraphSeparator(EditorParagraphSeparatorIsP)
; | 474 frame.editor().setDefaultParagraphSeparator(EditorParagraphSeparatorIsP)
; |
480 | 475 |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1107 | 1102 |
1108 static bool executePaste(LocalFrame& frame, Event*, EditorCommandSource source,
const String&) | 1103 static bool executePaste(LocalFrame& frame, Event*, EditorCommandSource source,
const String&) |
1109 { | 1104 { |
1110 // To support |allowExecutionWhenDisabled|, we need to check clipboard | 1105 // To support |allowExecutionWhenDisabled|, we need to check clipboard |
1111 // accessibility here rather than |Editor::Command::execute()|. | 1106 // accessibility here rather than |Editor::Command::execute()|. |
1112 // TODO(yosin) We should move checking |canReadClipboard()| to | 1107 // TODO(yosin) We should move checking |canReadClipboard()| to |
1113 // |Editor::Command::execute()| with introducing appropriate predicate, e.g. | 1108 // |Editor::Command::execute()| with introducing appropriate predicate, e.g. |
1114 // |canExecute()|. See also "Copy", and "Cut" command. | 1109 // |canExecute()|. See also "Copy", and "Cut" command. |
1115 if (!canReadClipboard(frame, source)) | 1110 if (!canReadClipboard(frame, source)) |
1116 return false; | 1111 return false; |
1117 frame.editor().paste(); | 1112 frame.editor().paste(source); |
1118 return true; | 1113 return true; |
1119 } | 1114 } |
1120 | 1115 |
1121 static bool executePasteGlobalSelection(LocalFrame& frame, Event*, EditorCommand
Source source, const String&) | 1116 static bool executePasteGlobalSelection(LocalFrame& frame, Event*, EditorCommand
Source source, const String&) |
1122 { | 1117 { |
1123 // To support |allowExecutionWhenDisabled|, we need to check clipboard | 1118 // To support |allowExecutionWhenDisabled|, we need to check clipboard |
1124 // accessibility here rather than |Editor::Command::execute()|. | 1119 // accessibility here rather than |Editor::Command::execute()|. |
1125 // TODO(yosin) We should move checking |canReadClipboard()| to | 1120 // TODO(yosin) We should move checking |canReadClipboard()| to |
1126 // |Editor::Command::execute()| with introducing appropriate predicate, e.g. | 1121 // |Editor::Command::execute()| with introducing appropriate predicate, e.g. |
1127 // |canExecute()|. See also "Copy", and "Cut" command. | 1122 // |canExecute()|. See also "Copy", and "Cut" command. |
1128 if (!canReadClipboard(frame, source)) | 1123 if (!canReadClipboard(frame, source)) |
1129 return false; | 1124 return false; |
1130 if (!frame.editor().behavior().supportsGlobalSelection()) | 1125 if (!frame.editor().behavior().supportsGlobalSelection()) |
1131 return false; | 1126 return false; |
1132 ASSERT_UNUSED(source, source == CommandFromMenuOrKeyBinding); | 1127 ASSERT_UNUSED(source, source == CommandFromMenuOrKeyBinding); |
1133 | 1128 |
1134 bool oldSelectionMode = Pasteboard::generalPasteboard()->isSelectionMode(); | 1129 bool oldSelectionMode = Pasteboard::generalPasteboard()->isSelectionMode(); |
1135 Pasteboard::generalPasteboard()->setSelectionMode(true); | 1130 Pasteboard::generalPasteboard()->setSelectionMode(true); |
1136 frame.editor().paste(); | 1131 frame.editor().paste(source); |
1137 Pasteboard::generalPasteboard()->setSelectionMode(oldSelectionMode); | 1132 Pasteboard::generalPasteboard()->setSelectionMode(oldSelectionMode); |
1138 return true; | 1133 return true; |
1139 } | 1134 } |
1140 | 1135 |
1141 static bool executePasteAndMatchStyle(LocalFrame& frame, Event*, EditorCommandSo
urce, const String&) | 1136 static bool executePasteAndMatchStyle(LocalFrame& frame, Event*, EditorCommandSo
urce source, const String&) |
1142 { | 1137 { |
1143 frame.editor().pasteAsPlainText(); | 1138 frame.editor().pasteAsPlainText(source); |
1144 return true; | 1139 return true; |
1145 } | 1140 } |
1146 | 1141 |
1147 static bool executePrint(LocalFrame& frame, Event*, EditorCommandSource, const S
tring&) | 1142 static bool executePrint(LocalFrame& frame, Event*, EditorCommandSource, const S
tring&) |
1148 { | 1143 { |
1149 FrameHost* host = frame.host(); | 1144 FrameHost* host = frame.host(); |
1150 if (!host) | 1145 if (!host) |
1151 return false; | 1146 return false; |
1152 host->chromeClient().print(&frame); | 1147 host->chromeClient().print(&frame); |
1153 return true; | 1148 return true; |
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1958 case WebEditingCommandType::DeleteWordBackward: | 1953 case WebEditingCommandType::DeleteWordBackward: |
1959 return RangesFromCurrentSelectionOrExtendCaret(*m_frame, DirectionBackwa
rd, WordGranularity); | 1954 return RangesFromCurrentSelectionOrExtendCaret(*m_frame, DirectionBackwa
rd, WordGranularity); |
1960 case WebEditingCommandType::DeleteWordForward: | 1955 case WebEditingCommandType::DeleteWordForward: |
1961 return RangesFromCurrentSelectionOrExtendCaret(*m_frame, DirectionForwar
d, WordGranularity); | 1956 return RangesFromCurrentSelectionOrExtendCaret(*m_frame, DirectionForwar
d, WordGranularity); |
1962 default: | 1957 default: |
1963 return nullptr; | 1958 return nullptr; |
1964 } | 1959 } |
1965 } | 1960 } |
1966 | 1961 |
1967 } // namespace blink | 1962 } // namespace blink |
OLD | NEW |