/src/mozilla-central/dom/flex/FlexLine.cpp
Line | Count | Source (jump to first uncovered line) |
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 "FlexLine.h" |
8 | | |
9 | | #include "FlexItem.h" |
10 | | #include "mozilla/dom/FlexBinding.h" |
11 | | #include "nsFlexContainerFrame.h" |
12 | | |
13 | | namespace mozilla { |
14 | | namespace dom { |
15 | | |
16 | | NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(FlexLine, mParent, mItems) |
17 | | NS_IMPL_CYCLE_COLLECTING_ADDREF(FlexLine) |
18 | | NS_IMPL_CYCLE_COLLECTING_RELEASE(FlexLine) |
19 | 0 | NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(FlexLine) |
20 | 0 | NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY |
21 | 0 | NS_INTERFACE_MAP_ENTRY(nsISupports) |
22 | 0 | NS_INTERFACE_MAP_END |
23 | | |
24 | | FlexLine::FlexLine(Flex* aParent, |
25 | | const ComputedFlexLineInfo* aLine) |
26 | | : mParent(aParent) |
27 | 0 | { |
28 | 0 | MOZ_ASSERT(aLine, |
29 | 0 | "Should never be instantiated with a null ComputedFlexLineInfo."); |
30 | 0 |
|
31 | 0 | // Eagerly copy values from aLine, because we're not |
32 | 0 | // going to keep it around. |
33 | 0 | switch (aLine->mGrowthState) { |
34 | 0 | case ComputedFlexLineInfo::GrowthState::SHRINKING: |
35 | 0 | mGrowthState = FlexLineGrowthState::Shrinking; |
36 | 0 | break; |
37 | 0 |
|
38 | 0 | case ComputedFlexLineInfo::GrowthState::GROWING: |
39 | 0 | mGrowthState = FlexLineGrowthState::Growing; |
40 | 0 | break; |
41 | 0 |
|
42 | 0 | default: |
43 | 0 | mGrowthState = FlexLineGrowthState::Unchanged; |
44 | 0 | }; |
45 | 0 |
|
46 | 0 | // Convert all the app unit values into css pixels. |
47 | 0 | mCrossStart = nsPresContext::AppUnitsToDoubleCSSPixels( |
48 | 0 | aLine->mCrossStart); |
49 | 0 | mCrossSize = nsPresContext::AppUnitsToDoubleCSSPixels( |
50 | 0 | aLine->mCrossSize); |
51 | 0 | mFirstBaselineOffset = nsPresContext::AppUnitsToDoubleCSSPixels( |
52 | 0 | aLine->mFirstBaselineOffset); |
53 | 0 | mLastBaselineOffset = nsPresContext::AppUnitsToDoubleCSSPixels( |
54 | 0 | aLine->mLastBaselineOffset); |
55 | 0 |
|
56 | 0 | mItems.SetLength(aLine->mItems.Length()); |
57 | 0 | uint32_t index = 0; |
58 | 0 | for (auto&& i : aLine->mItems) { |
59 | 0 | FlexItem* item = new FlexItem(this, &i); |
60 | 0 | mItems.ElementAt(index) = item; |
61 | 0 | index++; |
62 | 0 | } |
63 | 0 | } |
64 | | |
65 | | JSObject* |
66 | | FlexLine::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) |
67 | 0 | { |
68 | 0 | return FlexLine_Binding::Wrap(aCx, this, aGivenProto); |
69 | 0 | } |
70 | | |
71 | | FlexLineGrowthState |
72 | | FlexLine::GrowthState() const |
73 | 0 | { |
74 | 0 | return mGrowthState; |
75 | 0 | } |
76 | | |
77 | | double |
78 | | FlexLine::CrossStart() const |
79 | 0 | { |
80 | 0 | return mCrossStart; |
81 | 0 | } |
82 | | |
83 | | double |
84 | | FlexLine::CrossSize() const |
85 | 0 | { |
86 | 0 | return mCrossSize; |
87 | 0 | } |
88 | | |
89 | | double |
90 | | FlexLine::FirstBaselineOffset() const |
91 | 0 | { |
92 | 0 | return mFirstBaselineOffset; |
93 | 0 | } |
94 | | |
95 | | double |
96 | | FlexLine::LastBaselineOffset() const |
97 | 0 | { |
98 | 0 | return mLastBaselineOffset; |
99 | 0 | } |
100 | | |
101 | | void |
102 | | FlexLine::GetItems(nsTArray<RefPtr<FlexItem>>& aResult) |
103 | 0 | { |
104 | 0 | aResult.AppendElements(mItems); |
105 | 0 | } |
106 | | |
107 | | } // namespace dom |
108 | | } // namespace mozilla |