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 1870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1881 return frame.editor().canDHTMLCut() || frame.editor().canCut(); | 1881 return frame.editor().canDHTMLCut() || frame.editor().canCut(); |
1882 } | 1882 } |
1883 | 1883 |
1884 static bool enabledInEditableText(LocalFrame& frame, | 1884 static bool enabledInEditableText(LocalFrame& frame, |
1885 Event* event, | 1885 Event* event, |
1886 EditorCommandSource) { | 1886 EditorCommandSource) { |
1887 frame.document()->updateStyleAndLayoutIgnorePendingStylesheets(); | 1887 frame.document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
1888 return frame.editor().selectionForCommand(event).rootEditableElement(); | 1888 return frame.editor().selectionForCommand(event).rootEditableElement(); |
1889 } | 1889 } |
1890 | 1890 |
| 1891 static bool enabledInFocusedEditableText(LocalFrame& frame, |
| 1892 Event* event, |
| 1893 EditorCommandSource dummy) { |
| 1894 if (!enabledInEditableText(frame, event, dummy)) |
| 1895 return false; |
| 1896 |
| 1897 const Element* const focusedElement = frame.document()->focusedElement(); |
| 1898 if (!focusedElement->containsIncludingHostElements( |
| 1899 *frame.selection() |
| 1900 .computeVisibleSelectionInDOMTreeDeprecated() |
| 1901 .start() |
| 1902 .computeContainerNode())) { |
| 1903 // We should not move cursor if selected text does not have focus. |
| 1904 return false; |
| 1905 } |
| 1906 |
| 1907 return true; |
| 1908 } |
| 1909 |
1891 static bool enabledDelete(LocalFrame& frame, | 1910 static bool enabledDelete(LocalFrame& frame, |
1892 Event* event, | 1911 Event* event, |
1893 EditorCommandSource source) { | 1912 EditorCommandSource source) { |
1894 switch (source) { | 1913 switch (source) { |
1895 case CommandFromMenuOrKeyBinding: | 1914 case CommandFromMenuOrKeyBinding: |
1896 return frame.editor().canDelete(); | 1915 return frame.editor().canDelete(); |
1897 case CommandFromDOM: | 1916 case CommandFromDOM: |
1898 // "Delete" from DOM is like delete/backspace keypress, affects selected | 1917 // "Delete" from DOM is like delete/backspace keypress, affects selected |
1899 // range if non-empty, otherwise removes a character | 1918 // range if non-empty, otherwise removes a character |
1900 return enabledInEditableText(frame, event, source); | 1919 return enabledInEditableText(frame, event, source); |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2255 stateTextWritingDirectionRightToLeft, valueNull, notTextInsertion, | 2274 stateTextWritingDirectionRightToLeft, valueNull, notTextInsertion, |
2256 doNotAllowExecutionWhenDisabled}, | 2275 doNotAllowExecutionWhenDisabled}, |
2257 {WebEditingCommandType::MoveBackward, executeMoveBackward, | 2276 {WebEditingCommandType::MoveBackward, executeMoveBackward, |
2258 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, | 2277 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, |
2259 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, | 2278 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, |
2260 {WebEditingCommandType::MoveBackwardAndModifySelection, | 2279 {WebEditingCommandType::MoveBackwardAndModifySelection, |
2261 executeMoveBackwardAndModifySelection, supportedFromMenuOrKeyBinding, | 2280 executeMoveBackwardAndModifySelection, supportedFromMenuOrKeyBinding, |
2262 enabledVisibleSelection, stateNone, valueNull, notTextInsertion, | 2281 enabledVisibleSelection, stateNone, valueNull, notTextInsertion, |
2263 doNotAllowExecutionWhenDisabled}, | 2282 doNotAllowExecutionWhenDisabled}, |
2264 {WebEditingCommandType::MoveDown, executeMoveDown, | 2283 {WebEditingCommandType::MoveDown, executeMoveDown, |
2265 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, | 2284 supportedFromMenuOrKeyBinding, enabledInFocusedEditableText, stateNone, |
2266 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, | 2285 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, |
2267 {WebEditingCommandType::MoveDownAndModifySelection, | 2286 {WebEditingCommandType::MoveDownAndModifySelection, |
2268 executeMoveDownAndModifySelection, supportedFromMenuOrKeyBinding, | 2287 executeMoveDownAndModifySelection, supportedFromMenuOrKeyBinding, |
2269 enabledVisibleSelection, stateNone, valueNull, notTextInsertion, | 2288 enabledVisibleSelection, stateNone, valueNull, notTextInsertion, |
2270 doNotAllowExecutionWhenDisabled}, | 2289 doNotAllowExecutionWhenDisabled}, |
2271 {WebEditingCommandType::MoveForward, executeMoveForward, | 2290 {WebEditingCommandType::MoveForward, executeMoveForward, |
2272 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, | 2291 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, |
2273 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, | 2292 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, |
2274 {WebEditingCommandType::MoveForwardAndModifySelection, | 2293 {WebEditingCommandType::MoveForwardAndModifySelection, |
2275 executeMoveForwardAndModifySelection, supportedFromMenuOrKeyBinding, | 2294 executeMoveForwardAndModifySelection, supportedFromMenuOrKeyBinding, |
2276 enabledVisibleSelection, stateNone, valueNull, notTextInsertion, | 2295 enabledVisibleSelection, stateNone, valueNull, notTextInsertion, |
2277 doNotAllowExecutionWhenDisabled}, | 2296 doNotAllowExecutionWhenDisabled}, |
2278 {WebEditingCommandType::MoveLeft, executeMoveLeft, | 2297 {WebEditingCommandType::MoveLeft, executeMoveLeft, |
2279 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, | 2298 supportedFromMenuOrKeyBinding, enabledInFocusedEditableText, stateNone, |
2280 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, | 2299 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, |
2281 {WebEditingCommandType::MoveLeftAndModifySelection, | 2300 {WebEditingCommandType::MoveLeftAndModifySelection, |
2282 executeMoveLeftAndModifySelection, supportedFromMenuOrKeyBinding, | 2301 executeMoveLeftAndModifySelection, supportedFromMenuOrKeyBinding, |
2283 enabledVisibleSelection, stateNone, valueNull, notTextInsertion, | 2302 enabledVisibleSelection, stateNone, valueNull, notTextInsertion, |
2284 doNotAllowExecutionWhenDisabled}, | 2303 doNotAllowExecutionWhenDisabled}, |
2285 {WebEditingCommandType::MovePageDown, executeMovePageDown, | 2304 {WebEditingCommandType::MovePageDown, executeMovePageDown, |
2286 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, | 2305 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, |
2287 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, | 2306 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, |
2288 {WebEditingCommandType::MovePageDownAndModifySelection, | 2307 {WebEditingCommandType::MovePageDownAndModifySelection, |
2289 executeMovePageDownAndModifySelection, supportedFromMenuOrKeyBinding, | 2308 executeMovePageDownAndModifySelection, supportedFromMenuOrKeyBinding, |
(...skipping 15 matching lines...) Expand all Loading... |
2305 supportedFromMenuOrKeyBinding, enabledVisibleSelection, stateNone, | 2324 supportedFromMenuOrKeyBinding, enabledVisibleSelection, stateNone, |
2306 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, | 2325 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, |
2307 {WebEditingCommandType::MoveParagraphForward, executeMoveParagraphForward, | 2326 {WebEditingCommandType::MoveParagraphForward, executeMoveParagraphForward, |
2308 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, | 2327 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, |
2309 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, | 2328 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, |
2310 {WebEditingCommandType::MoveParagraphForwardAndModifySelection, | 2329 {WebEditingCommandType::MoveParagraphForwardAndModifySelection, |
2311 executeMoveParagraphForwardAndModifySelection, | 2330 executeMoveParagraphForwardAndModifySelection, |
2312 supportedFromMenuOrKeyBinding, enabledVisibleSelection, stateNone, | 2331 supportedFromMenuOrKeyBinding, enabledVisibleSelection, stateNone, |
2313 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, | 2332 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, |
2314 {WebEditingCommandType::MoveRight, executeMoveRight, | 2333 {WebEditingCommandType::MoveRight, executeMoveRight, |
2315 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, | 2334 supportedFromMenuOrKeyBinding, enabledInFocusedEditableText, stateNone, |
2316 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, | 2335 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, |
2317 {WebEditingCommandType::MoveRightAndModifySelection, | 2336 {WebEditingCommandType::MoveRightAndModifySelection, |
2318 executeMoveRightAndModifySelection, supportedFromMenuOrKeyBinding, | 2337 executeMoveRightAndModifySelection, supportedFromMenuOrKeyBinding, |
2319 enabledVisibleSelection, stateNone, valueNull, notTextInsertion, | 2338 enabledVisibleSelection, stateNone, valueNull, notTextInsertion, |
2320 doNotAllowExecutionWhenDisabled}, | 2339 doNotAllowExecutionWhenDisabled}, |
2321 {WebEditingCommandType::MoveToBeginningOfDocument, | 2340 {WebEditingCommandType::MoveToBeginningOfDocument, |
2322 executeMoveToBeginningOfDocument, supportedFromMenuOrKeyBinding, | 2341 executeMoveToBeginningOfDocument, supportedFromMenuOrKeyBinding, |
2323 enabledInEditableText, stateNone, valueNull, notTextInsertion, | 2342 enabledInEditableText, stateNone, valueNull, notTextInsertion, |
2324 doNotAllowExecutionWhenDisabled}, | 2343 doNotAllowExecutionWhenDisabled}, |
2325 {WebEditingCommandType::MoveToBeginningOfDocumentAndModifySelection, | 2344 {WebEditingCommandType::MoveToBeginningOfDocumentAndModifySelection, |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2386 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, | 2405 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, |
2387 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, | 2406 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, |
2388 {WebEditingCommandType::MoveToRightEndOfLine, executeMoveToRightEndOfLine, | 2407 {WebEditingCommandType::MoveToRightEndOfLine, executeMoveToRightEndOfLine, |
2389 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, | 2408 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, |
2390 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, | 2409 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, |
2391 {WebEditingCommandType::MoveToRightEndOfLineAndModifySelection, | 2410 {WebEditingCommandType::MoveToRightEndOfLineAndModifySelection, |
2392 executeMoveToRightEndOfLineAndModifySelection, | 2411 executeMoveToRightEndOfLineAndModifySelection, |
2393 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, | 2412 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, |
2394 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, | 2413 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, |
2395 {WebEditingCommandType::MoveUp, executeMoveUp, | 2414 {WebEditingCommandType::MoveUp, executeMoveUp, |
2396 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, | 2415 supportedFromMenuOrKeyBinding, enabledInFocusedEditableText, stateNone, |
2397 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, | 2416 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, |
2398 {WebEditingCommandType::MoveUpAndModifySelection, | 2417 {WebEditingCommandType::MoveUpAndModifySelection, |
2399 executeMoveUpAndModifySelection, supportedFromMenuOrKeyBinding, | 2418 executeMoveUpAndModifySelection, supportedFromMenuOrKeyBinding, |
2400 enabledVisibleSelection, stateNone, valueNull, notTextInsertion, | 2419 enabledVisibleSelection, stateNone, valueNull, notTextInsertion, |
2401 doNotAllowExecutionWhenDisabled}, | 2420 doNotAllowExecutionWhenDisabled}, |
2402 {WebEditingCommandType::MoveWordBackward, executeMoveWordBackward, | 2421 {WebEditingCommandType::MoveWordBackward, executeMoveWordBackward, |
2403 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, | 2422 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, |
2404 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, | 2423 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, |
2405 {WebEditingCommandType::MoveWordBackwardAndModifySelection, | 2424 {WebEditingCommandType::MoveWordBackwardAndModifySelection, |
2406 executeMoveWordBackwardAndModifySelection, supportedFromMenuOrKeyBinding, | 2425 executeMoveWordBackwardAndModifySelection, supportedFromMenuOrKeyBinding, |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2752 *m_frame, DirectionBackward, WordGranularity); | 2771 *m_frame, DirectionBackward, WordGranularity); |
2753 case WebEditingCommandType::DeleteWordForward: | 2772 case WebEditingCommandType::DeleteWordForward: |
2754 return RangesFromCurrentSelectionOrExtendCaret(*m_frame, DirectionForward, | 2773 return RangesFromCurrentSelectionOrExtendCaret(*m_frame, DirectionForward, |
2755 WordGranularity); | 2774 WordGranularity); |
2756 default: | 2775 default: |
2757 return targetRangesForInputEvent(*target); | 2776 return targetRangesForInputEvent(*target); |
2758 } | 2777 } |
2759 } | 2778 } |
2760 | 2779 |
2761 } // namespace blink | 2780 } // namespace blink |
OLD | NEW |