Popup: Moving function fitSegmentInsideSegment into the popup prototype.