WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
46950
Some bugs of search cancel button and spin button about state change in an event handler
https://bugs.webkit.org/show_bug.cgi?id=46950
Summary
Some bugs of search cancel button and spin button about state change in an ev...
Kent Tamura
Reported
2010-09-30 18:18:56 PDT
Search field cancel button keeps event capturing
Attachments
Patch
(10.12 KB, patch)
2010-09-30 20:18 PDT
,
Kent Tamura
no flags
Details
Formatted Diff
Diff
Patch 2
(14.55 KB, patch)
2010-11-05 00:38 PDT
,
Kent Tamura
no flags
Details
Formatted Diff
Diff
Patch 3
(14.67 KB, patch)
2010-11-05 00:54 PDT
,
Kent Tamura
no flags
Details
Formatted Diff
Diff
Patch 4 (rebased)
(14.75 KB, patch)
2010-12-13 21:31 PST
,
Kent Tamura
no flags
Details
Formatted Diff
Diff
Patch 5
(14.63 KB, patch)
2011-01-24 02:03 PST
,
Kent Tamura
no flags
Details
Formatted Diff
Diff
Show Obsolete
(4)
View All
Add attachment
proposed patch, testcase, etc.
Kent Tamura
Comment 1
2010-09-30 19:14:20 PDT
SearchFieldCancelButtonElement::defaultEventHandler and SpinButtonElement::defaultEventHandler calls focus(), which can change the element type, value, etc.
Kent Tamura
Comment 2
2010-09-30 20:18:03 PDT
Created
attachment 69417
[details]
Patch
Darin Adler
Comment 3
2010-11-04 12:56:57 PDT
Comment on
attachment 69417
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=69417&action=review
I’m going to say review+, but I think this can be improved and I’d be willing to review again if you post an improved version.
> WebCore/rendering/TextControlInnerElements.cpp:222 > + RefPtr<HTMLInputElement> protector(input);
Why not just make the local variable “input” be a RefPtr in the first place? The protector idiom should only be used when there’s no better option, and I think making the pointer be a RefPtr from the beginning is better.
> WebCore/rendering/TextControlInnerElements.cpp:227 > + // By an event handler, the input element might be removed or hidden, > + // the cancel button might be hidden, or the input type might be changed.
The grammar here is not great. You could say: “An event handler might remove or hide the input element, hide the cancel button, or change the input type.” But it would be even better to make it clearer what you mean by event handler. You are alluding to the fact that focus and select calls can invoke JavaScript, but this may not be clear to the person reading the code. So you could say: “Focusing and selecting the field may run JavaScript in response to the event. That code might remove or hide the input element, hide the cancel button, or change the input type.” But I’m not sure that list of specific the code can do is all that helpful, nor is the comment pointing clearly enough to the part of this function that was written to deal with those possibilities. I think the point here is that we protect “this” so that we can call renderer() and get access to m_capturing, and protect “input” so that we can call the select function even after calling the focus function.
> WebCore/rendering/TextControlInnerElements.cpp:276 > +void SpinButtonElement::detach()
Does the test case cover this? To be specific: Does the test fail if you remove this code?
> WebCore/rendering/TextControlInnerElements.cpp:314 > RefPtr<Node> protector(input);
Why not just make the local variable “input” be a RefPtr in the first place? The protector idiom should only be used when there’s no better option, and I think making the pointer be a RefPtr from the beginning is better.
> WebCore/rendering/TextControlInnerElements.cpp:318 > + // Input type might be changed by an event handler. This shadow node might be detached.
Again, I think a much better comment can be written.
Kent Tamura
Comment 4
2010-11-05 00:38:58 PDT
Created
attachment 73039
[details]
Patch 2
Kent Tamura
Comment 5
2010-11-05 00:48:41 PDT
Comment on
attachment 69417
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=69417&action=review
>> WebCore/rendering/TextControlInnerElements.cpp:222 >> + RefPtr<HTMLInputElement> protector(input); > > Why not just make the local variable “input” be a RefPtr in the first place? The protector idiom should only be used when there’s no better option, and I think making the pointer be a RefPtr from the beginning is better.
Oh, right. "input' should be a RefPtr. It's simpler.
>> WebCore/rendering/TextControlInnerElements.cpp:227 >> + // the cancel button might be hidden, or the input type might be changed. > > The grammar here is not great. > > You could say: “An event handler might remove or hide the input element, hide the cancel button, or change the input type.” > > But it would be even better to make it clearer what you mean by event handler. You are alluding to the fact that focus and select calls can invoke JavaScript, but this may not be clear to the person reading the code. > > So you could say: “Focusing and selecting the field may run JavaScript in response to the event. That code might remove or hide the input element, hide the cancel button, or change the input type.” > > But I’m not sure that list of specific the code can do is all that helpful, nor is the comment pointing clearly enough to the part of this function that was written to deal with those possibilities. I think the point here is that we protect “this” so that we can call renderer() and get access to m_capturing, and protect “input” so that we can call the select function even after calling the focus function.
I changed a way to fix the issue. I moved focus() and select() because I wanted to make sure the cancel button was visible before starting event capturing. The updated patch removes the visibility check in mouseup event, and doesn't change the mousedown event handling. It is much simpler. I removed the comment.
>> WebCore/rendering/TextControlInnerElements.cpp:276 >> +void SpinButtonElement::detach() > > Does the test case cover this? To be specific: Does the test fail if you remove this code?
Ah, no. I have added a test case for this.
>> WebCore/rendering/TextControlInnerElements.cpp:318 >> + // Input type might be changed by an event handler. This shadow node might be detached. > > Again, I think a much better comment can be written.
I have improved the comment.
Kent Tamura
Comment 6
2010-11-05 00:54:42 PDT
Created
attachment 73041
[details]
Patch 3
Kent Tamura
Comment 7
2010-12-13 21:31:01 PST
Created
attachment 76495
[details]
Patch 4 (rebased)
Kent Tamura
Comment 8
2011-01-24 02:03:22 PST
Created
attachment 79903
[details]
Patch 5 rebased
Dimitri Glazkov (Google)
Comment 9
2011-01-24 08:23:08 PST
Comment on
attachment 79903
[details]
Patch 5 ok
Kent Tamura
Comment 10
2011-01-24 20:36:37 PST
Comment on
attachment 79903
[details]
Patch 5 Clearing flags on attachment: 79903 Committed
r76566
: <
http://trac.webkit.org/changeset/76566
>
Kent Tamura
Comment 11
2011-01-24 20:36:46 PST
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