Ticket #3034: 3034_2.patch
File 3034_2.patch, 3.8 KB (added by , 15 years ago) |
---|
-
_source/tests/core/dom/element.html
486 486 var element = new CKEDITOR.dom.element( document.getElementsByTagName( 'small' )[0] ); 487 487 assert.isTrue( element.hasAttributes() ); 488 488 }, 489 489 490 test_getDocumentPosition : function() 491 { 492 // Assign the page location of the element. 493 YAHOO.util.Dom.setXY('DocPositionTarget', [ 350, 450 ] ); 494 var pos = CKEDITOR.document.getById( 'DocPositionTarget' ).getDocumentPosition(); 495 if ( !CKEDITOR.env.ie ) 496 { 497 assert.areEqual( 350, pos.x, 'Position coordinates:x relative to document doesn\'t match.' ); 498 assert.areEqual( 450, pos.y, 'Position coordinates:y relative to document doesn\'t match.' ); 499 } 500 else 501 { 502 assert.isTrue( pos.x == 348 || pos.x == 349, 'Position coordinates:x relative to document doesn\'t match.' ); 503 assert.areEqual( 448, pos.y, 'Position coordinates:y relative to document doesn\'t match.' ); 504 } 505 }, 506 490 507 name : document.title 491 508 }; 492 509 })() ); 493 510 494 511 //]]> 495 512 </script> 513 <style type="text/css" media="screen"> 514 #test-computed { 515 width:50%; 516 margin:auto; 517 padding:10px; 518 z-index: 2; 519 } 520 .scroll 521 { 522 overflow: visible; 523 } 524 .block1 525 { 526 width: 100%; 527 height: 100px; 528 background-color: blue; 529 text-align: center; 530 } 531 .block2 532 { 533 margin: auto; 534 width: 200px; 535 height: 200px; 536 background-color: green; 537 position : relative; 538 } 539 .block3 540 { 541 position: absolute; 542 float:right; 543 width: 300px; 544 height: 300px; 545 background-color: black; 546 } 547 .block4 548 { 549 position: absolute; 550 left: 50px; 551 right: 50px; 552 width: 400px; 553 height: 400px; 554 background-color: pink; 555 } 556 #DocPositionTarget 557 { 558 background-color: red; 559 } 560 </style> 496 561 </head> 497 562 <body> 498 563 <textarea id="test1" rows="10" cols="80"></textarea> … … 515 580 B</div> 516 581 <big>Test</big> 517 582 <small title="Testing">Test</small> 583 584 <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> 585 518 586 </body> 519 587 </html> -
_source/core/dom/element.js
1114 1114 x += current.$.offsetLeft - current.$.scrollLeft; 1115 1115 y += current.$.offsetTop - current.$.scrollTop; 1116 1116 1117 /* 1118 * IE doesn't really include the element borders into offsetLeft and 1119 * offsetTop, despite their claims on their MSDN documentations. 1120 * (#3034) 1121 */ 1122 if ( CKEDITOR.env.ie && !this.equals( current ) ) 1123 { 1124 x += current.$.clientLeft; 1125 y += current.$.clientTop; 1126 } 1127 1117 1128 if ( !CKEDITOR.env.opera ) 1118 1129 { 1119 1130 var scrollElement = previous; … … 1148 1159 // 1. It matters if document.body itself is a positioned element; 1149 1160 // 2. It matters when we're in IE and the element has no positioned ancestor. 1150 1161 // Otherwise the values should be ignored. 1151 if ( this.getComputedStyle( 'position' ) != 'static' || ( CKEDITOR.env.ie && this.getPositionedAncestor() == null ) ) 1162 var body = this.getDocument().getBody(); 1163 if ( body.getComputedStyle( 'position' ) != 'static' || ( CKEDITOR.env.ie && this.getPositionedAncestor() == null ) ) 1152 1164 { 1153 x += this.getDocument().getBody().$.offsetLeft;1154 y += this.getDocument().getBody().$.offsetTop;1165 x += body.$.offsetLeft; 1166 y += body.$.offsetTop; 1155 1167 } 1156 1168 1157 1169 return { x : x, y : y };