Diff
Modified: trunk/LayoutTests/ChangeLog (243761 => 243762)
--- trunk/LayoutTests/ChangeLog 2019-04-02 21:15:08 UTC (rev 243761)
+++ trunk/LayoutTests/ChangeLog 2019-04-02 21:43:24 UTC (rev 243762)
@@ -1,3 +1,17 @@
+2019-04-02 Chris Dumez <[email protected]>
+
+ [WK2] Add support for Window's beforeprint / afterprint events
+ https://bugs.webkit.org/show_bug.cgi?id=196478
+
+ Reviewed by Alex Christensen.
+
+ Add layout test coverage.
+
+ * TestExpectations:
+ * platform/wk2/TestExpectations:
+ * printing/printing-events-expected.txt: Added.
+ * printing/printing-events.html: Added.
+
2019-04-02 Zalan Bujtas <[email protected]>
[ContentChangeObserver] Hover menus do not function on fidelity.com
Modified: trunk/LayoutTests/TestExpectations (243761 => 243762)
--- trunk/LayoutTests/TestExpectations 2019-04-02 21:15:08 UTC (rev 243761)
+++ trunk/LayoutTests/TestExpectations 2019-04-02 21:43:24 UTC (rev 243762)
@@ -58,6 +58,9 @@
editing/pasteboard/ios [ Skip ]
editing/pasteboard/mac [ Skip ]
+# WebKit2 only.
+printing/printing-events.html [ Skip ]
+
http/tests/security/xss-DENIED-xsl-external-entity-no-logging.xml [ Skip ]
# window.showModalDialog is only tested in DumpRenderTree on Mac.
@@ -3074,4 +3077,4 @@
webkit.org/b/196274 imported/w3c/web-platform-tests/xhr/send-redirect-post-upload.htm [ Pass Failure ]
# If requestAnimationFrame is invoked before ResizeObserver timer fired, it would pass, otherwise it would fail same as eventloop-expected.txt
-webkit.org/b/157743 imported/w3c/web-platform-tests/resize-observer/eventloop.html [ Pass Failure ]
\ No newline at end of file
+webkit.org/b/157743 imported/w3c/web-platform-tests/resize-observer/eventloop.html [ Pass Failure ]
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (243761 => 243762)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2019-04-02 21:15:08 UTC (rev 243761)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2019-04-02 21:43:24 UTC (rev 243762)
@@ -1,5 +1,21 @@
2019-04-02 Chris Dumez <[email protected]>
+ [WK2] Add support for Window's beforeprint / afterprint events
+ https://bugs.webkit.org/show_bug.cgi?id=196478
+
+ Reviewed by Alex Christensen.
+
+ Rebaseline WPT tests now that more checks are passing.
+
+ * web-platform-tests/html/browsers/the-window-object/security-window/window-security.https-expected.txt:
+ * web-platform-tests/html/browsers/the-window-object/security-window/window-security.sub-expected.txt:
+ * web-platform-tests/html/browsers/the-window-object/window-properties.https-expected.txt:
+ * web-platform-tests/html/dom/interfaces-expected.txt:
+ * web-platform-tests/html/webappapis/scripting/events/body-exposed-window-event-handlers-expected.txt:
+ * web-platform-tests/html/webappapis/scripting/events/event-handler-attributes-body-window-expected.txt:
+
+2019-04-02 Chris Dumez <[email protected]>
+
[Fetch API] Allow used body replacement in Request constructor
https://bugs.webkit.org/show_bug.cgi?id=183703
<rdar://problem/49425609>
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-window-object/security-window/window-security.https-expected.txt (243761 => 243762)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-window-object/security-window/window-security.https-expected.txt 2019-04-02 21:15:08 UTC (rev 243761)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-window-object/security-window/window-security.https-expected.txt 2019-04-02 21:43:24 UTC (rev 243762)
@@ -14,8 +14,8 @@
PASS A SecurityError exception must be thrown when window.name is accessed from a different origin.
PASS A SecurityError exception must be thrown when window.navigator is accessed from a different origin.
PASS A SecurityError exception must be thrown when window.onabort is accessed from a different origin.
-FAIL A SecurityError exception must be thrown when window.onafterprint is accessed from a different origin. assert_true: window.onafterprint should exist. expected true got false
-FAIL A SecurityError exception must be thrown when window.onbeforeprint is accessed from a different origin. assert_true: window.onbeforeprint should exist. expected true got false
+PASS A SecurityError exception must be thrown when window.onafterprint is accessed from a different origin.
+PASS A SecurityError exception must be thrown when window.onbeforeprint is accessed from a different origin.
PASS A SecurityError exception must be thrown when window.onbeforeunload is accessed from a different origin.
PASS A SecurityError exception must be thrown when window.onblur is accessed from a different origin.
FAIL A SecurityError exception must be thrown when window.oncancel is accessed from a different origin. assert_true: window.oncancel should exist. expected true got false
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-window-object/security-window/window-security.sub-expected.txt (243761 => 243762)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-window-object/security-window/window-security.sub-expected.txt 2019-04-02 21:15:08 UTC (rev 243761)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-window-object/security-window/window-security.sub-expected.txt 2019-04-02 21:43:24 UTC (rev 243762)
@@ -14,8 +14,8 @@
PASS A SecurityError exception must be thrown when window.name is accessed from a different origin.
PASS A SecurityError exception must be thrown when window.navigator is accessed from a different origin.
PASS A SecurityError exception must be thrown when window.onabort is accessed from a different origin.
-FAIL A SecurityError exception must be thrown when window.onafterprint is accessed from a different origin. assert_true: window.onafterprint should exist. expected true got false
-FAIL A SecurityError exception must be thrown when window.onbeforeprint is accessed from a different origin. assert_true: window.onbeforeprint should exist. expected true got false
+PASS A SecurityError exception must be thrown when window.onafterprint is accessed from a different origin.
+PASS A SecurityError exception must be thrown when window.onbeforeprint is accessed from a different origin.
PASS A SecurityError exception must be thrown when window.onbeforeunload is accessed from a different origin.
PASS A SecurityError exception must be thrown when window.onblur is accessed from a different origin.
FAIL A SecurityError exception must be thrown when window.oncancel is accessed from a different origin. assert_true: window.oncancel should exist. expected true got false
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-window-object/window-properties.https-expected.txt (243761 => 243762)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-window-object/window-properties.https-expected.txt 2019-04-02 21:15:08 UTC (rev 243761)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-window-object/window-properties.https-expected.txt 2019-04-02 21:43:24 UTC (rev 243762)
@@ -76,8 +76,8 @@
PASS Window attribute: status
PASS Window attribute: opener
PASS Window attribute: onabort
-FAIL Window attribute: onafterprint assert_true: onafterprint in window expected true got false
-FAIL Window attribute: onbeforeprint assert_true: onbeforeprint in window expected true got false
+PASS Window attribute: onafterprint
+PASS Window attribute: onbeforeprint
PASS Window attribute: onbeforeunload
PASS Window attribute: onblur
FAIL Window attribute: oncancel assert_true: oncancel in window expected true got false
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt (243761 => 243762)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt 2019-04-02 21:15:08 UTC (rev 243761)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt 2019-04-02 21:43:24 UTC (rev 243762)
@@ -5,8 +5,6 @@
CONSOLE MESSAGE: line 482: callback not yet supported
CONSOLE MESSAGE: line 482: callback not yet supported
CONSOLE MESSAGE: line 482: callback not yet supported
-CONSOLE MESSAGE: WebSocket network error: The operation couldn’t be completed. (kCFErrorDomainCFNetwork error 2.)
-CONSOLE MESSAGE: WebSocket network error: The operation couldn’t be completed. (kCFErrorDomainCFNetwork error 2.)
HTML IDL tests
@@ -896,8 +894,8 @@
PASS HTMLBodyElement interface: attribute aLink
PASS HTMLBodyElement interface: attribute bgColor
PASS HTMLBodyElement interface: attribute background
-FAIL HTMLBodyElement interface: attribute onafterprint assert_true: The prototype object must have a property "onafterprint" expected true got false
-FAIL HTMLBodyElement interface: attribute onbeforeprint assert_true: The prototype object must have a property "onbeforeprint" expected true got false
+PASS HTMLBodyElement interface: attribute onafterprint
+PASS HTMLBodyElement interface: attribute onbeforeprint
PASS HTMLBodyElement interface: attribute onbeforeunload
PASS HTMLBodyElement interface: attribute onhashchange
PASS HTMLBodyElement interface: attribute onlanguagechange
@@ -920,8 +918,8 @@
PASS HTMLBodyElement interface: document.createElement("body") must inherit property "aLink" with the proper type
PASS HTMLBodyElement interface: document.createElement("body") must inherit property "bgColor" with the proper type
PASS HTMLBodyElement interface: document.createElement("body") must inherit property "background" with the proper type
-FAIL HTMLBodyElement interface: document.createElement("body") must inherit property "onafterprint" with the proper type assert_inherits: property "onafterprint" not found in prototype chain
-FAIL HTMLBodyElement interface: document.createElement("body") must inherit property "onbeforeprint" with the proper type assert_inherits: property "onbeforeprint" not found in prototype chain
+PASS HTMLBodyElement interface: document.createElement("body") must inherit property "onafterprint" with the proper type
+PASS HTMLBodyElement interface: document.createElement("body") must inherit property "onbeforeprint" with the proper type
PASS HTMLBodyElement interface: document.createElement("body") must inherit property "onbeforeunload" with the proper type
PASS HTMLBodyElement interface: document.createElement("body") must inherit property "onhashchange" with the proper type
PASS HTMLBodyElement interface: document.createElement("body") must inherit property "onlanguagechange" with the proper type
@@ -4684,8 +4682,8 @@
PASS Window interface: attribute ontoggle
PASS Window interface: attribute onvolumechange
PASS Window interface: attribute onwaiting
-FAIL Window interface: attribute onafterprint assert_own_property: The global object must have a property "onafterprint" expected property "onafterprint" missing
-FAIL Window interface: attribute onbeforeprint assert_own_property: The global object must have a property "onbeforeprint" expected property "onbeforeprint" missing
+PASS Window interface: attribute onafterprint
+PASS Window interface: attribute onbeforeprint
PASS Window interface: attribute onbeforeunload
PASS Window interface: attribute onhashchange
PASS Window interface: attribute onlanguagechange
@@ -4827,8 +4825,8 @@
PASS Window interface: window must inherit property "ontoggle" with the proper type
PASS Window interface: window must inherit property "onvolumechange" with the proper type
PASS Window interface: window must inherit property "onwaiting" with the proper type
-FAIL Window interface: window must inherit property "onafterprint" with the proper type assert_own_property: expected property "onafterprint" missing
-FAIL Window interface: window must inherit property "onbeforeprint" with the proper type assert_own_property: expected property "onbeforeprint" missing
+PASS Window interface: window must inherit property "onafterprint" with the proper type
+PASS Window interface: window must inherit property "onbeforeprint" with the proper type
PASS Window interface: window must inherit property "onbeforeunload" with the proper type
PASS Window interface: window must inherit property "onhashchange" with the proper type
PASS Window interface: window must inherit property "onlanguagechange" with the proper type
@@ -5359,8 +5357,8 @@
PASS HTMLFrameSetElement interface: existence and properties of interface prototype object's @@unscopables property
PASS HTMLFrameSetElement interface: attribute cols
PASS HTMLFrameSetElement interface: attribute rows
-FAIL HTMLFrameSetElement interface: attribute onafterprint assert_true: The prototype object must have a property "onafterprint" expected true got false
-FAIL HTMLFrameSetElement interface: attribute onbeforeprint assert_true: The prototype object must have a property "onbeforeprint" expected true got false
+PASS HTMLFrameSetElement interface: attribute onafterprint
+PASS HTMLFrameSetElement interface: attribute onbeforeprint
PASS HTMLFrameSetElement interface: attribute onbeforeunload
PASS HTMLFrameSetElement interface: attribute onhashchange
PASS HTMLFrameSetElement interface: attribute onlanguagechange
@@ -5379,8 +5377,8 @@
PASS Stringification of document.createElement("frameset")
PASS HTMLFrameSetElement interface: document.createElement("frameset") must inherit property "cols" with the proper type
PASS HTMLFrameSetElement interface: document.createElement("frameset") must inherit property "rows" with the proper type
-FAIL HTMLFrameSetElement interface: document.createElement("frameset") must inherit property "onafterprint" with the proper type assert_inherits: property "onafterprint" not found in prototype chain
-FAIL HTMLFrameSetElement interface: document.createElement("frameset") must inherit property "onbeforeprint" with the proper type assert_inherits: property "onbeforeprint" not found in prototype chain
+PASS HTMLFrameSetElement interface: document.createElement("frameset") must inherit property "onafterprint" with the proper type
+PASS HTMLFrameSetElement interface: document.createElement("frameset") must inherit property "onbeforeprint" with the proper type
PASS HTMLFrameSetElement interface: document.createElement("frameset") must inherit property "onbeforeunload" with the proper type
PASS HTMLFrameSetElement interface: document.createElement("frameset") must inherit property "onhashchange" with the proper type
PASS HTMLFrameSetElement interface: document.createElement("frameset") must inherit property "onlanguagechange" with the proper type
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/events/body-exposed-window-event-handlers-expected.txt (243761 => 243762)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/events/body-exposed-window-event-handlers-expected.txt 2019-04-02 21:15:08 UTC (rev 243761)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/events/body-exposed-window-event-handlers-expected.txt 2019-04-02 21:43:24 UTC (rev 243762)
@@ -9,10 +9,10 @@
PASS Ignore setting of focus window event handlers on windowless body
PASS Return null when getting the scroll event handler of a windowless body
PASS Ignore setting of scroll window event handlers on windowless body
-FAIL Return null when getting the afterprint event handler of a windowless body assert_equals: expected (object) null but got (undefined) undefined
-FAIL Ignore setting of afterprint window event handlers on windowless body assert_equals: expected (object) null but got (function) function "function () { return "Handler attached to windowless element"; }"
-FAIL Return null when getting the beforeprint event handler of a windowless body assert_equals: expected (object) null but got (undefined) undefined
-FAIL Ignore setting of beforeprint window event handlers on windowless body assert_equals: expected (object) null but got (function) function "function () { return "Handler attached to windowless element"; }"
+PASS Return null when getting the afterprint event handler of a windowless body
+PASS Ignore setting of afterprint window event handlers on windowless body
+PASS Return null when getting the beforeprint event handler of a windowless body
+PASS Ignore setting of beforeprint window event handlers on windowless body
PASS Return null when getting the beforeunload event handler of a windowless body
PASS Ignore setting of beforeunload window event handlers on windowless body
PASS Return null when getting the hashchange event handler of a windowless body
@@ -49,10 +49,10 @@
PASS Ignore setting of focus window event handlers on windowless frameset
PASS Return null when getting the scroll event handler of a windowless frameset
PASS Ignore setting of scroll window event handlers on windowless frameset
-FAIL Return null when getting the afterprint event handler of a windowless frameset assert_equals: expected (object) null but got (undefined) undefined
-FAIL Ignore setting of afterprint window event handlers on windowless frameset assert_equals: expected (object) null but got (function) function "function () { return "Handler attached to windowless element"; }"
-FAIL Return null when getting the beforeprint event handler of a windowless frameset assert_equals: expected (object) null but got (undefined) undefined
-FAIL Ignore setting of beforeprint window event handlers on windowless frameset assert_equals: expected (object) null but got (function) function "function () { return "Handler attached to windowless element"; }"
+PASS Return null when getting the afterprint event handler of a windowless frameset
+PASS Ignore setting of afterprint window event handlers on windowless frameset
+PASS Return null when getting the beforeprint event handler of a windowless frameset
+PASS Ignore setting of beforeprint window event handlers on windowless frameset
PASS Return null when getting the beforeunload event handler of a windowless frameset
PASS Ignore setting of beforeunload window event handlers on windowless frameset
PASS Return null when getting the hashchange event handler of a windowless frameset
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/events/event-handler-attributes-body-window-expected.txt (243761 => 243762)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/events/event-handler-attributes-body-window-expected.txt 2019-04-02 21:15:08 UTC (rev 243761)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/events/event-handler-attributes-body-window-expected.txt 2019-04-02 21:43:24 UTC (rev 243762)
@@ -5,12 +5,8 @@
PASS load
PASS resize
PASS scroll
-FAIL afterprint assert_equals: expected (function) function "function f() {
- return 0;
-}" but got (undefined) undefined
-FAIL beforeprint assert_equals: expected (function) function "function f() {
- return 0;
-}" but got (undefined) undefined
+PASS afterprint
+PASS beforeprint
PASS beforeunload
PASS hashchange
PASS languagechange
@@ -28,8 +24,8 @@
PASS load removal
PASS resize removal
PASS scroll removal
-FAIL afterprint removal assert_equals: expected (object) null but got (undefined) undefined
-FAIL beforeprint removal assert_equals: expected (object) null but got (undefined) undefined
+PASS afterprint removal
+PASS beforeprint removal
PASS beforeunload removal
PASS hashchange removal
PASS languagechange removal
Modified: trunk/LayoutTests/platform/wk2/TestExpectations (243761 => 243762)
--- trunk/LayoutTests/platform/wk2/TestExpectations 2019-04-02 21:15:08 UTC (rev 243761)
+++ trunk/LayoutTests/platform/wk2/TestExpectations 2019-04-02 21:43:24 UTC (rev 243762)
@@ -702,6 +702,8 @@
# bug 162281
imported/w3c/web-platform-tests/fetch/api/request/request-cache-only-if-cached.html [ Failure ]
+printing/printing-events.html [ Pass ]
+
# Resource Load Statistics are only supported in WebKit2.
http/tests/resourceLoadStatistics/prevalent-resource-with-user-interaction.html [ Pass ]
http/tests/resourceLoadStatistics/non-prevalent-resource-with-user-interaction.html [ Pass ]
Added: trunk/LayoutTests/printing/printing-events-expected.txt (0 => 243762)
--- trunk/LayoutTests/printing/printing-events-expected.txt (rev 0)
+++ trunk/LayoutTests/printing/printing-events-expected.txt 2019-04-02 21:43:24 UTC (rev 243762)
@@ -0,0 +1,13 @@
+Basic testing for beforeprint / afterprint events
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+window.print()
+* Received beforeprint event
+* Received afterprint event
+PASS receivedBeforePrintEvent is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/printing/printing-events.html (0 => 243762)
--- trunk/LayoutTests/printing/printing-events.html (rev 0)
+++ trunk/LayoutTests/printing/printing-events.html 2019-04-02 21:43:24 UTC (rev 243762)
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+description("Basic testing for beforeprint / afterprint events");
+jsTestIsAsync = true;
+let receivedBeforePrintEvent = false;
+
+addEventListener("beforeprint", () => {
+ debug("* Received beforeprint event");
+ receivedBeforePrintEvent = true;
+});
+
+addEventListener("afterprint", () => {
+ debug("* Received afterprint event");
+ shouldBeTrue("receivedBeforePrintEvent");
+ finishJSTest();
+});
+
+_onload_ = () => {
+ evalAndLog("window.print()");
+};
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (243761 => 243762)
--- trunk/Source/WebCore/ChangeLog 2019-04-02 21:15:08 UTC (rev 243761)
+++ trunk/Source/WebCore/ChangeLog 2019-04-02 21:43:24 UTC (rev 243762)
@@ -1,3 +1,28 @@
+2019-04-02 Chris Dumez <[email protected]>
+
+ [WK2] Add support for Window's beforeprint / afterprint events
+ https://bugs.webkit.org/show_bug.cgi?id=196478
+
+ Reviewed by Alex Christensen.
+
+ Add support for Window's beforeprint / afterprint events as per:
+ - https://html.spec.whatwg.org/#dom-print
+
+ Blink and Gecko already support this.
+
+ Test: printing/printing-events.html
+
+ * dom/EventNames.h:
+ * html/HTMLAttributeNames.in:
+ * html/HTMLBodyElement.cpp:
+ (WebCore::HTMLBodyElement::createWindowEventHandlerNameMap):
+ * page/Page.cpp:
+ (WebCore::dispatchPrintEvent):
+ (WebCore::Page::dispatchBeforePrintEvent):
+ (WebCore::Page::dispatchAfterPrintEvent):
+ * page/Page.h:
+ * page/WindowEventHandlers.idl:
+
2019-04-02 Zalan Bujtas <[email protected]>
[ContentChangeObserver] Hover menus do not function on fidelity.com
Modified: trunk/Source/WebCore/dom/EventNames.h (243761 => 243762)
--- trunk/Source/WebCore/dom/EventNames.h 2019-04-02 21:15:08 UTC (rev 243761)
+++ trunk/Source/WebCore/dom/EventNames.h 2019-04-02 21:43:24 UTC (rev 243762)
@@ -63,6 +63,7 @@
macro(addsourcebuffer) \
macro(addstream) \
macro(addtrack) \
+ macro(afterprint) \
macro(animationcancel) \
macro(animationend) \
macro(animationiteration) \
@@ -77,6 +78,7 @@
macro(beforeinput) \
macro(beforeload) \
macro(beforepaste) \
+ macro(beforeprint) \
macro(beforeunload) \
macro(beginEvent) \
macro(blocked) \
Modified: trunk/Source/WebCore/html/HTMLAttributeNames.in (243761 => 243762)
--- trunk/Source/WebCore/html/HTMLAttributeNames.in 2019-04-02 21:15:08 UTC (rev 243761)
+++ trunk/Source/WebCore/html/HTMLAttributeNames.in 2019-04-02 21:43:24 UTC (rev 243762)
@@ -202,6 +202,7 @@
onaccessiblescrollintoview
onaccessiblesetvalue
onaccessibleselect
+onafterprint
onanimationstart
onanimationiteration
onanimationend
@@ -213,6 +214,7 @@
onbeforeinput
onbeforeload
onbeforepaste
+onbeforeprint
onbeforeunload
onblur
oncanplay
Modified: trunk/Source/WebCore/html/HTMLBodyElement.cpp (243761 => 243762)
--- trunk/Source/WebCore/html/HTMLBodyElement.cpp 2019-04-02 21:15:08 UTC (rev 243761)
+++ trunk/Source/WebCore/html/HTMLBodyElement.cpp 2019-04-02 21:43:24 UTC (rev 243762)
@@ -98,6 +98,8 @@
HTMLElement::EventHandlerNameMap HTMLBodyElement::createWindowEventHandlerNameMap()
{
static const QualifiedName* const table[] = {
+ &onafterprintAttr.get(),
+ &onbeforeprintAttr.get(),
&onbeforeunloadAttr.get(),
&onblurAttr.get(),
&onerrorAttr.get(),
Modified: trunk/Source/WebCore/page/Page.cpp (243761 => 243762)
--- trunk/Source/WebCore/page/Page.cpp 2019-04-02 21:15:08 UTC (rev 243761)
+++ trunk/Source/WebCore/page/Page.cpp 2019-04-02 21:43:24 UTC (rev 243762)
@@ -2988,6 +2988,28 @@
}
#endif // PLATFORM(MAC)
+static void dispatchPrintEvent(Frame& mainFrame, const AtomicString& eventType)
+{
+ Vector<Ref<Frame>> frames;
+ for (auto* frame = &mainFrame; frame; frame = frame->tree().traverseNext())
+ frames.append(*frame);
+
+ for (auto& frame : frames) {
+ if (auto* window = frame->window())
+ window->dispatchEvent(Event::create(eventType, Event::CanBubble::No, Event::IsCancelable::No), window->document());
+ }
+}
+
+void Page::dispatchBeforePrintEvent()
+{
+ dispatchPrintEvent(m_mainFrame, eventNames().beforeprintEvent);
+}
+
+void Page::dispatchAfterPrintEvent()
+{
+ dispatchPrintEvent(m_mainFrame, eventNames().afterprintEvent);
+}
+
#if ENABLE(APPLE_PAY)
void Page::setPaymentCoordinator(std::unique_ptr<PaymentCoordinator>&& paymentCoordinator)
{
Modified: trunk/Source/WebCore/page/Page.h (243761 => 243762)
--- trunk/Source/WebCore/page/Page.h 2019-04-02 21:15:08 UTC (rev 243761)
+++ trunk/Source/WebCore/page/Page.h 2019-04-02 21:43:24 UTC (rev 243762)
@@ -296,6 +296,9 @@
WEBCORE_EXPORT void unmarkAllTextMatches();
+ WEBCORE_EXPORT void dispatchBeforePrintEvent();
+ WEBCORE_EXPORT void dispatchAfterPrintEvent();
+
// find all the Ranges for the matching text.
// Upon return, indexForSelection will be one of the following:
// 0 if there is no user selection
Modified: trunk/Source/WebCore/page/WindowEventHandlers.idl (243761 => 243762)
--- trunk/Source/WebCore/page/WindowEventHandlers.idl 2019-04-02 21:15:08 UTC (rev 243761)
+++ trunk/Source/WebCore/page/WindowEventHandlers.idl 2019-04-02 21:43:24 UTC (rev 243762)
@@ -31,8 +31,8 @@
// Commented out event handlers are defined by the HTML5 specification but
// are not yet implemented.
- // [WindowEventHandler] attribute EventHandler onafterprint;.
- // [WindowEventHandler] attribute EventHandler onbeforeprint;.
+ [WindowEventHandler] attribute EventHandler onafterprint;
+ [WindowEventHandler] attribute EventHandler onbeforeprint;
[WindowEventHandler] attribute EventHandler onbeforeunload;
[WindowEventHandler] attribute EventHandler onhashchange;
[WindowEventHandler] attribute EventHandler onlanguagechange;
Modified: trunk/Source/WebKit/ChangeLog (243761 => 243762)
--- trunk/Source/WebKit/ChangeLog 2019-04-02 21:15:08 UTC (rev 243761)
+++ trunk/Source/WebKit/ChangeLog 2019-04-02 21:43:24 UTC (rev 243762)
@@ -1,3 +1,19 @@
+2019-04-02 Chris Dumez <[email protected]>
+
+ [WK2] Add support for Window's beforeprint / afterprint events
+ https://bugs.webkit.org/show_bug.cgi?id=196478
+
+ Reviewed by Alex Christensen.
+
+ Add support for Window's beforeprint / afterprint events as per:
+ - https://html.spec.whatwg.org/#dom-print
+
+ Blink and Gecko already support this.
+
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::beginPrinting):
+ (WebKit::WebPage::endPrinting):
+
2019-04-02 Wenson Hsieh <[email protected]>
REGRESSION (r243726): Crash at unrecognized selector: -[WKWebpagePreferences webpagePreferences]
Modified: trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp (243761 => 243762)
--- trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp 2019-04-02 21:15:08 UTC (rev 243761)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp 2019-04-02 21:43:24 UTC (rev 243762)
@@ -2406,7 +2406,6 @@
toImpl(pageRef)->executeEditCommand(toImpl(command)->string());
}
-#if PLATFORM(COCOA)
static PrintInfo printInfoFromWKPrintInfo(const WKPrintInfo& printInfo)
{
PrintInfo result;
@@ -2426,14 +2425,16 @@
}));
}
-void WKPageBeginPrinting(WKPageRef page, WKFrameRef frame, WKPrintInfo printInfo)
+#if PLATFORM(COCOA)
+void WKPageDrawPagesToPDF(WKPageRef page, WKFrameRef frame, WKPrintInfo printInfo, uint32_t first, uint32_t count, WKPageDrawToPDFFunction callback, void* context)
{
- toImpl(page)->beginPrinting(toImpl(frame), printInfoFromWKPrintInfo(printInfo));
+ toImpl(page)->drawPagesToPDF(toImpl(frame), printInfoFromWKPrintInfo(printInfo), first, count, DataCallback::create(toGenericCallbackFunction(context, callback)));
}
+#endif
-void WKPageDrawPagesToPDF(WKPageRef page, WKFrameRef frame, WKPrintInfo printInfo, uint32_t first, uint32_t count, WKPageDrawToPDFFunction callback, void* context)
+void WKPageBeginPrinting(WKPageRef page, WKFrameRef frame, WKPrintInfo printInfo)
{
- toImpl(page)->drawPagesToPDF(toImpl(frame), printInfoFromWKPrintInfo(printInfo), first, count, DataCallback::create(toGenericCallbackFunction(context, callback)));
+ toImpl(page)->beginPrinting(toImpl(frame), printInfoFromWKPrintInfo(printInfo));
}
void WKPageEndPrinting(WKPageRef page)
@@ -2440,7 +2441,6 @@
{
toImpl(page)->endPrinting();
}
-#endif
bool WKPageGetIsControlledByAutomation(WKPageRef page)
{
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (243761 => 243762)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2019-04-02 21:15:08 UTC (rev 243761)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2019-04-02 21:43:24 UTC (rev 243762)
@@ -4607,8 +4607,10 @@
return;
#endif
- if (!m_printContext)
+ if (!m_printContext) {
m_printContext = std::make_unique<PrintContext>(coreFrame);
+ m_page->dispatchBeforePrintEvent();
+ }
freezeLayerTree(LayerTreeFreezeReason::Printing);
@@ -4627,7 +4629,10 @@
{
unfreezeLayerTree(LayerTreeFreezeReason::Printing);
- m_printContext = nullptr;
+ if (m_printContext) {
+ m_printContext = nullptr;
+ m_page->dispatchAfterPrintEvent();
+ }
}
void WebPage::computePagesForPrinting(uint64_t frameID, const PrintInfo& printInfo, CallbackID callbackID)
Modified: trunk/Tools/ChangeLog (243761 => 243762)
--- trunk/Tools/ChangeLog 2019-04-02 21:15:08 UTC (rev 243761)
+++ trunk/Tools/ChangeLog 2019-04-02 21:43:24 UTC (rev 243762)
@@ -1,3 +1,17 @@
+2019-04-02 Chris Dumez <[email protected]>
+
+ [WK2] Add support for Window's beforeprint / afterprint events
+ https://bugs.webkit.org/show_bug.cgi?id=196478
+
+ Reviewed by Alex Christensen.
+
+ Add minimal implementation for printFrame in WebKitTestRunner.
+
+ * WebKitTestRunner/TestController.cpp:
+ (WTR::printFrame):
+ (WTR::TestController::createOtherPage):
+ (WTR::TestController::createWebViewWithOptions):
+
2019-04-02 Aakash Jain <[email protected]>
[ews-app] Status bubble hover over message should clearly indicate that build is in-progress
Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (243761 => 243762)
--- trunk/Tools/WebKitTestRunner/TestController.cpp 2019-04-02 21:15:08 UTC (rev 243761)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp 2019-04-02 21:43:24 UTC (rev 243762)
@@ -262,6 +262,12 @@
WKPageDidAllowPointerLock(page);
}
+static void printFrame(WKPageRef page, WKFrameRef frame, const void*)
+{
+ WKPageBeginPrinting(page, frame, WKPrintInfo { 1.0, 21.0, 29.7 });
+ WKPageEndPrinting(page);
+}
+
static bool shouldAllowDeviceOrientationAndMotionAccess(WKPageRef, WKSecurityOriginRef origin, const void*)
{
return TestController::singleton().handleDeviceOrientationAndMotionAccessRequest(origin);
@@ -320,7 +326,7 @@
0, // footerHeight
0, // drawHeader
0, // drawFooter
- 0, // printFrame
+ printFrame,
runModal,
0, // didCompleteRubberBandForMainFrame
0, // saveDataToFileInDownloadsFolder
@@ -613,7 +619,7 @@
0, // footerHeight
0, // drawHeader
0, // drawFooter
- 0, // printFrame
+ printFrame,
runModal,
0, // didCompleteRubberBandForMainFrame
0, // saveDataToFileInDownloadsFolder