Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/nodes/geometrynode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export abstract class GeometryNode extends GraphicsNode {

protected getBoundingBoxCore(context: Context): Rect {
const path = this.getCachedPath(context)
if (!path) {
if (!path || !path.segments.length) {
return [0, 0, 0, 0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a bounding box with zero width and height "located at 0,0" handled properly in the rest of the code?
When we calculate the union of two bounding boxes do we filter "empty" bounding boxes like this?
What's the bounding box of a point at (0,0)?

E.g. in yFiles, a truely empty bounding box uses negative width and height as sentinel values, so that you can distinguish between non-existing and infinitely small bounding box rectangles...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, this is not 100% exact at this point and [0,0,0,0] isn't handled specially on the caller side. However, throughout the codebase we use [0,0,0,0] for empty bounding boxes and this hasn't been an issue so far. We could improve this in a separate PR, but let's keep it like this for the moment.

}
let minX = Number.POSITIVE_INFINITY
Expand Down
1 change: 1 addition & 0 deletions test/common/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ window.tests = [
'style-sheets',
'svg-viewbox',
'svg-use',
'svg-use-empty',
'symbols',
'text-fill-stroke',
'text-placement',
Expand Down
Binary file added test/specs/svg-use-empty/reference.pdf
Binary file not shown.
6 changes: 6 additions & 0 deletions test/specs/svg-use-empty/spec.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.