[webkit-changes] cvs commit: WebCore/manual-tests select_hr.html
Adele
adele at opensource.apple.com
Fri Sep 2 14:34:49 PDT 2005
adele 05/09/02 14:34:49
Modified: . ChangeLog
khtml/rendering render_form.cpp
kwq KWQComboBox.h KWQComboBox.mm KWQListBox.h
KWQListBox.mm
manual-tests select_hr.html
Log:
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.
Revision Changes Path
1.80 +30 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -r1.79 -r1.80
--- ChangeLog 2 Sep 2005 18:08:29 -0000 1.79
+++ ChangeLog 2 Sep 2005 21:34:45 -0000 1.80
@@ -1,3 +1,33 @@
+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-09-02 Beth Dakin <bdakin at apple.com>
Fix for <rdar://problem/4235531> Denver Regression: Safari crash in KWQStringData::makeUnicode
1.120 +13 -5 WebCore/khtml/rendering/render_form.cpp
Index: render_form.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/rendering/render_form.cpp,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -r1.119 -r1.120
--- render_form.cpp 1 Sep 2005 17:40:13 -0000 1.119
+++ render_form.cpp 2 Sep 2005 21:34:47 -0000 1.120
@@ -1324,13 +1324,16 @@
// 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<HTMLElementImpl*> listItems = element()->m_listItems;
- for ( unsigned i = 0; i < listItems.count(); i++ )
+ 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]->hasTagName(optionTag))
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]->hasTagName(optionTag) || listItems[i]->hasTagName(optgroupTag))
+ ++j;
+ }
element()->onChange();
}
@@ -1368,9 +1371,14 @@
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]->hasTagName(optionTag) &&
+ int j = 0;
+ for (i = 0; i < int(listItems.size()); i++) {
+ listBox->setSelected(j, listItems[i]->hasTagName(optionTag) &&
static_cast<HTMLOptionElementImpl*>(listItems[i])->selected());
+ if (listItems[i]->hasTagName(optionTag) || listItems[i]->hasTagName(optgroupTag))
+ ++j;
+
+ }
}
else {
bool found = false;
1.37 +4 -4 WebCore/kwq/KWQComboBox.h
Index: KWQComboBox.h
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQComboBox.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- KWQComboBox.h 1 Sep 2005 17:40:13 -0000 1.36
+++ KWQComboBox.h 2 Sep 2005 21:34:47 -0000 1.37
@@ -41,9 +41,9 @@
~QComboBox();
void clear();
- void appendItem(const QString &text) { appendItem(text, Option); }
- void appendGroupLabel(const QString &text) { appendItem(text, GroupLabel); }
- void appendSeparator() { appendItem(QString(""), Separator); }
+ 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);
@@ -67,7 +67,7 @@
void populateMenu();
private:
- void appendItem(const QString &, ItemType type);
+ void appendItem(const QString &, KWQListBoxItemType);
const int *dimensions() const;
NSFont *labelFont() const;
void setTitle(NSMenuItem *, const KWQListBoxItem &);
1.65 +5 -5 WebCore/kwq/KWQComboBox.mm
Index: KWQComboBox.mm
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQComboBox.mm,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -r1.64 -r1.65
--- KWQComboBox.mm 1 Sep 2005 17:40:13 -0000 1.64
+++ KWQComboBox.mm 2 Sep 2005 21:34:47 -0000 1.65
@@ -113,7 +113,7 @@
void QComboBox::setTitle(NSMenuItem *menuItem, const KWQListBoxItem &title)
{
- if (title.type == GroupLabel) {
+ 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];
@@ -125,7 +125,7 @@
}
}
-void QComboBox::appendItem(const QString &text, ItemType type)
+void QComboBox::appendItem(const QString &text, KWQListBoxItemType type)
{
const KWQListBoxItem listItem(text, type);
_items.append(listItem);
@@ -135,7 +135,7 @@
_menuPopulated = false;
} else {
KWQ_BLOCK_EXCEPTIONS;
- if (type == Separator) {
+ if (type == KWQListBoxSeparator) {
NSMenuItem *separator = [NSMenuItem separatorItem];
[[button menu] addItem:separator];
} else {
@@ -172,7 +172,7 @@
style.applyWordRounding = NO;
do {
const QString &s = (*i).string;
- bool isGroupLabel = ((*i).type == GroupLabel);
+ bool isGroupLabel = ((*i).type == KWQListBoxGroupLabel);
++i;
WebCoreTextRun run;
@@ -364,7 +364,7 @@
QValueListConstIterator<KWQListBoxItem> i = const_cast<const QValueList<KWQListBoxItem> &>(_items).begin();
QValueListConstIterator<KWQListBoxItem> e = const_cast<const QValueList<KWQListBoxItem> &>(_items).end();
for (; i != e; ++i) {
- if ((*i).type == Separator) {
+ if ((*i).type == KWQListBoxSeparator) {
NSMenuItem *separator = [NSMenuItem separatorItem];
[[button menu] addItem:separator];
} else {
1.26 +9 -9 WebCore/kwq/KWQListBox.h
Index: KWQListBox.h
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQListBox.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- KWQListBox.h 1 Sep 2005 17:40:13 -0000 1.25
+++ KWQListBox.h 2 Sep 2005 21:34:47 -0000 1.26
@@ -29,18 +29,18 @@
#include "KWQScrollView.h"
#include "KWQPainter.h"
-enum ItemType {
- Option,
- GroupLabel,
- Separator
+enum KWQListBoxItemType {
+ KWQListBoxOption,
+ KWQListBoxGroupLabel,
+ KWQListBoxSeparator
};
struct KWQListBoxItem
{
QString string;
- ItemType type;
+ KWQListBoxItemType type;
- KWQListBoxItem(const QString &s, ItemType t) : string(s), type(t) { }
+ KWQListBoxItem(const QString &s, KWQListBoxItemType t) : string(s), type(t) { }
};
class QListBox : public QScrollView {
@@ -57,8 +57,8 @@
void setSelectionMode(SelectionMode);
void clear();
- void appendItem(const QString &s) { appendItem(s, Option); }
- void appendGroupLabel(const QString &s) { appendItem(s, GroupLabel); }
+ void appendItem(const QString &s) { appendItem(s, KWQListBoxOption); }
+ void appendGroupLabel(const QString &s) { appendItem(s, KWQListBoxGroupLabel); }
void doneAppendingItems();
void setSelected(int, bool);
@@ -82,7 +82,7 @@
void setFont(const QFont &font);
private:
- void appendItem(const QString &, ItemType type);
+ void appendItem(const QString &, KWQListBoxItemType);
// A vector<KWQListBoxItem> or QValueVector<KWQListBoxItem> might be more efficient for large lists.
QValueList<KWQListBoxItem> _items;
1.57 +5 -5 WebCore/kwq/KWQListBox.mm
Index: KWQListBox.mm
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQListBox.mm,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- KWQListBox.mm 1 Sep 2005 17:40:13 -0000 1.56
+++ KWQListBox.mm 2 Sep 2005 21:34:48 -0000 1.57
@@ -183,7 +183,7 @@
KWQ_UNBLOCK_EXCEPTIONS;
}
-void QListBox::appendItem(const QString &text, ItemType type)
+void QListBox::appendItem(const QString &text, KWQListBoxItemType type)
{
_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).type == GroupLabel) ? 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;
@@ -599,7 +599,7 @@
- (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(int)row
{
- return _box && (_box->itemAtIndex(row).type != GroupLabel);
+ return _box && _box->itemAtIndex(row).type == KWQListBoxOption;
}
- (BOOL)selectionShouldChangeInTableView:(NSTableView *)aTableView
@@ -632,9 +632,9 @@
id <WebCoreTextRenderer> renderer;
if (isSystemFont) {
- renderer = (item.type == GroupLabel) ? groupLabelTextRenderer() : itemTextRenderer();
+ renderer = (item.type == KWQListBoxGroupLabel) ? groupLabelTextRenderer() : itemTextRenderer();
} else {
- if (item.type == GroupLabel) {
+ if (item.type == KWQListBoxGroupLabel) {
QFont boldFont = _box->font();
boldFont.setWeight(QFont::Bold);
font = boldFont.getNSFont();
1.2 +151 -50 WebCore/manual-tests/select_hr.html
Index: select_hr.html
===================================================================
RCS file: /cvs/root/WebCore/manual-tests/select_hr.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- select_hr.html 1 Sep 2005 17:40:14 -0000 1.1
+++ select_hr.html 2 Sep 2005 21:34:49 -0000 1.2
@@ -1,32 +1,83 @@
-<html>
-<body>
-These are some tests to make sure that adding an hr element in a select works properly.
-<br>Other good select & option tests are included in the W3C DOM tests.
-
-<br><br>Expected results: A disabled popup menu.
-<br><select id = "s1">
-<hr>
-</select>
-<input type="button" onclick="alert(document.getElementById('s1').length)" value ="Check length = 0"></input>
-
-<br>Expected results: A popup menu - separator, option, separator.
-<br><select id = "s2">
-<hr>
-<option>opt 1</option>
-<hr>
-</select>
-<input type="button" onclick="alert(document.getElementById('s2').length)" value="Check length = 1"></input>
-
-<br>Expected results: A popup menu - option, separator, option.
-<br><select id = "s3">
-<option>opt 1</option>
-<hr>
-<option>opt 2</option>
-</select>
-<input type="button" onclick="alert(document.getElementById('s3').length)" value="Check length = 2"></input>
-
-<br>Expected results: A popup menu - option, four separators, two options, separator, option.
-<br><select id = "s4">
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+ "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<script>
+ function getSelectInfo(myselect, mydiv) {
+ var s = document.getElementById(myselect);
+ var selectLength = s.length;
+ var optionCollectionLength = s.options.length;
+ var selectedInd = s.selectedIndex;
+ var opt = s.options[selectedInd];
+ var optText = "";
+
+ if (opt) {
+ optText = opt.innerHTML;
+ }
+
+ document.getElementById(mydiv).innerHTML = "Select length: " + selectLength + "<br>Option collection length: " + optionCollectionLength + "<br>Selected index: " + selectedInd + "<br>Selected option: " + optText;
+ }
+
+ function getAllInfo(x) {
+ for (i = 1; i < x; i++) {
+ var s = "s" + i;
+ var d = "d" + i;
+
+ getSelectInfo(s, d);
+ }
+ }
+</script>
+
+
+</head>
+<body onload="getAllInfo(12)">
+<p><b>BUG ID:</b> <a href="rdar://problem/4229189">4229189</a> add a way to get a separator into a select element</p>
+
+<p id="test" style="background-color:skyblue; padding:3px;"><b>STEPS TO TEST:</b>
+Please describe the steps required to test this bug here.
+</p>
+
+
+These tests make sure that adding an hr element in a select works properly.
+
+<p id="success" style="background-color:palegreen; padding:3px;"><b>TEST PASS:</b>This should be a disabled popup menu, since the hr is not selectable.
+</p>
+<p id="failure" style="background-color:#FF3300; padding:3px;"><b>TEST FAIL:</b> </p>
+<select id = "s1">
+<hr>
+</select>
+<div id="d1"></div>
+
+<p id="success" style="background-color:palegreen; padding:3px;"><b>TEST PASS:</b>
+You should see a popup menu with the following items: separator, option, separator
+</p>
+<p id="failure" style="background-color:#FF3300; padding:3px;"><b>TEST FAIL:</b>
+</p>
+<select id = "s2">
+<hr>
+<option>opt 1</option>
+<hr>
+</select>
+<div id="d2"></div>
+
+<p id="success" style="background-color:palegreen; padding:3px;"><b>TEST PASS:</b>
+You should see a popup menu with the following items: option, separator, option
+</p>
+<p id="failure" style="background-color:#FF3300; padding:3px;"><b>TEST FAIL:</b>
+</p>
+<select id = "s3">
+<option>opt 1</option>
+<hr>
+<option>opt 2</option>
+</select>
+<div id="d3"></div>
+
+<p id="success" style="background-color:palegreen; padding:3px;"><b>TEST PASS:</b>
+You should see a popup menu with the following items: option, four separators, two options, separator, option.
+</p>
+<p id="failure" style="background-color:#FF3300; padding:3px;"><b>TEST FAIL:</b>
+</p>
+<select id = "s4">
<option>opt 1</option>
<hr>
<hr>
@@ -37,28 +88,40 @@
<hr>
<option>opt 4</option>
</select>
-<input type="button" onclick="alert(document.getElementById('s4').length)" value="Check length = 4"></input>
+<div id="d4"></div>
-<br>Expected results: A popup menu - group label, option, separator (incl. in group).
-<br><select id = "s5">
+<p id="success" style="background-color:palegreen; padding:3px;"><b>TEST PASS:</b>
+You should see a popup menu with the following items: group label, option, separator (incl. in group).
+</p>
+<p id="failure" style="background-color:#FF3300; padding:3px;"><b>TEST FAIL:</b>
+</p>
+<select id = "s5">
<optgroup label="Group 1">
<option>opt 1</option>
<hr>
</optgroup>
</select>
-<input type="button" onclick="alert(document.getElementById('s5').length)" value="Check length = 1"></input>
+<div id="d5"></div>
-<br>Expected results: A popup menu - separator, group label, option.
-<br><select id = "s6">
+<p id="success" style="background-color:palegreen; padding:3px;"><b>TEST PASS:</b>
+You should see a popup menu with the following items: separator, group label, option.
+</p>
+<p id="failure" style="background-color:#FF3300; padding:3px;"><b>TEST FAIL:</b>
+</p>
+<select id = "s6">
<hr>
<optgroup label="Group 1">
<option>opt 1</option>
</optgroup>
</select>
-<input type="button" onclick="alert(document.getElementById('s6').length)" value="Check length = 1"></input>
+<div id="d6"></div>
-<br>Expected results: A popup menu - group label, option, separator, option, separator, option, two separators, (end of group), one option.
-<br><select id = "s7">
+<p id="success" style="background-color:palegreen; padding:3px;"><b>TEST PASS:</b>
+You should see a popup menu with the following items: group label, option, separator, option, separator, option, two separators, (end of group), one option.
+</p>
+<p id="failure" style="background-color:#FF3300; padding:3px;"><b>TEST FAIL:</b>
+</p>
+<select id = "s7">
<optgroup label="Group 1">
<option>opt 1</option>
<hr>
@@ -70,10 +133,15 @@
</optgroup>
<option>opt 4</option>
</select>
-<input type="button" onclick="alert(document.getElementById('s7').length)" value="Check length = 4"></input>
+<div id="d7"></div>
-<br>Expected results: A popup menu - group label, one option two separators, (end of group), separator, group label, separator, two options, separator, (end of group), option.
-<br><select id = "s8">
+<p id="success" style="background-color:palegreen; padding:3px;"><b>TEST PASS:</b>
+You should see a popup menu with the following items: group label, one option two separators, (end of group), separator, group label, separator, two options, separator, (end of group), option.
+</p>
+
+<p id="failure" style="background-color:#FF3300; padding:3px;"><b>TEST FAIL:</b>
+</p>
+<select id = "s8">
<optgroup label="Group 1">
<option>opt 1</option>
<hr>
@@ -88,17 +156,25 @@
</optgroup>
<option>opt 4</option>
</select>
-<input type="button" onclick="alert(document.getElementById('s8').length)" value="Check length = 4"></input>
+<div id="d8"></div>
-<br>Expected results: A disabled popup menu.
-<br><select id = "s9">
+<p id="success" style="background-color:palegreen; padding:3px;"><b>TEST PASS:</b>
+A disabled popup menu - since the optgroup and the hr are not selectable.
+</p>
+<p id="failure" style="background-color:#FF3300; padding:3px;"><b>TEST FAIL:</b>
+</p>
+<select id = "s9">
<optgroup label="Group 1">
<hr>
</optgroup>
</select>
-<input type="button" onclick="alert(document.getElementById('s9').length)" value="Check length = 0"></input>
+<div id="d9"></div>
-<br>Expected results: A list box - 4 options.
+<p id="success" style="background-color:palegreen; padding:3px;"><b>TEST PASS:</b>
+You should see a list box with the following items: 4 options.
+</p>
+<p id="failure" style="background-color:#FF3300; padding:3px;"><b>TEST FAIL:</b>
+You should not see any separators in the list box.</p>
<br><select id = "s10" multiple>
<option value="test">opt 1</option>
<hr>
@@ -110,10 +186,14 @@
<hr>
<option>opt 4</option>
</select>
-<input type="button" onclick="alert(document.getElementById('s10').length)" value="Check length = 4"></input>
+<div id="d10"></div>
-<br>Expected results: A list box - one option, group label, 3 options.
-<br><select id = "s11" multiple>
+<p id="success" style="background-color:palegreen; padding:3px;"><b>TEST PASS:</b>
+You should see a list box with the following items: one option, group label, 3 options.
+</p>
+<p id="failure" style="background-color:#FF3300; padding:3px;"><b>TEST FAIL:</b>
+You should not see any separators in the list box.</p>
+<select id = "s11" multiple>
<option value="test">opt 1</option>
<hr>
<hr>
@@ -126,7 +206,28 @@
<option>opt 4</option>
</optgroup>
</select>
-<input type="button" onclick="alert(document.getElementById('s11').length)" value="Check length = 4"></input>
+<div id="d11"></div>
+
+<p id="success" style="background-color:palegreen; padding:3px;"><b>TEST PASS:</b>
+For each of these list boxes, when you change the selection in JavaScript to index 1, the second option should get highlighted</p>
+<p id="failure" style="background-color:#FF3300; padding:3px;"><b>TEST FAIL:</b>
+"opt 2" does not get highlighted after clicking the button.</p>
+
+<select id="s12" multiple>
+<option id="o3">opt 1</option>
+<hr>
+<option id="o4">opt 2</option>
+</select>
+<input type="button" value="Change selection to 'opt 2'" onclick="document.getElementById('s12').selectedIndex = 1;"></input>
+
+<br><select id="s13" multiple>
+<option id="o5">opt 1</option>
+<hr>
+<optgroup label="group">
+<option id="o6">opt 2</option>
+</optgroup>
+</select>
+<input type="button" value="Change selection to 'opt 2'" onclick="document.getElementById('s13').selectedIndex = 1;"></input>
<body>
</html>
More information about the webkit-changes
mailing list