Closed
Bug 663461
Opened 15 years ago
Closed 15 years ago
Kill AddEventListenerByIID/RemoveEventListenerByIID from editor and embedding
Categories
(Core :: DOM: Events, defect)
Core
DOM: Events
Tracking
()
RESOLVED
FIXED
People
(Reporter: sicking, Assigned: sicking)
References
Details
Attachments
(2 files, 2 obsolete files)
|
26.10 KB,
patch
|
smaug
:
review+
|
Details | Diff | Splinter Review |
|
12.39 KB,
patch
|
smaug
:
review+
|
Details | Diff | Splinter Review |
First couple of patches for bug 661297
Attachment #538554 -
Flags: review?(Olli.Pettay)
| Assignee | ||
Comment 1•15 years ago
|
||
Assignee: nobody → jonas
Attachment #538555 -
Flags: review?(Olli.Pettay)
| Assignee | ||
Comment 2•15 years ago
|
||
The surprising part to me was that this actually *reduces* the amount of code that we have. I would have thought that having to register for each individual event would add to it, but it turns out not be less than the amount of code removed.
Comment 3•15 years ago
|
||
This is tricky to review. Need to make sure that the event is always
QIed to right interface before handling it.
| Assignee | ||
Comment 4•15 years ago
|
||
How do you mean? All the functions on nsIDOMMouseListener etc take a nsIDOMEvent, as does nsIDOMEventListener::HandleEvent.
Comment 5•15 years ago
|
||
It just happens to be a side-effect of nsIDOM***Listener interfaces that the
type of the event is checked before the listener is called.
(That check has been there forever)
| Assignee | ||
Comment 6•15 years ago
|
||
Oh, so we need to make sure that the event is QI*able* to the correct interface?
Doesn't the fact that we only listen to trusted events make sure that that is the case?
Comment 7•15 years ago
|
||
Trusted events don't guarantee anything about interfaces, but sure,
it would be chrome script which would be firing strange events.
| Assignee | ||
Comment 8•15 years ago
|
||
Oh, one thing I should fix in both these patches is to explicitly specify the aWantsUntrusted parameter to PR_FALSE.
Probably by adding another inline AddEventListener to nsIDOMEventTarget which takes both aCapture and aWantsUntrusted and forwards to the existing AddEventListener with aOptionalCount set to 2.
Let me know if you want new patches for that.
Comment 9•15 years ago
|
||
(In reply to comment #8)
> Oh, one thing I should fix in both these patches is to explicitly specify
> the aWantsUntrusted parameter to PR_FALSE.
I don't understand this?
Currently some of the listeners handle also untrusted events.
That is a bug, but should be fixed in a different bug.
Comment 10•15 years ago
|
||
Er, I was wrong.
Comment 11•15 years ago
|
||
The IID listeners don't listen for trusted events.
So yes, I'd like to see a new patch.
| Assignee | ||
Comment 12•15 years ago
|
||
Attachment #538554 -
Attachment is obsolete: true
Attachment #538554 -
Flags: review?(Olli.Pettay)
Attachment #538943 -
Flags: review?(Olli.Pettay)
| Assignee | ||
Comment 13•15 years ago
|
||
Attachment #538555 -
Attachment is obsolete: true
Attachment #538555 -
Flags: review?(Olli.Pettay)
Attachment #538944 -
Flags: review?(Olli.Pettay)
| Assignee | ||
Comment 14•15 years ago
|
||
I just verified that all HandleEvent functions can handle events of the wrong type.
The only one that was a bit doubtful (the event got spread further than I was comfortable with) was ChromeContextMenuListener::HandleEvent, so I added
nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aMouseEvent);
NS_ENSURE_TRUE(mouseEvent, NS_ERROR_UNEXPECTED);
to the top of that function locally. Let me know if you want a new patch.
Comment 15•15 years ago
|
||
Comment on attachment 538943 [details] [diff] [review]
Remove from editor
> nsEditor::CreateEventListeners()
> {
> // Don't create the handler twice
>- if (mEventListener)
>- return NS_OK;
>- mEventListener = do_QueryInterface(
>- static_cast<nsIDOMKeyListener*>(new nsEditorEventListener()));
>- NS_ENSURE_TRUE(mEventListener, NS_ERROR_OUT_OF_MEMORY);
>+ if (!mEventListener)
>+ mEventListener = new nsEditorEventListener();
if (expr) {
stmt;
}
> nsHTMLEditor::CreateEventListeners()
> {
> // Don't create the handler twice
>- if (mEventListener)
>- return NS_OK;
>- mEventListener = do_QueryInterface(
>- static_cast<nsIDOMKeyListener*>(new nsHTMLEditorEventListener()));
>- NS_ENSURE_TRUE(mEventListener, NS_ERROR_OUT_OF_MEMORY);
>+ if (!mEventListener)
>+ mEventListener = new nsHTMLEditorEventListener();
Ditto
Attachment #538943 -
Flags: review?(Olli.Pettay) → review+
Comment 16•15 years ago
|
||
Comment on attachment 538944 [details] [diff] [review]
Remove from embedding
>+NS_IMETHODIMP
>+ChromeTooltipListener::HandleEvent(nsIDOMEvent* aEvent)
>+{
>+ nsAutoString eventType;
>+ aEvent->GetType(eventType);
You should check that eEvent is key or mouse event
(depending on the event type)
Attachment #538944 -
Flags: review?(Olli.Pettay) → review+
| Assignee | ||
Comment 17•15 years ago
|
||
(In reply to comment #16)
> >+NS_IMETHODIMP
> >+ChromeTooltipListener::HandleEvent(nsIDOMEvent* aEvent)
> >+{
> >+ nsAutoString eventType;
> >+ aEvent->GetType(eventType);
> You should check that eEvent is key or mouse event
> (depending on the event type)
The code that doesn't check the type doesn't use the event object at all. Doesn't seem worth it to check that it's of the right type then.
The MouseMove function does use the event object and does check its type.
Let me know if you still want something changed.
| Assignee | ||
Comment 18•15 years ago
|
||
Landed the editor part:
http://hg.mozilla.org/mozilla-central/rev/347d715650f6
Comment 19•15 years ago
|
||
(In reply to comment #17)
> The code that doesn't check the type doesn't use the event object at all.
> Doesn't seem worth it to check that it's of the right type then.
Technically you're changing the behavior then, since non-key events
can trigger the code.
Though, in practice it shouldn't matter. r=me
| Assignee | ||
Comment 20•15 years ago
|
||
http://hg.mozilla.org/integration/mozilla-inbound/rev/ec503528d2ef
Checked in to mozilla-inbound. Thanks for review!
Comment 21•15 years ago
|
||
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•