From 650f2b4d93b5734f8e448953554cd6f153b1e424 Mon Sep 17 00:00:00 2001 From: Piro / SHIMODA Hiroshi Date: Tue, 14 Jun 2011 00:59:34 +0900 Subject: [PATCH 1/4] do destruction process later than other addons --- modules/window.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/window.js b/modules/window.js index 7f8fffcc..d9233250 100644 --- a/modules/window.js +++ b/modules/window.js @@ -414,7 +414,15 @@ TreeStyleTabWindow.prototype = { // rap('window/init start'); var w = this.window; w.removeEventListener('load', this, false); - w.addEventListener('unload', this, false); + + /** + * We should register event handler with delay, to do destruction + * process later than other addons. + */ + var self = this; + this.Deferred.next(function() { + w.addEventListener('unload', self, false); + }); if ( w.location.href.indexOf('chrome://browser/content/browser.xul') != 0 || From de116110050d3d863519c268bce869ef08d00d17 Mon Sep 17 00:00:00 2001 From: Piro / SHIMODA Hiroshi Date: Tue, 14 Jun 2011 02:04:37 +0900 Subject: [PATCH 2/4] revert --- modules/window.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/modules/window.js b/modules/window.js index d9233250..6c21be2e 100644 --- a/modules/window.js +++ b/modules/window.js @@ -415,14 +415,7 @@ TreeStyleTabWindow.prototype = { var w = this.window; w.removeEventListener('load', this, false); - /** - * We should register event handler with delay, to do destruction - * process later than other addons. - */ - var self = this; - this.Deferred.next(function() { - w.addEventListener('unload', self, false); - }); + w.addEventListener('unload', this, false); if ( w.location.href.indexOf('chrome://browser/content/browser.xul') != 0 || From bb77306af23ae9873f970e2cb1aad1b7a4d6028d Mon Sep 17 00:00:00 2001 From: Piro / SHIMODA Hiroshi Date: Wed, 15 Jun 2011 00:29:36 +0900 Subject: [PATCH 3/4] dragging of multiple URIs causes error. --- modules/autoHide.js | 6 +++-- modules/tabbarDNDObserver.js | 48 ++++++++++++++++++++++++------------ 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/modules/autoHide.js b/modules/autoHide.js index 49dda2b5..21e7d9e2 100644 --- a/modules/autoHide.js +++ b/modules/autoHide.js @@ -1268,8 +1268,10 @@ AutoHideBrowser.prototype = { return; var draggedTabs = this.window['piro.sakura.ne.jp'].tabsDragUtils.getSelectedTabs(aEvent); - if (draggedTabs.length || - this.treeStyleTab.tabbarDNDObserver.retrieveURLFromDataTransfer(aEvent.dataTransfer)) { + if ( + draggedTabs.length || + this.treeStyleTab.tabbarDNDObserver.retrieveURLsFromDataTransfer(aEvent.dataTransfer).length + ) { this.show(this.kSHOWN_BY_MOUSEMOVE); if (this._autoHideOnDragLeaveTimer) { diff --git a/modules/tabbarDNDObserver.js b/modules/tabbarDNDObserver.js index 7f7b6b07..f1a71247 100644 --- a/modules/tabbarDNDObserver.js +++ b/modules/tabbarDNDObserver.js @@ -1073,7 +1073,8 @@ catch(e) { if (!draggedTab) { aEvent.stopPropagation(); - let url = this.retrieveURLFromDataTransfer(dt); + let urls = this.retrieveURLFromDataTransfer(dt); + let url = urls.length ? urls[0] : '' ; if (!url || !url.length || url.indexOf(' ', 0) != -1 || /^\s*(javascript|data):/.test(url)) return; @@ -1125,40 +1126,55 @@ catch(e) { } }, - retrieveURLFromDataTransfer : function TSTService_retrieveURLFromDataTransfer(aDataTransfer) + retrieveURLsFromDataTransfer : function TSTService_retrieveURLsFromDataTransfer(aDataTransfer) { - let url; - let types = ['text/x-moz-url', 'text/uri-list', 'text/plain', 'application/x-moz-file']; + var urls; + var types = [ + 'text/uri-list', + 'text/x-moz-text-internal', + 'text/x-moz-url', + 'text/plain', + 'application/x-moz-file' + ]; for (let i = 0; i < types.length; i++) { let dataType = types[i]; - let isURLList = dataType == 'text/uri-list'; - let urlData = aDataTransfer.mozGetDataAt(isURLList ? 'URL' : dataType , 0); - if (urlData) { - url = this.retrieveURLFromData(urlData, isURLList ? 'text/plain' : dataType); - break; + for (let i = 0, maxi = aDataTransfer.mozItemCount; i < maxi; i++) + { + let urlData = aDataTransfer.mozGetDataAt(dataType, i); + if (urlData) { + urls = urls.concat(this.retrieveURLsFromData(urlData, dataType)); + } } + if (urls.length) + break; } - return url; + return urls; }, - retrieveURLFromData : function TSTService_retrieveURLFromData(aData, aType) + retrieveURLsFromData : function TSTService_retrieveURLsFromData(aData, aType) { switch (aType) { + case 'text/uri-list': + return aData.replace(/\r/g, '\n') + .replace(/^\#.+$/gim, '') + .replace(/\n\n+/g, '\n') + .split('\n'); + case 'text/unicode': case 'text/plain': case 'text/x-moz-text-internal': - return aData.replace(/^\s+|\s+$/g, ''); + return [aData.replace(/^\s+|\s+$/g, '')]; case 'text/x-moz-url': - return ((aData instanceof Ci.nsISupportsString) ? aData.toString() : aData) - .split('\n')[0]; + return [((aData instanceof Ci.nsISupportsString) ? aData.toString() : aData) + .split('\n')[0]]; case 'application/x-moz-file': let fileHandler = IOService.getProtocolHandler('file') .QueryInterface(Ci.nsIFileProtocolHandler); - return fileHandler.getURLSpecFromFile(aData); + return [fileHandler.getURLSpecFromFile(aData)]; } - return null; + return []; }, init : function TabbarDND_init(aTabBrowser) From 511348dd666eb337e082a81c9b97ea5b12a9774b Mon Sep 17 00:00:00 2001 From: Piro / SHIMODA Hiroshi Date: Wed, 15 Jun 2011 00:34:08 +0900 Subject: [PATCH 4/4] forgot to initialize as an empty array --- modules/tabbarDNDObserver.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/tabbarDNDObserver.js b/modules/tabbarDNDObserver.js index f1a71247..481f98eb 100644 --- a/modules/tabbarDNDObserver.js +++ b/modules/tabbarDNDObserver.js @@ -1128,7 +1128,7 @@ catch(e) { retrieveURLsFromDataTransfer : function TSTService_retrieveURLsFromDataTransfer(aDataTransfer) { - var urls; + var urls = []; var types = [ 'text/uri-list', 'text/x-moz-text-internal',