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

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

Issue 2616623002: Do not send redundant selectionchange-events (decouple focus) (Closed)
Patch Set: Restore tab-key (and spatial) navigation's clearing behavior Created 3 years, 10 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
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 1859 matching lines...) Expand 10 before | Expand all | Expand 10 after
1870 Event* event, 1870 Event* event,
1871 EditorCommandSource) { 1871 EditorCommandSource) {
1872 frame.document()->updateStyleAndLayoutIgnorePendingStylesheets(); 1872 frame.document()->updateStyleAndLayoutIgnorePendingStylesheets();
1873 1873
1874 // We should update selection to canonicalize with current layout and style, 1874 // We should update selection to canonicalize with current layout and style,
1875 // before accessing |FrameSelection::selection()|. 1875 // before accessing |FrameSelection::selection()|.
1876 frame.selection().updateIfNeeded(); 1876 frame.selection().updateIfNeeded();
1877 return frame.editor().selectionForCommand(event).rootEditableElement(); 1877 return frame.editor().selectionForCommand(event).rootEditableElement();
1878 } 1878 }
1879 1879
1880 static bool enabledInFocusedEditableText(LocalFrame& frame,
1881 Event* event,
1882 EditorCommandSource dummy) {
1883 if (!enabledInEditableText(frame, event, dummy))
1884 return false;
1885
1886 const Element* const focusedElement = frame.document()->focusedElement();
1887 if (!focusedElement->containsIncludingHostElements(
1888 *frame.selection().start().computeContainerNode())) {
1889 // We should not move cursor if selected text does not have focus.
1890 return false;
1891 }
1892
1893 return true;
1894 }
1895
1880 static bool enabledDelete(LocalFrame& frame, 1896 static bool enabledDelete(LocalFrame& frame,
1881 Event* event, 1897 Event* event,
1882 EditorCommandSource source) { 1898 EditorCommandSource source) {
1883 switch (source) { 1899 switch (source) {
1884 case CommandFromMenuOrKeyBinding: 1900 case CommandFromMenuOrKeyBinding:
1885 return frame.editor().canDelete(); 1901 return frame.editor().canDelete();
1886 case CommandFromDOM: 1902 case CommandFromDOM:
1887 // "Delete" from DOM is like delete/backspace keypress, affects selected 1903 // "Delete" from DOM is like delete/backspace keypress, affects selected
1888 // range if non-empty, otherwise removes a character 1904 // range if non-empty, otherwise removes a character
1889 return enabledInEditableText(frame, event, source); 1905 return enabledInEditableText(frame, event, source);
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
2239 stateTextWritingDirectionRightToLeft, valueNull, notTextInsertion, 2255 stateTextWritingDirectionRightToLeft, valueNull, notTextInsertion,
2240 doNotAllowExecutionWhenDisabled}, 2256 doNotAllowExecutionWhenDisabled},
2241 {WebEditingCommandType::MoveBackward, executeMoveBackward, 2257 {WebEditingCommandType::MoveBackward, executeMoveBackward,
2242 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, 2258 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone,
2243 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, 2259 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
2244 {WebEditingCommandType::MoveBackwardAndModifySelection, 2260 {WebEditingCommandType::MoveBackwardAndModifySelection,
2245 executeMoveBackwardAndModifySelection, supportedFromMenuOrKeyBinding, 2261 executeMoveBackwardAndModifySelection, supportedFromMenuOrKeyBinding,
2246 enabledVisibleSelection, stateNone, valueNull, notTextInsertion, 2262 enabledVisibleSelection, stateNone, valueNull, notTextInsertion,
2247 doNotAllowExecutionWhenDisabled}, 2263 doNotAllowExecutionWhenDisabled},
2248 {WebEditingCommandType::MoveDown, executeMoveDown, 2264 {WebEditingCommandType::MoveDown, executeMoveDown,
2249 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, 2265 supportedFromMenuOrKeyBinding, enabledInFocusedEditableText, stateNone,
2250 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, 2266 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
2251 {WebEditingCommandType::MoveDownAndModifySelection, 2267 {WebEditingCommandType::MoveDownAndModifySelection,
2252 executeMoveDownAndModifySelection, supportedFromMenuOrKeyBinding, 2268 executeMoveDownAndModifySelection, supportedFromMenuOrKeyBinding,
2253 enabledVisibleSelection, stateNone, valueNull, notTextInsertion, 2269 enabledVisibleSelection, stateNone, valueNull, notTextInsertion,
2254 doNotAllowExecutionWhenDisabled}, 2270 doNotAllowExecutionWhenDisabled},
2255 {WebEditingCommandType::MoveForward, executeMoveForward, 2271 {WebEditingCommandType::MoveForward, executeMoveForward,
2256 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, 2272 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone,
2257 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, 2273 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
2258 {WebEditingCommandType::MoveForwardAndModifySelection, 2274 {WebEditingCommandType::MoveForwardAndModifySelection,
2259 executeMoveForwardAndModifySelection, supportedFromMenuOrKeyBinding, 2275 executeMoveForwardAndModifySelection, supportedFromMenuOrKeyBinding,
2260 enabledVisibleSelection, stateNone, valueNull, notTextInsertion, 2276 enabledVisibleSelection, stateNone, valueNull, notTextInsertion,
2261 doNotAllowExecutionWhenDisabled}, 2277 doNotAllowExecutionWhenDisabled},
2262 {WebEditingCommandType::MoveLeft, executeMoveLeft, 2278 {WebEditingCommandType::MoveLeft, executeMoveLeft,
2263 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, 2279 supportedFromMenuOrKeyBinding, enabledInFocusedEditableText, stateNone,
2264 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, 2280 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
2265 {WebEditingCommandType::MoveLeftAndModifySelection, 2281 {WebEditingCommandType::MoveLeftAndModifySelection,
2266 executeMoveLeftAndModifySelection, supportedFromMenuOrKeyBinding, 2282 executeMoveLeftAndModifySelection, supportedFromMenuOrKeyBinding,
2267 enabledVisibleSelection, stateNone, valueNull, notTextInsertion, 2283 enabledVisibleSelection, stateNone, valueNull, notTextInsertion,
2268 doNotAllowExecutionWhenDisabled}, 2284 doNotAllowExecutionWhenDisabled},
2269 {WebEditingCommandType::MovePageDown, executeMovePageDown, 2285 {WebEditingCommandType::MovePageDown, executeMovePageDown,
2270 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, 2286 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone,
2271 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, 2287 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
2272 {WebEditingCommandType::MovePageDownAndModifySelection, 2288 {WebEditingCommandType::MovePageDownAndModifySelection,
2273 executeMovePageDownAndModifySelection, supportedFromMenuOrKeyBinding, 2289 executeMovePageDownAndModifySelection, supportedFromMenuOrKeyBinding,
(...skipping 15 matching lines...) Expand all
2289 supportedFromMenuOrKeyBinding, enabledVisibleSelection, stateNone, 2305 supportedFromMenuOrKeyBinding, enabledVisibleSelection, stateNone,
2290 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, 2306 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
2291 {WebEditingCommandType::MoveParagraphForward, executeMoveParagraphForward, 2307 {WebEditingCommandType::MoveParagraphForward, executeMoveParagraphForward,
2292 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, 2308 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone,
2293 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, 2309 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
2294 {WebEditingCommandType::MoveParagraphForwardAndModifySelection, 2310 {WebEditingCommandType::MoveParagraphForwardAndModifySelection,
2295 executeMoveParagraphForwardAndModifySelection, 2311 executeMoveParagraphForwardAndModifySelection,
2296 supportedFromMenuOrKeyBinding, enabledVisibleSelection, stateNone, 2312 supportedFromMenuOrKeyBinding, enabledVisibleSelection, stateNone,
2297 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, 2313 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
2298 {WebEditingCommandType::MoveRight, executeMoveRight, 2314 {WebEditingCommandType::MoveRight, executeMoveRight,
2299 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, 2315 supportedFromMenuOrKeyBinding, enabledInFocusedEditableText, stateNone,
2300 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, 2316 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
2301 {WebEditingCommandType::MoveRightAndModifySelection, 2317 {WebEditingCommandType::MoveRightAndModifySelection,
2302 executeMoveRightAndModifySelection, supportedFromMenuOrKeyBinding, 2318 executeMoveRightAndModifySelection, supportedFromMenuOrKeyBinding,
2303 enabledVisibleSelection, stateNone, valueNull, notTextInsertion, 2319 enabledVisibleSelection, stateNone, valueNull, notTextInsertion,
2304 doNotAllowExecutionWhenDisabled}, 2320 doNotAllowExecutionWhenDisabled},
2305 {WebEditingCommandType::MoveToBeginningOfDocument, 2321 {WebEditingCommandType::MoveToBeginningOfDocument,
2306 executeMoveToBeginningOfDocument, supportedFromMenuOrKeyBinding, 2322 executeMoveToBeginningOfDocument, supportedFromMenuOrKeyBinding,
2307 enabledInEditableText, stateNone, valueNull, notTextInsertion, 2323 enabledInEditableText, stateNone, valueNull, notTextInsertion,
2308 doNotAllowExecutionWhenDisabled}, 2324 doNotAllowExecutionWhenDisabled},
2309 {WebEditingCommandType::MoveToBeginningOfDocumentAndModifySelection, 2325 {WebEditingCommandType::MoveToBeginningOfDocumentAndModifySelection,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2370 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, 2386 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone,
2371 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, 2387 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
2372 {WebEditingCommandType::MoveToRightEndOfLine, executeMoveToRightEndOfLine, 2388 {WebEditingCommandType::MoveToRightEndOfLine, executeMoveToRightEndOfLine,
2373 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, 2389 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone,
2374 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, 2390 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
2375 {WebEditingCommandType::MoveToRightEndOfLineAndModifySelection, 2391 {WebEditingCommandType::MoveToRightEndOfLineAndModifySelection,
2376 executeMoveToRightEndOfLineAndModifySelection, 2392 executeMoveToRightEndOfLineAndModifySelection,
2377 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, 2393 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone,
2378 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, 2394 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
2379 {WebEditingCommandType::MoveUp, executeMoveUp, 2395 {WebEditingCommandType::MoveUp, executeMoveUp,
2380 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, 2396 supportedFromMenuOrKeyBinding, enabledInFocusedEditableText, stateNone,
2381 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, 2397 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
2382 {WebEditingCommandType::MoveUpAndModifySelection, 2398 {WebEditingCommandType::MoveUpAndModifySelection,
2383 executeMoveUpAndModifySelection, supportedFromMenuOrKeyBinding, 2399 executeMoveUpAndModifySelection, supportedFromMenuOrKeyBinding,
2384 enabledVisibleSelection, stateNone, valueNull, notTextInsertion, 2400 enabledVisibleSelection, stateNone, valueNull, notTextInsertion,
2385 doNotAllowExecutionWhenDisabled}, 2401 doNotAllowExecutionWhenDisabled},
2386 {WebEditingCommandType::MoveWordBackward, executeMoveWordBackward, 2402 {WebEditingCommandType::MoveWordBackward, executeMoveWordBackward,
2387 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, 2403 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone,
2388 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, 2404 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
2389 {WebEditingCommandType::MoveWordBackwardAndModifySelection, 2405 {WebEditingCommandType::MoveWordBackwardAndModifySelection,
2390 executeMoveWordBackwardAndModifySelection, supportedFromMenuOrKeyBinding, 2406 executeMoveWordBackwardAndModifySelection, supportedFromMenuOrKeyBinding,
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
2735 *m_frame, DirectionBackward, WordGranularity); 2751 *m_frame, DirectionBackward, WordGranularity);
2736 case WebEditingCommandType::DeleteWordForward: 2752 case WebEditingCommandType::DeleteWordForward:
2737 return RangesFromCurrentSelectionOrExtendCaret(*m_frame, DirectionForward, 2753 return RangesFromCurrentSelectionOrExtendCaret(*m_frame, DirectionForward,
2738 WordGranularity); 2754 WordGranularity);
2739 default: 2755 default:
2740 return nullptr; 2756 return nullptr;
2741 } 2757 }
2742 } 2758 }
2743 2759
2744 } // namespace blink 2760 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698