Changeset 251930 in webkit
- Timestamp:
- Nov 1, 2019 11:16:13 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r251924 r251930 1 2019-11-01 Ryosuke Niwa <rniwa@webkit.org> 2 3 Integrate media query evaluation into HTML5 event loop 4 https://bugs.webkit.org/show_bug.cgi?id=203134 5 <rdar://problem/56396316> 6 7 Reviewed by Antti Koivisto. 8 9 Added tests for listening to accessiblity related media queries without having any style rules 10 get affected by those media queries so that we can catch any future regressions. For now, 11 changing accessiblity settings seem to always schedule a rendering update so there is nothing to do 12 when these accessibility settings do change. 13 14 * fast/media/media-query-list-07.html: Fixed the test to be compatible with new behavior. 15 * fast/media/mq-inverted-colors-live-update-for-listener-expected.txt: Added. 16 * fast/media/mq-inverted-colors-live-update-for-listener.html: Added. 17 * fast/media/mq-prefers-reduced-motion-live-update-for-listener-expected.txt: Added. 18 * fast/media/mq-prefers-reduced-motion-live-update-for-listener.html: Added. 19 1 20 2019-11-01 Ryosuke Niwa <rniwa@webkit.org> 2 21 -
trunk/LayoutTests/fast/media/media-query-list-07.html
r251605 r251930 26 26 return; 27 27 28 testRunner.waitUntilDone(); 29 28 30 var query = window.matchMedia("screen"); 29 31 … … 50 52 51 53 window.internals.settings.setMediaTypeOverride("handheld"); 54 requestAnimationFrame(() => testRunner.notifyDone()); 52 55 } 53 56 -
trunk/Source/WebCore/ChangeLog
r251926 r251930 1 2019-11-01 Ryosuke Niwa <rniwa@webkit.org> 2 3 Integrate media query evaluation into HTML5 event loop 4 https://bugs.webkit.org/show_bug.cgi?id=203134 5 <rdar://problem/56396316> 6 7 Reviewed by Antti Koivisto. 8 9 Moved the code to call media query listeners to HTML5 event loop's step to update the rendering: 10 https://html.spec.whatwg.org/multipage/webappapis.html#update-the-rendering 11 12 Tests: fast/media/mq-inverted-colors-live-update-for-listener.html 13 fast/media/mq-prefers-reduced-motion-live-update-for-listener.html 14 15 * css/MediaQueryMatcher.cpp: 16 (WebCore::MediaQueryMatcher::evaluateAll): Renamed from styleResolverChanged. 17 * css/MediaQueryMatcher.h: 18 * dom/Document.cpp: 19 (WebCore::Document::updateElementsAffectedByMediaQueries): Split from evaluateMediaQueryList. 20 This function is still called right after each layout update so that picture element may start 21 requesting newly selected image resources without having to wait for a rendering update. 22 But this function will no longer execute arbitrary scripts. 23 (WebCore::Document::evaluateMediaQueriesAndReportChanges): Split from evaluateMediaQueryList. 24 Evaluates media query listeners. 25 * dom/Document.h: 26 * inspector/agents/InspectorPageAgent.cpp: 27 (WebCore::InspectorPageAgent::setEmulatedMedia): Force the evaluation of media queries for now 28 but this code should really be scheduling a rendering update instead so added a FIXME. 29 * page/Frame.cpp: 30 (WebCore::Frame::setPrinting): Evaluate media queries. We should consider invoking the full 31 algorithm to update the rendering here. e.g. intersection observer may add more contents. 32 * page/Page.cpp: 33 (WebCore::Page::updateStyleAfterChangeInEnvironment): Schedule a rendering update after 34 accessibility settings have changed. 35 (WebCore::Page::updateRendering): Call evaluateMediaQueriesAndReportChanges. 36 (WebCore::Page::accessibilitySettingsDidChange): Schedule a rendering update after accessibility 37 settings have changed. 38 (WebCore::Page::appearanceDidChange): Ditto. 39 1 40 2019-11-01 Tim Horton <timothy_horton@apple.com> 2 41 -
trunk/Source/WebCore/css/MediaQueryMatcher.cpp
r251605 r251930 110 110 } 111 111 112 void MediaQueryMatcher:: styleResolverChanged()112 void MediaQueryMatcher::evaluateAll() 113 113 { 114 114 ASSERT(m_document); -
trunk/Source/WebCore/css/MediaQueryMatcher.h
r251605 r251930 54 54 unsigned evaluationRound() const { return m_evaluationRound; } 55 55 56 void styleResolverChanged();56 void evaluateAll(); 57 57 58 58 bool evaluate(const MediaQuerySet&); -
trunk/Source/WebCore/dom/Document.cpp
r251924 r251930 3919 3919 } 3920 3920 3921 void Document::evaluateMediaQueryList() 3922 { 3923 if (m_mediaQueryMatcher) 3924 m_mediaQueryMatcher->styleResolverChanged(); 3925 3921 void Document::updateElementsAffectedByMediaQueries() 3922 { 3923 ScriptDisallowedScope::InMainThread scriptDisallowedScope; 3926 3924 checkViewportDependentPictures(); 3927 3925 checkAppearanceDependentPictures(); 3926 } 3927 3928 void Document::evaluateMediaQueriesAndReportChanges() 3929 { 3930 if (!m_mediaQueryMatcher) 3931 return; 3932 3933 m_mediaQueryMatcher->evaluateAll(); 3928 3934 } 3929 3935 -
trunk/Source/WebCore/dom/Document.h
r251924 r251930 558 558 void setGotoAnchorNeededAfterStylesheetsLoad(bool b) { m_gotoAnchorNeededAfterStylesheetsLoad = b; } 559 559 560 void evaluateMediaQueryList(); 560 void updateElementsAffectedByMediaQueries(); 561 void evaluateMediaQueriesAndReportChanges(); 561 562 562 563 FormController& formController(); -
trunk/Source/WebCore/inspector/agents/InspectorPageAgent.cpp
r251605 r251930 887 887 m_emulatedMedia = media; 888 888 889 // FIXME: Schedule a rendering update instead of synchronously updating the layout. 889 890 m_inspectedPage.updateStyleAfterChangeInEnvironment(); 890 891 891 if (auto* document = m_inspectedPage.mainFrame().document()) 892 document->updateLayout(); 892 auto document = makeRefPtr(m_inspectedPage.mainFrame().document()); 893 if (!document) 894 return; 895 896 document->updateLayout(); 897 document->evaluateMediaQueriesAndReportChanges(); 893 898 } 894 899 -
trunk/Source/WebCore/page/Frame.cpp
r251605 r251930 561 561 frameView.adjustMediaTypeForPrinting(printing); 562 562 563 // FIXME: Consider invoking Page::updateRendering or an equivalent. 563 564 m_doc->styleScope().didChangeStyleSheetEnvironment(); 565 m_doc->evaluateMediaQueriesAndReportChanges(); 564 566 if (shouldUsePrintingLayout()) 565 567 frameView.forceLayoutForPagination(pageSize, originalPageSize, maximumShrinkRatio, shouldAdjustViewSize); -
trunk/Source/WebCore/page/FrameViewLayoutContext.cpp
r251638 r251930 521 521 document.styleScope().evaluateMediaQueriesForViewportChange(); 522 522 523 document. evaluateMediaQueryList();523 document.updateElementsAffectedByMediaQueries(); 524 524 // If there is any pagination to apply, it will affect the RenderView's style, so we should 525 525 // take care of that now. -
trunk/Source/WebCore/page/Page.cpp
r251867 r251930 566 566 void Page::updateStyleAfterChangeInEnvironment() 567 567 { 568 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) { 569 // If a change in the global environment has occurred, we need to 570 // make sure all the properties a recomputed, therefore we invalidate 571 // the properties cache. 572 auto* document = frame->document(); 573 if (!document) 574 continue; 575 576 if (StyleResolver* styleResolver = document->styleScope().resolverIfExists()) 568 forEachDocument([](Document& document) { 569 if (StyleResolver* styleResolver = document.styleScope().resolverIfExists()) 577 570 styleResolver->invalidateMatchedPropertiesCache(); 578 document->scheduleFullStyleRebuild(); 579 document->styleScope().didChangeStyleSheetEnvironment(); 580 } 571 document.scheduleFullStyleRebuild(); 572 document.styleScope().didChangeStyleSheetEnvironment(); 573 document.scheduleTimedRenderingUpdate(); 574 }); 581 575 } 582 576 … … 1297 1291 layoutIfNeeded(); 1298 1292 1299 forEachDocument([&] 1293 forEachDocument([&](Document& document) { 1300 1294 document.runResizeSteps(); 1301 1295 }); … … 1303 1297 // FIXME: Run the scroll steps 1304 1298 1305 // FIXME: Evaluate media queries and report changes. 1299 forEachDocument([&](Document& document) { 1300 document.evaluateMediaQueriesAndReportChanges(); 1301 }); 1306 1302 1307 1303 Vector<Ref<Document>> documents = collectDocuments(); // The requestAnimationFrame callbacks may change the frame hierarchy of the page … … 2676 2672 void Page::accessibilitySettingsDidChange() 2677 2673 { 2678 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) { 2679 if (auto* document = frame->document()) { 2680 document->styleScope().evaluateMediaQueriesForAccessibilitySettingsChange(); 2681 document->evaluateMediaQueryList(); 2682 } 2683 } 2674 forEachDocument([](auto& document) { 2675 document.styleScope().evaluateMediaQueriesForAccessibilitySettingsChange(); 2676 document.updateElementsAffectedByMediaQueries(); 2677 document.scheduleTimedRenderingUpdate(); 2678 }); 2684 2679 } 2685 2680 2686 2681 void Page::appearanceDidChange() 2687 2682 { 2688 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) { 2689 auto* document = frame->document(); 2690 if (!document) 2691 continue; 2692 2693 document->styleScope().didChangeStyleSheetEnvironment(); 2694 document->styleScope().evaluateMediaQueriesForAppearanceChange(); 2695 document->evaluateMediaQueryList(); 2696 } 2683 forEachDocument([](auto& document) { 2684 document.styleScope().didChangeStyleSheetEnvironment(); 2685 document.styleScope().evaluateMediaQueriesForAppearanceChange(); 2686 document.updateElementsAffectedByMediaQueries(); 2687 document.scheduleTimedRenderingUpdate(); 2688 }); 2697 2689 } 2698 2690
Note: See TracChangeset
for help on using the changeset viewer.