LCOV - code coverage report
Current view: directory - layout/xul/base/src/tree/src - nsTreeBodyFrame.h (source / functions) Found Hit Coverage
Test: app.info Lines: 30 0 0.0 %
Date: 2012-06-02 Functions: 19 0 0.0 %

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

Generated by: LCOV version 1.7