From 5aac532c80c232bf199849c67cf66e9943dff9c0 Mon Sep 17 00:00:00 2001 From: piro Date: Sat, 26 Dec 2009 08:00:12 +0000 Subject: [PATCH] =?UTF-8?q?Gecko=201.9.1=E4=BB=A5=E5=89=8D=E7=94=A8?= =?UTF-8?q?=E3=81=AE=E3=83=8F=E3=83=83=E3=82=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@5671 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/treestyletab.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index a9d2c6f4..2b476529 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -1319,10 +1319,23 @@ catch(e) { fireTabSubtreeClosingEvent : function TSTService_fireTabSubtreeClosingEvent(aParentTab, aClosedTabs) { /* PUBLIC API */ - var event = aParentTab.ownerDocument.createEvent('UIEvents'); - event.initUIEvent('TreeStyleTabSubtreeClosing', true, true, aParentTab.ownerDocument.defaultView, aClosedTabs.length); + var event = aParentTab.ownerDocument.createEvent('Events'); + event.initEvent('TreeStyleTabSubtreeClosing', true, true); event.parent = aParentTab; event.tabs = aClosedTabs; + if (!event.getPreventDefault) { + // getPreventDefault is available on any event on Gecko 1.9.2 or later. + // on Gecko 1.9.1 or before, UIEvents only have the method... + event.__original__preventDefault = event.preventDefault; + event.__canceled = false; + event.preventDefault = function() { + this.__original__preventDefault(); + this.__canceled = true; + }; + event.getPreventDefault = function() { + return this.__canceled; + }; + } this.getTabBrowserFromChild(aParentTab).dispatchEvent(event); return !event.getPreventDefault(); },