haikuwebkit/LayoutTests/fast/dom/rangeIntersectsRange.html

90 lines
2.9 KiB
HTML
Raw Permalink Normal View History

Remove another function that implicitly uses the composed tree (intersects with range) https://bugs.webkit.org/show_bug.cgi?id=218726 Reviewed by Ryosuke Niwa. Source/WebCore: Tests: fast/dom/rangeContainsBoundaryPoint.html fast/dom/rangeIntersectsNode.html fast/dom/rangeIntersectsRange.html * Sources.txt: Added BoundaryPoint.cpp. * WebCore.xcodeproj/project.pbxproj: Ditto. * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::documentBasedSelectedTextRange const): Use intersects<ComposedTree>. * accessibility/atk/WebKitAccessibleUtil.cpp: (selectionBelongsToObject): Ditto. * dom/BoundaryPoint.cpp: Added. * dom/Range.cpp: (WebCore::Range::isPointInRange): Use contains instead of contains<Tree> since the normal tree is now default. (WebCore::Range::intersectsNode const): Use intersects instead of intersects<Tree> since the normal tree is now default. * dom/SimpleRange.cpp: (WebCore::makeBoundaryPointBeforeNode): Moved to BoundaryPoint.cpp. (WebCore::makeBoundaryPointAfterNode): Ditto. (WebCore::isOffsetBeforeChild): Ditto. (WebCore::order): Ditto. (WebCore::treeOrderForTesting): Ditto. (WebCore::containsForTesting): Added an overload for range and boundary point. (WebCore::intersects): Deleted two of these that were using ComposedTree. (WebCore::intersectsForTesting): Added. (WebCore::intersection): Use intersects<ComposedTree>. (WebCore::contains): Implemented this template function and use it to replac the incorrect specialization we had for ComposedTree. (WebCore::containsCrossingDocumentBoundaries): Added. * dom/SimpleRange.h: Made the contains functions template arguments default to Tree. Added another overload of containsForTesting and added intersectsForTesting. Removed intersects functions that were deprecated; the ones that used ComposedTree. Added containsCrossingDocumentBoundaries. * editing/Editor.cpp: (WebCore::isFrameInRange): Use intersects<ComposedTree>. (WebCore::Editor::scanSelectionForTelephoneNumbers): Ditto. * editing/FrameSelection.cpp: (WebCore::FrameSelection::respondToNodeModification): Ditto. * editing/VisiblePosition.cpp: (WebCore::makeVisiblePositionRange): Added. * editing/VisiblePosition.h: Added makeVisiblePositionRange, which takes an Optional<SimpleRange>. * page/DOMSelection.cpp: (WebCore::DOMSelection::addRange): Use intersects instead of intersects<Tree> since the normal tree is now default. (WebCore::DOMSelection::containsNode const): Use intersects/contains instead of intersects/contains<Tree> since the normal tree is now default. * page/DragController.cpp: (WebCore::DragController::insertDroppedImagePlaceholdersAtCaret): Use intersects<ComposedTree>. * testing/Internals.cpp: (WebCore::Internals::rangeContainsBoundaryPoint): Added. (WebCore::Internals::rangeIntersectsNode): Added. (WebCore::Internals::rangeIntersectsRange): Added. * testing/Internals.h: Updated for the above. * testing/Internals.idl: Ditto. Source/WebKit: * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::requestDocumentEditingContext): Refactor to use VisiblePositionRange and to call intersects on two of them, to improve the code readability and also sidestep the issue of calling the intersects template function from outside WebCore. Source/WebKitLegacy/mac: * WebView/WebPDFView.mm: (isFrameInRange): Deleted. This function used intersects, and deleting it side-steps the issue of calling the intersects function template from outside WebCore. (-[WebPDFView countMatchesForText:inDOMRange:options:limit:markMatches:]): Use containsCrossingDocumentBoundaries instead of isFrameInRange. Tools: * TestWebKitAPI/Tests/WebCore/DocumentOrder.cpp: (TestWebKitAPI::makeBoundaryPoint): Deleted. Deleted the DocumentOrder.IsPointInRange, DocumentOrder.RangeIntersectsRange and DocumentOrder.RangeIntersectsNode tests, each replaced by an internals-based test. LayoutTests: * fast/dom/rangeContainsBoundaryPoint-expected.txt: Added. * fast/dom/rangeContainsBoundaryPoint.html: Added. * fast/dom/rangeIntersectsNode-expected.txt: Added. * fast/dom/rangeIntersectsNode.html: Added. * fast/dom/rangeIntersectsRange-expected.txt: Added. * fast/dom/rangeIntersectsRange.html: Added. These tests were formerly part of TestWebKitAPI. Moving to internals-style tests at Ryosuke's suggestion since these are not something exposed as API or SPI. Canonical link: https://commits.webkit.org/231444@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269662 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-11-11 00:41:21 +00:00
<html><head></head><body>
<script src="../../resources/js-test.js"></script>
<script>
description("Test the intersects function that checks if a range intersects another range.")
function range(startContainer, startOffset, endContainer, endOffset)
{
return new StaticRange({ startContainer: startContainer, startOffset: startOffset, endContainer: endContainer, endOffset: endOffset })
}
function collapsedRange(container, offset)
{
return range(container, offset, container, offset)
}
function contentsRange(node)
{
return range(node, 0, node, node.childNodes.length)
}
function shouldIntersectSelf(a)
{
shouldBeTrue("internals.rangeIntersectsRange(" + a + ", " + a + ", 'ComposedTree')")
}
function shouldIntersect(a, b)
{
shouldBeTrue("internals.rangeIntersectsRange(" + a + ", " + b + ", 'ComposedTree')")
shouldBeTrue("internals.rangeIntersectsRange(" + b + ", " + a + ", 'ComposedTree')")
}
function shouldNotIntersect(a, b)
{
shouldBeFalse("internals.rangeIntersectsRange(" + a + ", " + b + ", 'ComposedTree')")
shouldBeFalse("internals.rangeIntersectsRange(" + b + ", " + a + ", 'ComposedTree')")
}
let documentElement = document.documentElement;
let body = document.body;
shouldIntersectSelf("contentsRange(document)")
shouldIntersectSelf("contentsRange(documentElement)")
shouldIntersectSelf("contentsRange(body)")
shouldIntersect("contentsRange(document)", "contentsRange(documentElement)")
shouldIntersect("contentsRange(document)", "contentsRange(body)")
shouldIntersect("contentsRange(documentElement)", "contentsRange(body)")
shouldIntersect("contentsRange(document)", "contentsRange(documentElement)")
shouldIntersect("contentsRange(documentElement)", "contentsRange(body)")
shouldIntersect("contentsRange(document)", "collapsedRange(document, 0)")
shouldIntersect("contentsRange(document)", "collapsedRange(document, 1)")
shouldNotIntersect("contentsRange(document)", "collapsedRange(document, 2)")
shouldIntersect("range(document, 0, document, 2)", "contentsRange(document)")
shouldIntersect("contentsRange(document)", "range(document, 1, document, 2)")
shouldNotIntersect("range(document, 0, documentElement, 0)", "contentsRange(body)")
shouldIntersect("range(document, 0, body, 0)", "collapsedRange(body, 0)")
let a = document.createElement("div")
shouldNotIntersect("contentsRange(document)", "contentsRange(a)")
body.appendChild(a)
let b = document.createElement("div")
body.appendChild(b)
let c = document.createElement("div")
b.appendChild(c)
let d = document.createElement("div")
a.appendChild(d)
let e = document.createElement("div")
let f = document.createElement("div")
e.appendChild(f)
shouldNotIntersect("contentsRange(body)", "contentsRange(f)")
let g = document.createElement("textarea");
c.appendChild(g)
let h = internals.ensureUserAgentShadowRoot(g).firstChild
shouldIntersect("contentsRange(body)", "contentsRange(h)")
</script>
</body></html>