Store :last/first-child state as restyle flags.

firstChildState and lastChildState were set to true on RenderStyle if we
had tried to match :first-child or :last-child on the element for which we
were constructing the RenderStyle. But also, when trying to match
:last-child on siblings or ascendants of the element, we set this flag on
their RenderStyle objects respectively.

That was problematic for a number of reasons. First, the state is used to
check if an element needs a style recalc when nodes are added or removed,
and that recalc is also necessary for if you have

:last-child { display: none }

in which case you have no RenderStyle. Second, the flag was reset as part
of recalculating style for a RenderStyle whose descendants depended on its
:last-child state. That flag would not be set again if the descendants
themselves didn't need a recalc. Last, the flag inconsistency caused
RenderStyle operator== to incorrectly return false, causing an assert in
the animations code.

This CL converts these RenderStyle state flags to DynamicRestyleFlags on
Element instead. That means they will give more false positives about the
need to recalculate for last-child/first-child mutations since they will
not be reset that often. They will be cleared along with the other restyle
flags when the element is removed from the tree. Since they will not be
reset on style recalc, they will also be unconditionally set when trying
to match the selector, not only when it matches.

BUG=435481,100559,435534

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

git-svn-id: svn://svn.chromium.org/blink/trunk@186043 bbb929c8-8fbe-4397-9dbb-9b2b20218538
16 files changed
tree: 405e2398d08b97decb01d15eed7e83d9d1e58196
  1. third_party/