author | Robert Longson <longsonr@gmail.com> |
Tue, 26 Oct 2010 09:19:31 +0100 | |
changeset 57013 | 459b7ba2ab709f5d475e9347186c05b17301f833 |
parent 57012 | 81da4980adaa5426644fca2f3f49a2bf11e48560 |
child 57014 | 08763c8d26c3b602b7ceaaf305689a2e3536f369 |
push id | 16757 |
push user | dgottwald@mozilla.com |
push date | Sat, 06 Nov 2010 13:55:43 +0000 |
treeherder | mozilla-central@459b7ba2ab70 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | dholbert, roc |
bugs | 605626 |
milestone | 2.0b8pre |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/layout/svg/base/src/nsSVGImageFrame.cpp +++ b/layout/svg/base/src/nsSVGImageFrame.cpp @@ -110,17 +110,17 @@ public: #ifdef DEBUG NS_IMETHOD GetFrameName(nsAString& aResult) const { return MakeFrameName(NS_LITERAL_STRING("SVGImage"), aResult); } #endif private: - gfxMatrix GetImageTransform(); + gfxMatrix GetImageTransform(PRInt32 aNativeWidth, PRInt32 aNativeHeight); nsCOMPtr<imgIDecoderObserver> mListener; nsCOMPtr<imgIContainer> mImageContainer; friend class nsSVGImageListener; }; @@ -188,30 +188,26 @@ nsSVGImageFrame::AttributeChanged(PRInt3 return NS_OK; } return nsSVGPathGeometryFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType); } gfxMatrix -nsSVGImageFrame::GetImageTransform() +nsSVGImageFrame::GetImageTransform(PRInt32 aNativeWidth, PRInt32 aNativeHeight) { float x, y, width, height; nsSVGImageElement *element = static_cast<nsSVGImageElement*>(mContent); element->GetAnimatedLengthValues(&x, &y, &width, &height, nsnull); - PRInt32 nativeWidth, nativeHeight; - mImageContainer->GetWidth(&nativeWidth); - mImageContainer->GetHeight(&nativeHeight); - gfxMatrix viewBoxTM = nsSVGUtils::GetViewBoxTransform(element, width, height, - 0, 0, nativeWidth, nativeHeight, + 0, 0, aNativeWidth, aNativeHeight, element->mPreserveAspectRatio); return viewBoxTM * gfxMatrix().Translate(gfxPoint(x, y)) * GetCanvasTM(); } //---------------------------------------------------------------------- // nsISVGChildFrame methods: NS_IMETHODIMP @@ -236,16 +232,24 @@ nsSVGImageFrame::PaintSVG(nsSVGRenderSta imageLoader->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST, getter_AddRefs(currentRequest)); if (currentRequest) currentRequest->GetImage(getter_AddRefs(mImageContainer)); } if (mImageContainer) { + PRInt32 nativeWidth, nativeHeight; + mImageContainer->GetWidth(&nativeWidth); + mImageContainer->GetHeight(&nativeHeight); + + if (nativeWidth == 0 || nativeHeight == 0) { + return NS_ERROR_FAILURE; + } + if (mImageContainer->GetType() == imgIContainer::TYPE_VECTOR) { // <svg:image> not supported for SVG images yet. return NS_ERROR_FAILURE; } gfxContext* ctx = aContext->GetGfxContext(); gfxContextAutoSaveRestore autoRestorer(ctx); @@ -256,17 +260,18 @@ nsSVGImageFrame::PaintSVG(nsSVGRenderSta } nscoord appUnitsPerDevPx = PresContext()->AppUnitsPerDevPixel(); gfxFloat pageZoomFactor = nsPresContext::AppUnitsToFloatCSSPixels(appUnitsPerDevPx); // NOTE: We need to cancel out the effects of Full-Page-Zoom, or else // it'll get applied an extra time by DrawSingleUnscaledImage. - ctx->Multiply(GetImageTransform().Scale(pageZoomFactor, pageZoomFactor)); + ctx->Multiply(GetImageTransform(nativeWidth, nativeHeight). + Scale(pageZoomFactor, pageZoomFactor)); // fill-opacity doesn't affect <image>, so if we're allowed to // optimize group opacity, the opacity used for compositing the // image into the current canvas is just the group opacity. float opacity = 1.0f; if (nsSVGUtils::CanOptimizeOpacity(this)) { opacity = GetStyleDisplay()->mOpacity; } @@ -308,17 +313,21 @@ nsSVGImageFrame::PaintSVG(nsSVGRenderSta NS_IMETHODIMP_(nsIFrame*) nsSVGImageFrame::GetFrameForPoint(const nsPoint &aPoint) { if (GetStyleDisplay()->IsScrollableOverflow() && mImageContainer) { PRInt32 nativeWidth, nativeHeight; mImageContainer->GetWidth(&nativeWidth); mImageContainer->GetHeight(&nativeHeight); - if (!nsSVGUtils::HitTestRect(GetImageTransform(), + if (nativeWidth == 0 || nativeHeight == 0) { + return nsnull; + } + + if (!nsSVGUtils::HitTestRect(GetImageTransform(nativeWidth, nativeHeight), 0, 0, nativeWidth, nativeHeight, PresContext()->AppUnitsToDevPixels(aPoint.x), PresContext()->AppUnitsToDevPixels(aPoint.y))) { return nsnull; } } return nsSVGPathGeometryFrame::GetFrameForPoint(aPoint);