From 3da96a75722e7ceef074bc1f2df55655b5b62b0f Mon Sep 17 00:00:00 2001 From: piro Date: Wed, 8 Apr 2009 15:16:34 +0000 Subject: [PATCH] =?UTF-8?q?=E7=94=BB=E9=9D=A2=E5=A4=96=E3=81=AB=E9=96=8B?= =?UTF-8?q?=E3=81=8B=E3=82=8C=E3=81=9F=E3=82=BF=E3=83=96=E3=81=AB=E6=AD=A3?= =?UTF-8?q?=E3=81=97=E3=81=8F=E3=82=B9=E3=82=AF=E3=83=AD=E3=83=BC=E3=83=AB?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= 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@4096 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/treestyletab.js | 17 ++++++++++++ content/treestyletab/treestyletabbrowser.js | 29 ++++++++++++--------- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index 4f2d8ebe..3c5dc18f 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -913,6 +913,23 @@ var TreeStyleTabService = { } } }, + + getXOffsetOfTab : function(aTab) + { + return this.evaluateXPath( + 'sum((self::* | preceding-sibling::xul:tab)/attribute::'+this.kX_OFFSET+')', + aTab, + XPathResult.NUMBER_TYPE + ).numberValue; + }, + getYOffsetOfTab : function(aTab) + { + return this.evaluateXPath( + 'sum((self::* | preceding-sibling::xul:tab)/attribute::'+this.kY_OFFSET+')', + aTab, + XPathResult.NUMBER_TYPE + ).numberValue; + }, /* Session Store API */ diff --git a/content/treestyletab/treestyletabbrowser.js b/content/treestyletab/treestyletabbrowser.js index 147b2aa4..7986acee 100644 --- a/content/treestyletab/treestyletabbrowser.js +++ b/content/treestyletab/treestyletabbrowser.js @@ -113,10 +113,12 @@ TreeStyleTabBrowser.prototype = { if (!aTab) return false; var tabBox = aTab.boxObject; var barBox = this.scrollBox.boxObject; - return (tabBox.screenX >= barBox.screenX && - tabBox.screenX + tabBox.width <= barBox.screenX + barBox.width && - tabBox.screenY >= barBox.screenY && - tabBox.screenY + tabBox.height <= barBox.screenY + barBox.height); + var xOffset = this.getXOffsetOfTab(aTab); + var yOffset = this.getYOffsetOfTab(aTab); + return (tabBox.screenX + xOffset >= barBox.screenX && + tabBox.screenX + xOffset + tabBox.width <= barBox.screenX + barBox.width && + tabBox.screenY + yOffset >= barBox.screenY && + tabBox.screenY + yOffset + tabBox.height <= barBox.screenY + barBox.height); }, isMultiRow : function() @@ -3097,7 +3099,7 @@ TreeStyleTabBrowser.prototype = { endOpacity = 0; } else { - aTab.setAttribute(offsetAttr, -maxMargin); + aTab.setAttribute(offsetAttr, maxMargin); startMargin = maxMargin; endMargin = 0; startOpacity = 0; @@ -3145,7 +3147,7 @@ TreeStyleTabBrowser.prototype = { collapseProp+': -'+margin+'px !important;'+ 'opacity: '+opacity+' !important;' ); - aTab.setAttribute(offsetAttr, -maxMargin); + aTab.setAttribute(offsetAttr, maxMargin); return false; } }; @@ -3305,13 +3307,16 @@ TreeStyleTabBrowser.prototype = { var targetTabBox = aTab.boxObject; var baseTabBox = aTab.parentNode.firstChild.boxObject; - var targetX = (aTab.boxObject.screenX < scrollBoxObject.screenX) ? - (targetTabBox.screenX - baseTabBox.screenX) - (targetTabBox.width * 0.5) : - (targetTabBox.screenX - baseTabBox.screenX) - scrollBoxObject.width + (targetTabBox.width * 1.5) ; + var xOffset = this.getXOffsetOfTab(aTab); + var yOffset = this.getYOffsetOfTab(aTab); - var targetY = (aTab.boxObject.screenY < scrollBoxObject.screenY) ? - (targetTabBox.screenY - baseTabBox.screenY) - (targetTabBox.height * 0.5) : - (targetTabBox.screenY - baseTabBox.screenY) - scrollBoxObject.height + (targetTabBox.height * 1.5) ; + var targetX = (aTab.boxObject.screenX + xOffset < scrollBoxObject.screenX) ? + (targetTabBox.screenX + xOffset - baseTabBox.screenX) - (targetTabBox.width * 0.5) : + (targetTabBox.screenX + xOffset - baseTabBox.screenX) - scrollBoxObject.width + (targetTabBox.width * 1.5) ; + + var targetY = (aTab.boxObject.screenY + yOffset < scrollBoxObject.screenY) ? + (targetTabBox.screenY + yOffset - baseTabBox.screenY) - (targetTabBox.height * 0.5) : + (targetTabBox.screenY + yOffset - baseTabBox.screenY) - scrollBoxObject.height + (targetTabBox.height * 1.5) ; this.scrollTo(targetX, targetY); },