layout: Support more types of selectors for style sharing.

This helps avoid problems with style sharing in common cases, often
caused by the user agent stylesheet.

r? @SimonSapin