[webkit-changes] cvs commit: WebCore/khtml/xml dom_docimpl.cpp

Adele adele at opensource.apple.com
Thu Dec 22 15:06:22 PST 2005


adele       05/12/22 15:06:22

  Modified:    .        ChangeLog
               .        ChangeLog
               khtml/html html_formimpl.cpp html_formimpl.h
               khtml/xml dom_docimpl.cpp
  Added:       fast/forms radio_checked_dynamic-expected.checksum
                        radio_checked_dynamic-expected.png
                        radio_checked_dynamic-expected.txt
                        radio_checked_dynamic.html
  Log:
  LayoutTests:
  
          Reviewed by Tim Hatcher.
  
          Tests for <rdar://problem/4387433> Seed: Radio buttons behave incorrectly in Gmail settings
  
          * fast/forms/radio_checked_dynamic-expected.checksum: Added.
          * fast/forms/radio_checked_dynamic-expected.png: Added.
          * fast/forms/radio_checked_dynamic-expected.txt: Added.
          * fast/forms/radio_checked_dynamic.html: Added.
  
  WebCore:
  
          Reviewed by Tim Hatcher.
  
          Fixed <rdar://problem/4387433> Seed: Radio buttons behave incorrectly in Gmail settings
  
          * khtml/html/html_formimpl.cpp:
          (DOM::HTMLFormElementImpl::registerFormElement): update radio button hash map when moving form elements around.
          (DOM::HTMLGenericFormElementImpl::insertedIntoTree): ditto.
          * khtml/html/html_formimpl.h:
          (DOM::HTMLGenericFormElementImpl::isRadioButton): Added.
          (DOM::HTMLInputElementImpl::isRadioButton): Added.
          * khtml/xml/dom_docimpl.cpp:
          (DocumentImpl::radioButtonChecked):
          Added comment explaining that we use 1 for the default form.  We can't use a null pointer as a key for the hash map.
          (DocumentImpl::checkedRadioButtonForGroup): Added conversion of null form pointer to 1.
          (DocumentImpl::removeRadioButtonGroup): ditto.
  
  Revision  Changes    Path
  1.181     +11 -0     LayoutTests/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/LayoutTests/ChangeLog,v
  retrieving revision 1.180
  retrieving revision 1.181
  diff -u -r1.180 -r1.181
  --- ChangeLog	22 Dec 2005 16:50:08 -0000	1.180
  +++ ChangeLog	22 Dec 2005 23:06:18 -0000	1.181
  @@ -1,3 +1,14 @@
  +2005-12-22  Adele Peterson  <adele at apple.com>
  +
  +        Reviewed by Tim Hatcher.
  +
  +        Tests for <rdar://problem/4387433> Seed: Radio buttons behave incorrectly in Gmail settings
  +
  +        * fast/forms/radio_checked_dynamic-expected.checksum: Added.
  +        * fast/forms/radio_checked_dynamic-expected.png: Added.
  +        * fast/forms/radio_checked_dynamic-expected.txt: Added.
  +        * fast/forms/radio_checked_dynamic.html: Added.
  +
   2005-12-22  Darin Adler  <darin at apple.com>
   
           Reviewed by Eric.
  
  
  
  1.1                  LayoutTests/fast/forms/radio_checked_dynamic-expected.checksum
  
  Index: radio_checked_dynamic-expected.checksum
  ===================================================================
  aadc3eb64586e2ff3380176d29ee3a46
  
  
  1.1                  LayoutTests/fast/forms/radio_checked_dynamic-expected.png
  
  	<<Binary file>>
  
  
  1.1                  LayoutTests/fast/forms/radio_checked_dynamic-expected.txt
  
  Index: radio_checked_dynamic-expected.txt
  ===================================================================
  layer at (0,0) size 800x600
    RenderCanvas at (0,0) size 800x600
  layer at (0,0) size 800x600
    RenderBlock {HTML} at (0,0) size 800x600
      RenderBody {BODY} at (8,8) size 784x584
        RenderBlock (anonymous) at (0,0) size 784x54
          RenderText {TEXT} at (0,0) size 779x36
            text run at (0,0) width 779: "This will test that radio buttons can be moved in and out of forms while maintaining only one checked button per group, per"
            text run at (0,18) width 38: "form. "
          RenderBR {BR} at (0,0) size 0x0
          RenderText {TEXT} at (0,36) size 346x18
            text run at (0,36) width 346: "Test 1: Transfer radio buttons from <body> to <form>:"
          RenderText {TEXT} at (0,0) size 0x0
          RenderText {TEXT} at (0,0) size 0x0
        RenderBlock {FORM} at (0,54) size 784x19
          RenderBlock {INPUT} at (3,3) size 12x13
          RenderBlock {INPUT} at (21,3) size 12x13
        RenderBlock {DIV} at (0,89) size 784x18
          RenderText {TEXT} at (0,0) size 91x18
            text run at (0,0) width 91: "Test 1 Passed"
        RenderBlock (anonymous) at (0,107) size 784x36
          RenderBR {BR} at (0,0) size 0x18
          RenderText {TEXT} at (0,18) size 346x18
            text run at (0,18) width 346: "Test 2: Transfer radio buttons from <form> to <body>:"
        RenderBlock {FORM} at (0,143) size 784x0
          RenderText {TEXT} at (0,0) size 0x0
          RenderText {TEXT} at (0,0) size 0x0
        RenderBlock {DIV} at (0,159) size 784x18
          RenderText {TEXT} at (0,0) size 91x18
            text run at (0,0) width 91: "Test 2 Passed"
        RenderBlock (anonymous) at (0,177) size 784x36
          RenderBR {BR} at (0,0) size 0x18
          RenderText {TEXT} at (0,18) size 563x18
            text run at (0,18) width 563: "Test 3: Transfer radio buttons from <form> to <body> with a dormant state in the middle:"
        RenderBlock {FORM} at (0,213) size 784x0
          RenderText {TEXT} at (0,0) size 0x0
          RenderText {TEXT} at (0,0) size 0x0
        RenderBlock {DIV} at (0,229) size 784x18
          RenderText {TEXT} at (0,0) size 91x18
            text run at (0,0) width 91: "Test 3 Passed"
        RenderBlock (anonymous) at (0,247) size 784x36
          RenderBR {BR} at (0,0) size 0x18
          RenderText {TEXT} at (0,18) size 254x18
            text run at (0,18) width 254: "Test 4: Transfer from <form> to <form>"
        RenderBlock {FORM} at (0,283) size 784x0
          RenderText {TEXT} at (0,0) size 0x0
          RenderText {TEXT} at (0,0) size 0x0
        RenderBlock {FORM} at (0,299) size 784x19
          RenderBlock {INPUT} at (3,3) size 12x13
          RenderText {TEXT} at (18,0) size 4x18
            text run at (18,0) width 4: " "
          RenderBlock {INPUT} at (25,3) size 12x13
          RenderBlock {INPUT} at (43,3) size 12x13
        RenderBlock {DIV} at (0,334) size 784x18
          RenderText {TEXT} at (0,0) size 91x18
            text run at (0,0) width 91: "Test 4 Passed"
        RenderBlock (anonymous) at (0,352) size 784x19
          RenderBlock {INPUT} at (3,3) size 12x13
          RenderBlock {INPUT} at (21,3) size 12x13
          RenderBlock {INPUT} at (39,3) size 12x13
          RenderBlock {INPUT} at (57,3) size 12x13
  
  
  
  1.1                  LayoutTests/fast/forms/radio_checked_dynamic.html
  
  Index: radio_checked_dynamic.html
  ===================================================================
  <html>
  <head>
  
  <script>
  
  function runTests() {
      var radio1 = document.getElementById("radio1");
      var radio2 = document.getElementById("radio2");
      var form = document.getElementById("test1");
      var result1 = document.getElementById("result1");
      form.appendChild(radio1);
      form.appendChild(radio2);
      radio2.checked = true;
      
      var radio3 = document.getElementById("radio3");
      var radio4 = document.getElementById("radio4");
      document.body.appendChild(radio3);
      document.body.appendChild(radio4);
      radio4.checked = true;
      
      var radio5 = document.getElementById("radio5");
      var radio6 = document.getElementById("radio6");
      radio5.parentNode.removeChild(radio5);
      radio6.parentNode.removeChild(radio6);
      document.body.appendChild(radio5);
      document.body.appendChild(radio6);
      radio6.checked = true;
      
      var radio7 = document.getElementById("radio7");
      var radio8 = document.getElementById("radio8");
      var radio9wasChecked = true;
      var form4 = document.getElementById("test4");
      form4.appendChild(radio7);
      form4.appendChild(radio8);
      radio9wasChecked = radio9.checked;
      radio8.checked = true;
      
      if (!radio1.checked && radio2.checked)
          result1.innerHTML = "Test 1 Passed";        
      if (!radio3.checked && radio4.checked)
          result2.innerHTML = "Test 2 Passed";
      if (!radio5.checked && radio6.checked)
          result3.innerHTML = "Test 3 Passed";
      if (!radio7.checked && radio8.checked && !radio9.checked && !radio9wasChecked)
          result4.innerHTML = "Test 4 Passed";
  }
  
  </script>
  <style>
  div { font-weight: bold; }
  </style>
  
  </head>
  
  <body onload="runTests()">
  This will test that radio buttons can be moved in and out of forms while maintaining only one checked button per group, per form.
  <br>
  Test 1: Transfer radio buttons from &lt;body&gt; to &lt;form&gt;:
  <input type="radio" name="group1" id="radio1" checked="checked">
  <input type="radio" name="group1" id="radio2">
  <form id="test1">
  </form>
  <div id="result1">Test 1 Failed</div>
  <br>
  Test 2: Transfer radio buttons from &lt;form&gt; to &lt;body&gt;:
  <form>
  <input type="radio" name="group2" id="radio3" checked="checked">
  <input type="radio" name="group2" id="radio4">
  </form>
  <div id="result2">Test 2 Failed</div>
  <br>
  Test 3: Transfer radio buttons from &lt;form&gt; to &lt;body&gt; with a dormant state in the middle:
  <form>
  <input type="radio" name="group3" id="radio5" checked="checked">
  <input type="radio" name="group3" id="radio6">
  </form>
  <div id="result3">Test 3 Failed</div>
  <br>
  Test 4: Transfer from &lt;form&gt; to &lt;form&gt;
  <form>
  <input type="radio" name="group4" id="radio7" checked="checked" style="outline:1px solid red">
  <input type="radio" name="group4" id="radio8" style="outline:1px solid blue">
  </form>
  <form id="test4">
  <input type="radio" name="group4" id="radio9" checked="checked" style="outline:1px solid green">
  </form>
  <div id="result4">Test 4 Failed</div>
  
  </body>
  </html>
  
  
  1.28      +18 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- ChangeLog	22 Dec 2005 21:10:50 -0000	1.27
  +++ ChangeLog	22 Dec 2005 23:06:19 -0000	1.28
  @@ -1,3 +1,21 @@
  +2005-12-22  Adele Peterson  <adele at apple.com>
  +
  +        Reviewed by Tim Hatcher.
  +
  +        Fixed <rdar://problem/4387433> Seed: Radio buttons behave incorrectly in Gmail settings
  +
  +        * khtml/html/html_formimpl.cpp:
  +        (DOM::HTMLFormElementImpl::registerFormElement): update radio button hash map when moving form elements around.
  +        (DOM::HTMLGenericFormElementImpl::insertedIntoTree): ditto.
  +        * khtml/html/html_formimpl.h:
  +        (DOM::HTMLGenericFormElementImpl::isRadioButton): Added.
  +        (DOM::HTMLInputElementImpl::isRadioButton): Added.
  +        * khtml/xml/dom_docimpl.cpp:
  +        (DocumentImpl::radioButtonChecked): 
  +        Added comment explaining that we use 1 for the default form.  We can't use a null pointer as a key for the hash map.
  +        (DocumentImpl::checkedRadioButtonForGroup): Added conversion of null form pointer to 1.
  +        (DocumentImpl::removeRadioButtonGroup): ditto.
  +
   2005-12-22  Anders Carlsson  <andersca at mac.com>
   
           Reviewed by Eric.
  
  
  
  1.215     +13 -0     WebCore/khtml/html/html_formimpl.cpp
  
  Index: html_formimpl.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/html/html_formimpl.cpp,v
  retrieving revision 1.214
  retrieving revision 1.215
  diff -u -r1.214 -r1.215
  --- html_formimpl.cpp	21 Dec 2005 16:51:01 -0000	1.214
  +++ html_formimpl.cpp	22 Dec 2005 23:06:20 -0000	1.215
  @@ -645,6 +645,14 @@
   
   void HTMLFormElementImpl::registerFormElement(HTMLGenericFormElementImpl *e)
   {
  +    DocumentImpl *doc = getDocument();
  +    if (doc && e->isRadioButton() && !e->name().isEmpty()) {
  +        HTMLGenericFormElementImpl* currentCheckedRadio = doc->checkedRadioButtonForGroup(e->name().impl(), (HTMLFormElementImpl*) 0);
  +        if (currentCheckedRadio == e)
  +            doc->removeRadioButtonGroup(e->name().impl(), (HTMLFormElementImpl*) 0);
  +        if (e->isChecked())
  +            doc->radioButtonChecked((HTMLInputElementImpl*) e, this);
  +    }
       insertIntoVector(formElements, formElementIndex(e), e);
   }
   
  @@ -807,6 +815,11 @@
           m_form = getForm();
   	if (m_form)
   	    m_form->registerFormElement(this);
  +        else {
  +            DocumentImpl *doc = getDocument();
  +            if (doc && isRadioButton() && !name().isEmpty() && isChecked())
  +                doc->radioButtonChecked((HTMLInputElementImpl*)this, m_form);
  +        }
       }
   
       HTMLElementImpl::insertedIntoTree(deep);
  
  
  
  1.100     +2 -0      WebCore/khtml/html/html_formimpl.h
  
  Index: html_formimpl.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/html/html_formimpl.h,v
  retrieving revision 1.99
  retrieving revision 1.100
  diff -u -r1.99 -r1.100
  --- html_formimpl.h	21 Dec 2005 16:51:02 -0000	1.99
  +++ html_formimpl.h	22 Dec 2005 23:06:20 -0000	1.100
  @@ -197,6 +197,7 @@
       void setName(const DOMString& name);
   
       virtual bool isGenericFormElement() const { return true; }
  +    virtual bool isRadioButton() const { return false; }
   
       /*
        * override in derived classes to get the encoded name=value pair
  @@ -333,6 +334,7 @@
       virtual bool isIndeterminate() const { return indeterminate(); }
   
       bool isTextButton() const { return m_type == SUBMIT || m_type == RESET || m_type == BUTTON; }
  +    virtual bool isRadioButton() const { return m_type == RADIO; }
   
       bool checked() const { return m_checked; }
       void setChecked(bool);
  
  
  
  1.291     +7 -1      WebCore/khtml/xml/dom_docimpl.cpp
  
  Index: dom_docimpl.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/xml/dom_docimpl.cpp,v
  retrieving revision 1.290
  retrieving revision 1.291
  diff -u -r1.290 -r1.291
  --- dom_docimpl.cpp	22 Dec 2005 16:53:56 -0000	1.290
  +++ dom_docimpl.cpp	22 Dec 2005 23:06:21 -0000	1.291
  @@ -3209,7 +3209,7 @@
       // Without a name, there is no group.
       if (caller->name().isEmpty())
           return;
  -    
  +    // Use 1 to represent the document's default form
       if (!form)
           form = (HTMLFormElementImpl*) 1;
       // Uncheck the currently selected item
  @@ -3232,6 +3232,9 @@
   {
       if (!m_selectedRadioButtons)
           return 0;
  +    // Use 1 to represent the document's default form
  +    if (!form)
  +        form = (HTMLFormElementImpl*) 1;
       NameToInputMap* formRadioButtons = m_selectedRadioButtons->get(form);
       if (!formRadioButtons)
           return 0;
  @@ -3241,6 +3244,9 @@
   
   void DocumentImpl::removeRadioButtonGroup(DOMStringImpl* name, HTMLFormElementImpl *form)
   {
  +    // Use 1 to represent the document's default form
  +    if (!form)
  +        form = (HTMLFormElementImpl*) 1;
       if (m_selectedRadioButtons) {
           NameToInputMap* formRadioButtons = m_selectedRadioButtons->get(form);
           if (formRadioButtons) {
  
  
  



More information about the webkit-changes mailing list