Title: [118228] trunk/Source/WebKit2
Revision
118228
Author
[email protected]
Date
2012-05-23 12:43:57 -0700 (Wed, 23 May 2012)

Log Message

[Qt][Wk2] Assertion failure when selecting an option in select list with size attribute greater than one
https://bugs.webkit.org/show_bug.cgi?id=86974

Patch by Dinu Jacob <[email protected]> on 2012-05-23
Reviewed by Simon Hausmann.

Select list with size attribute greater than one will not initially have any
item in selected state (if no option has 'selected' tag), resulting in
m_selectedModelIndex in WebPopupMenuProxyQt to be invalid. Hence, need to check
whether the old index is invalid before accessing the item at that index.

* UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_itemSelector.qml: Added new test that
  tests selection in a select list with size attribute value of 2.
* UIProcess/API/qt/tests/qmltests/common/selectwithsize.html: Added.
* UIProcess/qt/WebPopupMenuProxyQt.cpp:
(WebKit::PopupMenuItemModel::select): Check whether old index is valid before accessing
  the item at that index.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (118227 => 118228)


--- trunk/Source/WebKit2/ChangeLog	2012-05-23 19:41:16 UTC (rev 118227)
+++ trunk/Source/WebKit2/ChangeLog	2012-05-23 19:43:57 UTC (rev 118228)
@@ -1,3 +1,22 @@
+2012-05-23  Dinu Jacob  <[email protected]>
+
+        [Qt][Wk2] Assertion failure when selecting an option in select list with size attribute greater than one
+        https://bugs.webkit.org/show_bug.cgi?id=86974
+
+        Reviewed by Simon Hausmann.
+
+        Select list with size attribute greater than one will not initially have any
+        item in selected state (if no option has 'selected' tag), resulting in
+        m_selectedModelIndex in WebPopupMenuProxyQt to be invalid. Hence, need to check
+        whether the old index is invalid before accessing the item at that index.
+
+        * UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_itemSelector.qml: Added new test that
+          tests selection in a select list with size attribute value of 2.
+        * UIProcess/API/qt/tests/qmltests/common/selectwithsize.html: Added.
+        * UIProcess/qt/WebPopupMenuProxyQt.cpp:
+        (WebKit::PopupMenuItemModel::select): Check whether old index is valid before accessing
+          the item at that index.
+
 2012-05-23  Jer Noble  <[email protected]>
 
         REGRESSION (r116188): After exiting full screen, Safari window is frozen, then inline video speeds through frames as it catches up with audio

Modified: trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_itemSelector.qml (118227 => 118228)


--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_itemSelector.qml	2012-05-23 19:41:16 UTC (rev 118227)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_itemSelector.qml	2012-05-23 19:43:57 UTC (rev 118228)
@@ -107,5 +107,13 @@
             tryCompare(webView, "selectorLoaded", true)
             compare(webView.title, "No new selection was made")
         }
+
+        function test_selectWithSize() {
+            webView.url = ""
+            verify(webView.waitForLoadSucceeded())
+            titleSpy.clear()
+
+            test_selectFirstThenAcceptDirectly()
+        }
     }
 }

Added: trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/selectwithsize.html (0 => 118228)


--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/selectwithsize.html	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/selectwithsize.html	2012-05-23 19:43:57 UTC (rev 118228)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>No new selection was made</title>
+<script>
+function updateTitle(selectElement) {
+    var index = selectElement.selectedIndex;
+    document.title = selectElement.options[index].value;
+}
+</script>
+</head>
+<body>
+<select size=2 _onchange_="updateTitle(this)">
+<option value="__open__" >Open</option>
+<option value="__closed__" >Closed</option>
+<option value="__all__" >All</option>
+</select>
+</html>

Modified: trunk/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp (118227 => 118228)


--- trunk/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp	2012-05-23 19:41:16 UTC (rev 118227)
+++ trunk/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp	2012-05-23 19:43:57 UTC (rev 118228)
@@ -186,12 +186,15 @@
     if (!item.enabled)
         return;
 
-    Item& oldItem = m_items[oldIndex];
-    oldItem.selected = false;
     item.selected = true;
     m_selectedModelIndex = index;
 
-    emit dataChanged(this->index(oldIndex), this->index(oldIndex));
+    if (oldIndex != -1) {
+        Item& oldItem = m_items[oldIndex];
+        oldItem.selected = false;
+        emit dataChanged(this->index(oldIndex), this->index(oldIndex));
+    }
+
     emit dataChanged(this->index(index), this->index(index));
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to