Document::resolveStyle sometimes frameView.scrollToFragment when there were pending stylesheets inside FrameView::scrollToAnchor, which is called by FrameLoader::scrollToFragmentWithParentBoundary.
Created attachment 383686 [details] WIP1
Comment on attachment 383686 [details] WIP1 View in context: https://bugs.webkit.org/attachment.cgi?id=383686&action=review > Source/WebCore/dom/Document.cpp:3476 > + if (m_gotoAnchorNeededAfterStylesheetsLoad) { > + // https://html.spec.whatwg.org/multipage/browsing-the-web.html#try-to-scroll-to-the-fragment > + eventLoop().queueTask(TaskSource::Networking, *this, [this] { > + if (!m_renderView) > + return; > + m_renderView->frameView().scrollToFragment(m_url); > + }); > + } Shouldn't this be in the "run the scrolling steps" part of the event loop?
(In reply to Simon Fraser (smfr) from comment #2) > Comment on attachment 383686 [details] > WIP1 > > View in context: > https://bugs.webkit.org/attachment.cgi?id=383686&action=review > > > Source/WebCore/dom/Document.cpp:3476 > > + if (m_gotoAnchorNeededAfterStylesheetsLoad) { > > + // https://html.spec.whatwg.org/multipage/browsing-the-web.html#try-to-scroll-to-the-fragment > > + eventLoop().queueTask(TaskSource::Networking, *this, [this] { > > + if (!m_renderView) > > + return; > > + m_renderView->frameView().scrollToFragment(m_url); > > + }); > > + } > > Shouldn't this be in the "run the scrolling steps" part of the event loop? Nope: https://html.spec.whatwg.org/multipage/browsing-the-web.html#scroll-to-the-fragment-identifier which triggers: https://drafts.csswg.org/cssom-view/#perform-a-scroll just scrolls it. There is a separate section about what scrolling step does but that doesn't include the actual scrolling: https://drafts.csswg.org/cssom-view/#scrolling-events
Created attachment 384110 [details] Patch
Created attachment 384114 [details] Patch
Committed r252761: <https://trac.webkit.org/changeset/252761>
<rdar://problem/57418860>
Comment on attachment 384114 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=384114&action=review > Source/WebCore/dom/Document.cpp:-2006 > - if (m_gotoAnchorNeededAfterStylesheetsLoad && !styleScope().hasPendingSheets()) > - frameView.scrollToFragment(m_url); You should also remove this code from Document::needsStyleRecalc() // Ensure this happens eventually as it is currently in resolveStyle. This can be removed if the code moves. if (m_gotoAnchorNeededAfterStylesheetsLoad && !styleScope().hasPendingSheets()) return true;