2012-02-02 10:14:51 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2012-02-02 10:14:51 +04:00
|
|
|
|
|
|
|
#ifndef _nsAccessiblePivot_H_
|
|
|
|
#define _nsAccessiblePivot_H_
|
|
|
|
|
|
|
|
#include "nsIAccessiblePivot.h"
|
|
|
|
|
2013-05-24 22:13:50 +04:00
|
|
|
#include "Accessible-inl.h"
|
2012-02-02 10:14:51 +04:00
|
|
|
#include "nsTObserverArray.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2012-07-19 08:48:45 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2012-02-02 10:14:51 +04:00
|
|
|
|
2013-07-16 01:19:51 +04:00
|
|
|
class RuleCache;
|
2012-02-02 10:14:51 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class represents an accessible pivot.
|
|
|
|
*/
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsAccessiblePivot final : public nsIAccessiblePivot {
|
2012-02-02 10:14:51 +04:00
|
|
|
public:
|
2012-11-18 06:01:44 +04:00
|
|
|
typedef mozilla::a11y::Accessible Accessible;
|
|
|
|
|
2014-09-02 20:19:58 +04:00
|
|
|
explicit nsAccessiblePivot(Accessible* aRoot);
|
2012-02-02 10:14:51 +04:00
|
|
|
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsAccessiblePivot,
|
|
|
|
nsIAccessiblePivot)
|
|
|
|
|
|
|
|
NS_DECL_NSIACCESSIBLEPIVOT
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A simple getter for the pivot's position.
|
|
|
|
*/
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* Position() { return mPosition; }
|
2012-02-02 10:14:51 +04:00
|
|
|
|
2018-06-21 14:47:00 +03:00
|
|
|
int32_t StartOffset() { return mStartOffset; }
|
|
|
|
|
|
|
|
int32_t EndOffset() { return mEndOffset; }
|
|
|
|
|
2012-02-02 10:14:51 +04:00
|
|
|
private:
|
2014-06-23 23:56:09 +04:00
|
|
|
~nsAccessiblePivot();
|
2015-01-07 02:35:02 +03:00
|
|
|
nsAccessiblePivot() = delete;
|
|
|
|
nsAccessiblePivot(const nsAccessiblePivot&) = delete;
|
|
|
|
void operator=(const nsAccessiblePivot&) = delete;
|
2012-02-02 10:14:51 +04:00
|
|
|
|
|
|
|
/*
|
2012-06-19 03:07:56 +04:00
|
|
|
* Notify all observers on a pivot change. Return true if it has changed and
|
|
|
|
* observers have been notified.
|
2012-02-02 10:14:51 +04:00
|
|
|
*/
|
2012-06-19 03:07:56 +04:00
|
|
|
bool NotifyOfPivotChange(Accessible* aOldAccessible, int32_t aOldStart,
|
2014-08-15 05:44:59 +04:00
|
|
|
int32_t aOldEnd, PivotMoveReason aReason,
|
2018-07-16 13:56:00 +03:00
|
|
|
TextBoundaryType aBoundaryType,
|
2014-08-15 05:44:59 +04:00
|
|
|
bool aIsFromUserInput);
|
2012-02-02 10:14:51 +04:00
|
|
|
|
|
|
|
/*
|
2013-05-24 22:13:50 +04:00
|
|
|
* Check to see that the given accessible is a descendant of given ancestor
|
2012-02-02 10:14:51 +04:00
|
|
|
*/
|
2013-05-24 22:13:50 +04:00
|
|
|
bool IsDescendantOf(Accessible* aAccessible, Accessible* aAncestor);
|
2012-02-02 10:14:51 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Search in preorder for the first accessible to match the rule.
|
|
|
|
*/
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* SearchForward(Accessible* aAccessible,
|
|
|
|
nsIAccessibleTraversalRule* aRule,
|
|
|
|
bool aSearchCurrent, nsresult* aResult);
|
2012-02-02 10:14:51 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Reverse search in preorder for the first accessible to match the rule.
|
|
|
|
*/
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* SearchBackward(Accessible* aAccessible,
|
|
|
|
nsIAccessibleTraversalRule* aRule,
|
|
|
|
bool aSearchCurrent, nsresult* aResult);
|
2012-02-02 10:14:51 +04:00
|
|
|
|
2013-05-24 22:13:50 +04:00
|
|
|
/*
|
|
|
|
* Get the effective root for this pivot, either the true root or modal root.
|
|
|
|
*/
|
|
|
|
Accessible* GetActiveRoot() const {
|
|
|
|
if (mModalRoot) {
|
|
|
|
NS_ENSURE_FALSE(mModalRoot->IsDefunct(), mRoot);
|
|
|
|
return mModalRoot;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mRoot;
|
|
|
|
}
|
|
|
|
|
2012-02-02 10:14:51 +04:00
|
|
|
/*
|
2012-06-19 03:07:56 +04:00
|
|
|
* Update the pivot, and notify observers. Return true if it moved.
|
2012-02-02 10:14:51 +04:00
|
|
|
*/
|
2014-08-15 05:44:59 +04:00
|
|
|
bool MovePivotInternal(Accessible* aPosition, PivotMoveReason aReason,
|
|
|
|
bool aIsFromUserInput);
|
2012-02-02 10:14:51 +04:00
|
|
|
|
2013-07-16 01:19:51 +04:00
|
|
|
/*
|
|
|
|
* Get initial node we should start a search from with a given rule.
|
|
|
|
*
|
|
|
|
* When we do a move operation from one position to another,
|
|
|
|
* the initial position can be inside of a subtree that is ignored by
|
|
|
|
* the given rule. We need to step out of the ignored subtree and start
|
|
|
|
* the search from there.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
Accessible* AdjustStartPosition(Accessible* aAccessible, RuleCache& aCache,
|
|
|
|
uint16_t* aFilterResult, nsresult* aResult);
|
|
|
|
|
2012-02-02 10:14:51 +04:00
|
|
|
/*
|
|
|
|
* The root accessible.
|
|
|
|
*/
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Accessible> mRoot;
|
2012-02-02 10:14:51 +04:00
|
|
|
|
2013-05-24 22:13:50 +04:00
|
|
|
/*
|
|
|
|
* The temporary modal root accessible.
|
|
|
|
*/
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Accessible> mModalRoot;
|
2013-05-24 22:13:50 +04:00
|
|
|
|
2012-02-02 10:14:51 +04:00
|
|
|
/*
|
|
|
|
* The current pivot position.
|
|
|
|
*/
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Accessible> mPosition;
|
2012-02-02 10:14:51 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The text start offset ofthe pivot.
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mStartOffset;
|
2012-02-02 10:14:51 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The text end offset ofthe pivot.
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mEndOffset;
|
2012-02-02 10:14:51 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The list of pivot-changed observers.
|
|
|
|
*/
|
|
|
|
nsTObserverArray<nsCOMPtr<nsIAccessiblePivotObserver> > mObservers;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|