[iOS] iPhone should not allow selecting <optgroup> in <select multiple>
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Oct 2014 19:05:32 +0000 (19:05 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Oct 2014 19:05:32 +0000 (19:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=137991

Reviewed by Darin Adler.

We seem to be getting the delegate when we are not supposed to.
Workaround the issue as best we can by reseting the styles
for the group's content view and not changing selections.

* UIProcess/ios/forms/WKFormSelectPicker.mm:
(-[WKMultipleSelectPicker pickerView:row:column:checked:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@175266 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/ios/forms/WKFormSelectPicker.mm

index 5794cec..b6a2948 100644 (file)
@@ -1,3 +1,17 @@
+2014-10-28  Joseph Pecoraro  <pecoraro@apple.com>
+
+        [iOS] iPhone should not allow selecting <optgroup> in <select multiple>
+        https://bugs.webkit.org/show_bug.cgi?id=137991
+
+        Reviewed by Darin Adler.
+
+        We seem to be getting the delegate when we are not supposed to.
+        Workaround the issue as best we can by reseting the styles
+        for the group's content view and not changing selections.
+
+        * UIProcess/ios/forms/WKFormSelectPicker.mm:
+        (-[WKMultipleSelectPicker pickerView:row:column:checked:]):
+
 2014-10-28  Tim Horton  <timothy_horton@apple.com>
 
         Remove an inaccurate comment in WKActionMenuController
index 7568026..30ead04 100644 (file)
@@ -42,6 +42,7 @@
 using namespace WebKit;
 
 static const float DisabledOptionAlpha = 0.3;
+static const float GroupOptionTextColorAlpha = 0.5;
 
 @interface UIPickerView (UIPickerViewInternal)
 - (BOOL)allowsMultipleSelection;
@@ -110,7 +111,7 @@ static const float DisabledOptionAlpha = 0.3;
 
     [[self titleLabel] setText:trimmedText];
     [self setChecked:NO];
-    [[self titleLabel] setTextColor:[UIColor colorWithWhite:0.0 alpha:0.5]];
+    [[self titleLabel] setTextColor:[UIColor colorWithWhite:0.0 alpha:GroupOptionTextColorAlpha]];
     [self setDisabled:YES];
 
     return self;
@@ -279,6 +280,17 @@ static const float DisabledOptionAlpha = 0.3;
 
     OptionItem& item = [_view assistedNodeSelectOptions][rowIndex];
 
+    // FIXME: Remove this workaround once <rdar://problem/18745253> is fixed.
+    // Group rows should not be checkable, but we are getting this delegate for
+    // those rows. As a workaround, if we get this delegate for a group row, reset
+    // the styles for the content view so it still appears unselected.
+    if (item.isGroup) {
+        UIPickerContentView *view = (UIPickerContentView *)[self viewForRow:rowIndex forComponent:columnIndex];
+        [view setChecked:NO];
+        [[view titleLabel] setTextColor:[UIColor colorWithWhite:0.0 alpha:GroupOptionTextColorAlpha]];
+        return;
+    }
+
     if ([self allowsMultipleSelection]) {
         [_view page]->setAssistedNodeSelectedIndex([self findItemIndexAt:rowIndex], true);
         item.isSelected = isChecked;