Implement :list-child and :only-child pseudo-classes.

Same as #1296, with a fixed commit message.