diff --git a/layout/painting/nsCSSRendering.cpp b/layout/painting/nsCSSRendering.cpp index 5537ee595122..62e42d051f82 100644 --- a/layout/painting/nsCSSRendering.cpp +++ b/layout/painting/nsCSSRendering.cpp @@ -2906,11 +2906,8 @@ nsCSSRendering::ComputeImageLayerPositioningArea(nsPresContext* aPresContext, return positionArea; } -// Implementation of the formula for computation of background-repeat round -// See http://dev.w3.org/csswg/css3-background/#the-background-size -// This function returns the adjusted size of the background image. -static nscoord -ComputeRoundedSize(nscoord aCurrentSize, nscoord aPositioningSize) +/* static */ nscoord +nsCSSRendering::ComputeRoundedSize(nscoord aCurrentSize, nscoord aPositioningSize) { float repeatCount = NS_roundf(float(aPositioningSize) / float(aCurrentSize)); if (repeatCount < 1.0f) { @@ -2971,7 +2968,9 @@ ComputeDrawnSizeForBackground(const CSSSizeOrRatio& aIntrinsicSize, // Calculate the rounded size only if the background-size computation // returned a correct size for the image. if (imageSize.width && aXRepeat == NS_STYLE_IMAGELAYER_REPEAT_ROUND) { - imageSize.width = ComputeRoundedSize(imageSize.width, aBgPositioningArea.width); + imageSize.width = + nsCSSRendering::ComputeRoundedSize(imageSize.width, + aBgPositioningArea.width); if (!isRepeatRoundInBothDimensions && aLayerSize.mHeightType == nsStyleImageLayers::Size::DimensionType::eAuto) { // Restore intrinsic rato @@ -2985,7 +2984,9 @@ ComputeDrawnSizeForBackground(const CSSSizeOrRatio& aIntrinsicSize, // Calculate the rounded size only if the background-size computation // returned a correct size for the image. if (imageSize.height && aYRepeat == NS_STYLE_IMAGELAYER_REPEAT_ROUND) { - imageSize.height = ComputeRoundedSize(imageSize.height, aBgPositioningArea.height); + imageSize.height = + nsCSSRendering::ComputeRoundedSize(imageSize.height, + aBgPositioningArea.height); if (!isRepeatRoundInBothDimensions && aLayerSize.mWidthType == nsStyleImageLayers::Size::DimensionType::eAuto) { // Restore intrinsic rato @@ -3020,16 +3021,10 @@ ComputeSpacedRepeatSize(nscoord aImageDimension, } } -/* ComputeBorderSpacedRepeatSize - * aImageDimension: the image width/height - * aAvailableSpace: the background positioning area width/height - * aSpace: the space between each image - * Returns the image size plus gap size of app units for use as spacing - */ -static nscoord -ComputeBorderSpacedRepeatSize(nscoord aImageDimension, - nscoord aAvailableSpace, - nscoord& aSpace) +/* static */ nscoord +nsCSSRendering::ComputeBorderSpacedRepeatSize(nscoord aImageDimension, + nscoord aAvailableSpace, + nscoord& aSpace) { int32_t count = aAvailableSpace / aImageDimension; aSpace = (aAvailableSpace - aImageDimension * count) / (count + 1); diff --git a/layout/painting/nsCSSRendering.h b/layout/painting/nsCSSRendering.h index df0fb16d0e19..437c783a041f 100644 --- a/layout/painting/nsCSSRendering.h +++ b/layout/painting/nsCSSRendering.h @@ -337,6 +337,23 @@ struct nsCSSRendering { nsIFrame** aAttachedToFrame, bool* aOutTransformedFixed); + // Implementation of the formula for computation of background-repeat round + // See http://dev.w3.org/csswg/css3-background/#the-background-size + // This function returns the adjusted size of the background image. + static nscoord + ComputeRoundedSize(nscoord aCurrentSize, nscoord aPositioningSize); + + /* ComputeBorderSpacedRepeatSize + * aImageDimension: the image width/height + * aAvailableSpace: the background positioning area width/height + * aSpace: the space between each image + * Returns the image size plus gap size of app units for use as spacing + */ + static nscoord + ComputeBorderSpacedRepeatSize(nscoord aImageDimension, + nscoord aAvailableSpace, + nscoord& aSpace); + static nsBackgroundLayerState PrepareImageLayer(nsPresContext* aPresContext, nsIFrame* aForFrame, diff --git a/layout/painting/nsCSSRenderingGradients.h b/layout/painting/nsCSSRenderingGradients.h index e2cb1190d1d0..4a0cb4199818 100644 --- a/layout/painting/nsCSSRenderingGradients.h +++ b/layout/painting/nsCSSRenderingGradients.h @@ -10,6 +10,7 @@ #include "nsStyleStruct.h" #include "Units.h" #include "mozilla/Maybe.h" +#include "mozilla/gfx/2D.h" namespace mozilla { @@ -25,11 +26,11 @@ class DisplayListBuilder; // a color. struct ColorStop { ColorStop(): mPosition(0), mIsMidpoint(false) {} - ColorStop(double aPosition, bool aIsMidPoint, const Color& aColor) : + ColorStop(double aPosition, bool aIsMidPoint, const gfx::Color& aColor) : mPosition(aPosition), mIsMidpoint(aIsMidPoint), mColor(aColor) {} double mPosition; // along the gradient line; 0=start, 1=end bool mIsMidpoint; - Color mColor; + gfx::Color mColor; }; class nsCSSGradientRenderer final { diff --git a/layout/painting/nsImageRenderer.cpp b/layout/painting/nsImageRenderer.cpp index e597960bc48e..cc9f7b2a8d14 100644 --- a/layout/painting/nsImageRenderer.cpp +++ b/layout/painting/nsImageRenderer.cpp @@ -6,10 +6,25 @@ /* utility functions for drawing borders and backgrounds */ -#include "nsImageRenderer.h" #include "nsCSSRenderingGradients.h" + #include "mozilla/webrender/WebRenderAPI.h" +#include "gfxDrawable.h" +#include "ImageOps.h" +#include "nsContentUtils.h" +#include "nsCSSRendering.h" +#include "nsIFrame.h" +#include "nsImageRenderer.h" +#include "nsRenderingContext.h" +#include "nsSVGEffects.h" +#include "nsSVGIntegrationUtils.h" + +using namespace mozilla; +using namespace mozilla::gfx; +using namespace mozilla::image; +using namespace mozilla::layers; + nsSize CSSSizeOrRatio::ComputeConcreteSize() const { @@ -719,14 +734,16 @@ ComputeTile(nsRect& aFill, break; case NS_STYLE_BORDER_IMAGE_REPEAT_ROUND: tile.x = aFill.x; - tile.width = ComputeRoundedSize(aUnitSize.width, aFill.width); + tile.width = nsCSSRendering::ComputeRoundedSize(aUnitSize.width, + aFill.width); aRepeatSize.width = tile.width; break; case NS_STYLE_BORDER_IMAGE_REPEAT_SPACE: { nscoord space; aRepeatSize.width = - ComputeBorderSpacedRepeatSize(aUnitSize.width, aFill.width, space); + nsCSSRendering::ComputeBorderSpacedRepeatSize(aUnitSize.width, + aFill.width, space); tile.x = aFill.x + space; tile.width = aUnitSize.width; aFill.x = tile.x; @@ -750,14 +767,16 @@ ComputeTile(nsRect& aFill, break; case NS_STYLE_BORDER_IMAGE_REPEAT_ROUND: tile.y = aFill.y; - tile.height = ComputeRoundedSize(aUnitSize.height, aFill.height); + tile.height = nsCSSRendering::ComputeRoundedSize(aUnitSize.height, + aFill.height); aRepeatSize.height = tile.height; break; case NS_STYLE_BORDER_IMAGE_REPEAT_SPACE: { nscoord space; aRepeatSize.height = - ComputeBorderSpacedRepeatSize(aUnitSize.height, aFill.height, space); + nsCSSRendering::ComputeBorderSpacedRepeatSize(aUnitSize.height, + aFill.height, space); tile.y = aFill.y + space; tile.height = aUnitSize.height; aFill.y = tile.y;