Bug 129246 - -webkit-clip-path wrong offset for clipPath references
Summary: -webkit-clip-path wrong offset for clipPath references
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Dirk Schulze
URL:
Keywords: InRadar
Depends on:
Blocks: 126207
  Show dependency treegraph
 
Reported: 2014-02-24 01:03 PST by Dirk Schulze
Modified: 2018-06-27 16:29 PDT (History)
5 users (show)

See Also:


Attachments
Example - should be a perfect circle (285 bytes, text/html)
2014-02-24 01:03 PST, Dirk Schulze
no flags Details
Patch (9.46 KB, patch)
2018-05-20 14:47 PDT, Dirk Schulze
no flags Details | Formatted Diff | Diff
Patch for landing (9.84 KB, patch)
2018-06-27 13:32 PDT, Dirk Schulze
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>