Ticket #7946: 7946_4.patch

File 7946_4.patch, 6.3 KB (added by Garry Yao, 12 years ago)
  • _source/plugins/selection/plugin.js

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    16501650                        // If we have split the block, adds a temporary span at the
    16511651                        // range position and scroll relatively to it.
    16521652                        var start = this.getStartElement();
    1653                         start.scrollIntoView();
     1653                        start.scrollIntoParent();
    16541654                }
    16551655        };
    16561656})();
  • _source/plugins/maximize/plugin.js

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    313313
    314314                                                                editor.getSelection().selectRanges(savedSelection);
    315315                                                                var element = editor.getSelection().getStartElement();
    316                                                                 element && element.scrollIntoView( true );
     316                                                                element && element.scrollIntoParent();
    317317                                                        }
    318318
    319319                                                        else
  • _source/plugins/enterkey/plugin.js

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    239239                                        tmpNode.setHtml( '&nbsp;' );
    240240
    241241                                        range.insertNode( tmpNode );
    242                                         tmpNode.scrollIntoView();
     242                                        tmpNode.scrollIntoParent();
    243243                                        range.deleteContents();
    244244                                }
    245245                                else
    246246                                {
    247247                                        // We may use the above scroll logic for the new block case
    248248                                        // too, but it gives some weird result with Opera.
    249                                         newBlock.scrollIntoView();
     249                                        newBlock.scrollIntoParent();
    250250                                }
    251251                        }
    252252
     
    359359                                                dummy = doc.createElement( 'br' );
    360360
    361361                                        dummy.insertBefore( lineBreak.getNext() );
    362                                         dummy.scrollIntoView();
     362                                        dummy.scrollIntoParent();
    363363                                        dummy.remove();
    364364                                }
    365365                        }
  • _source/core/dom/element.js

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    13961396                        return { x : x, y : y };
    13971397                },
    13981398
    1399                 scrollIntoView : function( alignTop )
     1399                /**
     1400                 * Make any page element visible inside one of the ancestor by scrolling the parent.
     1401                 * @param {CKEDITOR.dom.element|CKEDITOR.dom.window} parent The container to scroll into.
     1402                 * @param {Boolean} [alignToTop] Align the element's top side with the container's.
     1403                 * @param {Boolean} [hscroll] Whether horizontal overflow should be considered.
     1404                 */
     1405                scrollIntoParent : function( parent, alignToTop, hscroll )
    14001406                {
    1401                         // Get the element window.
    1402                         var win = this.getWindow(),
    1403                                 winHeight = win.getViewPaneSize().height;
     1407                        !alignToTop && ( alignToTop = 1 );
     1408                        !parent && ( parent = this.getWindow() );
    14041409
    1405                         // Starts from the offset that will be scrolled with the negative value of
    1406                         // the visible window height.
    1407                         var offset = winHeight * -1;
     1410                        // On window <html> is scrolled while quirks scrolls <body>.
     1411                        if ( parent instanceof CKEDITOR.dom.window )
     1412                        {
     1413                                doc = new CKEDITOR.dom.document( parent.$.document );
     1414                                parent = CKEDITOR.env.quirks ? doc.getDocumentElement() : doc.getBody();
     1415                        }
    14081416
    1409                         // Append the view pane's height if align to top.
    1410                         // Append element height if we are aligning to the bottom.
    1411                         if ( alignTop )
    1412                                 offset += winHeight;
    1413                         else
     1417                        var doc = parent.getDocument();
     1418
     1419                        var thisPos = this.getDocumentPosition( doc ),
     1420                                parentPos = parent.getDocumentPosition( doc ),
     1421                                eh = this.$.offsetHeight,
     1422                                ew = this.$.offsetWidth,
     1423                                ch = parent.$.clientHeight,
     1424                                cw = parent.$.clientWidth,
     1425                                lt,
     1426                                br;
     1427
     1428                        // Left-top margins.
     1429                        lt =
    14141430                        {
    1415                                 offset += this.$.offsetHeight || 0;
     1431                                x : thisPos.x - parentPos.x || 0,
     1432                                y : thisPos.y - parentPos.y|| 0
     1433                        };
    14161434
    1417                                 // Consider the margin in the scroll, which is ok for our current needs, but
    1418                                 // needs investigation if we will be using this function in other places.
    1419                                 offset += parseInt( this.getComputedStyle( 'marginBottom' ) || 0, 10 ) || 0;
     1435                        // Bottom-right margins.
     1436                        br =
     1437                        {
     1438                                x : thisPos.x + ew - ( parentPos.x + cw ) || 0,
     1439                                y : thisPos.y + eh - ( parentPos.y + ch ) || 0
     1440                        };
     1441
     1442                        if ( lt.y < 0 || br.y > 0 )
     1443                        {
     1444                                // Never cut at the top
     1445                                if ( alignToTop || lt.y < 0 )
     1446                                        parent.$.scrollTop += lt.y;
     1447                                else
     1448                                        parent.$.scrollTop += br.y;
     1449
    14201450                        }
    14211451
    1422                         // Append the offsets for the entire element hierarchy.
    1423                         var elementPosition = this.getDocumentPosition();
    1424                         offset += elementPosition.y;
     1452                        if ( hscroll )
     1453                        {
     1454                                if ( lt.x < 0 || br.x > 0 )
     1455                                {
     1456                                        // Never cut at the left
     1457                                        if ( alignToTop || lt.x < 0 )
     1458                                                parent.$.scrollLeft += lt.x;
     1459                                        else
     1460                                                parent.$.scrollLeft += br.x;
     1461                                }
     1462                        }
     1463                },
    14251464
    1426                         // offset value might be out of range(nagative), fix it(#3692).
    1427                         offset = offset < 0 ? 0 : offset;
     1465                /**
     1466                 * Make any page element visible inside of the browser viewport.
     1467                 * @param {Boolean} [alignToTop]
     1468                 */
     1469                scrollIntoView : function( alignToTop )
     1470                {
     1471                        var parent = this.getParent();
     1472                        if ( !parent ) return;
    14281473
    1429                         // Scroll the window to the desired position, if not already visible(#3795).
    1430                         var currentScroll = win.getScrollPosition().y;
    1431                         if ( offset > currentScroll || offset < currentScroll - winHeight )
    1432                                 win.$.scrollTo( 0, offset );
     1474                        // Scroll the element into parent container from the inner out.
     1475                        do
     1476                        {
     1477                                // Check ancestors that overflows.
     1478                                var overflowed =
     1479                                        parent.$.clientWidth && parent.$.clientWidth < parent.$.scrollWidth
     1480                                        || parent.$.clientHeight && parent.$.clientHeight < parent.$.scrollHeight;
     1481
     1482                                if ( overflowed )
     1483                                        this.scrollIntoParent( parent, alignToTop, 1 );
     1484
     1485                                // Walk across the frame.
     1486                                if ( parent.is( 'html' ) )
     1487                                {
     1488                                        var win = parent.getWindow();
     1489
     1490                                        // Avoid security error.
     1491                                        try
     1492                                        {
     1493                                                var iframe = win.$.frameElement;
     1494                                                iframe && ( parent = new CKEDITOR.dom.element( iframe ) );
     1495                                        }
     1496                                        catch(er){}
     1497                                }
     1498                        }
     1499                        while ( parent = parent.getParent() );
     1500
    14331501                },
    14341502
    14351503                setState : function( state )
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy