2017-11-16 00:20:35 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "Flex.h"
|
|
|
|
|
2018-10-17 23:22:26 +03:00
|
|
|
#include "FlexLineValues.h"
|
2017-11-16 00:20:35 +03:00
|
|
|
#include "mozilla/dom/FlexBinding.h"
|
|
|
|
#include "nsFlexContainerFrame.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(Flex, mParent, mLines)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(Flex)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(Flex)
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Flex)
|
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
|
|
|
Flex::Flex(Element* aParent, nsFlexContainerFrame* aFrame) : mParent(aParent) {
|
|
|
|
MOZ_ASSERT(aFrame,
|
|
|
|
"Should never be instantiated with a null nsFlexContainerFrame");
|
|
|
|
|
2017-10-18 02:27:35 +03:00
|
|
|
// Eagerly create property values from aFrame, because we're not
|
|
|
|
// going to keep it around.
|
|
|
|
const ComputedFlexContainerInfo* containerInfo =
|
|
|
|
aFrame->GetFlexContainerInfo();
|
|
|
|
MOZ_ASSERT(containerInfo, "Should only be passed a frame with info.");
|
|
|
|
|
|
|
|
mLines.SetLength(containerInfo->mLines.Length());
|
|
|
|
uint32_t index = 0;
|
|
|
|
for (auto&& l : containerInfo->mLines) {
|
2018-10-17 23:22:26 +03:00
|
|
|
FlexLineValues* line = new FlexLineValues(this, &l);
|
2017-10-18 02:27:35 +03:00
|
|
|
mLines.ElementAt(index) = line;
|
|
|
|
index++;
|
|
|
|
}
|
2018-10-17 23:23:09 +03:00
|
|
|
|
|
|
|
mMainAxisDirection = containerInfo->mMainAxisDirection;
|
|
|
|
mCrossAxisDirection = containerInfo->mCrossAxisDirection;
|
2017-11-16 00:20:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
JSObject* Flex::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return Flex_Binding::Wrap(aCx, this, aGivenProto);
|
2017-11-16 00:20:35 +03:00
|
|
|
}
|
|
|
|
|
2018-10-17 23:22:26 +03:00
|
|
|
void Flex::GetLines(nsTArray<RefPtr<FlexLineValues>>& aResult) {
|
2017-11-16 00:20:35 +03:00
|
|
|
aResult.AppendElements(mLines);
|
|
|
|
}
|
|
|
|
|
2018-10-17 23:22:46 +03:00
|
|
|
FlexPhysicalDirection Flex::MainAxisDirection() const {
|
|
|
|
return mMainAxisDirection;
|
|
|
|
}
|
|
|
|
|
|
|
|
FlexPhysicalDirection Flex::CrossAxisDirection() const {
|
|
|
|
return mCrossAxisDirection;
|
|
|
|
}
|
|
|
|
|
2017-11-16 00:20:35 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|