Title: [217197] trunk
Revision
217197
Author
an...@apple.com
Date
2017-05-21 08:08:18 -0700 (Sun, 21 May 2017)

Log Message

matchMedia('print').addListener() fires in WK1 but never in WK2 when printing (breaks printing Google maps, QuickLooks)
https://bugs.webkit.org/show_bug.cgi?id=172361
<rdar://problem/28777408>

Reviewed by Sam Weinig.

Source/WebCore:

Test: fast/media/matchMedia-print.html

* page/FrameView.cpp:
(WebCore::FrameView::layout):

    Evaluate matchMedia queries unconditionally. No idea why it wasn't like that.

* testing/Internals.cpp:
(WebCore::Internals::setPrinting):

    Add testing support. The existing ways to do printing testing were unable to hit this bug as
    they had too much additional gunk.

* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

* fast/media/matchMedia-print-expected.txt: Added.
* fast/media/matchMedia-print.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (217196 => 217197)


--- trunk/LayoutTests/ChangeLog	2017-05-21 14:40:10 UTC (rev 217196)
+++ trunk/LayoutTests/ChangeLog	2017-05-21 15:08:18 UTC (rev 217197)
@@ -1,3 +1,14 @@
+2017-05-21  Antti Koivisto  <an...@apple.com>
+
+        matchMedia('print').addListener() fires in WK1 but never in WK2 when printing (breaks printing Google maps, QuickLooks)
+        https://bugs.webkit.org/show_bug.cgi?id=172361
+        <rdar://problem/28777408>
+
+        Reviewed by Sam Weinig.
+
+        * fast/media/matchMedia-print-expected.txt: Added.
+        * fast/media/matchMedia-print.html: Added.
+
 2017-05-20  Alexey Proskuryakov  <a...@apple.com>
 
         Correct line endings in a couple files.

Added: trunk/LayoutTests/fast/media/matchMedia-print-expected.txt (0 => 217197)


--- trunk/LayoutTests/fast/media/matchMedia-print-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/media/matchMedia-print-expected.txt	2017-05-21 15:08:18 UTC (rev 217197)
@@ -0,0 +1,2 @@
+This document was
+printed

Added: trunk/LayoutTests/fast/media/matchMedia-print.html (0 => 217197)


--- trunk/LayoutTests/fast/media/matchMedia-print.html	                        (rev 0)
+++ trunk/LayoutTests/fast/media/matchMedia-print.html	2017-05-21 15:08:18 UTC (rev 217197)
@@ -0,0 +1,16 @@
+<script>
+if (window.testRunner)
+    testRunner.dumpAsText();
+</script>
+This document was
+<div id=test>not printed</div>
+<script>
+var mediaQueryList = window.matchMedia("print");
+mediaQueryList.addListener((e) => {
+    if (e.matches)
+        test.innerHTML = "printed";
+});
+
+if (window.internals)
+    window.internals.setPrinting(500,500);
+</script>

Modified: trunk/Source/WebCore/ChangeLog (217196 => 217197)


--- trunk/Source/WebCore/ChangeLog	2017-05-21 14:40:10 UTC (rev 217196)
+++ trunk/Source/WebCore/ChangeLog	2017-05-21 15:08:18 UTC (rev 217197)
@@ -1,3 +1,27 @@
+2017-05-21  Antti Koivisto  <an...@apple.com>
+
+        matchMedia('print').addListener() fires in WK1 but never in WK2 when printing (breaks printing Google maps, QuickLooks)
+        https://bugs.webkit.org/show_bug.cgi?id=172361
+        <rdar://problem/28777408>
+
+        Reviewed by Sam Weinig.
+
+        Test: fast/media/matchMedia-print.html
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::layout):
+
+            Evaluate matchMedia queries unconditionally. No idea why it wasn't like that.
+
+        * testing/Internals.cpp:
+        (WebCore::Internals::setPrinting):
+
+            Add testing support. The existing ways to do printing testing were unable to hit this bug as
+            they had too much additional gunk.
+
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2017-05-21  Zalan Bujtas  <za...@apple.com>
 
         Remove redundant FrameView ref in FrameView::performPostLayoutTasks

Modified: trunk/Source/WebCore/page/FrameView.cpp (217196 => 217197)


--- trunk/Source/WebCore/page/FrameView.cpp	2017-05-21 14:40:10 UTC (rev 217196)
+++ trunk/Source/WebCore/page/FrameView.cpp	2017-05-21 15:08:18 UTC (rev 217197)
@@ -1367,8 +1367,9 @@
             document.styleScope().didChangeStyleSheetEnvironment();
             // FIXME: This instrumentation event is not strictly accurate since cached media query results do not persist across StyleResolver rebuilds.
             InspectorInstrumentation::mediaQueryResultChanged(document);
-        } else
-            document.evaluateMediaQueryList();
+        }
+        
+        document.evaluateMediaQueryList();
 
         // If there is any pagination to apply, it will affect the RenderView's style, so we should
         // take care of that now.

Modified: trunk/Source/WebCore/testing/Internals.cpp (217196 => 217197)


--- trunk/Source/WebCore/testing/Internals.cpp	2017-05-21 14:40:10 UTC (rev 217196)
+++ trunk/Source/WebCore/testing/Internals.cpp	2017-05-21 15:08:18 UTC (rev 217197)
@@ -367,6 +367,12 @@
     return true;
 }
 
+static std::unique_ptr<PrintContext>& printContextForTesting()
+{
+    static NeverDestroyed<std::unique_ptr<PrintContext>> context;
+    return context;
+}
+
 const char* Internals::internalsId = "internals";
 
 Ref<Internals> Internals::create(Document& document)
@@ -448,6 +454,8 @@
     MockPreviewLoaderClient::singleton().setPassword("");
     PreviewLoader::setClientForTesting(nullptr);
 #endif
+
+    printContextForTesting() = nullptr;
 }
 
 Internals::Internals(Document& document)
@@ -2602,6 +2610,12 @@
     return { };
 }
 
+void Internals::setPrinting(int width, int height)
+{
+    printContextForTesting() = std::make_unique<PrintContext>(frame());
+    printContextForTesting()->begin(width, height);
+}
+
 void Internals::setHeaderHeight(float height)
 {
     Document* document = contextDocument();

Modified: trunk/Source/WebCore/testing/Internals.h (217196 => 217197)


--- trunk/Source/WebCore/testing/Internals.h	2017-05-21 14:40:10 UTC (rev 217196)
+++ trunk/Source/WebCore/testing/Internals.h	2017-05-21 15:08:18 UTC (rev 217197)
@@ -344,6 +344,7 @@
     ExceptionOr<void> setUseFixedLayout(bool);
     ExceptionOr<void> setFixedLayoutSize(int width, int height);
     ExceptionOr<void> setViewExposedRect(float left, float top, float width, float height);
+    void setPrinting(int width, int height);
 
     void setHeaderHeight(float);
     void setFooterHeight(float);

Modified: trunk/Source/WebCore/testing/Internals.idl (217196 => 217197)


--- trunk/Source/WebCore/testing/Internals.idl	2017-05-21 14:40:10 UTC (rev 217196)
+++ trunk/Source/WebCore/testing/Internals.idl	2017-05-21 15:08:18 UTC (rev 217197)
@@ -323,6 +323,7 @@
 
     [MayThrowException] void setUseFixedLayout(boolean useFixedLayout);
     [MayThrowException] void setFixedLayoutSize(long width, long height);
+    void setPrinting(long width, long height);
 
     [MayThrowException] void setViewExposedRect(unrestricted float x, unrestricted float y, unrestricted float width, unrestricted float height);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to