script: Inline `is_element_for_layout` and friends.

8% improvement on style recalc on Wikipedia.

r? @Ms2ger