Open Bug 866655 Opened 9 years ago Updated 9 years ago

Percentage values in pattern contents should not resolve against the viewport established by the outer-<svg>

Categories

(Core :: SVG, defect)

defect
Not set
normal

Tracking

()

People

(Reporter: jwatt, Unassigned)

Details

Attachments

(1 file, 1 obsolete file)

It seems to me that percentage values in the contents of <pattern patternContentUnits="userSpaceOnUse" viewBox="none"> should not resolve against the viewport established by the outer-<svg>, but rather should resolve against the viewport established by the referencing element's nearest <svg>. What do you think, heycam? Annoyingly Chrome and Opera both seem to share our nonsensical behavior, but I'm guessing nobody depends on this in that case.
Attached image testcase (obsolete) —
Resize the window, and it becomes clear that the percentage values is the content of the pattern are resolving against the outer-<svg>.
Attached image testcase
Attachment #743004 - Attachment is obsolete: true
Yes I agree.

There's also some problems with invalidation on that test, if I shrink the width of the window to cover the black-stroked rect, and then widen it again, the blue rect in the pattern doesn't get painted everywhere it should.
But, there is this spec text:

  The contents of the ‘pattern’ are relative to a new coordinate system. If there
  is a ‘viewBox’ attribute, then the new coordinate system is fitted into the region
  defined by the ‘x’, ‘y’, ‘width’, ‘height’ and ‘patternUnits’ attributes on the
  ‘pattern’ element using the standard rules for ‘viewBox’ and
  ‘preserveAspectRatio’. If there is no ‘viewBox’ attribute, then the new coordinate
  system has its origin at (x, y), where x is established by the ‘x’ attribute on
  the ‘pattern’ element, and y is established by the ‘y’ attribute on the ‘pattern’
  element.

which defines the origin but not the size of the new coordinate system.  Does it actually make sense for the origin to be at the top left of the pattern tile but for percentage values to resolve against the viewport of the element using the pattern?  I would expect positioning a pattern content element at x="0" to be the same as x="0%".
(In reply to Cameron McCormack (:heycam) from comment #4)
> But, there is this spec text:
> 
>   The contents of the ‘pattern’ are relative to a new coordinate system. If
> there
>   is a ‘viewBox’ attribute, then the new coordinate system is fitted into
> the region
>   defined by the ‘x’, ‘y’, ‘width’, ‘height’ and ‘patternUnits’ attributes
> on the
>   ‘pattern’ element using the standard rules for ‘viewBox’ and
>   ‘preserveAspectRatio’. If there is no ‘viewBox’ attribute, then the new
> coordinate
>   system has its origin at (x, y), where x is established by the ‘x’
> attribute on
>   the ‘pattern’ element, and y is established by the ‘y’ attribute on the
> ‘pattern’
>   element.
> 
> which defines the origin but not the size of the new coordinate system. 
> Does it actually make sense for the origin to be at the top left of the
> pattern tile but for percentage values to resolve against the viewport of
> the element using the pattern?  I would expect positioning a pattern content
> element at x="0" to be the same as x="0%".

I think you interpret this text differently. Of course viewBox establishes a new coordinate system. This must be relative to an existing coordinate system once you use the pattern. Will it be relative to the coordinate system established by the <pattern> elements nearest viewport, or the nearest viewport of the element using the pattern?

The original question from jwatt remains.

Some more data: Safari, Chrome, Firefox, InkScape and IE share the behavior of using the nearest viewport of the <pattern> element.
Illustrator does not support references across viewports it seems.
Batik and Opera 12 support the behavior of the spec (Opera > 12.x doesn't).
You need to log in before you can comment on or make changes to this bug.