Bug 1361618 - Remove unnecessary calls to FlushPendingLinkUpdates. r=dbaron draft
authorJ. Ryan Stinnett <jryans@gmail.com>
Thu, 29 Jun 2017 11:31:52 -0700
changeset 617593 5f0365a719eeac9517b98eb2013d9e27d2a2e5fb
parent 617496 16ffc1d05422a81099ce8b9b59de66dde4c8b2f0
child 639855 08be336447924dfd5437b75a5f13ce43f5384596
push id71093
push userbmo:jryans@gmail.com
push dateFri, 28 Jul 2017 18:06:52 +0000
reviewersdbaron
bugs1361618
milestone56.0a1
Bug 1361618 - Remove unnecessary calls to FlushPendingLinkUpdates. r=dbaron This removes the two calls to `FlushPendingLinkUpdates` in nsCSSFrameConstructor and GeckoRestyleManager, which appear to have no effect. Looking through what the pending link code is attempting to do: * When a new anchor is bound in `BindToTree` we do: 1. Link::ResetLinkState(false, Link::ElementHasHref()); * Set link's mLinkState to default (either unvisited or not link) * Set element's link mState bits to default (either unvisited or not link) 2. doc->RegisterPendingLinkUpdate(this); * Schedules idle dispatch to run `FlushPendingLinkUpdates` within 1 sec * In `FlushPendingLinkUpdates`: * For each pending link, call element->UpdateLinkState(link->LinkState()); 1. Register link for async history update to get potential future visited state 2. mLinkState is still unvisited / not link until we hear from history, so element state is unchanged Thus, there seems to be no need to call `FlushPendingLinkUpdates` outside of `BindToTree`, since visited state is always applied async anyway (so it doesn't work as an optimization to avoid restyling if visited, since that will trigger later). MozReview-Commit-ID: KbFuKve1KUi
layout/base/GeckoRestyleManager.cpp
layout/base/nsCSSFrameConstructor.cpp
--- a/layout/base/GeckoRestyleManager.cpp
+++ b/layout/base/GeckoRestyleManager.cpp
@@ -1818,17 +1818,16 @@ ElementRestyler::Restyle(nsRestyleHint a
       // up the hint for one of the ancestors that we hit first, then
       // we'll fail to do the restyling we need to do.
       // Likewise, if we're restyling something with two nested frames,
       // and we post a restyle from the transition manager while
       // computing style for the outer frame (to be computed after the
       // descendants have been resolved), we don't want to consume it
       // for the inner frame.
       mContent->GetPrimaryFrame() == mFrame) {
-    mContent->OwnerDoc()->FlushPendingLinkUpdates();
     nsAutoPtr<RestyleTracker::RestyleData> restyleData;
     if (mRestyleTracker.GetRestyleData(mContent->AsElement(), restyleData)) {
       nsChangeHint changeToAppend =
         NS_RemoveSubsumedHints(restyleData->mChangeHint,
                                mHintsHandledByAncestors);
       // See the comment in CaptureChange about why we use NS_IsHintSubset here.
       if (!NS_IsHintSubset(changeToAppend, mHintsHandledBySelf)) {
         mHintsHandledBySelf |= changeToAppend;
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -5151,17 +5151,16 @@ nsCSSFrameConstructor::ResolveStyleConte
 
 already_AddRefed<nsStyleContext>
 nsCSSFrameConstructor::ResolveStyleContext(nsStyleContext* aParentStyleContext,
                                            nsIContent* aContent,
                                            nsFrameConstructorState* aState,
                                            Element* aOriginatingElementOrNull)
 {
   StyleSetHandle styleSet = mPresShell->StyleSet();
-  aContent->OwnerDoc()->FlushPendingLinkUpdates();
 
   RefPtr<nsStyleContext> result;
   if (aContent->IsElement()) {
     auto pseudoType = aContent->AsElement()->GetPseudoElementType();
     if (pseudoType == CSSPseudoElementType::NotPseudo) {
       MOZ_ASSERT(!aOriginatingElementOrNull);
       if (aState) {
         result = styleSet->ResolveStyleFor(aContent->AsElement(),