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