Bug 48372
Summary: | Fix direct event type querying by using a generic event wrapper function | ||
---|---|---|---|
Product: | WebKit | Reporter: | Abhishek Arya <inferno> |
Component: | DOM | Assignee: | Nobody <webkit-unassigned> |
Status: | NEW | ||
Severity: | Normal | CC: | ahmad.saleem792, ap, bfulgham, dglazkov, rniwa |
Priority: | P2 | ||
Version: | 528+ (Nightly build) | ||
Hardware: | All | ||
OS: | All |
Abhishek Arya
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
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
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);