mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Bug 1930322 part 1: cleanup: Remove aContent argument to LocalAccessible::DoCommand/DispatchClickEvent. r=morgan
We never set this argument to anything other than the default, which meant it always used the LocalAccessible's mContent. This makes the argument unnecessary and potentially confusing in an area which is already a bit difficult to follow, so just remove it. There should be no functional change. Differential Revision: https://phabricator.services.mozilla.com/D229297
This commit is contained in:
parent
fc3d5e493b
commit
75767f504f
@ -2486,52 +2486,45 @@ Relation LocalAccessible::RelationByType(RelationType aType) const {
|
||||
|
||||
void LocalAccessible::GetNativeInterface(void** aNativeAccessible) {}
|
||||
|
||||
void LocalAccessible::DoCommand(nsIContent* aContent,
|
||||
uint32_t aActionIndex) const {
|
||||
void LocalAccessible::DoCommand(uint32_t aActionIndex) const {
|
||||
class Runnable final : public mozilla::Runnable {
|
||||
public:
|
||||
Runnable(const LocalAccessible* aAcc, nsIContent* aContent, uint32_t aIdx)
|
||||
: mozilla::Runnable("Runnable"),
|
||||
mAcc(aAcc),
|
||||
mContent(aContent),
|
||||
mIdx(aIdx) {}
|
||||
Runnable(const LocalAccessible* aAcc, uint32_t aIdx)
|
||||
: mozilla::Runnable("Runnable"), mAcc(aAcc), mIdx(aIdx) {}
|
||||
|
||||
// XXX Cannot mark as MOZ_CAN_RUN_SCRIPT because the base class change
|
||||
// requires too big changes across a lot of modules.
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHOD Run() override {
|
||||
if (mAcc) {
|
||||
MOZ_KnownLive(mAcc)->DispatchClickEvent(MOZ_KnownLive(mContent), mIdx);
|
||||
MOZ_KnownLive(mAcc)->DispatchClickEvent(mIdx);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void Revoke() {
|
||||
mAcc = nullptr;
|
||||
mContent = nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
RefPtr<const LocalAccessible> mAcc;
|
||||
nsCOMPtr<nsIContent> mContent;
|
||||
uint32_t mIdx;
|
||||
};
|
||||
|
||||
nsIContent* content = aContent ? aContent : mContent.get();
|
||||
nsCOMPtr<nsIRunnable> runnable = new Runnable(this, content, aActionIndex);
|
||||
nsCOMPtr<nsIRunnable> runnable = new Runnable(this, aActionIndex);
|
||||
NS_DispatchToMainThread(runnable);
|
||||
}
|
||||
|
||||
void LocalAccessible::DispatchClickEvent(nsIContent* aContent,
|
||||
uint32_t aActionIndex) const {
|
||||
void LocalAccessible::DispatchClickEvent(uint32_t aActionIndex) const {
|
||||
if (IsDefunct()) return;
|
||||
MOZ_ASSERT(mContent);
|
||||
|
||||
RefPtr<PresShell> presShell = mDoc->PresShellPtr();
|
||||
|
||||
// Scroll into view.
|
||||
presShell->ScrollContentIntoView(aContent, ScrollAxis(), ScrollAxis(),
|
||||
presShell->ScrollContentIntoView(mContent, ScrollAxis(), ScrollAxis(),
|
||||
ScrollFlags::ScrollOverflowHidden);
|
||||
|
||||
AutoWeakFrame frame = aContent->GetPrimaryFrame();
|
||||
AutoWeakFrame frame = mContent->GetPrimaryFrame();
|
||||
if (!frame) return;
|
||||
|
||||
// Compute x and y coordinates.
|
||||
@ -2546,18 +2539,18 @@ void LocalAccessible::DispatchClickEvent(nsIContent* aContent,
|
||||
int32_t y = presContext->AppUnitsToDevPixels(point.y + size.height / 2);
|
||||
|
||||
// Simulate a touch interaction by dispatching touch events with mouse events.
|
||||
nsCoreUtils::DispatchTouchEvent(eTouchStart, x, y, aContent, frame, presShell,
|
||||
nsCoreUtils::DispatchTouchEvent(eTouchStart, x, y, mContent, frame, presShell,
|
||||
widget);
|
||||
|
||||
if (StaticPrefs::dom_popup_experimental()) {
|
||||
// This isn't needed once bug 1924790 is fixed.
|
||||
aContent->OwnerDoc()->NotifyUserGestureActivation();
|
||||
mContent->OwnerDoc()->NotifyUserGestureActivation();
|
||||
}
|
||||
nsCoreUtils::DispatchMouseEvent(eMouseDown, x, y, aContent, frame, presShell,
|
||||
nsCoreUtils::DispatchMouseEvent(eMouseDown, x, y, mContent, frame, presShell,
|
||||
widget);
|
||||
nsCoreUtils::DispatchTouchEvent(eTouchEnd, x, y, aContent, frame, presShell,
|
||||
nsCoreUtils::DispatchTouchEvent(eTouchEnd, x, y, mContent, frame, presShell,
|
||||
widget);
|
||||
nsCoreUtils::DispatchMouseEvent(eMouseUp, x, y, aContent, frame, presShell,
|
||||
nsCoreUtils::DispatchMouseEvent(eMouseUp, x, y, mContent, frame, presShell,
|
||||
widget);
|
||||
}
|
||||
|
||||
|
@ -897,18 +897,15 @@ class LocalAccessible : public nsISupports, public Accessible {
|
||||
* invoke action of mozilla accessibles direclty (see bug 277888 for
|
||||
* details).
|
||||
*
|
||||
* @param aContent [in, optional] element to click
|
||||
* @param aActionIndex [in, optional] index of accessible action
|
||||
*/
|
||||
void DoCommand(nsIContent* aContent = nullptr,
|
||||
uint32_t aActionIndex = 0) const;
|
||||
void DoCommand(uint32_t aActionIndex = 0) const;
|
||||
|
||||
/**
|
||||
* Dispatch click event.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual void DispatchClickEvent(nsIContent* aContent,
|
||||
uint32_t aActionIndex) const;
|
||||
virtual void DispatchClickEvent(uint32_t aActionIndex) const;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Helpers
|
||||
|
@ -42,11 +42,10 @@ void XULLabelAccessible::Shutdown() {
|
||||
HyperTextAccessible::Shutdown();
|
||||
}
|
||||
|
||||
void XULLabelAccessible::DispatchClickEvent(nsIContent* aContent,
|
||||
uint32_t aActionIndex) const {
|
||||
void XULLabelAccessible::DispatchClickEvent(uint32_t aActionIndex) const {
|
||||
// Bug 1578140: For labels inside buttons, The base implementation of
|
||||
// DispatchClickEvent doesn't fire a command event on the button.
|
||||
RefPtr<nsXULElement> el = nsXULElement::FromNodeOrNull(aContent);
|
||||
RefPtr<nsXULElement> el = nsXULElement::FromNodeOrNull(mContent);
|
||||
if (el) {
|
||||
el->Click(mozilla::dom::CallerType::System);
|
||||
}
|
||||
|
@ -32,8 +32,7 @@ class XULLabelAccessible : public HyperTextAccessible {
|
||||
protected:
|
||||
// LocalAccessible
|
||||
virtual ENameValueFlag NativeName(nsString& aName) const override;
|
||||
virtual void DispatchClickEvent(nsIContent* aContent,
|
||||
uint32_t aActionIndex) const override;
|
||||
virtual void DispatchClickEvent(uint32_t aActionIndex) const override;
|
||||
|
||||
private:
|
||||
RefPtr<XULLabelTextLeafAccessible> mValueTextLeaf;
|
||||
|
@ -716,7 +716,7 @@ bool XULTreeItemAccessibleBase::DoAction(uint8_t aIndex) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
DoCommand(nullptr, aIndex);
|
||||
DoCommand(aIndex);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -822,7 +822,7 @@ LocalAccessible* XULTreeItemAccessibleBase::ContainerWidget() const {
|
||||
// XULTreeItemAccessibleBase: LocalAccessible protected methods
|
||||
|
||||
void XULTreeItemAccessibleBase::DispatchClickEvent(
|
||||
nsIContent* aContent, uint32_t aActionIndex) const {
|
||||
uint32_t aActionIndex) const {
|
||||
if (IsDefunct()) return;
|
||||
|
||||
RefPtr<nsTreeColumns> columns = mTree->GetColumns();
|
||||
|
@ -186,8 +186,7 @@ class XULTreeItemAccessibleBase : public AccessibleWrap {
|
||||
|
||||
// LocalAccessible
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual void DispatchClickEvent(nsIContent* aContent,
|
||||
uint32_t aActionIndex) const override;
|
||||
virtual void DispatchClickEvent(uint32_t aActionIndex) const override;
|
||||
virtual LocalAccessible* GetSiblingAtOffset(
|
||||
int32_t aOffset, nsresult* aError = nullptr) const override;
|
||||
|
||||
|
@ -636,7 +636,7 @@ LocalAccessible* XULTreeGridCellAccessible::GetSiblingAtOffset(
|
||||
}
|
||||
|
||||
void XULTreeGridCellAccessible::DispatchClickEvent(
|
||||
nsIContent* aContent, uint32_t aActionIndex) const {
|
||||
uint32_t aActionIndex) const {
|
||||
if (IsDefunct()) return;
|
||||
|
||||
RefPtr<dom::XULTreeElement> tree = mTree;
|
||||
|
@ -166,8 +166,7 @@ class XULTreeGridCellAccessible : public LeafAccessible,
|
||||
virtual LocalAccessible* GetSiblingAtOffset(
|
||||
int32_t aOffset, nsresult* aError = nullptr) const override;
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual void DispatchClickEvent(nsIContent* aContent,
|
||||
uint32_t aActionIndex) const override;
|
||||
virtual void DispatchClickEvent(uint32_t aActionIndex) const override;
|
||||
|
||||
// XULTreeGridCellAccessible
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user