tor-browser

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

XULTreeElement.h (3748B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef XULTreeElement_h__
      8 #define XULTreeElement_h__
      9 
     10 #include "nsCycleCollectionParticipant.h"
     11 #include "nsITreeView.h"
     12 #include "nsString.h"
     13 #include "nsWrapperCache.h"
     14 #include "nsXULElement.h"
     15 
     16 class nsTreeBodyFrame;
     17 class nsTreeColumn;
     18 class nsTreeColumns;
     19 
     20 namespace mozilla {
     21 class ErrorResult;
     22 
     23 namespace dom {
     24 
     25 struct TreeCellInfo;
     26 class DOMRect;
     27 enum class CallerType : uint32_t;
     28 
     29 class XULTreeElement final : public nsXULElement {
     30 public:
     31  explicit XULTreeElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
     32      : nsXULElement(std::move(aNodeInfo)),
     33        mCachedFirstVisibleRow(0),
     34        mTreeBody(nullptr) {}
     35 
     36  NS_IMPL_FROMNODE_WITH_TAG(XULTreeElement, kNameSpaceID_XUL, tree)
     37 
     38  NS_DECL_ISUPPORTS_INHERITED
     39  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULTreeElement, nsXULElement)
     40 
     41  nsTreeBodyFrame* GetTreeBodyFrame(FlushType = FlushType::Frames);
     42  nsTreeBodyFrame* GetCachedTreeBodyFrame() { return mTreeBody; }
     43 
     44  already_AddRefed<nsTreeColumns> GetColumns(FlushType = FlushType::Frames);
     45 
     46  already_AddRefed<nsITreeView> GetView(CallerType /* unused */) {
     47    return GetView();
     48  }
     49  already_AddRefed<nsITreeView> GetView(FlushType = FlushType::Frames);
     50 
     51  void SetView(nsITreeView* arg, CallerType aCallerType, ErrorResult& aRv);
     52 
     53  bool Focused();
     54 
     55  already_AddRefed<Element> GetTreeBody();
     56 
     57  int32_t RowHeight();
     58 
     59  int32_t RowWidth();
     60 
     61  void EnsureCellIsVisible(int32_t row, nsTreeColumn* col, ErrorResult& aRv);
     62 
     63  void ScrollToRow(int32_t aRow);
     64 
     65  void ScrollByLines(int32_t aNumLines);
     66 
     67  void ScrollByPages(int32_t aNumPages);
     68 
     69  int32_t GetFirstVisibleRow();
     70 
     71  int32_t GetLastVisibleRow();
     72 
     73  int32_t GetPageLength();
     74 
     75  int32_t GetRowAt(int32_t x, int32_t y);
     76 
     77  void GetCellAt(int32_t x, int32_t y, TreeCellInfo& aRetVal, ErrorResult& aRv);
     78 
     79  nsIntRect GetCoordsForCellItem(int32_t aRow, nsTreeColumn* aCol,
     80                                 const nsAString& aElement, nsresult& rv);
     81  already_AddRefed<DOMRect> GetCoordsForCellItem(int32_t row, nsTreeColumn& col,
     82                                                 const nsAString& element,
     83                                                 ErrorResult& aRv);
     84 
     85  bool IsCellCropped(int32_t row, nsTreeColumn* col, ErrorResult& aRv);
     86 
     87  void RemoveImageCacheEntry(int32_t row, nsTreeColumn& col, ErrorResult& aRv);
     88 
     89  void SetFocused(bool aFocused);
     90  void EnsureRowIsVisible(int32_t index);
     91  void Invalidate();
     92  void InvalidateColumn(nsTreeColumn* col);
     93  void InvalidateRow(int32_t index);
     94  void InvalidateCell(int32_t row, nsTreeColumn* col);
     95  void InvalidateRange(int32_t startIndex, int32_t endIndex);
     96  void RowCountChanged(int32_t index, int32_t count);
     97  void BeginUpdateBatch();
     98  void EndUpdateBatch();
     99  void ClearStyleAndImageCaches();
    100 
    101  void UnbindFromTree(UnbindContext&) override;
    102  void DestroyContent() override;
    103 
    104  void BodyDestroyed(int32_t aFirstVisibleRow) {
    105    mTreeBody = nullptr;
    106    mCachedFirstVisibleRow = aFirstVisibleRow;
    107  }
    108 
    109  int32_t GetCachedTopVisibleRow() { return mCachedFirstVisibleRow; }
    110 
    111  int32_t ScrollbarPosition() const;
    112  int32_t ScrollbarMaxPosition() const;
    113 
    114 protected:
    115  int32_t mCachedFirstVisibleRow;
    116 
    117  nsTreeBodyFrame* mTreeBody;
    118  nsCOMPtr<nsITreeView> mView;
    119 
    120  virtual ~XULTreeElement() = default;
    121 
    122  JSObject* WrapNode(JSContext* aCx,
    123                     JS::Handle<JSObject*> aGivenProto) override;
    124 };
    125 
    126 }  // namespace dom
    127 }  // namespace mozilla
    128 
    129 #endif