daily pastebin goal
24%
SHARE
TWEET

firefox 37.0.2

a guest Sep 20th, 2015 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. --- layout/base/nsLayoutUtils.cpp.orig  2015-09-10 09:35:50.000000000 +0000
  3. +++ layout/base/nsLayoutUtils.cpp       2015-09-20 10:55:01.000000000 +0000
  4. @@ -3516,8 +3516,8 @@ enum ObjectDimensionType { eWidth, eHeig
  5.  static nscoord
  6.  ComputeMissingDimension(const nsSize& aDefaultObjectSize,
  7.                          const nsSize& aIntrinsicRatio,
  8. -                        const Maybe<nscoord>& aSpecifiedWidth,
  9. -                        const Maybe<nscoord>& aSpecifiedHeight,
  10. +                        const nscoord& aSpecifiedWidth,
  11. +                        const nscoord& aSpecifiedHeight,
  12.                          ObjectDimensionType aDimensionToCompute)
  13.  {
  14.    // The "default sizing algorithm" computes the missing dimension as follows:
  15. @@ -3531,10 +3531,10 @@ ComputeMissingDimension(const nsSize& aD
  16.      nscoord knownDimensionSize;
  17.      float ratio;
  18.      if (aDimensionToCompute == eWidth) {
  19. -      knownDimensionSize = *aSpecifiedHeight;
  20. +      knownDimensionSize = aSpecifiedHeight;
  21.        ratio = aIntrinsicRatio.width / aIntrinsicRatio.height;
  22.      } else {
  23. -      knownDimensionSize = *aSpecifiedWidth;
  24. +      knownDimensionSize = aSpecifiedWidth;
  25.        ratio = aIntrinsicRatio.height / aIntrinsicRatio.width;
  26.      }
  27.      return NSCoordSaturatingNonnegativeMultiply(knownDimensionSize, ratio);
  28. @@ -3575,8 +3575,8 @@ ComputeMissingDimension(const nsSize& aD
  29.   * outparam, and we let the caller figure out the size (using a contain
  30.   * constraint).
  31.   */
  32. -static Maybe<nsSize>
  33. -MaybeComputeObjectFitNoneSize(const nsSize& aDefaultObjectSize,
  34. +static nsSize
  35. +ComputeObjectFitNoneSize(const nsSize& aDefaultObjectSize,
  36.                                const IntrinsicSize& aIntrinsicSize,
  37.                                const nsSize& aIntrinsicRatio)
  38.  {
  39. @@ -3584,31 +3584,30 @@ MaybeComputeObjectFitNoneSize(const nsSi
  40.    // if its intrinsic dimensions were given as the specified size."
  41.    //
  42.    // So, first we check if we have an intrinsic height and/or width:
  43. -  Maybe<nscoord> specifiedWidth;
  44. +  nscoord specifiedWidth = (nscoord)0;
  45.    if (aIntrinsicSize.width.GetUnit() == eStyleUnit_Coord) {
  46. -    specifiedWidth.emplace(aIntrinsicSize.width.GetCoordValue());
  47. +    specifiedWidth = aIntrinsicSize.width.GetCoordValue();
  48.    }
  49.  
  50. -  Maybe<nscoord> specifiedHeight;
  51. +  nscoord specifiedHeight = (nscoord)0;
  52.    if (aIntrinsicSize.height.GetUnit() == eStyleUnit_Coord) {
  53. -    specifiedHeight.emplace(aIntrinsicSize.height.GetCoordValue());
  54. +    specifiedHeight = aIntrinsicSize.height.GetCoordValue();
  55.    }
  56.  
  57. -  Maybe<nsSize> noneSize; // (the value we'll return)
  58. -  if (specifiedWidth || specifiedHeight) {
  59. +  nsSize noneSize; // (the value we'll return)
  60. +  if (specifiedWidth != 0 || specifiedHeight != 0) {
  61.      // We have at least one specified dimension; use whichever dimension is
  62.      // specified, and compute the other one using our intrinsic ratio, or (if
  63.      // no valid ratio) using the default object size.
  64. -    noneSize.emplace();
  65.  
  66. -    noneSize->width = specifiedWidth ?
  67. -      *specifiedWidth :
  68. +    noneSize.width = specifiedWidth ?
  69. +      specifiedWidth :
  70.        ComputeMissingDimension(aDefaultObjectSize, aIntrinsicRatio,
  71.                                specifiedWidth, specifiedHeight,
  72.                                eWidth);
  73.  
  74. -    noneSize->height = specifiedHeight ?
  75. -      *specifiedHeight :
  76. +    noneSize.height = specifiedHeight ?
  77. +      specifiedHeight :
  78.        ComputeMissingDimension(aDefaultObjectSize, aIntrinsicRatio,
  79.                                specifiedWidth, specifiedHeight,
  80.                                eHeight);
  81. @@ -3637,62 +3636,41 @@ ComputeConcreteObjectSize(const nsSize&
  82.      return aConstraintSize;
  83.    }
  84.  
  85. -  // The type of constraint to compute (cover/contain), if needed:
  86. -  Maybe<nsImageRenderer::FitType> fitType;
  87. -
  88.    Maybe<nsSize> noneSize;
  89. -  if (aObjectFit == NS_STYLE_OBJECT_FIT_NONE ||
  90. -      aObjectFit == NS_STYLE_OBJECT_FIT_SCALE_DOWN) {
  91. -    noneSize = MaybeComputeObjectFitNoneSize(aConstraintSize, aIntrinsicSize,
  92. -                                             aIntrinsicRatio);
  93. -    if (!noneSize || aObjectFit == NS_STYLE_OBJECT_FIT_SCALE_DOWN) {
  94. -      // Need to compute a 'CONTAIN' constraint (either for the 'none' size
  95. -      // itself, or for comparison w/ the 'none' size to resolve 'scale-down'.)
  96. -      fitType.emplace(nsImageRenderer::CONTAIN);
  97. -    }
  98. -  } else if (aObjectFit == NS_STYLE_OBJECT_FIT_COVER) {
  99. -    fitType.emplace(nsImageRenderer::COVER);
  100. -  } else if (aObjectFit == NS_STYLE_OBJECT_FIT_CONTAIN) {
  101. -    fitType.emplace(nsImageRenderer::CONTAIN);
  102. -  }
  103. -
  104.    Maybe<nsSize> constrainedSize;
  105. -  if (fitType) {
  106. -    constrainedSize.emplace(
  107. -      nsImageRenderer::ComputeConstrainedSize(aConstraintSize,
  108. -                                              aIntrinsicRatio,
  109. -                                              *fitType));
  110. -  }
  111. +  Maybe<nsImageRenderer::FitType> fitType;
  112.  
  113. -  // Now, we should have all the sizing information that we need.
  114.    switch (aObjectFit) {
  115. -    // skipping NS_STYLE_OBJECT_FIT_FILL; we handled it w/ early-return.
  116. -    case NS_STYLE_OBJECT_FIT_CONTAIN:
  117. -    case NS_STYLE_OBJECT_FIT_COVER:
  118. -      MOZ_ASSERT(constrainedSize);
  119. -      return *constrainedSize;
  120. -
  121.      case NS_STYLE_OBJECT_FIT_NONE:
  122. -      if (noneSize) {
  123. +      noneSize.emplace(ComputeObjectFitNoneSize(aConstraintSize, aIntrinsicSize,
  124. +                                         aIntrinsicRatio));
  125. +      if (noneSize)
  126.          return *noneSize;
  127. -      }
  128. -      MOZ_ASSERT(constrainedSize);
  129. -      return *constrainedSize;
  130. +      fitType.emplace(nsImageRenderer::CONTAIN);
  131.  
  132.      case NS_STYLE_OBJECT_FIT_SCALE_DOWN:
  133. -      MOZ_ASSERT(constrainedSize);
  134. -      if (noneSize) {
  135. -        constrainedSize->width =
  136. -          std::min(constrainedSize->width, noneSize->width);
  137. -        constrainedSize->height =
  138. -          std::min(constrainedSize->height, noneSize->height);
  139. -      }
  140. -      return *constrainedSize;
  141. +      fitType.emplace(nsImageRenderer::CONTAIN);
  142. +      constrainedSize->width =
  143. +        std::min(constrainedSize->width, noneSize->width);
  144. +      constrainedSize->height =
  145. +        std::min(constrainedSize->height, noneSize->height);
  146. +
  147. +    case NS_STYLE_OBJECT_FIT_COVER:
  148. +      fitType.emplace(nsImageRenderer::COVER);
  149.  
  150. -    default:
  151. -      MOZ_ASSERT_UNREACHABLE("Unexpected enum value for 'object-fit'");
  152. -      return aConstraintSize; // fall back to (default) 'fill' behavior
  153. +    case NS_STYLE_OBJECT_FIT_CONTAIN:
  154. +      fitType.emplace(nsImageRenderer::CONTAIN);
  155. +  }
  156. +  constrainedSize.emplace(nsImageRenderer::ComputeConstrainedSize(aConstraintSize,
  157. +                                         aIntrinsicRatio, *fitType));
  158. +
  159. +  if (constrainedSize) {
  160. +    return *constrainedSize;
  161. +  } else {
  162. +    MOZ_ASSERT_UNREACHABLE("Unexpected enum value for 'object-fit'");
  163. +    return aConstraintSize; // fall back to (default) 'fill' behavior
  164.    }
  165. +
  166.  }
  167.  
  168.  // (Helper for HasInitialObjectFitAndPosition, to check
  169. @@ -4524,7 +4502,7 @@ nsLayoutUtils::ComputeISizeValue(
  170.    NS_PRECONDITION(aContainingBlockISize >= 0,
  171.                    "inline-size less than zero");
  172.  
  173. -  nscoord result;
  174. +  nscoord result = (nscoord)0;
  175.    if (aCoord.IsCoordPercentCalcUnit()) {
  176.      result = nsRuleNode::ComputeCoordPercentCalc(aCoord,
  177.                                                   aContainingBlockISize);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top