getPathBBox = function (path) {
  const seglist = path.pathSegList
  const tot = seglist.numberOfItems

  const bounds = [[], []]
  const start = seglist.getItem(0)
  let P0 = [start.x, start.y]

  const getCalc = function (j, P1, P2, P3) {
    return function (t) {
      return (
        1 -
        t ** 3 * P0[j] +
        3 * 1 -
        t ** 2 * t * P1[j] +
        3 * (1 - t) * t ** 2 * P2[j] +
        t ** 3 * P3[j]
      )
    }
  }

  for (let i = 0; i < tot; i++) {
    const seg = seglist.getItem(i)

    if (seg.x === undefined) {
      continue
    }

    // Add actual points to limits
    bounds[0].push(P0[0])
    bounds[1].push(P0[1])

    if (seg.x1) {
      const P1 = [seg.x1, seg.y1]
      const P2 = [seg.x2, seg.y2]
      const P3 = [seg.x, seg.y]

      for (let j = 0; j < 2; j++) {
        const calc = getCalc(j, P1, P2, P3)

        const b = 6 * P0[j] - 12 * P1[j] + 6 * P2[j]
        const a = -3 * P0[j] + 9 * P1[j] - 9 * P2[j] + 3 * P3[j]
        const c = 3 * P1[j] - 3 * P0[j]

        if (a === 0) {
          if (b === 0) {
            continue
          }
          const t = -c / b
          if (t > 0 && t < 1) {
            bounds[j].push(calc(t))
          }
          continue
        }
        const b2ac = b ** 2 - 4 * c * a
        if (b2ac < 0) {
          continue
        }
        const t1 = (-b + Math.sqrt(b2ac)) / (2 * a)
        if (t1 > 0 && t1 < 1) {
          bounds[j].push(calc(t1))
        }
        const t2 = (-b - Math.sqrt(b2ac)) / (2 * a)
        if (t2 > 0 && t2 < 1) {
          bounds[j].push(calc(t2))
        }
      }
      P0 = P3
    } else {
      bounds[0].push(seg.x)
      bounds[1].push(seg.y)
    }
  }

  const x = Math.min.apply(null, bounds[0])
  const w = Math.max.apply(null, bounds[0]) - x
  const y = Math.min.apply(null, bounds[1])
  const h = Math.max.apply(null, bounds[1]) - y
  return {
    x,
    y,
    width: w,
    height: h
  }
}
Get correct BBox for a path in Webkit.
Converted from code found [here]{@link http://blog.hackers-cafe.net/2009/06/how-to-calculate-bezier-curves-bounding.html}.
@function module:utilities.getPathBBox
@param {SVGPathElement} path - The path DOM element to get the BBox for
@returns {module:utilities.BBoxObject} A BBox-like object