1101 | | var x = 0, y = 0, current = this, previous = null; |
1102 | | while ( current && !( current.getName() == 'body' || current.getName() == 'html' ) ) |
1103 | | { |
1104 | | x += current.$.offsetLeft - current.$.scrollLeft; |
1105 | | y += current.$.offsetTop - current.$.scrollTop; |
| 1101 | var x = 0, y = 0, |
| 1102 | body = this.getDocument().getBody(); |
| 1103 | if ( document.documentElement[ "getBoundingClientRect" ] ) { |
| 1104 | var box = this.$.getBoundingClientRect(), |
| 1105 | doc = this.getDocument().$, |
| 1106 | docElem = doc.documentElement, |
| 1107 | clientTop = docElem.clientTop || body.$.clientTop || 0, |
| 1108 | clientLeft = docElem.clientLeft || body.$.clientLeft || 0; |
| 1109 | |
| 1110 | x = box.left + ( !CKEDITOR.env.quirks && docElem.scrollLeft || body.$.scrollLeft ); |
| 1111 | x -= clientLeft; |
| 1112 | y = box.top + ( !CKEDITOR.env.quirks && docElem.scrollTop || body.$.scrollTop ); |
| 1113 | y -= clientTop; |
| 1114 | } |
| 1115 | else |
| 1116 | { |
| 1117 | var current = this, previous = null; |
| 1118 | while ( current && !( current.getName() == 'body' || current.getName() == 'html' ) ) |
| 1119 | { |
| 1120 | x += current.$.offsetLeft - current.$.scrollLeft; |
| 1121 | y += current.$.offsetTop - current.$.scrollTop; |
1143 | | var body = this.getDocument().getBody(); |
1144 | | |
1145 | | // document.body is a special case when it comes to offsetTop and offsetLeft |
1146 | | // values. |
1147 | | // 1. It does not matter if we're in IE Quirks mode - in this case body is |
1148 | | // equal to the view pane itself. |
1149 | | // 2. It matters if document.body itself is a positioned element; |
1150 | | // 3. It matters when we're in IE Standards mode and the element has no |
1151 | | // positioned ancestor. |
1152 | | // Otherwise the values should be ignored. |
1153 | | if ( !( CKEDITOR.env.ie && CKEDITOR.env.quirks ) && ( body.getComputedStyle( 'position' ) != 'static' || |
1154 | | ( CKEDITOR.env.ie && !this.getPositionedAncestor() ) ) ) |
1155 | | { |
1156 | | x += body.$.offsetLeft + ( body.$.clientLeft || 0 ); |
1157 | | y += body.$.offsetTop + ( body.$.clientTop || 0 ); |
1158 | | } |
1159 | | |
1160 | | // In Firefox, we'll endup one pixel before the element positions, |
1161 | | // so we must add it here. |
1162 | | if ( CKEDITOR.env.gecko && !CKEDITOR.env.quirks ) |
1163 | | { |
1164 | | x += this.$.clientLeft ? 1 : 0; |
1165 | | y += this.$.clientTop ? 1 : 0; |
1166 | | } |
| 1157 | if ( !document.documentElement[ "getBoundingClientRect" ] ) { |
| 1158 | // In Firefox, we'll endup one pixel before the element positions, |
| 1159 | // so we must add it here. |
| 1160 | if ( CKEDITOR.env.gecko && !CKEDITOR.env.quirks ) |
| 1161 | { |
| 1162 | x += this.$.clientLeft ? 1 : 0; |
| 1163 | y += this.$.clientTop ? 1 : 0; |
| 1164 | } |
| 1165 | } |