From df8aa6f26a36247bb9c2db471b07e699e310c154 Mon Sep 17 00:00:00 2001 From: piro Date: Tue, 31 Mar 2009 07:44:56 +0000 Subject: [PATCH] =?UTF-8?q?=E3=83=A9=E3=82=A4=E3=83=96=E3=83=A9=E3=83=AA?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= 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@3972 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/boxObject.js | 86 +++++++++++++++++-------------- 1 file changed, 46 insertions(+), 40 deletions(-) diff --git a/content/treestyletab/boxObject.js b/content/treestyletab/boxObject.js index e6e8d018..135a0043 100644 --- a/content/treestyletab/boxObject.js +++ b/content/treestyletab/boxObject.js @@ -18,45 +18,6 @@ var Ci = Components.interfaces; - var getFrameOwnerFromFrame = function(aFrame) { - var parentItem = aFrame - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell) - .QueryInterface(Ci.nsIDocShellTreeNode) - .QueryInterface(Ci.nsIDocShellTreeItem) - .parent; - var isChrome = parentItem.itemType == parentItem.typeChrome; - var parentDocument = parentItem - .QueryInterface(Ci.nsIWebNavigation) - .document; - var nodes = parentDocument.evaluate( - '/descendant::*[contains(" frame FRAME iframe IFRAME browser tabbrowser ", concat(" ", local-name(), " "))]', - parentDocument, - null, - XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, - null - ); - for (let i = 0, maxi = nodes.snapshotLength; i < maxi; i++) - { - let owner = nodes.snapshotItem(i); - if (isChrome && owner.wrappedJSObject) owner = owner.wrappedJSObject; - if (owner.localName == 'tabbrowser') { - let tabs = owner.mTabContainer.childNodes; - for (let i = 0, maxi = tabs.length; i < maxi; i++) - { - let browser = tabs[i].linkedBrowser; - if (browser.contentWindow == aFrame) - return browser; - } - } - else if (owner.contentWindow == aFrame) { - return owner; - } - } - return null; - }; - window['piro.sakura.ne.jp'].boxObject = { revision : currentRevision, @@ -65,6 +26,11 @@ if ('getBoxObjectFor' in aNode.ownerDocument) return aNode.ownerDocument.getBoxObjectFor(aNode); + return this.getBoxObjectFromClientRectFor(aNode); + }, + + getBoxObjectFromClientRectFor : function(aNode) + { var box = { x : 0, y : 0, @@ -87,7 +53,7 @@ while (true) { frame = owner.ownerDocument.defaultView; - owner = getFrameOwnerFromFrame(frame); + owner = this._getFrameOwnerFromFrame(frame); if (!owner) { box.screenX += frame.screenX; box.screenY += frame.screenY; @@ -107,6 +73,46 @@ catch(e) { } return box; + }, + + _getFrameOwnerFromFrame : function(aFrame) + { + var parentItem = aFrame + .QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIWebNavigation) + .QueryInterface(Ci.nsIDocShell) + .QueryInterface(Ci.nsIDocShellTreeNode) + .QueryInterface(Ci.nsIDocShellTreeItem) + .parent; + var isChrome = parentItem.itemType == parentItem.typeChrome; + var parentDocument = parentItem + .QueryInterface(Ci.nsIWebNavigation) + .document; + var nodes = parentDocument.evaluate( + '/descendant::*[contains(" frame FRAME iframe IFRAME browser tabbrowser ", concat(" ", local-name(), " "))]', + parentDocument, + null, + XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, + null + ); + for (let i = 0, maxi = nodes.snapshotLength; i < maxi; i++) + { + let owner = nodes.snapshotItem(i); + if (isChrome && owner.wrappedJSObject) owner = owner.wrappedJSObject; + if (owner.localName == 'tabbrowser') { + let tabs = owner.mTabContainer.childNodes; + for (let i = 0, maxi = tabs.length; i < maxi; i++) + { + let browser = tabs[i].linkedBrowser; + if (browser.contentWindow == aFrame) + return browser; + } + } + else if (owner.contentWindow == aFrame) { + return owner; + } + } + return null; } };