1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/src/base/nsAccessiblePivot.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,142 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set ts=2 et sw=2 tw=80: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef _nsAccessiblePivot_H_ 1.11 +#define _nsAccessiblePivot_H_ 1.12 + 1.13 +#include "nsIAccessiblePivot.h" 1.14 + 1.15 +#include "Accessible-inl.h" 1.16 +#include "nsAutoPtr.h" 1.17 +#include "nsTObserverArray.h" 1.18 +#include "nsCycleCollectionParticipant.h" 1.19 +#include "mozilla/Attributes.h" 1.20 + 1.21 +class RuleCache; 1.22 + 1.23 +/** 1.24 + * Class represents an accessible pivot. 1.25 + */ 1.26 +class nsAccessiblePivot MOZ_FINAL : public nsIAccessiblePivot 1.27 +{ 1.28 +public: 1.29 + typedef mozilla::a11y::Accessible Accessible; 1.30 + 1.31 + nsAccessiblePivot(Accessible* aRoot); 1.32 + 1.33 + NS_DECL_CYCLE_COLLECTING_ISUPPORTS 1.34 + NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsAccessiblePivot, nsIAccessiblePivot) 1.35 + 1.36 + NS_DECL_NSIACCESSIBLEPIVOT 1.37 + 1.38 + /* 1.39 + * A simple getter for the pivot's position. 1.40 + */ 1.41 + Accessible* Position() { return mPosition; } 1.42 + 1.43 +private: 1.44 + nsAccessiblePivot() MOZ_DELETE; 1.45 + nsAccessiblePivot(const nsAccessiblePivot&) MOZ_DELETE; 1.46 + void operator = (const nsAccessiblePivot&) MOZ_DELETE; 1.47 + 1.48 + /* 1.49 + * Notify all observers on a pivot change. Return true if it has changed and 1.50 + * observers have been notified. 1.51 + */ 1.52 + bool NotifyOfPivotChange(Accessible* aOldAccessible, 1.53 + int32_t aOldStart, int32_t aOldEnd, 1.54 + PivotMoveReason aReason); 1.55 + 1.56 + /* 1.57 + * Check to see that the given accessible is a descendant of given ancestor 1.58 + */ 1.59 + bool IsDescendantOf(Accessible* aAccessible, Accessible* aAncestor); 1.60 + 1.61 + 1.62 + /* 1.63 + * Search in preorder for the first accessible to match the rule. 1.64 + */ 1.65 + Accessible* SearchForward(Accessible* aAccessible, 1.66 + nsIAccessibleTraversalRule* aRule, 1.67 + bool aSearchCurrent, 1.68 + nsresult* aResult); 1.69 + 1.70 + /* 1.71 + * Reverse search in preorder for the first accessible to match the rule. 1.72 + */ 1.73 + Accessible* SearchBackward(Accessible* aAccessible, 1.74 + nsIAccessibleTraversalRule* aRule, 1.75 + bool aSearchCurrent, 1.76 + nsresult* aResult); 1.77 + 1.78 + /* 1.79 + * Search in preorder for the first text accessible. 1.80 + */ 1.81 + mozilla::a11y::HyperTextAccessible* SearchForText(Accessible* aAccessible, 1.82 + bool aBackward); 1.83 + 1.84 + /* 1.85 + * Get the effective root for this pivot, either the true root or modal root. 1.86 + */ 1.87 + Accessible* GetActiveRoot() const 1.88 + { 1.89 + if (mModalRoot) { 1.90 + NS_ENSURE_FALSE(mModalRoot->IsDefunct(), mRoot); 1.91 + return mModalRoot; 1.92 + } 1.93 + 1.94 + return mRoot; 1.95 + } 1.96 + 1.97 + /* 1.98 + * Update the pivot, and notify observers. Return true if it moved. 1.99 + */ 1.100 + bool MovePivotInternal(Accessible* aPosition, PivotMoveReason aReason); 1.101 + 1.102 + /* 1.103 + * Get initial node we should start a search from with a given rule. 1.104 + * 1.105 + * When we do a move operation from one position to another, 1.106 + * the initial position can be inside of a subtree that is ignored by 1.107 + * the given rule. We need to step out of the ignored subtree and start 1.108 + * the search from there. 1.109 + * 1.110 + */ 1.111 + Accessible* AdjustStartPosition(Accessible* aAccessible, RuleCache& aCache, 1.112 + uint16_t* aFilterResult, nsresult* aResult); 1.113 + 1.114 + /* 1.115 + * The root accessible. 1.116 + */ 1.117 + nsRefPtr<Accessible> mRoot; 1.118 + 1.119 + /* 1.120 + * The temporary modal root accessible. 1.121 + */ 1.122 + nsRefPtr<Accessible> mModalRoot; 1.123 + 1.124 + /* 1.125 + * The current pivot position. 1.126 + */ 1.127 + nsRefPtr<Accessible> mPosition; 1.128 + 1.129 + /* 1.130 + * The text start offset ofthe pivot. 1.131 + */ 1.132 + int32_t mStartOffset; 1.133 + 1.134 + /* 1.135 + * The text end offset ofthe pivot. 1.136 + */ 1.137 + int32_t mEndOffset; 1.138 + 1.139 + /* 1.140 + * The list of pivot-changed observers. 1.141 + */ 1.142 + nsTObserverArray<nsCOMPtr<nsIAccessiblePivotObserver> > mObservers; 1.143 +}; 1.144 + 1.145 +#endif