Bug 1840298: Unify ScrollToPoint for local and remote Accessibles, thus enabling support for RemoteAccessible on Windows. r=eeejay

Differential Revision: https://phabricator.services.mozilla.com/D181952
This commit is contained in:
James Teh 2023-07-04 22:25:33 +00:00
Родитель aac7a0622c
Коммит ad06ac989f
11 изменённых файлов: 64 добавлений и 38 удалений

Просмотреть файл

@ -372,6 +372,12 @@ class Accessible {
MOZ_CAN_RUN_SCRIPT
virtual void ScrollTo(uint32_t aHow) const = 0;
/**
* Scroll the accessible to the given point.
*/
virtual void ScrollToPoint(uint32_t aCoordinateType, int32_t aX,
int32_t aY) = 0;
/**
* Return tag name of associated DOM node.
*/

Просмотреть файл

@ -422,10 +422,8 @@ class LocalAccessible : public nsISupports, public Accessible {
MOZ_CAN_RUN_SCRIPT
virtual void ScrollTo(uint32_t aHow) const override;
/**
* Scroll the accessible to the given point.
*/
void ScrollToPoint(uint32_t aCoordinateType, int32_t aX, int32_t aY);
virtual void ScrollToPoint(uint32_t aCoordinateType, int32_t aX,
int32_t aY) override;
/**
* Get a pointer to accessibility interface for this node, which is specific

Просмотреть файл

@ -331,6 +331,17 @@ ipc::IPCResult DocAccessibleChild::RecvRestoreFocus() {
return IPC_OK();
}
mozilla::ipc::IPCResult DocAccessibleChild::RecvScrollToPoint(
const uint64_t& aID, const uint32_t& aScrollType, const int32_t& aX,
const int32_t& aY) {
LocalAccessible* acc = IdToAccessible(aID);
if (acc) {
acc->ScrollToPoint(aScrollType, aX, aY);
}
return IPC_OK();
}
#if defined(XP_WIN)
LayoutDeviceIntRect DocAccessibleChild::GetCaretRectFor(const uint64_t& aID) {
LocalAccessible* target;
@ -367,17 +378,6 @@ bool DocAccessibleChild::SendCaretMoveEvent(const uint64_t& aID,
}
#else // defined(XP_WIN)
mozilla::ipc::IPCResult DocAccessibleChild::RecvScrollToPoint(
const uint64_t& aID, const uint32_t& aScrollType, const int32_t& aX,
const int32_t& aY) {
LocalAccessible* acc = IdToAccessible(aID);
if (acc) {
acc->ScrollToPoint(aScrollType, aX, aY);
}
return IPC_OK();
}
mozilla::ipc::IPCResult DocAccessibleChild::RecvAnnounce(
const uint64_t& aID, const nsAString& aAnnouncement,
const uint16_t& aPriority) {

Просмотреть файл

@ -125,6 +125,11 @@ class DocAccessibleChild : public PDocAccessibleChild {
virtual mozilla::ipc::IPCResult RecvRestoreFocus() override;
virtual mozilla::ipc::IPCResult RecvScrollToPoint(const uint64_t& aID,
const uint32_t& aScrollType,
const int32_t& aX,
const int32_t& aY) override;
#if defined(XP_WIN)
bool SendCaretMoveEvent(const uint64_t& aID, const int32_t& aOffset,
const bool& aIsSelectionCollapsed,
@ -136,11 +141,6 @@ class DocAccessibleChild : public PDocAccessibleChild {
LayoutDeviceIntRect GetCaretRectFor(const uint64_t& aID);
#else // defined(XP_WIN)
virtual mozilla::ipc::IPCResult RecvScrollToPoint(const uint64_t& aID,
const uint32_t& aScrollType,
const int32_t& aX,
const int32_t& aY) override;
virtual mozilla::ipc::IPCResult RecvAnnounce(
const uint64_t& aID, const nsAString& aAnnouncement,
const uint16_t& aPriority) override;

Просмотреть файл

@ -128,9 +128,9 @@ child:
// LocalAccessible
async ScrollTo(uint64_t aID, uint32_t aScrollType);
#ifndef XP_WIN
async ScrollToPoint(uint64_t aID, uint32_t aScrollType, int32_t aX,
int32_t aY);
#ifndef XP_WIN
async Announce(uint64_t aID, nsString aAnnouncement, uint16_t aPriority);
#endif

Просмотреть файл

@ -1284,12 +1284,12 @@ void RemoteAccessible::DOMNodeID(nsString& aID) const {
}
}
#if !defined(XP_WIN)
void RemoteAccessible::ScrollToPoint(uint32_t aScrollType, int32_t aX,
int32_t aY) {
Unused << mDoc->SendScrollToPoint(mID, aScrollType, aX, aY);
}
#if !defined(XP_WIN)
void RemoteAccessible::Announce(const nsString& aAnnouncement,
uint16_t aPriority) {
Unused << mDoc->SendAnnounce(mID, aAnnouncement, aPriority);

Просмотреть файл

@ -365,9 +365,10 @@ class RemoteAccessible : public Accessible, public HyperTextAccessibleBase {
virtual void DOMNodeID(nsString& aID) const override;
#if !defined(XP_WIN)
void ScrollToPoint(uint32_t aScrollType, int32_t aX, int32_t aY);
virtual void ScrollToPoint(uint32_t aScrollType, int32_t aX,
int32_t aY) override;
#if !defined(XP_WIN)
void Announce(const nsString& aAnnouncement, uint16_t aPriority);
void ScrollSubstringToPoint(int32_t aStartOffset, int32_t aEndOffset,

Просмотреть файл

@ -8,6 +8,7 @@ support-files =
prefs =
javascript.options.asyncstack_capture_debuggee_only=false
[browser_scrollToPoint.js]
[browser_test_zoom_text.js]
skip-if = os == 'win' # bug 1372296
[browser_test_scroll_bounds.js]

Просмотреть файл

@ -0,0 +1,31 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/* import-globals-from ../../mochitest/layout.js */
loadScripts({ name: "layout.js", dir: MOCHITESTS_DIR });
/**
* Test nsIAccessible::scrollToPoint.
*/
addAccessibleTask(
`
<hr style="height: 100vh;">
<p id="p">hi</p>
<hr style="height: 100vh;">
`,
async function (browser, docAcc) {
const [docX, docY] = getPos(docAcc);
const p = findAccessibleChildByID(docAcc, "p");
const [pX] = getPos(p);
info("Scrolling p");
let scrolled = waitForEvent(EVENT_SCROLLING_END, docAcc);
p.scrollToPoint(COORDTYPE_SCREEN_RELATIVE, docX, docY);
await scrolled;
// We can only scroll this vertically.
testPos(p, [pX, docY]);
},
{ chrome: true, topLevel: true, remoteIframe: true }
);

Просмотреть файл

@ -199,12 +199,9 @@ ia2Accessible::scrollTo(enum IA2ScrollType aScrollType) {
STDMETHODIMP
ia2Accessible::scrollToPoint(enum IA2CoordinateType aCoordType, long aX,
long aY) {
if (!Acc()) {
return CO_E_OBJNOTCONNECTED;
}
AccessibleWrap* acc = LocalAcc();
Accessible* acc = Acc();
if (!acc) {
return E_NOTIMPL; // XXX Not supported for RemoteAccessible yet.
return CO_E_OBJNOTCONNECTED;
}
uint32_t geckoCoordType =

Просмотреть файл

@ -655,15 +655,7 @@ NS_IMETHODIMP
xpcAccessible::ScrollToPoint(uint32_t aCoordinateType, int32_t aX, int32_t aY) {
if (!IntlGeneric()) return NS_ERROR_FAILURE;
if (RemoteAccessible* proxy = IntlGeneric()->AsRemote()) {
#if defined(XP_WIN)
return NS_ERROR_NOT_IMPLEMENTED;
#else
proxy->ScrollToPoint(aCoordinateType, aX, aY);
#endif
} else {
Intl()->ScrollToPoint(aCoordinateType, aX, aY);
}
IntlGeneric()->ScrollToPoint(aCoordinateType, aX, aY);
return NS_OK;
}