WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
48372
Fix direct event type querying by using a generic event wrapper function
https://bugs.webkit.org/show_bug.cgi?id=48372
Summary
Fix direct event type querying by using a generic event wrapper function
Abhishek Arya
Reported
2010-10-26 13:52:02 PDT
As per Dimitri's comments on bug
https://bugs.webkit.org/show_bug.cgi?id=48345
, we should prevent direct event-type() querying in various places e.g. void ImageEventListener::handleEvent(ScriptExecutionContext*, Event* event) { if (event->type() == eventNames().resizeEvent) m_doc->windowSizeChanged(); else if (event->type() == eventNames().clickEvent) { MouseEvent* mouseEvent = static_cast<MouseEvent*>(event); And replace with a generic wrapper like isMouseClickEvent(event) which does the 1) event type check - event->type() == eventNames().clickEvent 2) event cast check - event->isMouseEvent
Attachments
Add attachment
proposed patch, testcase, etc.
Ahmad Saleem
Comment 1
2022-08-11 14:54:59 PDT
When searching for "ImageEventListener", I can only find single source in Webkit Github:
https://github.com/WebKit/WebKit/blob/50d7e0b0b808afca93e5ede9cd7c0d44b1ed8130/Source/WebCore/html/ImageDocument.cpp#L62
Is this in relation to above? Or this is no longer applicable. Thanks!
Alexey Proskuryakov
Comment 2
2022-08-19 19:53:42 PDT
We don't have this idea implemented, but we use safer casting. I'll leave it to others to decide if this is still worth tracking. Currently, the code looks like this: void ImageEventListener::handleEvent(ScriptExecutionContext&, Event& event) { if (event.type() == eventNames().resizeEvent) m_document.windowSizeChanged(); else if (event.type() == eventNames().clickEvent && is<MouseEvent>(event)) { MouseEvent& mouseEvent = downcast<MouseEvent>(event);
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