From e1f4410ad4c78f3371a1faeeb2c600f684f551e3 Mon Sep 17 00:00:00 2001 From: tsauerwein Date: Wed, 12 Feb 2014 09:20:59 +0100 Subject: [PATCH] removes not needed WeakMap struct --- src/ol/pointer/pointereventhandler.js | 22 ------ src/ol/structs/weakmap.js | 101 -------------------------- 2 files changed, 123 deletions(-) delete mode 100644 src/ol/structs/weakmap.js diff --git a/src/ol/pointer/pointereventhandler.js b/src/ol/pointer/pointereventhandler.js index 89776b5908..4d2bb81ac4 100644 --- a/src/ol/pointer/pointereventhandler.js +++ b/src/ol/pointer/pointereventhandler.js @@ -43,7 +43,6 @@ goog.require('ol.pointer.MsSource'); goog.require('ol.pointer.NativeSource'); goog.require('ol.pointer.PointerEvent'); goog.require('ol.pointer.TouchSource'); -goog.require('ol.structs.WeakMap'); @@ -69,18 +68,6 @@ ol.pointer.PointerEventHandler = function(element) { this.pointerMap = new goog.structs.Map(); - /** - * @const - * @type {ol.structs.WeakMap} - */ - this.targets = new ol.structs.WeakMap(); - - /** - * @const - * @type {ol.structs.WeakMap} - */ - this.handledEvents = new ol.structs.WeakMap(); - this.eventMap = {}; // Scope objects for native events. @@ -215,19 +202,11 @@ ol.pointer.PointerEventHandler.prototype.unregister_ = function() { * @param {goog.events.BrowserEvent} inEvent Browser event. */ ol.pointer.PointerEventHandler.prototype.eventHandler_ = function(inEvent) { - // This is used to prevent multiple dispatch of pointerevents from - // platform events. This can happen when two elements in different scopes - // are set up to create pointer events, which is relevant to Shadow DOM. - if (this.handledEvents['get'](inEvent)) { - return; - } - var type = inEvent.type; var handler = this.eventMap[type]; if (handler) { handler(inEvent); } - this.handledEvents['set'](inEvent, true); }; @@ -503,7 +482,6 @@ ol.pointer.PointerEventHandler.prototype.makeEvent = function(inType, inEvent) { if (inEvent.preventDefault) { e.preventDefault = inEvent.preventDefault; } - this.targets['set'](e, this.targets['get'](inEvent) || inEvent.target); return e; }; diff --git a/src/ol/structs/weakmap.js b/src/ol/structs/weakmap.js deleted file mode 100644 index 6574e74b0f..0000000000 --- a/src/ol/structs/weakmap.js +++ /dev/null @@ -1,101 +0,0 @@ -// Based on https://github.com/Polymer/WeakMap - -// Copyright (c) 2013 The Polymer Authors. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -goog.provide('ol.structs.WeakMap'); - - -/** - * @suppress {undefinedVars} - * @return {boolean} Is `WeakMap` already defined? - */ -ol.structs.isWeakMapUndefined = function() { - return typeof WeakMap === 'undefined'; -}; - - -if (ol.structs.isWeakMapUndefined()) { - /** - * @constructor - */ - ol.structs.WeakMap = function() { - this.name = '__st' + (Math.random() * 1e9 >>> 0) + - (ol.structs.WeakMap.counter++ + '__'); - }; - - - /** - * @this {ol.structs.WeakMap} - * @param {*} key - * @param {*} value - */ - ol.structs.WeakMap.prototype['set'] = function(key, value) { - var entry = key[this.name]; - if (entry && entry[0] === key) - entry[1] = value; - else - ol.structs.WeakMap.defineProperty(key, this.name, - {value: [key, value], writable: true}); - }; - - - /** - * @this {ol.structs.WeakMap} - * @param {*} key - * @return {*} - */ - ol.structs.WeakMap.prototype['get'] = function(key) { - var entry; - return (entry = key[this.name]) && entry[0] === key ? - entry[1] : undefined; - }; - - - /** - * @this {ol.structs.WeakMap} - * @param {*} key - */ - ol.structs.WeakMap.prototype['delete'] = function(key) { - this['set'](key, undefined); - }; -} else { - ol.structs.WeakMap = WeakMap; -} - - -/** - * @type {function(...)} - */ -ol.structs.WeakMap.defineProperty = Object.defineProperty; - - -/** - * @type {number} - */ -ol.structs.WeakMap.counter = Date.now() % 1e9;