function getAvailableSize(positionInfo, containerRect, margin) {
  var containerWidth = containerRect.width;
  var containerHeight = containerRect.height;
  var x = number_parsePercent(positionInfo.left, containerWidth);
  var y = number_parsePercent(positionInfo.top, containerHeight);
  var x2 = number_parsePercent(positionInfo.right, containerWidth);
  var y2 = number_parsePercent(positionInfo.bottom, containerHeight);
  (isNaN(x) || isNaN(parseFloat(positionInfo.left))) && (x = 0);
  (isNaN(x2) || isNaN(parseFloat(positionInfo.right))) && (x2 = containerWidth);
  (isNaN(y) || isNaN(parseFloat(positionInfo.top))) && (y = 0);
  (isNaN(y2) || isNaN(parseFloat(positionInfo.bottom))) && (y2 = containerHeight);
  margin = format_normalizeCssArray(margin || 0);
  return {
    width: Math.max(x2 - x - margin[1] - margin[3], 0),
    height: Math.max(y2 - y - margin[0] - margin[2], 0)
  };
}
If x or x2 is not specified or 'center' 'left' 'right',
the width would be as long as possible.
If y or y2 is not specified or 'middle' 'top' 'bottom',
the height would be as long as possible.