Fixed: in Firefox the text of edited text fields would "jump" down 1 px.

Locking down the line height and vertical alignment explicitly seems to work in Safari 6, Chrome 21, Firefox 14 and IE 8 (although Chrome and IE exhibit some unrelated horizontal jumping.)
This commit is contained in:
Alexander Ljungberg
2012-08-15 17:13:34 +01:00
parent 1e49704062
commit d53b8c5b1f
2 changed files with 14 additions and 4 deletions
+3 -1
View File
@@ -546,7 +546,9 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
element.style.top = topPoint;
element.style.left = (_CGRectGetMinX(contentRect) - 1) + "px"; // -1 because input element seems to have 1px left inset
element.style.width = _CGRectGetWidth(contentRect) + "px";
element.style.height = lineHeight + "px";
element.style.height = ROUND(lineHeight) + "px";
element.style.lineHeight = ROUND(lineHeight) + "px";
element.style.verticalAlign = @"top";
_DOMElement.appendChild(element);
+11 -3
View File
@@ -432,13 +432,15 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
{
_DOMTextShadowElement = document.createElement("div");
var shadowStyle = _DOMTextShadowElement.style;
var shadowStyle = _DOMTextShadowElement.style,
font = (_font || [CPFont systemFontOfSize:CPFontCurrentSystemSize]);
shadowStyle.font = [(_font || [CPFont systemFontOfSize:CPFontCurrentSystemSize]) cssString];
shadowStyle.font = [font cssString];
shadowStyle.position = "absolute";
shadowStyle.whiteSpace = textStyle.whiteSpace;
shadowStyle.wordWrap = textStyle.wordWrap;
shadowStyle.color = [_textShadowColor cssString];
shadowStyle.lineHeight = [font defaultLineHeightForFont] + "px";
shadowStyle.zIndex = 150;
shadowStyle.textOverflow = textStyle.textOverflow;
@@ -484,11 +486,16 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
if (_flags & _CPImageAndTextViewFontChangedFlag)
{
var fontStyle = [(_font || [CPFont systemFontOfSize:CPFontCurrentSystemSize]) cssString];
var font = (_font || [CPFont systemFontOfSize:CPFontCurrentSystemSize]),
fontStyle = [font cssString];
textStyle.font = fontStyle;
textStyle.lineHeight = [font defaultLineHeightForFont] + "px";
if (shadowStyle)
{
shadowStyle.font = fontStyle;
shadowStyle.lineHeight = [font defaultLineHeightForFont] + "px";
}
}
// Update the line break mode if necessary.
@@ -713,6 +720,7 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
textStyle.left = ROUND(textRectX) + "px";
textStyle.width = MAX(CEIL(textRectWidth), 0) + "px";
textStyle.height = MAX(CEIL(textRectHeight), 0) + "px";
textStyle.verticalAlign = @"top";
if (shadowStyle)
{