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 #include "GridDimension.h"
8 
9 #include "Grid.h"
10 #include "GridLines.h"
11 #include "GridTracks.h"
12 #include "mozilla/dom/GridBinding.h"
13 #include "nsGridContainerFrame.h"
14 
15 namespace mozilla::dom {
16 
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(GridDimension,mParent,mLines,mTracks)17 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(GridDimension, mParent, mLines, mTracks)
18 NS_IMPL_CYCLE_COLLECTING_ADDREF(GridDimension)
19 NS_IMPL_CYCLE_COLLECTING_RELEASE(GridDimension)
20 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(GridDimension)
21   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
22   NS_INTERFACE_MAP_ENTRY(nsISupports)
23 NS_INTERFACE_MAP_END
24 
25 GridDimension::GridDimension(Grid* aParent)
26     : mParent(aParent),
27       mLines(new GridLines(this)),
28       mTracks(new GridTracks(this)) {
29   MOZ_ASSERT(aParent, "Should never be instantiated with a null Grid");
30 }
31 
32 GridDimension::~GridDimension() = default;
33 
WrapObject(JSContext * aCx,JS::Handle<JSObject * > aGivenProto)34 JSObject* GridDimension::WrapObject(JSContext* aCx,
35                                     JS::Handle<JSObject*> aGivenProto) {
36   return GridDimension_Binding::Wrap(aCx, this, aGivenProto);
37 }
38 
Lines() const39 GridLines* GridDimension::Lines() const { return mLines; }
40 
Tracks() const41 GridTracks* GridDimension::Tracks() const { return mTracks; }
42 
SetTrackInfo(const ComputedGridTrackInfo * aTrackInfo)43 void GridDimension::SetTrackInfo(const ComputedGridTrackInfo* aTrackInfo) {
44   mTracks->SetTrackInfo(aTrackInfo);
45 }
46 
SetLineInfo(const ComputedGridTrackInfo * aTrackInfo,const ComputedGridLineInfo * aLineInfo,const nsTArray<RefPtr<GridArea>> & aAreas,bool aIsRow)47 void GridDimension::SetLineInfo(const ComputedGridTrackInfo* aTrackInfo,
48                                 const ComputedGridLineInfo* aLineInfo,
49                                 const nsTArray<RefPtr<GridArea>>& aAreas,
50                                 bool aIsRow) {
51   mLines->SetLineInfo(aTrackInfo, aLineInfo, aAreas, aIsRow);
52 }
53 
54 }  // namespace mozilla::dom
55