Closed Bug 378897 Opened 13 years ago Closed 13 years ago

foreignObject doesn't clip its content

Categories

(Core :: SVG, defect)

x86
Windows XP
defect
Not set

Tracking

()

RESOLVED FIXED

People

(Reporter: jwatt, Assigned: longsonr)

Details

(Keywords: regression, testcase)

Attachments

(2 files, 1 obsolete file)

The content of a foreignObject element should be clipped by the foreignObject's bounding box, certainly when overflow is set to hidden on the foreignObject.
Attached file testcase
Attached patch patch (obsolete) — Splinter Review
I think this is what is required.

Also makes the nsSVGImageFrame and nsSVGInnerSVGFrame more similar to nsSVGMarkerFrame i.e. only calculate the clip dimensions if you are actually going to clip.
Attachment #262959 - Flags: review?(jwatt)
Comment on attachment 262959 [details] [diff] [review]
patch

>+  if (GetStyleDisplay()->IsScrollableOverflow()) {
>+    float x, y, width, height;
>+    nsSVGElement *element = NS_STATIC_CAST(nsSVGElement*, mContent);
>+    element->GetAnimatedLengthValues(&x, &y, &width, &height, nsnull);
>+
>+    nsCOMPtr<nsIDOMSVGMatrix> ctm = GetCanvasTM();
>+    NS_ENSURE_TRUE(ctm, NS_ERROR_OUT_OF_MEMORY);

In theory the app could survive OOM and continue running once memory is freed, so we want that gfx->Restore() call to happen. I think it would be better to just wrap the SetClipRect call with an |if (ctm)| similar to what happens in nsSVGInnerSVGFrame.

>+
>+    nsSVGUtils::SetClipRect(gfx, ctm, x, y, width, height);
>+  }
>+
>   gfx->Multiply(matrix);
> 
>   nsresult rv = nsLayoutUtils::PaintFrame(ctx, kid, nsRegion(kid->GetRect()),
>                                           NS_RGBA(0,0,0,0));
> 
>   gfx->Restore();

Other than that it looks good, thanks. :-)
Attachment #262959 - Flags: review?(jwatt) → review+
The change that caused this bug was almost certainly the removal of the -moz-hidden-unscrollable line from svg.css in bug 368101 BTW.
Assignee: general → longsonr
Attachment #262959 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #263005 - Flags: superreview?(tor)
Attachment #263005 - Flags: superreview?(tor) → superreview+
checked in.

Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.