forked from mirrors/gecko-dev
Bug 1409083 Part 4: Actually set values for exposed Flex properties. r=dholbert
MozReview-Commit-ID: HfSmwzzQYOh --HG-- extra : rebase_source : 1594f7434e11f0a92831faf82ecdf905e9640818
This commit is contained in:
parent
d92c5394a0
commit
f75ea9819f
5 changed files with 106 additions and 16 deletions
|
|
@ -28,7 +28,19 @@ Flex::Flex(Element* aParent,
|
|||
MOZ_ASSERT(aFrame,
|
||||
"Should never be instantiated with a null nsFlexContainerFrame");
|
||||
|
||||
// Eagerly create mLines.
|
||||
// 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) {
|
||||
FlexLine* line = new FlexLine(this, &l);
|
||||
mLines.ElementAt(index) = line;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
JSObject*
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include "FlexItem.h"
|
||||
|
||||
#include "mozilla/dom/FlexBinding.h"
|
||||
#include "nsFlexContainerFrame.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
|
@ -19,9 +20,30 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(FlexItem)
|
|||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
FlexItem::FlexItem(FlexLine* aParent)
|
||||
FlexItem::FlexItem(FlexLine* aParent,
|
||||
const ComputedFlexItemInfo* aItem)
|
||||
: mParent(aParent)
|
||||
{
|
||||
MOZ_ASSERT(aItem,
|
||||
"Should never be instantiated with a null ComputedFlexLineInfo.");
|
||||
|
||||
// Eagerly copy values from aItem, because we're not
|
||||
// going to keep it around.
|
||||
mNode = aItem->mNode;
|
||||
|
||||
// Convert app unit sizes to css pixel sizes.
|
||||
mMainBaseSize = nsPresContext::AppUnitsToDoubleCSSPixels(
|
||||
aItem->mMainBaseSize);
|
||||
mMainDeltaSize = nsPresContext::AppUnitsToDoubleCSSPixels(
|
||||
aItem->mMainDeltaSize);
|
||||
mMainMinSize = nsPresContext::AppUnitsToDoubleCSSPixels(
|
||||
aItem->mMainMinSize);
|
||||
mMainMaxSize = nsPresContext::AppUnitsToDoubleCSSPixels(
|
||||
aItem->mMainMaxSize);
|
||||
mCrossMinSize = nsPresContext::AppUnitsToDoubleCSSPixels(
|
||||
aItem->mCrossMinSize);
|
||||
mCrossMaxSize = nsPresContext::AppUnitsToDoubleCSSPixels(
|
||||
aItem->mCrossMaxSize);
|
||||
}
|
||||
|
||||
JSObject*
|
||||
|
|
@ -33,43 +55,43 @@ FlexItem::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
|||
nsINode*
|
||||
FlexItem::GetNode() const
|
||||
{
|
||||
return nullptr;
|
||||
return mNode;
|
||||
}
|
||||
|
||||
double
|
||||
FlexItem::MainBaseSize() const
|
||||
{
|
||||
return 0;
|
||||
return mMainBaseSize;
|
||||
}
|
||||
|
||||
double
|
||||
FlexItem::MainDeltaSize() const
|
||||
{
|
||||
return 0;
|
||||
return mMainDeltaSize;
|
||||
}
|
||||
|
||||
double
|
||||
FlexItem::MainMinSize() const
|
||||
{
|
||||
return 0;
|
||||
return mMainMinSize;
|
||||
}
|
||||
|
||||
double
|
||||
FlexItem::MainMaxSize() const
|
||||
{
|
||||
return 0;
|
||||
return mMainMaxSize;
|
||||
}
|
||||
|
||||
double
|
||||
FlexItem::CrossMinSize() const
|
||||
{
|
||||
return 0;
|
||||
return mCrossMinSize;
|
||||
}
|
||||
|
||||
double
|
||||
FlexItem::CrossMaxSize() const
|
||||
{
|
||||
return 0;
|
||||
return mCrossMaxSize;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@
|
|||
#include "nsISupports.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
struct ComputedFlexItemInfo;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
|
|
@ -20,7 +22,8 @@ class FlexItem : public nsISupports
|
|||
, public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
explicit FlexItem(FlexLine* aParent);
|
||||
explicit FlexItem(FlexLine* aParent,
|
||||
const ComputedFlexItemInfo* aItem);
|
||||
|
||||
protected:
|
||||
virtual ~FlexItem() = default;
|
||||
|
|
@ -45,6 +48,15 @@ public:
|
|||
|
||||
protected:
|
||||
RefPtr<FlexLine> mParent;
|
||||
RefPtr<nsINode> mNode;
|
||||
|
||||
// These sizes are all CSS pixel units.
|
||||
double mMainBaseSize;
|
||||
double mMainDeltaSize;
|
||||
double mMainMinSize;
|
||||
double mMainMaxSize;
|
||||
double mCrossMinSize;
|
||||
double mCrossMaxSize;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "FlexItem.h"
|
||||
#include "mozilla/dom/FlexBinding.h"
|
||||
#include "nsFlexContainerFrame.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
|
@ -20,9 +21,43 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(FlexLine)
|
|||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
FlexLine::FlexLine(Flex* aParent)
|
||||
FlexLine::FlexLine(Flex* aParent,
|
||||
const ComputedFlexLineInfo* aLine)
|
||||
: mParent(aParent)
|
||||
{
|
||||
MOZ_ASSERT(aLine,
|
||||
"Should never be instantiated with a null ComputedFlexLineInfo.");
|
||||
|
||||
// Eagerly copy values from aLine, because we're not
|
||||
// going to keep it around.
|
||||
switch (aLine->mGrowthState) {
|
||||
case ComputedFlexLineInfo::GrowthState::SHRINKING:
|
||||
mGrowthState = FlexLineGrowthState::Shrinking;
|
||||
break;
|
||||
|
||||
case ComputedFlexLineInfo::GrowthState::GROWING:
|
||||
mGrowthState = FlexLineGrowthState::Growing;
|
||||
break;
|
||||
|
||||
default:
|
||||
mGrowthState = FlexLineGrowthState::Unchanged;
|
||||
};
|
||||
|
||||
// Convert all the app unit values into css pixels.
|
||||
mCrossSize = nsPresContext::AppUnitsToDoubleCSSPixels(
|
||||
aLine->mCrossSize);
|
||||
mFirstBaselineOffset = nsPresContext::AppUnitsToDoubleCSSPixels(
|
||||
aLine->mFirstBaselineOffset);
|
||||
mLastBaselineOffset = nsPresContext::AppUnitsToDoubleCSSPixels(
|
||||
aLine->mLastBaselineOffset);
|
||||
|
||||
mItems.SetLength(aLine->mItems.Length());
|
||||
uint32_t index = 0;
|
||||
for (auto&& i : aLine->mItems) {
|
||||
FlexItem* item = new FlexItem(this, &i);
|
||||
mItems.ElementAt(index) = item;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
JSObject*
|
||||
|
|
@ -34,25 +69,25 @@ FlexLine::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
|||
FlexLineGrowthState
|
||||
FlexLine::GrowthState() const
|
||||
{
|
||||
return FlexLineGrowthState::Unchanged;
|
||||
return mGrowthState;
|
||||
}
|
||||
|
||||
double
|
||||
FlexLine::CrossSize() const
|
||||
{
|
||||
return 0;
|
||||
return mCrossSize;
|
||||
}
|
||||
|
||||
double
|
||||
FlexLine::FirstBaselineOffset() const
|
||||
{
|
||||
return 0;
|
||||
return mFirstBaselineOffset;
|
||||
}
|
||||
|
||||
double
|
||||
FlexLine::LastBaselineOffset() const
|
||||
{
|
||||
return 0;
|
||||
return mLastBaselineOffset;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@
|
|||
#include "nsISupports.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
struct ComputedFlexLineInfo;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
|
|
@ -21,7 +23,8 @@ class FlexLine : public nsISupports
|
|||
, public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
explicit FlexLine(Flex* aParent);
|
||||
explicit FlexLine(Flex* aParent,
|
||||
const ComputedFlexLineInfo* aLine);
|
||||
|
||||
protected:
|
||||
virtual ~FlexLine() = default;
|
||||
|
|
@ -45,6 +48,12 @@ public:
|
|||
|
||||
protected:
|
||||
RefPtr<Flex> mParent;
|
||||
|
||||
FlexLineGrowthState mGrowthState;
|
||||
double mCrossSize;
|
||||
double mFirstBaselineOffset;
|
||||
double mLastBaselineOffset;
|
||||
|
||||
nsTArray<RefPtr<FlexItem>> mItems;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue