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 "GridTrack.h"
8 
9 #include "GridTracks.h"
10 #include "mozilla/dom/GridBinding.h"
11 
12 namespace mozilla::dom {
13 
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(GridTrack,mParent)14 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(GridTrack, mParent)
15 NS_IMPL_CYCLE_COLLECTING_ADDREF(GridTrack)
16 NS_IMPL_CYCLE_COLLECTING_RELEASE(GridTrack)
17 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(GridTrack)
18   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
19   NS_INTERFACE_MAP_ENTRY(nsISupports)
20 NS_INTERFACE_MAP_END
21 
22 GridTrack::GridTrack(GridTracks* aParent)
23     : mParent(aParent),
24       mStart(0.0),
25       mBreadth(0.0),
26       mType(GridDeclaration::Implicit),
27       mState(GridTrackState::Static) {
28   MOZ_ASSERT(aParent, "Should never be instantiated with a null GridTracks");
29 }
30 
31 GridTrack::~GridTrack() = default;
32 
WrapObject(JSContext * aCx,JS::Handle<JSObject * > aGivenProto)33 JSObject* GridTrack::WrapObject(JSContext* aCx,
34                                 JS::Handle<JSObject*> aGivenProto) {
35   return GridTrack_Binding::Wrap(aCx, this, aGivenProto);
36 }
37 
Start() const38 double GridTrack::Start() const { return mStart; }
39 
Breadth() const40 double GridTrack::Breadth() const { return mBreadth; }
41 
Type() const42 GridDeclaration GridTrack::Type() const { return mType; }
43 
State() const44 GridTrackState GridTrack::State() const { return mState; }
45 
SetTrackValues(double aStart,double aBreadth,GridDeclaration aType,GridTrackState aState)46 void GridTrack::SetTrackValues(double aStart, double aBreadth,
47                                GridDeclaration aType, GridTrackState aState) {
48   mStart = aStart;
49   mBreadth = aBreadth;
50   mType = aType;
51   mState = aState;
52 }
53 
54 }  // namespace mozilla::dom
55