haikuwebkit/LayoutTests/accessibility/scroll-to-global-point-ifra...

74 lines
2.4 KiB
HTML
Raw Permalink Normal View History

AX: When navigating the elements of a scrollable element with VoiceOver, the scrollTop() position of the element does not permanently change https://bugs.webkit.org/show_bug.cgi?id=125720 Reviewed by Daniel Bates. Source/WebCore: The scrollToVisible code did not account for scrollable elements that are larger than their viewports. First, we need to pass the sub-focus up the scroll chain (otherwise we'll scroll some parent to y=0). Second, we should try to center the focus within the viewport, rather than positioning at the bottom for a better experience. This change was adapted from Blink r183926: https://src.chromium.org/viewvc/blink?view=rev&revision=183926 Tests: accessibility/scroll-to-global-point-iframe-nested.html accessibility/scroll-to-global-point-iframe.html accessibility/scroll-to-global-point-main-window.html accessibility/scroll-to-global-point-nested.html accessibility/scroll-to-make-visible-div-overflow.html accessibility/scroll-to-make-visible-iframe.html accessibility/scroll-to-make-visible-nested-2.html accessibility/scroll-to-make-visible-nested.html accessibility/scroll-to-make-visible-with-subfocus.html * accessibility/AccessibilityObject.cpp: (WebCore::computeBestScrollOffset): (WebCore::AccessibilityObject::isOnscreen): (WebCore::AccessibilityObject::scrollToMakeVisibleWithSubFocus): (WebCore::AccessibilityObject::scrollToGlobalPoint): * accessibility/mac/WebAccessibilityObjectWrapperMac.mm: (-[WebAccessibilityObjectWrapper accessibilityScrollToVisible]): (-[WebAccessibilityObjectWrapper _accessibilityScrollToMakeVisibleWithSubFocus:]): (-[WebAccessibilityObjectWrapper _accessibilityScrollToGlobalPoint:]): (-[WebAccessibilityObjectWrapper accessibilityPerformAction:]): Tools: Add support for scrollToMakeVisibleWithSubFocus and scrollToGlobalPoint. * DumpRenderTree/AccessibilityUIElement.cpp: (pressCallback): (scrollToMakeVisibleWithSubFocusCallback): (scrollToGlobalPointCallback): (scrollToMakeVisibleCallback): (AccessibilityUIElement::getJSClass): * DumpRenderTree/ios/AccessibilityUIElementIOS.mm: (AccessibilityUIElement::scrollToMakeVisible): (AccessibilityUIElement::scrollToMakeVisibleWithSubFocus): (AccessibilityUIElement::scrollToGlobalPoint): (AccessibilityUIElement::selectedTextRange): * DumpRenderTree/mac/AccessibilityUIElementMac.mm: (AccessibilityUIElement::AccessibilityUIElement): (AccessibilityUIElement::mathPrescriptsDescription): (AccessibilityUIElement::scrollToMakeVisible): (AccessibilityUIElement::scrollToMakeVisibleWithSubFocus): (AccessibilityUIElement::scrollToGlobalPoint): * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp: (WTR::AccessibilityUIElement::isTextMarkerValid): (WTR::AccessibilityUIElement::textMarkerForIndex): (WTR::AccessibilityUIElement::scrollToMakeVisible): (WTR::AccessibilityUIElement::scrollToGlobalPoint): (WTR::AccessibilityUIElement::scrollToMakeVisibleWithSubFocus): (WTR::AccessibilityUIElement::supportedActions): (WTR::AccessibilityUIElement::mathPostscriptsDescription): (WTR::AccessibilityUIElement::mathPrescriptsDescription): * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h: * WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl: * WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm: (WTR::AccessibilityUIElement::scrollToMakeVisible): (WTR::AccessibilityUIElement::scrollToGlobalPoint): (WTR::AccessibilityUIElement::scrollToMakeVisibleWithSubFocus): (WTR::AccessibilityUIElement::selectedTextRange): * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm: (WTR::AccessibilityUIElement::scrollToMakeVisible): (WTR::AccessibilityUIElement::scrollToGlobalPoint): (WTR::AccessibilityUIElement::scrollToMakeVisibleWithSubFocus): (WTR::AccessibilityUIElement::selectedTextRange): LayoutTests: * accessibility/scroll-to-global-point-iframe-expected.txt: Added. * accessibility/scroll-to-global-point-iframe-nested-expected.txt: Added. * accessibility/scroll-to-global-point-iframe-nested.html: Added. * accessibility/scroll-to-global-point-iframe.html: Added. * accessibility/scroll-to-global-point-main-window-expected.txt: Added. * accessibility/scroll-to-global-point-main-window.html: Added. * accessibility/scroll-to-global-point-nested-expected.txt: Added. * accessibility/scroll-to-global-point-nested.html: Added. * accessibility/scroll-to-make-visible-div-overflow-expected.txt: Added. * accessibility/scroll-to-make-visible-div-overflow.html: Added. * accessibility/scroll-to-make-visible-iframe-expected.txt: Added. * accessibility/scroll-to-make-visible-iframe.html: Added. * accessibility/scroll-to-make-visible-nested-2-expected.txt: Added. * accessibility/scroll-to-make-visible-nested-2.html: Added. * accessibility/scroll-to-make-visible-nested-expected.txt: Added. * accessibility/scroll-to-make-visible-nested.html: Added. * accessibility/scroll-to-make-visible-with-subfocus-expected.txt: Added. * accessibility/scroll-to-make-visible-with-subfocus.html: Added. Canonical link: https://commits.webkit.org/166727@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@189149 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-08-29 07:41:46 +00:00
<!DOCTYPE html>
<head>
<script src="../resources/js-test.js"></script>
</head>
<body>
<p id="description"></p>
<div style="border: 1px solid #000; height: 5000px;">5000-pixel box</div>
<iframe id="frame" srcdoc="<body>
<style>button { border: 0; }</style>
<div style='border: 1px solid #000; height: 5000px;'>5000-pixel box</div>
<div id='container' style='height: 100px; overflow: scroll'>
<div style='border: 1px solid #000; height: 5000px;'>5000-pixel box</div>
<button id='target'>Target</button>
<div style='border: 1px solid #000; height: 5000px;'>5000-pixel box</div>
</div>
<div style='border: 1px solid #000; height: 5000px;'>5000-pixel box</div>
</body>"></iframe>
<div style="border: 1px solid #000; height: 5000px;">5000-pixel box</div>
<div id="console"></div>
<script>
description("Tests that scrolling to move an element to a specific point successfully scrolls both an iframe and a div with overflow.");
window.jsTestIsAsync = true;
function runTest() {
window.frame = document.getElementById("frame");
window.frameWindow = frame.contentWindow;
window.frameDoc = frameWindow.document;
window.container = frameDoc.getElementById("container");
window.target = frameDoc.getElementById("target");
var targetAccessibleObject;
if (window.accessibilityController) {
target.focus();
targetAccessibleObject = accessibilityController.focusedElement;
}
// Reset the initial scroll position (since calling focus() can scroll the page too).
window.scrollTo(0, 0);
frameWindow.scrollTo(0, 0);
container.scrollTop = 0;
shouldBeZero("window.pageYOffset");
shouldBeZero("frameWindow.pageYOffset");
shouldBeZero("container.scrollTop");
// Scroll to various locations and check.
if (window.accessibilityController)
targetAccessibleObject.scrollToGlobalPoint(0, 0);
shouldBeZero("target.getBoundingClientRect().top");
if (window.accessibilityController)
targetAccessibleObject.scrollToGlobalPoint(0, 300);
shouldBe("target.getBoundingClientRect().top", "300");
if (window.accessibilityController)
targetAccessibleObject.scrollToGlobalPoint(0, 3000);
shouldBe("target.getBoundingClientRect().top", "3000");
finishJSTest();
}
window.addEventListener("load", function() {
setTimeout(runTest, 0);
}, false);
</script>
</body>
</html>