Author: max
Date: 2007-01-24 09:34:20 -0800 (Wed, 24 Jan 2007)
New Revision: 3510
Modified:
openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzTextSprite.js
openlaszlo/branches/legals/test/lztest/lztest-textheight.lzx
Log:
Change 20070123-maxcarlson-3 by [EMAIL PROTECTED] on 2007-01-23 18:47:22 PST
in /Users/maxcarlson/openlaszlo/legals
Summary: Fix text measurement in DHTML
New Features:
Bugs Fixed: LPP-3397 - DHTML and SWF text wrapping difference, LPP-3276 -
DHTML - In Components - Sampler, text in tabslider is clipped
Technical Reviewer: promanik
QA Reviewer: hminsky
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details:
Tests:
http://localhost:8080/legals/examples/components/style_example.lzx?lzt=html&lzr=dhtml
isotope tabslider looks consistent in swf and dhtml. Updated
http://localhost:8080/legals/test/lztest/lztest-textheight.lzx?lzr=dhtml&debug=true
test to show new case. Failure now constent in DHTML across IE7 and firefox 2
mac.
lztest-textheight.lzx - Add dataset testcase, update labels.
LzSprite.js - inner_html_strips_newlines defaults to true
LzTextSprite.js - updated getTextSize, cleaned up setMultiLine()
Files:
M test/lztest/lztest-textheight.lzx
M WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
M WEB-INF/lps/lfc/kernel/dhtml/LzTextSprite.js
Changeset:
http://svn.openlaszlo.org/openlaszlo/patches/20070123-maxcarlson-3.tar
Modified: openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
2007-01-24 17:21:15 UTC (rev 3509)
+++ openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
2007-01-24 17:34:20 UTC (rev 3510)
@@ -257,7 +257,8 @@
,invisible_parent_image_sizing_fix: false
,disable_opacity: false
,emulate_flash_font_metrics: true
- ,inner_html_strips_newlines: false
+ // change \n to <br/>
+ ,inner_html_strips_newlines: true
,inner_html_no_entity_apos: false
,css_hide_canvas_during_init: true
,firefox_autocomplete_bug: false
@@ -289,9 +290,6 @@
// no image is attached
LzSprite.prototype.quirks['fix_ie_background_height'] = true;
- // workaround for IE stripping newlines from innerHTML
- LzSprite.prototype.quirks['inner_html_strips_newlines'] = true;
-
// workaround for IE not supporting ' in innerHTML
LzSprite.prototype.quirks['inner_html_no_entity_apos'] = true;
}
Modified:
openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzTextSprite.js
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzTextSprite.js
2007-01-24 17:21:15 UTC (rev 3509)
+++ openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzTextSprite.js
2007-01-24 17:34:20 UTC (rev 3510)
@@ -107,12 +107,9 @@
// use 'pre' The alternative would be `t.replace(RegExp('$',
// 'mg'), '<br />')`.
// TODO: [2006-10-02 ptw] Use 'pre-line' when supported.
+ // [max 1-23-2007] Actually, t.replace(...) gives the desired behavior...
if (this.multiline && t && (t.indexOf("\n") >= 0)) {
- if (this._whiteSpace != 'pre') {
- this._whiteSpace = 'pre';
- this.__LZdiv.style.whiteSpace = 'pre';
- }
- if (t && this.quirks['inner_html_strips_newlines']) {
+ if (this.quirks['inner_html_strips_newlines']) {
t = t.replace(RegExp('$', 'mg'), '<br />');
}
} else {
@@ -132,8 +129,9 @@
}
LzTextSprite.prototype.setMultiline = function(m) {
- if (this.multiline != (m == true)) {
- this.multiline = (m == true);
+ m = m == true;
+ if (this.multiline == m) return;
+ this.multiline = m;
if (m) {
// TODO: [2006-10-02 ptw] Use 'pre-line' when supported and
// remove the pre/normal hack in setText.
@@ -151,7 +149,6 @@
}
// To update height
this.setText(this.text, true);
- }
}
LzTextSprite.prototype.setPattern = function ( val ){
@@ -237,16 +234,19 @@
}
if (document.all && document.body.insertAdjacentHTML) {
- if (this.multiline) {
- if (string &&
LzSprite.prototype.quirks['inner_html_strips_newlines']) {
- string = string.replace(RegExp('$', 'mg'), '<br />');
- }
- style += '; white-space: ' + this._whiteSpace;
+ if (this.multiline && string &&
LzSprite.prototype.quirks['inner_html_strips_newlines']) {
+ string = string.replace(RegExp('$', 'mg'), '<br />');
}
- var html = '<span id="testSpan"';
+ if (this.__LzInputDiv != null) {
+ var tagname = 'div';
+ } else {
+ var tagname = 'span';
+ }
+ style += '; white-space: ' + this._whiteSpace;
+ var html = '<' + tagname + ' id="testSpan"';
html += ' style="' + style + '">';
html += string;
- html += '</span>';
+ html += '</' + tagname + '>';
document.body.insertAdjacentHTML('beforeEnd', html);
dim.width = document.all.testSpan.offsetWidth;
dim.height = document.all.testSpan.offsetHeight;
@@ -256,6 +256,9 @@
style += ';white-space: pre';
} else {
style += ';white-space: ' + this._whiteSpace;
+ if (this.multiline && string &&
LzSprite.prototype.quirks['inner_html_strips_newlines']) {
+ string = string.replace(RegExp('$', 'mg'), '<br />');
+ }
}
if (this.multiline) {
var div = document.createElement('div');
Modified: openlaszlo/branches/legals/test/lztest/lztest-textheight.lzx
===================================================================
--- openlaszlo/branches/legals/test/lztest/lztest-textheight.lzx
2007-01-24 17:21:15 UTC (rev 3509)
+++ openlaszlo/branches/legals/test/lztest/lztest-textheight.lzx
2007-01-24 17:34:20 UTC (rev 3510)
@@ -1,4 +1,4 @@
-<canvas height="760">
+<canvas height="800">
<!--
covers-tags : lztext
@@ -32,6 +32,21 @@
<inputtext fontsize="28" fgcolor="red" id="it6">D</inputtext>
<inputtext multiline="true" id="it7" width="350"/>
+ <dataset name="testds">
+ <text><![CDATA[What was this guy thinking? I mean to each their own,
but I can't figure out someone would think this would look good. You've got to
view the <a
href="http://www.flickr.com/photo_zoom.gne?id=174062027&size=l">Large
Version</a> of this photo to take it all in...
+
+I'm sure he paid a good bit for the airbrush work, wow... and on a tan car at
that... one 1977 Corvette that needs repainted.
+
+<b>NOTE:</b> This photo made it into Flickr's '<a
href="http://flickr.com/explore/">Explore</a>" as one of the top five hundred
most interesting photos on a particular day. You can see all of my photo's
that have made it into the Flickr Explore pages <a
href="http://www.flickr.com/photos/fensterbme/tags/interestingness/">here</a>.]]></text>
+ </dataset>
+
+ <view width="230">
+ <text id="t12" datapath="testds:/text/text()"
+ fgcolor="0x5c5c5c" bgcolor="yellow"
+ multiline="true"
+ width="${parent.width}" />
+ </view>
+
<script><![CDATA[
var textSizeSuite = new LzTestSuite("Text Size Test Suite");
@@ -66,8 +81,10 @@
LzTestManager.assertEquals(16, t9.height, "text9 height");
LzTestManager.assertEquals(16, t10.getAttribute("height"), "text10
height");
LzTestManager.assertEquals(16, t10.height, "text10 height");
- LzTestManager.assertEquals(56, t11.getAttribute("height"), "multiline7
text height");
- LzTestManager.assertEquals(56, t11.height, "multiline7 text.height");
+ LzTestManager.assertEquals(56, t11.getAttribute("height"), "multiline11
text height");
+ LzTestManager.assertEquals(56, t11.height, "multiline11 text.height");
+ LzTestManager.assertEquals(277, t12.getAttribute("height"), "text12
height");
+ LzTestManager.assertEquals(277, t12.height, "text12 text.height");
LzTestManager.assertEquals(17, it1.getAttribute("height"), "inputtext1
height");
LzTestManager.assertEquals(17, it1.height, "inputtext4.height");
LzTestManager.assertEquals(38, it2.getAttribute("height"), "inputtext2
height");
@@ -77,11 +94,11 @@
LzTestManager.assertEquals(38, it4.getAttribute("height"), "inputtext4
height");
LzTestManager.assertEquals(38, it4.height, "inputtext4.height");
LzTestManager.assertEquals(52, it5.getAttribute("height"), "inputtext5
height");
- LzTestManager.assertEquals(52, it5.height, "inputtext4.height");
- LzTestManager.assertEquals(38, it6.getAttribute("height"), "inputtext4
height");
- LzTestManager.assertEquals(38, it6.height, "inputtext4.height");
- LzTestManager.assertEquals(56, it7.getAttribute("height"), "multiline7
text height");
- LzTestManager.assertEquals(56, it7.height, "multiline7 text.height");
+ LzTestManager.assertEquals(52, it5.height, "inputtext5.height");
+ LzTestManager.assertEquals(38, it6.getAttribute("height"), "inputtext6
height");
+ LzTestManager.assertEquals(38, it6.height, "inputtext6.height");
+ LzTestManager.assertEquals(56, it7.getAttribute("height"), "multiline7
inputtext height");
+ LzTestManager.assertEquals(56, it7.height, "multiline7 inputtext.height");
}
@@ -104,6 +121,8 @@
LzTestManager.assertEquals(88, t10.width, "text10 width");
LzTestManager.assertEquals(350, t11.getAttribute("width"), "multiline7
text.width");
LzTestManager.assertEquals(350, t11.width, "multiline7 text width");
+ LzTestManager.assertEquals(230, t12.getAttribute("width"), "text12.width");
+ LzTestManager.assertEquals(230, t12.width, "text12 width");
LzTestManager.assertEquals(200, it1.getAttribute("width"), "inputtext1
width");
LzTestManager.assertEquals(200, it1.width, "inputtext1.width");
LzTestManager.assertEquals(200, it2.getAttribute("width"), "inputtext2
width");
@@ -114,11 +133,11 @@
LzTestManager.assertEquals(26, it4.width, "inputtext4.width");
LzTestManager.assertEquals(17, it5.getAttribute("width"), "inputtext5
width");
LzTestManager.assertEquals(17, it5.width, "inputtext5.width");
- LzTestManager.assertEquals(26, it6.getAttribute("width"), "inputtext4
width");
- LzTestManager.assertEquals(26, it6.width, "inputtext4.width");
+ LzTestManager.assertEquals(26, it6.getAttribute("width"), "inputtext6
width");
+ LzTestManager.assertEquals(26, it6.width, "inputtext6.width");
- LzTestManager.assertEquals(350, it7.getAttribute("width"), "multiline7
text.width");
- LzTestManager.assertEquals(350, it7.width, "multiline7 text width");
+ LzTestManager.assertEquals(350, it7.getAttribute("width"), "multiline7
inputtext.width");
+ LzTestManager.assertEquals(350, it7.width, "multiline7 inputtext width");
}
textSizeSuite.addTest(textSizeSuite.testJustText);
_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins