Rebase CSS legend support onto latest master