mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 666041 patch 5: Use flex-basis in place of main-size property, when computing the main size of a flex item. r=dbaron
This commit is contained in:
parent
551a753f47
commit
89dfb7e636
@ -2816,7 +2816,38 @@ nsLayoutUtils::ComputeSizeWithIntrinsicDimensions(
|
||||
nsSize aIntrinsicRatio, nsSize aCBSize,
|
||||
nsSize aMargin, nsSize aBorder, nsSize aPadding)
|
||||
{
|
||||
const nsStylePosition *stylePos = aFrame->GetStylePosition();
|
||||
const nsStylePosition* stylePos = aFrame->GetStylePosition();
|
||||
|
||||
// If we're a flex item, we'll compute our size a bit differently.
|
||||
const nsStyleCoord* widthStyleCoord = &(stylePos->mWidth);
|
||||
const nsStyleCoord* heightStyleCoord = &(stylePos->mHeight);
|
||||
|
||||
bool isFlexItem = aFrame->IsFlexItem();
|
||||
bool isHorizontalFlexItem = false;
|
||||
|
||||
#ifdef MOZ_FLEXBOX
|
||||
if (isFlexItem) {
|
||||
// Flex items use their "flex-basis" property in place of their main-size
|
||||
// property (e.g. "width") for sizing purposes, *unless* they have
|
||||
// "flex-basis:auto", in which case they use their main-size property after
|
||||
// all.
|
||||
uint32_t flexDirection =
|
||||
aFrame->GetParent()->GetStylePosition()->mFlexDirection;
|
||||
isHorizontalFlexItem =
|
||||
flexDirection == NS_STYLE_FLEX_DIRECTION_ROW ||
|
||||
flexDirection == NS_STYLE_FLEX_DIRECTION_ROW_REVERSE;
|
||||
|
||||
if (stylePos->mFlexBasis.GetUnit() != eStyleUnit_Auto) {
|
||||
if (isHorizontalFlexItem) {
|
||||
widthStyleCoord = &(stylePos->mFlexBasis);
|
||||
} else {
|
||||
heightStyleCoord = &(stylePos->mFlexBasis);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // MOZ_FLEXBOX
|
||||
|
||||
|
||||
// Handle intrinsic sizes and their interaction with
|
||||
// {min-,max-,}{width,height} according to the rules in
|
||||
// http://www.w3.org/TR/CSS21/visudet.html#min-max-widths
|
||||
@ -2825,8 +2856,8 @@ nsLayoutUtils::ComputeSizeWithIntrinsicDimensions(
|
||||
// a * (b / c) because of its reduced accuracy relative to a * b / c
|
||||
// or (a * b) / c (which are equivalent).
|
||||
|
||||
const bool isAutoWidth = stylePos->mWidth.GetUnit() == eStyleUnit_Auto;
|
||||
const bool isAutoHeight = IsAutoHeight(stylePos->mHeight, aCBSize.height);
|
||||
const bool isAutoWidth = widthStyleCoord->GetUnit() == eStyleUnit_Auto;
|
||||
const bool isAutoHeight = IsAutoHeight(*heightStyleCoord, aCBSize.height);
|
||||
|
||||
nsSize boxSizingAdjust(0,0);
|
||||
switch (stylePos->mBoxSizing) {
|
||||
@ -2844,7 +2875,7 @@ nsLayoutUtils::ComputeSizeWithIntrinsicDimensions(
|
||||
if (!isAutoWidth) {
|
||||
width = nsLayoutUtils::ComputeWidthValue(aRenderingContext,
|
||||
aFrame, aCBSize.width, boxSizingAdjust.width,
|
||||
boxSizingToMarginEdgeWidth, stylePos->mWidth);
|
||||
boxSizingToMarginEdgeWidth, *widthStyleCoord);
|
||||
}
|
||||
|
||||
if (stylePos->mMaxWidth.GetUnit() != eStyleUnit_None) {
|
||||
@ -2871,7 +2902,7 @@ nsLayoutUtils::ComputeSizeWithIntrinsicDimensions(
|
||||
if (!isAutoHeight) {
|
||||
height = nsLayoutUtils::ComputeHeightValue(aCBSize.height,
|
||||
boxSizingAdjust.height,
|
||||
stylePos->mHeight);
|
||||
*heightStyleCoord);
|
||||
}
|
||||
|
||||
if (!IsAutoHeight(stylePos->mMaxHeight, aCBSize.height)) {
|
||||
|
@ -3873,13 +3873,40 @@ nsFrame::ComputeSize(nsRenderingContext *aRenderingContext,
|
||||
}
|
||||
nscoord boxSizingToMarginEdgeWidth =
|
||||
aMargin.width + aBorder.width + aPadding.width - boxSizingAdjust.width;
|
||||
const nsStyleCoord* widthStyleCoord = &(stylePos->mWidth);
|
||||
const nsStyleCoord* heightStyleCoord = &(stylePos->mHeight);
|
||||
|
||||
bool isFlexItem = IsFlexItem();
|
||||
bool isHorizontalFlexItem = false;
|
||||
|
||||
#ifdef MOZ_FLEXBOX
|
||||
if (isFlexItem) {
|
||||
// Flex items use their "flex-basis" property in place of their main-size
|
||||
// property (e.g. "width") for sizing purposes, *unless* they have
|
||||
// "flex-basis:auto", in which case they use their main-size property after
|
||||
// all.
|
||||
uint32_t flexDirection = mParent->GetStylePosition()->mFlexDirection;
|
||||
isHorizontalFlexItem =
|
||||
flexDirection == NS_STYLE_FLEX_DIRECTION_ROW ||
|
||||
flexDirection == NS_STYLE_FLEX_DIRECTION_ROW_REVERSE;
|
||||
|
||||
if (stylePos->mFlexBasis.GetUnit() != eStyleUnit_Auto) {
|
||||
if (isHorizontalFlexItem) {
|
||||
widthStyleCoord = &(stylePos->mFlexBasis);
|
||||
} else {
|
||||
heightStyleCoord = &(stylePos->mFlexBasis);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // MOZ_FLEXBOX
|
||||
|
||||
// Compute width
|
||||
|
||||
if (stylePos->mWidth.GetUnit() != eStyleUnit_Auto) {
|
||||
if (widthStyleCoord->GetUnit() != eStyleUnit_Auto) {
|
||||
result.width =
|
||||
nsLayoutUtils::ComputeWidthValue(aRenderingContext, this,
|
||||
aCBSize.width, boxSizingAdjust.width, boxSizingToMarginEdgeWidth,
|
||||
stylePos->mWidth);
|
||||
*widthStyleCoord);
|
||||
}
|
||||
|
||||
if (stylePos->mMaxWidth.GetUnit() != eStyleUnit_None) {
|
||||
@ -3907,11 +3934,11 @@ nsFrame::ComputeSize(nsRenderingContext *aRenderingContext,
|
||||
result.width = NS_MAX(minWidth, result.width);
|
||||
|
||||
// Compute height
|
||||
if (!nsLayoutUtils::IsAutoHeight(stylePos->mHeight, aCBSize.height)) {
|
||||
if (!nsLayoutUtils::IsAutoHeight(*heightStyleCoord, aCBSize.height)) {
|
||||
result.height =
|
||||
nsLayoutUtils::ComputeHeightValue(aCBSize.height,
|
||||
boxSizingAdjust.height,
|
||||
stylePos->mHeight);
|
||||
*heightStyleCoord);
|
||||
}
|
||||
|
||||
if (result.height != NS_UNCONSTRAINEDSIZE) {
|
||||
|
@ -2092,6 +2092,12 @@ public:
|
||||
*/
|
||||
virtual bool IsLeaf() const;
|
||||
|
||||
/**
|
||||
* Is this a flex item? (Is the parent a flex container frame?)
|
||||
*/
|
||||
bool IsFlexItem() const
|
||||
{ return mParent && mParent->GetType() == nsGkAtoms::flexContainerFrame; }
|
||||
|
||||
/**
|
||||
* This must only be called on frames that are display roots (see
|
||||
* nsLayoutUtils::GetDisplayRootFrame). This causes all invalidates
|
||||
|
Loading…
Reference in New Issue
Block a user