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

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

Issue 2618583003: [InputEvent] Add 'beforeinput' logic in |will*()| and guarded by a flag (3/11) (Closed)
Patch Set: Change target to |startingRootEditableElement()| Created 3 years, 11 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) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 2141 matching lines...) Expand 10 before | Expand all | Expand 10 after
2152 2152
2153 InputEvent::EventIsComposing isComposingFromCommand( 2153 InputEvent::EventIsComposing isComposingFromCommand(
2154 const CompositeEditCommand* command) { 2154 const CompositeEditCommand* command) {
2155 if (command->isTypingCommand() && 2155 if (command->isTypingCommand() &&
2156 toTypingCommand(command)->compositionType() != 2156 toTypingCommand(command)->compositionType() !=
2157 TypingCommand::TextCompositionNone) 2157 TypingCommand::TextCompositionNone)
2158 return InputEvent::IsComposing; 2158 return InputEvent::IsComposing;
2159 return InputEvent::NotComposing; 2159 return InputEvent::NotComposing;
2160 } 2160 }
2161 2161
2162 bool dispatchBeforeInputEvent(EditCommandSource source,
2163 LocalFrame* frame,
2164 Node* target,
2165 InputEvent::InputType inputType,
2166 const String& data,
2167 DataTransfer* dataTransfer,
2168 InputEvent::EventCancelable isCancelable,
2169 InputEvent::EventIsComposing isComposing,
2170 const RangeVector* ranges) {
2171 // Don't fire 'beforeinput', return true to continue.
2172 if (source != EditCommandSource::kMenuOrKeyBinding ||
2173 inputType == InputEvent::InputType::None)
2174 return true;
2175 if (!RuntimeEnabledFeatures::inputEventEnabled())
2176 return true;
2177 if (!frame || !target || !target->isConnected())
2178 return true;
2179
2180 if (!hasRichlyEditableStyle(*target)) {
2181 // Plain-text only elements (<input>, <textarea>, etc.) don't support
2182 // DataTransfer or Range.
2183 dataTransfer = nullptr;
2184 ranges = nullptr;
2185 }
2186
2187 InputEvent* beforeInputEvent;
2188
2189 if (dataTransfer) {
2190 beforeInputEvent = InputEvent::createBeforeInput(
2191 inputType, dataTransfer, isCancelable, isComposing, ranges);
2192 } else {
2193 beforeInputEvent = InputEvent::createBeforeInput(
2194 inputType, data, isCancelable, isComposing, ranges);
2195 }
2196
2197 DispatchEventResult result = target->dispatchEvent(beforeInputEvent);
2198 // 'beforeinput' event handler may destroy target frame.
2199 if (!frame->document() || frame->document()->frame() != frame ||
2200 !target->isConnected())
2201 return false;
2202 return result == DispatchEventResult::NotCanceled;
2203 }
2204
2162 } // namespace blink 2205 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698