Author: max
Date: 2007-09-13 12:50:49 -0700 (Thu, 13 Sep 2007)
New Revision: 6464
Modified:
openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzInputTextSprite.js
openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzTextSprite.js
Log:
Change 20070913-maxcarlson-o by [EMAIL PROTECTED] on 2007-09-13 11:25:21 PDT
in /Users/maxcarlson/openlaszlo/legals
for http://svn.openlaszlo.org/openlaszlo/branches/legals
Summary: Fix inputtext height measurement
New Features:
Bugs Fixed: LPP-4658 - DHTML inputtext is the incorrect height
Technical Reviewer: promanik
QA Reviewer: hminsky
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details: LzSprite.js - Add text_measurement_use_insertadjacenthtml quirk and
turn it on for IE. Clean up testing to prevent LzModeManager and
LzKeyboardKernel exceptions when applications are loaded or unloaded and the
keyboard and mouse are active.
LzTextSprite.js - getTextSize() now does all text measurement inside a div,
rather than attaching to the body and uses the
text_measurement_use_insertadjacenthtml quirk.
LzInputTextSprite.js - Add getTextHeight() implementation to ensure correct
heights are reported.
Tests:
http://localhost:8080/legals/test/lztest/lztest-textheight.lzx?lzr=dhtml&debug=true
runs as before, and tabbing into and out of the inputtext in
http://localhost:8080/legals/examples/components/style_example.lzx?lzt=html&lzr=dhtml
no longer causes it to resize.
Modified:
openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzInputTextSprite.js
===================================================================
---
openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzInputTextSprite.js
2007-09-13 18:59:34 UTC (rev 6463)
+++
openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzInputTextSprite.js
2007-09-13 19:50:49 UTC (rev 6464)
@@ -409,3 +409,11 @@
if (testheight) this.text = '';
return h;
}
+
+LzInputTextSprite.prototype.getTextHeight = function () {
+ var h = this.getTextfieldHeight();
+ if (this.quirks.emulate_flash_font_metrics) {
+ h -= 4;
+ }
+ return h;
+}
Modified: openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
2007-09-13 18:59:34 UTC (rev 6463)
+++ openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
2007-09-13 19:50:49 UTC (rev 6464)
@@ -226,6 +226,7 @@
,set_height_for_multiline_inputtext: false
,ie_offset_position_by_2: false
,ie_opacity: false
+ ,text_measurement_use_insertadjacenthtml: false
}
LzSprite.prototype.capabilities = {
@@ -288,6 +289,9 @@
// IE 7 offsets div positions by 2 px. See LPP-4176.
this.quirks['ie_offset_position_by_2'] = true;
}
+
+ // text size measurement uses insertAdjacentHTML()
+ this.quirks['text_measurement_use_insertadjacenthtml'] = true;
} else if (Lz.__BrowserDetect.isSafari) {
// Fix bug in where if any parent of an image is hidden the size
is 0
// TODO: Tucker claims this is fixed in the latest version of
webkit
@@ -649,7 +653,7 @@
*/
LzSprite.prototype.__mouseEvent = function ( e ){
if (!e) e = window.event;
- if (window['LzKeyboardKernel'] &&
window['LzKeyboardKernel'].__keyboardEvent) LzKeyboardKernel.__keyboardEvent(e);
+ if (LzKeyboardKernel && LzKeyboardKernel['__keyboardEvent'])
LzKeyboardKernel.__keyboardEvent(e);
var skipevent = false;
var eventname = 'on' + e.type;
if (window['LzInputTextSprite'] && eventname == 'onmouseover' &&
LzInputTextSprite.prototype.__lastshown != null)
LzInputTextSprite.prototype.__hideIfNotFocused();
@@ -669,7 +673,7 @@
}
//Debug.write('__mouseEvent', eventname, this.owner);
- if (skipevent == false && this.owner.mouseevent)
LzModeManager.handleMouseButton(this.owner, eventname);
+ if (skipevent == false && this.owner.mouseevent && LzModeManager &&
LzModeManager['handleMouseButton']) LzModeManager.handleMouseButton(this.owner,
eventname);
}
// called by LzMouseKernel when mouse goes up on another sprite
Modified:
openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzTextSprite.js
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzTextSprite.js
2007-09-13 18:59:34 UTC (rev 6463)
+++ openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzTextSprite.js
2007-09-13 19:50:49 UTC (rev 6464)
@@ -240,7 +240,6 @@
} else {
var style = 'position: absolute';
style += ';visibility: hidden';
- style += ';top: 4000px';
style += ';font-size: ' + this._fontSize;
style += ';font-style: ' + this._fontStyle;
style += ';font-weight: ' + this._fontWeight;
@@ -249,13 +248,13 @@
if (this.multiline && ignorewidth != true) {
if (this.width) style += ';width: ' + this.width + 'px';
}
- if (document.all && document.body.insertAdjacentHTML) {
+ if (this.quirks['text_measurement_use_insertadjacenthtml']) {
if (this.__LzInputDiv != null) {
style += ';white-space: pre';
} else {
style += ';white-space: ' + this._whiteSpace;
}
- } else if (document.getElementById && document.createElement) {
+ } else {
if (this.__LzInputDiv != null) {
style += ';white-space: pre';
} else {
@@ -270,10 +269,20 @@
if (this._sizecache.counter > this.__sizecacheupperbound) this._sizecache
= {counter: 0};
if (this._sizecache[style] == null) this._sizecache[style] = {};
+ var root = document.getElementById('lzTextSizeCache');
+
+ if (! root) {
+ root = document.createElement('div');
+ root.setAttribute('id', 'lzTextSizeCache');
+ root.setAttribute('style', 'top: 4000px;');
+ document.body.appendChild(root);
+ }
+
var _textsizecache = this._sizecache[style];
if (! _textsizecache[string]) {
- var dim = {};
- if (document.all && document.body.insertAdjacentHTML) {
+ var size = {};
+
+ if (this.quirks['text_measurement_use_insertadjacenthtml']) {
if (this.multiline && string &&
this.quirks['inner_html_strips_newlines']) {
string = string.replace(this.inner_html_strips_newlines_re,
'<br />');
}
@@ -284,12 +293,12 @@
html += ' style="' + style + '">';
html += string;
html += '</' + tagname + '>';
- document.body.insertAdjacentHTML('beforeEnd', html);
+ root.insertAdjacentHTML('beforeEnd', html);
mdiv = document.all['testSpan' + this._sizecache.counter];
_textsizecache[tagname] = mdiv;
}
- } else if (document.getElementById && document.createElement) {
+ } else {
if (this.__LzInputDiv == null) {
if (this.multiline && string &&
this.quirks['inner_html_strips_newlines']) {
string =
string.replace(this.inner_html_strips_newlines_re, '<br />');
@@ -300,7 +309,7 @@
if (mdiv == null) {
mdiv = document.createElement(tagname);
mdiv.setAttribute('style', style);
- document.body.appendChild(mdiv);
+ root.appendChild(mdiv);
_textsizecache[tagname] = mdiv;
}
}
@@ -310,21 +319,21 @@
mdiv.innerHTML = string;
mdiv.style.display = 'block';
- dim.width = mdiv.offsetWidth;
- dim.height = mdiv.offsetHeight;
+ size.width = mdiv.offsetWidth;
+ size.height = mdiv.offsetHeight;
mdiv.style.display = 'none';
if (this.quirks.emulate_flash_font_metrics) {
// Fix to make equivalent across swf and DHTML
- dim.height = Math.floor(dim.height * 1.0000002) + (this.multiline
? 0 : this.__hpadding);
- dim.width = dim.width + (this.multiline ? 0 : this.__wpadding);
+ size.height = Math.floor(size.height * 1.0000002) +
(this.multiline ? 0 : this.__hpadding);
+ size.width = size.width + (this.multiline ? 0 : this.__wpadding);
if (this._whiteSpace == 'normal') {
if (this.multiline) {
- dim.width += this.__wpadding;
+ size.width += this.__wpadding;
}
}
}
- _textsizecache[string] = dim;
+ _textsizecache[string] = size;
this._sizecache.counter++;
}
return _textsizecache[string];
_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins