Ticket #3034: 3034_2.patch

File 3034_2.patch, 3.8 KB (added by Martin Kou, 15 years ago)
  • _source/tests/core/dom/element.html

     
    486486                        var element = new CKEDITOR.dom.element( document.getElementsByTagName( 'small' )[0] );
    487487                        assert.isTrue( element.hasAttributes() );
    488488                },
    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               
    490507                name : document.title
    491508        };
    492509})() );
    493510
    494511        //]]>
    495512        </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>
    496561</head>
    497562<body>
    498563        <textarea id="test1" rows="10" cols="80"></textarea>
     
    515580B</div>
    516581        <big>Test</big>
    517582        <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       
    518586</body>
    519587</html>
  • _source/core/dom/element.js

     
    11141114                                x += current.$.offsetLeft - current.$.scrollLeft;
    11151115                                y += current.$.offsetTop - current.$.scrollTop;
    11161116
     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
    11171128                                if ( !CKEDITOR.env.opera )
    11181129                                {
    11191130                                        var scrollElement = previous;
     
    11481159                        // 1. It matters if document.body itself is a positioned element;
    11491160                        // 2. It matters when we're in IE and the element has no positioned ancestor.
    11501161                        // 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 ) )
    11521164                        {
    1153                                 x += this.getDocument().getBody().$.offsetLeft;
    1154                                 y += this.getDocument().getBody().$.offsetTop;
     1165                                x += body.$.offsetLeft;
     1166                                y += body.$.offsetTop;
    11551167                        }
    11561168
    11571169                        return { x : x, y : y };
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy