Host plant quality and local adaptation determine the distribution of a gall-forming herbivore.