From 3795ef8f3d82d6e1727984fa5a64146c45e10ebb Mon Sep 17 00:00:00 2001 From: "antti@apple.com" Date: Mon, 16 Apr 2012 18:45:29 +0000 Subject: [PATCH] matchMedia() MediaQueryList not updating https://bugs.webkit.org/show_bug.cgi?id=75903 Patch by Luiz Agostini on 2012-04-16 Reviewed by Antti Koivisto. Source/WebCore: Test: fast/media/media-query-list-08.html Viewport related MediaQueryList listeners were not triggered and the value of matches were not updated if the document's style selector were not affected by viewport changes. The new method evaluateMediaQueries() is now called by FrameView instead of styleSelectorChanged() if the style selector is not affected by viewport changes. * dom/Document.cpp: (WebCore::Document::evaluateMediaQueries): (WebCore): (WebCore::Document::styleSelectorChanged): * dom/Document.h: (Document): * page/FrameView.cpp: (WebCore::FrameView::layout): LayoutTests: Testing MediaQueryLists listeners related to viewport changes. * fast/media/media-query-list-08-expected.txt: Added. * fast/media/media-query-list-08.html: Added. Skipping the new test in Qt due to an issue in its DumpRenderTree. * platform/qt/Skipped: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@114285 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- LayoutTests/ChangeLog | 16 ++++++++++ .../fast/media/media-query-list-08-expected.txt | 6 ++++ LayoutTests/fast/media/media-query-list-08.html | 34 ++++++++++++++++++++++ LayoutTests/platform/qt/Skipped | 3 ++ Source/WebCore/ChangeLog | 25 ++++++++++++++++ Source/WebCore/dom/Document.cpp | 9 ++++-- Source/WebCore/dom/Document.h | 2 ++ Source/WebCore/page/FrameView.cpp | 3 +- 8 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 LayoutTests/fast/media/media-query-list-08-expected.txt create mode 100644 LayoutTests/fast/media/media-query-list-08.html diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index d7841ec..ade3b1b 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,19 @@ +2012-04-16 Luiz Agostini + + matchMedia() MediaQueryList not updating + https://bugs.webkit.org/show_bug.cgi?id=75903 + + Reviewed by Antti Koivisto. + + Testing MediaQueryLists listeners related to viewport changes. + + * fast/media/media-query-list-08-expected.txt: Added. + * fast/media/media-query-list-08.html: Added. + + Skipping the new test in Qt due to an issue in its DumpRenderTree. + + * platform/qt/Skipped: + 2012-04-13 Simon Fraser Avoid using backing store for compositing layers that just need to clip diff --git a/LayoutTests/fast/media/media-query-list-08-expected.txt b/LayoutTests/fast/media/media-query-list-08-expected.txt new file mode 100644 index 0000000..d947f9a --- /dev/null +++ b/LayoutTests/fast/media/media-query-list-08-expected.txt @@ -0,0 +1,6 @@ +Test the MediaQueryList interface: http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface. + +Testing viewport related callbacks + +PASS + diff --git a/LayoutTests/fast/media/media-query-list-08.html b/LayoutTests/fast/media/media-query-list-08.html new file mode 100644 index 0000000..9b7c91e --- /dev/null +++ b/LayoutTests/fast/media/media-query-list-08.html @@ -0,0 +1,34 @@ + + +Test CSSOM View module: MediaQueryList interface + + + +

Test the MediaQueryList interface: http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface.

+

Testing viewport related callbacks

+
+
+ + diff --git a/LayoutTests/platform/qt/Skipped b/LayoutTests/platform/qt/Skipped index a639f4b..e080184 100644 --- a/LayoutTests/platform/qt/Skipped +++ b/LayoutTests/platform/qt/Skipped @@ -1108,6 +1108,9 @@ fast/autoresize fast/canvas/2d.backingStorePixelRatio.html fast/canvas/2d.imageDataHD.html +# window.resizeTo() does not trigger a relayout in our DumpRenderTree +fast/media/media-query-list-08.html + # This requires didClearWindowObjectForFrameInIsolatedWorld foo in FrameLoaderClient http/tests/security/isolatedWorld/didClearWindowObject.html # This needs more investigation diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 158a14e..5f9ac4f 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,28 @@ +2012-04-16 Luiz Agostini + + matchMedia() MediaQueryList not updating + https://bugs.webkit.org/show_bug.cgi?id=75903 + + Reviewed by Antti Koivisto. + + Test: fast/media/media-query-list-08.html + + Viewport related MediaQueryList listeners were not triggered and the value + of matches were not updated if the document's style selector were not + affected by viewport changes. + + The new method evaluateMediaQueries() is now called by FrameView instead of + styleSelectorChanged() if the style selector is not affected by viewport changes. + + * dom/Document.cpp: + (WebCore::Document::evaluateMediaQueries): + (WebCore): + (WebCore::Document::styleSelectorChanged): + * dom/Document.h: + (Document): + * page/FrameView.cpp: + (WebCore::FrameView::layout): + 2012-04-16 James Robinson [chromium] Delete uncalled unreserveContentsTextures function diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp index 53b9a70..81f2524 100644 --- a/Source/WebCore/dom/Document.cpp +++ b/Source/WebCore/dom/Document.cpp @@ -3145,6 +3145,12 @@ void Document::removePendingSheet() view()->scrollToFragment(m_url); } +void Document::evaluateMediaQueryList() +{ + if (m_mediaQueryMatcher) + m_mediaQueryMatcher->styleSelectorChanged(); +} + void Document::styleSelectorChanged(StyleSelectorUpdateFlag updateFlag) { // Don't bother updating, since we haven't loaded all our style info yet @@ -3194,8 +3200,7 @@ void Document::styleSelectorChanged(StyleSelectorUpdateFlag updateFlag) view()->scheduleRelayout(); } - if (m_mediaQueryMatcher) - m_mediaQueryMatcher->styleSelectorChanged(); + evaluateMediaQueryList(); } void Document::addStyleSheetCandidateNode(Node* node, bool createdByParser) diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h index 8950de5..4545c8a 100644 --- a/Source/WebCore/dom/Document.h +++ b/Source/WebCore/dom/Document.h @@ -505,6 +505,8 @@ public: */ void styleSelectorChanged(StyleSelectorUpdateFlag); + void evaluateMediaQueryList(); + bool usesSiblingRules() const { return m_usesSiblingRules || m_usesSiblingRulesOverride; } void setUsesSiblingRules(bool b) { m_usesSiblingRulesOverride = b; } bool usesFirstLineRules() const { return m_usesFirstLineRules; } diff --git a/Source/WebCore/page/FrameView.cpp b/Source/WebCore/page/FrameView.cpp index 844de28..472d73b 100644 --- a/Source/WebCore/page/FrameView.cpp +++ b/Source/WebCore/page/FrameView.cpp @@ -976,7 +976,8 @@ void FrameView::layout(bool allowSubtree) if (document->styleSelector()->affectedByViewportChange()) { document->styleSelectorChanged(RecalcStyleImmediately); InspectorInstrumentation::mediaQueryResultChanged(document); - } + } else + document->evaluateMediaQueryList(); // Always ensure our style info is up-to-date. This can happen in situations where // the layout beats any sort of style recalc update that needs to occur. -- 2.7.4