From 427e8f836d62a2b240209d0c4cee3af3d57dbe26 Mon Sep 17 00:00:00 2001 From: Sebastian Hengst Date: Sun, 2 Apr 2017 14:37:08 +0200 Subject: [PATCH] Backed out 2 changesets (bug 1314388) for timing out in dom/svg/test/test_zoom.xhtml. r=backout Backed out changeset 804d8199aeca (bug 1314388) Backed out changeset b7fab6a89c1d (bug 1314388) --- devtools/client/debugger/new/debugger.js | 435 +++++++++--------- dom/events/EventDispatcher.cpp | 12 + dom/events/EventNameList.h | 13 + .../test/test_all_synthetic_events.html | 7 + dom/smil/test/test_smilTimeEvents.xhtml | 8 + dom/svg/SVGSVGElement.cpp | 10 +- dom/svg/SVGSVGElement.h | 2 - dom/svg/SVGZoomEvent.cpp | 103 +++++ dom/svg/SVGZoomEvent.h | 78 ++++ dom/svg/moz.build | 2 + .../mochitest/general/test_interfaces.js | 2 + dom/webidl/SVGZoomEvent.webidl | 25 + dom/webidl/moz.build | 1 + .../dom/nodes/Document-createEvent.html.ini | 30 ++ .../web-platform/meta/svg/historical.html.ini | 3 + .../web-platform/tests/svg/interfaces.html | 8 + widget/BasicEvents.h | 1 + widget/ContentEvents.h | 32 ++ widget/EventClassList.h | 1 + 19 files changed, 549 insertions(+), 224 deletions(-) create mode 100644 dom/svg/SVGZoomEvent.cpp create mode 100644 dom/svg/SVGZoomEvent.h create mode 100644 dom/webidl/SVGZoomEvent.webidl diff --git a/devtools/client/debugger/new/debugger.js b/devtools/client/debugger/new/debugger.js index 61d6d6666426..54c54ff73861 100644 --- a/devtools/client/debugger/new/debugger.js +++ b/devtools/client/debugger/new/debugger.js @@ -2027,57 +2027,57 @@ return /******/ (function(modules) { // webpackBootstrap /***/ function(module, exports, __webpack_require__) { /* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - - const React = __webpack_require__(2); - const ReactDOM = __webpack_require__(31); - const { DOM: dom, PropTypes } = React; - - const Draggable = React.createClass({ - displayName: "Draggable", - - propTypes: { - onMove: PropTypes.func.isRequired, - onStart: PropTypes.func, - onStop: PropTypes.func, - style: PropTypes.object, - className: PropTypes.string - }, - - startDragging(ev) { - ev.preventDefault(); - const doc = ReactDOM.findDOMNode(this).ownerDocument; - doc.addEventListener("mousemove", this.onMove); - doc.addEventListener("mouseup", this.onUp); - this.props.onStart && this.props.onStart(); - }, - - onMove(ev) { + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + + const React = __webpack_require__(2); + const ReactDOM = __webpack_require__(31); + const { DOM: dom, PropTypes } = React; + + const Draggable = React.createClass({ + displayName: "Draggable", + + propTypes: { + onMove: PropTypes.func.isRequired, + onStart: PropTypes.func, + onStop: PropTypes.func, + style: PropTypes.object, + className: PropTypes.string + }, + + startDragging(ev) { + ev.preventDefault(); + const doc = ReactDOM.findDOMNode(this).ownerDocument; + doc.addEventListener("mousemove", this.onMove); + doc.addEventListener("mouseup", this.onUp); + this.props.onStart && this.props.onStart(); + }, + + onMove(ev) { ev.preventDefault(); // We pass the whole event because we don't know which properties // the callee needs. this.props.onMove(ev); - }, - - onUp(ev) { - ev.preventDefault(); - const doc = ReactDOM.findDOMNode(this).ownerDocument; - doc.removeEventListener("mousemove", this.onMove); - doc.removeEventListener("mouseup", this.onUp); - this.props.onStop && this.props.onStop(); - }, - - render() { - return dom.div({ - style: this.props.style, - className: this.props.className, - onMouseDown: this.startDragging - }); - } - }); - - module.exports = Draggable; + }, + + onUp(ev) { + ev.preventDefault(); + const doc = ReactDOM.findDOMNode(this).ownerDocument; + doc.removeEventListener("mousemove", this.onMove); + doc.removeEventListener("mouseup", this.onUp); + this.props.onStop && this.props.onStop(); + }, + + render() { + return dom.div({ + style: this.props.style, + className: this.props.className, + onMouseDown: this.startDragging + }); + } + }); + + module.exports = Draggable; /***/ }, @@ -10036,16 +10036,16 @@ return /******/ (function(modules) { // webpackBootstrap /* 51 */ /***/ function(module, exports) { - module.exports = function(module) { - if(!module.webpackPolyfill) { - module.deprecate = function() {}; - module.paths = []; - // module.parent = undefined by default - module.children = []; - module.webpackPolyfill = 1; - } - return module; - } + module.exports = function(module) { + if(!module.webpackPolyfill) { + module.deprecate = function() {}; + module.paths = []; + // module.parent = undefined by default + module.children = []; + module.webpackPolyfill = 1; + } + return module; + } /***/ }, @@ -32338,166 +32338,166 @@ return /******/ (function(modules) { // webpackBootstrap /* 248 */ /***/ function(module, exports, __webpack_require__) { - (function(){ - var crypt = __webpack_require__(249), - utf8 = __webpack_require__(250).utf8, - isBuffer = __webpack_require__(251), - bin = __webpack_require__(250).bin, - - // The core - md5 = function (message, options) { - // Convert to byte array - if (message.constructor == String) - if (options && options.encoding === 'binary') - message = bin.stringToBytes(message); - else - message = utf8.stringToBytes(message); - else if (isBuffer(message)) - message = Array.prototype.slice.call(message, 0); - else if (!Array.isArray(message)) - message = message.toString(); - // else, assume byte array already - - var m = crypt.bytesToWords(message), - l = message.length * 8, - a = 1732584193, - b = -271733879, - c = -1732584194, - d = 271733878; - - // Swap endian - for (var i = 0; i < m.length; i++) { - m[i] = ((m[i] << 8) | (m[i] >>> 24)) & 0x00FF00FF | - ((m[i] << 24) | (m[i] >>> 8)) & 0xFF00FF00; - } - - // Padding - m[l >>> 5] |= 0x80 << (l % 32); - m[(((l + 64) >>> 9) << 4) + 14] = l; - - // Method shortcuts - var FF = md5._ff, - GG = md5._gg, - HH = md5._hh, - II = md5._ii; - - for (var i = 0; i < m.length; i += 16) { - - var aa = a, - bb = b, - cc = c, - dd = d; - - a = FF(a, b, c, d, m[i+ 0], 7, -680876936); - d = FF(d, a, b, c, m[i+ 1], 12, -389564586); - c = FF(c, d, a, b, m[i+ 2], 17, 606105819); - b = FF(b, c, d, a, m[i+ 3], 22, -1044525330); - a = FF(a, b, c, d, m[i+ 4], 7, -176418897); - d = FF(d, a, b, c, m[i+ 5], 12, 1200080426); - c = FF(c, d, a, b, m[i+ 6], 17, -1473231341); - b = FF(b, c, d, a, m[i+ 7], 22, -45705983); - a = FF(a, b, c, d, m[i+ 8], 7, 1770035416); - d = FF(d, a, b, c, m[i+ 9], 12, -1958414417); - c = FF(c, d, a, b, m[i+10], 17, -42063); - b = FF(b, c, d, a, m[i+11], 22, -1990404162); - a = FF(a, b, c, d, m[i+12], 7, 1804603682); - d = FF(d, a, b, c, m[i+13], 12, -40341101); - c = FF(c, d, a, b, m[i+14], 17, -1502002290); - b = FF(b, c, d, a, m[i+15], 22, 1236535329); - - a = GG(a, b, c, d, m[i+ 1], 5, -165796510); - d = GG(d, a, b, c, m[i+ 6], 9, -1069501632); - c = GG(c, d, a, b, m[i+11], 14, 643717713); - b = GG(b, c, d, a, m[i+ 0], 20, -373897302); - a = GG(a, b, c, d, m[i+ 5], 5, -701558691); - d = GG(d, a, b, c, m[i+10], 9, 38016083); - c = GG(c, d, a, b, m[i+15], 14, -660478335); - b = GG(b, c, d, a, m[i+ 4], 20, -405537848); - a = GG(a, b, c, d, m[i+ 9], 5, 568446438); - d = GG(d, a, b, c, m[i+14], 9, -1019803690); - c = GG(c, d, a, b, m[i+ 3], 14, -187363961); - b = GG(b, c, d, a, m[i+ 8], 20, 1163531501); - a = GG(a, b, c, d, m[i+13], 5, -1444681467); - d = GG(d, a, b, c, m[i+ 2], 9, -51403784); - c = GG(c, d, a, b, m[i+ 7], 14, 1735328473); - b = GG(b, c, d, a, m[i+12], 20, -1926607734); - - a = HH(a, b, c, d, m[i+ 5], 4, -378558); - d = HH(d, a, b, c, m[i+ 8], 11, -2022574463); - c = HH(c, d, a, b, m[i+11], 16, 1839030562); - b = HH(b, c, d, a, m[i+14], 23, -35309556); - a = HH(a, b, c, d, m[i+ 1], 4, -1530992060); - d = HH(d, a, b, c, m[i+ 4], 11, 1272893353); - c = HH(c, d, a, b, m[i+ 7], 16, -155497632); - b = HH(b, c, d, a, m[i+10], 23, -1094730640); - a = HH(a, b, c, d, m[i+13], 4, 681279174); - d = HH(d, a, b, c, m[i+ 0], 11, -358537222); - c = HH(c, d, a, b, m[i+ 3], 16, -722521979); - b = HH(b, c, d, a, m[i+ 6], 23, 76029189); - a = HH(a, b, c, d, m[i+ 9], 4, -640364487); - d = HH(d, a, b, c, m[i+12], 11, -421815835); - c = HH(c, d, a, b, m[i+15], 16, 530742520); - b = HH(b, c, d, a, m[i+ 2], 23, -995338651); - - a = II(a, b, c, d, m[i+ 0], 6, -198630844); - d = II(d, a, b, c, m[i+ 7], 10, 1126891415); - c = II(c, d, a, b, m[i+14], 15, -1416354905); - b = II(b, c, d, a, m[i+ 5], 21, -57434055); - a = II(a, b, c, d, m[i+12], 6, 1700485571); - d = II(d, a, b, c, m[i+ 3], 10, -1894986606); - c = II(c, d, a, b, m[i+10], 15, -1051523); - b = II(b, c, d, a, m[i+ 1], 21, -2054922799); - a = II(a, b, c, d, m[i+ 8], 6, 1873313359); - d = II(d, a, b, c, m[i+15], 10, -30611744); - c = II(c, d, a, b, m[i+ 6], 15, -1560198380); - b = II(b, c, d, a, m[i+13], 21, 1309151649); - a = II(a, b, c, d, m[i+ 4], 6, -145523070); - d = II(d, a, b, c, m[i+11], 10, -1120210379); - c = II(c, d, a, b, m[i+ 2], 15, 718787259); - b = II(b, c, d, a, m[i+ 9], 21, -343485551); - - a = (a + aa) >>> 0; - b = (b + bb) >>> 0; - c = (c + cc) >>> 0; - d = (d + dd) >>> 0; - } - - return crypt.endian([a, b, c, d]); - }; - - // Auxiliary functions - md5._ff = function (a, b, c, d, x, s, t) { - var n = a + (b & c | ~b & d) + (x >>> 0) + t; - return ((n << s) | (n >>> (32 - s))) + b; - }; - md5._gg = function (a, b, c, d, x, s, t) { - var n = a + (b & d | c & ~d) + (x >>> 0) + t; - return ((n << s) | (n >>> (32 - s))) + b; - }; - md5._hh = function (a, b, c, d, x, s, t) { - var n = a + (b ^ c ^ d) + (x >>> 0) + t; - return ((n << s) | (n >>> (32 - s))) + b; - }; - md5._ii = function (a, b, c, d, x, s, t) { - var n = a + (c ^ (b | ~d)) + (x >>> 0) + t; - return ((n << s) | (n >>> (32 - s))) + b; - }; - - // Package private blocksize - md5._blocksize = 16; - md5._digestsize = 16; - - module.exports = function (message, options) { - if (message === undefined || message === null) - throw new Error('Illegal argument ' + message); - - var digestbytes = crypt.wordsToBytes(md5(message, options)); - return options && options.asBytes ? digestbytes : - options && options.asString ? bin.bytesToString(digestbytes) : - crypt.bytesToHex(digestbytes); - }; - - })(); + (function(){ + var crypt = __webpack_require__(249), + utf8 = __webpack_require__(250).utf8, + isBuffer = __webpack_require__(251), + bin = __webpack_require__(250).bin, + + // The core + md5 = function (message, options) { + // Convert to byte array + if (message.constructor == String) + if (options && options.encoding === 'binary') + message = bin.stringToBytes(message); + else + message = utf8.stringToBytes(message); + else if (isBuffer(message)) + message = Array.prototype.slice.call(message, 0); + else if (!Array.isArray(message)) + message = message.toString(); + // else, assume byte array already + + var m = crypt.bytesToWords(message), + l = message.length * 8, + a = 1732584193, + b = -271733879, + c = -1732584194, + d = 271733878; + + // Swap endian + for (var i = 0; i < m.length; i++) { + m[i] = ((m[i] << 8) | (m[i] >>> 24)) & 0x00FF00FF | + ((m[i] << 24) | (m[i] >>> 8)) & 0xFF00FF00; + } + + // Padding + m[l >>> 5] |= 0x80 << (l % 32); + m[(((l + 64) >>> 9) << 4) + 14] = l; + + // Method shortcuts + var FF = md5._ff, + GG = md5._gg, + HH = md5._hh, + II = md5._ii; + + for (var i = 0; i < m.length; i += 16) { + + var aa = a, + bb = b, + cc = c, + dd = d; + + a = FF(a, b, c, d, m[i+ 0], 7, -680876936); + d = FF(d, a, b, c, m[i+ 1], 12, -389564586); + c = FF(c, d, a, b, m[i+ 2], 17, 606105819); + b = FF(b, c, d, a, m[i+ 3], 22, -1044525330); + a = FF(a, b, c, d, m[i+ 4], 7, -176418897); + d = FF(d, a, b, c, m[i+ 5], 12, 1200080426); + c = FF(c, d, a, b, m[i+ 6], 17, -1473231341); + b = FF(b, c, d, a, m[i+ 7], 22, -45705983); + a = FF(a, b, c, d, m[i+ 8], 7, 1770035416); + d = FF(d, a, b, c, m[i+ 9], 12, -1958414417); + c = FF(c, d, a, b, m[i+10], 17, -42063); + b = FF(b, c, d, a, m[i+11], 22, -1990404162); + a = FF(a, b, c, d, m[i+12], 7, 1804603682); + d = FF(d, a, b, c, m[i+13], 12, -40341101); + c = FF(c, d, a, b, m[i+14], 17, -1502002290); + b = FF(b, c, d, a, m[i+15], 22, 1236535329); + + a = GG(a, b, c, d, m[i+ 1], 5, -165796510); + d = GG(d, a, b, c, m[i+ 6], 9, -1069501632); + c = GG(c, d, a, b, m[i+11], 14, 643717713); + b = GG(b, c, d, a, m[i+ 0], 20, -373897302); + a = GG(a, b, c, d, m[i+ 5], 5, -701558691); + d = GG(d, a, b, c, m[i+10], 9, 38016083); + c = GG(c, d, a, b, m[i+15], 14, -660478335); + b = GG(b, c, d, a, m[i+ 4], 20, -405537848); + a = GG(a, b, c, d, m[i+ 9], 5, 568446438); + d = GG(d, a, b, c, m[i+14], 9, -1019803690); + c = GG(c, d, a, b, m[i+ 3], 14, -187363961); + b = GG(b, c, d, a, m[i+ 8], 20, 1163531501); + a = GG(a, b, c, d, m[i+13], 5, -1444681467); + d = GG(d, a, b, c, m[i+ 2], 9, -51403784); + c = GG(c, d, a, b, m[i+ 7], 14, 1735328473); + b = GG(b, c, d, a, m[i+12], 20, -1926607734); + + a = HH(a, b, c, d, m[i+ 5], 4, -378558); + d = HH(d, a, b, c, m[i+ 8], 11, -2022574463); + c = HH(c, d, a, b, m[i+11], 16, 1839030562); + b = HH(b, c, d, a, m[i+14], 23, -35309556); + a = HH(a, b, c, d, m[i+ 1], 4, -1530992060); + d = HH(d, a, b, c, m[i+ 4], 11, 1272893353); + c = HH(c, d, a, b, m[i+ 7], 16, -155497632); + b = HH(b, c, d, a, m[i+10], 23, -1094730640); + a = HH(a, b, c, d, m[i+13], 4, 681279174); + d = HH(d, a, b, c, m[i+ 0], 11, -358537222); + c = HH(c, d, a, b, m[i+ 3], 16, -722521979); + b = HH(b, c, d, a, m[i+ 6], 23, 76029189); + a = HH(a, b, c, d, m[i+ 9], 4, -640364487); + d = HH(d, a, b, c, m[i+12], 11, -421815835); + c = HH(c, d, a, b, m[i+15], 16, 530742520); + b = HH(b, c, d, a, m[i+ 2], 23, -995338651); + + a = II(a, b, c, d, m[i+ 0], 6, -198630844); + d = II(d, a, b, c, m[i+ 7], 10, 1126891415); + c = II(c, d, a, b, m[i+14], 15, -1416354905); + b = II(b, c, d, a, m[i+ 5], 21, -57434055); + a = II(a, b, c, d, m[i+12], 6, 1700485571); + d = II(d, a, b, c, m[i+ 3], 10, -1894986606); + c = II(c, d, a, b, m[i+10], 15, -1051523); + b = II(b, c, d, a, m[i+ 1], 21, -2054922799); + a = II(a, b, c, d, m[i+ 8], 6, 1873313359); + d = II(d, a, b, c, m[i+15], 10, -30611744); + c = II(c, d, a, b, m[i+ 6], 15, -1560198380); + b = II(b, c, d, a, m[i+13], 21, 1309151649); + a = II(a, b, c, d, m[i+ 4], 6, -145523070); + d = II(d, a, b, c, m[i+11], 10, -1120210379); + c = II(c, d, a, b, m[i+ 2], 15, 718787259); + b = II(b, c, d, a, m[i+ 9], 21, -343485551); + + a = (a + aa) >>> 0; + b = (b + bb) >>> 0; + c = (c + cc) >>> 0; + d = (d + dd) >>> 0; + } + + return crypt.endian([a, b, c, d]); + }; + + // Auxiliary functions + md5._ff = function (a, b, c, d, x, s, t) { + var n = a + (b & c | ~b & d) + (x >>> 0) + t; + return ((n << s) | (n >>> (32 - s))) + b; + }; + md5._gg = function (a, b, c, d, x, s, t) { + var n = a + (b & d | c & ~d) + (x >>> 0) + t; + return ((n << s) | (n >>> (32 - s))) + b; + }; + md5._hh = function (a, b, c, d, x, s, t) { + var n = a + (b ^ c ^ d) + (x >>> 0) + t; + return ((n << s) | (n >>> (32 - s))) + b; + }; + md5._ii = function (a, b, c, d, x, s, t) { + var n = a + (c ^ (b | ~d)) + (x >>> 0) + t; + return ((n << s) | (n >>> (32 - s))) + b; + }; + + // Package private blocksize + md5._blocksize = 16; + md5._digestsize = 16; + + module.exports = function (message, options) { + if (message === undefined || message === null) + throw new Error('Illegal argument ' + message); + + var digestbytes = crypt.wordsToBytes(md5(message, options)); + return options && options.asBytes ? digestbytes : + options && options.asString ? bin.bytesToString(digestbytes) : + crypt.bytesToHex(digestbytes); + }; + + })(); /***/ }, @@ -73515,6 +73515,7 @@ return /******/ (function(modules) { // webpackBootstrap "SVGViewSpec": false, "SVGVKernElement": false, "SVGZoomAndPan": false, + "SVGZoomEvent": false, "Text": false, "TextDecoder": false, "TextEncoder": false, diff --git a/dom/events/EventDispatcher.cpp b/dom/events/EventDispatcher.cpp index 85a02348122e..daf58176fe3d 100644 --- a/dom/events/EventDispatcher.cpp +++ b/dom/events/EventDispatcher.cpp @@ -43,6 +43,7 @@ #include "mozilla/dom/SimpleGestureEvent.h" #include "mozilla/dom/ScriptSettings.h" #include "mozilla/dom/StorageEvent.h" +#include "mozilla/dom/SVGZoomEvent.h" #include "mozilla/dom/TimeEvent.h" #include "mozilla/dom/TouchEvent.h" #include "mozilla/dom/TransitionEvent.h" @@ -939,6 +940,9 @@ EventDispatcher::CreateEvent(EventTarget* aOwner, case eClipboardEventClass: return NS_NewDOMClipboardEvent(aOwner, aPresContext, aEvent->AsClipboardEvent()); + case eSVGZoomEventClass: + return NS_NewDOMSVGZoomEvent(aOwner, aPresContext, + aEvent->AsSVGZoomEvent()); case eSMILTimeEventClass: return NS_NewDOMTimeEvent(aOwner, aPresContext, aEvent->AsSMILTimeEvent()); @@ -1062,6 +1066,14 @@ EventDispatcher::CreateEvent(EventTarget* aOwner, LOG_EVENT_CREATION(SVGEVENTS); return NS_NewDOMEvent(aOwner, aPresContext, nullptr); } + if (aEventType.LowerCaseEqualsLiteral("svgzoomevent")) { + LOG_EVENT_CREATION(SVGZOOMEVENT); + return NS_NewDOMSVGZoomEvent(aOwner, aPresContext, nullptr); + } + if (aEventType.LowerCaseEqualsLiteral("svgzoomevents")) { + LOG_EVENT_CREATION(SVGZOOMEVENTS); + return NS_NewDOMSVGZoomEvent(aOwner, aPresContext, nullptr); + } if (aEventType.LowerCaseEqualsLiteral("timeevent")) { LOG_EVENT_CREATION(TIMEEVENT); return NS_NewDOMTimeEvent(aOwner, aPresContext, nullptr); diff --git a/dom/events/EventNameList.h b/dom/events/EventNameList.h index bfc38376fe46..d56c26a5deb6 100644 --- a/dom/events/EventNameList.h +++ b/dom/events/EventNameList.h @@ -835,6 +835,19 @@ NON_IDL_EVENT(SVGScroll, EventNameType_None, eBasicEventClass) +NON_IDL_EVENT(SVGZoom, + eSVGZoom, + EventNameType_None, + eSVGZoomEventClass) + +// Only map the ID to the real event name when MESSAGE_TO_EVENT is defined. +#ifndef MESSAGE_TO_EVENT +// This is a bit hackish, but SVG's event names are weird. +NON_IDL_EVENT(zoom, + eSVGZoom, + EventNameType_SVGSVG, + eBasicEventClass) +#endif // Only map the ID to the real event name when MESSAGE_TO_EVENT is defined. #ifndef MESSAGE_TO_EVENT NON_IDL_EVENT(begin, diff --git a/dom/events/test/test_all_synthetic_events.html b/dom/events/test/test_all_synthetic_events.html index 1f1225fca5c9..ffd969d8d639 100644 --- a/dom/events/test/test_all_synthetic_events.html +++ b/dom/events/test/test_all_synthetic_events.html @@ -381,6 +381,13 @@ const kEventConstructors = { }, chromeOnly: true, }, + SVGZoomEvent: { create: function (aName, aProps) { + var e = document.createEvent("svgzoomevent"); + e.initUIEvent(aName, aProps.bubbles, aProps.cancelable, + aProps.view, aProps.detail); + return e; + }, + }, TCPSocketErrorEvent: { create: function(aName, aProps) { return new TCPSocketErrorEvent(aName, aProps); }, diff --git a/dom/smil/test/test_smilTimeEvents.xhtml b/dom/smil/test/test_smilTimeEvents.xhtml index 13064e0d8829..1a2e52a282bd 100644 --- a/dom/smil/test/test_smilTimeEvents.xhtml +++ b/dom/smil/test/test_smilTimeEvents.xhtml @@ -322,6 +322,14 @@ d.addEventListener("zoom", function(e) { expectedEvents.shift(); }); +var zoomEvent = document.createEvent("svgzoomevent"); +zoomEvent.initEvent("zoom", true, true); +d.dispatchEvent(zoomEvent); +zoomEvent = document.createEvent("svgzoomevent"); +zoomEvent.initEvent("SVGZoom", true, true); +d.dispatchEvent(zoomEvent); +is(expectedEvents.length, 0, "Got all the expected events."); + ]]> diff --git a/dom/svg/SVGSVGElement.cpp b/dom/svg/SVGSVGElement.cpp index cd7ba4b98473..ffb613687d97 100644 --- a/dom/svg/SVGSVGElement.cpp +++ b/dom/svg/SVGSVGElement.cpp @@ -475,7 +475,7 @@ SVGSVGElement::SetZoomAndPan(uint16_t aZoomAndPan, ErrorResult& rv) } //---------------------------------------------------------------------- -// helper method for implementing SetCurrentScale/Translate +// helper methods for implementing SVGZoomEvent: void SVGSVGElement::SetCurrentScaleTranslate(float s, float x, float y) @@ -499,9 +499,6 @@ SVGSVGElement::SetCurrentScaleTranslate(float s, float x, float y) // change that caused the event's dispatch, which is *not* necessarily the // same thing as the values of currentScale and currentTranslate prior to // their own last change. - // - // XXX This comment is out-of-date due to removal of SVGZoomEvent. Can we - // remove some of this code? mPreviousScale = mCurrentScale; mPreviousTranslate = mCurrentTranslate; @@ -514,7 +511,10 @@ SVGSVGElement::SetCurrentScaleTranslate(float s, float x, float y) nsCOMPtr presShell = doc->GetShell(); if (presShell && IsRoot()) { nsEventStatus status = nsEventStatus_eIgnore; - if (mPreviousScale == mCurrentScale) { + if (mPreviousScale != mCurrentScale) { + InternalSVGZoomEvent svgZoomEvent(true, eSVGZoom); + presShell->HandleDOMEventWithTarget(this, &svgZoomEvent, &status); + } else { WidgetEvent svgScrollEvent(true, eSVGScroll); presShell->HandleDOMEventWithTarget(this, &svgScrollEvent, &status); } diff --git a/dom/svg/SVGSVGElement.h b/dom/svg/SVGSVGElement.h index d8aa70aa506e..0145ae8fac76 100644 --- a/dom/svg/SVGSVGElement.h +++ b/dom/svg/SVGSVGElement.h @@ -132,8 +132,6 @@ public: * For use by zoom controls to allow currentScale, currentTranslate.x and * currentTranslate.y to be set by a single operation that dispatches a * single SVGZoom event (instead of one SVGZoom and two SVGScroll events). - * - * XXX SVGZoomEvent is no more, is this needed? */ void SetCurrentScaleTranslate(float s, float x, float y); diff --git a/dom/svg/SVGZoomEvent.cpp b/dom/svg/SVGZoomEvent.cpp new file mode 100644 index 000000000000..4856f2c3896a --- /dev/null +++ b/dom/svg/SVGZoomEvent.cpp @@ -0,0 +1,103 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "DOMSVGPoint.h" +#include "mozilla/ContentEvents.h" +#include "mozilla/dom/Element.h" +#include "mozilla/dom/SVGSVGElement.h" +#include "mozilla/dom/SVGZoomEvent.h" +#include "nsIDocument.h" +#include "nsIPresShell.h" +#include "prtime.h" + +namespace mozilla { +namespace dom { + +//---------------------------------------------------------------------- +// Implementation + +NS_IMPL_CYCLE_COLLECTION_INHERITED(SVGZoomEvent, UIEvent, mPreviousTranslate, mNewTranslate) + +NS_IMPL_ADDREF_INHERITED(SVGZoomEvent, UIEvent) +NS_IMPL_RELEASE_INHERITED(SVGZoomEvent, UIEvent) + +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SVGZoomEvent) +NS_INTERFACE_MAP_END_INHERITING(UIEvent) + +SVGZoomEvent::SVGZoomEvent(EventTarget* aOwner, + nsPresContext* aPresContext, + InternalSVGZoomEvent* aEvent) + : UIEvent(aOwner, aPresContext, + aEvent ? aEvent : new InternalSVGZoomEvent(false, eSVGZoom)) + , mPreviousScale(0) + , mNewScale(0) +{ + if (aEvent) { + mEventIsInternal = false; + } + else { + mEventIsInternal = true; + mEvent->mTime = PR_Now(); + } + + // We must store the "Previous" and "New" values before this event is + // dispatched. Reading the values from the root 'svg' element after we've + // been dispatched is not an option since event handler code may change + // currentScale and currentTranslate in response to this event. + nsIPresShell *presShell; + if (mPresContext && (presShell = mPresContext->GetPresShell())) { + nsIDocument *doc = presShell->GetDocument(); + if (doc) { + Element *rootElement = doc->GetRootElement(); + if (rootElement) { + // If the root element isn't an SVG 'svg' element + // (e.g. if this event was created by calling createEvent on a + // non-SVGDocument), then the "New" and "Previous" + // properties will be left null which is probably what we want. + if (rootElement->IsSVGElement(nsGkAtoms::svg)) { + SVGSVGElement *SVGSVGElem = + static_cast(rootElement); + + mNewScale = SVGSVGElem->GetCurrentScale(); + mPreviousScale = SVGSVGElem->GetPreviousScale(); + + const SVGPoint& translate = SVGSVGElem->GetCurrentTranslate(); + mNewTranslate = + new DOMSVGPoint(translate.GetX(), translate.GetY()); + mNewTranslate->SetReadonly(true); + + const SVGPoint& prevTranslate = SVGSVGElem->GetPreviousTranslate(); + mPreviousTranslate = + new DOMSVGPoint(prevTranslate.GetX(), prevTranslate.GetY()); + mPreviousTranslate->SetReadonly(true); + } + } + } + } +} + +SVGZoomEvent::~SVGZoomEvent() +{ +} + +} // namespace dom +} // namespace mozilla + + +//////////////////////////////////////////////////////////////////////// +// Exported creation functions: + +using namespace mozilla; +using namespace mozilla::dom; + +already_AddRefed +NS_NewDOMSVGZoomEvent(EventTarget* aOwner, + nsPresContext* aPresContext, + mozilla::InternalSVGZoomEvent* aEvent) +{ + RefPtr it = new SVGZoomEvent(aOwner, aPresContext, aEvent); + return it.forget(); +} diff --git a/dom/svg/SVGZoomEvent.h b/dom/svg/SVGZoomEvent.h new file mode 100644 index 000000000000..c0937309b0c8 --- /dev/null +++ b/dom/svg/SVGZoomEvent.h @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_SVGZoomEvent_h +#define mozilla_dom_SVGZoomEvent_h + +#include "DOMSVGPoint.h" +#include "mozilla/dom/UIEvent.h" +#include "mozilla/dom/SVGZoomEventBinding.h" +#include "mozilla/EventForwards.h" + +class nsPresContext; + +namespace mozilla { + +class nsISVGPoint; + +namespace dom { + +class SVGZoomEvent final : public UIEvent +{ +public: + + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGZoomEvent, UIEvent) + NS_DECL_ISUPPORTS_INHERITED + + SVGZoomEvent(EventTarget* aOwner, nsPresContext* aPresContext, + InternalSVGZoomEvent* aEvent); + + // Forward to base class + NS_FORWARD_TO_UIEVENT + + virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle aGivenProto) override + { + return SVGZoomEventBinding::Wrap(aCx, this, aGivenProto); + } + + float PreviousScale() const + { + return mPreviousScale; + } + + nsISVGPoint* GetPreviousTranslate() const + { + return mPreviousTranslate; + } + + float NewScale() const + { + return mNewScale; + } + + nsISVGPoint* GetNewTranslate() const + { + return mNewTranslate; + } + +private: + ~SVGZoomEvent(); + + float mPreviousScale; + float mNewScale; + RefPtr mPreviousTranslate; + RefPtr mNewTranslate; +}; + +} // namespace dom +} // namespace mozilla + +already_AddRefed +NS_NewDOMSVGZoomEvent(mozilla::dom::EventTarget* aOwner, + nsPresContext* aPresContext, + mozilla::InternalSVGZoomEvent* aEvent); + +#endif // mozilla_dom_SVGZoomEvent_h diff --git a/dom/svg/moz.build b/dom/svg/moz.build index 94e4aab26413..0b71f1aaa08d 100644 --- a/dom/svg/moz.build +++ b/dom/svg/moz.build @@ -102,6 +102,7 @@ EXPORTS.mozilla.dom += [ 'SVGTSpanElement.h', 'SVGUseElement.h', 'SVGViewElement.h', + 'SVGZoomEvent.h', ] UNIFIED_SOURCES += [ @@ -248,6 +249,7 @@ UNIFIED_SOURCES += [ 'SVGUseElement.cpp', 'SVGViewBoxSMILType.cpp', 'SVGViewElement.cpp', + 'SVGZoomEvent.cpp', ] include('/ipc/chromium/chromium-config.mozbuild') diff --git a/dom/tests/mochitest/general/test_interfaces.js b/dom/tests/mochitest/general/test_interfaces.js index d5be8ebe93eb..714e6f6f83e5 100644 --- a/dom/tests/mochitest/general/test_interfaces.js +++ b/dom/tests/mochitest/general/test_interfaces.js @@ -1118,6 +1118,8 @@ var interfaceNamesInGlobalScope = "SVGViewElement", // IMPORTANT: Do not change this list without review from a DOM peer! "SVGZoomAndPan", +// IMPORTANT: Do not change this list without review from a DOM peer! + "SVGZoomEvent", // IMPORTANT: Do not change this list without review from a DOM peer! "Text", // IMPORTANT: Do not change this list without review from a DOM peer! diff --git a/dom/webidl/SVGZoomEvent.webidl b/dom/webidl/SVGZoomEvent.webidl new file mode 100644 index 000000000000..044247f3ca09 --- /dev/null +++ b/dom/webidl/SVGZoomEvent.webidl @@ -0,0 +1,25 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * http://www.w3.org/TR/SVG2/ + * + * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C + * liability, trademark and document use rules apply. + */ + +interface SVGZoomEvent : UIEvent { + // Not implemented + // readonly attribute SVGRect zoomRectScreen; + + [Constant] + readonly attribute float previousScale; + [Constant] + readonly attribute SVGPoint? previousTranslate; + [Constant] + readonly attribute float newScale; + [Constant] + readonly attribute SVGPoint? newTranslate; +}; diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build index 2ff1e2fffb2b..fb517109944a 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -900,6 +900,7 @@ WEBIDL_FILES = [ 'SVGViewElement.webidl', 'SVGZoomAndPan.webidl', 'SVGZoomAndPanValues.webidl', + 'SVGZoomEvent.webidl', 'TCPServerSocket.webidl', 'TCPServerSocketEvent.webidl', 'TCPSocket.webidl', diff --git a/testing/web-platform/meta/dom/nodes/Document-createEvent.html.ini b/testing/web-platform/meta/dom/nodes/Document-createEvent.html.ini index 46760df2ea7e..f8475cc9ad7e 100644 --- a/testing/web-platform/meta/dom/nodes/Document-createEvent.html.ini +++ b/testing/web-platform/meta/dom/nodes/Document-createEvent.html.ini @@ -148,6 +148,30 @@ expected: FAIL bug: https://github.com/whatwg/dom/issues/362, 1314303 + [createEvent('SVGZoomEvent') should be initialized correctly.] + expected: FAIL + bug: 1314388 + + [createEvent('svgzoomevent') should be initialized correctly.] + expected: FAIL + bug: 1314388 + + [createEvent('SVGZOOMEVENT') should be initialized correctly.] + expected: FAIL + bug: 1314388 + + [createEvent('SVGZoomEvents') should be initialized correctly.] + expected: FAIL + bug: 1314388 + + [createEvent('svgzoomevents') should be initialized correctly.] + expected: FAIL + bug: 1314388 + + [createEvent('SVGZOOMEVENTS') should be initialized correctly.] + expected: FAIL + bug: 1314388 + [Should throw NOT_SUPPORTED_ERR for pluralized legacy event interface "TextEvents"] expected: FAIL bug: 1251198 @@ -320,3 +344,9 @@ expected: FAIL bug: 1251198 + [Should throw NOT_SUPPORTED_ERR for non-legacy event interface "SVGZoomEvent"] + expected: FAIL + + [Should throw NOT_SUPPORTED_ERR for pluralized non-legacy event interface "SVGZoomEvents"] + expected: FAIL + diff --git a/testing/web-platform/meta/svg/historical.html.ini b/testing/web-platform/meta/svg/historical.html.ini index bfbbbda26cd8..d7dbe0d85f66 100644 --- a/testing/web-platform/meta/svg/historical.html.ini +++ b/testing/web-platform/meta/svg/historical.html.ini @@ -3,6 +3,9 @@ [SVGPathSeg interface must be removed] expected: FAIL + [SVGZoomEvent interface must be removed] + expected: FAIL + [SVGUnitTypes mixin interface must not be exposed] expected: FAIL diff --git a/testing/web-platform/tests/svg/interfaces.html b/testing/web-platform/tests/svg/interfaces.html index ce979dde55a7..a9bf2bd6bb52 100644 --- a/testing/web-platform/tests/svg/interfaces.html +++ b/testing/web-platform/tests/svg/interfaces.html @@ -983,6 +983,14 @@ interface SVGScriptElement : SVGElement { SVGScriptElement implements SVGURIReference; +interface SVGZoomEvent : UIEvent { + [SameObject] readonly attribute DOMRectReadOnly zoomRectScreen; + readonly attribute float previousScale; + [SameObject] readonly attribute DOMPointReadOnly previousTranslate; + readonly attribute float newScale; + [SameObject] readonly attribute DOMPointReadOnly newTranslate; +}; + interface SVGAElement : SVGGraphicsElement { [SameObject] readonly attribute SVGAnimatedString target; }; diff --git a/widget/BasicEvents.h b/widget/BasicEvents.h index 61ab0f9231b3..c7a8f2690825 100644 --- a/widget/BasicEvents.h +++ b/widget/BasicEvents.h @@ -324,6 +324,7 @@ private: break; case eTransitionEventClass: case eAnimationEventClass: + case eSVGZoomEventClass: mFlags.mCancelable = false; mFlags.mBubbles = true; break; diff --git a/widget/ContentEvents.h b/widget/ContentEvents.h index 2cc8b0c5c13a..be64b7bebdc0 100644 --- a/widget/ContentEvents.h +++ b/widget/ContentEvents.h @@ -316,6 +316,38 @@ public: } }; +/****************************************************************************** + * mozilla::InternalSVGZoomEvent + ******************************************************************************/ + +class InternalSVGZoomEvent : public WidgetGUIEvent +{ +public: + virtual InternalSVGZoomEvent* AsSVGZoomEvent() override { return this; } + + InternalSVGZoomEvent(bool aIsTrusted, EventMessage aMessage) + : WidgetGUIEvent(aIsTrusted, aMessage, nullptr, eSVGZoomEventClass) + { + } + + virtual WidgetEvent* Duplicate() const override + { + MOZ_ASSERT(mClass == eSVGZoomEventClass, + "Duplicate() must be overridden by sub class"); + // Not copying widget, it is a weak reference. + InternalSVGZoomEvent* result = new InternalSVGZoomEvent(false, mMessage); + result->AssignSVGZoomEventData(*this, true); + result->mFlags = mFlags; + return result; + } + + void AssignSVGZoomEventData(const InternalSVGZoomEvent& aEvent, + bool aCopyTargets) + { + AssignGUIEventData(aEvent, aCopyTargets); + } +}; + /****************************************************************************** * mozilla::InternalSMILTimeEvent ******************************************************************************/ diff --git a/widget/EventClassList.h b/widget/EventClassList.h index fc08792b238f..e6a160fab86d 100644 --- a/widget/EventClassList.h +++ b/widget/EventClassList.h @@ -48,6 +48,7 @@ NS_EVENT_CLASS(Internal, ClipboardEvent) NS_EVENT_CLASS(Internal, FocusEvent) NS_EVENT_CLASS(Internal, TransitionEvent) NS_EVENT_CLASS(Internal, AnimationEvent) +NS_EVENT_CLASS(Internal, SVGZoomEvent) NS_EVENT_CLASS(Internal, SMILTimeEvent) // MiscEvents.h