Open Bug 1388985 Opened 7 years ago Updated 2 years ago

css clip-path with basic-shape rendering should respect box-decoration-break

Categories

(Core :: Web Painting, enhancement, P2)

enhancement

Tracking

()

Tracking Status
firefox57 --- fix-optional

People

(Reporter: lochang, Unassigned)

References

Details

Attachments

(3 files, 1 obsolete file)

+++ This bug was initially created as a clone of Bug #1319406 +++

According to CSS Fragmentation Module Level 3:
https://drafts.csswg.org/css-break/#break-decoration

When a break (page/column/region/line) splits a box, the box-decoration-break property controls
* how the background positioning area [CSS3BG] (and mask positioning area [CSS-MASKING-1], shape reference box [CSS-SHAPES-1], etc.) is derived from or duplicated across the box fragments and how the element’s background is drawn within them. 

Depend on the value of box-decoration-break, we should generate the shape of clip-path differently. Currently, both slice and clone only clip the first continuation frame.
We only apply basic-shape onto the first continuation. Do you check the behavior of chrome or safari?
(In reply to C.J. Ku[:cjku](UTC+8) from comment #1)
> We only apply basic-shape onto the first continuation. Do you check the
> behavior of chrome or safari?

Chrome clip only first frame as well. Safari doesn't clip anything.
Depends on: 1385745
Attachment #8896207 - Attachment is obsolete: true
Comment on attachment 8896098 [details]
Bug 1388985 Part 1 - Compute box for clip-path: basic shape based on first frame according to the value of box-decoration-break.

https://reviewboard.mozilla.org/r/167380/#review172700

::: layout/svg/nsCSSClipPathInstance.cpp:74
(Diff revision 4)
>    return path->ContainsPoint(ToPoint(aPoint) * pixelRatio, Matrix());
>  }
>  
>  already_AddRefed<Path>
> -nsCSSClipPathInstance::CreateClipPath(DrawTarget* aDrawTarget)
> +nsCSSClipPathInstance::CreateClipPath(DrawTarget* aDrawTarget, nsIFrame* aFrame)
>  {

What's the difference between aFrame and nsCSSClipPathInstance::mFrame?
Comment on attachment 8896098 [details]
Bug 1388985 Part 1 - Compute box for clip-path: basic shape based on first frame according to the value of box-decoration-break.

https://reviewboard.mozilla.org/r/167380/#review172702

::: layout/svg/nsCSSClipPathInstance.cpp:80
(Diff revision 4)
> -  nsRect r =
> -    nsLayoutUtils::ComputeGeometryBox(mTargetFrame,
> -                                      mClipPathStyle.GetReferenceBox());
> +  uint32_t flags =
> +    (aFrame->StyleBorder()->mBoxDecorationBreak == StyleBoxDecorationBreak::Clone)
> +      ? nsSVGUtils::eBBoxIncludeFillGeometry |
> +        nsSVGUtils::eIncludeOnlyCurrentFrameForNonSVGElement
> +      : nsSVGUtils::eBBoxIncludeFillGeometry;
> +  gfxRect bbox = nsSVGUtils::GetBBox(aFrame, flags);

You should not use nsSVGUtils::GetBBox directly here since it does not handle clip-path: reference-box
Attachment #8896098 - Flags: review?(cku) → review-
Comment on attachment 8896098 [details]
Bug 1388985 Part 1 - Compute box for clip-path: basic shape based on first frame according to the value of box-decoration-break.

https://reviewboard.mozilla.org/r/167380/#review174790

::: layout/svg/nsCSSClipPathInstance.cpp:83
(Diff revision 5)
>  
> +  // If mTargetFrame is a continuation frame, compute the box based on
> +  // first frame according to different values of box-decoration-break.
> +  nsIFrame* firstFrame =
> +    nsLayoutUtils::FirstContinuationOrIBSplitSibling(mTargetFrame);
> +  if (firstFrame != mTargetFrame) {

what if "firstFrame == mTargetFrame" and "mTargetFrame->StyleBorder()->mBoxDecorationBreak == slice"? We still need to union bbox of all continuations, right?

::: layout/svg/nsCSSClipPathInstance.cpp:93
(Diff revision 5)
> +      r.MoveTo(r.TopLeft() + offsetToFirstFrame);
> +    } else {
> +      nsRect firstComputedRect =
> +        nsLayoutUtils::ComputeGeometryBox(firstFrame,
> +                                          mClipPathStyle.GetReferenceBox());
> +      gfxRect bbox = nsSVGUtils::GetBBox(mTargetFrame);

What if you have tree, or above, continuations?
Attachment #8896098 - Flags: review?(cku) → review-
Component: Layout: View Rendering → Layout: Web Painting

The bug assignee didn't login in Bugzilla in the last 7 months.
:miko, could you have a look please?
For more information, please visit auto_nag documentation.

Assignee: lochang → nobody
Status: ASSIGNED → NEW
Flags: needinfo?(mikokm)
Attached image ss.png

The clipping is slightly different compared to Chrome.

Flags: needinfo?(mikokm)
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: