tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nsTreeBodyFrame.h (23449B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef nsTreeBodyFrame_h
      8 #define nsTreeBodyFrame_h
      9 
     10 #include "SimpleXULLeafFrame.h"
     11 #include "imgINotificationObserver.h"
     12 #include "imgIRequest.h"
     13 #include "mozilla/AtomArray.h"
     14 #include "mozilla/Attributes.h"
     15 #include "mozilla/LookAndFeel.h"
     16 #include "nsIReflowCallback.h"
     17 #include "nsIScrollbarMediator.h"
     18 #include "nsITimer.h"
     19 #include "nsITreeView.h"
     20 #include "nsScrollbarFrame.h"
     21 #include "nsTArray.h"
     22 #include "nsTHashMap.h"
     23 #include "nsTHashSet.h"
     24 #include "nsThreadUtils.h"
     25 #include "nsTreeColumns.h"
     26 #include "nsTreeStyleCache.h"
     27 
     28 class nsFontMetrics;
     29 class nsOverflowChecker;
     30 class nsTreeImageListener;
     31 
     32 namespace mozilla {
     33 class PresShell;
     34 class ScrollContainerFrame;
     35 namespace layout {
     36 class ScrollbarActivity;
     37 }  // namespace layout
     38 }  // namespace mozilla
     39 
     40 // An entry in the tree's image cache
     41 struct nsTreeImageCacheEntry {
     42  nsTreeImageCacheEntry();
     43  nsTreeImageCacheEntry(imgIRequest* aRequest, nsTreeImageListener* aListener);
     44  ~nsTreeImageCacheEntry();
     45 
     46  nsCOMPtr<imgIRequest> request;
     47  RefPtr<nsTreeImageListener> listener;
     48 };
     49 
     50 // The actual frame that paints the cells and rows.
     51 class nsTreeBodyFrame final : public mozilla::SimpleXULLeafFrame,
     52                              public nsIScrollbarMediator,
     53                              public nsIReflowCallback {
     54  typedef mozilla::layout::ScrollbarActivity ScrollbarActivity;
     55  typedef mozilla::image::ImgDrawResult ImgDrawResult;
     56 
     57 public:
     58  explicit nsTreeBodyFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
     59  ~nsTreeBodyFrame();
     60 
     61  mozilla::IntrinsicSize GetIntrinsicSize() override;
     62 
     63  NS_DECL_QUERYFRAME
     64  NS_DECL_FRAMEARENA_HELPERS(nsTreeBodyFrame)
     65 
     66  // Callback handler methods for refresh driver based animations.
     67  // Calls to these functions are forwarded from nsTreeImageListener. These
     68  // mirror how nsImageFrame works.
     69  void OnImageIsAnimated(imgIRequest* aRequest);
     70 
     71  // non-virtual signatures like nsITreeBodyFrame
     72  already_AddRefed<nsTreeColumns> Columns() const {
     73    RefPtr<nsTreeColumns> cols = mColumns;
     74    return cols.forget();
     75  }
     76  already_AddRefed<nsITreeView> GetExistingView() const {
     77    nsCOMPtr<nsITreeView> view = mView;
     78    return view.forget();
     79  }
     80  already_AddRefed<nsITreeSelection> GetSelection() const;
     81  nsresult GetView(nsITreeView** aView);
     82  nsresult SetView(nsITreeView* aView);
     83  bool GetFocused() const { return mFocused; }
     84  nsresult SetFocused(bool aFocused);
     85  nsresult GetTreeBody(mozilla::dom::Element** aElement);
     86  int32_t RowHeight() const;
     87  int32_t RowWidth();
     88  mozilla::Maybe<mozilla::CSSIntRegion> GetSelectionRegion();
     89  int32_t FirstVisibleRow() const { return mTopRowIndex; }
     90  int32_t LastVisibleRow() const { return mTopRowIndex + mPageLength; }
     91  int32_t PageLength() const { return mPageLength; }
     92  nsresult EnsureRowIsVisible(int32_t aRow);
     93  nsresult EnsureCellIsVisible(int32_t aRow, nsTreeColumn* aCol);
     94  void ScrollToRow(int32_t aRow);
     95  void ScrollByLines(int32_t aNumLines);
     96  void ScrollByPages(int32_t aNumPages);
     97  nsresult Invalidate();
     98  nsresult InvalidateColumn(nsTreeColumn* aCol);
     99  nsresult InvalidateRow(int32_t aRow);
    100  nsresult InvalidateCell(int32_t aRow, nsTreeColumn* aCol);
    101  nsresult InvalidateRange(int32_t aStart, int32_t aEnd);
    102  int32_t GetRowAt(int32_t aX, int32_t aY);
    103  nsresult GetCellAt(int32_t aX, int32_t aY, int32_t* aRow, nsTreeColumn** aCol,
    104                     nsACString& aChildElt);
    105  nsresult GetCoordsForCellItem(int32_t aRow, nsTreeColumn* aCol,
    106                                const nsACString& aElt, int32_t* aX,
    107                                int32_t* aY, int32_t* aWidth, int32_t* aHeight);
    108  nsresult IsCellCropped(int32_t aRow, nsTreeColumn* aCol, bool* aResult);
    109  nsresult RowCountChanged(int32_t aIndex, int32_t aCount);
    110  nsresult BeginUpdateBatch();
    111  nsresult EndUpdateBatch();
    112  nsresult ClearStyleAndImageCaches();
    113  void RemoveImageCacheEntry(int32_t aRowIndex, nsTreeColumn* aCol);
    114 
    115  void CancelImageRequests();
    116 
    117  void ManageReflowCallback();
    118 
    119  void DidReflow(nsPresContext*, const ReflowInput*) override;
    120 
    121  // nsIReflowCallback
    122  bool ReflowFinished() override;
    123  void ReflowCallbackCanceled() override;
    124 
    125  // nsIScrollbarMediator
    126  void ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection,
    127                    mozilla::ScrollSnapFlags aSnapFlags =
    128                        mozilla::ScrollSnapFlags::Disabled) override;
    129  void ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection,
    130                     mozilla::ScrollSnapFlags aSnapFlags =
    131                         mozilla::ScrollSnapFlags::Disabled) override;
    132  void ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection,
    133                    mozilla::ScrollSnapFlags aSnapFlags =
    134                        mozilla::ScrollSnapFlags::Disabled) override;
    135  void ScrollByUnit(nsScrollbarFrame* aScrollbar, mozilla::ScrollMode aMode,
    136                    int32_t aDirection, mozilla::ScrollUnit aUnit,
    137                    mozilla::ScrollSnapFlags aSnapFlags =
    138                        mozilla::ScrollSnapFlags::Disabled) override;
    139  void RepeatButtonScroll(nsScrollbarFrame* aScrollbar) override;
    140  void ThumbMoved(nsScrollbarFrame* aScrollbar, nscoord aOldPos,
    141                  nscoord aNewPos) override;
    142  void ScrollbarReleased(nsScrollbarFrame* aScrollbar) override {}
    143  void VisibilityChanged(bool aVisible) override { Invalidate(); }
    144  nsScrollbarFrame* GetScrollbarBox(bool aVertical) override {
    145    ScrollParts parts = GetScrollParts();
    146    return aVertical ? parts.mVScrollbar : nullptr;
    147  }
    148  void ScrollbarActivityStarted() const override;
    149  void ScrollbarActivityStopped() const override;
    150  bool IsScrollbarOnRight() const override {
    151    return StyleVisibility()->mDirection == mozilla::StyleDirection::Ltr;
    152  }
    153  bool ShouldSuppressScrollbarRepaints() const override { return false; }
    154 
    155  // Overridden from nsIFrame to cache our pres context.
    156  void Init(nsIContent* aContent, nsContainerFrame* aParent,
    157            nsIFrame* aPrevInFlow) override;
    158  void Destroy(DestroyContext&) override;
    159 
    160  Cursor GetCursor(const nsPoint&) override;
    161 
    162  nsresult HandleEvent(nsPresContext* aPresContext,
    163                       mozilla::WidgetGUIEvent* aEvent,
    164                       nsEventStatus* aEventStatus) override;
    165 
    166  void BuildDisplayList(nsDisplayListBuilder* aBuilder,
    167                        const nsDisplayListSet& aLists) override;
    168 
    169  void DidSetComputedStyle(ComputedStyle* aOldComputedStyle) override;
    170 
    171  friend nsIFrame* NS_NewTreeBodyFrame(mozilla::PresShell* aPresShell);
    172  friend class nsTreeColumn;
    173 
    174  struct ScrollParts {
    175    nsScrollbarFrame* mVScrollbar = nullptr;
    176    RefPtr<mozilla::dom::Element> mVScrollbarContent;
    177  };
    178 
    179  ImgDrawResult PaintTreeBody(gfxContext& aRenderingContext,
    180                              const nsRect& aDirtyRect, nsPoint aPt,
    181                              nsDisplayListBuilder* aBuilder);
    182 
    183  // Get the base element, <tree>
    184  mozilla::dom::XULTreeElement* GetBaseElement();
    185 
    186  bool GetVerticalOverflow() const { return mVerticalOverflow; }
    187 
    188  // This returns the property array where atoms are stored for style during
    189  // draw, whether the row currently being drawn is selected, hovered, etc.
    190  const mozilla::AtomArray& GetPropertyArrayForCurrentDrawingItem() {
    191    return mScratchArray;
    192  }
    193 
    194 protected:
    195  friend class nsOverflowChecker;
    196 
    197  // This method paints a specific column background of the tree.
    198  ImgDrawResult PaintColumn(nsTreeColumn* aColumn, const nsRect& aColumnRect,
    199                            nsPresContext* aPresContext,
    200                            gfxContext& aRenderingContext,
    201                            const nsRect& aDirtyRect);
    202 
    203  // This method paints a single row in the tree.
    204  ImgDrawResult PaintRow(int32_t aRowIndex, const nsRect& aRowRect,
    205                         nsPresContext* aPresContext,
    206                         gfxContext& aRenderingContext,
    207                         const nsRect& aDirtyRect, nsPoint aPt,
    208                         nsDisplayListBuilder* aBuilder);
    209 
    210  // This method paints a single separator in the tree.
    211  ImgDrawResult PaintSeparator(int32_t aRowIndex, const nsRect& aSeparatorRect,
    212                               nsPresContext* aPresContext,
    213                               gfxContext& aRenderingContext,
    214                               const nsRect& aDirtyRect);
    215 
    216  // This method paints a specific cell in a given row of the tree.
    217  ImgDrawResult PaintCell(int32_t aRowIndex, nsTreeColumn* aColumn,
    218                          const nsRect& aCellRect, nsPresContext* aPresContext,
    219                          gfxContext& aRenderingContext,
    220                          const nsRect& aDirtyRect, nscoord& aCurrX,
    221                          nsPoint aPt, nsDisplayListBuilder* aBuilder);
    222 
    223  // This method paints the twisty inside a cell in the primary column of an
    224  // tree.
    225  ImgDrawResult PaintTwisty(int32_t aRowIndex, nsTreeColumn* aColumn,
    226                            const nsRect& aTwistyRect,
    227                            nsPresContext* aPresContext,
    228                            gfxContext& aRenderingContext,
    229                            const nsRect& aDirtyRect, nscoord& aRemainingWidth,
    230                            nscoord& aCurrX);
    231 
    232  // This method paints the image inside the cell of an tree.
    233  ImgDrawResult PaintImage(int32_t aRowIndex, nsTreeColumn* aColumn,
    234                           const nsRect& aImageRect,
    235                           nsPresContext* aPresContext,
    236                           gfxContext& aRenderingContext,
    237                           const nsRect& aDirtyRect, nscoord& aRemainingWidth,
    238                           nscoord& aCurrX, nsDisplayListBuilder* aBuilder);
    239 
    240  // This method paints the text string inside a particular cell of the tree.
    241  ImgDrawResult PaintText(int32_t aRowIndex, nsTreeColumn* aColumn,
    242                          const nsRect& aTextRect, nsPresContext* aPresContext,
    243                          gfxContext& aRenderingContext,
    244                          const nsRect& aDirtyRect, nscoord& aCurrX);
    245 
    246  // This method paints the checkbox inside a particular cell of the tree.
    247  ImgDrawResult PaintCheckbox(int32_t aRowIndex, nsTreeColumn* aColumn,
    248                              const nsRect& aCheckboxRect,
    249                              nsPresContext* aPresContext,
    250                              gfxContext& aRenderingContext,
    251                              const nsRect& aDirtyRect);
    252 
    253  // This method paints a drop feedback of the tree.
    254  ImgDrawResult PaintDropFeedback(const nsRect& aDropFeedbackRect,
    255                                  nsPresContext* aPresContext,
    256                                  gfxContext& aRenderingContext,
    257                                  const nsRect& aDirtyRect, nsPoint aPt);
    258 
    259  // This method is called with a specific ComputedStyle and rect to
    260  // paint the background rect as if it were a full-blown frame.
    261  ImgDrawResult PaintBackgroundLayer(ComputedStyle* aComputedStyle,
    262                                     nsPresContext* aPresContext,
    263                                     gfxContext& aRenderingContext,
    264                                     const nsRect& aRect,
    265                                     const nsRect& aDirtyRect);
    266 
    267  // An internal hit test.  aX and aY are expected to be in twips in the
    268  // coordinate system of this frame.
    269  int32_t GetRowAtInternal(nscoord aX, nscoord aY);
    270 
    271  // Check for bidi characters in the text, and if there are any, ensure
    272  // that the prescontext is in bidi mode.
    273  void CheckTextForBidi(nsAutoString& aText);
    274 
    275  void AdjustForCellText(nsAutoString& aText, int32_t aRowIndex,
    276                         nsTreeColumn* aColumn, gfxContext& aRenderingContext,
    277                         nsFontMetrics& aFontMetrics, nsRect& aTextRect);
    278 
    279  // A helper used when hit testing.
    280  nsCSSAnonBoxPseudoStaticAtom* GetItemWithinCellAt(nscoord aX,
    281                                                    const nsRect& aCellRect,
    282                                                    int32_t aRowIndex,
    283                                                    nsTreeColumn* aColumn);
    284 
    285  // An internal hit test.  aX and aY are expected to be in twips in the
    286  // coordinate system of this frame.
    287  void GetCellAt(nscoord aX, nscoord aY, int32_t* aRow, nsTreeColumn** aCol,
    288                 nsCSSAnonBoxPseudoStaticAtom** aChildElt);
    289 
    290  // Retrieve the area for the twisty for a cell.
    291  void GetTwistyRect(int32_t aRowIndex, nsTreeColumn* aColumn,
    292                     nsRect& aImageRect, nsRect& aTwistyRect,
    293                     nsPresContext* aPresContext,
    294                     ComputedStyle* aTwistyContext);
    295 
    296  // Fetch an image from the image cache, or request it.
    297  already_AddRefed<imgIContainer> GetImage(int32_t aRowIndex,
    298                                           nsTreeColumn* aCol, bool aUseContext,
    299                                           ComputedStyle* aComputedStyle);
    300 
    301  // Returns the size of a given image.   This size *includes* border and
    302  // padding.  It does not include margins.
    303  nsRect GetImageSize(int32_t aRowIndex, nsTreeColumn* aCol, bool aUseContext,
    304                      ComputedStyle* aComputedStyle);
    305 
    306  // Returns the destination size of the image, not including borders and
    307  // padding.
    308  nsSize GetImageDestSize(ComputedStyle*, imgIContainer*);
    309 
    310  // Returns the source rectangle of the image to be displayed.
    311  nsRect GetImageSourceRect(ComputedStyle*, imgIContainer*);
    312 
    313  // Returns the height of rows in the tree.
    314  int32_t GetRowHeight();
    315 
    316  // Returns our indentation width.
    317  int32_t GetIndentation();
    318 
    319  // Calculates our width/height once border and padding have been removed.
    320  void CalcInnerBox();
    321 
    322  // Calculate the total width of our scrollable portion
    323  nscoord CalcHorzWidth(const ScrollParts& aParts);
    324 
    325  // Looks up a ComputedStyle in the style cache.  On a cache miss we resolve
    326  // the pseudo-styles passed in and place them into the cache.
    327  ComputedStyle* GetPseudoComputedStyle(
    328      nsCSSAnonBoxPseudoStaticAtom* aPseudoElement);
    329 
    330  // Retrieves the scrollbars and scrollview relevant to this treebody. We
    331  // traverse the frame tree under our base element, in frame order, looking
    332  // for the first relevant vertical scrollbar, horizontal scrollbar, and
    333  // scrollable frame (with associated content and scrollable view). These
    334  // are all volatile and should not be retained.
    335  ScrollParts GetScrollParts();
    336 
    337  // Update the curpos of the scrollbar.
    338  void UpdateScrollbars(const ScrollParts& aParts);
    339 
    340  // Update the maxpos of the scrollbar.
    341  void InvalidateScrollbars(const ScrollParts& aParts);
    342 
    343  // Check overflow and generate events.
    344  MOZ_CAN_RUN_SCRIPT_BOUNDARY void CheckOverflow(const ScrollParts& aParts);
    345 
    346  // Calls UpdateScrollbars, Invalidate aNeedsFullInvalidation if true,
    347  // InvalidateScrollbars and finally CheckOverflow.
    348  // returns true if the frame is still alive after the method call.
    349  bool FullScrollbarsUpdate(bool aNeedsFullInvalidation);
    350 
    351  // Use to auto-fill some of the common properties without the view having to
    352  // do it. Examples include container, open, selected, and focus.
    353  void PrefillPropertyArray(int32_t aRowIndex, nsTreeColumn* aCol);
    354 
    355  // Our internal scroll method, used by all the public scroll methods.
    356  nsresult ScrollInternal(const ScrollParts& aParts, int32_t aRow);
    357  nsresult ScrollToRowInternal(const ScrollParts& aParts, int32_t aRow);
    358  nsresult EnsureRowIsVisibleInternal(const ScrollParts& aParts, int32_t aRow);
    359 
    360  // Convert client pixels into appunits in our coordinate space.
    361  nsPoint AdjustClientCoordsToBoxCoordSpace(int32_t aX, int32_t aY);
    362 
    363  void EnsureView();
    364 
    365  nsresult GetCellWidth(int32_t aRow, nsTreeColumn* aCol,
    366                        gfxContext* aRenderingContext, nscoord& aDesiredSize,
    367                        nscoord& aCurrentSize);
    368 
    369  // Translate the given rect horizontally from tree coordinates into the
    370  // coordinate system of our nsTreeBodyFrame.  If clip is true, then clip the
    371  // rect to its intersection with mInnerBox in the horizontal direction.
    372  // Return whether the result has a nonempty intersection with mInnerBox
    373  // after projecting both onto the horizontal coordinate axis.
    374  bool OffsetForHorzScroll(nsRect& rect, bool clip);
    375 
    376  bool CanAutoScroll(int32_t aRowIndex);
    377 
    378  // Calc the row and above/below/on status given where the mouse currently is
    379  // hovering. Also calc if we're in the region in which we want to auto-scroll
    380  // the tree. A positive value of |aScrollLines| means scroll down, a negative
    381  // value means scroll up, a zero value means that we aren't in drag scroll
    382  // region.
    383  void ComputeDropPosition(mozilla::WidgetGUIEvent* aEvent, int32_t* aRow,
    384                           int16_t* aOrient, int16_t* aScrollLines);
    385 
    386  void InvalidateDropFeedback(int32_t aRow, int16_t aOrientation) {
    387    InvalidateRow(aRow);
    388    if (aOrientation != nsITreeView::DROP_ON) {
    389      InvalidateRow(aRow + aOrientation);
    390    }
    391  }
    392 
    393 protected:
    394  // Create a new timer. This method is used to delay various actions like
    395  // opening/closing folders or tree scrolling.
    396  // aID is type of the action, aFunc is the function to be called when
    397  // the timer fires and aType is type of timer - one shot or repeating.
    398  nsresult CreateTimer(const mozilla::LookAndFeel::IntID aID,
    399                       nsTimerCallbackFunc aFunc, int32_t aType,
    400                       nsITimer** aTimer, const nsACString& aName);
    401 
    402  static void OpenCallback(nsITimer* aTimer, void* aClosure);
    403 
    404  static void CloseCallback(nsITimer* aTimer, void* aClosure);
    405 
    406  static void LazyScrollCallback(nsITimer* aTimer, void* aClosure);
    407 
    408  static void ScrollCallback(nsITimer* aTimer, void* aClosure);
    409 
    410  class ScrollEvent : public mozilla::Runnable {
    411   public:
    412    NS_DECL_NSIRUNNABLE
    413    explicit ScrollEvent(nsTreeBodyFrame* aInner)
    414        : mozilla::Runnable("nsTreeBodyFrame::ScrollEvent"), mInner(aInner) {}
    415    void Revoke() { mInner = nullptr; }
    416 
    417   private:
    418    nsTreeBodyFrame* mInner;
    419  };
    420 
    421  void PostScrollEvent();
    422  MOZ_CAN_RUN_SCRIPT void FireScrollEvent();
    423 
    424  /**
    425   * Clear the pointer to this frame for all nsTreeImageListeners that were
    426   * created by this frame.
    427   */
    428  void DetachImageListeners();
    429 
    430 #ifdef ACCESSIBILITY
    431  /**
    432   * Fires 'treeRowCountChanged' event asynchronously. The event is a
    433   * CustomEvent that is used to expose the following information structures
    434   * via a property bag.
    435   *
    436   * @param aIndex  the row index rows are added/removed from
    437   * @param aCount  the number of added/removed rows (the sign points to
    438   *                an operation, plus - addition, minus - removing)
    439   */
    440  void FireRowCountChangedEvent(int32_t aIndex, int32_t aCount);
    441 
    442  /**
    443   * Fires 'treeInvalidated' event asynchronously. The event is a CustomEvent
    444   * that is used to expose the information structures described by method
    445   * arguments via a property bag.
    446   *
    447   * @param aStartRow  the start index of invalidated rows, -1 means that
    448   *                   columns have been invalidated only
    449   * @param aEndRow    the end index of invalidated rows, -1 means that columns
    450   *                   have been invalidated only
    451   * @param aStartCol  the start invalidated column, nullptr means that only
    452   *                   rows have been invalidated
    453   * @param aEndCol    the end invalidated column, nullptr means that rows have
    454   *                   been invalidated only
    455   */
    456  void FireInvalidateEvent(int32_t aStartRow, int32_t aEndRow,
    457                           nsTreeColumn* aStartCol, nsTreeColumn* aEndCol);
    458 #endif
    459 
    460 protected:  // Data Members
    461  class Slots {
    462   public:
    463    Slots() = default;
    464 
    465    ~Slots() {
    466      if (mTimer) {
    467        mTimer->Cancel();
    468      }
    469    }
    470 
    471    friend class nsTreeBodyFrame;
    472 
    473   protected:
    474    // If the drop is actually allowed here or not.
    475    bool mDropAllowed = false;
    476 
    477    // True while dragging over the tree.
    478    bool mIsDragging = false;
    479 
    480    // The row the mouse is hovering over during a drop.
    481    int32_t mDropRow = -1;
    482 
    483    // Where we want to draw feedback (above/on this row/below) if allowed.
    484    int16_t mDropOrient = -1;
    485 
    486    // Number of lines to be scrolled.
    487    int16_t mScrollLines = 0;
    488 
    489    // The drag action that was received for this slot
    490    uint32_t mDragAction = 0;
    491 
    492    // Timer for opening/closing spring loaded folders or scrolling the tree.
    493    nsCOMPtr<nsITimer> mTimer;
    494 
    495    // An array used to keep track of all spring loaded folders.
    496    nsTArray<int32_t> mArray;
    497  };
    498 
    499  mozilla::UniquePtr<Slots> mSlots;
    500 
    501  nsRevocableEventPtr<ScrollEvent> mScrollEvent;
    502 
    503  RefPtr<ScrollbarActivity> mScrollbarActivity;
    504 
    505  // The <tree> element containing this treebody.
    506  RefPtr<mozilla::dom::XULTreeElement> mTree;
    507 
    508  // Cached column information.
    509  RefPtr<nsTreeColumns> mColumns;
    510 
    511  // The current view for this tree widget.  We get all of our row and cell data
    512  // from the view.
    513  nsCOMPtr<nsITreeView> mView;
    514 
    515  // A cache of all the ComputedStyles we have seen for rows and cells of the
    516  // tree.  This is a mapping from a list of atoms to a corresponding
    517  // ComputedStyle.  This cache stores every combination that occurs in the
    518  // tree, so for n distinct properties, this cache could have 2 to the n
    519  // entries (the power set of all row properties).
    520  nsTreeStyleCache mStyleCache;
    521 
    522  // A hashtable that maps from URLs to image request/listener pairs.  The URL
    523  // is provided by the view or by the ComputedStyle. The ComputedStyle
    524  // represents a resolved :-moz-tree-cell-image (or twisty) pseudo-element.
    525  nsTHashMap<nsURIHashKey, nsTreeImageCacheEntry> mImageCache;
    526 
    527  // A scratch array used when looking up cached ComputedStyles.
    528  mozilla::AtomArray mScratchArray;
    529 
    530  // The index of the first visible row and the # of rows visible onscreen.
    531  // The tree only examines onscreen rows, starting from
    532  // this index and going up to index+pageLength.
    533  int32_t mTopRowIndex;
    534  int32_t mPageLength;
    535 
    536  // The horizontal scroll position
    537  nscoord mHorzPosition;
    538 
    539  // The original desired horizontal width before changing it and posting a
    540  // reflow callback. In some cases, the desired horizontal width can first be
    541  // different from the current desired horizontal width, only to return to
    542  // the same value later during the same reflow. In this case, we can cancel
    543  // the posted reflow callback and prevent an unnecessary reflow.
    544  nscoord mOriginalHorzWidth;
    545  // Our desired horizontal width (the width for which we actually have tree
    546  // columns).
    547  nscoord mHorzWidth;
    548 
    549  // Our last reflowed rect, used for invalidation, see ManageReflowCallback().
    550  Maybe<nsRect> mLastReflowRect;
    551 
    552  // Cached heights and indent info.
    553  nsRect mInnerBox;  // 4-byte aligned
    554  int32_t mRowHeight;
    555  int32_t mIndentation;
    556 
    557  int32_t mUpdateBatchNest;
    558 
    559  // Cached row count.
    560  int32_t mRowCount;
    561 
    562  // The row the mouse is hovering over.
    563  int32_t mMouseOverRow;
    564 
    565  // Whether or not we're currently focused.
    566  bool mFocused;
    567 
    568  // Do we have a fixed number of onscreen rows?
    569  bool mHasFixedRowCount;
    570 
    571  bool mVerticalOverflow;
    572 
    573  bool mReflowCallbackPosted;
    574 
    575  // Set while we flush layout to take account of effects of overflow/underflow
    576  // event handlers
    577  bool mCheckingOverflow;
    578 };  // class nsTreeBodyFrame
    579 
    580 #endif