LCOV - code coverage report
Current view: top level - layout/xul/tree - nsTreeBodyFrame.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 50 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 30 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.13