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

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: Move isSelectionInDocument() and selectionHasFocus() to EditingUtilities Created 3 years, 9 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 1870 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // We only move carret when the carret's selection has focus.
1898 return selectionHasFocus(frame);
1899 }
1900
1891 static bool enabledDelete(LocalFrame& frame, 1901 static bool enabledDelete(LocalFrame& frame,
1892 Event* event, 1902 Event* event,
1893 EditorCommandSource source) { 1903 EditorCommandSource source) {
1894 switch (source) { 1904 switch (source) {
1895 case CommandFromMenuOrKeyBinding: 1905 case CommandFromMenuOrKeyBinding:
1896 return frame.editor().canDelete(); 1906 return frame.editor().canDelete();
1897 case CommandFromDOM: 1907 case CommandFromDOM:
1898 // "Delete" from DOM is like delete/backspace keypress, affects selected 1908 // "Delete" from DOM is like delete/backspace keypress, affects selected
1899 // range if non-empty, otherwise removes a character 1909 // range if non-empty, otherwise removes a character
1900 return enabledInEditableText(frame, event, source); 1910 return enabledInEditableText(frame, event, source);
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
2254 supportedFromMenuOrKeyBinding, enabledInRichlyEditableText, 2264 supportedFromMenuOrKeyBinding, enabledInRichlyEditableText,
2255 stateTextWritingDirectionRightToLeft, valueNull, notTextInsertion, 2265 stateTextWritingDirectionRightToLeft, valueNull, notTextInsertion,
2256 doNotAllowExecutionWhenDisabled}, 2266 doNotAllowExecutionWhenDisabled},
2257 {WebEditingCommandType::MoveBackward, executeMoveBackward, 2267 {WebEditingCommandType::MoveBackward, executeMoveBackward,
2258 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, 2268 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone,
2259 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, 2269 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
2260 {WebEditingCommandType::MoveBackwardAndModifySelection, 2270 {WebEditingCommandType::MoveBackwardAndModifySelection,
2261 executeMoveBackwardAndModifySelection, supportedFromMenuOrKeyBinding, 2271 executeMoveBackwardAndModifySelection, supportedFromMenuOrKeyBinding,
2262 enabledVisibleSelection, stateNone, valueNull, notTextInsertion, 2272 enabledVisibleSelection, stateNone, valueNull, notTextInsertion,
2263 doNotAllowExecutionWhenDisabled}, 2273 doNotAllowExecutionWhenDisabled},
2264 {WebEditingCommandType::MoveDown, executeMoveDown, 2274 {WebEditingCommandType::MoveDown, executeMoveDown,
yosin_UTC9 2017/03/21 06:49:59 Should we change of Move{Paragraph,Word,...}{Back,
hugoh_UTC2 2017/03/22 02:54:47 I introduced these changes to make LayoutTests/fas
2265 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, 2275 supportedFromMenuOrKeyBinding, enabledInFocusedEditableText, stateNone,
2266 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, 2276 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
2267 {WebEditingCommandType::MoveDownAndModifySelection, 2277 {WebEditingCommandType::MoveDownAndModifySelection,
2268 executeMoveDownAndModifySelection, supportedFromMenuOrKeyBinding, 2278 executeMoveDownAndModifySelection, supportedFromMenuOrKeyBinding,
2269 enabledVisibleSelection, stateNone, valueNull, notTextInsertion, 2279 enabledVisibleSelection, stateNone, valueNull, notTextInsertion,
2270 doNotAllowExecutionWhenDisabled}, 2280 doNotAllowExecutionWhenDisabled},
2271 {WebEditingCommandType::MoveForward, executeMoveForward, 2281 {WebEditingCommandType::MoveForward, executeMoveForward,
2272 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, 2282 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone,
2273 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, 2283 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
2274 {WebEditingCommandType::MoveForwardAndModifySelection, 2284 {WebEditingCommandType::MoveForwardAndModifySelection,
2275 executeMoveForwardAndModifySelection, supportedFromMenuOrKeyBinding, 2285 executeMoveForwardAndModifySelection, supportedFromMenuOrKeyBinding,
2276 enabledVisibleSelection, stateNone, valueNull, notTextInsertion, 2286 enabledVisibleSelection, stateNone, valueNull, notTextInsertion,
2277 doNotAllowExecutionWhenDisabled}, 2287 doNotAllowExecutionWhenDisabled},
2278 {WebEditingCommandType::MoveLeft, executeMoveLeft, 2288 {WebEditingCommandType::MoveLeft, executeMoveLeft,
2279 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, 2289 supportedFromMenuOrKeyBinding, enabledInFocusedEditableText, stateNone,
2280 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, 2290 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
2281 {WebEditingCommandType::MoveLeftAndModifySelection, 2291 {WebEditingCommandType::MoveLeftAndModifySelection,
2282 executeMoveLeftAndModifySelection, supportedFromMenuOrKeyBinding, 2292 executeMoveLeftAndModifySelection, supportedFromMenuOrKeyBinding,
2283 enabledVisibleSelection, stateNone, valueNull, notTextInsertion, 2293 enabledVisibleSelection, stateNone, valueNull, notTextInsertion,
2284 doNotAllowExecutionWhenDisabled}, 2294 doNotAllowExecutionWhenDisabled},
2285 {WebEditingCommandType::MovePageDown, executeMovePageDown, 2295 {WebEditingCommandType::MovePageDown, executeMovePageDown,
2286 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, 2296 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone,
2287 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, 2297 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
2288 {WebEditingCommandType::MovePageDownAndModifySelection, 2298 {WebEditingCommandType::MovePageDownAndModifySelection,
2289 executeMovePageDownAndModifySelection, supportedFromMenuOrKeyBinding, 2299 executeMovePageDownAndModifySelection, supportedFromMenuOrKeyBinding,
(...skipping 15 matching lines...) Expand all
2305 supportedFromMenuOrKeyBinding, enabledVisibleSelection, stateNone, 2315 supportedFromMenuOrKeyBinding, enabledVisibleSelection, stateNone,
2306 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, 2316 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
2307 {WebEditingCommandType::MoveParagraphForward, executeMoveParagraphForward, 2317 {WebEditingCommandType::MoveParagraphForward, executeMoveParagraphForward,
2308 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, 2318 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone,
2309 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, 2319 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
2310 {WebEditingCommandType::MoveParagraphForwardAndModifySelection, 2320 {WebEditingCommandType::MoveParagraphForwardAndModifySelection,
2311 executeMoveParagraphForwardAndModifySelection, 2321 executeMoveParagraphForwardAndModifySelection,
2312 supportedFromMenuOrKeyBinding, enabledVisibleSelection, stateNone, 2322 supportedFromMenuOrKeyBinding, enabledVisibleSelection, stateNone,
2313 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, 2323 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
2314 {WebEditingCommandType::MoveRight, executeMoveRight, 2324 {WebEditingCommandType::MoveRight, executeMoveRight,
2315 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, 2325 supportedFromMenuOrKeyBinding, enabledInFocusedEditableText, stateNone,
2316 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, 2326 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
2317 {WebEditingCommandType::MoveRightAndModifySelection, 2327 {WebEditingCommandType::MoveRightAndModifySelection,
2318 executeMoveRightAndModifySelection, supportedFromMenuOrKeyBinding, 2328 executeMoveRightAndModifySelection, supportedFromMenuOrKeyBinding,
2319 enabledVisibleSelection, stateNone, valueNull, notTextInsertion, 2329 enabledVisibleSelection, stateNone, valueNull, notTextInsertion,
2320 doNotAllowExecutionWhenDisabled}, 2330 doNotAllowExecutionWhenDisabled},
2321 {WebEditingCommandType::MoveToBeginningOfDocument, 2331 {WebEditingCommandType::MoveToBeginningOfDocument,
2322 executeMoveToBeginningOfDocument, supportedFromMenuOrKeyBinding, 2332 executeMoveToBeginningOfDocument, supportedFromMenuOrKeyBinding,
2323 enabledInEditableText, stateNone, valueNull, notTextInsertion, 2333 enabledInEditableText, stateNone, valueNull, notTextInsertion,
2324 doNotAllowExecutionWhenDisabled}, 2334 doNotAllowExecutionWhenDisabled},
2325 {WebEditingCommandType::MoveToBeginningOfDocumentAndModifySelection, 2335 {WebEditingCommandType::MoveToBeginningOfDocumentAndModifySelection,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2386 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, 2396 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone,
2387 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, 2397 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
2388 {WebEditingCommandType::MoveToRightEndOfLine, executeMoveToRightEndOfLine, 2398 {WebEditingCommandType::MoveToRightEndOfLine, executeMoveToRightEndOfLine,
2389 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, 2399 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone,
2390 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, 2400 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
2391 {WebEditingCommandType::MoveToRightEndOfLineAndModifySelection, 2401 {WebEditingCommandType::MoveToRightEndOfLineAndModifySelection,
2392 executeMoveToRightEndOfLineAndModifySelection, 2402 executeMoveToRightEndOfLineAndModifySelection,
2393 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, 2403 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone,
2394 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, 2404 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
2395 {WebEditingCommandType::MoveUp, executeMoveUp, 2405 {WebEditingCommandType::MoveUp, executeMoveUp,
2396 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, 2406 supportedFromMenuOrKeyBinding, enabledInFocusedEditableText, stateNone,
2397 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, 2407 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
2398 {WebEditingCommandType::MoveUpAndModifySelection, 2408 {WebEditingCommandType::MoveUpAndModifySelection,
2399 executeMoveUpAndModifySelection, supportedFromMenuOrKeyBinding, 2409 executeMoveUpAndModifySelection, supportedFromMenuOrKeyBinding,
2400 enabledVisibleSelection, stateNone, valueNull, notTextInsertion, 2410 enabledVisibleSelection, stateNone, valueNull, notTextInsertion,
2401 doNotAllowExecutionWhenDisabled}, 2411 doNotAllowExecutionWhenDisabled},
2402 {WebEditingCommandType::MoveWordBackward, executeMoveWordBackward, 2412 {WebEditingCommandType::MoveWordBackward, executeMoveWordBackward,
2403 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, 2413 supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone,
2404 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, 2414 valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
2405 {WebEditingCommandType::MoveWordBackwardAndModifySelection, 2415 {WebEditingCommandType::MoveWordBackwardAndModifySelection,
2406 executeMoveWordBackwardAndModifySelection, supportedFromMenuOrKeyBinding, 2416 executeMoveWordBackwardAndModifySelection, supportedFromMenuOrKeyBinding,
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
2752 *m_frame, DirectionBackward, WordGranularity); 2762 *m_frame, DirectionBackward, WordGranularity);
2753 case WebEditingCommandType::DeleteWordForward: 2763 case WebEditingCommandType::DeleteWordForward:
2754 return RangesFromCurrentSelectionOrExtendCaret(*m_frame, DirectionForward, 2764 return RangesFromCurrentSelectionOrExtendCaret(*m_frame, DirectionForward,
2755 WordGranularity); 2765 WordGranularity);
2756 default: 2766 default:
2757 return targetRangesForInputEvent(*target); 2767 return targetRangesForInputEvent(*target);
2758 } 2768 }
2759 } 2769 }
2760 2770
2761 } // namespace blink 2771 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698