Closed Bug 323669 Opened 19 years ago Closed 19 years ago

Percent attribute values in userSpace gradients don't work

Categories

(Core :: SVG, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: tor, Assigned: tor)

Details

Attachments

(2 files)

394 bytes, image/svg+xml
Details
6.39 KB, patch
scootermorris
: review+
Details | Diff | Splinter Review
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.
Attached image testcase
Attached patch patchSplinter Review
Assignee: general → tor
Status: NEW → ASSIGNED
Attachment #208886 - Flags: review?(scootermorris)
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 on attachment 208886 [details] [diff] [review]
patch

r=scooter with comment
Attachment #208886 - Flags: review?(scootermorris) → review+
Checked in with comment.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: