Bug 931668 - Part 11: Add eRestyle_Force (and eRestyle_ForceDescendants) restyle hints to control whether the frame (and all of its descendants) must be assigned its new style context even if it had the same style data as the old style context. r=dbaron

--HG--
extra : rebase_source : f92a5b5033bb4cf424ee172611a58fe583aed87f
This commit is contained in:
Cameron McCormack 2014-09-05 13:48:45 +10:00
parent eb13de60fe
commit a3aa708945
2 changed files with 26 additions and 2 deletions

View File

@ -2418,7 +2418,12 @@ ElementRestyler::Restyle(nsRestyleHint aRestyleHint)
}
}
nsRestyleHint childRestyleHint = nsRestyleHint(aRestyleHint & eRestyle_Subtree);
// If we are restyling this frame with eRestyle_Self, we restyle
// children with nsRestyleHint(0). But we pass the eRestyle_ForceDescendants
// flag down too.
nsRestyleHint childRestyleHint =
nsRestyleHint(aRestyleHint & (eRestyle_Subtree |
eRestyle_ForceDescendants));
{
nsRefPtr<nsStyleContext> oldContext = mFrame->StyleContext();
@ -2539,7 +2544,7 @@ ElementRestyler::RestyleSelf(nsIFrame* aSelf, nsRestyleHint aRestyleHint)
}
else if (!(aRestyleHint & (eRestyle_Self | eRestyle_Subtree))) {
Element* element = ElementForStyleContext(mParentContent, aSelf, pseudoType);
if (aRestyleHint == nsRestyleHint(0) &&
if (!(aRestyleHint & ~(eRestyle_Force | eRestyle_ForceDescendants)) &&
!styleSet->IsInRuleTreeReconstruct()) {
nsIContent* pseudoElementContent = aSelf->GetContent();
Element* pseudoElement =

View File

@ -266,6 +266,16 @@ inline nsChangeHint NS_HintsNotHandledForDescendantsIn(nsChangeHint aChangeHint)
* |nsRestyleHint| is a bitfield for the result of
* |HasStateDependentStyle| and |HasAttributeDependentStyle|. When no
* restyling is necessary, use |nsRestyleHint(0)|.
*
* Without eRestyle_Force or eRestyle_ForceDescendants, the restyling process
* can stop processing at a frame when it detects no style changes and it is
* known that the styles of the subtree beneath it will not change, leaving
* the old style context on the frame. eRestyle_Force can be used to skip this
* optimization on a frame, and to force its new style context to be used.
*
* Similarly, eRestyle_ForceDescendants will cause the frame and all of its
* descendants to be traversed and for the new style contexts that are created
* to be set on the frames.
*/
enum nsRestyleHint {
// Rerun selector matching on the element. If a new style context
@ -294,6 +304,15 @@ enum nsRestyleHint {
// eRestyle_Subtree is also set, since those imply a superset of the
// work.)
eRestyle_CSSAnimations = (1<<4),
// Continue the restyling process to the current frame's children even
// if this frame's restyling resulted in no style changes.
eRestyle_Force = (1<<5),
// Continue the restyling process to all of the current frame's
// descendants, even if any frame's restyling resulted in no style
// changes. (Implies eRestyle_Force.)
eRestyle_ForceDescendants = (1<<6),
};