[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

hyatt hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:43:41 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 7059d939be412954346727276ceb0288a99aac19
Author: hyatt <hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri May 30 23:21:53 2003 +0000

    	Fix for 3269129 and 3269220.  setAttribute('value') didn't work
    	for inputs.  Basically defaultValue and defaultChecked have never
    	worked.  This patch fixes the problem by making sure that for both
    	value and checked you have a two-tier system where you look first
    	for the value as altered by the control (or by setting the DOM
    	property) and if that isn't set then you look at the default value.
    
    	This allows setAttribute (which changes the *default*) to work in
    	the cases where the control has not overridden the default
    	with a different value.
    
            Reviewed by NOBODY (OOPS!).
    
            * khtml/html/html_formimpl.cpp:
            (HTMLInputElementImpl::HTMLInputElementImpl):
            (HTMLInputElementImpl::state):
            (HTMLInputElementImpl::parseAttribute):
            (HTMLInputElementImpl::attach):
            (HTMLInputElementImpl::reset):
            (HTMLInputElementImpl::setChecked):
            (HTMLInputElementImpl::value):
            (HTMLInputElementImpl::setValue):
            (HTMLInputElementImpl::isCheckedRadioButtonForDocument):
            * khtml/html/html_formimpl.h:
            * khtml/rendering/render_form.cpp:
            (RenderLineEdit::RenderLineEdit):
            (RenderLineEdit::calcMinMaxWidth):
            (RenderLineEdit::updateFromElement):
            (RenderLineEdit::slotTextChanged):
            * khtml/rendering/render_form.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4457 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index cc66d6e..b183709 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,36 @@
+2003-05-30  David Hyatt  <hyatt at apple.com>
+
+	Fix for 3269129 and 3269220.  setAttribute('value') didn't work
+	for inputs.  Basically defaultValue and defaultChecked have never
+	worked.  This patch fixes the problem by making sure that for both
+	value and checked you have a two-tier system where you look first
+	for the value as altered by the control (or by setting the DOM
+	property) and if that isn't set then you look at the default value.
+
+	This allows setAttribute (which changes the *default*) to work in
+	the cases where the control has not overridden the default 
+	with a different value.
+	
+        Reviewed by NOBODY (OOPS!).
+
+        * khtml/html/html_formimpl.cpp:
+        (HTMLInputElementImpl::HTMLInputElementImpl):
+        (HTMLInputElementImpl::state):
+        (HTMLInputElementImpl::parseAttribute):
+        (HTMLInputElementImpl::attach):
+        (HTMLInputElementImpl::reset):
+        (HTMLInputElementImpl::setChecked):
+        (HTMLInputElementImpl::value):
+        (HTMLInputElementImpl::setValue):
+        (HTMLInputElementImpl::isCheckedRadioButtonForDocument):
+        * khtml/html/html_formimpl.h:
+        * khtml/rendering/render_form.cpp:
+        (RenderLineEdit::RenderLineEdit):
+        (RenderLineEdit::calcMinMaxWidth):
+        (RenderLineEdit::updateFromElement):
+        (RenderLineEdit::slotTextChanged):
+        * khtml/rendering/render_form.h:
+
 2003-05-30  Darin Adler  <darin at apple.com>
 
         Reviewed by John.
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index cc66d6e..b183709 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,36 @@
+2003-05-30  David Hyatt  <hyatt at apple.com>
+
+	Fix for 3269129 and 3269220.  setAttribute('value') didn't work
+	for inputs.  Basically defaultValue and defaultChecked have never
+	worked.  This patch fixes the problem by making sure that for both
+	value and checked you have a two-tier system where you look first
+	for the value as altered by the control (or by setting the DOM
+	property) and if that isn't set then you look at the default value.
+
+	This allows setAttribute (which changes the *default*) to work in
+	the cases where the control has not overridden the default 
+	with a different value.
+	
+        Reviewed by NOBODY (OOPS!).
+
+        * khtml/html/html_formimpl.cpp:
+        (HTMLInputElementImpl::HTMLInputElementImpl):
+        (HTMLInputElementImpl::state):
+        (HTMLInputElementImpl::parseAttribute):
+        (HTMLInputElementImpl::attach):
+        (HTMLInputElementImpl::reset):
+        (HTMLInputElementImpl::setChecked):
+        (HTMLInputElementImpl::value):
+        (HTMLInputElementImpl::setValue):
+        (HTMLInputElementImpl::isCheckedRadioButtonForDocument):
+        * khtml/html/html_formimpl.h:
+        * khtml/rendering/render_form.cpp:
+        (RenderLineEdit::RenderLineEdit):
+        (RenderLineEdit::calcMinMaxWidth):
+        (RenderLineEdit::updateFromElement):
+        (RenderLineEdit::slotTextChanged):
+        * khtml/rendering/render_form.h:
+
 2003-05-30  Darin Adler  <darin at apple.com>
 
         Reviewed by John.
diff --git a/WebCore/khtml/html/html_formimpl.cpp b/WebCore/khtml/html/html_formimpl.cpp
index 651616a..aaced6f 100644
--- a/WebCore/khtml/html/html_formimpl.cpp
+++ b/WebCore/khtml/html/html_formimpl.cpp
@@ -1067,7 +1067,9 @@ HTMLInputElementImpl::HTMLInputElementImpl(DocumentPtr *doc, HTMLFormElementImpl
     m_maxLen = -1;
     m_size = 20;
     m_checked = false;
-
+    m_defaultChecked = false;
+    m_useDefaultChecked = true;
+    
     m_haveType = false;
     m_activeSubmit = false;
     m_autocomplete = true;
@@ -1161,7 +1163,7 @@ QString HTMLInputElementImpl::state( )
     switch (m_type) {
     case CHECKBOX:
     case RADIO:
-        return state + (m_checked ? "on" : "off");
+        return state + (checked() ? "on" : "off");
     default:
         return state + value().string()+'.'; // Make sure the string is not empty!
     }
@@ -1214,8 +1216,13 @@ void HTMLInputElementImpl::parseAttribute(AttributeImpl *attr)
         setType(attr->value());
         break;
     case ATTR_VALUE:
+        if (m_value.isNull()) // We only need to setChanged if the form is looking
+            setChanged();     // at the default value right now.
+        break;
     case ATTR_CHECKED:
-        // these are the defaults, don't change them
+        m_defaultChecked = attr->val();
+        if (m_useDefaultChecked) // We only need to setChanged if the form is looking
+            setChanged();        // at the default checked state right now.
         break;
     case ATTR_MAXLENGTH:
         m_maxLen = attr->val() ? attr->val()->toInt() : -1;
@@ -1324,19 +1331,22 @@ void HTMLInputElementImpl::attach()
         if (!m_haveType)
             setType(getAttribute(ATTR_TYPE));
 
-        if (m_type != FILE) m_value = getAttribute(ATTR_VALUE);
-        if ((uint) m_type <= ISINDEX && !m_value.isEmpty()) {
-            QString value = m_value.string();
+        // FIXME: This needs to be dynamic, doesn't it, since someone could set this
+        // after attachment?
+        DOMString val = getAttribute(ATTR_VALUE);
+        if ((uint) m_type <= ISINDEX && !val.isEmpty()) {
             // remove newline stuff..
             QString nvalue;
-            for (unsigned int i = 0; i < value.length(); ++i)
-                if (value[i] >= ' ')
-                    nvalue += value[i];
-            m_value = nvalue;
+            for (unsigned int i = 0; i < val.length(); ++i)
+                if (val[i] >= ' ')
+                    nvalue += val[i];
+
+            if (val.length() != nvalue.length())
+                setAttribute(ATTR_VALUE, nvalue);
         }
 
         removeCheckedRadioButtonFromDocument();
-        m_checked = (getAttribute(ATTR_CHECKED) != 0);
+        m_defaultChecked = (getAttribute(ATTR_CHECKED) != 0);
         addCheckedRadioButtonToDocument();
 
         m_inited = true;
@@ -1563,14 +1573,16 @@ bool HTMLInputElementImpl::encoding(const QTextCodec* codec, khtml::encodingList
 
 void HTMLInputElementImpl::reset()
 {
-    setValue(getAttribute(ATTR_VALUE));
-    setChecked(getAttribute(ATTR_CHECKED) != 0);
+    setValue(DOMString());
+    m_useDefaultChecked = true;
+    m_checked = m_defaultChecked;
 }
 
 void HTMLInputElementImpl::setChecked(bool _checked)
 {
-    if (m_checked == _checked) return;
+    if (checked() == _checked) return;
     removeCheckedRadioButtonFromDocument();
+    m_useDefaultChecked = false;
     m_checked = _checked;
     addCheckedRadioButtonToDocument();
     setChanged();
@@ -1580,14 +1592,14 @@ void HTMLInputElementImpl::setChecked(bool _checked)
 DOMString HTMLInputElementImpl::value() const
 {
     if ((m_type == CHECKBOX || m_type == RADIO) && m_value.isNull()) {
-        if (m_checked)
+        if (checked())
             return DOMString("on");
         else
             return DOMString("");
     }
 
-    if(m_value.isNull())
-        return DOMString(""); // some JS sites obviously need this
+    if (m_value.isNull())
+        return getAttribute(ATTR_VALUE);
     return m_value;
 }
 
@@ -1596,7 +1608,7 @@ void HTMLInputElementImpl::setValue(DOMString val)
 {
     if (m_type == FILE) return;
 
-    m_value = (val.isNull() ? DOMString("") : val);
+    m_value = val;
     setChanged();
 }
 
@@ -1666,7 +1678,7 @@ void HTMLInputElementImpl::setName(const DOMString& name)
 
 bool HTMLInputElementImpl::isCheckedRadioButtonForDocument() const
 {
-    return m_checked && m_type == RADIO && !name().isEmpty() && getDocument();
+    return checked() && m_type == RADIO && !name().isEmpty() && getDocument();
 }
 
 void HTMLInputElementImpl::addCheckedRadioButtonToDocument()
diff --git a/WebCore/khtml/html/html_formimpl.h b/WebCore/khtml/html/html_formimpl.h
index 85b1b58..bf50530 100644
--- a/WebCore/khtml/html/html_formimpl.h
+++ b/WebCore/khtml/html/html_formimpl.h
@@ -271,7 +271,7 @@ public:
 
     bool autoComplete() const { return m_autocomplete; }
 
-    bool checked() const { return m_checked; }
+    bool checked() const { return m_useDefaultChecked ? m_defaultChecked : m_checked; }
     void setChecked(bool);
     long maxLength() const { return m_maxLen; }
     int size() const { return m_size; }
@@ -325,6 +325,8 @@ protected:
 
     typeEnum m_type : 4;
     bool m_checked : 1;
+    bool m_defaultChecked : 1;
+    bool m_useDefaultChecked : 1;
     bool m_haveType : 1;
     bool m_activeSubmit : 1;
     bool m_autocomplete : 1;
diff --git a/WebCore/khtml/rendering/render_form.cpp b/WebCore/khtml/rendering/render_form.cpp
index c2a5b7f..bbd5154 100644
--- a/WebCore/khtml/rendering/render_form.cpp
+++ b/WebCore/khtml/rendering/render_form.cpp
@@ -459,7 +459,7 @@ bool LineEditWidget::event( QEvent *e )
 // -----------------------------------------------------------------------------
 
 RenderLineEdit::RenderLineEdit(HTMLInputElementImpl *element)
-    : RenderFormElement(element)
+    : RenderFormElement(element), m_updating(false)
 {
     LineEditWidget *edit = new LineEditWidget(view()->viewport());
     connect(edit,SIGNAL(returnPressed()), this, SLOT(slotReturnPressed()));
@@ -513,8 +513,10 @@ void RenderLineEdit::calcMinMaxWidth()
 
 #if APPLE_CHANGES
     // Let the widget tell us how big it wants to be.
+    m_updating = true;
     int size = element()->size();
     QSize s(widget()->sizeForCharacterWidth(size > 0 ? size : 20));
+    m_updating = false;
 #else
     const QFontMetrics &fm = style()->fontMetrics();
     QSize s;
@@ -547,8 +549,11 @@ void RenderLineEdit::updateFromElement()
     if (element()->value().string() != w->text()) {
         w->blockSignals(true);
         int pos = w->cursorPosition();
-        w->setText(element()->value().string());
 
+        m_updating = true;
+        w->setText(element()->value().string());
+        m_updating = false;
+        
         w->setEdited( false );
 
         w->setCursorPosition(pos);
@@ -564,6 +569,8 @@ void RenderLineEdit::updateFromElement()
 void RenderLineEdit::slotTextChanged(const QString &string)
 {
     // don't use setValue here!
+    if (m_updating) // Don't alter m_value if we are in the middle of initing the control, since
+        return;     // we may have gotten our initial value from the attribute.
     element()->m_value = string;
 }
 
diff --git a/WebCore/khtml/rendering/render_form.h b/WebCore/khtml/rendering/render_form.h
index 97319b3..c673bd3 100644
--- a/WebCore/khtml/rendering/render_form.h
+++ b/WebCore/khtml/rendering/render_form.h
@@ -263,6 +263,8 @@ protected:
 
 private:
     virtual bool isEditable() const { return true; }
+
+    bool m_updating;
 };
 
 // -------------------------------------------------------------------------

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list