It sounds like a good optimization, maybe we should file an improvement task for it..<br>I suppose we'd need to check that IE7 didn't have some bug with parsing the style<br>text, like it has with reading it out... <br>
<br><br><div class="gmail_quote">On Wed, Oct 14, 2009 at 10:09 AM, P T Withington <span dir="ltr"><<a href="mailto:ptw@laszlosystems.com">ptw@laszlosystems.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
My idea is that we'd keep the classes around, so if I create a div that uses 15pt monospace, there would be a class for that. I'd only create it the first time around, after that, I'd look up the class name and just jam it in:<br>
<br>
var fontclass = findClassForFont(style, variant, weight, size, lineHeight, family);<br>
div.className = 'lzswftext ' + fontclass;<br>
<br>
And when switching from single to multiline I would be able to just reuse the "type style" class, doing something like:<br>
<br>
newdiv.className = olddiv.className.replace('lzswftext', 'lzswftextmultiline'); // leave the type style class alone.<div><div></div><div class="h5"><br>
<br>
<br>
On 2009-10-14, at 09:59, Henry Minsky wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
What would be the advantage? making it cleaner to apply and remove these<br>
properties as a group? I don't think it would help with speed because it<br>
would cost you as much time and space to cons up the new class as to frob<br>
the properties directly on the div...<br>
<br>
On Wed, Oct 14, 2009 at 9:55 AM, P T Withington <<a href="mailto:ptw@laszlosystems.com" target="_blank">ptw@laszlosystems.com</a>>wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Ok, here's another idea, maybe too whacky:<br>
<br>
Instead of smacking styles into divs, what if we dynamically created a CSS<br>
class style rule for each case? We already have some of this mechanism in<br>
the measurement cache. At least for the various text attributes we could do<br>
something like, accumulate all the text style properties, build a CSS rule,<br>
assign it to a (generated) class name, and add that class name to the div's<br>
class (you can have multiple classes apply to a div, they are separated by<br>
spaces).<br>
<br>
We'd still use individual styles for position/overflow/width/height/clip,<br>
but for the styles that affect text, bundle them into a class.<br>
<br>
<br>
On 2009-10-14, at 09:37, Henry Minsky wrote:<br>
<br>
In Firefox, asking for cssText gives you this<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
lzx> foo.sprite.__LzInputDiv.style.cssText<br>
'overflow: scroll; font-family: monospace; width: 415px; height: 115px;'<br>
lzx><br>
<br>
But in IE7 you get no font info<br>
lzx> foo.sprite.__LzInputDiv.style.cssText<br>
'OVERFLOW: scroll; WIDTH: 417px; CLIP: rect(auto auto auto auto); HEIGHT:<br>
117px'<br>
lzx><br>
<br>
<br>
On Wed, Oct 14, 2009 at 9:29 AM, Henry Minsky <<a href="mailto:henry.minsky@gmail.com" target="_blank">henry.minsky@gmail.com</a><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
wrote:<br>
</blockquote>
<br>
That apparently does not work in IE7 for some reason...<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
On Wed, Oct 14, 2009 at 9:25 AM, P T Withington <<a href="mailto:ptw@laszlosystems.com" target="_blank">ptw@laszlosystems.com</a><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
wrote:<br>
</blockquote>
<br>
I don't follow. setMultiline copies _all_ of the div styles over:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
lz.embed.__setAttr(newdiv, 'style', olddiv.style.cssText);<br>
<br>
(in addition to the scroll position). So, something else is going<br>
wrong...<br>
<br>
<br>
On 2009-10-14, at 08:22, Max Carlson wrote:<br>
<br>
Yes, I think it needs to copy the necessary fontstyles over. Right now<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
LzInputTextSprite#setMultiline() only preserves the text contents,<br>
scrollLeft and scrollTop. The necessary styles should be preserved in:<br>
LzInputTextSprite.prototype.__fontStyle = 'normal';<br>
LzInputTextSprite.prototype.__fontWeight = 'normal';<br>
LzInputTextSprite.prototype.__fontSize = '11px';<br>
LzInputTextSprite.prototype.__fontFamily = 'Verdana,Vera,sans-serif';<br>
<br>
I'd avoid copying the entire CSS style - that's pretty risky.<br>
<br>
Henry Minsky wrote:<br>
<br>
I'm trying to figure out why the font is changing back to the default<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
font when an input field<br>
is set to multiline in IE7/DHTML.<br>
The code in LzInputTextSprite.setMultiline does create a new div, with<br>
_createInputDiv, does that need to<br>
copy the font styles over?<br>
<canvas><br>
<inputtext id="foo" width="400" x="14" name="foo" font="monospace"<br>
fontsize="11" fontstyle="plain"<br>
multiline="false"<br>
text="${canvas.runtime}"<br>
bgcolor="#ccffcc"<br>
onclick=" setAttribute('multiline', true);<br>
this.setAttribute('height', 100); "/><br>
</canvas><br>
--<br>
Henry Minsky<br>
Software Architect<br>
<a href="mailto:hminsky@laszlosystems.com" target="_blank">hminsky@laszlosystems.com</a> <mailto:<a href="mailto:hminsky@laszlosystems.com" target="_blank">hminsky@laszlosystems.com</a>><br>
<br>
<br>
</blockquote>
--<br>
Regards,<br>
Max Carlson<br>
OpenLaszlo.org<br>
<br>
<br>
</blockquote>
<br>
<br>
</blockquote>
<br>
--<br>
Henry Minsky<br>
Software Architect<br>
<a href="mailto:hminsky@laszlosystems.com" target="_blank">hminsky@laszlosystems.com</a><br>
<br>
<br>
<br>
<br>
</blockquote>
<br>
--<br>
Henry Minsky<br>
Software Architect<br>
<a href="mailto:hminsky@laszlosystems.com" target="_blank">hminsky@laszlosystems.com</a><br>
<br>
</blockquote>
<br>
<br>
</blockquote>
<br>
<br>
-- <br>
Henry Minsky<br>
Software Architect<br>
<a href="mailto:hminsky@laszlosystems.com" target="_blank">hminsky@laszlosystems.com</a><br>
</blockquote>
<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Henry Minsky<br>Software Architect<br><a href="mailto:hminsky@laszlosystems.com">hminsky@laszlosystems.com</a><br><br><br>