Bug 1821956 part 6: Remove event deferral and sync text change events from Windows PDocAccessible. r=nlapre
We only needed to defer events because of the need to wait for a parent COM proxy. Similarly, sync text change events (as opposed to async) were only necessary with the COM proxy architecture. Now that there are no COM proxies, neither of these are necessary. Differential Revision: https://phabricator.services.mozilla.com/D177899
This commit is contained in:
@@ -977,9 +977,6 @@ void NotificationController::WillRefresh(mozilla::TimeStamp aTime) {
|
|||||||
ipcDoc = new DocAccessibleChild(childDoc, parentIPCDoc->Manager());
|
ipcDoc = new DocAccessibleChild(childDoc, parentIPCDoc->Manager());
|
||||||
childDoc->SetIPCDoc(ipcDoc);
|
childDoc->SetIPCDoc(ipcDoc);
|
||||||
|
|
||||||
#if defined(XP_WIN)
|
|
||||||
parentIPCDoc->ConstructChildDocInParentProcess(ipcDoc, id);
|
|
||||||
#else
|
|
||||||
nsCOMPtr<nsIBrowserChild> browserChild =
|
nsCOMPtr<nsIBrowserChild> browserChild =
|
||||||
do_GetInterface(mDocument->DocumentNode()->GetDocShell());
|
do_GetInterface(mDocument->DocumentNode()->GetDocShell());
|
||||||
if (browserChild) {
|
if (browserChild) {
|
||||||
@@ -987,9 +984,10 @@ void NotificationController::WillRefresh(mozilla::TimeStamp aTime) {
|
|||||||
->SendPDocAccessibleConstructor(
|
->SendPDocAccessibleConstructor(
|
||||||
ipcDoc, parentIPCDoc, id,
|
ipcDoc, parentIPCDoc, id,
|
||||||
childDoc->DocumentNode()->GetBrowsingContext());
|
childDoc->DocumentNode()->GetBrowsingContext());
|
||||||
|
#ifndef XP_WIN
|
||||||
ipcDoc->SendPDocAccessiblePlatformExtConstructor();
|
ipcDoc->SendPDocAccessiblePlatformExtConstructor();
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -937,23 +937,9 @@ nsresult LocalAccessible::HandleAccEvent(AccEvent* aEvent) {
|
|||||||
case nsIAccessibleEvent::EVENT_TEXT_REMOVED: {
|
case nsIAccessibleEvent::EVENT_TEXT_REMOVED: {
|
||||||
AccTextChangeEvent* event = downcast_accEvent(aEvent);
|
AccTextChangeEvent* event = downcast_accEvent(aEvent);
|
||||||
const nsString& text = event->ModifiedText();
|
const nsString& text = event->ModifiedText();
|
||||||
#if defined(XP_WIN)
|
ipcDoc->SendTextChangeEvent(
|
||||||
// On Windows with the cache disabled, events for live region updates
|
id, text, event->GetStartOffset(), event->GetLength(),
|
||||||
// containing embedded objects require us to dispatch synchronous
|
event->IsTextInserted(), event->IsFromUserInput());
|
||||||
// events.
|
|
||||||
bool sync = !a11y::IsCacheActive() && text.Contains(L'\xfffc') &&
|
|
||||||
nsAccUtils::IsARIALive(aEvent->GetAccessible());
|
|
||||||
#endif
|
|
||||||
ipcDoc->SendTextChangeEvent(id, text, event->GetStartOffset(),
|
|
||||||
event->GetLength(),
|
|
||||||
event->IsTextInserted(),
|
|
||||||
event->IsFromUserInput()
|
|
||||||
#if defined(XP_WIN)
|
|
||||||
// This parameter only exists on Windows.
|
|
||||||
,
|
|
||||||
sync
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case nsIAccessibleEvent::EVENT_SELECTION:
|
case nsIAccessibleEvent::EVENT_SELECTION:
|
||||||
|
|||||||
@@ -56,11 +56,7 @@ void OuterDocAccessible::SendEmbedderAccessible(
|
|||||||
DocAccessibleChild* ipcDoc = mDoc->IPCDoc();
|
DocAccessibleChild* ipcDoc = mDoc->IPCDoc();
|
||||||
if (ipcDoc) {
|
if (ipcDoc) {
|
||||||
uint64_t id = reinterpret_cast<uintptr_t>(UniqueID());
|
uint64_t id = reinterpret_cast<uintptr_t>(UniqueID());
|
||||||
#if defined(XP_WIN)
|
|
||||||
ipcDoc->SetEmbedderOnBridge(aBridge, id);
|
|
||||||
#else
|
|
||||||
aBridge->SetEmbedderAccessible(ipcDoc, id);
|
aBridge->SetEmbedderAccessible(ipcDoc, id);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,12 +6,9 @@
|
|||||||
|
|
||||||
#include "DocAccessibleChild.h"
|
#include "DocAccessibleChild.h"
|
||||||
|
|
||||||
#include "nsAccessibilityService.h"
|
|
||||||
#include "LocalAccessible-inl.h"
|
#include "LocalAccessible-inl.h"
|
||||||
#include "mozilla/a11y/PlatformChild.h"
|
#include "mozilla/a11y/PlatformChild.h"
|
||||||
#include "mozilla/ClearOnShutdown.h"
|
#include "mozilla/ClearOnShutdown.h"
|
||||||
#include "mozilla/dom/Document.h"
|
|
||||||
#include "RootAccessible.h"
|
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace a11y {
|
namespace a11y {
|
||||||
@@ -27,89 +24,12 @@ DocAccessibleChild::DocAccessibleChild(DocAccessible* aDoc, IProtocol* aManager)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SetManager(aManager);
|
SetManager(aManager);
|
||||||
if (a11y::IsCacheActive()) {
|
|
||||||
// If the cache is enabled, we don't need to care whether this is
|
|
||||||
// constructed in the parent process. We must still set this flag because we
|
|
||||||
// defer sending any events unless it is set.
|
|
||||||
SetConstructedInParentProcess();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DocAccessibleChild::~DocAccessibleChild() {
|
DocAccessibleChild::~DocAccessibleChild() {
|
||||||
MOZ_COUNT_DTOR_INHERITED(DocAccessibleChild, DocAccessibleChildBase);
|
MOZ_COUNT_DTOR_INHERITED(DocAccessibleChild, DocAccessibleChildBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DocAccessibleChild::Shutdown() {
|
|
||||||
if (IsConstructedInParentProcess()) {
|
|
||||||
DocAccessibleChildBase::Shutdown();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PushDeferredEvent(MakeUnique<SerializedShutdown>(this));
|
|
||||||
DetachDocument();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DocAccessibleChild::PushDeferredEvent(UniquePtr<DeferredEvent> aEvent) {
|
|
||||||
DocAccessibleChild* topLevelIPCDoc = nullptr;
|
|
||||||
|
|
||||||
if (mDoc && mDoc->IsRoot()) {
|
|
||||||
topLevelIPCDoc = this;
|
|
||||||
} else {
|
|
||||||
auto browserChild = static_cast<dom::BrowserChild*>(Manager());
|
|
||||||
if (!browserChild) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
topLevelIPCDoc = static_cast<DocAccessibleChild*>(
|
|
||||||
browserChild->GetTopLevelDocAccessibleChild());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (topLevelIPCDoc) {
|
|
||||||
topLevelIPCDoc->mDeferredEvents.AppendElement(std::move(aEvent));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DocAccessibleChild::SendEvent(const uint64_t& aID, const uint32_t& aType) {
|
|
||||||
if (IsConstructedInParentProcess()) {
|
|
||||||
return PDocAccessibleChild::SendEvent(aID, aType);
|
|
||||||
}
|
|
||||||
|
|
||||||
PushDeferredEvent(MakeUnique<SerializedEvent>(this, aID, aType));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DocAccessibleChild::MaybeSendShowEvent(ShowEventData& aData,
|
|
||||||
bool aFromUser) {
|
|
||||||
if (IsConstructedInParentProcess()) {
|
|
||||||
Unused << SendShowEvent(aData, aFromUser);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PushDeferredEvent(MakeUnique<SerializedShow>(this, aData, aFromUser));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DocAccessibleChild::SendHideEvent(const uint64_t& aRootID,
|
|
||||||
const bool& aFromUser) {
|
|
||||||
if (IsConstructedInParentProcess()) {
|
|
||||||
return PDocAccessibleChild::SendHideEvent(aRootID, aFromUser);
|
|
||||||
}
|
|
||||||
|
|
||||||
PushDeferredEvent(MakeUnique<SerializedHide>(this, aRootID, aFromUser));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DocAccessibleChild::SendStateChangeEvent(const uint64_t& aID,
|
|
||||||
const uint64_t& aState,
|
|
||||||
const bool& aEnabled) {
|
|
||||||
if (IsConstructedInParentProcess()) {
|
|
||||||
return PDocAccessibleChild::SendStateChangeEvent(aID, aState, aEnabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
PushDeferredEvent(
|
|
||||||
MakeUnique<SerializedStateChange>(this, aID, aState, aEnabled));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
LayoutDeviceIntRect DocAccessibleChild::GetCaretRectFor(const uint64_t& aID) {
|
LayoutDeviceIntRect DocAccessibleChild::GetCaretRectFor(const uint64_t& aID) {
|
||||||
LocalAccessible* target;
|
LocalAccessible* target;
|
||||||
|
|
||||||
@@ -131,17 +51,7 @@ LayoutDeviceIntRect DocAccessibleChild::GetCaretRectFor(const uint64_t& aID) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DocAccessibleChild::SendFocusEvent(const uint64_t& aID) {
|
bool DocAccessibleChild::SendFocusEvent(const uint64_t& aID) {
|
||||||
return SendFocusEvent(aID, GetCaretRectFor(aID));
|
return PDocAccessibleChild::SendFocusEvent(aID, GetCaretRectFor(aID));
|
||||||
}
|
|
||||||
|
|
||||||
bool DocAccessibleChild::SendFocusEvent(const uint64_t& aID,
|
|
||||||
const LayoutDeviceIntRect& aCaretRect) {
|
|
||||||
if (IsConstructedInParentProcess()) {
|
|
||||||
return PDocAccessibleChild::SendFocusEvent(aID, aCaretRect);
|
|
||||||
}
|
|
||||||
|
|
||||||
PushDeferredEvent(MakeUnique<SerializedFocus>(this, aID, aCaretRect));
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DocAccessibleChild::SendCaretMoveEvent(const uint64_t& aID,
|
bool DocAccessibleChild::SendCaretMoveEvent(const uint64_t& aID,
|
||||||
@@ -149,116 +59,9 @@ bool DocAccessibleChild::SendCaretMoveEvent(const uint64_t& aID,
|
|||||||
const bool& aIsSelectionCollapsed,
|
const bool& aIsSelectionCollapsed,
|
||||||
const bool& aIsAtEndOfLine,
|
const bool& aIsAtEndOfLine,
|
||||||
const int32_t& aGranularity) {
|
const int32_t& aGranularity) {
|
||||||
return SendCaretMoveEvent(aID, GetCaretRectFor(aID), aOffset,
|
return PDocAccessibleChild::SendCaretMoveEvent(aID, GetCaretRectFor(aID),
|
||||||
aIsSelectionCollapsed, aIsAtEndOfLine,
|
aOffset, aIsSelectionCollapsed,
|
||||||
aGranularity);
|
aIsAtEndOfLine, aGranularity);
|
||||||
}
|
|
||||||
|
|
||||||
bool DocAccessibleChild::SendCaretMoveEvent(
|
|
||||||
const uint64_t& aID, const LayoutDeviceIntRect& aCaretRect,
|
|
||||||
const int32_t& aOffset, const bool& aIsSelectionCollapsed,
|
|
||||||
const bool& aIsAtEndOfLine, const int32_t& aGranularity) {
|
|
||||||
if (IsConstructedInParentProcess()) {
|
|
||||||
return PDocAccessibleChild::SendCaretMoveEvent(
|
|
||||||
aID, aCaretRect, aOffset, aIsSelectionCollapsed, aIsAtEndOfLine,
|
|
||||||
aGranularity);
|
|
||||||
}
|
|
||||||
|
|
||||||
PushDeferredEvent(MakeUnique<SerializedCaretMove>(
|
|
||||||
this, aID, aCaretRect, aOffset, aIsSelectionCollapsed, aIsAtEndOfLine,
|
|
||||||
aGranularity));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DocAccessibleChild::SendTextChangeEvent(
|
|
||||||
const uint64_t& aID, const nsString& aStr, const int32_t& aStart,
|
|
||||||
const uint32_t& aLen, const bool& aIsInsert, const bool& aFromUser,
|
|
||||||
const bool aDoSync) {
|
|
||||||
if (IsConstructedInParentProcess()) {
|
|
||||||
if (aDoSync) {
|
|
||||||
// The AT is going to need to reenter content while the event is being
|
|
||||||
// dispatched synchronously.
|
|
||||||
return PDocAccessibleChild::SendSyncTextChangeEvent(
|
|
||||||
aID, aStr, aStart, aLen, aIsInsert, aFromUser);
|
|
||||||
}
|
|
||||||
return PDocAccessibleChild::SendTextChangeEvent(aID, aStr, aStart, aLen,
|
|
||||||
aIsInsert, aFromUser);
|
|
||||||
}
|
|
||||||
|
|
||||||
PushDeferredEvent(MakeUnique<SerializedTextChange>(
|
|
||||||
this, aID, aStr, aStart, aLen, aIsInsert, aFromUser));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DocAccessibleChild::SendSelectionEvent(const uint64_t& aID,
|
|
||||||
const uint64_t& aWidgetID,
|
|
||||||
const uint32_t& aType) {
|
|
||||||
if (IsConstructedInParentProcess()) {
|
|
||||||
return PDocAccessibleChild::SendSelectionEvent(aID, aWidgetID, aType);
|
|
||||||
}
|
|
||||||
|
|
||||||
PushDeferredEvent(
|
|
||||||
MakeUnique<SerializedSelection>(this, aID, aWidgetID, aType));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DocAccessibleChild::SendRoleChangedEvent(const a11y::role& aRole,
|
|
||||||
uint8_t aRoleMapEntryIndex) {
|
|
||||||
if (IsConstructedInParentProcess()) {
|
|
||||||
return PDocAccessibleChild::SendRoleChangedEvent(aRole, aRoleMapEntryIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
PushDeferredEvent(
|
|
||||||
MakeUnique<SerializedRoleChanged>(this, aRole, aRoleMapEntryIndex));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DocAccessibleChild::SendScrollingEvent(const uint64_t& aID,
|
|
||||||
const uint64_t& aType,
|
|
||||||
const uint32_t& aScrollX,
|
|
||||||
const uint32_t& aScrollY,
|
|
||||||
const uint32_t& aMaxScrollX,
|
|
||||||
const uint32_t& aMaxScrollY) {
|
|
||||||
if (IsConstructedInParentProcess()) {
|
|
||||||
return PDocAccessibleChild::SendScrollingEvent(
|
|
||||||
aID, aType, aScrollX, aScrollY, aMaxScrollX, aMaxScrollY);
|
|
||||||
}
|
|
||||||
|
|
||||||
PushDeferredEvent(MakeUnique<SerializedScrolling>(
|
|
||||||
this, aID, aType, aScrollX, aScrollY, aMaxScrollX, aMaxScrollY));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DocAccessibleChild::ConstructChildDocInParentProcess(
|
|
||||||
DocAccessibleChild* aNewChildDoc, uint64_t aUniqueID) {
|
|
||||||
if (IsConstructedInParentProcess()) {
|
|
||||||
// We may send the constructor immediately
|
|
||||||
auto browserChild = static_cast<dom::BrowserChild*>(Manager());
|
|
||||||
MOZ_ASSERT(browserChild);
|
|
||||||
bool result = browserChild->SendPDocAccessibleConstructor(
|
|
||||||
aNewChildDoc, this, aUniqueID,
|
|
||||||
aNewChildDoc->mDoc->DocumentNode()->GetBrowsingContext());
|
|
||||||
if (result) {
|
|
||||||
aNewChildDoc->SetConstructedInParentProcess();
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
PushDeferredEvent(MakeUnique<SerializedChildDocConstructor>(
|
|
||||||
aNewChildDoc, this, aUniqueID,
|
|
||||||
aNewChildDoc->mDoc->DocumentNode()->GetBrowsingContext()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DocAccessibleChild::SendBindChildDoc(
|
|
||||||
NotNull<DocAccessibleChild*> aChildDoc, const uint64_t& aNewParentID) {
|
|
||||||
if (IsConstructedInParentProcess()) {
|
|
||||||
return DocAccessibleChildBase::SendBindChildDoc(aChildDoc, aNewParentID);
|
|
||||||
}
|
|
||||||
|
|
||||||
PushDeferredEvent(
|
|
||||||
MakeUnique<SerializedBindChildDoc>(this, aChildDoc, aNewParentID));
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ipc::IPCResult DocAccessibleChild::RecvRestoreFocus() {
|
ipc::IPCResult DocAccessibleChild::RecvRestoreFocus() {
|
||||||
@@ -268,21 +71,5 @@ ipc::IPCResult DocAccessibleChild::RecvRestoreFocus() {
|
|||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DocAccessibleChild::SetEmbedderOnBridge(dom::BrowserBridgeChild* aBridge,
|
|
||||||
uint64_t aID) {
|
|
||||||
DocAccessibleChild* doc = aID ? this : nullptr;
|
|
||||||
if (IsConstructedInParentProcess()) {
|
|
||||||
MOZ_ASSERT(CanSend());
|
|
||||||
aBridge->SetEmbedderAccessible(doc, aID);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Even though this doesn't fire an event, we must ensure this is sent in
|
|
||||||
// the correct order with insertions/removals, which are deferred until
|
|
||||||
// we are notified about parent process construction. Otherwise, the
|
|
||||||
// parent process might bind a child document to the wrong accessible if
|
|
||||||
// ids get reused.
|
|
||||||
PushDeferredEvent(MakeUnique<SerializedSetEmbedder>(aBridge, doc, aID));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|||||||
@@ -8,8 +8,6 @@
|
|||||||
#define mozilla_a11y_DocAccessibleChild_h
|
#define mozilla_a11y_DocAccessibleChild_h
|
||||||
|
|
||||||
#include "mozilla/a11y/DocAccessibleChildBase.h"
|
#include "mozilla/a11y/DocAccessibleChildBase.h"
|
||||||
#include "mozilla/dom/BrowserBridgeChild.h"
|
|
||||||
#include "mozilla/dom/BrowserChild.h"
|
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace a11y {
|
namespace a11y {
|
||||||
@@ -23,341 +21,16 @@ class DocAccessibleChild : public DocAccessibleChildBase {
|
|||||||
DocAccessibleChild(DocAccessible* aDoc, IProtocol* aManager);
|
DocAccessibleChild(DocAccessible* aDoc, IProtocol* aManager);
|
||||||
~DocAccessibleChild();
|
~DocAccessibleChild();
|
||||||
|
|
||||||
virtual void Shutdown() override;
|
|
||||||
|
|
||||||
virtual ipc::IPCResult RecvRestoreFocus() override;
|
virtual ipc::IPCResult RecvRestoreFocus() override;
|
||||||
|
|
||||||
bool SendEvent(const uint64_t& aID, const uint32_t& type);
|
|
||||||
bool SendHideEvent(const uint64_t& aRootID, const bool& aFromUser);
|
|
||||||
bool SendStateChangeEvent(const uint64_t& aID, const uint64_t& aState,
|
|
||||||
const bool& aEnabled);
|
|
||||||
bool SendCaretMoveEvent(const uint64_t& aID, const int32_t& aOffset,
|
bool SendCaretMoveEvent(const uint64_t& aID, const int32_t& aOffset,
|
||||||
const bool& aIsSelectionCollapsed,
|
const bool& aIsSelectionCollapsed,
|
||||||
const bool& aIsAtEndOfLine,
|
const bool& aIsAtEndOfLine,
|
||||||
const int32_t& aGranularity);
|
const int32_t& aGranularity);
|
||||||
bool SendCaretMoveEvent(const uint64_t& aID,
|
|
||||||
const LayoutDeviceIntRect& aCaretRect,
|
|
||||||
const int32_t& aOffset,
|
|
||||||
const bool& aIsSelectionCollapsed,
|
|
||||||
const bool& aIsAtEndOfLine,
|
|
||||||
const int32_t& aGranularity);
|
|
||||||
bool SendFocusEvent(const uint64_t& aID);
|
bool SendFocusEvent(const uint64_t& aID);
|
||||||
bool SendFocusEvent(const uint64_t& aID,
|
|
||||||
const LayoutDeviceIntRect& aCaretRect);
|
|
||||||
bool SendTextChangeEvent(const uint64_t& aID, const nsString& aStr,
|
|
||||||
const int32_t& aStart, const uint32_t& aLen,
|
|
||||||
const bool& aIsInsert, const bool& aFromUser,
|
|
||||||
const bool aDoSync = false);
|
|
||||||
bool SendSelectionEvent(const uint64_t& aID, const uint64_t& aWidgetID,
|
|
||||||
const uint32_t& aType);
|
|
||||||
bool SendRoleChangedEvent(const a11y::role& aRole,
|
|
||||||
uint8_t aRoleMapEntryIndex);
|
|
||||||
bool SendScrollingEvent(const uint64_t& aID, const uint64_t& aType,
|
|
||||||
const uint32_t& aScrollX, const uint32_t& aScrollY,
|
|
||||||
const uint32_t& aMaxScrollX,
|
|
||||||
const uint32_t& aMaxScrollY);
|
|
||||||
|
|
||||||
bool ConstructChildDocInParentProcess(DocAccessibleChild* aNewChildDoc,
|
|
||||||
uint64_t aUniqueID);
|
|
||||||
|
|
||||||
bool SendBindChildDoc(NotNull<DocAccessibleChild*> aChildDoc,
|
|
||||||
const uint64_t& aNewParentID);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the embedder accessible on a BrowserBridgeChild to an accessible in
|
|
||||||
* this document.
|
|
||||||
* Sending this will be deferred if this DocAccessibleChild hasn't been
|
|
||||||
* constructed in the parent process yet.
|
|
||||||
*/
|
|
||||||
void SetEmbedderOnBridge(dom::BrowserBridgeChild* aBridge, uint64_t aID);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void MaybeSendShowEvent(ShowEventData& aData,
|
|
||||||
bool aFromUser) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void RemoveDeferredConstructor();
|
|
||||||
|
|
||||||
LayoutDeviceIntRect GetCaretRectFor(const uint64_t& aID);
|
LayoutDeviceIntRect GetCaretRectFor(const uint64_t& aID);
|
||||||
|
|
||||||
/**
|
|
||||||
* DocAccessibleChild should not fire events until it has asynchronously
|
|
||||||
* received the COM proxy for its parent. OTOH, content a11y may still be
|
|
||||||
* attempting to fire events during this window of time. If this object does
|
|
||||||
* not yet have its parent proxy, instead of immediately sending the events to
|
|
||||||
* our parent, we enqueue them to mDeferredEvents. As soon as
|
|
||||||
* RecvParentCOMProxy is called, we play back mDeferredEvents.
|
|
||||||
*/
|
|
||||||
struct DeferredEvent {
|
|
||||||
void Dispatch() { Dispatch(mTarget); }
|
|
||||||
|
|
||||||
virtual ~DeferredEvent() {}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
explicit DeferredEvent(DocAccessibleChild* aTarget) : mTarget(aTarget) {}
|
|
||||||
|
|
||||||
virtual void Dispatch(DocAccessibleChild* aIPCDoc) = 0;
|
|
||||||
|
|
||||||
private:
|
|
||||||
DocAccessibleChild* mTarget;
|
|
||||||
};
|
|
||||||
|
|
||||||
void PushDeferredEvent(UniquePtr<DeferredEvent> aEvent);
|
|
||||||
|
|
||||||
struct SerializedShow final : public DeferredEvent {
|
|
||||||
SerializedShow(DocAccessibleChild* aTarget, ShowEventData& aEventData,
|
|
||||||
bool aFromUser)
|
|
||||||
: DeferredEvent(aTarget),
|
|
||||||
mEventData(aEventData.ID(), aEventData.Idx(),
|
|
||||||
nsTArray<AccessibleData>(), aEventData.EventSuppressed()),
|
|
||||||
mFromUser(aFromUser) {
|
|
||||||
// Since IPDL doesn't generate a move constructor for ShowEventData,
|
|
||||||
// we move NewTree manually (ugh). We still construct with an empty
|
|
||||||
// NewTree above so that the compiler catches any changes made to the
|
|
||||||
// ShowEventData structure in IPDL.
|
|
||||||
mEventData.NewTree() = std::move(aEventData.NewTree());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dispatch(DocAccessibleChild* aIPCDoc) override {
|
|
||||||
Unused << aIPCDoc->SendShowEvent(mEventData, mFromUser);
|
|
||||||
}
|
|
||||||
|
|
||||||
ShowEventData mEventData;
|
|
||||||
bool mFromUser;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SerializedHide final : public DeferredEvent {
|
|
||||||
SerializedHide(DocAccessibleChild* aTarget, uint64_t aRootID,
|
|
||||||
bool aFromUser)
|
|
||||||
: DeferredEvent(aTarget), mRootID(aRootID), mFromUser(aFromUser) {}
|
|
||||||
|
|
||||||
void Dispatch(DocAccessibleChild* aIPCDoc) override {
|
|
||||||
Unused << aIPCDoc->SendHideEvent(mRootID, mFromUser);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t mRootID;
|
|
||||||
bool mFromUser;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SerializedStateChange final : public DeferredEvent {
|
|
||||||
SerializedStateChange(DocAccessibleChild* aTarget, uint64_t aID,
|
|
||||||
uint64_t aState, bool aEnabled)
|
|
||||||
: DeferredEvent(aTarget),
|
|
||||||
mID(aID),
|
|
||||||
mState(aState),
|
|
||||||
mEnabled(aEnabled) {}
|
|
||||||
|
|
||||||
void Dispatch(DocAccessibleChild* aIPCDoc) override {
|
|
||||||
Unused << aIPCDoc->SendStateChangeEvent(mID, mState, mEnabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t mID;
|
|
||||||
uint64_t mState;
|
|
||||||
bool mEnabled;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SerializedCaretMove final : public DeferredEvent {
|
|
||||||
SerializedCaretMove(DocAccessibleChild* aTarget, uint64_t aID,
|
|
||||||
const LayoutDeviceIntRect& aCaretRect, int32_t aOffset,
|
|
||||||
bool aIsSelectionCollapsed, bool aIsAtEndOfLine,
|
|
||||||
int32_t aGranularity)
|
|
||||||
: DeferredEvent(aTarget),
|
|
||||||
mID(aID),
|
|
||||||
mCaretRect(aCaretRect),
|
|
||||||
mOffset(aOffset),
|
|
||||||
mIsSelectionCollapsed(aIsSelectionCollapsed),
|
|
||||||
mIsAtEndOfLine(aIsAtEndOfLine),
|
|
||||||
mGranularity(aGranularity) {}
|
|
||||||
|
|
||||||
void Dispatch(DocAccessibleChild* aIPCDoc) override {
|
|
||||||
Unused << aIPCDoc->SendCaretMoveEvent(mID, mCaretRect, mOffset,
|
|
||||||
mIsSelectionCollapsed,
|
|
||||||
mIsAtEndOfLine, mGranularity);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t mID;
|
|
||||||
LayoutDeviceIntRect mCaretRect;
|
|
||||||
int32_t mOffset;
|
|
||||||
bool mIsSelectionCollapsed;
|
|
||||||
bool mIsAtEndOfLine;
|
|
||||||
int32_t mGranularity;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SerializedFocus final : public DeferredEvent {
|
|
||||||
SerializedFocus(DocAccessibleChild* aTarget, uint64_t aID,
|
|
||||||
const LayoutDeviceIntRect& aCaretRect)
|
|
||||||
: DeferredEvent(aTarget), mID(aID), mCaretRect(aCaretRect) {}
|
|
||||||
|
|
||||||
void Dispatch(DocAccessibleChild* aIPCDoc) override {
|
|
||||||
Unused << aIPCDoc->SendFocusEvent(mID, mCaretRect);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t mID;
|
|
||||||
LayoutDeviceIntRect mCaretRect;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SerializedTextChange final : public DeferredEvent {
|
|
||||||
SerializedTextChange(DocAccessibleChild* aTarget, uint64_t aID,
|
|
||||||
const nsString& aStr, int32_t aStart, uint32_t aLen,
|
|
||||||
bool aIsInsert, bool aFromUser)
|
|
||||||
: DeferredEvent(aTarget),
|
|
||||||
mID(aID),
|
|
||||||
mStr(aStr),
|
|
||||||
mStart(aStart),
|
|
||||||
mLen(aLen),
|
|
||||||
mIsInsert(aIsInsert),
|
|
||||||
mFromUser(aFromUser) {}
|
|
||||||
|
|
||||||
void Dispatch(DocAccessibleChild* aIPCDoc) override {
|
|
||||||
Unused << aIPCDoc->SendTextChangeEvent(mID, mStr, mStart, mLen, mIsInsert,
|
|
||||||
mFromUser, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t mID;
|
|
||||||
nsString mStr;
|
|
||||||
int32_t mStart;
|
|
||||||
uint32_t mLen;
|
|
||||||
bool mIsInsert;
|
|
||||||
bool mFromUser;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SerializedSelection final : public DeferredEvent {
|
|
||||||
SerializedSelection(DocAccessibleChild* aTarget, uint64_t aID,
|
|
||||||
uint64_t aWidgetID, uint32_t aType)
|
|
||||||
: DeferredEvent(aTarget),
|
|
||||||
mID(aID),
|
|
||||||
mWidgetID(aWidgetID),
|
|
||||||
mType(aType) {}
|
|
||||||
|
|
||||||
void Dispatch(DocAccessibleChild* aIPCDoc) override {
|
|
||||||
Unused << aIPCDoc->SendSelectionEvent(mID, mWidgetID, mType);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t mID;
|
|
||||||
uint64_t mWidgetID;
|
|
||||||
uint32_t mType;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SerializedRoleChanged final : public DeferredEvent {
|
|
||||||
explicit SerializedRoleChanged(DocAccessibleChild* aTarget,
|
|
||||||
a11y::role aRole, uint8_t aRoleMapEntryIndex)
|
|
||||||
: DeferredEvent(aTarget),
|
|
||||||
mRole(aRole),
|
|
||||||
mRoleMapEntryIndex(aRoleMapEntryIndex) {}
|
|
||||||
|
|
||||||
void Dispatch(DocAccessibleChild* aIPCDoc) override {
|
|
||||||
Unused << aIPCDoc->SendRoleChangedEvent(mRole, mRoleMapEntryIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
a11y::role mRole;
|
|
||||||
uint8_t mRoleMapEntryIndex;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SerializedScrolling final : public DeferredEvent {
|
|
||||||
explicit SerializedScrolling(DocAccessibleChild* aTarget, uint64_t aID,
|
|
||||||
uint64_t aType, uint32_t aScrollX,
|
|
||||||
uint32_t aScrollY, uint32_t aMaxScrollX,
|
|
||||||
uint32_t aMaxScrollY)
|
|
||||||
: DeferredEvent(aTarget),
|
|
||||||
mID(aID),
|
|
||||||
mType(aType),
|
|
||||||
mScrollX(aScrollX),
|
|
||||||
mScrollY(aScrollY),
|
|
||||||
mMaxScrollX(aMaxScrollX),
|
|
||||||
mMaxScrollY(aMaxScrollY) {}
|
|
||||||
|
|
||||||
void Dispatch(DocAccessibleChild* aIPCDoc) override {
|
|
||||||
Unused << aIPCDoc->SendScrollingEvent(mID, mType, mScrollX, mScrollY,
|
|
||||||
mMaxScrollX, mMaxScrollY);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t mID;
|
|
||||||
uint64_t mType;
|
|
||||||
uint32_t mScrollX;
|
|
||||||
uint32_t mScrollY;
|
|
||||||
uint32_t mMaxScrollX;
|
|
||||||
uint32_t mMaxScrollY;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SerializedEvent final : public DeferredEvent {
|
|
||||||
SerializedEvent(DocAccessibleChild* aTarget, uint64_t aID, uint32_t aType)
|
|
||||||
: DeferredEvent(aTarget), mID(aID), mType(aType) {}
|
|
||||||
|
|
||||||
void Dispatch(DocAccessibleChild* aIPCDoc) override {
|
|
||||||
Unused << aIPCDoc->SendEvent(mID, mType);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t mID;
|
|
||||||
uint32_t mType;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SerializedChildDocConstructor final : public DeferredEvent {
|
|
||||||
SerializedChildDocConstructor(DocAccessibleChild* aIPCDoc,
|
|
||||||
DocAccessibleChild* aParentIPCDoc,
|
|
||||||
uint64_t aUniqueID,
|
|
||||||
dom::BrowsingContext* aBrowsingContext)
|
|
||||||
: DeferredEvent(aParentIPCDoc),
|
|
||||||
mIPCDoc(aIPCDoc),
|
|
||||||
mUniqueID(aUniqueID),
|
|
||||||
mBrowsingContext(aBrowsingContext) {}
|
|
||||||
|
|
||||||
void Dispatch(DocAccessibleChild* aParentIPCDoc) override {
|
|
||||||
auto browserChild =
|
|
||||||
static_cast<dom::BrowserChild*>(aParentIPCDoc->Manager());
|
|
||||||
MOZ_ASSERT(browserChild);
|
|
||||||
Unused << browserChild->SendPDocAccessibleConstructor(
|
|
||||||
mIPCDoc, aParentIPCDoc, mUniqueID, mBrowsingContext);
|
|
||||||
mIPCDoc->SetConstructedInParentProcess();
|
|
||||||
}
|
|
||||||
|
|
||||||
DocAccessibleChild* mIPCDoc;
|
|
||||||
uint64_t mUniqueID;
|
|
||||||
// By the time we replay this, the document and its BrowsingContext might
|
|
||||||
// be dead, so we use MaybeDiscardedBrowsingContext here. Ideally, we just
|
|
||||||
// wouldn't replay this, but this is tricky because IPDL should manage the
|
|
||||||
// lifetime of DocAccessibleChild, which means we must send the constructor.
|
|
||||||
dom::MaybeDiscardedBrowsingContext mBrowsingContext;
|
|
||||||
};
|
|
||||||
|
|
||||||
friend struct SerializedChildDocConstructor;
|
|
||||||
|
|
||||||
struct SerializedBindChildDoc final : public DeferredEvent {
|
|
||||||
SerializedBindChildDoc(DocAccessibleChild* aParentDoc,
|
|
||||||
NotNull<DocAccessibleChild*> aChildDoc,
|
|
||||||
uint64_t aNewParentID)
|
|
||||||
: DeferredEvent(aParentDoc),
|
|
||||||
mChildDoc(aChildDoc),
|
|
||||||
mNewParentID(aNewParentID) {}
|
|
||||||
|
|
||||||
void Dispatch(DocAccessibleChild* aParentIPCDoc) override {
|
|
||||||
Unused << aParentIPCDoc->SendBindChildDoc(mChildDoc, mNewParentID);
|
|
||||||
}
|
|
||||||
|
|
||||||
NotNull<DocAccessibleChild*> mChildDoc;
|
|
||||||
uint64_t mNewParentID;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SerializedShutdown final : public DeferredEvent {
|
|
||||||
explicit SerializedShutdown(DocAccessibleChild* aTarget)
|
|
||||||
: DeferredEvent(aTarget) {}
|
|
||||||
|
|
||||||
void Dispatch(DocAccessibleChild* aIPCDoc) override { aIPCDoc->Shutdown(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SerializedSetEmbedder final : public DeferredEvent {
|
|
||||||
SerializedSetEmbedder(dom::BrowserBridgeChild* aBridge,
|
|
||||||
DocAccessibleChild* aDoc, uint64_t aID)
|
|
||||||
: DeferredEvent(aDoc), mBridge(aBridge), mID(aID) {}
|
|
||||||
|
|
||||||
void Dispatch(DocAccessibleChild* aDoc) override {
|
|
||||||
mBridge->SetEmbedderAccessible(aDoc, mID);
|
|
||||||
}
|
|
||||||
|
|
||||||
RefPtr<dom::BrowserBridgeChild> mBridge;
|
|
||||||
uint64_t mID;
|
|
||||||
};
|
|
||||||
|
|
||||||
nsTArray<UniquePtr<DeferredEvent>> mDeferredEvents;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "Compatibility.h"
|
#include "Compatibility.h"
|
||||||
#include "mozilla/PresShell.h"
|
#include "mozilla/PresShell.h"
|
||||||
|
#include "mozilla/dom/BrowsingContext.h"
|
||||||
#include "mozilla/dom/Document.h"
|
#include "mozilla/dom/Document.h"
|
||||||
#include "DocAccessibleChild.h"
|
#include "DocAccessibleChild.h"
|
||||||
#include "nsWinUtils.h"
|
#include "nsWinUtils.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user