haikuwebkit/Source/WebCore/dom/AbstractRange.idl

41 lines
1.6 KiB
Plaintext
Raw Permalink Normal View History

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) 2020 Apple Inc. All rights reserved.
*
* 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 THE COPYRIGHT HOLDER "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 THE COPYRIGHT HOLDER 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.
*/
[
CustomToJSObject,
Start removing functions that implicitly use composed tree https://bugs.webkit.org/show_bug.cgi?id=218424 Reviewed by Ryosuke Niwa. Source/WebCore: Tests: fast/dom/rangeContainsNode.html fast/dom/rangeContainsRange.html fast/dom/treeOrder.html Ryosuke pointed out that most clients should not be using the composed tree, so this is a step in work to make the use of the composed tree explicit. After that we can more easily find and correct call sites where use of the composed tree is incorrect. Likely that most or all cases of treeOrder<ComposedTree> can be changed to just treeOrder and contains<ComposedTree> to just contains; will do those in follow-ups. * Modules/highlight/Highlight.cpp: (WebCore::repaintRange): Simplified code to use boundary points, and changed to use treeOrder<ComposedTree>. * dom/AbstractRange.h: Export makeSimpleRange so it can be used in Internals. * dom/AbstractRange.idl: Export the class so it can be used in Internals. * dom/Node.cpp: (WebCore::parent<ShadowIncludingTree>): Added. (WebCore::treeOrderForTesting): Added. (WebCore::documentOrder): Deleted. * dom/Node.h: Updated for the above. * dom/RadioButtonGroups.cpp: (WebCore::RadioButtonGroup::members const): Use treeOrder<ComposedTree>. * dom/SimpleRange.cpp: (WebCore::contains): Removed a couple contains functions that implicitly use composed tree. (WebCore::containsForTesting): Added. * dom/SimpleRange.h: Updated for the above. Should also make contains<Tree> the default and remove the <Tree> at all call sites, but it's safer to do that in a separate patch after this is landed and builds on all platforms. * editing/Editing.cpp: (WebCore::isNodeVisiblyContainedWithin): Use contains<ComposedTree>. * page/DragController.cpp: (WebCore::DragController::draggableElement const): Ditto. * page/EventHandler.cpp: (WebCore::EventHandler::dispatchMouseEvent): Ditto. Note that this has a call to isDescendantOf right next to it, which does not use the composed tree. * page/Page.cpp: (WebCore::Page::findTextMatches): Use treeOrder<ComposedTree>. (WebCore::replaceRanges): Ditto. * page/mac/ServicesOverlayController.mm: (WebCore::ServicesOverlayController::findTelephoneNumberHighlightContainingSelectionHighlight): Use contains<ComposedTree>. * testing/Internals.cpp: (WebCore::string): Added. (WebCore::convertType): Added. (WebCore::Internals::treeOrder): Added. (WebCore::Internals::rangeContainsNode): Added. (WebCore::Internals::rangeContainsRange): Added. * testing/Internals.h: Updated for added functions above. * testing/Internals.idl: Ditto. These functions were tested in a TestWebKitAPI test, but we plan to move those types of tests to internals-based tests instead. Source/WebKit: * WebProcess/WebPage/glib/WebPageGLib.cpp: (WebKit::WebPage::getPlatformEditorState const): Use contains<ComposedTree>. Tools: * TestWebKitAPI/Tests/WebCore/DocumentOrder.cpp: Moved the tests of documentOrder for two nodes and contains for range/range or range/node into internals-based tests in the LayoutTests directory. Eventually we'll move the rest of these tests, too. LayoutTests: * fast/dom/rangeContainsNode-expected.txt: Added. * fast/dom/rangeContainsNode.html: Added. * fast/dom/rangeContainsRange-expected.txt: Added. * fast/dom/rangeContainsRange.html: Added. * fast/dom/treeOrder-expected.txt: Added. * fast/dom/treeOrder.html: Added. These tests were formerly part of TestWebKitAPI, although treeOrder was named documentOrder. Moving to internals-style tests at Ryosuke's suggestion since these are not something exposed as API or even SPI. Canonical link: https://commits.webkit.org/231111@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-11-02 18:53:36 +00:00
ExportMacro=WEBCORE_EXPORT,
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,
] interface AbstractRange {
readonly attribute Node startContainer;
readonly attribute unsigned long startOffset;
readonly attribute Node endContainer;
readonly attribute unsigned long endOffset;
readonly attribute boolean collapsed;
};