Main Page/BBoxEmptyElements

From SVG

This is an attempt to summarize the discussion on how bboxes should work on elements that "don't render" (such as path without a d attribute, polygon without points etc).

This is ISSUE-2454.

Models

Model A (originally proposed by Nikos):

  • Remove the restriction that a d attribute must have an initial moveto.
  • The lacuna value of the 'd' attribute will change from 'none' to an empty string.

Model A was discarded in favor of Model E, see here.

Model B:

  • elements that don't render must return bbox=[0,0,0,0]
  • elements that don't render don't contribute to any (conceptual) ancestor's bbox (thinking of container elements, but also of <use>)

Nikos argues that we should drop model B, see here.

Model C:

  • elements that don't render must return bbox=[0,0,0,0]
  • elements that don't render do contribute to any (conceptual) ancestor's bbox

Nikos argues that we should drop models C, see here.

Model D:

  • elements that don't render must return bbox=[x,y,w,h] with the values for x,y,w,h taken from the lacuna values as defined for each relevant attribute on the given element, and if there's nothing to fall back on use zero for the missing value(s) instead
  • elements that don't render don't contribute to any (conceptual) ancestor's bbox

Model E:

  • elements that don't render must always return bbox=[x,y,w,h] with the values for x,y,w,h taken from the lacuna values as defined for each relevant attribute on the given element, and if there's nothing to fall back on use zeros instead
  • elements that don't render do contribute to any (conceptual) ancestor's bbox

Model F:

  • elements that don't render must return bbox=[x,y,w,h]. x,y,w,h are taken from lacuna values or an invalid rect is returned otherwise
  • elements that don't render don't contribute to parent bounding box

Model G:

  • elements that don't render must return bbox=[x,y,w,h]. x,y,w,h are taken from lacuna values or an invalid rect is returned otherwise
  • elements that don't render do contribute to parent bounding box unless bbox is invalid rect

Testing

Test IE11 Webkit Chrome Firefox Opera Presto SVG2 spec
rect D E E E G D
circle D E E E G D
ellipse D E E E G D
line D E E E G D
polygon X E E E G D
polyline X E E E G D
path X E E E G D

Tests from [1] and [2]. SVG 2 is currently listed as D, but this isn't quite correct because the specification doesn't define to use zero when dimensions not available (i.e. value is none).

Implementation changes

Robert Longson writes that Firefox trunk has been changed to more closely follow model A.

Previously stated opinions

  • Cameron thinks SVG2 should require model D or E, see [3].
  • Dirk thinks we should go with either D or E given that most implementations follow that, see [4].
  • Nikos suggests the WG should pick model D, see [5].

Proposal

  1. Require model D
    Rationale: because it doesn't inflate ancestor bboxes for elements that aren't actually rendered.
  2. Make the following cases equivalent in terms of the returned bbox (and the non-contribution to the ancestor bbox):
    • <path /> == <path d="" />
    • <polygon /> == <polygon points="" />
    • <polyline /> == <polyline points="" />
  3. If path data (or points attribute) is malformed before an initial moveto then the bbox should be [0,0,0,0]
  4. If the point where the path data (or points attribute) is malformed is right after the initial moveto (x,y) the bbox should be [x,y,0,0].
  5. Clarify in the bbox algorithm for container elements [6] that "elements that don't render" are handled the same as if they had a "failing conditional attribute".

Resolutions

See minutes, resulted in ACTION-3599.