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

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

Issue 2457523003: Support 'insertReplacementText' for spellcheck (Closed)
Patch Set: Created 4 years, 1 month 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
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "core/editing/EditingUtilities.h" 26 #include "core/editing/EditingUtilities.h"
27 27
28 #include "core/HTMLElementFactory.h" 28 #include "core/HTMLElementFactory.h"
29 #include "core/HTMLNames.h" 29 #include "core/HTMLNames.h"
30 #include "core/clipboard/DataObject.h"
30 #include "core/dom/Document.h" 31 #include "core/dom/Document.h"
31 #include "core/dom/ElementTraversal.h" 32 #include "core/dom/ElementTraversal.h"
32 #include "core/dom/NodeComputedStyle.h" 33 #include "core/dom/NodeComputedStyle.h"
33 #include "core/dom/Range.h" 34 #include "core/dom/Range.h"
34 #include "core/dom/Text.h" 35 #include "core/dom/Text.h"
35 #include "core/dom/shadow/ShadowRoot.h" 36 #include "core/dom/shadow/ShadowRoot.h"
36 #include "core/editing/EditingStrategy.h" 37 #include "core/editing/EditingStrategy.h"
37 #include "core/editing/Editor.h" 38 #include "core/editing/Editor.h"
38 #include "core/editing/PlainTextRange.h" 39 #include "core/editing/PlainTextRange.h"
39 #include "core/editing/PositionIterator.h" 40 #include "core/editing/PositionIterator.h"
(...skipping 2044 matching lines...) Expand 10 before | Expand all | Expand 10 after
2084 if (!RuntimeEnabledFeatures::inputEventEnabled()) 2085 if (!RuntimeEnabledFeatures::inputEventEnabled())
2085 return DispatchEventResult::NotCanceled; 2086 return DispatchEventResult::NotCanceled;
2086 if (!target) 2087 if (!target)
2087 return DispatchEventResult::NotCanceled; 2088 return DispatchEventResult::NotCanceled;
2088 InputEvent* beforeInputEvent = InputEvent::createBeforeInput( 2089 InputEvent* beforeInputEvent = InputEvent::createBeforeInput(
2089 inputType, dataTransfer, InputEvent::EventCancelable::IsCancelable, 2090 inputType, dataTransfer, InputEvent::EventCancelable::IsCancelable,
2090 InputEvent::EventIsComposing::NotComposing, ranges); 2091 InputEvent::EventIsComposing::NotComposing, ranges);
2091 return target->dispatchEvent(beforeInputEvent); 2092 return target->dispatchEvent(beforeInputEvent);
2092 } 2093 }
2093 2094
2095 DispatchEventResult dispatchBeforeInputPlainText(
chongz 2016/10/27 16:41:24 Sorry for the confusion. I was imagining we could
2096 EventTarget* target,
2097 InputEvent::InputType inputType,
2098 const String& data,
2099 DataTransfer::DataTransferType dataTransferType,
2100 DataTransferAccessPolicy dataTransferAccessPolicy,
2101 const RangeVector* ranges) {
2102 if (!RuntimeEnabledFeatures::inputEventEnabled())
2103 return DispatchEventResult::NotCanceled;
2104 if (!target)
2105 return DispatchEventResult::NotCanceled;
2106
2107 if (hasRichlyEditableStyle(*(target->toNode()))) {
2108 DataTransfer* dataTransfer =
2109 DataTransfer::create(dataTransferType, dataTransferAccessPolicy,
2110 DataObject::createFromString(data));
2111
2112 return dispatchBeforeInputDataTransfer(target, inputType, dataTransfer,
2113 ranges);
2114 } else {
2115 // TODO(chongz): Pass appreciate |ranges| after it's defined on spec.
2116 // http://w3c.github.io/editing/input-events.html#dom-inputevent-inputtype
2117 InputEvent* beforeInputEvent = InputEvent::createBeforeInput(
2118 inputType, data, InputEvent::EventCancelable::IsCancelable,
2119 InputEvent::EventIsComposing::NotComposing, nullptr);
2120 return target->dispatchEvent(beforeInputEvent);
2121 }
2122 }
2123
2094 InputEvent::InputType deletionInputTypeFromTextGranularity( 2124 InputEvent::InputType deletionInputTypeFromTextGranularity(
2095 DeleteDirection direction, 2125 DeleteDirection direction,
2096 TextGranularity granularity) { 2126 TextGranularity granularity) {
2097 using InputType = InputEvent::InputType; 2127 using InputType = InputEvent::InputType;
2098 switch (direction) { 2128 switch (direction) {
2099 case DeleteDirection::Forward: 2129 case DeleteDirection::Forward:
2100 if (granularity == WordGranularity) 2130 if (granularity == WordGranularity)
2101 return InputType::DeleteWordForward; 2131 return InputType::DeleteWordForward;
2102 if (granularity == LineBoundary) 2132 if (granularity == LineBoundary)
2103 return InputType::DeleteLineForward; 2133 return InputType::DeleteLineForward;
2104 return InputType::DeleteContentForward; 2134 return InputType::DeleteContentForward;
2105 case DeleteDirection::Backward: 2135 case DeleteDirection::Backward:
2106 if (granularity == WordGranularity) 2136 if (granularity == WordGranularity)
2107 return InputType::DeleteWordBackward; 2137 return InputType::DeleteWordBackward;
2108 if (granularity == LineBoundary) 2138 if (granularity == LineBoundary)
2109 return InputType::DeleteLineBackward; 2139 return InputType::DeleteLineBackward;
2110 return InputType::DeleteContentBackward; 2140 return InputType::DeleteContentBackward;
2111 default: 2141 default:
2112 return InputType::None; 2142 return InputType::None;
2113 } 2143 }
2114 } 2144 }
2115 2145
2116 } // namespace blink 2146 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698