diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index 08283aa453ed..44fa40c91bc0 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -3953,15 +3953,6 @@ DrawBorderImage(nsPresContext* aPresContext, DrawResult result = DrawResult::SUCCESS; - // intrinsicSize.CanComputeConcreteSize() return false means we can not - // read intrinsic size from aStyleBorder.mBorderImageSource. - // In this condition, we pass imageSize(a resolved size comes from - // default sizing algorithm) to renderer as the viewport size. - Maybe svgViewportSize = intrinsicSize.CanComputeConcreteSize() ? - Nothing() : Some(imageSize); - bool hasIntrinsicRatio = intrinsicSize.HasRatio(); - renderer.PurgeCacheForViewportChange(svgViewportSize, hasIntrinsicRatio); - for (int i = LEFT; i <= RIGHT; i++) { for (int j = TOP; j <= BOTTOM; j++) { uint8_t fillStyleH, fillStyleV; @@ -4048,6 +4039,12 @@ DrawBorderImage(nsPresContext* aPresContext, continue; nsIntRect intSubArea = subArea.ToOutsidePixels(nsPresContext::AppUnitsPerCSSPixel()); + // intrinsicSize.CanComputeConcreteSize() return false means we can not + // read intrinsic size from aStyleBorder.mBorderImageSource. + // In this condition, we pass imageSize(a resolved size comes from + // default sizing algorithm) to renderer as the viewport size. + Maybe svgViewportSize = intrinsicSize.CanComputeConcreteSize() ? + Nothing() : Some(imageSize); result &= renderer.DrawBorderImageComponent(aPresContext, aRenderingContext, aDirtyRect, @@ -4057,7 +4054,7 @@ DrawBorderImage(nsPresContext* aPresContext, intSubArea.height), fillStyleH, fillStyleV, unitSize, j * (RIGHT + 1) + i, - svgViewportSize, hasIntrinsicRatio); + svgViewportSize); } } @@ -5684,8 +5681,7 @@ nsImageRenderer::DrawBorderImageComponent(nsPresContext* aPresContext, uint8_t aVFill, const nsSize& aUnitSize, uint8_t aIndex, - const Maybe& aSVGViewportSize, - const bool aHasIntrinsicRatio) + const Maybe& aSVGViewportSize) { if (!IsReady()) { NS_NOTREACHED("Ensure PrepareImage() has returned true before calling me"); @@ -5709,7 +5705,7 @@ nsImageRenderer::DrawBorderImageComponent(nsPresContext* aPresContext, // For those SVG image sources which don't have fixed aspect ratio (i.e. // without viewport size and viewBox), we should scale the source uniformly // after the viewport size is decided by "Default Sizing Algorithm". - if (!aHasIntrinsicRatio) { + if (!ComputeIntrinsicSize().HasRatio()) { drawFlags = drawFlags | imgIContainer::FLAG_FORCE_UNIFORM_SCALING; } // Retrieve or create the subimage we'll draw. @@ -5808,18 +5804,6 @@ nsImageRenderer::GetImage() return image.forget(); } -void -nsImageRenderer::PurgeCacheForViewportChange( - const Maybe& aSVGViewportSize, const bool aHasIntrinsicRatio) -{ - // Check if we should flush the cached data - only vector images need to do - // the check since they might not have fixed ratio. - if (mImageContainer && - mImageContainer->GetType() == imgIContainer::TYPE_VECTOR) { - mImage->PurgeCacheForViewportChange(aSVGViewportSize, aHasIntrinsicRatio); - } -} - #define MAX_BLUR_RADIUS 300 #define MAX_SPREAD_RADIUS 50 diff --git a/layout/base/nsCSSRendering.h b/layout/base/nsCSSRendering.h index e504f336b575..213060892357 100644 --- a/layout/base/nsCSSRendering.h +++ b/layout/base/nsCSSRendering.h @@ -236,8 +236,6 @@ public: * Pass Nothing() if we can read a valid viewport size or aspect-ratio from * the drawing image directly, otherwise, pass Some() with viewport size * evaluated from default sizing algorithm. - * aHasIntrinsicRatio is used to record if the source image has fixed - * intrinsic ratio. */ DrawResult DrawBorderImageComponent(nsPresContext* aPresContext, @@ -249,8 +247,7 @@ public: uint8_t aVFill, const nsSize& aUnitSize, uint8_t aIndex, - const mozilla::Maybe& aSVGViewportSize, - const bool aHasIntrinsicRatio); + const mozilla::Maybe& aSVGViewportSize); bool IsRasterImage(); bool IsAnimatedImage(); @@ -262,8 +259,6 @@ public: DrawResult PrepareResult() const { return mPrepareResult; } void SetExtendMode(mozilla::gfx::ExtendMode aMode) { mExtendMode = aMode; } void SetMaskOp(uint8_t aMaskOp) { mMaskOp = aMaskOp; } - void PurgeCacheForViewportChange(const mozilla::Maybe& aSVGViewportSize, - const bool aHasRatio); private: /** diff --git a/layout/reftests/border-image/reftest.list b/layout/reftests/border-image/reftest.list index b95f1afd8f4c..9c8b8f931906 100644 --- a/layout/reftests/border-image/reftest.list +++ b/layout/reftests/border-image/reftest.list @@ -89,4 +89,3 @@ fuzzy(125,5808) fuzzy-if(B2G,151,5809) == border-image-element.html border-image == svg-as-border-image-1c.html svg-as-border-image-1-ref.html == svg-as-border-image-2.html svg-as-border-image-2-ref.html == svg-as-border-image-3.html svg-as-border-image-3-ref.html -== svg-as-border-image-4.html svg-as-border-image-4-ref.html diff --git a/layout/reftests/border-image/svg-as-border-image-4-ref.html b/layout/reftests/border-image/svg-as-border-image-4-ref.html deleted file mode 100644 index 41833c316295..000000000000 --- a/layout/reftests/border-image/svg-as-border-image-4-ref.html +++ /dev/null @@ -1,18 +0,0 @@ - - -reference of svg-as-border-image - - - -
- - diff --git a/layout/reftests/border-image/svg-as-border-image-4.html b/layout/reftests/border-image/svg-as-border-image-4.html deleted file mode 100644 index 81574ba637ce..000000000000 --- a/layout/reftests/border-image/svg-as-border-image-4.html +++ /dev/null @@ -1,26 +0,0 @@ - - -test of svg-as-border-image - - - - -
- - diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 76db8ccf19a7..7b8ce971f799 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -1912,19 +1912,6 @@ nsStyleGradient::HasCalc() // -------------------- // CachedBorderImageData // -void -CachedBorderImageData::SetCachedSVGViewportSize( - const mozilla::Maybe& aSVGViewportSize) -{ - mCachedSVGViewportSize = aSVGViewportSize; -} - -const mozilla::Maybe& -CachedBorderImageData::GetCachedSVGViewportSize() -{ - return mCachedSVGViewportSize; -} - void CachedBorderImageData::PurgeCachedImages() { @@ -2308,26 +2295,6 @@ nsStyleImage::operator==(const nsStyleImage& aOther) const return true; } -void -nsStyleImage::PurgeCacheForViewportChange( - const mozilla::Maybe& aSVGViewportSize, - const bool aHasIntrinsicRatio) const -{ - EnsureCachedBIData(); - - // If we're redrawing with a different viewport-size than we used for our - // cached subimages, then we can't trust that our subimages are valid; - // any percent sizes/positions in our SVG doc may be different now. Purge! - // (We don't have to purge if the SVG document has an intrinsic ratio, - // though, because the actual size of elements in SVG documant's coordinate - // axis are fixed in this case.) - if (aSVGViewportSize != mCachedBIData->GetCachedSVGViewportSize() && - !aHasIntrinsicRatio) { - mCachedBIData->PurgeCachedImages(); - mCachedBIData->SetCachedSVGViewportSize(aSVGViewportSize); - } -} - // -------------------- // nsStyleImageLayers // diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index d2b3dde9f17b..cd479f0460f3 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -15,7 +15,6 @@ #include "mozilla/ArenaObjectID.h" #include "mozilla/Attributes.h" #include "mozilla/CSSVariableValues.h" -#include "mozilla/Maybe.h" #include "mozilla/SheetType.h" #include "mozilla/StaticPtr.h" #include "mozilla/StyleStructContext.h" @@ -250,19 +249,11 @@ enum nsStyleImageType { struct CachedBorderImageData { - // Caller are expected to ensure that the value of aSVGViewportSize is - // different from the cached one since the method won't do the check. - void SetCachedSVGViewportSize(const mozilla::Maybe& aSVGViewportSize); - const mozilla::Maybe& GetCachedSVGViewportSize(); void PurgeCachedImages(); void SetSubImage(uint8_t aIndex, imgIContainer* aSubImage); imgIContainer* GetSubImage(uint8_t aIndex); private: - // If this is a SVG border-image, we save the size of the SVG viewport that - // we used when rasterizing any cached border-image subimages. (The viewport - // size matters for percent-valued sizes & positions in inner SVG doc). - mozilla::Maybe mCachedSVGViewportSize; nsCOMArray mSubImages; }; @@ -378,9 +369,6 @@ struct nsStyleImage // during a border-image paint operation inline void SetSubImage(uint8_t aIndex, imgIContainer* aSubImage) const; inline imgIContainer* GetSubImage(uint8_t aIndex) const; - void PurgeCacheForViewportChange( - const mozilla::Maybe& aSVGViewportSize, - const bool aHasIntrinsicRatio) const; private: void DoCopy(const nsStyleImage& aOther);