haikuwebkit/Source/WebCore/dom/StaticRange.idl

40 lines
1.6 KiB
Plaintext
Raw Permalink Normal View History

Implement InputEvent.getTargetRanges() for the input events spec https://bugs.webkit.org/show_bug.cgi?id=162947 <rdar://problem/28853079> Reviewed by Darin Adler. Source/JavaScriptCore: Boilerplate change to add a runtime guard for InputEvents-related IDL interfaces. See WebCore ChangeLog entry for more details. * runtime/CommonIdentifiers.h: Source/WebCore: Implements InputEvent.getTargetRanges(). See individual method changes below for more details. Adds a new hook for subclasses of CompositeEditCommand to vend a list of target StaticRanges when retrieving target ranges for an editing command on a contenteditable area. Tests: fast/events/before-input-delete-empty-list-target-ranges.html fast/events/before-input-delete-text-target-ranges.html fast/events/before-input-replace-text-target-ranges.html * CMakeLists.txt: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: Add StaticRange.idl, StaticRange.cpp and StaticRange.h. * bindings/generic/RuntimeEnabledFeatures.h: (WebCore::RuntimeEnabledFeatures::setInputEventsEnabled): (WebCore::RuntimeEnabledFeatures::inputEventsEnabled): Add a new runtime bindings flag for InputEvents and guard both InputEvent and StaticRange behind it. * dom/DOMAllInOne.cpp: * dom/InputEvent.cpp: (WebCore::InputEvent::InputEvent): * dom/InputEvent.h: * dom/InputEvent.idl: * dom/StaticRange.cpp: Copied from Source/WebCore/dom/InputEvent.cpp. (WebCore::StaticRange::StaticRange): (WebCore::StaticRange::create): (WebCore::StaticRange::createFromRange): Convenience method for creating a StaticRange from a Range's start/end container and offset. (WebCore::StaticRange::startContainer): (WebCore::StaticRange::endContainer): (WebCore::StaticRange::collapsed): * dom/StaticRange.h: Copied from Source/WebCore/dom/InputEvent.cpp. (WebCore::StaticRange::startOffset): (WebCore::StaticRange::endOffset): * dom/StaticRange.idl: Copied from Source/WebCore/editing/ReplaceRangeWithTextCommand.h. * editing/CompositeEditCommand.cpp: (WebCore::CompositeEditCommand::willApplyCommand): (WebCore::CompositeEditCommand::targetRanges): Virtual method that returns a list of target ranges which are associated with this command. (WebCore::CompositeEditCommand::targetRangesForBindings): Non-virtual method that calls the above targetRanges(). Takes whether or not the CompositeEditCommand is editing a textarea or plain text input into account. (WebCore::CompositeEditCommand::moveParagraphs): * editing/CompositeEditCommand.h: * editing/EditCommand.cpp: (WebCore::EditCommand::frame): * editing/EditCommand.h: (WebCore::EditCommand::document): * editing/Editor.cpp: (WebCore::dispatchBeforeInputEvent): (WebCore::dispatchInputEvent): (WebCore::dispatchBeforeInputEvents): Changed the `beforeinput` event dispatch to use the regular Node::dispatchEvent instead of dispatchScopedEvent. This is because if the page prevents the `beforeinput` event, we need to know immediately in order to bail from the default action. (WebCore::dispatchInputEvents): (WebCore::Editor::willApplyEditing): Added a list of static ranges as a parameter when calling on the Editor to dispatch `beforeinput` events. By default, this uses the composite edit command's targetRangesForBindings(), though it may be special cased by subclasses of CompositeEditCommand (see ReplaceRangeWithTextCommand, SpellingCorrectionCommand, and TypingCommand). * editing/Editor.h: * editing/ReplaceRangeWithTextCommand.cpp: (WebCore::ReplaceRangeWithTextCommand::targetRanges): * editing/ReplaceRangeWithTextCommand.h: * editing/SpellingCorrectionCommand.cpp: (WebCore::SpellingCorrectionCommand::targetRanges): * editing/SpellingCorrectionCommand.h: * editing/TypingCommand.cpp: (WebCore::editActionIsDeleteByTyping): (WebCore::TypingCommand::shouldDeferWillApplyCommandUntilAddingTypingCommand): (WebCore::TypingCommand::willApplyCommand): (WebCore::TypingCommand::willAddTypingToOpenCommand): (WebCore::TypingCommand::deleteKeyPressed): (WebCore::TypingCommand::forwardDeleteKeyPressed): Moves the firing of the `beforeinput` until after the selection range to delete has been computed. * editing/TypingCommand.h: Source/WebKit2: Boilerplate change to add a runtime guard for InputEvents-related IDL interfaces. See WebCore ChangeLog entry for more details. * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::updatePreferences): LayoutTests: Adds 3 new layout tests and tweaks some existing unit tests. See WebCore ChangeLog entry for more details. Tests verify the result of getTargetRanges() when breaking out of a list, deleting backwards and forwards at all text granularities, deleting selected text, and spell checking (candidate text replacement). * fast/events/before-input-delete-empty-list-target-ranges-expected.txt: Added. * fast/events/before-input-delete-empty-list-target-ranges.html: Added. * fast/events/before-input-delete-text-target-ranges-expected.txt: Added. * fast/events/before-input-delete-text-target-ranges.html: Added. * fast/events/before-input-events-prevent-default-in-textfield.html: * fast/events/before-input-replace-text-target-ranges-expected.txt: Added. * fast/events/before-input-replace-text-target-ranges.html: Added. * fast/events/input-events-fired-when-typing-expected.txt: * fast/events/input-events-fired-when-typing.html: * js/dom/global-constructors-attributes-expected.txt: * platform/ios-simulator/TestExpectations: * platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt: * platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt: * platform/mac/js/dom/global-constructors-attributes-expected.txt: Canonical link: https://commits.webkit.org/181550@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207670 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-21 15:51:28 +00:00
/*
Add AbstractRange https://bugs.webkit.org/show_bug.cgi?id=217846 Reviewed by Ryosuke Niwa. LayoutTests/imported/w3c: * web-platform-tests/dom/idlharness.window-expected.txt: Updated test result for progression. Source/WebCore: This makes us more accurately match the DOM specification, makes Range and StaticRange objects slightly bigger since they now have a virtual table pointer, and makes the AbstractRange methods a bit slower to call from JavaScript since they are backed by C++ virtual functions. * CMakeLists.txt: Added AbstractRange files. * DerivedSources-input.xcfilelist: Ditto. * DerivedSources-output.xcfilelist: Ditto. * DerivedSources.make: Ditto. * Headers.cmake: Ditto. * Sources.txt: Ditto. * WebCore.xcodeproj/project.pbxproj: Ditto. Also removed reference to non-existent JSAudioNodeCustom.cpp and moved JSStaticRange file from the Events group into the Ranges group. * bindings/js/JSAbstractRangeCustom.cpp: Added. (WebCore::toJS): Added. Just the default implementation. Would be nice if we did not have to write this. (WebCore::toJSNewlyCreated): Make either a StaticRange or Range wrapper depending on whether this is a live range or not. * bindings/js/JSEventCustom.cpp: Removed lots of unneeded includes. (WebCore::toJS): Stopped using "using namespace JSC". * bindings/js/WebCoreBuiltinNames.h: Added AbstractRange. * dom/AbstractRange.cpp: Added. (WebCore::makeSimpleRange): Added. * dom/AbstractRange.h: Added. * dom/AbstractRange.idl: Added. * dom/Range.h: Changed to derive from AbstractRange instead of from RefCounted. Also marked this final since it's now polymorphic. Marked all the functions that override final as well, to check that they correctly override the virtual functions in the base class. Added private isLiveRange function override that returns true. Added SPECIALIZE_TYPE_TRAITS_BEGIN/END so we can do is<Range>. * dom/Range.idl: Removed ImplementationLacksVTable. Added JSGenerateToNativeObject. Inherit from AbstractRange. Removed the 5 attribute getters that are now inherited from AbstractRange. * dom/StaticRange.h: Changed to derive from AbstractRange instead of from RefCounted. Also marked this final since it's now polymorphic. Added functions to override the ones from StaticRange, calling through to the ones from SimpleRange (I thought there was a way to do this with using, but I couldn't figure that out). Added private isLiveRange function override that returns false. Added SPECIALIZE_TYPE_TRAITS_BEGIN/END so we can do is<StaticRange>. * dom/StaticRange.idl: Removed EnabledBySetting=InputEvents since this should now always be included. I think we should probably remove the InputEvents setting now entirely. Removed ImplementationLacksVTable. Added JSGenerateToNativeObject. Inherit from AbstractRange. Removed all 5 attribute getters, which are now inherited from AbstractRange. Canonical link: https://commits.webkit.org/230606@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268648 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-10-17 20:33:53 +00:00
* Copyright (C) 2016-2020 Apple, Inc. All rights reserved.
Implement InputEvent.getTargetRanges() for the input events spec https://bugs.webkit.org/show_bug.cgi?id=162947 <rdar://problem/28853079> Reviewed by Darin Adler. Source/JavaScriptCore: Boilerplate change to add a runtime guard for InputEvents-related IDL interfaces. See WebCore ChangeLog entry for more details. * runtime/CommonIdentifiers.h: Source/WebCore: Implements InputEvent.getTargetRanges(). See individual method changes below for more details. Adds a new hook for subclasses of CompositeEditCommand to vend a list of target StaticRanges when retrieving target ranges for an editing command on a contenteditable area. Tests: fast/events/before-input-delete-empty-list-target-ranges.html fast/events/before-input-delete-text-target-ranges.html fast/events/before-input-replace-text-target-ranges.html * CMakeLists.txt: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: Add StaticRange.idl, StaticRange.cpp and StaticRange.h. * bindings/generic/RuntimeEnabledFeatures.h: (WebCore::RuntimeEnabledFeatures::setInputEventsEnabled): (WebCore::RuntimeEnabledFeatures::inputEventsEnabled): Add a new runtime bindings flag for InputEvents and guard both InputEvent and StaticRange behind it. * dom/DOMAllInOne.cpp: * dom/InputEvent.cpp: (WebCore::InputEvent::InputEvent): * dom/InputEvent.h: * dom/InputEvent.idl: * dom/StaticRange.cpp: Copied from Source/WebCore/dom/InputEvent.cpp. (WebCore::StaticRange::StaticRange): (WebCore::StaticRange::create): (WebCore::StaticRange::createFromRange): Convenience method for creating a StaticRange from a Range's start/end container and offset. (WebCore::StaticRange::startContainer): (WebCore::StaticRange::endContainer): (WebCore::StaticRange::collapsed): * dom/StaticRange.h: Copied from Source/WebCore/dom/InputEvent.cpp. (WebCore::StaticRange::startOffset): (WebCore::StaticRange::endOffset): * dom/StaticRange.idl: Copied from Source/WebCore/editing/ReplaceRangeWithTextCommand.h. * editing/CompositeEditCommand.cpp: (WebCore::CompositeEditCommand::willApplyCommand): (WebCore::CompositeEditCommand::targetRanges): Virtual method that returns a list of target ranges which are associated with this command. (WebCore::CompositeEditCommand::targetRangesForBindings): Non-virtual method that calls the above targetRanges(). Takes whether or not the CompositeEditCommand is editing a textarea or plain text input into account. (WebCore::CompositeEditCommand::moveParagraphs): * editing/CompositeEditCommand.h: * editing/EditCommand.cpp: (WebCore::EditCommand::frame): * editing/EditCommand.h: (WebCore::EditCommand::document): * editing/Editor.cpp: (WebCore::dispatchBeforeInputEvent): (WebCore::dispatchInputEvent): (WebCore::dispatchBeforeInputEvents): Changed the `beforeinput` event dispatch to use the regular Node::dispatchEvent instead of dispatchScopedEvent. This is because if the page prevents the `beforeinput` event, we need to know immediately in order to bail from the default action. (WebCore::dispatchInputEvents): (WebCore::Editor::willApplyEditing): Added a list of static ranges as a parameter when calling on the Editor to dispatch `beforeinput` events. By default, this uses the composite edit command's targetRangesForBindings(), though it may be special cased by subclasses of CompositeEditCommand (see ReplaceRangeWithTextCommand, SpellingCorrectionCommand, and TypingCommand). * editing/Editor.h: * editing/ReplaceRangeWithTextCommand.cpp: (WebCore::ReplaceRangeWithTextCommand::targetRanges): * editing/ReplaceRangeWithTextCommand.h: * editing/SpellingCorrectionCommand.cpp: (WebCore::SpellingCorrectionCommand::targetRanges): * editing/SpellingCorrectionCommand.h: * editing/TypingCommand.cpp: (WebCore::editActionIsDeleteByTyping): (WebCore::TypingCommand::shouldDeferWillApplyCommandUntilAddingTypingCommand): (WebCore::TypingCommand::willApplyCommand): (WebCore::TypingCommand::willAddTypingToOpenCommand): (WebCore::TypingCommand::deleteKeyPressed): (WebCore::TypingCommand::forwardDeleteKeyPressed): Moves the firing of the `beforeinput` until after the selection range to delete has been computed. * editing/TypingCommand.h: Source/WebKit2: Boilerplate change to add a runtime guard for InputEvents-related IDL interfaces. See WebCore ChangeLog entry for more details. * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::updatePreferences): LayoutTests: Adds 3 new layout tests and tweaks some existing unit tests. See WebCore ChangeLog entry for more details. Tests verify the result of getTargetRanges() when breaking out of a list, deleting backwards and forwards at all text granularities, deleting selected text, and spell checking (candidate text replacement). * fast/events/before-input-delete-empty-list-target-ranges-expected.txt: Added. * fast/events/before-input-delete-empty-list-target-ranges.html: Added. * fast/events/before-input-delete-text-target-ranges-expected.txt: Added. * fast/events/before-input-delete-text-target-ranges.html: Added. * fast/events/before-input-events-prevent-default-in-textfield.html: * fast/events/before-input-replace-text-target-ranges-expected.txt: Added. * fast/events/before-input-replace-text-target-ranges.html: Added. * fast/events/input-events-fired-when-typing-expected.txt: * fast/events/input-events-fired-when-typing.html: * js/dom/global-constructors-attributes-expected.txt: * platform/ios-simulator/TestExpectations: * platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt: * platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt: * platform/mac/js/dom/global-constructors-attributes-expected.txt: Canonical link: https://commits.webkit.org/181550@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207670 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-21 15:51:28 +00:00
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
[
Add AbstractRange https://bugs.webkit.org/show_bug.cgi?id=217846 Reviewed by Ryosuke Niwa. LayoutTests/imported/w3c: * web-platform-tests/dom/idlharness.window-expected.txt: Updated test result for progression. Source/WebCore: This makes us more accurately match the DOM specification, makes Range and StaticRange objects slightly bigger since they now have a virtual table pointer, and makes the AbstractRange methods a bit slower to call from JavaScript since they are backed by C++ virtual functions. * CMakeLists.txt: Added AbstractRange files. * DerivedSources-input.xcfilelist: Ditto. * DerivedSources-output.xcfilelist: Ditto. * DerivedSources.make: Ditto. * Headers.cmake: Ditto. * Sources.txt: Ditto. * WebCore.xcodeproj/project.pbxproj: Ditto. Also removed reference to non-existent JSAudioNodeCustom.cpp and moved JSStaticRange file from the Events group into the Ranges group. * bindings/js/JSAbstractRangeCustom.cpp: Added. (WebCore::toJS): Added. Just the default implementation. Would be nice if we did not have to write this. (WebCore::toJSNewlyCreated): Make either a StaticRange or Range wrapper depending on whether this is a live range or not. * bindings/js/JSEventCustom.cpp: Removed lots of unneeded includes. (WebCore::toJS): Stopped using "using namespace JSC". * bindings/js/WebCoreBuiltinNames.h: Added AbstractRange. * dom/AbstractRange.cpp: Added. (WebCore::makeSimpleRange): Added. * dom/AbstractRange.h: Added. * dom/AbstractRange.idl: Added. * dom/Range.h: Changed to derive from AbstractRange instead of from RefCounted. Also marked this final since it's now polymorphic. Marked all the functions that override final as well, to check that they correctly override the virtual functions in the base class. Added private isLiveRange function override that returns true. Added SPECIALIZE_TYPE_TRAITS_BEGIN/END so we can do is<Range>. * dom/Range.idl: Removed ImplementationLacksVTable. Added JSGenerateToNativeObject. Inherit from AbstractRange. Removed the 5 attribute getters that are now inherited from AbstractRange. * dom/StaticRange.h: Changed to derive from AbstractRange instead of from RefCounted. Also marked this final since it's now polymorphic. Added functions to override the ones from StaticRange, calling through to the ones from SimpleRange (I thought there was a way to do this with using, but I couldn't figure that out). Added private isLiveRange function override that returns false. Added SPECIALIZE_TYPE_TRAITS_BEGIN/END so we can do is<StaticRange>. * dom/StaticRange.idl: Removed EnabledBySetting=InputEvents since this should now always be included. I think we should probably remove the InputEvents setting now entirely. Removed ImplementationLacksVTable. Added JSGenerateToNativeObject. Inherit from AbstractRange. Removed all 5 attribute getters, which are now inherited from AbstractRange. Canonical link: https://commits.webkit.org/230606@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268648 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-10-17 20:33:53 +00:00
Exposed=Window,
JSGenerateToNativeObject,
JSCustomMarkFunction,
Add AbstractRange https://bugs.webkit.org/show_bug.cgi?id=217846 Reviewed by Ryosuke Niwa. LayoutTests/imported/w3c: * web-platform-tests/dom/idlharness.window-expected.txt: Updated test result for progression. Source/WebCore: This makes us more accurately match the DOM specification, makes Range and StaticRange objects slightly bigger since they now have a virtual table pointer, and makes the AbstractRange methods a bit slower to call from JavaScript since they are backed by C++ virtual functions. * CMakeLists.txt: Added AbstractRange files. * DerivedSources-input.xcfilelist: Ditto. * DerivedSources-output.xcfilelist: Ditto. * DerivedSources.make: Ditto. * Headers.cmake: Ditto. * Sources.txt: Ditto. * WebCore.xcodeproj/project.pbxproj: Ditto. Also removed reference to non-existent JSAudioNodeCustom.cpp and moved JSStaticRange file from the Events group into the Ranges group. * bindings/js/JSAbstractRangeCustom.cpp: Added. (WebCore::toJS): Added. Just the default implementation. Would be nice if we did not have to write this. (WebCore::toJSNewlyCreated): Make either a StaticRange or Range wrapper depending on whether this is a live range or not. * bindings/js/JSEventCustom.cpp: Removed lots of unneeded includes. (WebCore::toJS): Stopped using "using namespace JSC". * bindings/js/WebCoreBuiltinNames.h: Added AbstractRange. * dom/AbstractRange.cpp: Added. (WebCore::makeSimpleRange): Added. * dom/AbstractRange.h: Added. * dom/AbstractRange.idl: Added. * dom/Range.h: Changed to derive from AbstractRange instead of from RefCounted. Also marked this final since it's now polymorphic. Marked all the functions that override final as well, to check that they correctly override the virtual functions in the base class. Added private isLiveRange function override that returns true. Added SPECIALIZE_TYPE_TRAITS_BEGIN/END so we can do is<Range>. * dom/Range.idl: Removed ImplementationLacksVTable. Added JSGenerateToNativeObject. Inherit from AbstractRange. Removed the 5 attribute getters that are now inherited from AbstractRange. * dom/StaticRange.h: Changed to derive from AbstractRange instead of from RefCounted. Also marked this final since it's now polymorphic. Added functions to override the ones from StaticRange, calling through to the ones from SimpleRange (I thought there was a way to do this with using, but I couldn't figure that out). Added private isLiveRange function override that returns false. Added SPECIALIZE_TYPE_TRAITS_BEGIN/END so we can do is<StaticRange>. * dom/StaticRange.idl: Removed EnabledBySetting=InputEvents since this should now always be included. I think we should probably remove the InputEvents setting now entirely. Removed ImplementationLacksVTable. Added JSGenerateToNativeObject. Inherit from AbstractRange. Removed all 5 attribute getters, which are now inherited from AbstractRange. Canonical link: https://commits.webkit.org/230606@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268648 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-10-17 20:33:53 +00:00
] interface StaticRange : AbstractRange {
constructor(StaticRangeInit init);
Implement InputEvent.getTargetRanges() for the input events spec https://bugs.webkit.org/show_bug.cgi?id=162947 <rdar://problem/28853079> Reviewed by Darin Adler. Source/JavaScriptCore: Boilerplate change to add a runtime guard for InputEvents-related IDL interfaces. See WebCore ChangeLog entry for more details. * runtime/CommonIdentifiers.h: Source/WebCore: Implements InputEvent.getTargetRanges(). See individual method changes below for more details. Adds a new hook for subclasses of CompositeEditCommand to vend a list of target StaticRanges when retrieving target ranges for an editing command on a contenteditable area. Tests: fast/events/before-input-delete-empty-list-target-ranges.html fast/events/before-input-delete-text-target-ranges.html fast/events/before-input-replace-text-target-ranges.html * CMakeLists.txt: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: Add StaticRange.idl, StaticRange.cpp and StaticRange.h. * bindings/generic/RuntimeEnabledFeatures.h: (WebCore::RuntimeEnabledFeatures::setInputEventsEnabled): (WebCore::RuntimeEnabledFeatures::inputEventsEnabled): Add a new runtime bindings flag for InputEvents and guard both InputEvent and StaticRange behind it. * dom/DOMAllInOne.cpp: * dom/InputEvent.cpp: (WebCore::InputEvent::InputEvent): * dom/InputEvent.h: * dom/InputEvent.idl: * dom/StaticRange.cpp: Copied from Source/WebCore/dom/InputEvent.cpp. (WebCore::StaticRange::StaticRange): (WebCore::StaticRange::create): (WebCore::StaticRange::createFromRange): Convenience method for creating a StaticRange from a Range's start/end container and offset. (WebCore::StaticRange::startContainer): (WebCore::StaticRange::endContainer): (WebCore::StaticRange::collapsed): * dom/StaticRange.h: Copied from Source/WebCore/dom/InputEvent.cpp. (WebCore::StaticRange::startOffset): (WebCore::StaticRange::endOffset): * dom/StaticRange.idl: Copied from Source/WebCore/editing/ReplaceRangeWithTextCommand.h. * editing/CompositeEditCommand.cpp: (WebCore::CompositeEditCommand::willApplyCommand): (WebCore::CompositeEditCommand::targetRanges): Virtual method that returns a list of target ranges which are associated with this command. (WebCore::CompositeEditCommand::targetRangesForBindings): Non-virtual method that calls the above targetRanges(). Takes whether or not the CompositeEditCommand is editing a textarea or plain text input into account. (WebCore::CompositeEditCommand::moveParagraphs): * editing/CompositeEditCommand.h: * editing/EditCommand.cpp: (WebCore::EditCommand::frame): * editing/EditCommand.h: (WebCore::EditCommand::document): * editing/Editor.cpp: (WebCore::dispatchBeforeInputEvent): (WebCore::dispatchInputEvent): (WebCore::dispatchBeforeInputEvents): Changed the `beforeinput` event dispatch to use the regular Node::dispatchEvent instead of dispatchScopedEvent. This is because if the page prevents the `beforeinput` event, we need to know immediately in order to bail from the default action. (WebCore::dispatchInputEvents): (WebCore::Editor::willApplyEditing): Added a list of static ranges as a parameter when calling on the Editor to dispatch `beforeinput` events. By default, this uses the composite edit command's targetRangesForBindings(), though it may be special cased by subclasses of CompositeEditCommand (see ReplaceRangeWithTextCommand, SpellingCorrectionCommand, and TypingCommand). * editing/Editor.h: * editing/ReplaceRangeWithTextCommand.cpp: (WebCore::ReplaceRangeWithTextCommand::targetRanges): * editing/ReplaceRangeWithTextCommand.h: * editing/SpellingCorrectionCommand.cpp: (WebCore::SpellingCorrectionCommand::targetRanges): * editing/SpellingCorrectionCommand.h: * editing/TypingCommand.cpp: (WebCore::editActionIsDeleteByTyping): (WebCore::TypingCommand::shouldDeferWillApplyCommandUntilAddingTypingCommand): (WebCore::TypingCommand::willApplyCommand): (WebCore::TypingCommand::willAddTypingToOpenCommand): (WebCore::TypingCommand::deleteKeyPressed): (WebCore::TypingCommand::forwardDeleteKeyPressed): Moves the firing of the `beforeinput` until after the selection range to delete has been computed. * editing/TypingCommand.h: Source/WebKit2: Boilerplate change to add a runtime guard for InputEvents-related IDL interfaces. See WebCore ChangeLog entry for more details. * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::updatePreferences): LayoutTests: Adds 3 new layout tests and tweaks some existing unit tests. See WebCore ChangeLog entry for more details. Tests verify the result of getTargetRanges() when breaking out of a list, deleting backwards and forwards at all text granularities, deleting selected text, and spell checking (candidate text replacement). * fast/events/before-input-delete-empty-list-target-ranges-expected.txt: Added. * fast/events/before-input-delete-empty-list-target-ranges.html: Added. * fast/events/before-input-delete-text-target-ranges-expected.txt: Added. * fast/events/before-input-delete-text-target-ranges.html: Added. * fast/events/before-input-events-prevent-default-in-textfield.html: * fast/events/before-input-replace-text-target-ranges-expected.txt: Added. * fast/events/before-input-replace-text-target-ranges.html: Added. * fast/events/input-events-fired-when-typing-expected.txt: * fast/events/input-events-fired-when-typing.html: * js/dom/global-constructors-attributes-expected.txt: * platform/ios-simulator/TestExpectations: * platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt: * platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt: * platform/mac/js/dom/global-constructors-attributes-expected.txt: Canonical link: https://commits.webkit.org/181550@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207670 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-21 15:51:28 +00:00
};
dictionary StaticRangeInit {
Begin moving off of live ranges for WebKit internals https://bugs.webkit.org/show_bug.cgi?id=208432 Reviewed by Daniel Bates. Source/WebCore: The DOM Range class is a live range. The live updating feature of these ranges mean they are expensive to create and destroy and also make all DOM mutation more expensive while they are alive. We will be able to speed up, likely measurable on Speedometer, if we can cut down uses of live ranges. - Refactored the StaticRange class to create two new structs. - The BoundaryPoint struct implements what the DOM standard calls a boundary point: a node and offset. Similar to the RangeBoundaryPoint class, which supports being the boundary point of a live range, but simpler and not live. - The SimpleRange struct implements what the DOM standard calls a range (not a live range). Like StaticRange but without reference counting and DOM binding. - Since StaticRange is derived publicly from SimpleRange you can pass either to any function that takes a SimpleRange. And since there is a constructor to create a SimpleRange from a Range you can pass a Range to those functions too. - Renamed StaticRange::createFromRange to StaticRange::create. * Headers.cmake: Added BoundaryPoint.h, SimpleRange.h, and StaticRange.h. * Sources.txt: Added BoundaryPoint.cpp and SimpleRange.cpp. * WebCore.xcodeproj/project.pbxproj: Added BoundaryPoint.cpp/h and SimpleRange.cpp/h. * dom/BoundaryPoint.cpp: Added. * dom/BoundaryPoint.h: Added. * dom/SimpleRange.cpp: Added. * dom/SimpleRange.h: Added. * dom/StaticRange.cpp: (WebCore::StaticRange::StaticRange): Take an rvalue reference to a SimpleRange. (WebCore::StaticRange::create): Ditto. Changed the other overloads to create a SimpleRange first then call through to the main one. (WebCore::isDocumentTypeOrAttr): Wrote a much more efficient version of this. The old version called the virtual function nodeType twice. This calls it at most once, and mostly doesn't call it at all. * dom/StaticRange.h: Simplified this class, putting most of the actual range logic into the base class. Note that this change eliminated the peculiar code that in the == operator that compared nodes using isEqualNode instead of using node identity. There was no one who needed that other behavior. Also fixed mistaken use of unsigned long in StaticRange::Init. It's unsigned long in the IDL file, but confusingly that's just unsigned in .cpp files. * dom/StaticRange.idl: Tweaked formatting. * editing/CompositeEditCommand.cpp: (WebCore::CompositeEditCommand::targetRanges const): Updated for rename of StaticRange::create. * editing/ReplaceRangeWithTextCommand.cpp: (WebCore::ReplaceRangeWithTextCommand::doApply): Updated since VisibleSelection takes SimpleRange now. (WebCore::ReplaceRangeWithTextCommand::targetRanges const): Updated for rename of StaticRange::create. * editing/SpellingCorrectionCommand.cpp: (WebCore::SpellingCorrectionCommand::SpellingCorrectionCommand): Updated since a selection now takes a SimpleRange&, not a StaticRange. (WebCore::SpellingCorrectionCommand::targetRanges const): Updated for rename of StaticRange::create. * editing/TypingCommand.cpp: (WebCore::TypingCommand::willAddTypingToOpenCommand): Ditto. * editing/VisibleSelection.cpp: (WebCore::VisibleSelection::VisibleSelection): Use SimpleRange instead of StaticRange and Range. * editing/VisibleSelection.h: Updated for the above. * editing/mac/EditorMac.mm: Added include. * page/DragController.cpp: Ditto. * page/TextIndicator.cpp: Ditto. (WebCore::TextIndicator::createWithRange): Updated since VisibleSelection takes SimpleRange now. * page/mac/EventHandlerMac.mm: (WebCore::InlineTextBox::collectMarkedTextsForHighlights): Tweaked coding style a bit. Source/WebKit: * Shared/EditingRange.cpp: (WebKit::EditingRange::fromRange): Initialize out arguments. * WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp: Added include. * WebProcess/WebPage/FindController.cpp: Ditto. * WebProcess/WebPage/WebPage.cpp: Ditto. * WebProcess/WebPage/mac/WebPageMac.mm: Ditto. Source/WebKitLegacy/ios: * WebCoreSupport/WebFrameIOS.mm: Added include. Source/WebKitLegacy/mac: * WebCoreSupport/WebContextMenuClient.mm: Added include. * WebView/WebFrame.mm: Ditto. (-[WebFrame _convertToNSRange:]): Initialized out arguments. Canonical link: https://commits.webkit.org/221736@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@258129 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-03-09 04:00:31 +00:00
required Node startContainer;
required unsigned long startOffset;
required Node endContainer;
required unsigned long endOffset;
};