Index: /CKEditor/trunk/_source/core/dom/element.js
===================================================================
--- /CKEditor/trunk/_source/core/dom/element.js	(revision 3741)
+++ /CKEditor/trunk/_source/core/dom/element.js	(revision 3742)
@@ -1100,18 +1100,44 @@
 		{
 			var x = 0, y = 0,
-				body = this.getDocument().getBody();
+				body = this.getDocument().getBody(),
+				quirks = this.getDocument().$.compatMode == 'BackCompat';
+
+			var doc = this.getDocument();
 
 			if ( document.documentElement[ "getBoundingClientRect" ] )
 			{
 				var box  = this.$.getBoundingClientRect(),
-					doc = this.getDocument().$,
-					docElem = doc.documentElement,
-					clientTop = docElem.clientTop || body.$.clientTop || 0,
-					clientLeft = docElem.clientLeft || body.$.clientLeft || 0;
-
-				x = box.left + ( !CKEDITOR.env.quirks && docElem.scrollLeft || body.$.scrollLeft );
-				x -= clientLeft;
-				y = box.top  + ( !CKEDITOR.env.quirks && docElem.scrollTop || body.$.scrollTop );
-				y -= clientTop;
+					$doc = doc.$,
+					$docElem = $doc.documentElement;
+
+				var clientTop = $docElem.clientTop || body.$.clientTop || 0,
+					clientLeft = $docElem.clientLeft || body.$.clientLeft || 0,
+					needAdjustScrollAndBorders = true;
+
+				/*
+				 * #3804: getBoundingClientRect() works differently on IE and non-IE
+				 * browsers, regarding scroll positions.
+				 *
+				 * On IE, the top position of the <html> element is always 0, no matter
+				 * how much you scrolled down.
+				 *
+				 * On other browsers, the top position of the <html> element is negative
+				 * scrollTop.
+				 */
+				if ( CKEDITOR.env.ie )
+				{
+					var inDocElem = doc.getDocumentElement().contains( this ),
+						inBody = doc.getBody().contains( this );
+
+					needAdjustScrollAndBorders = ( quirks && inBody ) || ( !quirks && inDocElem );
+				}
+
+				if ( needAdjustScrollAndBorders )
+				{
+					x = box.left + ( !quirks && $docElem.scrollLeft || body.$.scrollLeft );
+					x -= clientLeft;
+					y = box.top  + ( !quirks && $docElem.scrollTop || body.$.scrollTop );
+					y -= clientTop;
+				}
 			}
 			else
@@ -1162,5 +1188,5 @@
 				// In Firefox, we'll endup one pixel before the element positions,
 				// so we must add it here.
-				if ( CKEDITOR.env.gecko && !CKEDITOR.env.quirks )
+				if ( CKEDITOR.env.gecko && !quirks )
 				{
 					x += this.$.clientLeft ? 1 : 0;
Index: /CKEditor/trunk/_source/tests/core/dom/element.html
===================================================================
--- /CKEditor/trunk/_source/tests/core/dom/element.html	(revision 3741)
+++ /CKEditor/trunk/_source/tests/core/dom/element.html	(revision 3742)
@@ -507,5 +507,22 @@
 			assert.isTrue( element.hasAttributes() );
 		},
-
+		
+		test_getDocumentPosition : function()
+		{
+			// Assign the page location of the element. 
+			YAHOO.util.Dom.setXY('DocPositionTarget', [ 350, 450 ] );
+			var pos = CKEDITOR.document.getById( 'DocPositionTarget' ).getDocumentPosition();
+			if ( !CKEDITOR.env.ie )
+			{
+				assert.areEqual( 350, pos.x, 'Position coordinates:x relative to document doesn\'t match.' );
+				assert.areEqual( 450, pos.y, 'Position coordinates:y relative to document doesn\'t match.' );
+			}
+			else
+			{
+				assert.isTrue( pos.x == 348 || pos.x == 349, 'Position coordinates:x relative to document doesn\'t match.' );
+				assert.areEqual( 448, pos.y, 'Position coordinates:y relative to document doesn\'t match.' );
+			}
+		},
+		
 		name : document.title
 	};
@@ -514,4 +531,52 @@
 	//]]>
 	</script>
+	<style type="text/css" media="screen">
+		#test-computed {
+		    width:50%;
+		    margin:auto;
+		    padding:10px;
+		    z-index: 2;
+		}
+		.scroll
+		{
+			overflow: visible;
+		}
+		.block1
+		{
+			width: 100%;
+			height: 100px;
+			background-color: blue;
+			text-align: center;
+		}
+		.block2
+		{
+			margin: auto;
+			width: 200px;
+			height: 200px;
+			background-color: green;
+			position : relative;
+		}
+		.block3
+		{
+			position: absolute;
+			float:right;
+			width: 300px;
+			height: 300px;
+			background-color: black;
+		}
+		.block4
+		{
+			position: absolute;
+			left: 50px;
+			right: 50px;
+			width: 400px;
+			height: 400px;
+			background-color: pink;
+		}
+		#DocPositionTarget
+		{
+			background-color: red;
+		}
+	</style>
 </head>
 <body>
@@ -537,4 +602,7 @@
 	<big>Test</big>
 	<small title="Testing">Test</small>
+	
+	<div class="block1 scroll" id="block1"><div class="block2 scroll" id="block2"><div class="block3 scroll" id="block3"><div class="block4 scroll" id="block4"><div id="DocPositionTarget">target</div></div></div></div></div>
+	
 </body>
 </html>
