Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- layout/base/nsLayoutUtils.cpp.orig 2015-09-10 09:35:50.000000000 +0000
- +++ layout/base/nsLayoutUtils.cpp 2015-09-20 10:55:01.000000000 +0000
- @@ -3516,8 +3516,8 @@ enum ObjectDimensionType { eWidth, eHeig
- static nscoord
- ComputeMissingDimension(const nsSize& aDefaultObjectSize,
- const nsSize& aIntrinsicRatio,
- - const Maybe<nscoord>& aSpecifiedWidth,
- - const Maybe<nscoord>& aSpecifiedHeight,
- + const nscoord& aSpecifiedWidth,
- + const nscoord& aSpecifiedHeight,
- ObjectDimensionType aDimensionToCompute)
- {
- // The "default sizing algorithm" computes the missing dimension as follows:
- @@ -3531,10 +3531,10 @@ ComputeMissingDimension(const nsSize& aD
- nscoord knownDimensionSize;
- float ratio;
- if (aDimensionToCompute == eWidth) {
- - knownDimensionSize = *aSpecifiedHeight;
- + knownDimensionSize = aSpecifiedHeight;
- ratio = aIntrinsicRatio.width / aIntrinsicRatio.height;
- } else {
- - knownDimensionSize = *aSpecifiedWidth;
- + knownDimensionSize = aSpecifiedWidth;
- ratio = aIntrinsicRatio.height / aIntrinsicRatio.width;
- }
- return NSCoordSaturatingNonnegativeMultiply(knownDimensionSize, ratio);
- @@ -3575,8 +3575,8 @@ ComputeMissingDimension(const nsSize& aD
- * outparam, and we let the caller figure out the size (using a contain
- * constraint).
- */
- -static Maybe<nsSize>
- -MaybeComputeObjectFitNoneSize(const nsSize& aDefaultObjectSize,
- +static nsSize
- +ComputeObjectFitNoneSize(const nsSize& aDefaultObjectSize,
- const IntrinsicSize& aIntrinsicSize,
- const nsSize& aIntrinsicRatio)
- {
- @@ -3584,31 +3584,30 @@ MaybeComputeObjectFitNoneSize(const nsSi
- // if its intrinsic dimensions were given as the specified size."
- //
- // So, first we check if we have an intrinsic height and/or width:
- - Maybe<nscoord> specifiedWidth;
- + nscoord specifiedWidth = (nscoord)0;
- if (aIntrinsicSize.width.GetUnit() == eStyleUnit_Coord) {
- - specifiedWidth.emplace(aIntrinsicSize.width.GetCoordValue());
- + specifiedWidth = aIntrinsicSize.width.GetCoordValue();
- }
- - Maybe<nscoord> specifiedHeight;
- + nscoord specifiedHeight = (nscoord)0;
- if (aIntrinsicSize.height.GetUnit() == eStyleUnit_Coord) {
- - specifiedHeight.emplace(aIntrinsicSize.height.GetCoordValue());
- + specifiedHeight = aIntrinsicSize.height.GetCoordValue();
- }
- - Maybe<nsSize> noneSize; // (the value we'll return)
- - if (specifiedWidth || specifiedHeight) {
- + nsSize noneSize; // (the value we'll return)
- + if (specifiedWidth != 0 || specifiedHeight != 0) {
- // We have at least one specified dimension; use whichever dimension is
- // specified, and compute the other one using our intrinsic ratio, or (if
- // no valid ratio) using the default object size.
- - noneSize.emplace();
- - noneSize->width = specifiedWidth ?
- - *specifiedWidth :
- + noneSize.width = specifiedWidth ?
- + specifiedWidth :
- ComputeMissingDimension(aDefaultObjectSize, aIntrinsicRatio,
- specifiedWidth, specifiedHeight,
- eWidth);
- - noneSize->height = specifiedHeight ?
- - *specifiedHeight :
- + noneSize.height = specifiedHeight ?
- + specifiedHeight :
- ComputeMissingDimension(aDefaultObjectSize, aIntrinsicRatio,
- specifiedWidth, specifiedHeight,
- eHeight);
- @@ -3637,62 +3636,41 @@ ComputeConcreteObjectSize(const nsSize&
- return aConstraintSize;
- }
- - // The type of constraint to compute (cover/contain), if needed:
- - Maybe<nsImageRenderer::FitType> fitType;
- -
- Maybe<nsSize> noneSize;
- - if (aObjectFit == NS_STYLE_OBJECT_FIT_NONE ||
- - aObjectFit == NS_STYLE_OBJECT_FIT_SCALE_DOWN) {
- - noneSize = MaybeComputeObjectFitNoneSize(aConstraintSize, aIntrinsicSize,
- - aIntrinsicRatio);
- - if (!noneSize || aObjectFit == NS_STYLE_OBJECT_FIT_SCALE_DOWN) {
- - // Need to compute a 'CONTAIN' constraint (either for the 'none' size
- - // itself, or for comparison w/ the 'none' size to resolve 'scale-down'.)
- - fitType.emplace(nsImageRenderer::CONTAIN);
- - }
- - } else if (aObjectFit == NS_STYLE_OBJECT_FIT_COVER) {
- - fitType.emplace(nsImageRenderer::COVER);
- - } else if (aObjectFit == NS_STYLE_OBJECT_FIT_CONTAIN) {
- - fitType.emplace(nsImageRenderer::CONTAIN);
- - }
- -
- Maybe<nsSize> constrainedSize;
- - if (fitType) {
- - constrainedSize.emplace(
- - nsImageRenderer::ComputeConstrainedSize(aConstraintSize,
- - aIntrinsicRatio,
- - *fitType));
- - }
- + Maybe<nsImageRenderer::FitType> fitType;
- - // Now, we should have all the sizing information that we need.
- switch (aObjectFit) {
- - // skipping NS_STYLE_OBJECT_FIT_FILL; we handled it w/ early-return.
- - case NS_STYLE_OBJECT_FIT_CONTAIN:
- - case NS_STYLE_OBJECT_FIT_COVER:
- - MOZ_ASSERT(constrainedSize);
- - return *constrainedSize;
- -
- case NS_STYLE_OBJECT_FIT_NONE:
- - if (noneSize) {
- + noneSize.emplace(ComputeObjectFitNoneSize(aConstraintSize, aIntrinsicSize,
- + aIntrinsicRatio));
- + if (noneSize)
- return *noneSize;
- - }
- - MOZ_ASSERT(constrainedSize);
- - return *constrainedSize;
- + fitType.emplace(nsImageRenderer::CONTAIN);
- case NS_STYLE_OBJECT_FIT_SCALE_DOWN:
- - MOZ_ASSERT(constrainedSize);
- - if (noneSize) {
- - constrainedSize->width =
- - std::min(constrainedSize->width, noneSize->width);
- - constrainedSize->height =
- - std::min(constrainedSize->height, noneSize->height);
- - }
- - return *constrainedSize;
- + fitType.emplace(nsImageRenderer::CONTAIN);
- + constrainedSize->width =
- + std::min(constrainedSize->width, noneSize->width);
- + constrainedSize->height =
- + std::min(constrainedSize->height, noneSize->height);
- +
- + case NS_STYLE_OBJECT_FIT_COVER:
- + fitType.emplace(nsImageRenderer::COVER);
- - default:
- - MOZ_ASSERT_UNREACHABLE("Unexpected enum value for 'object-fit'");
- - return aConstraintSize; // fall back to (default) 'fill' behavior
- + case NS_STYLE_OBJECT_FIT_CONTAIN:
- + fitType.emplace(nsImageRenderer::CONTAIN);
- + }
- + constrainedSize.emplace(nsImageRenderer::ComputeConstrainedSize(aConstraintSize,
- + aIntrinsicRatio, *fitType));
- +
- + if (constrainedSize) {
- + return *constrainedSize;
- + } else {
- + MOZ_ASSERT_UNREACHABLE("Unexpected enum value for 'object-fit'");
- + return aConstraintSize; // fall back to (default) 'fill' behavior
- }
- +
- }
- // (Helper for HasInitialObjectFitAndPosition, to check
- @@ -4524,7 +4502,7 @@ nsLayoutUtils::ComputeISizeValue(
- NS_PRECONDITION(aContainingBlockISize >= 0,
- "inline-size less than zero");
- - nscoord result;
- + nscoord result = (nscoord)0;
- if (aCoord.IsCoordPercentCalcUnit()) {
- result = nsRuleNode::ComputeCoordPercentCalc(aCoord,
- aContainingBlockISize);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement