layout/xul/tree/nsTreeBodyFrame.h

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

     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 nsTreeBodyFrame_h
     7 #define nsTreeBodyFrame_h
     9 #include "mozilla/Attributes.h"
    11 #include "nsLeafBoxFrame.h"
    12 #include "nsITreeView.h"
    13 #include "nsICSSPseudoComparator.h"
    14 #include "nsIScrollbarMediator.h"
    15 #include "nsITimer.h"
    16 #include "nsIReflowCallback.h"
    17 #include "nsTArray.h"
    18 #include "nsTreeStyleCache.h"
    19 #include "nsTreeColumns.h"
    20 #include "nsAutoPtr.h"
    21 #include "nsDataHashtable.h"
    22 #include "imgIRequest.h"
    23 #include "imgINotificationObserver.h"
    24 #include "nsScrollbarFrame.h"
    25 #include "nsThreadUtils.h"
    26 #include "mozilla/LookAndFeel.h"
    27 #include "nsIScrollbarOwner.h"
    29 class nsOverflowChecker;
    30 class nsTreeImageListener;
    32 namespace mozilla {
    33 namespace layout {
    34 class ScrollbarActivity;
    35 }
    36 }
    38 // An entry in the tree's image cache
    39 struct nsTreeImageCacheEntry
    40 {
    41   nsTreeImageCacheEntry() {}
    42   nsTreeImageCacheEntry(imgIRequest *aRequest, imgINotificationObserver *aListener)
    43     : request(aRequest), listener(aListener) {}
    45   nsCOMPtr<imgIRequest> request;
    46   nsCOMPtr<imgINotificationObserver> listener;
    47 };
    49 // The actual frame that paints the cells and rows.
    50 class nsTreeBodyFrame MOZ_FINAL
    51   : public nsLeafBoxFrame
    52   , public nsICSSPseudoComparator
    53   , public nsIScrollbarMediator
    54   , public nsIReflowCallback
    55   , public nsIScrollbarOwner
    56 {
    57 public:
    58   typedef mozilla::layout::ScrollbarActivity ScrollbarActivity;
    60   nsTreeBodyFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
    61   ~nsTreeBodyFrame();
    63   NS_DECL_QUERYFRAME_TARGET(nsTreeBodyFrame)
    64   NS_DECL_QUERYFRAME
    65   NS_DECL_FRAMEARENA_HELPERS
    67   // Callback handler methods for refresh driver based animations.
    68   // Calls to these functions are forwarded from nsTreeImageListener. These
    69   // mirror how nsImageFrame works.
    70   nsresult OnImageIsAnimated(imgIRequest* aRequest);
    72   // non-virtual signatures like nsITreeBodyFrame
    73   already_AddRefed<nsTreeColumns> Columns() const
    74   {
    75     nsRefPtr<nsTreeColumns> cols = mColumns;
    76     return cols.forget();
    77   }
    78   already_AddRefed<nsITreeView> GetExistingView() const
    79   {
    80     nsCOMPtr<nsITreeView> view = mView;
    81     return view.forget();
    82   }
    83   nsresult GetView(nsITreeView **aView);
    84   nsresult SetView(nsITreeView *aView);
    85   nsresult GetFocused(bool *aFocused);
    86   nsresult SetFocused(bool aFocused);
    87   nsresult GetTreeBody(nsIDOMElement **aElement);
    88   nsresult GetRowHeight(int32_t *aValue);
    89   nsresult GetRowWidth(int32_t *aValue);
    90   nsresult GetHorizontalPosition(int32_t *aValue);
    91   nsresult GetSelectionRegion(nsIScriptableRegion **aRegion);
    92   int32_t FirstVisibleRow() const { return mTopRowIndex; }
    93   int32_t LastVisibleRow() const { return mTopRowIndex + mPageLength; }
    94   int32_t PageLength() const { return mPageLength; }
    95   nsresult EnsureRowIsVisible(int32_t aRow);
    96   nsresult EnsureCellIsVisible(int32_t aRow, nsITreeColumn *aCol);
    97   nsresult ScrollToRow(int32_t aRow);
    98   nsresult ScrollByLines(int32_t aNumLines);
    99   nsresult ScrollByPages(int32_t aNumPages);
   100   nsresult ScrollToCell(int32_t aRow, nsITreeColumn *aCol);
   101   nsresult ScrollToColumn(nsITreeColumn *aCol);
   102   nsresult ScrollToHorizontalPosition(int32_t aValue);
   103   nsresult Invalidate();
   104   nsresult InvalidateColumn(nsITreeColumn *aCol);
   105   nsresult InvalidateRow(int32_t aRow);
   106   nsresult InvalidateCell(int32_t aRow, nsITreeColumn *aCol);
   107   nsresult InvalidateRange(int32_t aStart, int32_t aEnd);
   108   nsresult InvalidateColumnRange(int32_t aStart, int32_t aEnd,
   109                                  nsITreeColumn *aCol);
   110   nsresult GetRowAt(int32_t aX, int32_t aY, int32_t *aValue);
   111   nsresult GetCellAt(int32_t aX, int32_t aY, int32_t *aRow,
   112                      nsITreeColumn **aCol, nsACString &aChildElt);
   113   nsresult GetCoordsForCellItem(int32_t aRow, nsITreeColumn *aCol,
   114                                 const nsACString &aElt,
   115                                 int32_t *aX, int32_t *aY,
   116                                 int32_t *aWidth, int32_t *aHeight);
   117   nsresult IsCellCropped(int32_t aRow, nsITreeColumn *aCol, bool *aResult);
   118   nsresult RowCountChanged(int32_t aIndex, int32_t aCount);
   119   nsresult BeginUpdateBatch();
   120   nsresult EndUpdateBatch();
   121   nsresult ClearStyleAndImageCaches();
   123   void ManageReflowCallback(const nsRect& aRect, nscoord aHorzWidth);
   125   virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
   126   virtual void SetBounds(nsBoxLayoutState& aBoxLayoutState, const nsRect& aRect,
   127                          bool aRemoveOverflowArea = false) MOZ_OVERRIDE;
   129   // nsIReflowCallback
   130   virtual bool ReflowFinished() MOZ_OVERRIDE;
   131   virtual void ReflowCallbackCanceled() MOZ_OVERRIDE;
   133   // nsICSSPseudoComparator
   134   virtual bool PseudoMatches(nsCSSSelector* aSelector) MOZ_OVERRIDE;
   136   // nsIScrollbarMediator
   137   NS_IMETHOD PositionChanged(nsScrollbarFrame* aScrollbar, int32_t aOldIndex, int32_t& aNewIndex) MOZ_OVERRIDE;
   138   NS_IMETHOD ScrollbarButtonPressed(nsScrollbarFrame* aScrollbar, int32_t aOldIndex, int32_t aNewIndex) MOZ_OVERRIDE;
   139   NS_IMETHOD VisibilityChanged(bool aVisible) MOZ_OVERRIDE { Invalidate(); return NS_OK; }
   141   // nsIScrollbarOwner
   142   virtual nsIFrame* GetScrollbarBox(bool aVertical) MOZ_OVERRIDE {
   143     ScrollParts parts = GetScrollParts();
   144     return aVertical ? parts.mVScrollbar : parts.mHScrollbar;
   145   }
   147   // Overridden from nsIFrame to cache our pres context.
   148   virtual void Init(nsIContent*     aContent,
   149                     nsIFrame*       aParent,
   150                     nsIFrame*       aPrevInFlow) MOZ_OVERRIDE;
   151   virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
   153   virtual nsresult GetCursor(const nsPoint& aPoint,
   154                              nsIFrame::Cursor& aCursor) MOZ_OVERRIDE;
   156   virtual nsresult HandleEvent(nsPresContext* aPresContext,
   157                                mozilla::WidgetGUIEvent* aEvent,
   158                                nsEventStatus* aEventStatus) MOZ_OVERRIDE;
   160   virtual void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
   161                                 const nsRect&           aDirtyRect,
   162                                 const nsDisplayListSet& aLists) MOZ_OVERRIDE;
   164   virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext) MOZ_OVERRIDE;
   166   friend nsIFrame* NS_NewTreeBodyFrame(nsIPresShell* aPresShell);
   167   friend class nsTreeColumn;
   169   struct ScrollParts {
   170     nsScrollbarFrame*    mVScrollbar;
   171     nsCOMPtr<nsIContent> mVScrollbarContent;
   172     nsScrollbarFrame*    mHScrollbar;
   173     nsCOMPtr<nsIContent> mHScrollbarContent;
   174     nsIFrame*            mColumnsFrame;
   175     nsIScrollableFrame*  mColumnsScrollFrame;
   176   };
   178   void PaintTreeBody(nsRenderingContext& aRenderingContext,
   179                      const nsRect& aDirtyRect, nsPoint aPt);
   181   nsITreeBoxObject* GetTreeBoxObject() const { return mTreeBoxObject; }
   183   // Get the base element, <tree> or <select>
   184   nsIContent* GetBaseElement();
   186   bool GetVerticalOverflow() const { return mVerticalOverflow; }
   187   bool GetHorizontalOverflow() const {return mHorizontalOverflow; }
   189 protected:
   190   friend class nsOverflowChecker;
   192   // This method paints a specific column background of the tree.
   193   void PaintColumn(nsTreeColumn*        aColumn,
   194                    const nsRect&        aColumnRect,
   195                    nsPresContext*      aPresContext,
   196                    nsRenderingContext& aRenderingContext,
   197                    const nsRect&        aDirtyRect);
   199   // This method paints a single row in the tree.
   200   void PaintRow(int32_t              aRowIndex,
   201                 const nsRect&        aRowRect,
   202                 nsPresContext*       aPresContext,
   203                 nsRenderingContext& aRenderingContext,
   204                 const nsRect&        aDirtyRect,
   205                 nsPoint              aPt);
   207   // This method paints a single separator in the tree.
   208   void PaintSeparator(int32_t              aRowIndex,
   209                       const nsRect&        aSeparatorRect,
   210                       nsPresContext*      aPresContext,
   211                       nsRenderingContext& aRenderingContext,
   212                       const nsRect&        aDirtyRect);
   214   // This method paints a specific cell in a given row of the tree.
   215   void PaintCell(int32_t              aRowIndex, 
   216                  nsTreeColumn*        aColumn,
   217                  const nsRect&        aCellRect,
   218                  nsPresContext*       aPresContext,
   219                  nsRenderingContext& aRenderingContext,
   220                  const nsRect&        aDirtyRect,
   221                  nscoord&             aCurrX,
   222                  nsPoint              aPt);
   224   // This method paints the twisty inside a cell in the primary column of an tree.
   225   void PaintTwisty(int32_t              aRowIndex,
   226                    nsTreeColumn*        aColumn,
   227                    const nsRect&        aTwistyRect,
   228                    nsPresContext*      aPresContext,
   229                    nsRenderingContext& aRenderingContext,
   230                    const nsRect&        aDirtyRect,
   231                    nscoord&             aRemainingWidth,
   232                    nscoord&             aCurrX);
   234   // This method paints the image inside the cell of an tree.
   235   void PaintImage(int32_t              aRowIndex,
   236                   nsTreeColumn*        aColumn,
   237                   const nsRect&        aImageRect,
   238                   nsPresContext*      aPresContext,
   239                   nsRenderingContext& aRenderingContext,
   240                   const nsRect&        aDirtyRect,
   241                   nscoord&             aRemainingWidth,
   242                   nscoord&             aCurrX);
   244   // This method paints the text string inside a particular cell of the tree.
   245   void PaintText(int32_t              aRowIndex, 
   246                  nsTreeColumn*        aColumn,
   247                  const nsRect&        aTextRect,
   248                  nsPresContext*      aPresContext,
   249                  nsRenderingContext& aRenderingContext,
   250                  const nsRect&        aDirtyRect,
   251                  nscoord&             aCurrX);
   253   // This method paints the checkbox inside a particular cell of the tree.
   254   void PaintCheckbox(int32_t              aRowIndex, 
   255                      nsTreeColumn*        aColumn,
   256                      const nsRect&        aCheckboxRect,
   257                      nsPresContext*      aPresContext,
   258                      nsRenderingContext& aRenderingContext,
   259                      const nsRect&        aDirtyRect);
   261   // This method paints the progress meter inside a particular cell of the tree.
   262   void PaintProgressMeter(int32_t              aRowIndex, 
   263                           nsTreeColumn*        aColumn,
   264                           const nsRect&        aProgressMeterRect,
   265                           nsPresContext*      aPresContext,
   266                           nsRenderingContext& aRenderingContext,
   267                           const nsRect&        aDirtyRect);
   269   // This method paints a drop feedback of the tree.
   270   void PaintDropFeedback(const nsRect&        aDropFeedbackRect, 
   271                          nsPresContext*      aPresContext,
   272                          nsRenderingContext& aRenderingContext,
   273                          const nsRect&        aDirtyRect,
   274                          nsPoint              aPt);
   276   // This method is called with a specific style context and rect to
   277   // paint the background rect as if it were a full-blown frame.
   278   void PaintBackgroundLayer(nsStyleContext*      aStyleContext,
   279                             nsPresContext*      aPresContext, 
   280                             nsRenderingContext& aRenderingContext, 
   281                             const nsRect&        aRect,
   282                             const nsRect&        aDirtyRect);
   285   // An internal hit test.  aX and aY are expected to be in twips in the
   286   // coordinate system of this frame.
   287   int32_t GetRowAt(nscoord aX, nscoord aY);
   289   // Check for bidi characters in the text, and if there are any, ensure
   290   // that the prescontext is in bidi mode.
   291   void CheckTextForBidi(nsAutoString& aText);
   293   void AdjustForCellText(nsAutoString& aText,
   294                          int32_t aRowIndex,  nsTreeColumn* aColumn,
   295                          nsRenderingContext& aRenderingContext,
   296                          nsRect& aTextRect);
   298   // A helper used when hit testing.
   299   nsIAtom* GetItemWithinCellAt(nscoord aX, const nsRect& aCellRect,
   300                                int32_t aRowIndex, nsTreeColumn* aColumn);
   302   // An internal hit test.  aX and aY are expected to be in twips in the
   303   // coordinate system of this frame.
   304   void GetCellAt(nscoord aX, nscoord aY, int32_t* aRow, nsTreeColumn** aCol,
   305                  nsIAtom** aChildElt);
   307   // Retrieve the area for the twisty for a cell.
   308   nsITheme* GetTwistyRect(int32_t aRowIndex,
   309                           nsTreeColumn* aColumn,
   310                           nsRect& aImageRect,
   311                           nsRect& aTwistyRect,
   312                           nsPresContext* aPresContext,
   313                           nsRenderingContext& aRenderingContext,
   314                           nsStyleContext* aTwistyContext);
   316   // Fetch an image from the image cache.
   317   nsresult GetImage(int32_t aRowIndex, nsTreeColumn* aCol, bool aUseContext,
   318                     nsStyleContext* aStyleContext, bool& aAllowImageRegions, imgIContainer** aResult);
   320   // Returns the size of a given image.   This size *includes* border and
   321   // padding.  It does not include margins.
   322   nsRect GetImageSize(int32_t aRowIndex, nsTreeColumn* aCol, bool aUseContext, nsStyleContext* aStyleContext);
   324   // Returns the destination size of the image, not including borders and padding.
   325   nsSize GetImageDestSize(nsStyleContext* aStyleContext, bool useImageRegion, imgIContainer* image);
   327   // Returns the source rectangle of the image to be displayed.
   328   nsRect GetImageSourceRect(nsStyleContext* aStyleContext, bool useImageRegion, imgIContainer* image);
   330   // Returns the height of rows in the tree.
   331   int32_t GetRowHeight();
   333   // Returns our indentation width.
   334   int32_t GetIndentation();
   336   // Calculates our width/height once border and padding have been removed.
   337   void CalcInnerBox();
   339   // Calculate the total width of our scrollable portion
   340   nscoord CalcHorzWidth(const ScrollParts& aParts);
   342   // Looks up a style context in the style cache.  On a cache miss we resolve
   343   // the pseudo-styles passed in and place them into the cache.
   344   nsStyleContext* GetPseudoStyleContext(nsIAtom* aPseudoElement);
   346   // Retrieves the scrollbars and scrollview relevant to this treebody. We
   347   // traverse the frame tree under our base element, in frame order, looking
   348   // for the first relevant vertical scrollbar, horizontal scrollbar, and
   349   // scrollable frame (with associated content and scrollable view). These
   350   // are all volatile and should not be retained.
   351   ScrollParts GetScrollParts();
   353   // Update the curpos of the scrollbar.
   354   void UpdateScrollbars(const ScrollParts& aParts);
   356   // Update the maxpos of the scrollbar.
   357   void InvalidateScrollbars(const ScrollParts& aParts, nsWeakFrame& aWeakColumnsFrame);
   359   // Check overflow and generate events.
   360   void CheckOverflow(const ScrollParts& aParts);
   362   // Calls UpdateScrollbars, Invalidate aNeedsFullInvalidation if true,
   363   // InvalidateScrollbars and finally CheckOverflow.
   364   // returns true if the frame is still alive after the method call.
   365   bool FullScrollbarsUpdate(bool aNeedsFullInvalidation);
   367   // Use to auto-fill some of the common properties without the view having to do it.
   368   // Examples include container, open, selected, and focus.
   369   void PrefillPropertyArray(int32_t aRowIndex, nsTreeColumn* aCol);
   371   // Our internal scroll method, used by all the public scroll methods.
   372   nsresult ScrollInternal(const ScrollParts& aParts, int32_t aRow);
   373   nsresult ScrollToRowInternal(const ScrollParts& aParts, int32_t aRow);
   374   nsresult ScrollToColumnInternal(const ScrollParts& aParts, nsITreeColumn* aCol);
   375   nsresult ScrollHorzInternal(const ScrollParts& aParts, int32_t aPosition);
   376   nsresult EnsureRowIsVisibleInternal(const ScrollParts& aParts, int32_t aRow);
   378   // Convert client pixels into appunits in our coordinate space.
   379   nsPoint AdjustClientCoordsToBoxCoordSpace(int32_t aX, int32_t aY);
   381   // Cache the box object
   382   void EnsureBoxObject();
   384   void EnsureView();
   386   nsresult GetCellWidth(int32_t aRow, nsTreeColumn* aCol,
   387                         nsRenderingContext* aRenderingContext,
   388                         nscoord& aDesiredSize, nscoord& aCurrentSize);
   389   nscoord CalcMaxRowWidth();
   391   // Translate the given rect horizontally from tree coordinates into the
   392   // coordinate system of our nsTreeBodyFrame.  If clip is true, then clip the
   393   // rect to its intersection with mInnerBox in the horizontal direction.
   394   // Return whether the result has a nonempty intersection with mInnerBox
   395   // after projecting both onto the horizontal coordinate axis.
   396   bool OffsetForHorzScroll(nsRect& rect, bool clip);
   398   bool CanAutoScroll(int32_t aRowIndex);
   400   // Calc the row and above/below/on status given where the mouse currently is hovering.
   401   // Also calc if we're in the region in which we want to auto-scroll the tree.
   402   // A positive value of |aScrollLines| means scroll down, a negative value
   403   // means scroll up, a zero value means that we aren't in drag scroll region.
   404   void ComputeDropPosition(mozilla::WidgetGUIEvent* aEvent,
   405                            int32_t* aRow,
   406                            int16_t* aOrient,
   407                            int16_t* aScrollLines);
   409   // Mark ourselves dirty if we're a select widget
   410   void MarkDirtyIfSelect();
   412   void InvalidateDropFeedback(int32_t aRow, int16_t aOrientation) {
   413     InvalidateRow(aRow);
   414     if (aOrientation != nsITreeView::DROP_ON)
   415       InvalidateRow(aRow + aOrientation);
   416   }
   418 public:
   419   static
   420   already_AddRefed<nsTreeColumn> GetColumnImpl(nsITreeColumn* aUnknownCol) {
   421     if (!aUnknownCol)
   422       return nullptr;
   424     nsCOMPtr<nsTreeColumn> col = do_QueryInterface(aUnknownCol);
   425     return col.forget();
   426   }
   428   /**
   429    * Remove an nsITreeImageListener from being tracked by this frame. Only tree
   430    * image listeners that are created by this frame are tracked.
   431    *
   432    * @param aListener A pointer to an nsTreeImageListener to no longer
   433    *        track.
   434    */
   435   void RemoveTreeImageListener(nsTreeImageListener* aListener);
   437 protected:
   439   // Create a new timer. This method is used to delay various actions like
   440   // opening/closing folders or tree scrolling.
   441   // aID is type of the action, aFunc is the function to be called when
   442   // the timer fires and aType is type of timer - one shot or repeating.
   443   nsresult CreateTimer(const mozilla::LookAndFeel::IntID aID,
   444                        nsTimerCallbackFunc aFunc, int32_t aType,
   445                        nsITimer** aTimer);
   447   static void OpenCallback(nsITimer *aTimer, void *aClosure);
   449   static void CloseCallback(nsITimer *aTimer, void *aClosure);
   451   static void LazyScrollCallback(nsITimer *aTimer, void *aClosure);
   453   static void ScrollCallback(nsITimer *aTimer, void *aClosure);
   455   class ScrollEvent : public nsRunnable {
   456   public:
   457     NS_DECL_NSIRUNNABLE
   458     ScrollEvent(nsTreeBodyFrame *aInner) : mInner(aInner) {}
   459     void Revoke() { mInner = nullptr; }
   460   private:
   461     nsTreeBodyFrame* mInner;
   462   };
   464   void PostScrollEvent();
   465   void FireScrollEvent();
   467   virtual void ScrollbarActivityStarted() const MOZ_OVERRIDE;
   468   virtual void ScrollbarActivityStopped() const MOZ_OVERRIDE;
   470   /**
   471    * Clear the pointer to this frame for all nsTreeImageListeners that were
   472    * created by this frame.
   473    */
   474   void DetachImageListeners();
   476 #ifdef ACCESSIBILITY
   477   /**
   478    * Fires 'treeRowCountChanged' event asynchronously. The event supports
   479    * nsIDOMCustomEvent interface that is used to expose the following
   480    * information structures.
   481    *
   482    * @param aIndex  the row index rows are added/removed from
   483    * @param aCount  the number of added/removed rows (the sign points to
   484    *                an operation, plus - addition, minus - removing)
   485    */
   486   void FireRowCountChangedEvent(int32_t aIndex, int32_t aCount);
   488   /**
   489    * Fires 'treeInvalidated' event asynchronously. The event supports
   490    * nsIDOMCustomEvent interface that is used to expose the information
   491    * structures described by method arguments.
   492    *
   493    * @param aStartRow  the start index of invalidated rows, -1 means that
   494    *                   columns have been invalidated only
   495    * @param aEndRow    the end index of invalidated rows, -1 means that columns
   496    *                   have been invalidated only
   497    * @param aStartCol  the start invalidated column, nullptr means that only rows
   498    *                   have been invalidated
   499    * @param aEndCol    the end invalidated column, nullptr means that rows have
   500    *                   been invalidated only
   501    */
   502   void FireInvalidateEvent(int32_t aStartRow, int32_t aEndRow,
   503                            nsITreeColumn *aStartCol, nsITreeColumn *aEndCol);
   504 #endif
   506 protected: // Data Members
   508   class Slots {
   509     public:
   510       Slots() {
   511       }
   513       ~Slots() {
   514         if (mTimer)
   515           mTimer->Cancel();
   516       }
   518       friend class nsTreeBodyFrame;
   520     protected:
   521       // If the drop is actually allowed here or not.
   522       bool                     mDropAllowed;
   524       // True while dragging over the tree.
   525       bool mIsDragging;
   527       // The row the mouse is hovering over during a drop.
   528       int32_t                  mDropRow;
   530       // Where we want to draw feedback (above/on this row/below) if allowed.
   531       int16_t                  mDropOrient;
   533       // Number of lines to be scrolled.
   534       int16_t                  mScrollLines;
   536       // The drag action that was received for this slot
   537       uint32_t                 mDragAction;
   539       // Timer for opening/closing spring loaded folders or scrolling the tree.
   540       nsCOMPtr<nsITimer>       mTimer;
   542       // An array used to keep track of all spring loaded folders.
   543       nsTArray<int32_t>        mArray;
   544   };
   546   Slots* mSlots;
   548   nsRevocableEventPtr<ScrollEvent> mScrollEvent;
   550   nsRefPtr<ScrollbarActivity> mScrollbarActivity;
   552   // The cached box object parent.
   553   nsCOMPtr<nsITreeBoxObject> mTreeBoxObject;
   555   // Cached column information.
   556   nsRefPtr<nsTreeColumns> mColumns;
   558   // The current view for this tree widget.  We get all of our row and cell data
   559   // from the view.
   560   nsCOMPtr<nsITreeView> mView;
   562   // A cache of all the style contexts we have seen for rows and cells of the tree.  This is a mapping from
   563   // a list of atoms to a corresponding style context.  This cache stores every combination that
   564   // occurs in the tree, so for n distinct properties, this cache could have 2 to the n entries
   565   // (the power set of all row properties).
   566   nsTreeStyleCache mStyleCache;
   568   // A hashtable that maps from URLs to image request/listener pairs.  The URL
   569   // is provided by the view or by the style context. The style context
   570   // represents a resolved :-moz-tree-cell-image (or twisty) pseudo-element.
   571   // It maps directly to an imgIRequest.
   572   nsDataHashtable<nsStringHashKey, nsTreeImageCacheEntry> mImageCache;
   574   // A scratch array used when looking up cached style contexts.
   575   AtomArray mScratchArray;
   577   // The index of the first visible row and the # of rows visible onscreen.  
   578   // The tree only examines onscreen rows, starting from
   579   // this index and going up to index+pageLength.
   580   int32_t mTopRowIndex;
   581   int32_t mPageLength;
   583   // The horizontal scroll position
   584   nscoord mHorzPosition;
   586   // The original desired horizontal width before changing it and posting a
   587   // reflow callback. In some cases, the desired horizontal width can first be
   588   // different from the current desired horizontal width, only to return to
   589   // the same value later during the same reflow. In this case, we can cancel
   590   // the posted reflow callback and prevent an unnecessary reflow.
   591   nscoord mOriginalHorzWidth;
   592   // Our desired horizontal width (the width for which we actually have tree
   593   // columns).
   594   nscoord mHorzWidth;
   595   // The amount by which to adjust the width of the last cell.
   596   // This depends on whether or not the columnpicker and scrollbars are present.
   597   nscoord mAdjustWidth;
   599   // Cached heights and indent info.
   600   nsRect mInnerBox; // 4-byte aligned
   601   int32_t mRowHeight;
   602   int32_t mIndentation;
   603   nscoord mStringWidth;
   605   int32_t mUpdateBatchNest;
   607   // Cached row count.
   608   int32_t mRowCount;
   610   // The row the mouse is hovering over.
   611   int32_t mMouseOverRow;
   613   // Whether or not we're currently focused.
   614   bool mFocused;
   616   // Do we have a fixed number of onscreen rows?
   617   bool mHasFixedRowCount;
   619   bool mVerticalOverflow;
   620   bool mHorizontalOverflow;
   622   bool mReflowCallbackPosted;
   624   // Set while we flush layout to take account of effects of
   625   // overflow/underflow event handlers
   626   bool mCheckingOverflow;
   628   // Hash table to keep track of which listeners we created and thus
   629   // have pointers to us.
   630   nsTHashtable<nsPtrHashKey<nsTreeImageListener> > mCreatedListeners;
   632 }; // class nsTreeBodyFrame
   634 #endif

mercurial