From 4d3ebf09126f785ab7c63ebadeb0d11bbc33367a Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Tue, 4 Dec 2007 04:28:27 +0000 Subject: [PATCH] Change document.viewport.getDimensions to exclude scrollbars in all cases. Closes #10148, #9288. [Nick Stackenburg] --- CHANGELOG | 2 ++ src/dom.js | 5 ++-- test/unit/dom.html | 61 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 03c1522..c64a40b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Change document.viewport.getDimensions to exclude scrollbars in all cases. Closes #10148, #9288. [Nick Stackenburg] + * Add logic to Element#getStyle in Opera that fixes inaccurate reporting of computed 'width' and 'height' properties. [Andrew Dupont] * Ensure that an Ajax.Request's parameters option can be a Hash. Closes #10172. [kangax, sam] diff --git a/src/dom.js b/src/dom.js index 3a2eab3..a2d7240 100644 --- a/src/dom.js +++ b/src/dom.js @@ -1204,10 +1204,11 @@ Element.addMethods = function(methods) { document.viewport = { getDimensions: function() { var dimensions = { }; + var B = Prototype.Browser; $w('width height').each(function(d) { var D = d.capitalize(); - dimensions[d] = self['inner' + D] || - (document.documentElement['client' + D] || document.body['client' + D]); + dimensions[d] = (B.WebKit && !document.evaluate) ? self['inner' + D] : + (B.Opera) ? document.body['client' + D] : document.documentElement['client' + D]; }); return dimensions; }, diff --git a/test/unit/dom.html b/test/unit/dom.html index 8e1d59f..17c95a0 100644 --- a/test/unit/dom.html +++ b/test/unit/dom.html @@ -82,6 +82,15 @@ #notInlineAbsoluted { position: absolute; } + #elementToViewportDimensions { + position: absolute; + top: 0; + left: 0; + height: 10px; + width: 10px; + background: #000; + } + /* for scroll test on really big screens */ body { height: 40000px; @@ -371,6 +380,8 @@
+ +