[webkit-changes] cvs commit: WebCore/kwq KWQComboBox.h KWQComboBox.mm KWQListBox.h KWQListBox.mm

Adele adele at opensource.apple.com
Fri Sep 2 15:14:11 PDT 2005


adele       05/09/02 15:14:11

  Modified:    .        Tag: Safari-2-0-branch ChangeLog
               khtml/html Tag: Safari-2-0-branch dtd.cpp html_formimpl.cpp
                        html_formimpl.h
               khtml/rendering Tag: Safari-2-0-branch render_form.cpp
               kwq      Tag: Safari-2-0-branch KWQComboBox.h KWQComboBox.mm
                        KWQListBox.h KWQListBox.mm
  Log:
          Merged fix from TOT to Safari-2-0-branch
  
      2005-09-02  Adele Peterson  <adele at apple.com>
  
          Reviewed by Darin.
  
          Test cases updated:  manual-tests/select_hr.html:
          updated for case where selection is changed for a list box that has an <hr> in its list items, even though it doesn't appear in the list.
  
          * khtml/rendering/render_form.cpp:
          (RenderSelect::slotSelectionChanged):  Added counter that increments only for visible list items (options and optgroups).  Before this change,
          list boxes that had invisible <hr>s could have the visible selected option get out of sync from the selected state.
          (RenderSelect::updateSelection):  ditto.
          * kwq/KWQListBox.h: Changed enum from ItemType to KWQListBoxItemType and values to KWQListBoxOption, KWQListBoxGroupLabel, and KWQListBoxSeparator.
          (KWQListBoxItem::KWQListBoxItem): ditto.
          (QListBox::appendItem): ditto.
          (QListBox::appendGroupLabel): ditto.
          * kwq/KWQListBox.mm:
          (QListBox::appendItem): ditto.
          (QListBox::sizeForNumberOfLines): ditto.
          (-[KWQTableView tableView:shouldSelectRow:]): ditto.
          (-[KWQTableView drawRow:clipRect:]): ditto.
          * kwq/KWQComboBox.h:
          (QComboBox::appendItem): ditto.
          (QComboBox::appendGroupLabel): ditto.
          (QComboBox::appendSeparator): ditto.
          * kwq/KWQComboBox.mm:
          (QComboBox::setTitle): ditto.
          (QComboBox::appendItem): ditto.
          (QComboBox::sizeHint): ditto.
          (QComboBox::populateMenu): ditto.
  
      2005-08-31  Adele Peterson  <adele at apple.com>
  
          Reviewed by Dave Hyatt.
  
          - fixed <rdar://problem/4229189> add a way to get a separator into a <select>
  
          This will allow an <hr> within a select element to display a separator in a popup menu.
          These extra elements are added to our listItems array, which we use internally.  But this should not
          affect JavaScript operations, such as getting an index of an option element, or getting the length of the select,
          or getting the selected index.  In these cases, the <hr>s will be ignored.
  
          Test cases added:
          * manual-tests/select_hr.html: Added.
  
          * khtml/html/html_formimpl.h:
          (DOM::HTMLSelectElementImpl::listItems): Now that our listItems can also contain <hr>s,
          I've changed listItems to be a QMemArray<HTMLElementImpl*> instead of QMemArray<HTMLGenericFormElementImpl*>
          (DOM::HTMLOptGroupElementImpl::checkDTD): Added check for <hr>
  
          * khtml/html/html_formimpl.cpp:
          (DOM::HTMLSelectElementImpl::checkDTD): Added check for <hr>
          (DOM::HTMLSelectElementImpl::add): Added check for <hr> so these elements can be added through Javascript.
          (DOM::HTMLSelectElementImpl::recalcListItems): Added case for <hr> to add the element to the listItems array.
          (DOM::HTMLSelectElementImpl::selectedIndex): Updated type for array of listItems.
          (DOM::HTMLSelectElementImpl::setSelectedIndex): ditto.
          (DOM::HTMLSelectElementImpl::length): ditto.
          (DOM::HTMLSelectElementImpl::remove): ditto.
          (DOM::HTMLSelectElementImpl::value): ditto.
          (DOM::HTMLSelectElementImpl::setValue): ditto.
          (DOM::HTMLSelectElementImpl::state): ditto.
          (DOM::HTMLSelectElementImpl::restoreState): ditto.
          (DOM::HTMLSelectElementImpl::appendFormData): ditto.
          (DOM::HTMLSelectElementImpl::optionToListIndex): ditto.
          (DOM::HTMLSelectElementImpl::listToOptionIndex): ditto.
          (DOM::HTMLSelectElementImpl::reset): ditto.
          (DOM::HTMLSelectElementImpl::notifyOptionSelected): ditto.
          (DOM::HTMLOptionElementImpl::index): ditto.
  
          * khtml/rendering/render_form.cpp:
          (RenderSelect::updateFromElement): If the list item is an <hr>, and we're not using a ListBox, then we call appendSeparator on the widget.
          (RenderSelect::layout): Updated type for array of listItems.
          (RenderSelect::slotSelected): ditto.
          (RenderSelect::slotSelectionChanged): ditto.
          (RenderSelect::updateSelection): ditto.
  
          * kwq/KWQListBox.h: Added ItemType enum with the following values: Option, GroupLabel, and Separator.
          (KWQListBoxItem::KWQListBoxItem): Updated to use ItemType instead of old isGroupLabel bool.
          (QListBox::appendItem): ditto.
          (QListBox::appendGroupLabel): ditto.
  
          * kwq/KWQComboBox.h:
          (QComboBox::appendItem): the private version of appendItem used to take isLabel as a parameter.  Now it takes an ItemType.
          (QComboBox::appendGroupLabel): calls appendItem with an ItemType of GroupLabel
          (QComboBox::appendSeparator): calls appendItem with an ItemType of Separator
  
          * kwq/KWQComboBox.mm:
          (QComboBox::setTitle): Updated to check for the ItemType instead of the old isGroupLabel bool.
          (QComboBox::appendItem): If the new item is a Separator, then we add a separatorItem to the popup menu.
          (QComboBox::sizeHint): Updated to check for the ItemType instead of the old isGroupLabel bool.
          (QComboBox::populateMenu): If the new item is a Separator, then we add a separatorItem to the popup menu.
  
          * kwq/KWQListBox.mm:
          (QListBox::appendItem): Updated to use the ItemType instead of the old isLabel bool.
          (QListBox::sizeForNumberOfLines): ditto.
          (-[KWQTableView tableView:shouldSelectRow:]): ditto.
          (-[KWQTableView drawRow:clipRect:]): ditto.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.18  +102 -0    WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.1.2.17
  retrieving revision 1.1.2.18
  diff -u -r1.1.2.17 -r1.1.2.18
  --- ChangeLog	1 Sep 2005 01:01:50 -0000	1.1.2.17
  +++ ChangeLog	2 Sep 2005 22:14:07 -0000	1.1.2.18
  @@ -1,3 +1,105 @@
  +2005-09-02  Adele Peterson  <adele at apple.com>
  +
  +        Merged fix from TOT to Safari-2-0-branch
  +
  +    2005-09-02  Adele Peterson  <adele at apple.com>
  +
  +        Reviewed by Darin.
  +
  +        Test cases updated:  manual-tests/select_hr.html: 
  +        updated for case where selection is changed for a list box that has an <hr> in its list items, even though it doesn't appear in the list.
  +
  +        * khtml/rendering/render_form.cpp:
  +        (RenderSelect::slotSelectionChanged):  Added counter that increments only for visible list items (options and optgroups).  Before this change, 
  +        list boxes that had invisible <hr>s could have the visible selected option get out of sync from the selected state.
  +        (RenderSelect::updateSelection):  ditto.
  +        * kwq/KWQListBox.h: Changed enum from ItemType to KWQListBoxItemType and values to KWQListBoxOption, KWQListBoxGroupLabel, and KWQListBoxSeparator.
  +        (KWQListBoxItem::KWQListBoxItem): ditto.
  +        (QListBox::appendItem): ditto.
  +        (QListBox::appendGroupLabel): ditto.
  +        * kwq/KWQListBox.mm:
  +        (QListBox::appendItem): ditto.
  +        (QListBox::sizeForNumberOfLines): ditto.
  +        (-[KWQTableView tableView:shouldSelectRow:]): ditto.
  +        (-[KWQTableView drawRow:clipRect:]): ditto.
  +        * kwq/KWQComboBox.h: 
  +        (QComboBox::appendItem): ditto.
  +        (QComboBox::appendGroupLabel): ditto.
  +        (QComboBox::appendSeparator): ditto.
  +        * kwq/KWQComboBox.mm:
  +        (QComboBox::setTitle): ditto.
  +        (QComboBox::appendItem): ditto.
  +        (QComboBox::sizeHint): ditto.
  +        (QComboBox::populateMenu): ditto.
  +
  +    2005-08-31  Adele Peterson  <adele at apple.com>
  +
  +        Reviewed by Dave Hyatt.
  +
  +        - fixed <rdar://problem/4229189> add a way to get a separator into a <select>
  +
  +        This will allow an <hr> within a select element to display a separator in a popup menu.
  +        These extra elements are added to our listItems array, which we use internally.  But this should not
  +        affect JavaScript operations, such as getting an index of an option element, or getting the length of the select,
  +        or getting the selected index.  In these cases, the <hr>s will be ignored.
  +
  +        Test cases added:
  +        * manual-tests/select_hr.html: Added.
  +
  +        * khtml/html/html_formimpl.h: 
  +        (DOM::HTMLSelectElementImpl::listItems): Now that our listItems can also contain <hr>s, 
  +        I've changed listItems to be a QMemArray<HTMLElementImpl*> instead of QMemArray<HTMLGenericFormElementImpl*>
  +        (DOM::HTMLOptGroupElementImpl::checkDTD): Added check for <hr>
  +
  +        * khtml/html/html_formimpl.cpp:
  +        (DOM::HTMLSelectElementImpl::checkDTD): Added check for <hr>
  +        (DOM::HTMLSelectElementImpl::add): Added check for <hr> so these elements can be added through Javascript.
  +        (DOM::HTMLSelectElementImpl::recalcListItems): Added case for <hr> to add the element to the listItems array.
  +        (DOM::HTMLSelectElementImpl::selectedIndex): Updated type for array of listItems.
  +        (DOM::HTMLSelectElementImpl::setSelectedIndex): ditto.
  +        (DOM::HTMLSelectElementImpl::length): ditto.
  +        (DOM::HTMLSelectElementImpl::remove): ditto.
  +        (DOM::HTMLSelectElementImpl::value): ditto.
  +        (DOM::HTMLSelectElementImpl::setValue): ditto.
  +        (DOM::HTMLSelectElementImpl::state): ditto.
  +        (DOM::HTMLSelectElementImpl::restoreState): ditto.
  +        (DOM::HTMLSelectElementImpl::appendFormData): ditto.
  +        (DOM::HTMLSelectElementImpl::optionToListIndex): ditto.
  +        (DOM::HTMLSelectElementImpl::listToOptionIndex): ditto.
  +        (DOM::HTMLSelectElementImpl::reset): ditto.
  +        (DOM::HTMLSelectElementImpl::notifyOptionSelected): ditto.
  +        (DOM::HTMLOptionElementImpl::index): ditto.
  +
  +        * khtml/rendering/render_form.cpp:
  +        (RenderSelect::updateFromElement): If the list item is an <hr>, and we're not using a ListBox, then we call appendSeparator on the widget.  
  +        (RenderSelect::layout): Updated type for array of listItems.
  +        (RenderSelect::slotSelected): ditto.
  +        (RenderSelect::slotSelectionChanged): ditto.
  +        (RenderSelect::updateSelection): ditto.
  +
  +        * kwq/KWQListBox.h: Added ItemType enum with the following values: Option, GroupLabel, and Separator.
  +        (KWQListBoxItem::KWQListBoxItem): Updated to use ItemType instead of old isGroupLabel bool.
  +        (QListBox::appendItem): ditto.
  +        (QListBox::appendGroupLabel): ditto.
  +
  +        * kwq/KWQComboBox.h:
  +        (QComboBox::appendItem): the private version of appendItem used to take isLabel as a parameter.  Now it takes an ItemType.
  +        (QComboBox::appendGroupLabel): calls appendItem with an ItemType of GroupLabel
  +        (QComboBox::appendSeparator): calls appendItem with an ItemType of Separator
  +
  +        * kwq/KWQComboBox.mm:
  +        (QComboBox::setTitle): Updated to check for the ItemType instead of the old isGroupLabel bool.
  +        (QComboBox::appendItem): If the new item is a Separator, then we add a separatorItem to the popup menu.
  +        (QComboBox::sizeHint): Updated to check for the ItemType instead of the old isGroupLabel bool.
  +        (QComboBox::populateMenu): If the new item is a Separator, then we add a separatorItem to the popup menu.
  +
  +        * kwq/KWQListBox.mm:
  +        (QListBox::appendItem): Updated to use the ItemType instead of the old isLabel bool.
  +        (QListBox::sizeForNumberOfLines): ditto.
  +        (-[KWQTableView tableView:shouldSelectRow:]): ditto.
  +        (-[KWQTableView drawRow:clipRect:]): ditto.
  +
  +
   2005-08-31  Adele Peterson  <adele at apple.com>
   
           Merged fix from TOT to Safari-2-0-branch
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.37.6.2  +2 -1      WebCore/khtml/html/Attic/dtd.cpp
  
  Index: dtd.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/html/Attic/dtd.cpp,v
  retrieving revision 1.37.6.1
  retrieving revision 1.37.6.2
  diff -u -r1.37.6.1 -r1.37.6.2
  --- dtd.cpp	9 Aug 2005 23:52:13 -0000	1.37.6.1
  +++ dtd.cpp	2 Sep 2005 22:14:08 -0000	1.37.6.2
  @@ -514,6 +514,7 @@
       ID_OPTION,
       ID_COMMENT,
       ID_SCRIPT,
  +    ID_HR,
       0
   };
   
  @@ -686,7 +687,7 @@
           return check_array(childID, tag_list_7);
       case ID_OPTGROUP:
           // OPTGROUP: OPTION +
  -        if(childID == ID_OPTION) return true;
  +        if(childID == ID_OPTION || childID == ID_HR) return true;
           return false;
       case ID_OPTION:
       case ID_TEXTAREA:
  
  
  
  1.156.6.4 +21 -17    WebCore/khtml/html/html_formimpl.cpp
  
  Index: html_formimpl.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/html/html_formimpl.cpp,v
  retrieving revision 1.156.6.3
  retrieving revision 1.156.6.4
  diff -u -r1.156.6.3 -r1.156.6.4
  --- html_formimpl.cpp	12 Jul 2005 22:15:23 -0000	1.156.6.3
  +++ html_formimpl.cpp	2 Sep 2005 22:14:08 -0000	1.156.6.4
  @@ -2293,7 +2293,7 @@
   {
       // return the number of the first option selected
       uint o = 0;
  -    QMemArray<HTMLGenericFormElementImpl*> items = listItems();
  +    QMemArray<HTMLElementImpl*> items = listItems();
       for (unsigned int i = 0; i < items.size(); i++) {
           if (items[i]->id() == ID_OPTION) {
               if (static_cast<HTMLOptionElementImpl*>(items[i])->selected())
  @@ -2308,7 +2308,7 @@
   void HTMLSelectElementImpl::setSelectedIndex( long  index )
   {
       // deselect all other options and select only the new one
  -    QMemArray<HTMLGenericFormElementImpl*> items = listItems();
  +    QMemArray<HTMLElementImpl*> items = listItems();
       int listIndex;
       for (listIndex = 0; listIndex < int(items.size()); listIndex++) {
           if (items[listIndex]->id() == ID_OPTION)
  @@ -2325,7 +2325,7 @@
   {
       int len = 0;
       uint i;
  -    QMemArray<HTMLGenericFormElementImpl*> items = listItems();
  +    QMemArray<HTMLElementImpl*> items = listItems();
       for (i = 0; i < items.size(); i++) {
           if (items[i]->id() == ID_OPTION)
               len++;
  @@ -2335,7 +2335,7 @@
   
   void HTMLSelectElementImpl::add( HTMLElementImpl *element, HTMLElementImpl *before )
   {
  -    if (!element || element->id() != ID_OPTION)
  +    if (!element || !(element->id() == ID_OPTION || element->id() == ID_HR))
           return;
   
       int exceptioncode = 0;
  @@ -2349,7 +2349,7 @@
       int exceptioncode = 0;
       int listIndex = optionToListIndex(index);
   
  -    QMemArray<HTMLGenericFormElementImpl*> items = listItems();
  +    QMemArray<HTMLElementImpl*> items = listItems();
       if(listIndex < 0 || index >= int(items.size()))
           return; // ### what should we do ? remove the last item?
   
  @@ -2372,7 +2372,7 @@
   DOMString HTMLSelectElementImpl::value( )
   {
       uint i;
  -    QMemArray<HTMLGenericFormElementImpl*> items = listItems();
  +    QMemArray<HTMLElementImpl*> items = listItems();
       for (i = 0; i < items.size(); i++) {
           if ( items[i]->id() == ID_OPTION
               && static_cast<HTMLOptionElementImpl*>(items[i])->selected())
  @@ -2385,7 +2385,7 @@
   {
       // find the option with value() matching the given parameter
       // and make it the current selection.
  -    QMemArray<HTMLGenericFormElementImpl*> items = listItems();
  +    QMemArray<HTMLElementImpl*> items = listItems();
       for (unsigned i = 0; i < items.size(); i++)
           if (items[i]->id() == ID_OPTION && static_cast<HTMLOptionElementImpl*>(items[i])->value() == value) {
               static_cast<HTMLOptionElementImpl*>(items[i])->setSelected(true);
  @@ -2398,7 +2398,7 @@
   #if !APPLE_CHANGES
       QString state;
   #endif
  -    QMemArray<HTMLGenericFormElementImpl*> items = listItems();
  +    QMemArray<HTMLElementImpl*> items = listItems();
   
       int l = items.count();
   
  @@ -2439,7 +2439,7 @@
   #endif
       }
   
  -    QMemArray<HTMLGenericFormElementImpl*> items = listItems();
  +    QMemArray<HTMLElementImpl*> items = listItems();
   
       int l = items.count();
       for(int i = 0; i < l; i++) {
  @@ -2531,7 +2531,7 @@
   bool HTMLSelectElementImpl::appendFormData(FormDataList& encoded_values, bool)
   {
       bool successful = false;
  -    QMemArray<HTMLGenericFormElementImpl*> items = listItems();
  +    QMemArray<HTMLElementImpl*> items = listItems();
   
       uint i;
       for (i = 0; i < items.size(); i++) {
  @@ -2562,7 +2562,7 @@
   
   int HTMLSelectElementImpl::optionToListIndex(int optionIndex) const
   {
  -    QMemArray<HTMLGenericFormElementImpl*> items = listItems();
  +    QMemArray<HTMLElementImpl*> items = listItems();
       if (optionIndex < 0 || optionIndex >= int(items.size()))
           return -1;
   
  @@ -2580,7 +2580,7 @@
   
   int HTMLSelectElementImpl::listToOptionIndex(int listIndex) const
   {
  -    QMemArray<HTMLGenericFormElementImpl*> items = listItems();
  +    QMemArray<HTMLElementImpl*> items = listItems();
       if (listIndex < 0 || listIndex >= int(items.size()) ||
           items[listIndex]->id() != ID_OPTION)
           return -1;
  @@ -2611,12 +2611,12 @@
           if (current->id() == ID_OPTGROUP && current->firstChild()) {
               // ### what if optgroup contains just comments? don't want one of no options in it...
               m_listItems.resize(m_listItems.size()+1);
  -            m_listItems[m_listItems.size()-1] = static_cast<HTMLGenericFormElementImpl*>(current);
  +            m_listItems[m_listItems.size()-1] = static_cast<HTMLElementImpl*>(current);
               current = current->firstChild();
           }
           if (current->id() == ID_OPTION) {
               m_listItems.resize(m_listItems.size()+1);
  -            m_listItems[m_listItems.size()-1] = static_cast<HTMLGenericFormElementImpl*>(current);
  +            m_listItems[m_listItems.size()-1] = static_cast<HTMLElementImpl*>(current);
               if (!foundSelected && !m_multiple && m_size <= 1) {
                   foundSelected = static_cast<HTMLOptionElementImpl*>(current);
                   foundSelected->m_selected = true;
  @@ -2626,6 +2626,10 @@
                   foundSelected = static_cast<HTMLOptionElementImpl*>(current);
               }
           }
  +        if (current->id() == ID_HR) {
  +            m_listItems.resize(m_listItems.size()+1);
  +            m_listItems[m_listItems.size()-1] = static_cast<HTMLElementImpl*>(current);
  +        }
           NodeImpl *parent = current->parentNode();
           current = current->nextSibling();
           if (!current) {
  @@ -2653,7 +2657,7 @@
   
   void HTMLSelectElementImpl::reset()
   {
  -    QMemArray<HTMLGenericFormElementImpl*> items = listItems();
  +    QMemArray<HTMLElementImpl*> items = listItems();
       uint i;
       for (i = 0; i < items.size(); i++) {
           if (items[i]->id() == ID_OPTION) {
  @@ -2671,7 +2675,7 @@
   {
       if (selected && !m_multiple) {
           // deselect all other options
  -        QMemArray<HTMLGenericFormElementImpl*> items = listItems();
  +        QMemArray<HTMLElementImpl*> items = listItems();
           uint i;
           for (i = 0; i < items.size(); i++) {
               if (items[i]->id() == ID_OPTION)
  @@ -2908,7 +2912,7 @@
   {
       // Let's do this dynamically. Might be a bit slow, but we're sure
       // we won't forget to update a member variable in some cases...
  -    QMemArray<HTMLGenericFormElementImpl*> items = getSelect()->listItems();
  +    QMemArray<HTMLElementImpl*> items = getSelect()->listItems();
       int l = items.count();
       int optionIndex = 0;
       for(int i = 0; i < l; i++) {
  
  
  
  1.67.6.3  +2 -2      WebCore/khtml/html/html_formimpl.h
  
  Index: html_formimpl.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/html/html_formimpl.h,v
  retrieving revision 1.67.6.2
  retrieving revision 1.67.6.3
  diff -u -r1.67.6.2 -r1.67.6.3
  --- html_formimpl.h	12 Jul 2005 22:15:24 -0000	1.67.6.2
  +++ html_formimpl.h	2 Sep 2005 22:14:09 -0000	1.67.6.3
  @@ -493,7 +493,7 @@
   
       void setRecalcListItems();
   
  -    QMemArray<HTMLGenericFormElementImpl*> listItems() const
  +    QMemArray<HTMLElementImpl*> listItems() const
        {
            if (m_recalcListItems) const_cast<HTMLSelectElementImpl*>(this)->recalcListItems();
            return m_listItems;
  @@ -511,7 +511,7 @@
       void recalcListItems();
   
   protected:
  -    mutable QMemArray<HTMLGenericFormElementImpl*> m_listItems;
  +    mutable QMemArray<HTMLElementImpl*> m_listItems;
       HTMLOptionsCollectionImpl *m_options;
       short m_minwidth;
       short m_size;
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.102.8.3 +22 -10    WebCore/khtml/rendering/render_form.cpp
  
  Index: render_form.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_form.cpp,v
  retrieving revision 1.102.8.2
  retrieving revision 1.102.8.3
  diff -u -r1.102.8.2 -r1.102.8.3
  --- render_form.cpp	12 Jul 2005 19:09:50 -0000	1.102.8.2
  +++ render_form.cpp	2 Sep 2005 22:14:09 -0000	1.102.8.3
  @@ -1116,7 +1116,7 @@
       if ( m_optionsChanged ) {
           if (element()->m_recalcListItems)
               element()->recalcListItems();
  -        QMemArray<HTMLGenericFormElementImpl*> listItems = element()->listItems();
  +        QMemArray<HTMLElementImpl*> listItems = element()->listItems();
           int listIndex;
   
           if (m_useListBox)
  @@ -1171,6 +1171,11 @@
                       static_cast<KComboBox*>(m_widget)->insertItem(itemText, listIndex);
   #endif
               }
  +            else if (listItems[listIndex]->id() == ID_HR) {
  +                if (!m_useListBox) {
  +                    static_cast<KComboBox*>(m_widget)->appendSeparator();
  +                }
  +            }
               else
                   KHTMLAssert(false);
               m_selectionChanged = true;
  @@ -1278,7 +1283,7 @@
       RenderFormElement::layout();
   
       // and now disable the widget in case there is no <option> given
  -    QMemArray<HTMLGenericFormElementImpl*> listItems = element()->listItems();
  +    QMemArray<HTMLElementImpl*> listItems = element()->listItems();
   
       bool foundOption = false;
       for (uint i = 0; i < listItems.size() && !foundOption; i++)
  @@ -1293,7 +1298,7 @@
   
       KHTMLAssert( !m_useListBox );
   
  -    QMemArray<HTMLGenericFormElementImpl*> listItems = element()->listItems();
  +    QMemArray<HTMLElementImpl*> listItems = element()->listItems();
       if(index >= 0 && index < int(listItems.size()))
       {
           bool found = ( listItems[index]->id() == ID_OPTION );
  @@ -1341,14 +1346,17 @@
   
       // don't use listItems() here as we have to avoid recalculations - changing the
       // option list will make use update options not in the way the user expects them
  -    QMemArray<HTMLGenericFormElementImpl*> listItems = element()->m_listItems;
  -    for ( unsigned i = 0; i < listItems.count(); i++ )
  +    QMemArray<HTMLElementImpl*> listItems = element()->m_listItems;
  +    int j = 0;
  +    for ( unsigned i = 0; i < listItems.count(); i++ ) {
           // don't use setSelected() here because it will cause us to be called
           // again with updateSelection.
           if ( listItems[i]->id() == ID_OPTION )
               static_cast<HTMLOptionElementImpl*>( listItems[i] )
  -                ->m_selected = static_cast<KListBox*>( m_widget )->isSelected( i );
  -
  +                ->m_selected = static_cast<KListBox*>( m_widget )->isSelected( j );
  +        if ( listItems[i]->id() == ID_OPTION || listItems[i]->id() == ID_OPTGROUP)
  +            ++j;
  +    }
       element()->onChange();
   }
   
  @@ -1381,14 +1389,18 @@
   
   void RenderSelect::updateSelection()
   {
  -    QMemArray<HTMLGenericFormElementImpl*> listItems = element()->listItems();
  +    QMemArray<HTMLElementImpl*> listItems = element()->listItems();
       int i;
       if (m_useListBox) {
           // if multi-select, we select only the new selected index
           KListBox *listBox = static_cast<KListBox*>(m_widget);
  -        for (i = 0; i < int(listItems.size()); i++)
  -            listBox->setSelected(i,listItems[i]->id() == ID_OPTION &&
  +        int j = 0;
  +        for (i = 0; i < int(listItems.size()); i++) {
  +            listBox->setSelected(j,listItems[i]->id() == ID_OPTION &&
                                   static_cast<HTMLOptionElementImpl*>(listItems[i])->selected());
  +            if (listItems[i]->id() == ID_OPTION || listItems[i]->id() == ID_OPTGROUP)
  +                ++j;
  +        }
       }
       else {
           bool found = false;
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.35.18.1 +5 -4      WebCore/kwq/KWQComboBox.h
  
  Index: KWQComboBox.h
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQComboBox.h,v
  retrieving revision 1.35
  retrieving revision 1.35.18.1
  diff -u -r1.35 -r1.35.18.1
  --- KWQComboBox.h	27 Apr 2004 17:38:07 -0000	1.35
  +++ KWQComboBox.h	2 Sep 2005 22:14:10 -0000	1.35.18.1
  @@ -36,13 +36,14 @@
   #endif
   
   class QComboBox : public QWidget {
  -public:
  +public:  
       QComboBox();
       ~QComboBox();
       
       void clear();
  -    void appendItem(const QString &text) { appendItem(text, false); }
  -    void appendGroupLabel(const QString &text) { appendItem(text, true); }
  +    void appendItem(const QString &text) { appendItem(text, KWQListBoxOption); }
  +    void appendGroupLabel(const QString &text) { appendItem(text, KWQListBoxGroupLabel); }
  +    void appendSeparator() { appendItem(QString::null, KWQListBoxSeparator); }
   
       int currentItem() const { return _currentItem; }
       void setCurrentItem(int);
  @@ -66,7 +67,7 @@
       void populateMenu();
       
   private:
  -    void appendItem(const QString &, bool isLabel);
  +    void appendItem(const QString &, KWQListBoxItemType);
       const int *dimensions() const;
       NSFont *labelFont() const;
       void setTitle(NSMenuItem *, const KWQListBoxItem &);
  
  
  
  1.59.10.3 +25 -15    WebCore/kwq/KWQComboBox.mm
  
  Index: KWQComboBox.mm
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQComboBox.mm,v
  retrieving revision 1.59.10.2
  retrieving revision 1.59.10.3
  diff -u -r1.59.10.2 -r1.59.10.3
  --- KWQComboBox.mm	2 Aug 2005 21:39:00 -0000	1.59.10.2
  +++ KWQComboBox.mm	2 Sep 2005 22:14:10 -0000	1.59.10.3
  @@ -115,7 +115,7 @@
   
   void QComboBox::setTitle(NSMenuItem *menuItem, const KWQListBoxItem &title)
   {
  -    if (title.isGroupLabel) {
  +    if (title.type == KWQListBoxGroupLabel) {
           NSDictionary *attributes = [[NSDictionary alloc] initWithObjectsAndKeys:labelFont(), NSFontAttributeName, nil];
           NSAttributedString *string = [[NSAttributedString alloc] initWithString:title.string.getNSString() attributes:attributes];
           [menuItem setAttributedTitle:string];
  @@ -127,21 +127,26 @@
       }
   }
   
  -void QComboBox::appendItem(const QString &text, bool isLabel)
  +void QComboBox::appendItem(const QString &text, KWQListBoxItemType type)
   {
  -    const KWQListBoxItem listItem(text, isLabel);
  +    const KWQListBoxItem listItem(text, type);
       _items.append(listItem);
       if (_menuPopulated) {
           KWQPopUpButton *button = (KWQPopUpButton *)getView();
           if (![[button cell] isHighlighted]) {
               _menuPopulated = false;
           } else {
  -            // We must add the item with no title and then set the title because
  -            // addItemWithTitle does not allow duplicate titles.
               KWQ_BLOCK_EXCEPTIONS;
  -            [button addItemWithTitle:@""];
  -            NSMenuItem *menuItem = [button lastItem];
  -            setTitle(menuItem, listItem);
  +            if (type == KWQListBoxSeparator) {
  +                NSMenuItem *separator = [NSMenuItem separatorItem];
  +                [[button menu] addItem:separator];
  +            } else {
  +                // We must add the item with no title and then set the title because
  +                // addItemWithTitle does not allow duplicate titles.
  +                [button addItemWithTitle:@""];
  +                NSMenuItem *menuItem = [button lastItem];
  +                setTitle(menuItem, listItem);
  +            }
               KWQ_UNBLOCK_EXCEPTIONS;
           }
       }
  @@ -169,7 +174,7 @@
               style.applyWordRounding = NO;
               do {
                   const QString &s = (*i).string;
  -                bool isLabel = (*i).isGroupLabel;
  +                bool isGroupLabel = ((*i).type == KWQListBoxGroupLabel);
                   ++i;
   
                   WebCoreTextRun run;
  @@ -177,7 +182,7 @@
                   WebCoreInitializeTextRun(&run, reinterpret_cast<const UniChar *>(s.unicode()), length, 0, length);
   
                   id <WebCoreTextRenderer> renderer;
  -                if (isLabel) {
  +                if (isGroupLabel) {
                       if (labelRenderer == nil) {
                           labelRenderer = [[WebCoreTextRendererFactory sharedFactory]
                               rendererWithFont:labelFont()
  @@ -361,11 +366,16 @@
           QValueListConstIterator<KWQListBoxItem> i = const_cast<const QValueList<KWQListBoxItem> &>(_items).begin();
           QValueListConstIterator<KWQListBoxItem> e = const_cast<const QValueList<KWQListBoxItem> &>(_items).end();
           for (; i != e; ++i) {
  -            // We must add the item with no title and then set the title because
  -            // addItemWithTitle does not allow duplicate titles.
  -            [button addItemWithTitle:@""];
  -            NSMenuItem *menuItem = [button lastItem];
  -            setTitle(menuItem, *i);
  +            if ((*i).type == KWQListBoxSeparator) {
  +                NSMenuItem *separator = [NSMenuItem separatorItem];
  +                [[button menu] addItem:separator];
  +            } else {
  +                // We must add the item with no title and then set the title because
  +                // addItemWithTitle does not allow duplicate titles.
  +                [button addItemWithTitle:@""];
  +                NSMenuItem *menuItem = [button lastItem];
  +                setTitle(menuItem, *i);
  +            }
           }
           [button selectItemAtIndex:_currentItem];
   	[button setPopulatingMenu:NO];
  
  
  
  1.22.10.2 +12 -6     WebCore/kwq/KWQListBox.h
  
  Index: KWQListBox.h
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQListBox.h,v
  retrieving revision 1.22.10.1
  retrieving revision 1.22.10.2
  diff -u -r1.22.10.1 -r1.22.10.2
  --- KWQListBox.h	12 Aug 2005 01:35:21 -0000	1.22.10.1
  +++ KWQListBox.h	2 Sep 2005 22:14:10 -0000	1.22.10.2
  @@ -28,12 +28,18 @@
   
   #include "KWQScrollView.h"
   
  +enum KWQListBoxItemType {
  +    KWQListBoxOption,
  +    KWQListBoxGroupLabel,
  +    KWQListBoxSeparator
  +};
  +
   struct KWQListBoxItem
   {
       QString string;
  -    bool isGroupLabel;
  -
  -    KWQListBoxItem(const QString &s, bool isLabel) : string(s), isGroupLabel(isLabel) { }
  +    KWQListBoxItemType type;
  +    
  +    KWQListBoxItem(const QString &s, KWQListBoxItemType t) : string(s), type(t) { }
   };
   
   class QListBox : public QScrollView {
  @@ -50,8 +56,8 @@
       void setSelectionMode(SelectionMode);
   
       void clear();
  -    void appendItem(const QString &s) { appendItem(s, false); }
  -    void appendGroupLabel(const QString &s) { appendItem(s, true); }
  +    void appendItem(const QString &s) { appendItem(s, KWQListBoxOption); }
  +    void appendGroupLabel(const QString &s) { appendItem(s, KWQListBoxGroupLabel); }
       void doneAppendingItems();
   
       void setSelected(int, bool);
  @@ -75,7 +81,7 @@
       void setFont(const QFont &font);
   
   private:
  -    void appendItem(const QString &, bool isLabel);
  +    void appendItem(const QString &, KWQListBoxItemType);
   
       // A vector<KWQListBoxItem> or QValueVector<KWQListBoxItem> might be more efficient for large lists.
       QValueList<KWQListBoxItem> _items;
  
  
  
  1.51.8.4  +6 -6      WebCore/kwq/KWQListBox.mm
  
  Index: KWQListBox.mm
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQListBox.mm,v
  retrieving revision 1.51.8.3
  retrieving revision 1.51.8.4
  diff -u -r1.51.8.3 -r1.51.8.4
  --- KWQListBox.mm	16 Aug 2005 01:42:48 -0000	1.51.8.3
  +++ KWQListBox.mm	2 Sep 2005 22:14:10 -0000	1.51.8.4
  @@ -183,9 +183,9 @@
       KWQ_UNBLOCK_EXCEPTIONS;
   }
   
  -void QListBox::appendItem(const QString &text, bool isLabel)
  +void QListBox::appendItem(const QString &text, KWQListBoxItemType type)
   {
  -    _items.append(KWQListBoxItem(text, isLabel));
  +    _items.append(KWQListBoxItem(text, type));
       _widthGood = false;
   }
   
  @@ -306,7 +306,7 @@
                   int length = s.length();
                   WebCoreInitializeTextRun(&run, reinterpret_cast<const UniChar *>(s.unicode()), length, 0, length);
   
  -                float textWidth = [((*i).isGroupLabel ? groupLabelRenderer : renderer) floatWidthForRun:&run style:&style widths:0];
  +                float textWidth = [(((*i).type == KWQListBoxGroupLabel) ? groupLabelRenderer : renderer) floatWidthForRun:&run style:&style widths:0];
                   width = kMax(width, textWidth);
                   
                   ++i;
  @@ -598,7 +598,7 @@
   
   - (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(int)row
   {
  -    return _box && !_box->itemAtIndex(row).isGroupLabel;
  +    return _box && _box->itemAtIndex(row).type == KWQListBoxOption;
   }
   
   - (BOOL)selectionShouldChangeInTableView:(NSTableView *)aTableView
  @@ -631,9 +631,9 @@
       
       id <WebCoreTextRenderer> renderer;
       if (isSystemFont) {
  -        renderer = item.isGroupLabel ? groupLabelTextRenderer() : itemTextRenderer();
  +        renderer = (item.type == KWQListBoxGroupLabel) ? groupLabelTextRenderer() : itemTextRenderer();
       } else {
  -        if (item.isGroupLabel) {
  +        if (item.type == KWQListBoxGroupLabel) {
               QFont boldFont = _box->font();
               boldFont.setWeight(QFont::Bold);
               font = boldFont.getNSFont();
  
  
  



More information about the webkit-changes mailing list