Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify meaning of context-fill & context-stroke keywords in paint definitions #203

Closed
AmeliaBR opened this issue Jul 13, 2016 · 10 comments · Fixed by #206
Closed

Clarify meaning of context-fill & context-stroke keywords in paint definitions #203

AmeliaBR opened this issue Jul 13, 2016 · 10 comments · Fixed by #206

Comments

@AmeliaBR
Copy link
Contributor

AmeliaBR commented Jul 13, 2016

The context-fill and context-stroke keywords are listed as valid paint values, but aren't actually defined anywhere in SVG 2. clearly defined at the point where they are used.

@AmeliaBR
Copy link
Contributor Author

To be fair, there is a little bit of prose that says "a special keyword that references the value of fill or stroke in a referencing context". But "referencing context" isn't defined.

Is a <use> element a referencing context? (It will be a pain to integrate this in the shadow DOM model if it is.) Or does this only apply to markers? It can't apply to patterns, because then you'd get an infinite loop in some cases. If you use these values and there isn't a referencing context, what does it fallback as?

@nikosandronikos
Copy link
Member

I'm pretty sure context-fill and context-stroke are used by SVG in OpenType. They were in the past but I need to double check the latest spec.
Tav has also implemented them for markers in Inkscape.
So we at least need to define those two cases.

I do recall in the past having a discussion where we resolved that we need to define the meaning of 'referencing context' for each case.

This is the only discussion I could find, and it isn't very useful.
https://www.w3.org/2015/01/15-svg-minutes.html#item05

@nikosandronikos
Copy link
Member

nikosandronikos commented Jul 13, 2016

You did see this text, didn't you?

It comes from just above the example above this heading
https://svgwg.org/svg2-draft/painting.html#ColorProperty

The context-fill and context-stroke values are a reference to the computed value of the fill or stroke property, respectively, of the context element of the element being painted. The context element of an element is defined as follows:
If the element is within a ‘marker’, and is being rendered as part of that marker due to being referenced via a marker property, then the context element is the element referencing that ‘marker’.
If the element is within a sub-tree that is instantiated with a ‘use’ element, then the context element is that ‘use’ element.
Otherwise, there is no context element.

If there is no context element and these keywords are used, then no paint is applied. If the referenced paint is a gradient or a pattern, then the coordinate space to use and the object used for any 'objectBoundingBox'-relative values are the same as those of the context element.

@BigBadaboom
Copy link
Contributor

BigBadaboom commented Jul 13, 2016

These keywords (well actually only context-stroke) would be very useful for hatches as well. And there is no chance of circular references there because hatches are defined to only take solid colour paint servers.

@AmeliaBR
Copy link
Contributor Author

I did not see those, Nikos. (Maybe my keyword search of the source code was foiled by some extra whitespace???) That makes more sense. I knew we used to have more information, so I couldn't figure out why it wasn't there.

But there is also a lot of intervening text and examples. I think what's needed is a link from the "a special keyword" bit down to the actual definitions, and being consistent with terminology. I'm going to need to do some other tweaking to the wording there, to handle <use> elements and shadow DOM, so I can make those changes.

@BigBadaboom Not the way context-fill and context-stroke are currently defined, as representing a full paint stack (not just a color). We had discussed a separate context-color keyword that could be more flexible, but didn't come to a decision on how it would be set on the context element.

@AmeliaBR AmeliaBR self-assigned this Jul 13, 2016
@AmeliaBR AmeliaBR changed the title Define context-fill & context-stroke keywords, or defer to a future spec Clarify meaning of context-fill & context-stroke keywords in paint definitions Jul 13, 2016
@BigBadaboom
Copy link
Contributor

@AmeliaBR

Not the way context-fill and context-stroke are currently defined, as representing a full paint stack (not just a color).

That's no different from stroke thought right? Hatches use stroke, not a separate "color" property.

@AmeliaBR
Copy link
Contributor Author

@BigBadaboom But a hatch can be used as a stroke as well. So there is a potential for circular references.

Not saying its an insurmountable problem. We can always define them in such a way as to deal with circular references when the occur, but allow the generic case so paint servers that will be used for fill can reference context-stroke and vice versa.

Maybe I'll add a warning that the definition of "context element" could be expanded in the future, and that authors are therefore not to rely on the fallback to "no paint" behavior.

@nikosandronikos
Copy link
Member

currentColor sould be enough for hatch.

AmeliaBR added a commit that referenced this issue Jul 13, 2016
@AmeliaBR
Copy link
Contributor Author

@nikosandronikos Good point. I still don't know why we can't have gradient-stroked hatched lines, but since we can't, currentColor does the job.

See the linked commit 40c4769 for clarifying text. Unfortunately, I made the edits while still on my other branch, so the issue won't auto-close (& the changes won't make it to svgwg.org) until that gets merged.

(PS, should have that massive pull request ready for tomorrow.)

@BigBadaboom
Copy link
Contributor

But a hatch can be used as a stroke as well. So there is a potential for circular references.

@AmeliaBR In practice you wouldn't get a circlular reference because the hatch definition says it must be a solid colour. So a hatch being used for context-fill' orcontext-stroke` would be treated the same as if you tried to use a gradient or something. It would error out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants