bugzilla.mozilla.org will be intermittently unavailable on Saturday, March 24th, from 16:00 until 20:00 UTC.

Add support for |clip-path: path()|




2 years ago
11 months ago


(Reporter: jwatt, Unassigned)


(Blocks: 1 bug, {dev-doc-needed})

Dependency tree / graph

Firefox Tracking Flags

(firefox47 affected)





2 years ago
Bug 1075457 adds support for basic shape clip paths. Currently the only means of specifying a path in the spec is to specify a polygon, but this isn't sufficient for our Firefox frontend needs where we need to be able to clip to a curved path for tabs. We could add support for a |path()| value that supports the SVG path syntax. We should likely make that accessible only to chrome until/unless it is added to the specification.

Comment 1

2 years ago
(What the Firefox frontend currently does is reference an SVG <clipPath> element, but that requires the instantiation of an SVG document which has significant overhead.)

Comment 2

2 years ago
Implementing this would involve the following:

 * Extend CSSParserImpl::ParseBasicShape

 * Add a call to nsCSSValue::AppendToString similar to the
   AppendPolygonToString call

 * Add handling in nsComputedDOMStyle::CreatePrimitiveValueForClipPath
   similar to the nsStyleBasicShape::Type::ePolygon handling

 * Add handling in nsRuleNode::SetStyleClipPathToCSSValue similar to
   the eCSSKeyword_polygon handling

 * Add a define similar to #define NS_STYLE_BASIC_SHAPE_POLYGON in

 * Add a CreateClipPathPath method to nsCSSClipPathInstance

As far as creating a Moz2D path goes, we currently have the ability to parse a string to a Path using code along the lines of:

  SVGPathData pathData;
  nsSVGPathDataParser pathParser(pathString, &pathData);
  if (!pathData.Length()) {
  RefPtr<Path> path = pathData.BuildPath(builder, NS_STYLE_STROKE_LINECAP_BUTT, 0);

It seems unlikely that we'd want to store the path data in style as a string, but this is a useful starting point.

Comment 3

2 years ago
In fact we have SVGContentUtils::GetPath to parse a string to a Path. (Without digging into the callers I'm not sure why that's passing a non-zero stroke width to pathData.BuildPath though.)
Keywords: dev-doc-needed


2 years ago
See Also: → bug 1247229
Given that it's part of features in CSS Shape 2 spec, I think we need to initiate the spec(CSS Masking 1 or 2?) discussion before going further.
Assignee: jwatt → nobody
See Also: bug 1247229
You need to log in before you can comment on or make changes to this bug.