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/. */
7 #include "FlexLineValues.h"
10 #include "FlexItemValues.h"
11 #include "mozilla/dom/FlexBinding.h"
12 #include "nsFlexContainerFrame.h"
14 namespace mozilla::dom
{
16 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(FlexLineValues
, mParent
, mItems
)
17 NS_IMPL_CYCLE_COLLECTING_ADDREF(FlexLineValues
)
18 NS_IMPL_CYCLE_COLLECTING_RELEASE(FlexLineValues
)
19 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(FlexLineValues
)
20 NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
21 NS_INTERFACE_MAP_ENTRY(nsISupports
)
24 FlexLineValues::FlexLineValues(Flex
* aParent
, const ComputedFlexLineInfo
* aLine
)
27 "Should never be instantiated with a null ComputedFlexLineInfo.");
29 // Eagerly copy values from aLine, because we're not
30 // going to keep it around.
31 mGrowthState
= aLine
->mGrowthState
;
33 // Convert all the app unit values into css pixels.
34 mCrossStart
= nsPresContext::AppUnitsToDoubleCSSPixels(aLine
->mCrossStart
);
35 mCrossSize
= nsPresContext::AppUnitsToDoubleCSSPixels(aLine
->mCrossSize
);
36 mFirstBaselineOffset
=
37 nsPresContext::AppUnitsToDoubleCSSPixels(aLine
->mFirstBaselineOffset
);
39 nsPresContext::AppUnitsToDoubleCSSPixels(aLine
->mLastBaselineOffset
);
41 mItems
.SetLength(aLine
->mItems
.Length());
43 for (auto&& i
: aLine
->mItems
) {
44 FlexItemValues
* item
= new FlexItemValues(this, &i
);
45 mItems
.ElementAt(index
) = item
;
50 JSObject
* FlexLineValues::WrapObject(JSContext
* aCx
,
51 JS::Handle
<JSObject
*> aGivenProto
) {
52 return FlexLineValues_Binding::Wrap(aCx
, this, aGivenProto
);
55 FlexLineGrowthState
FlexLineValues::GrowthState() const { return mGrowthState
; }
57 double FlexLineValues::CrossStart() const { return mCrossStart
; }
59 double FlexLineValues::CrossSize() const { return mCrossSize
; }
61 double FlexLineValues::FirstBaselineOffset() const {
62 return mFirstBaselineOffset
;
65 double FlexLineValues::LastBaselineOffset() const {
66 return mLastBaselineOffset
;
69 void FlexLineValues::GetItems(nsTArray
<RefPtr
<FlexItemValues
>>& aResult
) {
70 aResult
.AppendElements(mItems
);
73 } // namespace mozilla::dom