Ticket #7946: 7946_5.patch
File 7946_5.patch, 6.6 KB (added by , 12 years ago) |
---|
-
_source/plugins/selection/plugin.js
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
1650 1650 // If we have split the block, adds a temporary span at the 1651 1651 // range position and scroll relatively to it. 1652 1652 var start = this.getStartElement(); 1653 start.scrollInto View();1653 start.scrollIntoParent(); 1654 1654 } 1655 1655 }; 1656 1656 })(); -
_source/plugins/maximize/plugin.js
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
313 313 314 314 editor.getSelection().selectRanges(savedSelection); 315 315 var element = editor.getSelection().getStartElement(); 316 element && element.scrollInto View( true);316 element && element.scrollIntoParent(); 317 317 } 318 318 319 319 else -
_source/plugins/enterkey/plugin.js
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
239 239 tmpNode.setHtml( ' ' ); 240 240 241 241 range.insertNode( tmpNode ); 242 tmpNode.scrollInto View();242 tmpNode.scrollIntoParent(); 243 243 range.deleteContents(); 244 244 } 245 245 else 246 246 { 247 247 // We may use the above scroll logic for the new block case 248 248 // too, but it gives some weird result with Opera. 249 newBlock.scrollInto View();249 newBlock.scrollIntoParent(); 250 250 } 251 251 } 252 252 … … 359 359 dummy = doc.createElement( 'br' ); 360 360 361 361 dummy.insertBefore( lineBreak.getNext() ); 362 dummy.scrollInto View();362 dummy.scrollIntoParent(); 363 363 dummy.remove(); 364 364 } 365 365 } -
_source/core/dom/element.js
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
1396 1396 return { x : x, y : y }; 1397 1397 }, 1398 1398 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 ) 1400 1406 { 1401 // Get the element window. 1402 var win = this.getWindow(), 1403 winHeight = win.getViewPaneSize().height; 1407 !alignToTop && ( alignToTop = 1 ); 1408 !parent && ( parent = this.getWindow() ); 1404 1409 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 var isQuirks = doc.$.compatMode == 'BackCompat'; 1415 parent = isQuirks ? doc.getBody() : doc.getDocumentElement(); 1416 } 1408 1417 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 1414 { 1415 offset += this.$.offsetHeight || 0; 1416 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; 1420 } 1418 // Scroll window or element. 1419 function scrollBy( x, y ) 1420 { 1421 // Webkit doesn't support "scrollTop/scrollLeft" 1422 // on documentElement/body element. 1423 if ( /body|html/.test( parent.getName() ) ) 1424 parent.getWindow().$.scrollBy( x, y ); 1425 else 1426 { 1427 parent.$[ 'scrollLeft' ] = x; 1428 parent.$[ 'scrollTop' ] = y; 1429 } 1430 } 1421 1431 1422 // Append the offsets for the entire element hierarchy. 1423 var elementPosition = this.getDocumentPosition(); 1424 offset += elementPosition.y; 1432 var doc = parent.getDocument(); 1425 1433 1426 // offset value might be out of range(nagative), fix it(#3692). 1427 offset = offset < 0 ? 0 : offset; 1434 var thisPos = this.getDocumentPosition( doc ), 1435 parentPos = parent.getDocumentPosition( doc ), 1436 eh = this.$.offsetHeight, 1437 ew = this.$.offsetWidth, 1438 ch = parent.$.clientHeight, 1439 cw = parent.$.clientWidth, 1440 lt, 1441 br; 1428 1442 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 ); 1443 // Left-top margins. 1444 lt = 1445 { 1446 x : thisPos.x - parentPos.x || 0, 1447 y : thisPos.y - parentPos.y|| 0 1448 }; 1449 1450 // Bottom-right margins. 1451 br = 1452 { 1453 x : thisPos.x + ew - ( parentPos.x + cw ) || 0, 1454 y : thisPos.y + eh - ( parentPos.y + ch ) || 0 1455 }; 1456 1457 // Align top if specified, but never cut at the top when overflowed. 1458 if ( lt.y < 0 || br.y > 0 ) 1459 scrollBy( 0, alignToTop || lt.y < 0 ? lt.y : br.y ); 1460 1461 if ( hscroll && ( lt.x < 0 || br.x > 0 ) ) 1462 scrollBy( alignToTop || lt.x < 0 ? lt.x : br.x, 0 ); 1463 }, 1464 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; 1473 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 1433 1501 }, 1434 1502 1435 1503 setState : function( state )