Persist invalidation sets on detach root

This is a second attempt at not clearing sibling invalidation sets on
detached and SubtreeStyleChange nodes. The first[1] failed because
childNeedsStyleInvalidation() was still cleared on detach().

This approach keeps invalidation sets on the detach root, but clears
invalidation sets on descendants. However, when we detach a node to be
removed, we also clear the detach root as that will not have a chance of
being used on the next invalidation. Also, there are asserts checking
that we don't re-insert nodes into the tree with needsStyleInvalidation().

Removed scheduled sibling invalidation sets from nodes being removed from
the tree is not a problem as the checkForSiblingStyleChanges() method
will make sure sibling trees are invalidated.

The early return in StyleInvalidator::scheduleInvalidationSetsForElement
is removed to be able to schedule sibling invalidation sets although we
have a SubtreeStyleChange or ReattachStyleChange on the element itself.

The added test checks that the invalidation works properly, also after
the checkForChildrenAdjacentRuleChanges() removal.

[1] https://codereview.chromium.org/1507653002

R=esprehn@chromium.org,ericwilligers@chromium.org
BUG=557440

Review URL: https://codereview.chromium.org/1533683002

Cr-Commit-Position: refs/heads/master@{#369021}
6 files changed