/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef nsTreeBodyFrame_h #define nsTreeBodyFrame_h #include "mozilla/Attributes.h" #include "nsLeafBoxFrame.h" #include "nsITreeView.h" #include "nsICSSPseudoComparator.h" #include "nsIScrollbarMediator.h" #include "nsITimer.h" #include "nsIReflowCallback.h" #include "nsTArray.h" #include "nsTreeStyleCache.h" #include "nsTreeColumns.h" #include "nsAutoPtr.h" #include "nsDataHashtable.h" #include "imgIRequest.h" #include "imgINotificationObserver.h" #include "nsScrollbarFrame.h" #include "nsThreadUtils.h" #include "mozilla/LookAndFeel.h" class nsOverflowChecker; class nsTreeImageListener; // An entry in the tree's image cache struct nsTreeImageCacheEntry { nsTreeImageCacheEntry() {} nsTreeImageCacheEntry(imgIRequest *aRequest, imgINotificationObserver *aListener) : request(aRequest), listener(aListener) {} nsCOMPtr request; nsCOMPtr listener; }; // The actual frame that paints the cells and rows. class nsTreeBodyFrame MOZ_FINAL : public nsLeafBoxFrame , public nsICSSPseudoComparator , public nsIScrollbarMediator , public nsIReflowCallback { public: nsTreeBodyFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); ~nsTreeBodyFrame(); NS_DECL_QUERYFRAME_TARGET(nsTreeBodyFrame) NS_DECL_QUERYFRAME NS_DECL_FRAMEARENA_HELPERS // Callback handler methods for refresh driver based animations. // Calls to these functions are forwarded from nsTreeImageListener. These // mirror how nsImageFrame works. nsresult OnImageIsAnimated(imgIRequest* aRequest); // non-virtual signatures like nsITreeBodyFrame already_AddRefed Columns() const { nsRefPtr cols = mColumns; return cols.forget(); } already_AddRefed GetExistingView() const { nsCOMPtr view = mView; return view.forget(); } nsresult GetView(nsITreeView **aView); nsresult SetView(nsITreeView *aView); nsresult GetFocused(bool *aFocused); nsresult SetFocused(bool aFocused); nsresult GetTreeBody(nsIDOMElement **aElement); nsresult GetRowHeight(int32_t *aValue); nsresult GetRowWidth(int32_t *aValue); nsresult GetHorizontalPosition(int32_t *aValue); nsresult GetSelectionRegion(nsIScriptableRegion **aRegion); int32_t FirstVisibleRow() const { return mTopRowIndex; } int32_t LastVisibleRow() const { return mTopRowIndex + mPageLength; } int32_t PageLength() const { return mPageLength; } nsresult EnsureRowIsVisible(int32_t aRow); nsresult EnsureCellIsVisible(int32_t aRow, nsITreeColumn *aCol); nsresult ScrollToRow(int32_t aRow); nsresult ScrollByLines(int32_t aNumLines); nsresult ScrollByPages(int32_t aNumPages); nsresult ScrollToCell(int32_t aRow, nsITreeColumn *aCol); nsresult ScrollToColumn(nsITreeColumn *aCol); nsresult ScrollToHorizontalPosition(int32_t aValue); nsresult Invalidate(); nsresult InvalidateColumn(nsITreeColumn *aCol); nsresult InvalidateRow(int32_t aRow); nsresult InvalidateCell(int32_t aRow, nsITreeColumn *aCol); nsresult InvalidateRange(int32_t aStart, int32_t aEnd); nsresult InvalidateColumnRange(int32_t aStart, int32_t aEnd, nsITreeColumn *aCol); nsresult GetRowAt(int32_t aX, int32_t aY, int32_t *aValue); nsresult GetCellAt(int32_t aX, int32_t aY, int32_t *aRow, nsITreeColumn **aCol, nsACString &aChildElt); nsresult GetCoordsForCellItem(int32_t aRow, nsITreeColumn *aCol, const nsACString &aElt, int32_t *aX, int32_t *aY, int32_t *aWidth, int32_t *aHeight); nsresult IsCellCropped(int32_t aRow, nsITreeColumn *aCol, bool *aResult); nsresult RowCountChanged(int32_t aIndex, int32_t aCount); nsresult BeginUpdateBatch(); nsresult EndUpdateBatch(); nsresult ClearStyleAndImageCaches(); virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState); virtual void SetBounds(nsBoxLayoutState& aBoxLayoutState, const nsRect& aRect, bool aRemoveOverflowArea = false); // nsIReflowCallback virtual bool ReflowFinished() MOZ_OVERRIDE; virtual void ReflowCallbackCanceled() MOZ_OVERRIDE; // nsICSSPseudoComparator virtual bool PseudoMatches(nsCSSSelector* aSelector) MOZ_OVERRIDE; // nsIScrollbarMediator NS_IMETHOD PositionChanged(nsScrollbarFrame* aScrollbar, int32_t aOldIndex, int32_t& aNewIndex); NS_IMETHOD ScrollbarButtonPressed(nsScrollbarFrame* aScrollbar, int32_t aOldIndex, int32_t aNewIndex) MOZ_OVERRIDE; NS_IMETHOD VisibilityChanged(bool aVisible) MOZ_OVERRIDE { Invalidate(); return NS_OK; } // Overridden from nsIFrame to cache our pres context. virtual void Init(nsIContent* aContent, nsIFrame* aParent, nsIFrame* aPrevInFlow) MOZ_OVERRIDE; virtual void DestroyFrom(nsIFrame* aDestructRoot); NS_IMETHOD GetCursor(const nsPoint& aPoint, nsIFrame::Cursor& aCursor); NS_IMETHOD HandleEvent(nsPresContext* aPresContext, nsGUIEvent* aEvent, nsEventStatus* aEventStatus); virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, const nsRect& aDirtyRect, const nsDisplayListSet& aLists) MOZ_OVERRIDE; virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext); friend nsIFrame* NS_NewTreeBodyFrame(nsIPresShell* aPresShell); friend class nsTreeColumn; struct ScrollParts { nsScrollbarFrame* mVScrollbar; nsCOMPtr mVScrollbarContent; nsScrollbarFrame* mHScrollbar; nsCOMPtr mHScrollbarContent; nsIFrame* mColumnsFrame; nsIScrollableFrame* mColumnsScrollFrame; }; void PaintTreeBody(nsRenderingContext& aRenderingContext, const nsRect& aDirtyRect, nsPoint aPt); nsITreeBoxObject* GetTreeBoxObject() const { return mTreeBoxObject; } // Get the base element, or