Bug 129246

Summary: -webkit-clip-path wrong offset for clipPath references
Product: WebKit Reporter: Dirk Schulze <krit>
Component: CSSAssignee: Dirk Schulze <krit>
Status: RESOLVED FIXED    
Severity: Normal CC: achicu, commit-queue, dino, simon.fraser, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 126207    
Attachments:
Description Flags
Example - should be a perfect circle
none
Patch
none
Patch for landing none

Description Dirk Schulze 2014-02-24 01:03:50 PST
Created attachment 225035 [details]
Example - should be a perfect circle

If -webkit-clip-path references a <clipPath> element the offset is from the top left of the viewport, not of the HTML element.

This changes once a CSS transform is specified. Then the offset is correct. -webkit-transform: translate(0px, 0px)
Comment 1 Dirk Schulze 2014-02-25 05:06:45 PST
The example makes use of clipPathUnits="userSpaceOnUse". All units an percentage are resolved in the viewport of the <clip-path> element (wrongly btw). All objects within <clipPath> are sized and positioned in this coordinate space. The these objects are just mapped to the coordinate space of the clipped object.

This causes the wrong offset and strange behavior of clipping paths with percentage values.
Comment 2 Dirk Schulze 2018-05-20 11:02:17 PDT
https://codepen.io/krit/pen/xjMRWM
Comment 3 Dirk Schulze 2018-05-20 14:47:19 PDT
Created attachment 340807 [details]
Patch
Comment 4 Simon Fraser (smfr) 2018-06-26 14:08:28 PDT
Comment on attachment 340807 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=340807&action=review

> Source/WebCore/rendering/RenderLayer.cpp:4179
> +            downcast<RenderSVGResourceClipper>(*element->renderer()).applyClippingToContext(renderer(), svgReferenceBox, paintingInfo.paintDirtyRect, context);

Does hasTagName(SVGNames::clipPathTag) mean that the renderer is always a RenderSVGResourceClipper? (I know the existing code did this.). I would feel happier with an is<> check, otherwise this code will release-assert.
Comment 5 Dirk Schulze 2018-06-27 13:32:37 PDT
Created attachment 343747 [details]
Patch for landing
Comment 6 WebKit Commit Bot 2018-06-27 16:28:26 PDT
Comment on attachment 343747 [details]
Patch for landing

Clearing flags on attachment: 343747

Committed r233287: <https://trac.webkit.org/changeset/233287>
Comment 7 WebKit Commit Bot 2018-06-27 16:28:28 PDT
All reviewed patches have been landed.  Closing bug.
Comment 8 Radar WebKit Bug Importer 2018-06-27 16:29:18 PDT
<rdar://problem/41550953>