OLD | NEW |
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 2024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2035 // otherwise, make sure to be at the start of the first selected node, | 2035 // otherwise, make sure to be at the start of the first selected node, |
2036 // instead of possibly at the end of the last node before the selection | 2036 // instead of possibly at the end of the last node before the selection |
2037 return mostForwardCaretPosition(visiblePosition.deepEquivalent()); | 2037 return mostForwardCaretPosition(visiblePosition.deepEquivalent()); |
2038 } | 2038 } |
2039 | 2039 |
2040 bool isTextSecurityNode(const Node* node) { | 2040 bool isTextSecurityNode(const Node* node) { |
2041 return node && node->layoutObject() && | 2041 return node && node->layoutObject() && |
2042 node->layoutObject()->style()->textSecurity() != TSNONE; | 2042 node->layoutObject()->style()->textSecurity() != TSNONE; |
2043 } | 2043 } |
2044 | 2044 |
2045 const RangeVector* targetRangesForInputEvent(const Node& node) { | 2045 const StaticRangeVector* targetRangesForInputEvent(const Node& node) { |
2046 if (!hasRichlyEditableStyle(node)) | 2046 if (!hasRichlyEditableStyle(node)) |
2047 return nullptr; | 2047 return nullptr; |
2048 return new RangeVector( | 2048 return new StaticRangeVector( |
2049 1, firstRangeOf(node.document() | 2049 1, StaticRange::create( |
2050 .frame() | 2050 firstRangeOf(node.document() |
2051 ->selection() | 2051 .frame() |
2052 .computeVisibleSelectionInDOMTreeDeprecated())); | 2052 ->selection() |
| 2053 .computeVisibleSelectionInDOMTreeDeprecated()))); |
2053 } | 2054 } |
2054 | 2055 |
2055 DispatchEventResult dispatchBeforeInputInsertText(Node* target, | 2056 DispatchEventResult dispatchBeforeInputInsertText(Node* target, |
2056 const String& data) { | 2057 const String& data) { |
2057 if (!RuntimeEnabledFeatures::inputEventEnabled()) | 2058 if (!RuntimeEnabledFeatures::inputEventEnabled()) |
2058 return DispatchEventResult::NotCanceled; | 2059 return DispatchEventResult::NotCanceled; |
2059 if (!target) | 2060 if (!target) |
2060 return DispatchEventResult::NotCanceled; | 2061 return DispatchEventResult::NotCanceled; |
2061 // TODO(chongz): Pass appropriate |ranges| after it's defined on spec. | 2062 // TODO(chongz): Pass appropriate |ranges| after it's defined on spec. |
2062 // http://w3c.github.io/editing/input-events.html#dom-inputevent-inputtype | 2063 // http://w3c.github.io/editing/input-events.html#dom-inputevent-inputtype |
2063 InputEvent* beforeInputEvent = | 2064 InputEvent* beforeInputEvent = |
2064 InputEvent::createBeforeInput(InputEvent::InputType::InsertText, data, | 2065 InputEvent::createBeforeInput(InputEvent::InputType::InsertText, data, |
2065 InputEvent::EventCancelable::IsCancelable, | 2066 InputEvent::EventCancelable::IsCancelable, |
2066 InputEvent::EventIsComposing::NotComposing, | 2067 InputEvent::EventIsComposing::NotComposing, |
2067 targetRangesForInputEvent(*target)); | 2068 targetRangesForInputEvent(*target)); |
2068 return target->dispatchEvent(beforeInputEvent); | 2069 return target->dispatchEvent(beforeInputEvent); |
2069 } | 2070 } |
2070 | 2071 |
2071 DispatchEventResult dispatchBeforeInputEditorCommand( | 2072 DispatchEventResult dispatchBeforeInputEditorCommand( |
2072 Node* target, | 2073 Node* target, |
2073 InputEvent::InputType inputType, | 2074 InputEvent::InputType inputType, |
2074 const RangeVector* ranges) { | 2075 const StaticRangeVector* ranges) { |
2075 if (!RuntimeEnabledFeatures::inputEventEnabled()) | 2076 if (!RuntimeEnabledFeatures::inputEventEnabled()) |
2076 return DispatchEventResult::NotCanceled; | 2077 return DispatchEventResult::NotCanceled; |
2077 if (!target) | 2078 if (!target) |
2078 return DispatchEventResult::NotCanceled; | 2079 return DispatchEventResult::NotCanceled; |
2079 InputEvent* beforeInputEvent = InputEvent::createBeforeInput( | 2080 InputEvent* beforeInputEvent = InputEvent::createBeforeInput( |
2080 inputType, nullAtom, InputEvent::EventCancelable::IsCancelable, | 2081 inputType, nullAtom, InputEvent::EventCancelable::IsCancelable, |
2081 InputEvent::EventIsComposing::NotComposing, ranges); | 2082 InputEvent::EventIsComposing::NotComposing, ranges); |
2082 return target->dispatchEvent(beforeInputEvent); | 2083 return target->dispatchEvent(beforeInputEvent); |
2083 } | 2084 } |
2084 | 2085 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2132 return InputType::DeleteWordBackward; | 2133 return InputType::DeleteWordBackward; |
2133 if (granularity == LineBoundary) | 2134 if (granularity == LineBoundary) |
2134 return InputType::DeleteLineBackward; | 2135 return InputType::DeleteLineBackward; |
2135 return InputType::DeleteContentBackward; | 2136 return InputType::DeleteContentBackward; |
2136 default: | 2137 default: |
2137 return InputType::None; | 2138 return InputType::None; |
2138 } | 2139 } |
2139 } | 2140 } |
2140 | 2141 |
2141 } // namespace blink | 2142 } // namespace blink |
OLD | NEW |