Bug 1031149 - Consistently pass correct aRelevantLinkVisited to nsStyleContext::FindChildWithRules.  r=heycam

I believe this will fix some cache misses in the FindChildWithRules
lookup when restyling.  I don't think it will fix any correctness bugs
because the RelevantLinkVisited() bit will always end up set to true
anyway as the non-link descendant of a visited link style context, and
link descendants shouldn't be able to share styles with non-link
descendants due to matching rules in the UA style sheet.
Bug 996796 patch 5 - Move the guts of UpdateThrottledStyle into nsStyleSet, where it can be reused.  r=heycam
Bug 996796 patch 6 - Adjust checks of restyle types to accomodate new types weaker than eRestyle_Self.  r=heycam

FIXME: Adjust for eRestyle_Force if bug 931668 lands first.

Later patches will add such types that are like eRestyle_Self but that
only replace the style attribute, animation rule, or transition rule.
Bug 996796 patch 7 - Add new restyle types that replace only the data from CSS transitions or animations.  r=heycam

This is the start of a refactoring of the existing code in
CommonAnimationManager, nsTransitionManager, and nsAnimationManager,
which will be removed in later patches (after patches in between cause
this code to be used instead of the current code).

But it also handles interesting cases more correctly, such as cases
where style context parents are unusual.

FIXME: It would be nice to add tests for these cases, but they're mostly
pretty obscure (e.g., a transition of 'transform' that's affected by
inheriting 'transform' from ::first-line), so I'm not treating it as a
priority right now.
Bug 996796 patch 8 - Pass the replacements through to ResolveStyleWithReplacement.  r=heycam

This means ResolveStyleWithReplacement will replace only the rules in
the nsRestyleHint rather than always replacing both the animations rule
and the transitions rule.  (This will become even more useful later when
we add the ability to replace the style attribute rule.)
Bug 996796 patch 9 - Make nsStyleSet::ResolveStyleWithReplacement handle changing between having and not having animation or transition rules, make it set IsImportantRule on rule nodes correctly, and merge the bogus ResolveStyleForRules into it.  r=heycam

ResolveStyleForRules had various problems:  it failed to set importance
correctly and really only handled replacing a path in the rule tree
since it didn't handle creating important rules.  (Possibly more.)
Bug 996796 patch 10 - Separate the rule node replacement code from the style context handling so that we can make visited handling correct.  r=heycam
Bug 996796 patch 11 - Fix the visited flag handling in ResolveStyleWithReplacement.  r=heycam

This does the same thing as ReparentStyleContext (which thanks to the
patch to bug 1031149 deals with aNewParentStyleContext being null).
Bug 996796 patch 12 - Fix the visited rule node handling in ResolveStyleWithReplacement.  r=heycam

The added test passes locally on Linux with OMT compositing and OMT
animations enabled.  However, it also passes without the patch because
the calls to FlushAnimations and FlushTransitions from
PresShell::FlushPendingNotifications cover up the damage done by bugs in
the animation-only style flush.

Unfortunately due to lack of global history on B2G and not running OMT
animations tests on any other platforms, the new test won't actually run
in automation right now.
Bug 996796 patch 13 - Fix the pseudo element information created by ResolveStyleWithReplacement.  r=heycam

Note that we're not yet using this code for style contexts that have
pseudo-elements, since we don't run transitions or animations on
pseudo-elements on the compositor thread.  But bug 960465 will (with
some more work) start doing so.
Bug 996796 patch 14 - Fix the aElementForAnimation passed from ResolveStyleWithReplacement.  r=heycam
Bug 996796 patch 15 - Copy the eSkipParentDisplayBasedStyleFixup bit from ReparentStyleContext as well.  r=heycam
Bug 996796 patch 16 - Add comment about potential performance impromevent to RuleNodeWithReplacement.  r=heycam
Bug 996796 patch 17 - Add comment about how RuleNodeWithReplacement should interact with nsTransitionManager and nsAnimationManager.  r=heycam
Bug 996796 patch 18 - Fix RestyleTracker to handle restyle hints exactly rather than pessimistically when restyling continuations with varying styles (e.g., spans inside ::first-line or ::first-letter).  r=heycam

This will be necessary when we use the restyle tracker for the
animation-only style flush, because animation-only style flushes need to
update *only* the animation style data and no other style data.  Thus
using the RestyleTracker for animation-only style flushes requires that
we do this.
Bug 996796 patch 19 - Avoid reresolution for extra style contexts when the restyle hint is not eRestyle_Self or eRestyle_Subtree.  r=heycam

This is part of making reresolution not touch style that it was not
asked to touch, so that we can use it for the animation-only restyle.
Bug 996796 patch 20 - Make restyling exact - Avoid rerunning selector matching on everything when the basis of rem units changes.  r=heycam
Bug 996796 patch 21 - Make restyling exact - Only call MaybeRecreateFramesForElement when we have a nonzero restyle hint.  r=heycam
Bug 996796 patch 22 - Make restyling exact - only call RestyleBeforePseudo and RestyleAfterPseudo when we have an eRestyle_Subtree hint.  r=heycam
Bug 996796 patch 23 - Make transition manager ignore StyleContextChanged notifications during an animation-only style update.  r=heycam

This will be necessary when we use the restyle tracker for the
animation-only style flush.