accessible/src/base/TreeWalker.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef mozilla_a11y_TreeWalker_h_
     7 #define mozilla_a11y_TreeWalker_h_
     9 #include "mozilla/Attributes.h"
    10 #include <stdint.h>
    12 class nsIContent;
    14 namespace mozilla {
    15 namespace a11y {
    17 class Accessible;
    18 class DocAccessible;
    20 struct WalkState;
    22 /**
    23  * This class is used to walk the DOM tree to create accessible tree.
    24  */
    25 class TreeWalker MOZ_FINAL
    26 {
    27 public:
    28   enum {
    29     // used to walk the existing tree of the given node
    30     eWalkCache = 1,
    31     // used to walk the context tree starting from given node
    32     eWalkContextTree = 2 | eWalkCache
    33   };
    35   /**
    36    * Constructor
    37    *
    38    * @param aContext [in] container accessible for the given node, used to
    39    *                   define accessible context
    40    * @param aNode    [in] the node the search will be prepared relative to
    41    * @param aFlags   [in] flags (see enum above)
    42    */
    43   TreeWalker(Accessible* aContext, nsIContent* aNode, uint32_t aFlags = 0);
    44   ~TreeWalker();
    46   /**
    47    * Return the next child accessible.
    48    *
    49    * @note Returned accessible is bound to the document, if the accessible is
    50    *       rejected during tree creation then the caller should be unbind it
    51    *       from the document.
    52    */
    53   Accessible* NextChild()
    54   {
    55     return NextChildInternal(false);
    56   }
    58 private:
    59   TreeWalker();
    60   TreeWalker(const TreeWalker&);
    61   TreeWalker& operator =(const TreeWalker&);
    63   /**
    64    * Return the next child accessible.
    65    *
    66    * @param  aNoWalkUp  [in] specifies the walk direction, true means we
    67    *                     shouldn't go up through the tree if we failed find
    68    *                     accessible children.
    69    */
    70   Accessible* NextChildInternal(bool aNoWalkUp);
    72   /**
    73    * Create new state for the given node and push it on top of stack.
    74    *
    75    * @note State stack is used to navigate up/down the DOM subtree during
    76    *        accessible children search.
    77    */
    78   void PushState(nsIContent* aNode);
    80   /**
    81    * Pop state from stack.
    82    */
    83   void PopState();
    85   DocAccessible* mDoc;
    86   Accessible* mContext;
    87   int32_t mChildFilter;
    88   uint32_t mFlags;
    89   WalkState* mState;
    90 };
    92 } // namespace a11y
    93 } // namespace mozilla
    95 #endif // mozilla_a11y_TreeWalker_h_

mercurial