From e5392d861a169e5b7c8cd0cff187aca08d975d0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6kay=20=C5=9Eat=C4=B1r?= Date: Mon, 15 Jul 2024 12:39:32 +0300 Subject: [PATCH] Move the resizeDetector and use document-container for the event handling. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gökay Şatır Change-Id: I6990480da8ba3a058e4e5d32407bf38d341e8ee4 --- browser/src/map/Map.js | 20 +------------------- browser/src/map/handler/Map.Mouse.js | 12 ------------ 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/browser/src/map/Map.js b/browser/src/map/Map.js index 7b5cb25ec..a31bd22ee 100644 --- a/browser/src/map/Map.js +++ b/browser/src/map/Map.js @@ -26,7 +26,6 @@ L.Map = L.Evented.extend({ maxZoom: 18, maxBounds: L.latLngBounds([0, 0], [-100, 100]), fadeAnimation: false, // Not useful for typing. - trackResize: true, markerZoomAnimation: true, // defaultZoom: // The zoom level at which the tile size in twips equals the default size (3840 x 3840). @@ -74,9 +73,6 @@ L.Map = L.Evented.extend({ this._initContainer(id); this._initLayout(); - // hack for https://github.com/Leaflet/Leaflet/issues/1980 - this._onResize = L.bind(this._onResize, this); - // Start with readonly toolbars on desktop if (window.mode.isDesktop()) { L.DomUtil.addClass(L.DomUtil.get('toolbar-wrapper'), 'readonly'); @@ -195,8 +191,6 @@ L.Map = L.Evented.extend({ this._fireInitComplete('doclayerinit'); } - // We need core's knowledge of whether it is a mobile phone - // or not to be in sync with the test in _onJSDialogMsg in TileLayer.js. if (window.mode.isMobile()) { document.getElementById('document-container').classList.add('mobile'); @@ -1201,14 +1195,6 @@ L.Map = L.Evented.extend({ throw new Error('Map container is already initialized.'); } - if (window.mode.isDesktop()) { - this._resizeDetector = L.DomUtil.create('iframe', 'resize-detector', container); - this._resizeDetector.title = 'Intentionally blank'; - this._resizeDetector.setAttribute('aria-hidden', 'true'); - this._resizeDetector.contentWindow.addEventListener('touchstart', L.DomEvent.preventDefault, {passive: false}); - L.DomEvent.on(this._resizeDetector.contentWindow, 'contextmenu', L.DomEvent.preventDefault); - } - this._fileDownloader = L.DomUtil.create('iframe', '', container); L.DomUtil.setStyle(this._fileDownloader, 'display', 'none'); @@ -1339,11 +1325,7 @@ L.Map = L.Evented.extend({ this._mainEvents(onOff); - if (this.options.trackResize) { - var winTarget = this._resizeDetector && this._resizeDetector.contentWindow ? this._resizeDetector.contentWindow : - window; - L.DomEvent[onOff](winTarget, 'resize', this._onResize, this); - } + document.getElementById('document-container').addEventListener('resize', this._onResize.bind(this)); L.DomEvent[onOff](window, 'blur', this._onLostFocus, this); L.DomEvent[onOff](window, 'focus', this._onGotFocus, this); diff --git a/browser/src/map/handler/Map.Mouse.js b/browser/src/map/handler/Map.Mouse.js index 6b1201b42..66fda5beb 100644 --- a/browser/src/map/handler/Map.Mouse.js +++ b/browser/src/map/handler/Map.Mouse.js @@ -73,10 +73,6 @@ L.Map.Mouse = L.Handler.extend({ if (mouseEnteringLeavingMap && e.type === 'mouseover' && this._mouseDown) { L.DomEvent.off(document, 'mousemove', this._onMouseMoveOutside, this); L.DomEvent.off(document, 'mouseup', this._onMouseUpOutside, this); - if (this._map._resizeDetector) { - L.DomEvent.off(this._map._resizeDetector.contentWindow, 'mousemove', this._onMouseMoveOutside, this); - L.DomEvent.off(this._map._resizeDetector.contentWindow, 'mouseup', this._onMouseUpOutside, this); - } } else if (e.type === 'mousedown') { docLayer._resetPreFetching(); @@ -188,10 +184,6 @@ L.Map.Mouse = L.Handler.extend({ docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, count, buttons, modifier); } else if (mouseEnteringLeavingMap && e.type === 'mouseout' && this._mouseDown) { - if (this._map._resizeDetector) { - L.DomEvent.on(this._map._resizeDetector.contentWindow, 'mousemove', this._onMouseMoveOutside, this); - L.DomEvent.on(this._map._resizeDetector.contentWindow, 'mouseup', this._onMouseUpOutside, this); - } L.DomEvent.on(document, 'mousemove', this._onMouseMoveOutside, this); L.DomEvent.on(document, 'mouseup', this._onMouseUpOutside, this); } @@ -216,10 +208,6 @@ L.Map.Mouse = L.Handler.extend({ this._mouseDown = false; L.DomEvent.off(document, 'mousemove', this._onMouseMoveOutside, this); L.DomEvent.off(document, 'mouseup', this._onMouseUpOutside, this); - if (this._map._resizeDetector) { - L.DomEvent.off(this._map._resizeDetector.contentWindow, 'mousemove', this._onMouseMoveOutside, this); - L.DomEvent.off(this._map._resizeDetector.contentWindow, 'mouseup', this._onMouseUpOutside, this); - } this._map._handleDOMEvent(e); if (this._map.dragging.enabled()) {