mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
Context menu in wrong place
A bug in I4bad882d1d6fb83bcdcfd0de3bfc9af52960c2ff caused the vertical position to sometimes be NaN, and thus make the context in the wrong place (but only vertically). Change-Id: I5216af5c432caaa0fb400d8d006647b9f2488619
This commit is contained in:
parent
76b277485e
commit
2706b6dc50
|
@ -135,7 +135,7 @@ ve.ce.Surface.static.textPattern = new RegExp(
|
||||||
* @static
|
* @static
|
||||||
*/
|
*/
|
||||||
ve.ce.Surface.getSelectionRect = function () {
|
ve.ce.Surface.getSelectionRect = function () {
|
||||||
var sel, rect, $span, startRange, startOffset, endRange, endOffset, scrollLeft, scrollTop;
|
var sel, rect, $span, lineHeight, startRange, startOffset, endRange, endOffset;
|
||||||
|
|
||||||
if ( !rangy.initialized ) {
|
if ( !rangy.initialized ) {
|
||||||
rangy.init();
|
rangy.init();
|
||||||
|
@ -168,23 +168,22 @@ ve.ce.Surface.getSelectionRect = function () {
|
||||||
endRange.collapse( false );
|
endRange.collapse( false );
|
||||||
endRange.insertNode( $span[0] );
|
endRange.insertNode( $span[0] );
|
||||||
endOffset = $span.offset();
|
endOffset = $span.offset();
|
||||||
|
lineHeight = parseInt( $span.css( 'line-height' ), 10 );
|
||||||
$span.detach();
|
$span.detach();
|
||||||
|
|
||||||
// Restore the selection
|
// Restore the selection
|
||||||
startRange.refresh();
|
startRange.refresh();
|
||||||
|
|
||||||
// Return the selection bounding rectangle
|
// Return the selection bounding rectangle
|
||||||
scrollLeft = $( window ).scrollLeft();
|
|
||||||
scrollTop = $( window ).scrollTop();
|
|
||||||
return {
|
return {
|
||||||
'start': {
|
'start': {
|
||||||
x: startOffset.left - scrollLeft,
|
'x': startOffset.left,
|
||||||
y: startOffset.top - scrollTop
|
'y': startOffset.top
|
||||||
},
|
},
|
||||||
'end': {
|
'end': {
|
||||||
x: endOffset.left - scrollLeft,
|
'x': endOffset.left,
|
||||||
// Adjust the vertical position by the line-height to get the bottom dimension
|
// Adjust the vertical position by the line-height to get the bottom dimension
|
||||||
y: endOffset.top - scrollTop + parseInt( $span.css( 'line-height' ), 10 )
|
'y': endOffset.top + lineHeight
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue