Last Comment Bug 323669 - Percent attribute values in userSpace gradients don't work
: Percent attribute values in userSpace gradients don't work
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: SVG (show other bugs)
: Trunk
: All All
: -- normal (vote)
: ---
Assigned To: tor
: Hixie (not reading bugmail)
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2006-01-16 14:16 PST by tor
Modified: 2006-01-20 10:29 PST (History)
2 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
testcase (394 bytes, image/svg+xml)
2006-01-16 14:18 PST, tor
no flags Details
patch (6.39 KB, patch)
2006-01-18 11:50 PST, tor
scootermorris: review+
Details | Diff | Splinter Review

Description tor 2006-01-16 14:16:58 PST
The attached example which has a userspace radial gradient without a radius specified (and thus gets the default value of 50%) doesn't draw properly.  This is due to CairoRadialGradient getting a value of 0.5 back from GetR() and handing this off to cairo.
Comment 1 tor 2006-01-16 14:18:05 PST
Created attachment 208670 [details]
testcase
Comment 2 tor 2006-01-18 11:50:43 PST
Created attachment 208886 [details] [diff] [review]
patch
Comment 3 Scooter Morris 2006-01-18 14:20:10 PST
Comment on attachment 208886 [details] [diff] [review]
patch

>Index: nsSVGGradientFrame.cpp
>===================================================================
>RCS file: /cvsroot/mozilla/layout/svg/base/src/nsSVGGradientFrame.cpp,v
>retrieving revision 1.21
>diff -u -8 -p -r1.21 nsSVGGradientFrame.cpp
>--- nsSVGGradientFrame.cpp	13 Jan 2006 18:20:00 -0000	1.21
>+++ nsSVGGradientFrame.cpp	18 Jan 2006 19:47:11 -0000
>@@ -148,16 +148,17 @@ protected:
>   PRBool checkURITarget();
>   //
>   NS_IMETHOD PrivateGetGradientUnits(nsIDOMSVGAnimatedEnumeration * *aEnum);
>   NS_IMETHOD PrivateGetSpreadMethod(nsIDOMSVGAnimatedEnumeration * *aValue);
>   //
> 
>   nsSVGGradientFrame                     *mNextGrad;
>   PRBool                                  mLoopFlag;
>+  nsCOMPtr<nsIContent>                    mSourceContent;
> 
> private:
>   // Cached values
>   nsCOMPtr<nsIDOMSVGAnimatedEnumeration>  mGradientUnits;
>   nsCOMPtr<nsIDOMSVGAnimatedEnumeration>  mSpreadMethod;
> 
>   nsAutoString                            mNextGradStr;
> 
>@@ -529,16 +530,20 @@ nsSVGGradientFrame::GetGradientTransform
>       float x, y, width, height;
>       rect->GetX(&x);
>       rect->GetY(&y);
>       rect->GetWidth(&width);
>       rect->GetHeight(&height);
>       NS_NewSVGMatrix(getter_AddRefs(bboxTransform),
>                       width, 0, 0, height, x, y);
>     }
>+  } else {
>+    nsIFrame *frame = nsnull;
>+    CallQueryInterface(aSource, &frame);
>+    mSourceContent = frame->GetContent();
>   }
> 
>   if (!bboxTransform)
>     NS_NewSVGMatrix(getter_AddRefs(bboxTransform));
> 
>   nsCOMPtr<nsIDOMSVGMatrix> gradientTransform;
>   // See if we need to get the value from another gradient
>   if (!checkURITarget(nsSVGAtoms::gradientTransform)) {
>@@ -860,56 +865,80 @@ NS_IMETHODIMP
> nsSVGLinearGradientFrame::GetX1(float *aX1)
> {
>   if (!mX1) {
>     PrivateGetX1(getter_AddRefs(mX1));
>     if (!mX1)
>       return NS_ERROR_FAILURE;
>     NS_ADD_SVGVALUE_OBSERVER(mX1);
>   }
>-  mX1->GetValue(aX1);

Could you comment this here?  Something along the lines of
  // We handle object bounding box units as part of GetGradientTransform,
  // but we need handle user space units as part of the individual get
  // routines.  Fixes bug 323669
>+  PRUint16 bbox;
>+  GetGradientUnits(&bbox);
>+  if (bbox == nsIDOMSVGGradientElement::SVG_GRUNITS_OBJECTBOUNDINGBOX) {
>+    mX1->GetValue(aX1);
>+  } else {
>+    *aX1 = nsSVGUtils::UserSpace(mSourceContent, mX1, nsSVGUtils::X);
>+  }
>   return NS_OK;
> }
>
Comment 4 Scooter Morris 2006-01-18 14:21:07 PST
Comment on attachment 208886 [details] [diff] [review]
patch

r=scooter with comment
Comment 5 tor 2006-01-18 15:50:54 PST
Checked in with comment.

Note You need to log in before you can comment on or make changes to this bug.