Bug 1361618 - Remove unnecessary calls to FlushPendingLinkUpdates. r=smaug draft
authorJ. Ryan Stinnett <jryans@gmail.com>
Thu, 29 Jun 2017 11:31:52 -0700
changeset 602814 2d89bcbc4911e2725bfee4c7b4cec9dd2e469ada
parent 601255 cc903e3f61894e60c3b0efaf05e9a446d1d85888
child 635726 23b8429b0112afa873188ab41d73c5ec6fc41b1e
push id66564
push userbmo:jryans@gmail.com
push dateFri, 30 Jun 2017 19:59:34 +0000
reviewerssmaug
bugs1361618
milestone56.0a1
Bug 1361618 - Remove unnecessary calls to FlushPendingLinkUpdates. r=smaug 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
@@ -1736,17 +1736,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
@@ -5138,17 +5138,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(),