Title: [174178] trunk/Source
Revision
174178
Author
cdu...@apple.com
Date
2014-10-01 15:29:14 -0700 (Wed, 01 Oct 2014)

Log Message

Use is<>() / downcast<>() for Event classes
https://bugs.webkit.org/show_bug.cgi?id=137284

Reviewed by Andreas Kling.

Use is<>() / downcast<>() for Event classes.

Source/WebCore:

No new tests, no behavior change.

* bindings/js/JSErrorHandler.cpp:
(WebCore::JSErrorHandler::handleEvent):
* bindings/js/JSEventListener.cpp:
(WebCore::JSEventListener::handleEvent):
* dom/BeforeTextInsertedEvent.h:
* dom/BeforeUnloadEvent.h:
* dom/ErrorEvent.h:
* dom/Event.h:
* dom/EventContext.cpp:
(WebCore::MouseOrFocusEventContext::handleLocalEvents):
* dom/FocusEvent.h:
* dom/KeyboardEvent.cpp:
(WebCore::findKeyboardEvent):
* dom/KeyboardEvent.h:
* dom/MouseEvent.cpp:
(WebCore::SimulatedMouseEvent::SimulatedMouseEvent):
* dom/MouseEvent.h:
* dom/Node.cpp:
(WebCore::Node::defaultEventHandler):
* dom/TextEvent.h:
* dom/UIEvent.h:
* dom/WheelEvent.h:
* html/HTMLAnchorElement.cpp:
(WebCore::appendServerMapMousePosition):
(WebCore::HTMLAnchorElement::defaultEventHandler):
(WebCore::HTMLAnchorElement::eventType):
(WebCore::isEnterKeyKeydownEvent):
(WebCore::isLinkClick):
* html/HTMLButtonElement.cpp:
(WebCore::HTMLButtonElement::defaultEventHandler):
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::submitImplicitly):
* html/HTMLFormElement.h:
* html/HTMLFrameSetElement.cpp:
(WebCore::HTMLFrameSetElement::defaultEventHandler):
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::willDispatchEvent):
(WebCore::HTMLInputElement::defaultEventHandler):
* html/HTMLPlugInImageElement.cpp:
(WebCore::HTMLPlugInImageElement::defaultEventHandler):
* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::menuListDefaultEventHandler):
(WebCore::HTMLSelectElement::listBoxDefaultEventHandler):
(WebCore::HTMLSelectElement::defaultEventHandler):
* html/HTMLSummaryElement.cpp:
(WebCore::HTMLSummaryElement::defaultEventHandler):
* html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::defaultEventHandler):
* html/ImageDocument.cpp:
(WebCore::ImageEventListener::handleEvent):
* html/ImageInputType.cpp:
(WebCore::ImageInputType::handleDOMActivateEvent):
* html/InputType.cpp:
(WebCore::InputType::shouldSubmitImplicitly):
* html/InputType.h:
* html/MediaDocument.cpp:
(WebCore::MediaDocument::defaultEventHandler):
* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::shouldSubmitImplicitly):
* html/TextFieldInputType.h:
* html/shadow/MediaControlElementTypes.cpp:
(WebCore::MediaControlVolumeSliderElement::defaultEventHandler):
* html/shadow/MediaControlElements.cpp:
(WebCore::MediaControlPanelElement::defaultEventHandler):
(WebCore::MediaControlVolumeSliderContainerElement::defaultEventHandler):
(WebCore::MediaControlTimelineElement::defaultEventHandler):
* html/shadow/MediaControls.cpp:
(WebCore::MediaControls::containsRelatedTarget):
* html/shadow/MediaControlsApple.cpp:
(WebCore::MediaControlsAppleEventListener::handleEvent):
* html/shadow/SliderThumbElement.cpp:
(WebCore::SliderThumbElement::defaultEventHandler):
* html/shadow/SpinButtonElement.cpp:
(WebCore::SpinButtonElement::defaultEventHandler):
(WebCore::SpinButtonElement::forwardEvent):
* html/shadow/TextControlInnerElements.cpp:
(WebCore::SearchFieldResultsButtonElement::defaultEventHandler):
(WebCore::SearchFieldCancelButtonElement::defaultEventHandler):
* inspector/InspectorFrontendHost.cpp:
(WebCore::InspectorFrontendHost::dispatchEventAsContextMenuEvent):
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::maybeCreateContextMenu):
* page/EventHandler.cpp:
(WebCore::EventHandler::handleTextInputEvent):
* rendering/RenderEmbeddedObject.cpp:
(WebCore::RenderEmbeddedObject::isInUnavailablePluginIndicator):
(WebCore::RenderEmbeddedObject::handleUnavailablePluginIndicatorEvent):
* rendering/RenderEmbeddedObject.h:
* rendering/RenderSnapshottedPlugIn.cpp:
(WebCore::RenderSnapshottedPlugIn::handleEvent):

Source/WebKit2:

* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::handleEvent):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (174177 => 174178)


--- trunk/Source/WebCore/ChangeLog	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/ChangeLog	2014-10-01 22:29:14 UTC (rev 174178)
@@ -1,3 +1,105 @@
+2014-10-01  Christophe Dumez  <cdu...@apple.com>
+
+        Use is<>() / downcast<>() for Event classes
+        https://bugs.webkit.org/show_bug.cgi?id=137284
+
+        Reviewed by Andreas Kling.
+
+        Use is<>() / downcast<>() for Event classes.
+
+        No new tests, no behavior change.
+
+        * bindings/js/JSErrorHandler.cpp:
+        (WebCore::JSErrorHandler::handleEvent):
+        * bindings/js/JSEventListener.cpp:
+        (WebCore::JSEventListener::handleEvent):
+        * dom/BeforeTextInsertedEvent.h:
+        * dom/BeforeUnloadEvent.h:
+        * dom/ErrorEvent.h:
+        * dom/Event.h:
+        * dom/EventContext.cpp:
+        (WebCore::MouseOrFocusEventContext::handleLocalEvents):
+        * dom/FocusEvent.h:
+        * dom/KeyboardEvent.cpp:
+        (WebCore::findKeyboardEvent):
+        * dom/KeyboardEvent.h:
+        * dom/MouseEvent.cpp:
+        (WebCore::SimulatedMouseEvent::SimulatedMouseEvent):
+        * dom/MouseEvent.h:
+        * dom/Node.cpp:
+        (WebCore::Node::defaultEventHandler):
+        * dom/TextEvent.h:
+        * dom/UIEvent.h:
+        * dom/WheelEvent.h:
+        * html/HTMLAnchorElement.cpp:
+        (WebCore::appendServerMapMousePosition):
+        (WebCore::HTMLAnchorElement::defaultEventHandler):
+        (WebCore::HTMLAnchorElement::eventType):
+        (WebCore::isEnterKeyKeydownEvent):
+        (WebCore::isLinkClick):
+        * html/HTMLButtonElement.cpp:
+        (WebCore::HTMLButtonElement::defaultEventHandler):
+        * html/HTMLFormElement.cpp:
+        (WebCore::HTMLFormElement::submitImplicitly):
+        * html/HTMLFormElement.h:
+        * html/HTMLFrameSetElement.cpp:
+        (WebCore::HTMLFrameSetElement::defaultEventHandler):
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::willDispatchEvent):
+        (WebCore::HTMLInputElement::defaultEventHandler):
+        * html/HTMLPlugInImageElement.cpp:
+        (WebCore::HTMLPlugInImageElement::defaultEventHandler):
+        * html/HTMLSelectElement.cpp:
+        (WebCore::HTMLSelectElement::menuListDefaultEventHandler):
+        (WebCore::HTMLSelectElement::listBoxDefaultEventHandler):
+        (WebCore::HTMLSelectElement::defaultEventHandler):
+        * html/HTMLSummaryElement.cpp:
+        (WebCore::HTMLSummaryElement::defaultEventHandler):
+        * html/HTMLTextAreaElement.cpp:
+        (WebCore::HTMLTextAreaElement::defaultEventHandler):
+        * html/ImageDocument.cpp:
+        (WebCore::ImageEventListener::handleEvent):
+        * html/ImageInputType.cpp:
+        (WebCore::ImageInputType::handleDOMActivateEvent):
+        * html/InputType.cpp:
+        (WebCore::InputType::shouldSubmitImplicitly):
+        * html/InputType.h:
+        * html/MediaDocument.cpp:
+        (WebCore::MediaDocument::defaultEventHandler):
+        * html/TextFieldInputType.cpp:
+        (WebCore::TextFieldInputType::shouldSubmitImplicitly):
+        * html/TextFieldInputType.h:
+        * html/shadow/MediaControlElementTypes.cpp:
+        (WebCore::MediaControlVolumeSliderElement::defaultEventHandler):
+        * html/shadow/MediaControlElements.cpp:
+        (WebCore::MediaControlPanelElement::defaultEventHandler):
+        (WebCore::MediaControlVolumeSliderContainerElement::defaultEventHandler):
+        (WebCore::MediaControlTimelineElement::defaultEventHandler):
+        * html/shadow/MediaControls.cpp:
+        (WebCore::MediaControls::containsRelatedTarget):
+        * html/shadow/MediaControlsApple.cpp:
+        (WebCore::MediaControlsAppleEventListener::handleEvent):
+        * html/shadow/SliderThumbElement.cpp:
+        (WebCore::SliderThumbElement::defaultEventHandler):
+        * html/shadow/SpinButtonElement.cpp:
+        (WebCore::SpinButtonElement::defaultEventHandler):
+        (WebCore::SpinButtonElement::forwardEvent):
+        * html/shadow/TextControlInnerElements.cpp:
+        (WebCore::SearchFieldResultsButtonElement::defaultEventHandler):
+        (WebCore::SearchFieldCancelButtonElement::defaultEventHandler):
+        * inspector/InspectorFrontendHost.cpp:
+        (WebCore::InspectorFrontendHost::dispatchEventAsContextMenuEvent):
+        * page/ContextMenuController.cpp:
+        (WebCore::ContextMenuController::maybeCreateContextMenu):
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::handleTextInputEvent):
+        * rendering/RenderEmbeddedObject.cpp:
+        (WebCore::RenderEmbeddedObject::isInUnavailablePluginIndicator):
+        (WebCore::RenderEmbeddedObject::handleUnavailablePluginIndicatorEvent):
+        * rendering/RenderEmbeddedObject.h:
+        * rendering/RenderSnapshottedPlugIn.cpp:
+        (WebCore::RenderSnapshottedPlugIn::handleEvent):
+
 2014-10-01  Zan Dobersek  <zdober...@igalia.com>
 
         [TexMap] Sprinkle range-based for-loops in GraphicsLayerTextureMapper, TextureMapperLayer

Modified: trunk/Source/WebCore/bindings/js/JSErrorHandler.cpp (174177 => 174178)


--- trunk/Source/WebCore/bindings/js/JSErrorHandler.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/bindings/js/JSErrorHandler.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -59,14 +59,14 @@
 void JSErrorHandler::handleEvent(ScriptExecutionContext* scriptExecutionContext, Event* event)
 {
 
-    if (event->eventInterface() != ErrorEventInterfaceType)
+    if (!is<ErrorEvent>(event))
         return JSEventListener::handleEvent(scriptExecutionContext, event);
 
     ASSERT(scriptExecutionContext);
     if (!scriptExecutionContext)
         return;
 
-    ErrorEvent* errorEvent = toErrorEvent(event);
+    ErrorEvent& errorEvent = downcast<ErrorEvent>(*event);
 
     JSLockHolder lock(scriptExecutionContext->vm());
 
@@ -90,10 +90,10 @@
         globalObject->setCurrentEvent(event);
 
         MarkedArgumentBuffer args;
-        args.append(jsStringWithCache(exec, errorEvent->message()));
-        args.append(jsStringWithCache(exec, errorEvent->filename()));
-        args.append(jsNumber(errorEvent->lineno()));
-        args.append(jsNumber(errorEvent->colno()));
+        args.append(jsStringWithCache(exec, errorEvent.message()));
+        args.append(jsStringWithCache(exec, errorEvent.filename()));
+        args.append(jsNumber(errorEvent.lineno()));
+        args.append(jsNumber(errorEvent.colno()));
 
         VM& vm = globalObject->vm();
         VMEntryScope entryScope(vm, vm.entryScope ? vm.entryScope->globalObject() : globalObject);

Modified: trunk/Source/WebCore/bindings/js/JSEventListener.cpp (174177 => 174178)


--- trunk/Source/WebCore/bindings/js/JSEventListener.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/bindings/js/JSEventListener.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -141,8 +141,8 @@
             event->target()->uncaughtExceptionInEventHandler();
             reportException(exec, exception);
         } else {
-            if (!retval.isUndefinedOrNull() && event->isBeforeUnloadEvent())
-                toBeforeUnloadEvent(event)->setReturnValue(retval.toString(exec)->value(exec));
+            if (!retval.isUndefinedOrNull() && is<BeforeUnloadEvent>(event))
+                downcast<BeforeUnloadEvent>(*event).setReturnValue(retval.toString(exec)->value(exec));
             if (m_isAttribute) {
                 if (retval.isFalse())
                     event->preventDefault();

Modified: trunk/Source/WebCore/dom/BeforeTextInsertedEvent.h (174177 => 174178)


--- trunk/Source/WebCore/dom/BeforeTextInsertedEvent.h	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/dom/BeforeTextInsertedEvent.h	2014-10-01 22:29:14 UTC (rev 174178)
@@ -51,8 +51,8 @@
     String m_text;
 };
 
-EVENT_TYPE_CASTS(BeforeTextInsertedEvent)
+} // namespace WebCore
 
-} // namespace
+SPECIALIZE_TYPE_TRAITS_EVENT(BeforeTextInsertedEvent)
 
 #endif

Modified: trunk/Source/WebCore/dom/BeforeUnloadEvent.h (174177 => 174178)


--- trunk/Source/WebCore/dom/BeforeUnloadEvent.h	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/dom/BeforeUnloadEvent.h	2014-10-01 22:29:14 UTC (rev 174178)
@@ -51,8 +51,8 @@
     String m_returnValue;
 };
 
-EVENT_TYPE_CASTS(BeforeUnloadEvent)
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_EVENT(BeforeUnloadEvent)
+
 #endif // BeforeUnloadEvent_h

Modified: trunk/Source/WebCore/dom/ErrorEvent.h (174177 => 174178)


--- trunk/Source/WebCore/dom/ErrorEvent.h	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/dom/ErrorEvent.h	2014-10-01 22:29:14 UTC (rev 174178)
@@ -81,8 +81,8 @@
     unsigned m_columnNumber;
 };
 
-EVENT_TYPE_CASTS(ErrorEvent)
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_EVENT(ErrorEvent)
+
 #endif // ErrorEvent_h

Modified: trunk/Source/WebCore/dom/Event.h (174177 => 174178)


--- trunk/Source/WebCore/dom/Event.h	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/dom/Event.h	2014-10-01 22:29:14 UTC (rev 174178)
@@ -30,6 +30,7 @@
 #include <wtf/HashMap.h>
 #include <wtf/ListHashSet.h>
 #include <wtf/RefCounted.h>
+#include <wtf/TypeCasts.h>
 #include <wtf/text/AtomicString.h>
 
 namespace WebCore {
@@ -205,10 +206,11 @@
     RefPtr<Event> m_underlyingEvent;
 };
 
-#define EVENT_TYPE_CASTS(ToValueTypeName) \
-    TYPE_CASTS_BASE(ToValueTypeName, Event, event, event->is##ToValueTypeName(), event.is##ToValueTypeName())
+} // namespace WebCore
 
+#define SPECIALIZE_TYPE_TRAITS_EVENT(ToValueTypeName) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToValueTypeName) \
+    static bool isType(const WebCore::Event& event) { return event.is##ToValueTypeName(); } \
+SPECIALIZE_TYPE_TRAITS_END()
 
-} // namespace WebCore
-
 #endif // Event_h

Modified: trunk/Source/WebCore/dom/EventContext.cpp (174177 => 174178)


--- trunk/Source/WebCore/dom/EventContext.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/dom/EventContext.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -76,12 +76,12 @@
 
 void MouseOrFocusEventContext::handleLocalEvents(Event& event) const
 {
-    ASSERT(event.isMouseEvent() || event.isFocusEvent());
+    ASSERT(is<MouseEvent>(event) || is<FocusEvent>(event));
     if (m_relatedTarget) {
-        if (event.isMouseEvent())
-            toMouseEvent(event).setRelatedTarget(m_relatedTarget.get());
-        else if (event.isFocusEvent())
-            toFocusEvent(event).setRelatedTarget(m_relatedTarget.get());
+        if (is<MouseEvent>(event))
+            downcast<MouseEvent>(event).setRelatedTarget(m_relatedTarget.get());
+        else if (is<FocusEvent>(event))
+            downcast<FocusEvent>(event).setRelatedTarget(m_relatedTarget.get());
     }
     EventContext::handleLocalEvents(event);
 }
@@ -111,8 +111,8 @@
     checkReachability(m_targetTouches.get());
     checkReachability(m_changedTouches.get());
 #endif
-    ASSERT(event.isTouchEvent());
-    TouchEvent& touchEvent = toTouchEvent(event);
+    ASSERT(is<TouchEvent>(event));
+    TouchEvent& touchEvent = downcast<TouchEvent>(event);
     touchEvent.setTouches(m_touches);
     touchEvent.setTargetTouches(m_targetTouches);
     touchEvent.setChangedTouches(m_changedTouches);

Modified: trunk/Source/WebCore/dom/EventDispatcher.cpp (174177 => 174178)


--- trunk/Source/WebCore/dom/EventDispatcher.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/dom/EventDispatcher.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -342,8 +342,8 @@
     if (EventTarget* relatedTarget = event->relatedTarget())
         eventPath.setRelatedTarget(*node, *relatedTarget);
 #if ENABLE(TOUCH_EVENTS) && !PLATFORM(IOS)
-    if (event->isTouchEvent()) {
-        if (!eventPath.updateTouchLists(*toTouchEvent(event.get())))
+    if (is<TouchEvent>(*event)) {
+        if (!eventPath.updateTouchLists(downcast<TouchEvent>(*event)))
             return true;
     }
 #endif

Modified: trunk/Source/WebCore/dom/FocusEvent.h (174177 => 174178)


--- trunk/Source/WebCore/dom/FocusEvent.h	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/dom/FocusEvent.h	2014-10-01 22:29:14 UTC (rev 174178)
@@ -70,8 +70,8 @@
     RefPtr<EventTarget> m_relatedTarget;
 };
 
-EVENT_TYPE_CASTS(FocusEvent)
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_EVENT(FocusEvent)
+
 #endif // FocusEvent_h

Modified: trunk/Source/WebCore/dom/KeyboardEvent.cpp (174177 => 174178)


--- trunk/Source/WebCore/dom/KeyboardEvent.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/dom/KeyboardEvent.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -220,9 +220,9 @@
 KeyboardEvent* findKeyboardEvent(Event* event)
 {
     for (Event* e = event; e; e = e->underlyingEvent())
-        if (e->isKeyboardEvent())
-            return toKeyboardEvent(e);
-    return 0;
+        if (is<KeyboardEvent>(e))
+            return downcast<KeyboardEvent>(e);
+    return nullptr;
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/dom/KeyboardEvent.h (174177 => 174178)


--- trunk/Source/WebCore/dom/KeyboardEvent.h	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/dom/KeyboardEvent.h	2014-10-01 22:29:14 UTC (rev 174178)
@@ -119,10 +119,10 @@
 #endif
 };
 
-EVENT_TYPE_CASTS(KeyboardEvent)
-
 KeyboardEvent* findKeyboardEvent(Event*);
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_EVENT(KeyboardEvent)
+
 #endif // KeyboardEvent_h

Modified: trunk/Source/WebCore/dom/MouseEvent.cpp (174177 => 174178)


--- trunk/Source/WebCore/dom/MouseEvent.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/dom/MouseEvent.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -276,10 +276,10 @@
     }
     setUnderlyingEvent(underlyingEvent);
 
-    if (this->underlyingEvent() && this->underlyingEvent()->isMouseEvent()) {
-        MouseEvent* mouseEvent = toMouseEvent(this->underlyingEvent());
-        m_screenLocation = mouseEvent->screenLocation();
-        initCoordinates(mouseEvent->clientLocation());
+    if (this->underlyingEvent() && is<MouseEvent>(this->underlyingEvent())) {
+        MouseEvent& mouseEvent = downcast<MouseEvent>(*this->underlyingEvent());
+        m_screenLocation = mouseEvent.screenLocation();
+        initCoordinates(mouseEvent.clientLocation());
     } else if (target) {
         m_screenLocation = target->screenRect().center();
         initCoordinates(LayoutPoint(target->clientRect().center()));

Modified: trunk/Source/WebCore/dom/MouseEvent.h (174177 => 174178)


--- trunk/Source/WebCore/dom/MouseEvent.h	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/dom/MouseEvent.h	2014-10-01 22:29:14 UTC (rev 174178)
@@ -132,8 +132,8 @@
     SimulatedMouseEvent(const AtomicString& eventType, PassRefPtr<AbstractView>, PassRefPtr<Event> underlyingEvent, Element* target);
 };
 
-EVENT_TYPE_CASTS(MouseEvent)
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_EVENT(MouseEvent)
+
 #endif // MouseEvent_h

Modified: trunk/Source/WebCore/dom/Node.cpp (174177 => 174178)


--- trunk/Source/WebCore/dom/Node.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/dom/Node.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -2032,8 +2032,8 @@
 bool Node::dispatchEvent(PassRefPtr<Event> event)
 {
 #if ENABLE(TOUCH_EVENTS) && !PLATFORM(IOS)
-    if (event->isTouchEvent())
-        return dispatchTouchEvent(adoptRef(toTouchEvent(event.leakRef())));
+    if (is<TouchEvent>(event.get()))
+        return dispatchTouchEvent(adoptRef(downcast<TouchEvent>(event.leakRef())));
 #endif
     return EventDispatcher::dispatchEvent(this, event);
 }
@@ -2100,11 +2100,12 @@
         return;
     const AtomicString& eventType = event->type();
     if (eventType == eventNames().keydownEvent || eventType == eventNames().keypressEvent) {
-        if (event->isKeyboardEvent())
+        if (is<KeyboardEvent>(event)) {
             if (Frame* frame = document().frame())
-                frame->eventHandler().defaultKeyboardEventHandler(toKeyboardEvent(event));
+                frame->eventHandler().defaultKeyboardEventHandler(downcast<KeyboardEvent>(event));
+        }
     } else if (eventType == eventNames().clickEvent) {
-        int detail = event->isUIEvent() ? toUIEvent(event)->detail() : 0;
+        int detail = is<UIEvent>(event) ? downcast<UIEvent>(*event).detail() : 0;
         if (dispatchDOMActivateEvent(detail, event))
             event->setDefaultHandled();
 #if ENABLE(CONTEXT_MENUS)
@@ -2114,12 +2115,13 @@
                 page->contextMenuController().handleContextMenuEvent(event);
 #endif
     } else if (eventType == eventNames().textInputEvent) {
-        if (event->eventInterface() == TextEventInterfaceType)
+        if (is<TextEvent>(event)) {
             if (Frame* frame = document().frame())
-                frame->eventHandler().defaultTextInputEventHandler(toTextEvent(event));
+                frame->eventHandler().defaultTextInputEventHandler(downcast<TextEvent>(event));
+        }
 #if ENABLE(PAN_SCROLLING)
-    } else if (eventType == eventNames().mousedownEvent && event->isMouseEvent()) {
-        if (toMouseEvent(event)->button() == MiddleButton) {
+    } else if (eventType == eventNames().mousedownEvent && is<MouseEvent>(event)) {
+        if (downcast<MouseEvent>(*event).button() == MiddleButton) {
             if (enclosingLinkEventParentOrSelf())
                 return;
 
@@ -2133,7 +2135,7 @@
             }
         }
 #endif
-    } else if ((eventType == eventNames().wheelEvent || eventType == eventNames().mousewheelEvent) && event->eventInterface() == WheelEventInterfaceType) {
+    } else if ((eventType == eventNames().wheelEvent || eventType == eventNames().mousewheelEvent) && is<WheelEvent>(event)) {
 
         // If we don't have a renderer, send the wheel event to the first node we find with a renderer.
         // This is needed for <option> and <optgroup> elements so that <select>s get a wheel scroll.
@@ -2143,16 +2145,16 @@
         
         if (startNode && startNode->renderer())
             if (Frame* frame = document().frame())
-                frame->eventHandler().defaultWheelEventHandler(startNode, toWheelEvent(event));
+                frame->eventHandler().defaultWheelEventHandler(startNode, downcast<WheelEvent>(event));
 #if ENABLE(TOUCH_EVENTS) && PLATFORM(IOS)
-    } else if (event->eventInterface() == TouchEventInterfaceType && eventNames().isTouchEventType(eventType)) {
+    } else if (is<TouchEvent>(event) && eventNames().isTouchEventType(eventType)) {
         RenderObject* renderer = this->renderer();
         while (renderer && (!renderer->isBox() || !toRenderBox(renderer)->canBeScrolledAndHasScrollableArea()))
             renderer = renderer->parent();
 
         if (renderer && renderer->node()) {
             if (Frame* frame = document().frame())
-                frame->eventHandler().defaultTouchEventHandler(renderer->node(), toTouchEvent(event));
+                frame->eventHandler().defaultTouchEventHandler(renderer->node(), downcast<TouchEvent>(event));
         }
 #endif
     } else if (event->type() == eventNames().webkitEditableContentChangedEvent) {

Modified: trunk/Source/WebCore/dom/TextEvent.h (174177 => 174178)


--- trunk/Source/WebCore/dom/TextEvent.h	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/dom/TextEvent.h	2014-10-01 22:29:14 UTC (rev 174178)
@@ -87,8 +87,8 @@
         Vector<DictationAlternative> m_dictationAlternatives;
     };
 
-EVENT_TYPE_CASTS(TextEvent)
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_EVENT(TextEvent)
+
 #endif // TextEvent_h

Modified: trunk/Source/WebCore/dom/TouchEvent.h (174177 => 174178)


--- trunk/Source/WebCore/dom/TouchEvent.h	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/dom/TouchEvent.h	2014-10-01 22:29:14 UTC (rev 174178)
@@ -86,10 +86,10 @@
     RefPtr<TouchList> m_changedTouches;
 };
 
-EVENT_TYPE_CASTS(TouchEvent)
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_EVENT(TouchEvent)
+
 #endif // ENABLE(TOUCH_EVENTS)
 
 #endif // TouchEvent_h

Modified: trunk/Source/WebCore/dom/UIEvent.h (174177 => 174178)


--- trunk/Source/WebCore/dom/UIEvent.h	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/dom/UIEvent.h	2014-10-01 22:29:14 UTC (rev 174178)
@@ -85,8 +85,8 @@
     int m_detail;
 };
 
-EVENT_TYPE_CASTS(UIEvent)
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_EVENT(UIEvent)
+
 #endif // UIEvent_h

Modified: trunk/Source/WebCore/dom/WheelEvent.h (174177 => 174178)


--- trunk/Source/WebCore/dom/WheelEvent.h	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/dom/WheelEvent.h	2014-10-01 22:29:14 UTC (rev 174178)
@@ -114,8 +114,8 @@
     bool m_initializedWithPlatformWheelEvent;
 };
 
-EVENT_TYPE_CASTS(WheelEvent)
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_EVENT(WheelEvent)
+
 #endif // WheelEvent_h

Modified: trunk/Source/WebCore/html/HTMLAnchorElement.cpp (174177 => 174178)


--- trunk/Source/WebCore/html/HTMLAnchorElement.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/html/HTMLAnchorElement.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -152,7 +152,7 @@
 
 static void appendServerMapMousePosition(StringBuilder& url, Event* event)
 {
-    if (!event->isMouseEvent())
+    if (!is<MouseEvent>(event))
         return;
 
     ASSERT(event->target());
@@ -170,7 +170,7 @@
     RenderImage& renderer = toRenderImage(*imageElement.renderer());
 
     // FIXME: This should probably pass true for useTransforms.
-    FloatPoint absolutePosition = renderer.absoluteToLocal(FloatPoint(toMouseEvent(event)->pageX(), toMouseEvent(event)->pageY()));
+    FloatPoint absolutePosition = renderer.absoluteToLocal(FloatPoint(downcast<MouseEvent>(*event).pageX(), downcast<MouseEvent>(*event).pageY()));
     int x = absolutePosition.x();
     int y = absolutePosition.y();
     url.append('?');
@@ -196,9 +196,9 @@
         if (hasEditableStyle()) {
             // This keeps track of the editable block that the selection was in (if it was in one) just before the link was clicked
             // for the LiveWhenNotFocused editable link behavior
-            if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && toMouseEvent(event)->button() != RightButton && document().frame()) {
+            if (event->type() == eventNames().mousedownEvent && is<MouseEvent>(event) && downcast<MouseEvent>(*event).button() != RightButton && document().frame()) {
                 setRootEditableElementForSelectionOnMouseDown(document().frame()->selection().selection().rootEditableElement());
-                m_wasShiftKeyDownOnMouseDown = toMouseEvent(event)->shiftKey();
+                m_wasShiftKeyDownOnMouseDown = downcast<MouseEvent>(*event).shiftKey();
             } else if (event->type() == eventNames().mouseoverEvent) {
                 // These are cleared on mouseover and not mouseout because their values are needed for drag events,
                 // but drag events happen after mouse out events.
@@ -555,9 +555,9 @@
 
 HTMLAnchorElement::EventType HTMLAnchorElement::eventType(Event* event)
 {
-    if (!event->isMouseEvent())
+    if (!is<MouseEvent>(event))
         return NonMouseEvent;
-    return toMouseEvent(event)->shiftKey() ? MouseEventWithShiftKey : MouseEventWithoutShiftKey;
+    return downcast<MouseEvent>(*event).shiftKey() ? MouseEventWithShiftKey : MouseEventWithoutShiftKey;
 }
 
 bool HTMLAnchorElement::treatLinkAsLiveForEventType(EventType eventType) const
@@ -592,12 +592,12 @@
 
 bool isEnterKeyKeydownEvent(Event* event)
 {
-    return event->type() == eventNames().keydownEvent && event->isKeyboardEvent() && toKeyboardEvent(event)->keyIdentifier() == "Enter";
+    return event->type() == eventNames().keydownEvent && is<KeyboardEvent>(event) && downcast<KeyboardEvent>(*event).keyIdentifier() == "Enter";
 }
 
 bool isLinkClick(Event* event)
 {
-    return event->type() == eventNames().clickEvent && (!event->isMouseEvent() || toMouseEvent(event)->button() != RightButton);
+    return event->type() == eventNames().clickEvent && (!is<MouseEvent>(event) || downcast<MouseEvent>(*event).button() != RightButton);
 }
 
 bool shouldProhibitLinks(Element* element)

Modified: trunk/Source/WebCore/html/HTMLButtonElement.cpp (174177 => 174178)


--- trunk/Source/WebCore/html/HTMLButtonElement.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/html/HTMLButtonElement.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -123,28 +123,29 @@
         }
     }
 
-    if (event->isKeyboardEvent()) {
-        if (event->type() == eventNames().keydownEvent && toKeyboardEvent(event)->keyIdentifier() == "U+0020") {
+    if (is<KeyboardEvent>(event)) {
+        KeyboardEvent& keyboardEvent = downcast<KeyboardEvent>(*event);
+        if (keyboardEvent.type() == eventNames().keydownEvent && keyboardEvent.keyIdentifier() == "U+0020") {
             setActive(true, true);
             // No setDefaultHandled() - IE dispatches a keypress in this case.
             return;
         }
-        if (event->type() == eventNames().keypressEvent) {
-            switch (toKeyboardEvent(event)->charCode()) {
+        if (keyboardEvent.type() == eventNames().keypressEvent) {
+            switch (keyboardEvent.charCode()) {
                 case '\r':
-                    dispatchSimulatedClick(event);
-                    event->setDefaultHandled();
+                    dispatchSimulatedClick(&keyboardEvent);
+                    keyboardEvent.setDefaultHandled();
                     return;
                 case ' ':
                     // Prevent scrolling down the page.
-                    event->setDefaultHandled();
+                    keyboardEvent.setDefaultHandled();
                     return;
             }
         }
-        if (event->type() == eventNames().keyupEvent && toKeyboardEvent(event)->keyIdentifier() == "U+0020") {
+        if (keyboardEvent.type() == eventNames().keyupEvent && keyboardEvent.keyIdentifier() == "U+0020") {
             if (active())
-                dispatchSimulatedClick(event);
-            event->setDefaultHandled();
+                dispatchSimulatedClick(&keyboardEvent);
+            keyboardEvent.setDefaultHandled();
             return;
         }
     }

Modified: trunk/Source/WebCore/html/HTMLFrameSetElement.cpp (174177 => 174178)


--- trunk/Source/WebCore/html/HTMLFrameSetElement.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/html/HTMLFrameSetElement.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -187,15 +187,15 @@
         m_noresize = containingFrameSet->noResize();
 }
 
-void HTMLFrameSetElement::defaultEventHandler(Event* evt)
+void HTMLFrameSetElement::defaultEventHandler(Event* event)
 {
-    if (evt->isMouseEvent() && !m_noresize && renderer() && renderer()->isFrameSet()) {
-        if (toRenderFrameSet(renderer())->userResize(toMouseEvent(evt))) {
-            evt->setDefaultHandled();
+    if (is<MouseEvent>(event) && !m_noresize && renderer() && renderer()->isFrameSet()) {
+        if (toRenderFrameSet(renderer())->userResize(downcast<MouseEvent>(event))) {
+            event->setDefaultHandled();
             return;
         }
     }
-    HTMLElement::defaultEventHandler(evt);
+    HTMLElement::defaultEventHandler(event);
 }
 
 bool HTMLFrameSetElement::willRecalcStyle(Style::Change)

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (174177 => 174178)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -1032,7 +1032,7 @@
 {
     if (event.type() == eventNames().textInputEvent && m_inputType->shouldSubmitImplicitly(&event))
         event.stopPropagation();
-    if (event.type() == eventNames().clickEvent && event.isMouseEvent() && toMouseEvent(&event)->button() == LeftButton) {
+    if (event.type() == eventNames().clickEvent && is<MouseEvent>(event) && downcast<MouseEvent>(event).button() == LeftButton) {
         m_inputType->willDispatchClick(state);
         state.stateful = true;
     }
@@ -1045,22 +1045,22 @@
 
 void HTMLInputElement::defaultEventHandler(Event* evt)
 {
-    if (evt->isMouseEvent() && evt->type() == eventNames().clickEvent && toMouseEvent(evt)->button() == LeftButton) {
-        m_inputType->handleClickEvent(toMouseEvent(evt));
+    if (is<MouseEvent>(evt) && evt->type() == eventNames().clickEvent && downcast<MouseEvent>(*evt).button() == LeftButton) {
+        m_inputType->handleClickEvent(downcast<MouseEvent>(evt));
         if (evt->defaultHandled())
             return;
     }
 
 #if ENABLE(TOUCH_EVENTS)
-    if (evt->isTouchEvent()) {
-        m_inputType->handleTouchEvent(toTouchEvent(evt));
+    if (is<TouchEvent>(evt)) {
+        m_inputType->handleTouchEvent(downcast<TouchEvent>(evt));
         if (evt->defaultHandled())
             return;
     }
 #endif
 
-    if (evt->isKeyboardEvent() && evt->type() == eventNames().keydownEvent) {
-        m_inputType->handleKeydownEvent(toKeyboardEvent(evt));
+    if (is<KeyboardEvent>(evt) && evt->type() == eventNames().keydownEvent) {
+        m_inputType->handleKeydownEvent(downcast<KeyboardEvent>(evt));
         if (evt->defaultHandled())
             return;
     }
@@ -1086,18 +1086,19 @@
 
     // Use key press event here since sending simulated mouse events
     // on key down blocks the proper sending of the key press event.
-    if (evt->isKeyboardEvent() && evt->type() == eventNames().keypressEvent) {
-        m_inputType->handleKeypressEvent(toKeyboardEvent(evt));
-        if (evt->defaultHandled())
-            return;
+    if (is<KeyboardEvent>(evt)) {
+        KeyboardEvent& keyboardEvent = downcast<KeyboardEvent>(*evt);
+        if (keyboardEvent.type() == eventNames().keypressEvent) {
+            m_inputType->handleKeypressEvent(&keyboardEvent);
+            if (keyboardEvent.defaultHandled())
+                return;
+        } else if (keyboardEvent.type() == eventNames().keyupEvent) {
+            m_inputType->handleKeyupEvent(&keyboardEvent);
+            if (keyboardEvent.defaultHandled())
+                return;
+        }
     }
 
-    if (evt->isKeyboardEvent() && evt->type() == eventNames().keyupEvent) {
-        m_inputType->handleKeyupEvent(toKeyboardEvent(evt));
-        if (evt->defaultHandled())
-            return;
-    }
-
     if (m_inputType->shouldSubmitImplicitly(evt)) {
         if (isSearchField()) {
             addSearchResult();
@@ -1117,11 +1118,11 @@
         return;
     }
 
-    if (evt->isBeforeTextInsertedEvent())
-        m_inputType->handleBeforeTextInsertedEvent(toBeforeTextInsertedEvent(evt));
+    if (is<BeforeTextInsertedEvent>(evt))
+        m_inputType->handleBeforeTextInsertedEvent(downcast<BeforeTextInsertedEvent>(evt));
 
-    if (evt->isMouseEvent() && evt->type() == eventNames().mousedownEvent) {
-        m_inputType->handleMouseDownEvent(toMouseEvent(evt));
+    if (is<MouseEvent>(evt) && evt->type() == eventNames().mousedownEvent) {
+        m_inputType->handleMouseDownEvent(downcast<MouseEvent>(evt));
         if (evt->defaultHandled())
             return;
     }

Modified: trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp (174177 => 174178)


--- trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -747,11 +747,11 @@
 {
     RenderElement* r = renderer();
     if (r && r->isEmbeddedObject()) {
-        if (isPlugInImageElement() && displayState() == WaitingForSnapshot && event->isMouseEvent() && event->type() == eventNames().clickEvent) {
-            MouseEvent* mouseEvent = toMouseEvent(event);
-            if (mouseEvent->button() == LeftButton) {
-                userDidClickSnapshot(mouseEvent, true);
-                event->setDefaultHandled();
+        if (displayState() == WaitingForSnapshot && is<MouseEvent>(event) && event->type() == eventNames().clickEvent) {
+            MouseEvent& mouseEvent = downcast<MouseEvent>(*event);
+            if (mouseEvent.button() == LeftButton) {
+                userDidClickSnapshot(&mouseEvent, true);
+                mouseEvent.setDefaultHandled();
                 return;
             }
         }

Modified: trunk/Source/WebCore/html/HTMLSelectElement.cpp (174177 => 174178)


--- trunk/Source/WebCore/html/HTMLSelectElement.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/html/HTMLSelectElement.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -1146,10 +1146,11 @@
     RefPtr<RenderTheme> renderTheme = page ? &page->theme() : RenderTheme::defaultTheme();
 
     if (event->type() == eventNames().keydownEvent) {
-        if (!event->isKeyboardEvent())
+        if (!is<KeyboardEvent>(event))
             return;
 
-        if (platformHandleKeydownEvent(toKeyboardEvent(event)))
+        KeyboardEvent& keyboardEvent = downcast<KeyboardEvent>(*event);
+        if (platformHandleKeydownEvent(&keyboardEvent))
             return;
 
         // When using spatial navigation, we want to be able to navigate away
@@ -1160,7 +1161,7 @@
                 return;
         }
 
-        const String& keyIdentifier = toKeyboardEvent(event)->keyIdentifier();
+        const String& keyIdentifier = keyboardEvent.keyIdentifier();
         bool handled = true;
         const Vector<HTMLElement*>& listItems = this->listItems();
         int listIndex = optionToListIndex(selectedIndex());
@@ -1192,22 +1193,23 @@
             selectOption(listToOptionIndex(listIndex), DeselectOtherOptions | DispatchChangeEvent | UserDriven);
 
         if (handled)
-            event->setDefaultHandled();
+            keyboardEvent.setDefaultHandled();
     }
 
     // Use key press event here since sending simulated mouse events
     // on key down blocks the proper sending of the key press event.
     if (event->type() == eventNames().keypressEvent) {
-        if (!event->isKeyboardEvent())
+        if (!is<KeyboardEvent>(event))
             return;
 
-        int keyCode = toKeyboardEvent(event)->keyCode();
+        KeyboardEvent& keyboardEvent = downcast<KeyboardEvent>(*event);
+        int keyCode = keyboardEvent.keyCode();
         bool handled = false;
 
         if (keyCode == ' ' && isSpatialNavigationEnabled(document().frame())) {
             // Use space to toggle arrow key handling for selection change or spatial navigation.
             m_activeSelectionState = !m_activeSelectionState;
-            event->setDefaultHandled();
+            keyboardEvent.setDefaultHandled();
             return;
         }
 
@@ -1246,17 +1248,17 @@
                 handled = true;
             } else if (keyCode == '\r') {
                 if (form())
-                    form()->submitImplicitly(event, false);
+                    form()->submitImplicitly(&keyboardEvent, false);
                 dispatchChangeEventForMenuList();
                 handled = true;
             }
         }
 
         if (handled)
-            event->setDefaultHandled();
+            keyboardEvent.setDefaultHandled();
     }
 
-    if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && toMouseEvent(event)->button() == LeftButton) {
+    if (event->type() == eventNames().mousedownEvent && is<MouseEvent>(event) && downcast<MouseEvent>(*event).button() == LeftButton) {
         focus();
 #if !PLATFORM(IOS)
         if (renderer() && renderer()->isMenuList()) {
@@ -1336,35 +1338,35 @@
 {
     const Vector<HTMLElement*>& listItems = this->listItems();
 
-    if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && toMouseEvent(event)->button() == LeftButton) {
+    if (event->type() == eventNames().mousedownEvent && is<MouseEvent>(event) && downcast<MouseEvent>(*event).button() == LeftButton) {
         focus();
         // Calling focus() may remove or change our renderer, in which case we don't want to handle the event further.
         if (!renderer() || !renderer()->isListBox())
             return;
 
         // Convert to coords relative to the list box if needed.
-        MouseEvent* mouseEvent = toMouseEvent(event);
-        IntPoint localOffset = roundedIntPoint(renderer()->absoluteToLocal(mouseEvent->absoluteLocation(), UseTransforms));
+        MouseEvent& mouseEvent = downcast<MouseEvent>(*event);
+        IntPoint localOffset = roundedIntPoint(renderer()->absoluteToLocal(mouseEvent.absoluteLocation(), UseTransforms));
         int listIndex = toRenderListBox(renderer())->listIndexAtOffset(toIntSize(localOffset));
         if (listIndex >= 0) {
             if (!isDisabledFormControl()) {
 #if PLATFORM(COCOA)
-                updateSelectedState(listIndex, mouseEvent->metaKey(), mouseEvent->shiftKey());
+                updateSelectedState(listIndex, mouseEvent.metaKey(), mouseEvent.shiftKey());
 #else
-                updateSelectedState(listIndex, mouseEvent->ctrlKey(), mouseEvent->shiftKey());
+                updateSelectedState(listIndex, mouseEvent.ctrlKey(), mouseEvent.shiftKey());
 #endif
             }
             if (Frame* frame = document().frame())
                 frame->eventHandler().setMouseDownMayStartAutoscroll();
 
-            event->setDefaultHandled();
+            mouseEvent.setDefaultHandled();
         }
-    } else if (event->type() == eventNames().mousemoveEvent && event->isMouseEvent() && !toRenderBox(renderer())->canBeScrolledAndHasScrollableArea()) {
-        MouseEvent* mouseEvent = toMouseEvent(event);
-        if (mouseEvent->button() != LeftButton || !mouseEvent->buttonDown())
+    } else if (event->type() == eventNames().mousemoveEvent && is<MouseEvent>(event) && !toRenderBox(renderer())->canBeScrolledAndHasScrollableArea()) {
+        MouseEvent& mouseEvent = downcast<MouseEvent>(*event);
+        if (mouseEvent.button() != LeftButton || !mouseEvent.buttonDown())
             return;
 
-        IntPoint localOffset = roundedIntPoint(renderer()->absoluteToLocal(mouseEvent->absoluteLocation(), UseTransforms));
+        IntPoint localOffset = roundedIntPoint(renderer()->absoluteToLocal(mouseEvent.absoluteLocation(), UseTransforms));
         int listIndex = toRenderListBox(renderer())->listIndexAtOffset(toIntSize(localOffset));
         if (listIndex >= 0) {
             if (!isDisabledFormControl()) {
@@ -1381,9 +1383,9 @@
                     updateListBoxSelection(true);
                 }
             }
-            event->setDefaultHandled();
+            mouseEvent.setDefaultHandled();
         }
-    } else if (event->type() == eventNames().mouseupEvent && event->isMouseEvent() && toMouseEvent(event)->button() == LeftButton && document().frame()->eventHandler().autoscrollRenderer() != renderer()) {
+    } else if (event->type() == eventNames().mouseupEvent && is<MouseEvent>(event) && downcast<MouseEvent>(*event).button() == LeftButton && document().frame()->eventHandler().autoscrollRenderer() != renderer()) {
         // This click or drag event was not over any of the options.
         if (m_lastOnChangeSelection.isEmpty())
             return;
@@ -1392,10 +1394,12 @@
         // timer stops.
         listBoxOnChange();
     } else if (event->type() == eventNames().keydownEvent) {
-        if (!event->isKeyboardEvent())
+        if (!is<KeyboardEvent>(event))
             return;
-        const String& keyIdentifier = toKeyboardEvent(event)->keyIdentifier();
 
+        KeyboardEvent& keyboardEvent = downcast<KeyboardEvent>(*event);
+        const String& keyIdentifier = keyboardEvent.keyIdentifier();
+
         bool handled = false;
         int endIndex = 0;
         if (m_activeSelectionEndIndex < 0) {
@@ -1456,15 +1460,15 @@
 #if PLATFORM(COCOA)
             m_allowsNonContiguousSelection = m_multiple && isSpatialNavigationEnabled(document().frame());
 #else
-            m_allowsNonContiguousSelection = m_multiple && (isSpatialNavigationEnabled(document().frame()) || toKeyboardEvent(event)->ctrlKey());
+            m_allowsNonContiguousSelection = m_multiple && (isSpatialNavigationEnabled(document().frame()) || keyboardEvent.ctrlKey());
 #endif
-            bool selectNewItem = toKeyboardEvent(event)->shiftKey() || !m_allowsNonContiguousSelection;
+            bool selectNewItem = keyboardEvent.shiftKey() || !m_allowsNonContiguousSelection;
 
             if (selectNewItem)
                 m_activeSelectionState = true;
             // If the anchor is unitialized, or if we're going to deselect all
             // other options, then set the anchor index equal to the end index.
-            bool deselectOthers = !m_multiple || (!toKeyboardEvent(event)->shiftKey() && selectNewItem);
+            bool deselectOthers = !m_multiple || (!keyboardEvent.shiftKey() && selectNewItem);
             if (m_activeSelectionAnchorIndex < 0 || deselectOthers) {
                 if (deselectOthers)
                     deselectItemsWithoutValidation();
@@ -1478,17 +1482,18 @@
             } else
                 scrollToSelection();
 
-            event->setDefaultHandled();
+            keyboardEvent.setDefaultHandled();
         }
     } else if (event->type() == eventNames().keypressEvent) {
-        if (!event->isKeyboardEvent())
+        if (!is<KeyboardEvent>(event))
             return;
-        int keyCode = toKeyboardEvent(event)->keyCode();
+        KeyboardEvent& keyboardEvent = downcast<KeyboardEvent>(*event);
+        int keyCode = keyboardEvent.keyCode();
 
         if (keyCode == '\r') {
             if (form())
-                form()->submitImplicitly(event, false);
-            event->setDefaultHandled();
+                form()->submitImplicitly(&keyboardEvent, false);
+            keyboardEvent.setDefaultHandled();
         } else if (m_multiple && keyCode == ' ' && m_allowsNonContiguousSelection) {
             // Use space to toggle selection change.
             m_activeSelectionState = !m_activeSelectionState;
@@ -1497,7 +1502,7 @@
             ASSERT(is<HTMLOptionElement>(*listItems[m_activeSelectionEndIndex]));
             updateSelectedState(m_activeSelectionEndIndex, true /*multi*/, false /*shift*/);
             listBoxOnChange();
-            event->setDefaultHandled();
+            keyboardEvent.setDefaultHandled();
         }
     }
 }
@@ -1523,9 +1528,9 @@
     if (event->defaultHandled())
         return;
 
-    if (event->type() == eventNames().keypressEvent && event->isKeyboardEvent()) {
-        KeyboardEvent* keyboardEvent = toKeyboardEvent(event);
-        if (!keyboardEvent->ctrlKey() && !keyboardEvent->altKey() && !keyboardEvent->metaKey() && u_isprint(keyboardEvent->charCode())) {
+    if (event->type() == eventNames().keypressEvent && is<KeyboardEvent>(event)) {
+        KeyboardEvent& keyboardEvent = downcast<KeyboardEvent>(*event);
+        if (!keyboardEvent.ctrlKey() && !keyboardEvent.altKey() && !keyboardEvent.metaKey() && u_isprint(keyboardEvent.charCode())) {
             typeAheadFind(keyboardEvent);
             event->setDefaultHandled();
             return;
@@ -1565,9 +1570,9 @@
     return downcast<HTMLOptionElement>(*element).textIndentedToRespectGroupLabel();
 }
 
-void HTMLSelectElement::typeAheadFind(KeyboardEvent* event)
+void HTMLSelectElement::typeAheadFind(KeyboardEvent& event)
 {
-    int index = m_typeAhead.handleEvent(event, TypeAhead::MatchPrefix | TypeAhead::CycleFirstChar);
+    int index = m_typeAhead.handleEvent(&event, TypeAhead::MatchPrefix | TypeAhead::CycleFirstChar);
     if (index < 0)
         return;
     selectOption(listToOptionIndex(index), DeselectOtherOptions | DispatchChangeEvent | UserDriven);

Modified: trunk/Source/WebCore/html/HTMLSelectElement.h (174177 => 174178)


--- trunk/Source/WebCore/html/HTMLSelectElement.h	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/html/HTMLSelectElement.h	2014-10-01 22:29:14 UTC (rev 174178)
@@ -151,7 +151,7 @@
     void recalcListItems(bool updateSelectedStates = true) const;
 
     void deselectItems(HTMLOptionElement* excludeElement = 0);
-    void typeAheadFind(KeyboardEvent*);
+    void typeAheadFind(KeyboardEvent&);
     void saveLastSelection();
 
     virtual InsertionNotificationRequest insertedInto(ContainerNode&) override;

Modified: trunk/Source/WebCore/html/HTMLSummaryElement.cpp (174177 => 174178)


--- trunk/Source/WebCore/html/HTMLSummaryElement.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/html/HTMLSummaryElement.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -126,28 +126,29 @@
             return;
         }
 
-        if (event->isKeyboardEvent()) {
-            if (event->type() == eventNames().keydownEvent && toKeyboardEvent(event)->keyIdentifier() == "U+0020") {
+        if (is<KeyboardEvent>(event)) {
+            KeyboardEvent& keyboardEvent = downcast<KeyboardEvent>(*event);
+            if (keyboardEvent.type() == eventNames().keydownEvent && keyboardEvent.keyIdentifier() == "U+0020") {
                 setActive(true, true);
                 // No setDefaultHandled() - IE dispatches a keypress in this case.
                 return;
             }
-            if (event->type() == eventNames().keypressEvent) {
-                switch (toKeyboardEvent(event)->charCode()) {
+            if (keyboardEvent.type() == eventNames().keypressEvent) {
+                switch (keyboardEvent.charCode()) {
                 case '\r':
                     dispatchSimulatedClick(event);
-                    event->setDefaultHandled();
+                    keyboardEvent.setDefaultHandled();
                     return;
                 case ' ':
                     // Prevent scrolling down the page.
-                    event->setDefaultHandled();
+                    keyboardEvent.setDefaultHandled();
                     return;
                 }
             }
-            if (event->type() == eventNames().keyupEvent && toKeyboardEvent(event)->keyIdentifier() == "U+0020") {
+            if (keyboardEvent.type() == eventNames().keyupEvent && keyboardEvent.keyIdentifier() == "U+0020") {
                 if (active())
                     dispatchSimulatedClick(event);
-                event->setDefaultHandled();
+                keyboardEvent.setDefaultHandled();
                 return;
             }
         }

Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.cpp (174177 => 174178)


--- trunk/Source/WebCore/html/HTMLTextAreaElement.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -270,8 +270,8 @@
 {
     if (renderer() && (event->isMouseEvent() || event->isDragEvent() || event->eventInterface() == WheelEventInterfaceType || event->type() == eventNames().blurEvent))
         forwardEvent(event);
-    else if (renderer() && event->isBeforeTextInsertedEvent())
-        handleBeforeTextInsertedEvent(toBeforeTextInsertedEvent(event));
+    else if (renderer() && is<BeforeTextInsertedEvent>(event))
+        handleBeforeTextInsertedEvent(downcast<BeforeTextInsertedEvent>(event));
 
     HTMLTextFormControlElement::defaultEventHandler(event);
 }

Modified: trunk/Source/WebCore/html/ImageDocument.cpp (174177 => 174178)


--- trunk/Source/WebCore/html/ImageDocument.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/html/ImageDocument.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -398,8 +398,8 @@
 {
     if (event->type() == eventNames().resizeEvent)
         m_document.windowSizeChanged();
-    else if (event->type() == eventNames().clickEvent && event->isMouseEvent()) {
-        MouseEvent& mouseEvent = toMouseEvent(*event);
+    else if (event->type() == eventNames().clickEvent && is<MouseEvent>(event)) {
+        MouseEvent& mouseEvent = downcast<MouseEvent>(*event);
         m_document.imageClicked(mouseEvent.x(), mouseEvent.y());
     }
 }

Modified: trunk/Source/WebCore/html/ImageInputType.cpp (174177 => 174178)


--- trunk/Source/WebCore/html/ImageInputType.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/html/ImageInputType.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -89,8 +89,8 @@
     m_clickLocation = IntPoint();
     if (event->underlyingEvent()) {
         Event& underlyingEvent = *event->underlyingEvent();
-        if (underlyingEvent.isMouseEvent()) {
-            MouseEvent& mouseEvent = toMouseEvent(underlyingEvent);
+        if (is<MouseEvent>(underlyingEvent)) {
+            MouseEvent& mouseEvent = downcast<MouseEvent>(underlyingEvent);
             if (!mouseEvent.isSimulated())
                 m_clickLocation = IntPoint(mouseEvent.offsetX(), mouseEvent.offsetY());
         }

Modified: trunk/Source/WebCore/html/InputType.cpp (174177 => 174178)


--- trunk/Source/WebCore/html/InputType.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/html/InputType.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -471,7 +471,7 @@
 
 bool InputType::shouldSubmitImplicitly(Event* event)
 {
-    return event->isKeyboardEvent() && event->type() == eventNames().keypressEvent && toKeyboardEvent(event)->charCode() == '\r';
+    return is<KeyboardEvent>(event) && event->type() == eventNames().keypressEvent && downcast<KeyboardEvent>(*event).charCode() == '\r';
 }
 
 PassRefPtr<HTMLFormElement> InputType::formForSubmission() const

Modified: trunk/Source/WebCore/html/MediaDocument.cpp (174177 => 174178)


--- trunk/Source/WebCore/html/MediaDocument.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/html/MediaDocument.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -204,19 +204,19 @@
     if (!is<ContainerNode>(targetNode))
         return;
     ContainerNode& targetContainer = downcast<ContainerNode>(*targetNode);
-    if (event->type() == eventNames().keydownEvent && event->isKeyboardEvent()) {
+    if (event->type() == eventNames().keydownEvent && is<KeyboardEvent>(event)) {
         HTMLVideoElement* video = descendentVideoElement(targetContainer);
         if (!video)
             return;
 
-        KeyboardEvent* keyboardEvent = toKeyboardEvent(event);
-        if (keyboardEvent->keyIdentifier() == "U+0020") { // space
+        KeyboardEvent& keyboardEvent = downcast<KeyboardEvent>(*event);
+        if (keyboardEvent.keyIdentifier() == "U+0020") { // space
             if (video->paused()) {
                 if (video->canPlay())
                     video->play();
             } else
                 video->pause();
-            event->setDefaultHandled();
+            keyboardEvent.setDefaultHandled();
         }
     }
 }

Modified: trunk/Source/WebCore/html/TextFieldInputType.cpp (174177 => 174178)


--- trunk/Source/WebCore/html/TextFieldInputType.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/html/TextFieldInputType.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -206,7 +206,8 @@
 
 bool TextFieldInputType::shouldSubmitImplicitly(Event* event)
 {
-    return (event->type() == eventNames().textInputEvent && event->eventInterface() == TextEventInterfaceType && toTextEvent(event)->data() == "\n") || InputType::shouldSubmitImplicitly(event);
+    return (event->type() == eventNames().textInputEvent && is<TextEvent>(event) && downcast<TextEvent>(*event).data() == "\n")
+        || InputType::shouldSubmitImplicitly(event);
 }
 
 RenderPtr<RenderElement> TextFieldInputType::createInputRenderer(PassRef<RenderStyle> style)

Modified: trunk/Source/WebCore/html/shadow/MediaControlElementTypes.cpp (174177 => 174178)


--- trunk/Source/WebCore/html/shadow/MediaControlElementTypes.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/html/shadow/MediaControlElementTypes.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -196,7 +196,7 @@
 void MediaControlVolumeSliderElement::defaultEventHandler(Event* event)
 {
     // Left button is 0. Rejects mouse events not from left button.
-    if (event->isMouseEvent() && toMouseEvent(event)->button())
+    if (is<MouseEvent>(event) && downcast<MouseEvent>(*event).button())
         return;
 
     if (!renderer())

Modified: trunk/Source/WebCore/html/shadow/MediaControlElements.cpp (174177 => 174178)


--- trunk/Source/WebCore/html/shadow/MediaControlElements.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/html/shadow/MediaControlElements.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -221,8 +221,8 @@
 {
     MediaControlDivElement::defaultEventHandler(event);
 
-    if (event->isMouseEvent()) {
-        LayoutPoint location = toMouseEvent(event)->absoluteLocation();
+    if (is<MouseEvent>(event)) {
+        LayoutPoint location = downcast<MouseEvent>(*event).absoluteLocation();
         if (event->type() == eventNames().mousedownEvent && event->target() == this) {
             startDrag(location);
             event->setDefaultHandled();
@@ -337,12 +337,12 @@
 
 void MediaControlVolumeSliderContainerElement::defaultEventHandler(Event* event)
 {
-    if (!event->isMouseEvent() || event->type() != eventNames().mouseoutEvent)
+    if (!is<MouseEvent>(event) || event->type() != eventNames().mouseoutEvent)
         return;
 
     // Poor man's mouseleave event detection.
-    MouseEvent* mouseEvent = toMouseEvent(event);
-    EventTarget* relatedTarget = mouseEvent->relatedTarget();
+    MouseEvent& mouseEvent = downcast<MouseEvent>(*event);
+    EventTarget* relatedTarget = mouseEvent.relatedTarget();
     if (!relatedTarget || !relatedTarget->toNode())
         return;
 
@@ -851,7 +851,7 @@
 void MediaControlTimelineElement::defaultEventHandler(Event* event)
 {
     // Left button is 0. Rejects mouse events not from left button.
-    if (event->isMouseEvent() && toMouseEvent(event)->button())
+    if (is<MouseEvent>(event) && downcast<MouseEvent>(*event).button())
         return;
 
     if (!renderer())

Modified: trunk/Source/WebCore/html/shadow/MediaControls.cpp (174177 => 174178)


--- trunk/Source/WebCore/html/shadow/MediaControls.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/html/shadow/MediaControls.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -366,9 +366,9 @@
 
 bool MediaControls::containsRelatedTarget(Event* event)
 {
-    if (!event->isMouseEvent())
+    if (!is<MouseEvent>(event))
         return false;
-    EventTarget* relatedTarget = toMouseEvent(event)->relatedTarget();
+    EventTarget* relatedTarget = downcast<MouseEvent>(*event).relatedTarget();
     if (!relatedTarget)
         return false;
     return contains(relatedTarget->toNode());

Modified: trunk/Source/WebCore/html/shadow/MediaControlsApple.cpp (174177 => 174178)


--- trunk/Source/WebCore/html/shadow/MediaControlsApple.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/html/shadow/MediaControlsApple.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -588,10 +588,10 @@
 {
     if (event->type() == eventNames().clickEvent)
         m_mediaControls->handleClickEvent(event);
-    else if ((event->type() == eventNames().wheelEvent || event->type() == eventNames().mousewheelEvent) && event->eventInterface() == WheelEventInterfaceType) {
-        WheelEvent* wheelEvent = toWheelEvent(event);
-        if (m_mediaControls->shouldClosedCaptionsContainerPreventPageScrolling(wheelEvent->wheelDeltaY()))
-            event->preventDefault();
+    else if ((event->type() == eventNames().wheelEvent || event->type() == eventNames().mousewheelEvent) && is<WheelEvent>(event)) {
+        WheelEvent& wheelEvent = downcast<WheelEvent>(*event);
+        if (m_mediaControls->shouldClosedCaptionsContainerPreventPageScrolling(wheelEvent.wheelDeltaY()))
+            wheelEvent.preventDefault();
     }
 }
 

Modified: trunk/Source/WebCore/html/shadow/SliderThumbElement.cpp (174177 => 174178)


--- trunk/Source/WebCore/html/shadow/SliderThumbElement.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/html/shadow/SliderThumbElement.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -333,7 +333,7 @@
 #if !PLATFORM(IOS)
 void SliderThumbElement::defaultEventHandler(Event* event)
 {
-    if (!event->isMouseEvent()) {
+    if (!is<MouseEvent>(event)) {
         HTMLDivElement::defaultEventHandler(event);
         return;
     }
@@ -347,9 +347,9 @@
         return;
     }
 
-    MouseEvent* mouseEvent = toMouseEvent(event);
-    bool isLeftButton = mouseEvent->button() == LeftButton;
-    const AtomicString& eventType = event->type();
+    MouseEvent& mouseEvent = downcast<MouseEvent>(*event);
+    bool isLeftButton = mouseEvent.button() == LeftButton;
+    const AtomicString& eventType = mouseEvent.type();
 
     // We intentionally do not call event->setDefaultHandled() here because
     // MediaControlTimelineElement::defaultEventHandler() wants to handle these
@@ -362,11 +362,11 @@
         return;
     } else if (eventType == eventNames().mousemoveEvent) {
         if (m_inDragMode)
-            setPositionFromPoint(mouseEvent->absoluteLocation());
+            setPositionFromPoint(mouseEvent.absoluteLocation());
         return;
     }
 
-    HTMLDivElement::defaultEventHandler(event);
+    HTMLDivElement::defaultEventHandler(&mouseEvent);
 }
 #endif
 

Modified: trunk/Source/WebCore/html/shadow/SpinButtonElement.cpp (174177 => 174178)


--- trunk/Source/WebCore/html/shadow/SpinButtonElement.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/html/shadow/SpinButtonElement.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -67,7 +67,7 @@
 
 void SpinButtonElement::defaultEventHandler(Event* event)
 {
-    if (!event->isMouseEvent()) {
+    if (!is<MouseEvent>(event)) {
         if (!event->defaultHandled())
             HTMLDivElement::defaultEventHandler(event);
         return;
@@ -86,9 +86,9 @@
         return;
     }
 
-    MouseEvent* mouseEvent = toMouseEvent(event);
-    IntPoint local = roundedIntPoint(box->absoluteToLocal(mouseEvent->absoluteLocation(), UseTransforms));
-    if (mouseEvent->type() == eventNames().mousedownEvent && mouseEvent->button() == LeftButton) {
+    MouseEvent& mouseEvent = downcast<MouseEvent>(*event);
+    IntPoint local = roundedIntPoint(box->absoluteToLocal(mouseEvent.absoluteLocation(), UseTransforms));
+    if (mouseEvent.type() == eventNames().mousedownEvent && mouseEvent.button() == LeftButton) {
         if (box->pixelSnappedBorderBoxRect().contains(local)) {
             // The following functions of HTMLInputElement may run _javascript_
             // code which detaches this shadow node. We need to take a reference
@@ -107,11 +107,11 @@
                     doStepAction(m_upDownState == Up ? 1 : -1);
                 }
             }
-            event->setDefaultHandled();
+            mouseEvent.setDefaultHandled();
         }
-    } else if (mouseEvent->type() == eventNames().mouseupEvent && mouseEvent->button() == LeftButton)
+    } else if (mouseEvent.type() == eventNames().mouseupEvent && mouseEvent.button() == LeftButton)
         stopRepeatingTimer();
-    else if (event->type() == eventNames().mousemoveEvent) {
+    else if (mouseEvent.type() == eventNames().mousemoveEvent) {
         if (box->pixelSnappedBorderBoxRect().contains(local)) {
             if (!m_capturing) {
                 if (Frame* frame = document().frame()) {
@@ -131,8 +131,8 @@
         }
     }
 
-    if (!event->defaultHandled())
-        HTMLDivElement::defaultEventHandler(event);
+    if (!mouseEvent.defaultHandled())
+        HTMLDivElement::defaultEventHandler(&mouseEvent);
 }
 
 void SpinButtonElement::willOpenPopup()
@@ -146,7 +146,7 @@
     if (!renderBox())
         return;
 
-    if (event->eventInterface() != WheelEventInterfaceType)
+    if (!is<WheelEvent>(event))
         return;
 
     if (!m_spinButtonOwner)
@@ -155,7 +155,7 @@
     if (!m_spinButtonOwner->shouldSpinButtonRespondToWheelEvents())
         return;
 
-    doStepAction(toWheelEvent(event)->wheelDeltaY());
+    doStepAction(downcast<WheelEvent>(*event).wheelDeltaY());
     event->setDefaultHandled();
 }
 

Modified: trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp (174177 => 174178)


--- trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -142,7 +142,7 @@
 {
     // On mousedown, bring up a menu, if needed
     HTMLInputElement* input = downcast<HTMLInputElement>(shadowHost());
-    if (input && event->type() == eventNames().mousedownEvent && event->isMouseEvent() && toMouseEvent(event)->button() == LeftButton) {
+    if (input && event->type() == eventNames().mousedownEvent && is<MouseEvent>(event) && downcast<MouseEvent>(*event).button() == LeftButton) {
         input->focus();
         input->select();
 #if !PLATFORM(IOS)
@@ -199,7 +199,7 @@
         return;
     }
 
-    if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && toMouseEvent(event)->button() == LeftButton) {
+    if (event->type() == eventNames().mousedownEvent && is<MouseEvent>(event) && downcast<MouseEvent>(*event).button() == LeftButton) {
         if (renderer() && renderer()->visibleToHitTesting()) {
             if (Frame* frame = document().frame()) {
                 frame->eventHandler().setCapturingMouseEventsElement(this);
@@ -210,7 +210,7 @@
         input->select();
         event->setDefaultHandled();
     }
-    if (event->type() == eventNames().mouseupEvent && event->isMouseEvent() && toMouseEvent(event)->button() == LeftButton) {
+    if (event->type() == eventNames().mouseupEvent && is<MouseEvent>(event) && downcast<MouseEvent>(*event).button() == LeftButton) {
         if (m_capturing) {
             if (Frame* frame = document().frame()) {
                 frame->eventHandler().setCapturingMouseEventsElement(nullptr);

Modified: trunk/Source/WebCore/inspector/InspectorFrontendHost.cpp (174177 => 174178)


--- trunk/Source/WebCore/inspector/InspectorFrontendHost.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/inspector/InspectorFrontendHost.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -284,12 +284,12 @@
 void InspectorFrontendHost::dispatchEventAsContextMenuEvent(Event* event)
 {
 #if ENABLE(CONTEXT_MENUS) && USE(ACCESSIBILITY_CONTEXT_MENUS)
-    if (!event || !event->isMouseEvent())
+    if (!event || !is<MouseEvent>(event))
         return;
 
     Frame* frame = event->target()->toNode()->document().frame();
-    MouseEvent* mouseEvent = toMouseEvent(event);
-    IntPoint mousePoint = IntPoint(mouseEvent->clientX(), mouseEvent->clientY());
+    MouseEvent& mouseEvent = downcast<MouseEvent>(*event);
+    IntPoint mousePoint = IntPoint(mouseEvent.clientX(), mouseEvent.clientY());
 
     m_frontendPage->contextMenuController().showContextMenuAt(frame, mousePoint);
 #else

Modified: trunk/Source/WebCore/page/ContextMenuController.cpp (174177 => 174178)


--- trunk/Source/WebCore/page/ContextMenuController.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/page/ContextMenuController.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -150,10 +150,10 @@
 {
     ASSERT(event);
     
-    if (!event->isMouseEvent())
+    if (!is<MouseEvent>(event))
         return nullptr;
 
-    MouseEvent& mouseEvent = toMouseEvent(*event);
+    MouseEvent& mouseEvent = downcast<MouseEvent>(*event);
     HitTestResult result(mouseEvent.absoluteLocation());
 
     Node* node = event->target()->toNode();

Modified: trunk/Source/WebCore/page/EventHandler.cpp (174177 => 174178)


--- trunk/Source/WebCore/page/EventHandler.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -3523,7 +3523,7 @@
 {
     // Platforms should differentiate real commands like selectAll from text input in disguise (like insertNewline),
     // and avoid dispatching text input events from keydown default handlers.
-    ASSERT(!underlyingEvent || !underlyingEvent->isKeyboardEvent() || toKeyboardEvent(underlyingEvent)->type() == eventNames().keypressEvent);
+    ASSERT(!underlyingEvent || !is<KeyboardEvent>(underlyingEvent) || downcast<KeyboardEvent>(*underlyingEvent).type() == eventNames().keypressEvent);
 
     EventTarget* target;
     if (underlyingEvent)

Modified: trunk/Source/WebCore/rendering/RenderEmbeddedObject.cpp (174177 => 174178)


--- trunk/Source/WebCore/rendering/RenderEmbeddedObject.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/rendering/RenderEmbeddedObject.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -590,9 +590,9 @@
         && indicatorRect.contains(point);
 }
 
-bool RenderEmbeddedObject::isInUnavailablePluginIndicator(MouseEvent* event) const
+bool RenderEmbeddedObject::isInUnavailablePluginIndicator(const MouseEvent& event) const
 {
-    return isInUnavailablePluginIndicator(absoluteToLocal(event->absoluteLocation(), UseTransforms));
+    return isInUnavailablePluginIndicator(absoluteToLocal(event.absoluteLocation(), UseTransforms));
 }
 
 void RenderEmbeddedObject::handleUnavailablePluginIndicatorEvent(Event* event)
@@ -600,21 +600,21 @@
     if (!shouldUnavailablePluginMessageBeButton(document(), m_pluginUnavailabilityReason))
         return;
 
-    if (!event->isMouseEvent())
+    if (!is<MouseEvent>(event))
         return;
 
-    MouseEvent* mouseEvent = toMouseEvent(event);
+    MouseEvent& mouseEvent = downcast<MouseEvent>(*event);
     HTMLPlugInElement& element = downcast<HTMLPlugInElement>(frameOwnerElement());
-    if (event->type() == eventNames().mousedownEvent && toMouseEvent(event)->button() == LeftButton) {
+    if (mouseEvent.type() == eventNames().mousedownEvent && mouseEvent.button() == LeftButton) {
         m_mouseDownWasInUnavailablePluginIndicator = isInUnavailablePluginIndicator(mouseEvent);
         if (m_mouseDownWasInUnavailablePluginIndicator) {
             frame().eventHandler().setCapturingMouseEventsElement(&element);
             element.setIsCapturingMouseEvents(true);
             setUnavailablePluginIndicatorIsPressed(true);
         }
-        event->setDefaultHandled();
+        mouseEvent.setDefaultHandled();
     }
-    if (event->type() == eventNames().mouseupEvent && toMouseEvent(event)->button() == LeftButton) {
+    if (mouseEvent.type() == eventNames().mouseupEvent && mouseEvent.button() == LeftButton) {
         if (m_unavailablePluginIndicatorIsPressed) {
             frame().eventHandler().setCapturingMouseEventsElement(nullptr);
             element.setIsCapturingMouseEvents(false);
@@ -627,9 +627,9 @@
         m_mouseDownWasInUnavailablePluginIndicator = false;
         event->setDefaultHandled();
     }
-    if (event->type() == eventNames().mousemoveEvent) {
+    if (mouseEvent.type() == eventNames().mousemoveEvent) {
         setUnavailablePluginIndicatorIsPressed(m_mouseDownWasInUnavailablePluginIndicator && isInUnavailablePluginIndicator(mouseEvent));
-        event->setDefaultHandled();
+        mouseEvent.setDefaultHandled();
     }
 }
 

Modified: trunk/Source/WebCore/rendering/RenderEmbeddedObject.h (174177 => 174178)


--- trunk/Source/WebCore/rendering/RenderEmbeddedObject.h	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/rendering/RenderEmbeddedObject.h	2014-10-01 22:29:14 UTC (rev 174178)
@@ -84,7 +84,7 @@
     virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier, Element** stopElement) override final;
 
     void setUnavailablePluginIndicatorIsPressed(bool);
-    bool isInUnavailablePluginIndicator(MouseEvent*) const;
+    bool isInUnavailablePluginIndicator(const MouseEvent&) const;
     bool isInUnavailablePluginIndicator(const FloatPoint&) const;
     bool getReplacementTextGeometry(const LayoutPoint& accumulatedOffset, FloatRect& contentRect, FloatRect& indicatorRect, FloatRect& replacementTextRect, FloatRect& arrowRect, Font&, TextRun&, float& textWidth) const;
     LayoutRect unavailablePluginIndicatorBounds(const LayoutPoint&) const;

Modified: trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp (174177 => 174178)


--- trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -155,10 +155,10 @@
 
 void RenderSnapshottedPlugIn::handleEvent(Event* event)
 {
-    if (!event->isMouseEvent())
+    if (!is<MouseEvent>(event))
         return;
 
-    MouseEvent* mouseEvent = toMouseEvent(event);
+    MouseEvent& mouseEvent = downcast<MouseEvent>(*event);
 
     // If we're a snapshotted plugin, we want to make sure we activate on
     // clicks even if the page is preventing our default behaviour. Otherwise
@@ -168,20 +168,20 @@
     // event. The code below is not completely foolproof, but the worst that
     // could happen is that a snapshotted plugin restarts.
 
-    if (event->type() == eventNames().mouseoutEvent)
+    if (mouseEvent.type() == eventNames().mouseoutEvent)
         m_isPotentialMouseActivation = false;
 
-    if (mouseEvent->button() != LeftButton)
+    if (mouseEvent.button() != LeftButton)
         return;
 
-    if (event->type() == eventNames().clickEvent || (m_isPotentialMouseActivation && event->type() == eventNames().mouseupEvent)) {
+    if (mouseEvent.type() == eventNames().clickEvent || (m_isPotentialMouseActivation && mouseEvent.type() == eventNames().mouseupEvent)) {
         m_isPotentialMouseActivation = false;
-        bool clickWasOnOverlay = plugInImageElement().partOfSnapshotOverlay(event->target()->toNode());
-        plugInImageElement().userDidClickSnapshot(mouseEvent, !clickWasOnOverlay);
-        event->setDefaultHandled();
-    } else if (event->type() == eventNames().mousedownEvent) {
+        bool clickWasOnOverlay = plugInImageElement().partOfSnapshotOverlay(mouseEvent.target()->toNode());
+        plugInImageElement().userDidClickSnapshot(&mouseEvent, !clickWasOnOverlay);
+        mouseEvent.setDefaultHandled();
+    } else if (mouseEvent.type() == eventNames().mousedownEvent) {
         m_isPotentialMouseActivation = true;
-        event->setDefaultHandled();
+        mouseEvent.setDefaultHandled();
     }
 }
 

Modified: trunk/Source/WebKit2/ChangeLog (174177 => 174178)


--- trunk/Source/WebKit2/ChangeLog	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebKit2/ChangeLog	2014-10-01 22:29:14 UTC (rev 174178)
@@ -1,3 +1,15 @@
+2014-10-01  Christophe Dumez  <cdu...@apple.com>
+
+        Use is<>() / downcast<>() for Event classes
+        https://bugs.webkit.org/show_bug.cgi?id=137284
+
+        Reviewed by Andreas Kling.
+
+        Use is<>() / downcast<>() for Event classes.
+
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::handleEvent):
+
 2014-10-01  Joseph Pecoraro  <pecor...@apple.com>
 
         [iOS] <select> with <optgroup> may change initial selected option when assisted

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp (174177 => 174178)


--- trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp	2014-10-01 22:12:30 UTC (rev 174177)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp	2014-10-01 22:29:14 UTC (rev 174178)
@@ -892,8 +892,8 @@
 
     const WebEvent* currentEvent = WebPage::currentEvent();
     std::unique_ptr<WebEvent> simulatedWebEvent;
-    if (event->isMouseEvent() && toMouseEvent(event)->isSimulated()) {
-        simulatedWebEvent = createWebEvent(toMouseEvent(event));
+    if (is<MouseEvent>(event) && downcast<MouseEvent>(*event).isSimulated()) {
+        simulatedWebEvent = createWebEvent(downcast<MouseEvent>(event));
         currentEvent = simulatedWebEvent.get();
     }
     if (!currentEvent)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to