Bug 48879 - (testcase) value of textarea not shown after insert by dom functions
Summary: (testcase) value of textarea not shown after insert by dom functions
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: khtml forms (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-10-08 17:02 UTC by T Zachmann
Modified: 2004-09-07 12:14 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Test case 1 (622 bytes, text/html)
2004-02-11 22:42 UTC, Luis Carvalho
Details
Test case 2 (604 bytes, text/html)
2004-02-11 22:47 UTC, Luis Carvalho
Details

Note You need to log in before you can comment on or make changes to this bug.
Description T Zachmann 2002-10-08 17:02:52 UTC
Version:            (using KDE KDE 3.0.3)
Installed from:    SuSE RPMs
OS:          Linux

Hello all

Have a look at the script at the end of the report. I create a input tag by the dom functions. The value of the input tag get not shown. In the Tool "Show DOM tree" the attribute is shown. This is also a problem on input type="text".

Thorsten Zachmann

---------------------
<html>
<head>
<script>

function start() {
  input = document.createElement( "input" );
  input.setAttribute("name", "new");
  input.setAttribute("value", "hugo" );
  input.setAttribute("type", "button" );
  //input.setAttribute("type", "text" );
  node = document.createElement( "form" );
  node.appendChild( input ) ;
  document.body.appendChild( node );
}

</script>
</head>
<body>
<form name="Formular">
<input type="button" value="Start" onClick="start()"><br>
</body>
</html>
Comment 1 T Zachmann 2002-10-09 08:43:51 UTC
Nearly the same problem exists for textarea. The text in the textarea is not shown. It is shown however in the DOM tree.  Thorsten   <html> <head> <script>  function start() {   text = document.createTextNode( "Hallo das ist die Vorbelegung" );   input = document.createElement( "textarea" );   input.setAttribute("name", "new");   input.appendChild( text );    node = document.createElement( "form" );   node.appendChild( input ) ;   document.body.appendChild( node ); }  </script> </head> <body> <form name="Formular"> <input type="button" value="Start" onClick="start()"><br> </body> </html>  
Comment 2 David Faure 2002-10-28 17:21:04 UTC
The testcase in the initial report works now, with the current Konqueror (CVS,     
soon 3.1-rc1). I see a button with "hugo" on it when pressing Start.     
     
The testcase in the comment still doesn't work though, the textarea doesn't get the     
text, indeed. KHTML bug (I think in HTMLTextAreaElementImpl but I'm not sure 
where), reassigning to khtml. 
    
     
Comment 3 Luis Carvalho 2004-02-11 22:42:52 UTC
Created attachment 4647 [details]
Test case 1

First testcase of this bug report
Comment 4 Luis Carvalho 2004-02-11 22:47:46 UTC
Created attachment 4648 [details]
Test case 2

Second test case specified in the bug report.
Comment 5 Leo Savernik 2004-08-26 12:36:21 UTC
The patch for bug 86916 fixes this one, too.
Comment 6 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 7 Leo Savernik 2004-09-07 12:14:52 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;