WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
70184
Change HTMLSelectElement::setSelectedIndex to use enums instead of bools
https://bugs.webkit.org/show_bug.cgi?id=70184
Summary
Change HTMLSelectElement::setSelectedIndex to use enums instead of bools
Darin Adler
Reported
2011-10-15 15:17:16 PDT
Many arguments to setSelectedIndex take boolean constants. Change them to use enums instead of bools.
Attachments
Patch
(19.82 KB, patch)
2011-10-18 10:08 PDT
,
Darin Adler
no flags
Details
Formatted Diff
Diff
Patch
(23.25 KB, patch)
2011-10-23 23:00 PDT
,
Darin Adler
no flags
Details
Formatted Diff
Diff
Patch
(22.42 KB, patch)
2011-10-25 18:45 PDT
,
Darin Adler
no flags
Details
Formatted Diff
Diff
Patch
(23.17 KB, patch)
2011-11-01 15:44 PDT
,
Darin Adler
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Darin Adler
Comment 1
2011-10-18 10:08:39 PDT
Created
attachment 111459
[details]
Patch
Ryosuke Niwa
Comment 2
2011-10-18 10:38:19 PDT
Comment on
attachment 111459
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=111459&action=review
> Source/WebCore/ChangeLog:8 > + No new tests. (OOPS!)
Please remove this. cq- because of this line.
> Source/WebCore/html/HTMLSelectElement.cpp:388 > + selectOption(index, LeaveOtherOptionsSelected, DoNotDispatchChangeEvent, NotUserDriven);
We can call setSelectedIndex(index, LeaveOtherOptionsSelected); here.
> Source/WebCore/html/HTMLSelectElement.cpp:766 > + m_isProcessingUserDrivenChange = userDrivenChange;
I'd prefer explicitly comparing userDrivenChange to UserDriven rather than implicitly coercing the enum to bool.
> Source/WebCore/html/HTMLSelectElement.cpp:1010 > + selectOption(listToOptionIndex(listIndex), DeselectOtherOptions, DoNotDispatchChangeEvent, UserDriven);
Seems like you can just call setSelectedIndex(listToOptionIndex(listIndex), DeselectOtherOptions);
> Source/WebCore/html/HTMLSelectElement.h:39 > +enum ShouldDeselectOtherOptions { LeaveOtherOptionsSelected, DeselectOtherOptions };
I'd prefer calling it KeepOtherOptionsSelectedIfAllowed given that selectOption can ignore this option when m_multiple is false.
Darin Adler
Comment 3
2011-10-18 11:47:36 PDT
Good suggestions. I’ll deal with this when I get back to the computer that happens to already have this patch on it.
Darin Adler
Comment 4
2011-10-23 22:58:31 PDT
Comment on
attachment 111459
[details]
Patch I’ve got a new better version of this that I’ll put up for review that goes a little bit further in renaming and refactoring as well as fixing everything Ryosuke mentioned.
Darin Adler
Comment 5
2011-10-23 23:00:13 PDT
Created
attachment 112152
[details]
Patch
Ryosuke Niwa
Comment 6
2011-10-24 11:55:48 PDT
Comment on
attachment 112152
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=112152&action=review
> Source/WebCore/ChangeLog:3 > + OBSOLETE CHANGE LOG NEEDS TO BE UPDATED (OOPS)
Please update the change log.
> Source/WebCore/html/HTMLSelectElement.cpp:749 > + selectOption(option->index(), DeselectOnlyToMaintainSingleOptionInvariant, DoNotDispatchChangeEvent, NotUserDriven);
Hm... DeselectOnlyToMaintainSingleOptionInvariant seems too verbose to me. How about DeselectIfMultiSelectIsDisallowed or DeselectIfOnlySingleSelectionIsAllowed (including their variants)?
> Source/WebCore/html/HTMLSelectElement.cpp:754 > +void HTMLSelectElement::selectOption(int optionIndex, ShouldDeselectOtherOptions deselectOptions, ShouldDispatchChangeEvent shouldDispatchChangeEvent, UserDrivenFlag userDrivenFlag)
"flag" makes me think of bit flags. I'd prefer calling it EUserDriven. Also I just recalled that FrameSelection already defines EUserTriggered. Maybe we should move that to EUserTriggered.h and reuse it here?
> Source/WebKit/chromium/ChangeLog:3 > + OBSOLETE CHANGE LOG NEEDS TO BE UPDATED (OOPS)
Please update the change log.
Darin Adler
Comment 7
2011-10-24 12:06:52 PDT
(In reply to
comment #6
)
> > + selectOption(option->index(), DeselectOnlyToMaintainSingleOptionInvariant, DoNotDispatchChangeEvent, NotUserDriven); > > Hm... DeselectOnlyToMaintainSingleOptionInvariant seems too verbose to me. How about DeselectIfMultiSelectIsDisallowed or DeselectIfOnlySingleSelectionIsAllowed (including their variants)?
So far I don’t like any of these, including the one I used. Note that they are all about 6 or 7 words. I do think the “only” is better than “if”. The ones with if don’t indicate what will be deselected very well.
> > +void HTMLSelectElement::selectOption(int optionIndex, ShouldDeselectOtherOptions deselectOptions, ShouldDispatchChangeEvent shouldDispatchChangeEvent, UserDrivenFlag userDrivenFlag) > > "flag" makes me think of bit flags
OK. This is a bit flag; just a single one. But sure, I will stay away from flag.
> I'd prefer calling it EUserDriven.
I am not a fan of that “E”.
> Also I just recalled that FrameSelection already defines EUserTriggered.
Sure, would be good to share that. Although there may be some subtle semantic difference.
Ryosuke Niwa
Comment 8
2011-10-24 13:32:17 PDT
Are you intending to upload a new patch for review? Or is the
attachment 112152
[details]
supposed to have r? ?
Darin Adler
Comment 9
2011-10-24 14:27:23 PDT
(In reply to
comment #8
)
> Are you intending to upload a new patch for review?
Yes. Not for a while, though.
> Or is the
attachment 112152
[details]
supposed to have r? ?
No. I hadn’t written change log yet, so didn’t put it up for review yet.
Darin Adler
Comment 10
2011-10-25 17:22:00 PDT
I think I should use a single set of flags instead of three separate arguments.
Darin Adler
Comment 11
2011-10-25 18:45:46 PDT
Created
attachment 112441
[details]
Patch
Darin Adler
Comment 12
2011-10-25 18:46:22 PDT
Still not up for review, still no change log.
Kent Tamura
Comment 13
2011-10-26 22:33:14 PDT
(In reply to
comment #10
)
> I think I should use a single set of flags instead of three separate arguments.
This looks good!
Darin Adler
Comment 14
2011-11-01 15:44:59 PDT
Created
attachment 113244
[details]
Patch
Kent Tamura
Comment 15
2011-11-01 19:13:30 PDT
Comment on
attachment 113244
[details]
Patch The patch improves the code readability very much!
WebKit Review Bot
Comment 16
2011-11-01 19:47:37 PDT
Comment on
attachment 113244
[details]
Patch Clearing flags on attachment: 113244 Committed
r99035
: <
http://trac.webkit.org/changeset/99035
>
WebKit Review Bot
Comment 17
2011-11-01 19:47:42 PDT
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug