Ticket #3034: 3034.patch
File 3034.patch, 3.3 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
1148 1148 // 1. It matters if document.body itself is a positioned element; 1149 1149 // 2. It matters when we're in IE and the element has no positioned ancestor. 1150 1150 // Otherwise the values should be ignored. 1151 if ( this.getComputedStyle( 'position' ) != 'static' || ( CKEDITOR.env.ie && this.getPositionedAncestor() == null ) ) 1151 var body = this.getDocument().getBody(); 1152 if ( body.getComputedStyle( 'position' ) != 'static' || ( CKEDITOR.env.ie && this.getPositionedAncestor() == null ) ) 1152 1153 { 1153 x += this.getDocument().getBody().$.offsetLeft;1154 y += this.getDocument().getBody().$.offsetTop;1154 x += body.$.offsetLeft; 1155 y += body.$.offsetTop; 1155 1156 } 1156 1157 1157 1158 return { x : x, y : y };