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 mozilla_dom_GridLines_h
8 #define mozilla_dom_GridLines_h
9 
10 #include "nsCoord.h"
11 #include "nsTArray.h"
12 #include "nsWrapperCache.h"
13 
14 class nsAtom;
15 
16 namespace mozilla {
17 
18 struct ComputedGridTrackInfo;
19 struct ComputedGridLineInfo;
20 
21 namespace dom {
22 
23 class GridDimension;
24 class GridLine;
25 class GridArea;
26 
27 class GridLines : public nsISupports, public nsWrapperCache {
28  public:
29   explicit GridLines(GridDimension* aParent);
30 
31  protected:
32   virtual ~GridLines();
33 
34  public:
35   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
36   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(GridLines)
37 
38   virtual JSObject* WrapObject(JSContext* aCx,
39                                JS::Handle<JSObject*> aGivenProto) override;
GetParentObject()40   GridDimension* GetParentObject() { return mParent; }
41 
42   uint32_t Length() const;
43   GridLine* Item(uint32_t aIndex);
44   GridLine* IndexedGetter(uint32_t aIndex, bool& aFound);
45 
46   void SetLineInfo(const ComputedGridTrackInfo* aTrackInfo,
47                    const ComputedGridLineInfo* aLineInfo,
48                    const nsTArray<RefPtr<GridArea>>& aAreas, bool aIsRow);
49 
50  protected:
51   uint32_t AppendRemovedAutoFits(const ComputedGridTrackInfo* aTrackInfo,
52                                  const ComputedGridLineInfo* aLineInfo,
53                                  nscoord aLastTrackEdge, uint32_t& aRepeatIndex,
54                                  uint32_t aNumRepeatTracks,
55                                  uint32_t aNumLeadingTracks,
56                                  nsTArray<RefPtr<nsAtom>>& aLineNames);
57 
58   RefPtr<GridDimension> mParent;
59   nsTArray<RefPtr<GridLine>> mLines;
60 };
61 
62 }  // namespace dom
63 }  // namespace mozilla
64 
65 #endif /* mozilla_dom_GridLines_h */
66