Bug 859027 - Uplift #2967: Refactor 'cmap' generation. r=bdahl a=lsblakk