Implement lazy (re-)attachment of whitespace.

The existing implementation of re-attachment of whitespace nodes had
performance issues because it tried to re-attach whitepace nodes as
early as possible, leading to multiple re-attachments of the same node
and multiple sibling-walks past the same out-of-flow elements.

Instead, this CL stores the last seen text node in a new
WhitespaceAttacher object and delays the re-attachment of that text
node until we know its need for a LayoutObject for the current layout
tree rebuild. In particular, we don't re-attach the whitespace node
when previous siblings are/become display:none or out-of-flow.

Contrary to what last_text_node did, the WhitespaceAttacher persist
the last seen text node in the flat tree order and across
display:contents and slot/content element which fixes various
correctness issues in addition to performance issues.

In addition to the last visited text node, we also store the last
seen display:contents element and only walk the display:contents
subtree when needed to find its first in-flow whitespace descendant.

BUG=349395,399816,705525,686016,648931,650168

Change-Id: Id397986c49a4bc75e831da1ff8b679f2043873c3
Reviewed-on: https://chromium-review.googlesource.com/517940
Commit-Queue: Rune Lillesveen <rune@opera.com>
Reviewed-by: Hayato Ito <hayato@chromium.org>
Reviewed-by: meade_UTC10 <meade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#483683}
800 files changed