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 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1167 | 1167 |
1168 static bool supportedFromMenuOrKeyBinding(LocalFrame*) | 1168 static bool supportedFromMenuOrKeyBinding(LocalFrame*) |
1169 { | 1169 { |
1170 return false; | 1170 return false; |
1171 } | 1171 } |
1172 | 1172 |
1173 static bool supportedCopyCut(LocalFrame* frame) | 1173 static bool supportedCopyCut(LocalFrame* frame) |
1174 { | 1174 { |
1175 if (!frame) | 1175 if (!frame) |
1176 return false; | 1176 return false; |
1177 | 1177 return true; |
1178 Settings* settings = frame->settings(); | |
1179 bool defaultValue = (settings && settings->javaScriptCanAccessClipboard()) |
| UserGestureIndicator::processingUserGesture(); | |
1180 return frame->editor().client().canCopyCut(frame, defaultValue); | |
1181 } | 1178 } |
1182 | 1179 |
1183 static bool supportedPaste(LocalFrame* frame) | 1180 static bool supportedPaste(LocalFrame* frame) |
1184 { | 1181 { |
1185 if (!frame) | 1182 if (!frame) |
1186 return false; | 1183 return false; |
1187 | 1184 return true; |
1188 Settings* settings = frame->settings(); | |
1189 bool defaultValue = settings && settings->javaScriptCanAccessClipboard() &&
settings->DOMPasteAllowed(); | |
1190 return frame->editor().client().canPaste(frame, defaultValue); | |
1191 } | 1185 } |
1192 | 1186 |
1193 // Enabled functions | 1187 // Enabled functions |
1194 | 1188 |
1195 static bool enabled(LocalFrame&, Event*, EditorCommandSource) | 1189 static bool enabled(LocalFrame&, Event*, EditorCommandSource) |
1196 { | 1190 { |
1197 return true; | 1191 return true; |
1198 } | 1192 } |
1199 | 1193 |
1200 static bool enabledVisibleSelection(LocalFrame& frame, Event* event, EditorComma
ndSource) | 1194 static bool enabledVisibleSelection(LocalFrame& frame, Event* event, EditorComma
ndSource) |
(...skipping 24 matching lines...) Expand all Loading... |
1225 } | 1219 } |
1226 | 1220 |
1227 static bool enableCaretInEditableText(LocalFrame& frame, Event* event, EditorCom
mandSource) | 1221 static bool enableCaretInEditableText(LocalFrame& frame, Event* event, EditorCom
mandSource) |
1228 { | 1222 { |
1229 const VisibleSelection& selection = frame.editor().selectionForCommand(event
); | 1223 const VisibleSelection& selection = frame.editor().selectionForCommand(event
); |
1230 return selection.isCaret() && selection.isContentEditable(); | 1224 return selection.isCaret() && selection.isContentEditable(); |
1231 } | 1225 } |
1232 | 1226 |
1233 static bool enabledCopy(LocalFrame& frame, Event*, EditorCommandSource) | 1227 static bool enabledCopy(LocalFrame& frame, Event*, EditorCommandSource) |
1234 { | 1228 { |
1235 return frame.editor().canDHTMLCopy() || frame.editor().canCopy(); | 1229 Settings* settings = frame.settings(); |
| 1230 bool defaultValue = (settings && settings->javaScriptCanAccessClipboard()) |
| UserGestureIndicator::processingUserGesture(); |
| 1231 return frame.editor().client().canCopyCut(&frame, defaultValue) && (frame.ed
itor().canDHTMLCopy() || frame.editor().canCopy()); |
1236 } | 1232 } |
1237 | 1233 |
1238 static bool enabledCut(LocalFrame& frame, Event*, EditorCommandSource) | 1234 static bool enabledCut(LocalFrame& frame, Event*, EditorCommandSource) |
1239 { | 1235 { |
1240 return frame.editor().canDHTMLCut() || frame.editor().canCut(); | 1236 Settings* settings = frame.settings(); |
| 1237 bool defaultValue = (settings && settings->javaScriptCanAccessClipboard()) |
| UserGestureIndicator::processingUserGesture(); |
| 1238 return frame.editor().client().canCopyCut(&frame, defaultValue) && (frame.ed
itor().canDHTMLCut() || frame.editor().canCut()); |
1241 } | 1239 } |
1242 | 1240 |
1243 static bool enabledInEditableText(LocalFrame& frame, Event* event, EditorCommand
Source) | 1241 static bool enabledInEditableText(LocalFrame& frame, Event* event, EditorCommand
Source) |
1244 { | 1242 { |
1245 return frame.editor().selectionForCommand(event).rootEditableElement(); | 1243 return frame.editor().selectionForCommand(event).rootEditableElement(); |
1246 } | 1244 } |
1247 | 1245 |
1248 static bool enabledDelete(LocalFrame& frame, Event* event, EditorCommandSource s
ource) | 1246 static bool enabledDelete(LocalFrame& frame, Event* event, EditorCommandSource s
ource) |
1249 { | 1247 { |
1250 switch (source) { | 1248 switch (source) { |
(...skipping 14 matching lines...) Expand all Loading... |
1265 return caretBrowsingEnabled(frame) || enabledInEditableText(frame, event, du
mmyEditorCommandSource); | 1263 return caretBrowsingEnabled(frame) || enabledInEditableText(frame, event, du
mmyEditorCommandSource); |
1266 } | 1264 } |
1267 | 1265 |
1268 static bool enabledInRichlyEditableText(LocalFrame& frame, Event*, EditorCommand
Source) | 1266 static bool enabledInRichlyEditableText(LocalFrame& frame, Event*, EditorCommand
Source) |
1269 { | 1267 { |
1270 return frame.selection().isCaretOrRange() && frame.selection().isContentRich
lyEditable() && frame.selection().rootEditableElement(); | 1268 return frame.selection().isCaretOrRange() && frame.selection().isContentRich
lyEditable() && frame.selection().rootEditableElement(); |
1271 } | 1269 } |
1272 | 1270 |
1273 static bool enabledPaste(LocalFrame& frame, Event*, EditorCommandSource) | 1271 static bool enabledPaste(LocalFrame& frame, Event*, EditorCommandSource) |
1274 { | 1272 { |
1275 return frame.editor().canPaste(); | 1273 Settings* settings = frame.settings(); |
| 1274 bool defaultValue = settings && settings->javaScriptCanAccessClipboard() &&
settings->DOMPasteAllowed(); |
| 1275 return frame.editor().client().canPaste(&frame, defaultValue) && frame.edito
r().canPaste(); |
1276 } | 1276 } |
1277 | 1277 |
1278 static bool enabledRangeInEditableText(LocalFrame& frame, Event*, EditorCommandS
ource) | 1278 static bool enabledRangeInEditableText(LocalFrame& frame, Event*, EditorCommandS
ource) |
1279 { | 1279 { |
1280 return frame.selection().isRange() && frame.selection().isContentEditable(); | 1280 return frame.selection().isRange() && frame.selection().isContentEditable(); |
1281 } | 1281 } |
1282 | 1282 |
1283 static bool enabledRangeInRichlyEditableText(LocalFrame& frame, Event*, EditorCo
mmandSource) | 1283 static bool enabledRangeInRichlyEditableText(LocalFrame& frame, Event*, EditorCo
mmandSource) |
1284 { | 1284 { |
1285 return frame.selection().isRange() && frame.selection().isContentRichlyEdita
ble(); | 1285 return frame.selection().isRange() && frame.selection().isContentRichlyEdita
ble(); |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1787 { | 1787 { |
1788 return m_command && m_command->isTextInsertion; | 1788 return m_command && m_command->isTextInsertion; |
1789 } | 1789 } |
1790 | 1790 |
1791 int Editor::Command::idForHistogram() const | 1791 int Editor::Command::idForHistogram() const |
1792 { | 1792 { |
1793 return isSupported() ? m_command->idForUserMetrics : 0; | 1793 return isSupported() ? m_command->idForUserMetrics : 0; |
1794 } | 1794 } |
1795 | 1795 |
1796 } // namespace blink | 1796 } // namespace blink |
OLD | NEW |