michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef _nsAccessiblePivot_H_ michael@0: #define _nsAccessiblePivot_H_ michael@0: michael@0: #include "nsIAccessiblePivot.h" michael@0: michael@0: #include "Accessible-inl.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "nsTObserverArray.h" michael@0: #include "nsCycleCollectionParticipant.h" michael@0: #include "mozilla/Attributes.h" michael@0: michael@0: class RuleCache; michael@0: michael@0: /** michael@0: * Class represents an accessible pivot. michael@0: */ michael@0: class nsAccessiblePivot MOZ_FINAL : public nsIAccessiblePivot michael@0: { michael@0: public: michael@0: typedef mozilla::a11y::Accessible Accessible; michael@0: michael@0: nsAccessiblePivot(Accessible* aRoot); michael@0: michael@0: NS_DECL_CYCLE_COLLECTING_ISUPPORTS michael@0: NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsAccessiblePivot, nsIAccessiblePivot) michael@0: michael@0: NS_DECL_NSIACCESSIBLEPIVOT michael@0: michael@0: /* michael@0: * A simple getter for the pivot's position. michael@0: */ michael@0: Accessible* Position() { return mPosition; } michael@0: michael@0: private: michael@0: nsAccessiblePivot() MOZ_DELETE; michael@0: nsAccessiblePivot(const nsAccessiblePivot&) MOZ_DELETE; michael@0: void operator = (const nsAccessiblePivot&) MOZ_DELETE; michael@0: michael@0: /* michael@0: * Notify all observers on a pivot change. Return true if it has changed and michael@0: * observers have been notified. michael@0: */ michael@0: bool NotifyOfPivotChange(Accessible* aOldAccessible, michael@0: int32_t aOldStart, int32_t aOldEnd, michael@0: PivotMoveReason aReason); michael@0: michael@0: /* michael@0: * Check to see that the given accessible is a descendant of given ancestor michael@0: */ michael@0: bool IsDescendantOf(Accessible* aAccessible, Accessible* aAncestor); michael@0: michael@0: michael@0: /* michael@0: * Search in preorder for the first accessible to match the rule. michael@0: */ michael@0: Accessible* SearchForward(Accessible* aAccessible, michael@0: nsIAccessibleTraversalRule* aRule, michael@0: bool aSearchCurrent, michael@0: nsresult* aResult); michael@0: michael@0: /* michael@0: * Reverse search in preorder for the first accessible to match the rule. michael@0: */ michael@0: Accessible* SearchBackward(Accessible* aAccessible, michael@0: nsIAccessibleTraversalRule* aRule, michael@0: bool aSearchCurrent, michael@0: nsresult* aResult); michael@0: michael@0: /* michael@0: * Search in preorder for the first text accessible. michael@0: */ michael@0: mozilla::a11y::HyperTextAccessible* SearchForText(Accessible* aAccessible, michael@0: bool aBackward); michael@0: michael@0: /* michael@0: * Get the effective root for this pivot, either the true root or modal root. michael@0: */ michael@0: Accessible* GetActiveRoot() const michael@0: { michael@0: if (mModalRoot) { michael@0: NS_ENSURE_FALSE(mModalRoot->IsDefunct(), mRoot); michael@0: return mModalRoot; michael@0: } michael@0: michael@0: return mRoot; michael@0: } michael@0: michael@0: /* michael@0: * Update the pivot, and notify observers. Return true if it moved. michael@0: */ michael@0: bool MovePivotInternal(Accessible* aPosition, PivotMoveReason aReason); michael@0: michael@0: /* michael@0: * Get initial node we should start a search from with a given rule. michael@0: * michael@0: * When we do a move operation from one position to another, michael@0: * the initial position can be inside of a subtree that is ignored by michael@0: * the given rule. We need to step out of the ignored subtree and start michael@0: * the search from there. michael@0: * michael@0: */ michael@0: Accessible* AdjustStartPosition(Accessible* aAccessible, RuleCache& aCache, michael@0: uint16_t* aFilterResult, nsresult* aResult); michael@0: michael@0: /* michael@0: * The root accessible. michael@0: */ michael@0: nsRefPtr mRoot; michael@0: michael@0: /* michael@0: * The temporary modal root accessible. michael@0: */ michael@0: nsRefPtr mModalRoot; michael@0: michael@0: /* michael@0: * The current pivot position. michael@0: */ michael@0: nsRefPtr mPosition; michael@0: michael@0: /* michael@0: * The text start offset ofthe pivot. michael@0: */ michael@0: int32_t mStartOffset; michael@0: michael@0: /* michael@0: * The text end offset ofthe pivot. michael@0: */ michael@0: int32_t mEndOffset; michael@0: michael@0: /* michael@0: * The list of pivot-changed observers. michael@0: */ michael@0: nsTObserverArray > mObservers; michael@0: }; michael@0: michael@0: #endif