Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a8da1735 authored by Leon Scroggins's avatar Leon Scroggins
Browse files

Do not show radio/checkboxes for <optgroup> labels.

Fix for http://b/issue?id=2186188.  Keep track of <optgroup> labels
separately from disabled <option> labels.  Requires a change to
external/webkit.

In CheckedTextView, if the CheckMarkDrawable is set to null,
remove it.
parent 8785c064
Loading
Loading
Loading
Loading
+36 −10
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ import android.widget.AbsoluteLayout;
import android.widget.Adapter;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CheckedTextView;
import android.widget.FrameLayout;
import android.widget.ListView;
import android.widget.Scroller;
@@ -5299,8 +5300,16 @@ public class WebView extends AbsoluteLayout
        // Need these to provide stable ids to my ArrayAdapter,
        // which normally does not have stable ids. (Bug 1250098)
        private class Container extends Object {
            /**
             * Possible values for mEnabled.  Keep in sync with OptionStatus in
             * WebViewCore.cpp
             */
            final static int OPTGROUP = -1;
            final static int OPTION_DISABLED = 0;
            final static int OPTION_ENABLED = 1;

            String  mString;
            boolean mEnabled;
            int     mEnabled;
            int     mId;

            public String toString() {
@@ -5320,6 +5329,23 @@ public class WebView extends AbsoluteLayout
                            objects);
            }

            @Override
            public View getView(int position, View convertView,
                    ViewGroup parent) {
                // Always pass in null so that we will get a new CheckedTextView
                // Otherwise, an item which was previously used as an <optgroup>
                // element (i.e. has no check), could get used as an <option>
                // element, which needs a checkbox/radio, but it would not have
                // one.
                convertView = super.getView(position, null, parent);
                Container c = item(position);
                if (c != null && Container.OPTGROUP == c.mEnabled
                        && convertView instanceof CheckedTextView) {
                    ((CheckedTextView) convertView).setCheckMarkDrawable(null);
                }
                return convertView;
            }

            @Override
            public boolean hasStableIds() {
                // AdapterView's onChanged method uses this to determine whether
@@ -5355,12 +5381,11 @@ public class WebView extends AbsoluteLayout
                if (item == null) {
                    return false;
                }
                return item.mEnabled;
                return Container.OPTION_ENABLED == item.mEnabled;
            }
        }

        private InvokeListBox(String[] array,
                boolean[] enabled, int[] selected) {
        private InvokeListBox(String[] array, int[] enabled, int[] selected) {
            mMultiple = true;
            mSelectedArray = selected;

@@ -5374,8 +5399,7 @@ public class WebView extends AbsoluteLayout
            }
        }

        private InvokeListBox(String[] array, boolean[] enabled, int
                selection) {
        private InvokeListBox(String[] array, int[] enabled, int selection) {
            mSelection = selection;
            mMultiple = false;

@@ -5506,10 +5530,11 @@ public class WebView extends AbsoluteLayout
     * Request a dropdown menu for a listbox with multiple selection.
     *
     * @param array Labels for the listbox.
     * @param enabledArray  Which positions are enabled.
     * @param enabledArray  State for each element in the list.  See static
     *      integers in Container class.
     * @param selectedArray Which positions are initally selected.
     */
    void requestListBox(String[] array, boolean[]enabledArray, int[]
    void requestListBox(String[] array, int[] enabledArray, int[]
            selectedArray) {
        mPrivateHandler.post(
                new InvokeListBox(array, enabledArray, selectedArray));
@@ -5520,10 +5545,11 @@ public class WebView extends AbsoluteLayout
     * <select> element.
     *
     * @param array Labels for the listbox.
     * @param enabledArray  Which positions are enabled.
     * @param enabledArray  State for each element in the list.  See static
     *      integers in Container class.
     * @param selection Which position is initally selected.
     */
    void requestListBox(String[] array, boolean[]enabledArray, int selection) {
    void requestListBox(String[] array, int[] enabledArray, int selection) {
        mPrivateHandler.post(
                new InvokeListBox(array, enabledArray, selection));
    }
+2 −2
Original line number Diff line number Diff line
@@ -2141,7 +2141,7 @@ final class WebViewCore {
    private native void nativeSetGlobalBounds(int x, int y, int w, int h);

    // called by JNI
    private void requestListBox(String[] array, boolean[] enabledArray,
    private void requestListBox(String[] array, int[] enabledArray,
            int[] selectedArray) {
        if (mWebView != null) {
            mWebView.requestListBox(array, enabledArray, selectedArray);
@@ -2149,7 +2149,7 @@ final class WebViewCore {
    }

    // called by JNI
    private void requestListBox(String[] array, boolean[] enabledArray,
    private void requestListBox(String[] array, int[] enabledArray,
            int selection) {
        if (mWebView != null) {
            mWebView.requestListBox(array, enabledArray, selection);
+5 −5
Original line number Diff line number Diff line
@@ -117,11 +117,11 @@ public class CheckedTextView extends TextView implements Checkable {
     * @param d The Drawable to use for the checkmark.
     */
    public void setCheckMarkDrawable(Drawable d) {
        if (d != null) {
        if (mCheckMarkDrawable != null) {
            mCheckMarkDrawable.setCallback(null);
            unscheduleDrawable(mCheckMarkDrawable);
        }
        if (d != null) {
            d.setCallback(this);
            d.setVisible(getVisibility() == VISIBLE, false);
            d.setState(CHECKED_STATE_SET);
@@ -130,10 +130,10 @@ public class CheckedTextView extends TextView implements Checkable {
            mCheckMarkWidth = d.getIntrinsicWidth();
            mPaddingRight = mCheckMarkWidth + mBasePaddingRight;
            d.setState(getDrawableState());
            mCheckMarkDrawable = d;
        } else {
            mPaddingRight = mBasePaddingRight;
        }
        mCheckMarkDrawable = d;
        requestLayout();
    }