Fix FF editor location by a pixel.

This commit is contained in:
Neil Fraser
2015-08-21 14:13:07 -07:00
parent fe12aeee93
commit f601bdc3c7
4 changed files with 16 additions and 8 deletions

View File

@@ -227,13 +227,13 @@ Blockly.Field.prototype.getSize = function() {
/**
* Returns the height and width of the field,
* accounting for the workspace scaling.
* @return {!Object} Height and width.
* @return {!goog.math.Size} Height and width.
*/
Blockly.Field.prototype.getScaledBBox_ = function() {
var bBox = this.borderRect_.getBBox();
// Create new object, as getBBox can return an uneditable SVGRect.
return {width: bBox.width * this.sourceBlock_.workspace.scale,
height: bBox.height * this.sourceBlock_.workspace.scale};
// Create new object, as getBBox can return an uneditable SVGRect in IE.
return new goog.math.Size(bBox.width * this.sourceBlock_.workspace.scale,
bBox.height * this.sourceBlock_.workspace.scale);
};
/**

View File

@@ -240,6 +240,12 @@ Blockly.FieldTextInput.prototype.resizeEditor_ = function() {
}
// Shift by a few pixels to line up exactly.
xy.y += 1;
if (goog.userAgent.GECKO && Blockly.WidgetDiv.DIV.style.top) {
// Firefox mis-reports the location of the border by a pixel
// once the WidgetDiv is moved into position.
xy.x -= 1;
xy.y -= 1;
}
if (goog.userAgent.WEBKIT) {
xy.y -= 3;
}

View File

@@ -85,6 +85,8 @@ Blockly.WidgetDiv.show = function(newOwner, rtl, dispose) {
Blockly.WidgetDiv.hide = function() {
if (Blockly.WidgetDiv.owner_) {
Blockly.WidgetDiv.DIV.style.display = 'none';
Blockly.WidgetDiv.DIV.style.left = '';
Blockly.WidgetDiv.DIV.style.top = '';
Blockly.WidgetDiv.dispose_ && Blockly.WidgetDiv.dispose_();
Blockly.WidgetDiv.owner_ = null;
Blockly.WidgetDiv.dispose_ = null;