Bug 49828 - <textarea> looses its content when have applied style (testcase)
Summary: <textarea> looses its content when have applied style (testcase)
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: khtml (show other bugs)
Version: unspecified
Platform: Unlisted Binaries Linux
: NOR major
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-10-28 14:43 UTC by Dimiter Stoyanov
Modified: 2004-09-07 12:14 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
A simple test case (627 bytes, text/html)
2004-07-16 14:59 UTC, Klaus S. Madsen
Details
hacky fix (2.12 KB, patch)
2004-08-24 23:22 UTC, Leo Savernik
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dimiter Stoyanov 2002-10-28 14:43:02 UTC
Version:            (using KDE KDE 3.0.1)
Installed from:    Unspecified Linux

If for some table which contains textarea set style with display:none and after that change the display to block the content of the textarea is missing

So here is the code:
========================================
<style>
   .myStyle{
      display:none;
   }
</style>
<table cellsapcing=0 cellpadding=0 border=1 class=myStyle id=myTable>
   <tr>
      <td><textarea name=textarea>Here is the content of the textarea</textarea></td>
   </tr>
</table>
<script>
   document.all.myTable.style.display = "block";
</script>
=======================================

So as you can see there is some text in textarea but when open this in Konqueror the content is missing
Comment 1 giaracca 2002-11-15 14:22:53 UTC
I have prepared a little test for this bug. 
I'm using kde-3.0.8 from gentoo. 
http://www.preciso.net/~gianpaolo/bugs/textarea.html 
I think the content is loose only when initial display is set to none 
 
Comment 2 Moritz Moeller-Herrmann 2002-12-22 23:13:24 UTC
Still present in KDE-3.1 (Dec 20) 
Comment 3 giaracca 2003-07-27 15:53:29 UTC
still present in kde 3.1.2 (27 jul ) 
Comment 4 Sashmit Bhaduri 2003-09-28 08:44:56 UTC
Looks like it's been fixed in KDE 3.2a2. The text displays fine.  
Comment 5 Stephan Kulow 2003-11-01 11:03:22 UTC
I can't reproduce a problem with KDE CVS either
Comment 6 giaracca 2004-04-06 17:54:25 UTC
If you try my test case you will see that after 2 display switch the text in textarea element disappear. The test is here:
http://www.preciso.net/~gianpaolo/bugs/textarea.html
Comment 7 kosh 2004-06-18 22:31:37 UTC
in KDE 3.2.2 it is still broken here. The link that gianpaolo gave (http://www.preciso.net/~gianpaolo/bugs/textarea.html) still breaks in konqueror when toggle visibility is clicked more then once. It displays the first time for me and then the textarea is blank after that.   
Comment 8 Klaus S. Madsen 2004-07-16 14:59:51 UTC
Created attachment 6700 [details]
A simple test case

This attatchment is a very simple test-case of this bug. When the "Hide/Unhide
textarea" is clicked, the textarea is hidden, and when the link is clicked
again, the text disappears.

I'm using KDE 3.2.2 from Gentoo (which should be newer than the 3.2a2, where
the bug could not be reproduced).
Comment 9 Klaus S. Madsen 2004-07-22 10:22:48 UTC
Any chance of getting this bug reopened, or should I post a new bug?
Comment 10 Klaus S. Madsen 2004-08-03 16:53:18 UTC
This bug is also present in KDE 3.3beta2 from gentoo.
Comment 11 Stephan Kulow 2004-08-04 10:37:58 UTC
you're right, the bug was closed too soon
Comment 12 Leo Savernik 2004-08-24 20:40:51 UTC
This is a dataloss bug -> major.
Comment 13 Leo Savernik 2004-08-24 23:22:34 UTC
Created attachment 7257 [details]
hacky fix

This patch fixes the bug in relying on the flaky behaviour that QTextEdit
always emits a textChanged signal just after begin constructed.
Comment 14 Leo Savernik 2004-09-02 11:51:39 UTC
CVS commit by savernik: 

Fixed spurious deletion of textarea contents. Original patch by me, improved patch
by Germain Garand.

CCMAIL: 49828-done@bugs.kde.org, 48879-done@bugs.kde.org, 86916-done@bugs.kde.org


  M +12 -0     ChangeLog   1.283
  M +7 -3      html/html_formimpl.cpp   1.383
  M +4 -3      html/html_formimpl.h   1.155
  M +3 -1      rendering/render_form.cpp   1.271


--- kdelibs/khtml/html/html_formimpl.cpp  #1.382:1.383
@@ -2204,4 +2204,5 @@ HTMLTextAreaElementImpl::HTMLTextAreaEle
     m_wrap = ta_Virtual;
     m_dirtyvalue = true;
+    m_initialized = false;
     m_unsubmittedFormChange = false;
 }
@@ -2313,8 +2314,10 @@ DOMString HTMLTextAreaElementImpl::value
 {
     if ( m_dirtyvalue) {
-        if ( m_render )
+        if ( m_render && m_initialized )
             m_value = static_cast<RenderTextArea*>( m_render )->text();
-        else
+        else {
             m_value = defaultValue().string();
+            m_initialized = true;
+        }
 
         m_dirtyvalue = false;
@@ -2332,4 +2335,5 @@ void HTMLTextAreaElementImpl::setValue(D
     m_value = str.replace( '\r', '\n' );
     m_dirtyvalue = false;
+    m_initialized = true;
     setChanged(true);
 }

--- kdelibs/khtml/html/html_formimpl.h  #1.154:1.155
@@ -537,6 +537,7 @@ protected:
     WrapMethod m_wrap;
     QString m_value;
-    bool m_dirtyvalue;
-    bool m_unsubmittedFormChange;
+    bool m_dirtyvalue: 1;
+    bool m_unsubmittedFormChange: 1;
+    bool m_initialized: 1;
 };
 

--- kdelibs/khtml/rendering/render_form.cpp  #1.270:1.271
@@ -1587,6 +1587,8 @@ void RenderTextArea::setStyle(RenderStyl
     RenderFormElement::setStyle(_style);
 
+    widget()->blockSignals(true);
     widget()->setAlignment( _style->direction() == RTL ?
                             Qt::AlignRight : Qt::AlignLeft );
+    widget()->blockSignals(false);
 
     scrollbarsStyled = false;

--- kdelibs/khtml/ChangeLog  #1.282:1.283
@@ -1,2 +1,14 @@
+2004-09-02  Leo Savernik  <l.savernik@aon.at>
+
+        * html_formimpl.{cpp,h} (HTMLTextAreaElementImpl::value):
+        Only take text from RenderTextArea when it has been fully initialized.
+        Mark it fully initialized when RenderTextArea has been initialized
+        from the DOM.
+        (HTMLTextAreaElementImpl::setValue): Mark element as initialized after
+        setting. 
+        * render_form.cpp (RenderTextArea::setStyle):
+        Block signals on call to QTextEdit::setAlignment. Otherwise, a bogus
+        textChanged signal is emitted. 
+
 2004-08-27  Germain Garand  <germain@ebooksfrance.org>
         


Comment 15 Leo Savernik 2004-09-07 12:14:53 UTC
CVS commit by savernik: 

Backport: Fixed spurious deletion of textarea contents.

CCMAIL: 49828@bugs.kde.org, 48879@bugs.kde.org, 86916@bugs.kde.org


  M +7 -3      html/html_formimpl.cpp   1.380.2.2
  M +4 -3      html/html_formimpl.h   1.154.2.1
  M +3 -1      rendering/render_form.cpp   1.269.2.2


--- kdelibs/khtml/html/html_formimpl.cpp  #1.380.2.1:1.380.2.2
@@ -2204,4 +2204,5 @@ HTMLTextAreaElementImpl::HTMLTextAreaEle
     m_wrap = ta_Virtual;
     m_dirtyvalue = true;
+    m_initialized = false;
     m_unsubmittedFormChange = false;
 }
@@ -2313,8 +2314,10 @@ DOMString HTMLTextAreaElementImpl::value
 {
     if ( m_dirtyvalue) {
-        if ( m_render )
+        if ( m_render && m_initialized )
             m_value = static_cast<RenderTextArea*>( m_render )->text();
-        else
+        else {
             m_value = defaultValue().string();
+            m_initialized = true;
+        }
 
         m_dirtyvalue = false;
@@ -2332,4 +2335,5 @@ void HTMLTextAreaElementImpl::setValue(D
     m_value = str.replace( '\r', '\n' );
     m_dirtyvalue = false;
+    m_initialized = true;
     setChanged(true);
 }

--- kdelibs/khtml/html/html_formimpl.h  #1.154:1.154.2.1
@@ -537,6 +537,7 @@ protected:
     WrapMethod m_wrap;
     QString m_value;
-    bool m_dirtyvalue;
-    bool m_unsubmittedFormChange;
+    bool m_dirtyvalue: 1;
+    bool m_unsubmittedFormChange: 1;
+    bool m_initialized: 1;
 };
 

--- kdelibs/khtml/rendering/render_form.cpp  #1.269.2.1:1.269.2.2
@@ -1587,6 +1587,8 @@ void RenderTextArea::setStyle(RenderStyl
     RenderFormElement::setStyle(_style);
 
+    widget()->blockSignals(true);
     widget()->setAlignment( _style->direction() == RTL ?
                             Qt::AlignRight : Qt::AlignLeft );
+    widget()->blockSignals(false);
 
     scrollbarsStyled = false;