Changeset 252761 in webkit
- Timestamp:
- Nov 21, 2019 9:09:36 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r252760 r252761 1 2019-11-21 Ryosuke Niwa <rniwa@webkit.org> 2 3 Scrolling to fragment shouldn't happen as a part of updating style 4 https://bugs.webkit.org/show_bug.cgi?id=203982 5 6 Reviewed by Simon Fraser. 7 8 Made an existing test more robust. 9 10 * fast/parser/adoption-agency-unload-iframe-4.html: Made the iframe's data URL not cachable. 11 1 12 2019-11-21 Myles C. Maxfield <mmaxfield@apple.com> 2 13 -
trunk/LayoutTests/fast/parser/adoption-agency-unload-iframe-4.html
r212621 r252761 38 38 doc.write(`<div><b><p><script> 39 39 parent.p = document.querySelector('p'); 40 document.write('<link rel="stylesheet" href="data:,a ">');40 document.write('<link rel="stylesheet" href="data:,a${(new Date).toISOString() + Math.random()}">'); 41 41 location.hash = 'target'; 42 42 <\/script></b></p></div></body>`); -
trunk/Source/WebCore/ChangeLog
r252760 r252761 1 2019-11-21 Ryosuke Niwa <rniwa@webkit.org> 2 3 Scrolling to fragment shouldn't happen as a part of updating style 4 https://bugs.webkit.org/show_bug.cgi?id=203982 5 6 Reviewed by Simon Fraser. 7 8 Don't scroll to the current URL's fragment at the end of resolveStyle. Instead, schedule a task 9 to scroll to the current URL's fragment when all pending stylesheets have finished loading. 10 11 This patch also moves the code which sets a Document's m_gotoAnchorNeededAfterStylesheetsLoadflag 12 from FrameView to FrameLoader as FrameView shouldn't be relying on the states of pending stylesheets. 13 14 * dom/Document.cpp: 15 (WebCore::Document::resolveStyle): Removed the code to scroll to the current URL's fragment. 16 (WebCore::Document::didRemoveAllPendingStylesheet): Added a code to schedule a task to scoll. 17 * loader/FrameLoader.cpp: 18 (WebCore::FrameLoader::scrollToFragmentWithParentBoundary): Moved the code to trigger the code 19 in didRemoveAllPendingStylesheet from FrameView. 20 * page/FrameView.cpp: 21 (WebCore::FrameView::scrollToFragment): 22 (WebCore::FrameView::scrollToFragmentInternal): Renamed from scrollToAnchor since this function sets 23 the current anchor. Also removed the code which defers the scrolling based on pending stylesheets' 24 states since such a code doesn't belong in FrameView. 25 * page/FrameView.h: 26 1 27 2019-11-21 Myles C. Maxfield <mmaxfield@apple.com> 2 28 -
trunk/Source/WebCore/dom/Document.cpp
r252723 r252761 2002 2002 if (updatedCompositingLayers && !frameView.needsLayout()) 2003 2003 frameView.viewportContentsChanged(); 2004 2005 if (m_gotoAnchorNeededAfterStylesheetsLoad && !styleScope().hasPendingSheets())2006 frameView.scrollToFragment(m_url);2007 2004 } 2008 2005 … … 3473 3470 if (auto* parser = scriptableDocumentParser()) 3474 3471 parser->executeScriptsWaitingForStylesheetsSoon(); 3472 3473 if (m_gotoAnchorNeededAfterStylesheetsLoad) { 3474 // https://html.spec.whatwg.org/multipage/browsing-the-web.html#try-to-scroll-to-the-fragment 3475 eventLoop().queueTask(TaskSource::Networking, [protectedThis = makeRef(*this), this] { 3476 auto frameView = makeRefPtr(view()); 3477 if (!frameView) 3478 return; 3479 if (!haveStylesheetsLoaded()) { 3480 m_gotoAnchorNeededAfterStylesheetsLoad = true; 3481 return; 3482 } 3483 frameView->scrollToFragment(m_url); 3484 }); 3485 } 3475 3486 } 3476 3487 -
trunk/Source/WebCore/loader/FrameLoader.cpp
r252641 r252761 3251 3251 void FrameLoader::scrollToFragmentWithParentBoundary(const URL& url, bool isNewNavigation) 3252 3252 { 3253 FrameView* view = m_frame.view(); 3254 if (!view) 3255 return; 3256 3257 if (isSameDocumentReload(isNewNavigation, m_loadType) || itemAllowsScrollRestoration(history().currentItem())) 3258 view->scrollToFragment(url); 3253 auto view = makeRefPtr(m_frame.view()); 3254 auto document = makeRefPtr(m_frame.document()); 3255 if (!view || !document) 3256 return; 3257 3258 if (isSameDocumentReload(isNewNavigation, m_loadType) || itemAllowsScrollRestoration(history().currentItem())) { 3259 // https://html.spec.whatwg.org/multipage/browsing-the-web.html#try-to-scroll-to-the-fragment 3260 if (!document->haveStylesheetsLoaded()) 3261 document->setGotoAnchorNeededAfterStylesheetsLoad(true); 3262 else 3263 view->scrollToFragment(url); 3264 } 3265 3259 3266 } 3260 3267 -
trunk/Source/WebCore/page/FrameView.cpp
r252628 r252761 2170 2170 { 2171 2171 String fragmentIdentifier = url.fragmentIdentifier(); 2172 if (scrollTo Anchor(fragmentIdentifier))2172 if (scrollToFragmentInternal(fragmentIdentifier)) 2173 2173 return true; 2174 2174 2175 2175 // Try again after decoding the ref, based on the document's encoding. 2176 2176 if (TextResourceDecoder* decoder = frame().document()->decoder()) { 2177 if (scrollTo Anchor(decodeURLEscapeSequences(fragmentIdentifier, decoder->encoding())))2177 if (scrollToFragmentInternal(decodeURLEscapeSequences(fragmentIdentifier, decoder->encoding()))) 2178 2178 return true; 2179 2179 } … … 2183 2183 } 2184 2184 2185 bool FrameView::scrollTo Anchor(const String& fragmentIdentifier)2185 bool FrameView::scrollToFragmentInternal(const String& fragmentIdentifier) 2186 2186 { 2187 2187 LOG(Scrolling, "FrameView::scrollToAnchor %s", fragmentIdentifier.utf8().data()); … … 2193 2193 ASSERT(frame().document()); 2194 2194 auto& document = *frame().document(); 2195 2196 if (!document.haveStylesheetsLoaded()) { 2197 document.setGotoAnchorNeededAfterStylesheetsLoad(true); 2198 return false; 2199 } 2200 2201 document.setGotoAnchorNeededAfterStylesheetsLoad(false); 2195 RELEASE_ASSERT(document.haveStylesheetsLoaded()); 2202 2196 2203 2197 Element* anchorElement = document.findAnchor(fragmentIdentifier); -
trunk/Source/WebCore/page/FrameView.h
r252552 r252761 426 426 427 427 bool scrollToFragment(const URL&); 428 bool scrollToAnchor(const String&);429 428 void maintainScrollPositionAtAnchor(ContainerNode*); 430 429 WEBCORE_EXPORT void scrollElementToRect(const Element&, const IntRect&); … … 779 778 void updateWidgetPositionsTimerFired(); 780 779 780 bool scrollToFragmentInternal(const String&); 781 781 void scrollToAnchor(); 782 782 void scrollPositionChanged(const ScrollPosition& oldPosition, const ScrollPosition& newPosition);
Note: See TracChangeset
for help on using the changeset viewer.