Diff
Modified: branches/safari-604-branch/LayoutTests/ChangeLog (220755 => 220756)
--- branches/safari-604-branch/LayoutTests/ChangeLog 2017-08-15 20:36:50 UTC (rev 220755)
+++ branches/safari-604-branch/LayoutTests/ChangeLog 2017-08-15 20:41:46 UTC (rev 220756)
@@ -1,3 +1,18 @@
+2017-08-15 Jason Marcell <jmarc...@apple.com>
+
+ Cherry-pick r217197. rdar://problem/33890650
+
+ 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-08-14 Jason Marcell <jmarc...@apple.com>
Revert r217197. rdar://problem/33890650
Added: branches/safari-604-branch/LayoutTests/fast/media/matchMedia-print-expected.txt (0 => 220756)
--- branches/safari-604-branch/LayoutTests/fast/media/matchMedia-print-expected.txt (rev 0)
+++ branches/safari-604-branch/LayoutTests/fast/media/matchMedia-print-expected.txt 2017-08-15 20:41:46 UTC (rev 220756)
@@ -0,0 +1,2 @@
+This document was
+printed
Added: branches/safari-604-branch/LayoutTests/fast/media/matchMedia-print.html (0 => 220756)
--- branches/safari-604-branch/LayoutTests/fast/media/matchMedia-print.html (rev 0)
+++ branches/safari-604-branch/LayoutTests/fast/media/matchMedia-print.html 2017-08-15 20:41:46 UTC (rev 220756)
@@ -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: branches/safari-604-branch/Source/WebCore/ChangeLog (220755 => 220756)
--- branches/safari-604-branch/Source/WebCore/ChangeLog 2017-08-15 20:36:50 UTC (rev 220755)
+++ branches/safari-604-branch/Source/WebCore/ChangeLog 2017-08-15 20:41:46 UTC (rev 220756)
@@ -1,3 +1,31 @@
+2017-08-15 Jason Marcell <jmarc...@apple.com>
+
+ Cherry-pick r217197. rdar://problem/33890650
+
+ 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-08-15 Matthew Hanson <matthew_han...@apple.com>
Cherry-pick r220722. rdar://problem/33890577
Modified: branches/safari-604-branch/Source/WebCore/page/FrameView.cpp (220755 => 220756)
--- branches/safari-604-branch/Source/WebCore/page/FrameView.cpp 2017-08-15 20:36:50 UTC (rev 220755)
+++ branches/safari-604-branch/Source/WebCore/page/FrameView.cpp 2017-08-15 20:41:46 UTC (rev 220756)
@@ -1369,8 +1369,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: branches/safari-604-branch/Source/WebCore/testing/Internals.cpp (220755 => 220756)
--- branches/safari-604-branch/Source/WebCore/testing/Internals.cpp 2017-08-15 20:36:50 UTC (rev 220755)
+++ branches/safari-604-branch/Source/WebCore/testing/Internals.cpp 2017-08-15 20:41:46 UTC (rev 220756)
@@ -375,6 +375,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)
@@ -463,6 +469,8 @@
#endif
ResourceLoadObserver::shared().setShouldThrottleObserverNotifications(true);
+
+ printContextForTesting() = nullptr;
}
Internals::Internals(Document& document)
@@ -2603,6 +2611,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: branches/safari-604-branch/Source/WebCore/testing/Internals.h (220755 => 220756)
--- branches/safari-604-branch/Source/WebCore/testing/Internals.h 2017-08-15 20:36:50 UTC (rev 220755)
+++ branches/safari-604-branch/Source/WebCore/testing/Internals.h 2017-08-15 20:41:46 UTC (rev 220756)
@@ -350,6 +350,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: branches/safari-604-branch/Source/WebCore/testing/Internals.idl (220755 => 220756)
--- branches/safari-604-branch/Source/WebCore/testing/Internals.idl 2017-08-15 20:36:50 UTC (rev 220755)
+++ branches/safari-604-branch/Source/WebCore/testing/Internals.idl 2017-08-15 20:41:46 UTC (rev 220756)
@@ -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);