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

darin darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:38:08 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit feb2010585a2bd79323a32ce4e1db90d08f598d7
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Apr 23 00:03:34 2003 +0000

            Reviewed by Maciej.
    
    	- fixed 3158411 -- radio button groups are per-form in WebCore, per-page in other browsers (flyglobespan.com)
    
            * khtml/html/html_formimpl.h: Removed radioClicked. Made setName virtual and make
            HTMLInputElementImpl override it. Added isCheckedRadioButtonForDocument,
            addCheckedRadioButtonToDocument, and removeCheckedRadioButtonFromDocument.
            * khtml/html/html_formimpl.cpp:
            (HTMLInputElementImpl::~HTMLInputElementImpl): Call removeCheckedRadioButtonFromDocument.
            (HTMLInputElementImpl::setType): Call removeCheckedRadioButtonFromDocument before changing
            the type and addCheckedRadioButtonToDocument after.
            (HTMLInputElementImpl::parseAttribute): Call removeCheckedRadioButtonFromDocument before changing
            ATTR_NAME and addCheckedRadioButtonToDocument after.
            (HTMLInputElementImpl::setChecked): Call removeCheckedRadioButtonFromDocument before changing
            the checked state and addCheckedRadioButtonToDocument after.
            (HTMLInputElementImpl::setName): Call removeCheckedRadioButtonFromDocument before changing
            the name and addCheckedRadioButtonToDocument after.
            (HTMLInputElementImpl::isCheckedRadioButtonForDocument): Added. Checks if this element should
            be the one known to the document.
            (HTMLInputElementImpl::addCheckedRadioButtonToDocument): Call addCheckedRadioButton on the
            document if isCheckedRadioButtonForDocument returns true.
            (HTMLInputElementImpl::removeCheckedRadioButtonFromDocument): Call
            removeCheckedRadioButtonFromDocument on the document if isCheckedRadioButtonForDocument
            returns true.
    
            * khtml/xml/dom_docimpl.h: Add addCheckedRadioButton, removeCheckedRadioButton, and
            m_checkedRadioButtons.
            * khtml/xml/dom_docimpl.cpp:
            (DocumentImpl::addCheckedRadioButton): Uncheck the old radio button with this name, if any.
            Store the new radio button in the "checked radio buttons" map.
            (DocumentImpl::removeCheckedRadioButton): Remove the radio button from the map.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4155 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index c337a6c..2950f5a 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,5 +1,45 @@
 2003-04-22  Darin Adler  <darin at apple.com>
 
+        Reviewed by Maciej.
+
+	- fixed 3158411 -- radio button groups are per-form in WebCore, per-page in other browsers (flyglobespan.com)
+
+        * khtml/html/html_formimpl.h: Removed radioClicked. Made setName virtual and make
+        HTMLInputElementImpl override it. Added isCheckedRadioButtonForDocument,
+        addCheckedRadioButtonToDocument, and removeCheckedRadioButtonFromDocument.
+        * khtml/html/html_formimpl.cpp:
+        (HTMLInputElementImpl::~HTMLInputElementImpl): Call removeCheckedRadioButtonFromDocument.
+        (HTMLInputElementImpl::setType): Call removeCheckedRadioButtonFromDocument before changing
+        the type and addCheckedRadioButtonToDocument after.
+        (HTMLInputElementImpl::parseAttribute): Call removeCheckedRadioButtonFromDocument before changing
+        ATTR_NAME and addCheckedRadioButtonToDocument after.
+        (HTMLInputElementImpl::setChecked): Call removeCheckedRadioButtonFromDocument before changing
+        the checked state and addCheckedRadioButtonToDocument after.
+        (HTMLInputElementImpl::setName): Call removeCheckedRadioButtonFromDocument before changing
+        the name and addCheckedRadioButtonToDocument after.
+        (HTMLInputElementImpl::isCheckedRadioButtonForDocument): Added. Checks if this element should
+        be the one known to the document.
+        (HTMLInputElementImpl::addCheckedRadioButtonToDocument): Call addCheckedRadioButton on the
+        document if isCheckedRadioButtonForDocument returns true.
+        (HTMLInputElementImpl::removeCheckedRadioButtonFromDocument): Call
+        removeCheckedRadioButtonFromDocument on the document if isCheckedRadioButtonForDocument
+        returns true.
+        
+        * khtml/xml/dom_docimpl.h: Add addCheckedRadioButton, removeCheckedRadioButton, and
+        m_checkedRadioButtons.
+        * khtml/xml/dom_docimpl.cpp:
+        (DocumentImpl::addCheckedRadioButton): Uncheck the old radio button with this name, if any.
+        Store the new radio button in the "checked radio buttons" map.
+        (DocumentImpl::removeCheckedRadioButton): Remove the radio button from the map.
+
+2003-04-22  Darin Adler  <darin at apple.com>
+
+        * khtml/html/html_formimpl.h: Remove radioClicked.
+        * khtml/html/html_formimpl.cpp: (HTMLInputElementImpl::setChecked): When unchecking other
+        input elements with the same name, traverse the entire document, not just the form.
+
+2003-04-22  Darin Adler  <darin at apple.com>
+
         Reviewed by John.
 
 	- fixed 3144966 -- problems typing in form at http://www.mobile.att.net/messagecenter
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index c337a6c..2950f5a 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,5 +1,45 @@
 2003-04-22  Darin Adler  <darin at apple.com>
 
+        Reviewed by Maciej.
+
+	- fixed 3158411 -- radio button groups are per-form in WebCore, per-page in other browsers (flyglobespan.com)
+
+        * khtml/html/html_formimpl.h: Removed radioClicked. Made setName virtual and make
+        HTMLInputElementImpl override it. Added isCheckedRadioButtonForDocument,
+        addCheckedRadioButtonToDocument, and removeCheckedRadioButtonFromDocument.
+        * khtml/html/html_formimpl.cpp:
+        (HTMLInputElementImpl::~HTMLInputElementImpl): Call removeCheckedRadioButtonFromDocument.
+        (HTMLInputElementImpl::setType): Call removeCheckedRadioButtonFromDocument before changing
+        the type and addCheckedRadioButtonToDocument after.
+        (HTMLInputElementImpl::parseAttribute): Call removeCheckedRadioButtonFromDocument before changing
+        ATTR_NAME and addCheckedRadioButtonToDocument after.
+        (HTMLInputElementImpl::setChecked): Call removeCheckedRadioButtonFromDocument before changing
+        the checked state and addCheckedRadioButtonToDocument after.
+        (HTMLInputElementImpl::setName): Call removeCheckedRadioButtonFromDocument before changing
+        the name and addCheckedRadioButtonToDocument after.
+        (HTMLInputElementImpl::isCheckedRadioButtonForDocument): Added. Checks if this element should
+        be the one known to the document.
+        (HTMLInputElementImpl::addCheckedRadioButtonToDocument): Call addCheckedRadioButton on the
+        document if isCheckedRadioButtonForDocument returns true.
+        (HTMLInputElementImpl::removeCheckedRadioButtonFromDocument): Call
+        removeCheckedRadioButtonFromDocument on the document if isCheckedRadioButtonForDocument
+        returns true.
+        
+        * khtml/xml/dom_docimpl.h: Add addCheckedRadioButton, removeCheckedRadioButton, and
+        m_checkedRadioButtons.
+        * khtml/xml/dom_docimpl.cpp:
+        (DocumentImpl::addCheckedRadioButton): Uncheck the old radio button with this name, if any.
+        Store the new radio button in the "checked radio buttons" map.
+        (DocumentImpl::removeCheckedRadioButton): Remove the radio button from the map.
+
+2003-04-22  Darin Adler  <darin at apple.com>
+
+        * khtml/html/html_formimpl.h: Remove radioClicked.
+        * khtml/html/html_formimpl.cpp: (HTMLInputElementImpl::setChecked): When unchecking other
+        input elements with the same name, traverse the entire document, not just the form.
+
+2003-04-22  Darin Adler  <darin at apple.com>
+
         Reviewed by John.
 
 	- fixed 3144966 -- problems typing in form at http://www.mobile.att.net/messagecenter
diff --git a/WebCore/khtml/html/html_formimpl.cpp b/WebCore/khtml/html/html_formimpl.cpp
index a170ab7..ea17c0a 100644
--- a/WebCore/khtml/html/html_formimpl.cpp
+++ b/WebCore/khtml/html/html_formimpl.cpp
@@ -663,18 +663,6 @@ void HTMLFormElementImpl::parseAttribute(AttributeImpl *attr)
     }
 }
 
-void HTMLFormElementImpl::radioClicked( HTMLGenericFormElementImpl *caller )
-{
-    for (QPtrListIterator<HTMLGenericFormElementImpl> it(formElements); it.current(); ++it) {
-        HTMLGenericFormElementImpl *current = it.current();
-        if (current->id() == ID_INPUT &&
-            static_cast<HTMLInputElementImpl*>(current)->inputType() == HTMLInputElementImpl::RADIO &&
-            current != caller && current->form() == caller->form() && current->name() == caller->name()) {
-            static_cast<HTMLInputElementImpl*>(current)->setChecked(false);
-        }
-    }
-}
-
 void HTMLFormElementImpl::registerFormElement(HTMLGenericFormElementImpl *e)
 {
     formElements.append(e);
@@ -1107,6 +1095,7 @@ HTMLInputElementImpl::HTMLInputElementImpl(DocumentPtr *doc, HTMLFormElementImpl
 
 HTMLInputElementImpl::~HTMLInputElementImpl()
 {
+    removeCheckedRadioButtonFromDocument();
     if (getDocument()) getDocument()->deregisterMaintainsState(this);
 }
 
@@ -1145,13 +1134,18 @@ void HTMLInputElementImpl::setType(const DOMString& t)
     // ### IMPORTANT: Don't allow the type to be changed to FILE after the first
     // type change, otherwise a JavaScript programmer would be able to set a text
     // field's value to something like /etc/passwd and then change it to a file field.
-    if (newType != FILE || !m_haveType) {
-        m_type = newType;
-        m_haveType = true;
-    }
-    else if (m_type != newType) {
-        setAttribute(ATTR_TYPE, type());
+    if (m_type != newType) {
+        if (newType == FILE && m_haveType) {
+            // Set the attribute back to the old value.
+            // Useful in case we were called from inside parseAttribute.
+            setAttribute(ATTR_TYPE, type());
+        } else {
+            removeCheckedRadioButtonFromDocument();
+            m_type = newType;
+            addCheckedRadioButtonToDocument();
+        }
     }
+    m_haveType = true;
 }
 
 DOMString HTMLInputElementImpl::type() const
@@ -1287,6 +1281,11 @@ void HTMLInputElementImpl::parseAttribute(AttributeImpl *attr)
         setHTMLEventListener(EventImpl::CHANGE_EVENT,
             getDocument()->createHTMLEventListener(attr->value().string()));
         break;
+    case ATTR_NAME:
+	removeCheckedRadioButtonFromDocument();
+        HTMLGenericFormElementImpl::parseAttribute(attr);
+	addCheckedRadioButtonToDocument();
+	break;
     default:
         HTMLGenericFormElementImpl::parseAttribute(attr);
     }
@@ -1579,11 +1578,10 @@ void HTMLInputElementImpl::reset()
 
 void HTMLInputElementImpl::setChecked(bool _checked)
 {
-    if (m_form && m_type == RADIO && _checked && !name().isEmpty())
-        m_form->radioClicked(this);
-
     if (m_checked == _checked) return;
+    removeCheckedRadioButtonFromDocument();
     m_checked = _checked;
+    addCheckedRadioButtonToDocument();
     setChanged();
 }
 
@@ -1668,6 +1666,30 @@ bool HTMLInputElementImpl::isEditable()
     return ((m_type == TEXT) || (m_type == PASSWORD) || (m_type == ISINDEX) || (m_type == FILE));
 }
 
+void HTMLInputElementImpl::setName(const DOMString& name)
+{
+    removeCheckedRadioButtonFromDocument();
+    HTMLGenericFormElementImpl::setName(name);
+    addCheckedRadioButtonToDocument();
+}
+
+bool HTMLInputElementImpl::isCheckedRadioButtonForDocument() const
+{
+    return m_checked && m_type == RADIO && !name().isEmpty() && getDocument();
+}
+
+void HTMLInputElementImpl::addCheckedRadioButtonToDocument()
+{
+    if (isCheckedRadioButtonForDocument())
+        getDocument()->addCheckedRadioButton(this);
+}
+
+void HTMLInputElementImpl::removeCheckedRadioButtonFromDocument()
+{
+    if (isCheckedRadioButtonForDocument())
+        getDocument()->removeCheckedRadioButton(this);
+}
+
 // -------------------------------------------------------------------------
 
 HTMLLabelElementImpl::HTMLLabelElementImpl(DocumentPtr *doc)
diff --git a/WebCore/khtml/html/html_formimpl.h b/WebCore/khtml/html/html_formimpl.h
index 674736f..557303a 100644
--- a/WebCore/khtml/html/html_formimpl.h
+++ b/WebCore/khtml/html/html_formimpl.h
@@ -82,8 +82,6 @@ public:
 
     virtual void parseAttribute(AttributeImpl *attr);
 
-    void radioClicked( HTMLGenericFormElementImpl *caller );
-
     void registerFormElement(khtml::RenderFormElement *);
     void removeFormElement(khtml::RenderFormElement *);
 
@@ -158,7 +156,7 @@ public:
     virtual void recalcStyle( StyleChange );
 
     DOMString name() const;
-    void setName(const DOMString& name);
+    virtual void setName(const DOMString& name);
 
     virtual bool isGenericFormElement() const { return true; }
 
@@ -293,6 +291,7 @@ public:
     void click();
 
     virtual void parseAttribute(AttributeImpl *attr);
+    virtual void setName(const DOMString& name);
 
     virtual void init();
     virtual void attach();
@@ -329,6 +328,12 @@ protected:
     bool m_haveType : 1;
     bool m_activeSubmit : 1;
     bool m_autocomplete : 1;
+
+private:
+
+    bool isCheckedRadioButtonForDocument() const;
+    void addCheckedRadioButtonToDocument();
+    void removeCheckedRadioButtonFromDocument();
 };
 
 // -------------------------------------------------------------------------
diff --git a/WebCore/khtml/xml/dom_docimpl.cpp b/WebCore/khtml/xml/dom_docimpl.cpp
index 1b67747..dd569f7 100644
--- a/WebCore/khtml/xml/dom_docimpl.cpp
+++ b/WebCore/khtml/xml/dom_docimpl.cpp
@@ -2219,6 +2219,28 @@ void DocumentImpl::timerEvent(QTimerEvent *)
     dispatchImageLoadEventsNow();
 }
 
+void DocumentImpl::addCheckedRadioButton(HTMLInputElementImpl *b)
+{
+    QString name = b->name().string();
+    
+    // Uncheck the old checked radio button.
+    QMap<QString, HTMLInputElementImpl *>::ConstIterator i = m_checkedRadioButtons.find(name);
+    if (i != m_checkedRadioButtons.end()) {
+        assert(i.data() != b);
+        i.data()->setChecked(false);
+        assert(m_checkedRadioButtons.find(name) == m_checkedRadioButtons.end());
+    }
+    
+    m_checkedRadioButtons.insert(name, b);
+}
+
+void DocumentImpl::removeCheckedRadioButton(HTMLInputElementImpl *b)
+{
+    QString name = b->name().string();
+    assert(m_checkedRadioButtons[name] == b);
+    m_checkedRadioButtons.remove(name);
+}
+
 #if APPLE_CHANGES
 
 QString DocumentImpl::completeURL(const QString &URL)
diff --git a/WebCore/khtml/xml/dom_docimpl.h b/WebCore/khtml/xml/dom_docimpl.h
index 686c6d0..1414cbe 100644
--- a/WebCore/khtml/xml/dom_docimpl.h
+++ b/WebCore/khtml/xml/dom_docimpl.h
@@ -76,6 +76,7 @@ namespace DOM {
     class GenericRONamedNodeMapImpl;
     class HTMLDocumentImpl;
     class HTMLElementImpl;
+    class HTMLInputElementImpl;
     class NodeFilter;
     class NodeFilterImpl;
     class NodeIteratorImpl;
@@ -429,6 +430,9 @@ public:
     void dispatchImageLoadEventsNow();
     void removeImage(khtml::RenderImage *);
     virtual void timerEvent(QTimerEvent *);
+    
+    void addCheckedRadioButton(HTMLInputElementImpl *);
+    void removeCheckedRadioButton(HTMLInputElementImpl *);
 
 signals:
     void finishedParsing();
@@ -509,6 +513,8 @@ protected:
     QPtrList<khtml::RenderImage> m_imageLoadEventDispatchingList;
     int m_imageLoadEventTimer;
 
+    QMap<QString, HTMLInputElementImpl *> m_checkedRadioButtons;
+
     NodeImpl* m_cssTarget;
     
 #if APPLE_CHANGES

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list