Add checked casts for Event.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 16 Feb 2014 02:01:04 +0000 (02:01 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 16 Feb 2014 02:01:04 +0000 (02:01 +0000)
<https://webkit.org/b/128875>

Generate casting helpers for casting from Event to various subclasses
and go on static_cast replacement spree.

Reviewed by Sam Weinig.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@164184 268f45cc-cd09-0410-ab3c-d52691b4dbfc

42 files changed:
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSErrorHandler.cpp
Source/WebCore/dom/BeforeTextInsertedEvent.h
Source/WebCore/dom/BeforeUnloadEvent.h
Source/WebCore/dom/ErrorEvent.cpp
Source/WebCore/dom/ErrorEvent.h
Source/WebCore/dom/Event.cpp
Source/WebCore/dom/Event.h
Source/WebCore/dom/FocusEvent.h
Source/WebCore/dom/KeyboardEvent.cpp
Source/WebCore/dom/KeyboardEvent.h
Source/WebCore/dom/MouseEvent.cpp
Source/WebCore/dom/MouseEvent.h
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/TextEvent.cpp
Source/WebCore/dom/TextEvent.h
Source/WebCore/dom/TouchEvent.h
Source/WebCore/dom/UIEvent.h
Source/WebCore/dom/WheelEvent.cpp
Source/WebCore/dom/WheelEvent.h
Source/WebCore/html/HTMLAnchorElement.cpp
Source/WebCore/html/HTMLButtonElement.cpp
Source/WebCore/html/HTMLFrameSetElement.cpp
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLSelectElement.cpp
Source/WebCore/html/HTMLSummaryElement.cpp
Source/WebCore/html/HTMLTextAreaElement.cpp
Source/WebCore/html/ImageDocument.cpp
Source/WebCore/html/InputType.cpp
Source/WebCore/html/MediaDocument.cpp
Source/WebCore/html/TextFieldInputType.cpp
Source/WebCore/html/shadow/MediaControlElementTypes.cpp
Source/WebCore/html/shadow/MediaControlElements.cpp
Source/WebCore/html/shadow/MediaControls.cpp
Source/WebCore/html/shadow/MediaControlsApple.cpp
Source/WebCore/html/shadow/SliderThumbElement.cpp
Source/WebCore/html/shadow/SpinButtonElement.cpp
Source/WebCore/html/shadow/TextControlInnerElements.cpp
Source/WebCore/page/ContextMenuController.cpp
Source/WebCore/page/EventHandler.cpp
Source/WebCore/rendering/RenderEmbeddedObject.cpp
Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp

index 75ba1e8df245dfc18f1ec7c787bdc1afa5b8f83c..4ae2ae682e3d244631440fbd0f4a9f50f3528427 100644 (file)
@@ -1,3 +1,13 @@
+2014-02-15  Andreas Kling  <akling@apple.com>
+
+        Add checked casts for Event.
+        <https://webkit.org/b/128875>
+
+        Generate casting helpers for casting from Event to various subclasses
+        and go on static_cast replacement spree.
+
+        Reviewed by Sam Weinig.
+
 2014-02-15  Ryosuke Niwa  <rniwa@webkit.org>
 
         HTMLTextFormControlElement::subtreeHasChanged should be called before updating selection
index f72c334bd9fecc2daf1e7aebee094e00bd8465be..d92c1b8f3ae226a686e6a0c0b323f4f9785bbab0 100644 (file)
@@ -66,7 +66,7 @@ void JSErrorHandler::handleEvent(ScriptExecutionContext* scriptExecutionContext,
     if (!scriptExecutionContext)
         return;
 
-    ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event);
+    ErrorEvent* errorEvent = toErrorEvent(event);
 
     JSLockHolder lock(scriptExecutionContext->vm());
 
index 6e5f4eb792fd0482a5d95d0a623d0bef962d869b..261d0a83ce55d9a3ac55ee2baf24fdf2408db7ac 100644 (file)
@@ -51,6 +51,8 @@ private:
     String m_text;
 };
 
+EVENT_TYPE_CASTS(BeforeTextInsertedEvent)
+
 } // namespace
 
 #endif
index 9188ad57698e4497cda44ef9beb31fbe55d96e77..fd773982b1011d8c6084d963a99f1944a7b18ee7 100644 (file)
@@ -51,11 +51,7 @@ private:
     String m_returnValue;
 };
 
-inline BeforeUnloadEvent* toBeforeUnloadEvent(Event* event)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(!event || event->isBeforeUnloadEvent());
-    return static_cast<BeforeUnloadEvent*>(event);
-}
+EVENT_TYPE_CASTS(BeforeUnloadEvent)
 
 } // namespace WebCore
 
index d0c337af395546cda346164f580986d871dca9b3..6c6a5952b55eb8b0b0fcf76c9b6a3e5ae50ae3ee 100644 (file)
@@ -74,4 +74,9 @@ EventInterface ErrorEvent::eventInterface() const
     return ErrorEventInterfaceType;
 }
 
+bool ErrorEvent::isErrorEvent() const
+{
+    return true;
+}
+
 } // namespace WebCore
index d58eed6a82fa40d8a177bd2462075b99e60f4db9..b58e79cc0b737aed217db343b378d5582ff2528c 100644 (file)
@@ -73,12 +73,16 @@ private:
     ErrorEvent(const String& message, const String& fileName, unsigned lineNumber, unsigned columnNumber);
     ErrorEvent(const AtomicString&, const ErrorEventInit&);
 
+    virtual bool isErrorEvent() const override;
+
     String m_message;
     String m_fileName;
     unsigned m_lineNumber;
     unsigned m_columnNumber;
 };
 
+EVENT_TYPE_CASTS(ErrorEvent)
+
 } // namespace WebCore
 
 #endif // ErrorEvent_h
index e222072d88675463606cffecd78fd12ba1392459..1d0fe613518bc85a00858f1cd2f8669780daefa9 100644 (file)
@@ -168,6 +168,21 @@ bool Event::isBeforeUnloadEvent() const
     return false;
 }
 
+bool Event::isErrorEvent() const
+{
+    return false;
+}
+
+bool Event::isTextEvent() const
+{
+    return false;
+}
+
+bool Event::isWheelEvent() const
+{
+    return false;
+}
+
 PassRefPtr<Event> Event::cloneFor(HTMLIFrameElement*) const
 {
     return Event::create(type(), bubbles(), cancelable());
index 9cd6dcddd43c9deb0363327d45496d376953390c..84938148c66d5ed0777a4dae1158d7103f2a6800 100644 (file)
@@ -145,6 +145,10 @@ public:
 
     virtual bool isBeforeUnloadEvent() const;
 
+    virtual bool isErrorEvent() const;
+    virtual bool isTextEvent() const;
+    virtual bool isWheelEvent() const;
+
     bool propagationStopped() const { return m_propagationStopped || m_immediatePropagationStopped; }
     bool immediatePropagationStopped() const { return m_immediatePropagationStopped; }
 
@@ -201,6 +205,10 @@ private:
     RefPtr<Event> m_underlyingEvent;
 };
 
+#define EVENT_TYPE_CASTS(ToValueTypeName) \
+    TYPE_CASTS_BASE(ToValueTypeName, Event, event, event->is##ToValueTypeName(), event.is##ToValueTypeName())
+
+
 } // namespace WebCore
 
 #endif // Event_h
index 474f45db9b5dffb646ec61067431e10216438d5a..91c887e7f3e6c727470ebe04612c7595b048bf35 100644 (file)
@@ -70,17 +70,7 @@ private:
     RefPtr<EventTarget> m_relatedTarget;
 };
 
-inline FocusEvent* toFocusEvent(Event* event)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(event && event->isFocusEvent());
-    return static_cast<FocusEvent*>(event);
-}
-
-inline FocusEvent& toFocusEvent(Event& event)
-{
-    ASSERT(event.isFocusEvent());
-    return static_cast<FocusEvent&>(event);
-}
+EVENT_TYPE_CASTS(FocusEvent)
 
 } // namespace WebCore
 
index c0e16f84172d57a49f97ae67153c70acd704daae..7916908ddbe4a3c39255fc4ef5d5609e34aaa23c 100644 (file)
@@ -207,7 +207,7 @@ KeyboardEvent* findKeyboardEvent(Event* event)
 {
     for (Event* e = event; e; e = e->underlyingEvent())
         if (e->isKeyboardEvent())
-            return static_cast<KeyboardEvent*>(e);
+            return toKeyboardEvent(e);
     return 0;
 }
 
index e028052d20b72d560ed6835ad71cda67b92afc9f..bd2d1fb61b13d134d06e30031d968cfb59876bf1 100644 (file)
@@ -124,6 +124,8 @@ private:
 #endif
 };
 
+EVENT_TYPE_CASTS(KeyboardEvent)
+
 KeyboardEvent* findKeyboardEvent(Event*);
 
 } // namespace WebCore
index 5682f8a53485c774c97697689bfba4ecaf6e5c16..33559501b7f64e59c9a4895c49a16b41450605e4 100644 (file)
@@ -277,7 +277,7 @@ SimulatedMouseEvent::SimulatedMouseEvent(const AtomicString& eventType, PassRefP
     setUnderlyingEvent(underlyingEvent);
 
     if (this->underlyingEvent() && this->underlyingEvent()->isMouseEvent()) {
-        MouseEvent* mouseEvent = static_cast<MouseEvent*>(this->underlyingEvent());
+        MouseEvent* mouseEvent = toMouseEvent(this->underlyingEvent());
         m_screenLocation = mouseEvent->screenLocation();
         initCoordinates(mouseEvent->clientLocation());
     } else if (target) {
index 3b550cb8c8bd73aaf261e7cd6bb1afb20c31c618..af5d1971be494dd940fe3dc4d0d21f19c4b29a2f 100644 (file)
@@ -131,17 +131,7 @@ private:
     SimulatedMouseEvent(const AtomicString& eventType, PassRefPtr<AbstractView>, PassRefPtr<Event> underlyingEvent, Element* target);
 };
 
-inline MouseEvent* toMouseEvent(Event* event)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(event && event->isMouseEvent());
-    return static_cast<MouseEvent*>(event);
-}
-
-inline MouseEvent& toMouseEvent(Event& event)
-{
-    ASSERT(event.isMouseEvent());
-    return static_cast<MouseEvent&>(event);
-}
+EVENT_TYPE_CASTS(MouseEvent)
 
 } // namespace WebCore
 
index 72f8a84b8bf00b33a50a66abb946794166fa1e27..9e9545d6aa367dc99d9d4de19aa42bb0b4240466 100644 (file)
@@ -2101,9 +2101,9 @@ void Node::defaultEventHandler(Event* event)
     if (eventType == eventNames().keydownEvent || eventType == eventNames().keypressEvent) {
         if (event->isKeyboardEvent())
             if (Frame* frame = document().frame())
-                frame->eventHandler().defaultKeyboardEventHandler(static_cast<KeyboardEvent*>(event));
+                frame->eventHandler().defaultKeyboardEventHandler(toKeyboardEvent(event));
     } else if (eventType == eventNames().clickEvent) {
-        int detail = event->isUIEvent() ? static_cast<UIEvent*>(event)->detail() : 0;
+        int detail = event->isUIEvent() ? toUIEvent(event)->detail() : 0;
         if (dispatchDOMActivateEvent(detail, event))
             event->setDefaultHandled();
 #if ENABLE(CONTEXT_MENUS)
@@ -2115,11 +2115,10 @@ void Node::defaultEventHandler(Event* event)
     } else if (eventType == eventNames().textInputEvent) {
         if (event->eventInterface() == TextEventInterfaceType)
             if (Frame* frame = document().frame())
-                frame->eventHandler().defaultTextInputEventHandler(static_cast<TextEvent*>(event));
+                frame->eventHandler().defaultTextInputEventHandler(toTextEvent(event));
 #if ENABLE(PAN_SCROLLING)
     } else if (eventType == eventNames().mousedownEvent && event->isMouseEvent()) {
-        MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
-        if (mouseEvent->button() == MiddleButton) {
+        if (toMouseEvent(event)->button() == MiddleButton) {
             if (enclosingLinkEventParentOrSelf())
                 return;
 
@@ -2134,8 +2133,7 @@ void Node::defaultEventHandler(Event* event)
         }
 #endif
     } else if ((eventType == eventNames().wheelEvent || eventType == eventNames().mousewheelEvent) && event->eventInterface() == WheelEventInterfaceType) {
-        WheelEvent* wheelEvent = static_cast<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.
         Node* startNode = this;
@@ -2144,18 +2142,16 @@ void Node::defaultEventHandler(Event* event)
         
         if (startNode && startNode->renderer())
             if (Frame* frame = document().frame())
-                frame->eventHandler().defaultWheelEventHandler(startNode, wheelEvent);
+                frame->eventHandler().defaultWheelEventHandler(startNode, toWheelEvent(event));
 #if ENABLE(TOUCH_EVENTS) && PLATFORM(IOS)
     } else if (event->eventInterface() == TouchEventInterfaceType && eventNames().isTouchEventType(eventType)) {
-        TouchEvent* touchEvent = static_cast<TouchEvent*>(event);
-
         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(), touchEvent);
+                frame->eventHandler().defaultTouchEventHandler(renderer->node(), toTouchEvent(touchEvent));
         }
 #endif
     } else if (event->type() == eventNames().webkitEditableContentChangedEvent) {
index cdc668de4dee457dacf22baf62d009f6534676dc..c5cf3cb5b37cf911178feea16759503c56975f36 100644 (file)
@@ -118,4 +118,9 @@ EventInterface TextEvent::eventInterface() const
     return TextEventInterfaceType;
 }
 
+bool TextEvent::isTextEvent() const
+{
+    return true;
+}
+
 } // namespace WebCore
index 6cc2cb02c8566b87dc06bec4573f1b4bbaa3741f..083c7e546b293c7e2a33399eeb4489eb3b8da1d9 100644 (file)
@@ -73,6 +73,8 @@ namespace WebCore {
                   bool shouldSmartReplace, bool shouldMatchStyle);
         TextEvent(PassRefPtr<AbstractView>, const String& data, const Vector<DictationAlternative>& dictationAlternatives);
 
+        virtual bool isTextEvent() const override;
+
         TextEventInputType m_inputType;
         String m_data;
 
@@ -82,6 +84,8 @@ namespace WebCore {
         Vector<DictationAlternative> m_dictationAlternatives;
     };
 
+EVENT_TYPE_CASTS(TextEvent)
+
 } // namespace WebCore
 
 #endif // TextEvent_h
index 1a73ccac5c8f3cc1019e36c61a8797f45546887c..39a116344495f45dd68fd24e6059a568680b4829 100644 (file)
@@ -86,17 +86,7 @@ private:
     RefPtr<TouchList> m_changedTouches;
 };
 
-inline TouchEvent* toTouchEvent(Event* event)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(event && event->isTouchEvent());
-    return static_cast<TouchEvent*>(event);
-}
-
-inline TouchEvent& toTouchEvent(Event& event)
-{
-    ASSERT(event.isTouchEvent());
-    return static_cast<TouchEvent&>(event);
-}
+EVENT_TYPE_CASTS(TouchEvent)
 
 } // namespace WebCore
 
index 077bee460f3e85aff776b7f59c31e630868c96bf..d31ebbcd269bac6f0f0d05e5e964dcfd436ce77c 100644 (file)
@@ -85,6 +85,8 @@ private:
     int m_detail;
 };
 
+EVENT_TYPE_CASTS(UIEvent)
+
 } // namespace WebCore
 
 #endif // UIEvent_h
index ee672cbb272f2068e0eecdae883dffd08f90d376..9c9fc24cf91bd3bd0eff64171141c24b9082389c 100644 (file)
@@ -124,4 +124,9 @@ bool WheelEvent::isMouseEvent() const
     return false;
 }
 
+bool WheelEvent::isWheelEvent() const
+{
+    return true;
+}
+
 } // namespace WebCore
index 07c030e3f421599ff95e04dde66a0a0c4a577796..f164de37364aff0ef8e7c7a341ebb410da7989fd 100644 (file)
@@ -102,6 +102,8 @@ private:
         unsigned, PassRefPtr<AbstractView>, const IntPoint& screenLocation, const IntPoint& pageLocation,
         bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool directionInvertedFromDevice, double timestamp);
 
+    virtual bool isWheelEvent() const override;
+
     IntPoint m_wheelDelta;
     double m_deltaX;
     double m_deltaY;
@@ -110,6 +112,8 @@ private:
     bool m_directionInvertedFromDevice;
 };
 
+EVENT_TYPE_CASTS(WheelEvent)
+
 } // namespace WebCore
 
 #endif // WheelEvent_h
index c04644392e746a37f87074aff84c052b57f34465..041226751fa9d571794c3ac06ef9e1a9ffd7dd9b 100644 (file)
@@ -168,7 +168,7 @@ static void appendServerMapMousePosition(StringBuilder& url, Event* event)
     RenderImage* renderer = toRenderImage(imageElement->renderer());
 
     // FIXME: This should probably pass true for useTransforms.
-    FloatPoint absolutePosition = renderer->absoluteToLocal(FloatPoint(static_cast<MouseEvent*>(event)->pageX(), static_cast<MouseEvent*>(event)->pageY()));
+    FloatPoint absolutePosition = renderer->absoluteToLocal(FloatPoint(toMouseEvent(event)->pageX(), toMouseEvent(event)->pageY()));
     int x = absolutePosition.x();
     int y = absolutePosition.y();
     url.append('?');
@@ -194,9 +194,9 @@ void HTMLAnchorElement::defaultEventHandler(Event* event)
         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() && static_cast<MouseEvent*>(event)->button() != RightButton && document().frame()) {
+            if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && toMouseEvent(event)->button() != RightButton && document().frame()) {
                 setRootEditableElementForSelectionOnMouseDown(document().frame()->selection().selection().rootEditableElement());
-                m_wasShiftKeyDownOnMouseDown = static_cast<MouseEvent*>(event)->shiftKey();
+                m_wasShiftKeyDownOnMouseDown = toMouseEvent(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.
@@ -556,7 +556,7 @@ HTMLAnchorElement::EventType HTMLAnchorElement::eventType(Event* event)
 {
     if (!event->isMouseEvent())
         return NonMouseEvent;
-    return static_cast<MouseEvent*>(event)->shiftKey() ? MouseEventWithShiftKey : MouseEventWithoutShiftKey;
+    return toMouseEvent(event)->shiftKey() ? MouseEventWithShiftKey : MouseEventWithoutShiftKey;
 }
 
 bool HTMLAnchorElement::treatLinkAsLiveForEventType(EventType eventType) const
@@ -591,12 +591,12 @@ bool HTMLAnchorElement::treatLinkAsLiveForEventType(EventType eventType) const
 
 bool isEnterKeyKeydownEvent(Event* event)
 {
-    return event->type() == eventNames().keydownEvent && event->isKeyboardEvent() && static_cast<KeyboardEvent*>(event)->keyIdentifier() == "Enter";
+    return event->type() == eventNames().keydownEvent && event->isKeyboardEvent() && toKeyboardEvent(event)->keyIdentifier() == "Enter";
 }
 
 bool isLinkClick(Event* event)
 {
-    return event->type() == eventNames().clickEvent && (!event->isMouseEvent() || static_cast<MouseEvent*>(event)->button() != RightButton);
+    return event->type() == eventNames().clickEvent && (!event->isMouseEvent() || toMouseEvent(event)->button() != RightButton);
 }
 
 bool shouldProhibitLinks(Element* element)
index bceeef5e9e5a6b2036166dd6f541f149fd334cba..be1ce66c900cddbe80933f99c42ee345747fdd69 100644 (file)
@@ -124,13 +124,13 @@ void HTMLButtonElement::defaultEventHandler(Event* event)
     }
 
     if (event->isKeyboardEvent()) {
-        if (event->type() == eventNames().keydownEvent && static_cast<KeyboardEvent*>(event)->keyIdentifier() == "U+0020") {
+        if (event->type() == eventNames().keydownEvent && toKeyboardEvent(event)->keyIdentifier() == "U+0020") {
             setActive(true, true);
             // No setDefaultHandled() - IE dispatches a keypress in this case.
             return;
         }
         if (event->type() == eventNames().keypressEvent) {
-            switch (static_cast<KeyboardEvent*>(event)->charCode()) {
+            switch (toKeyboardEvent(event)->charCode()) {
                 case '\r':
                     dispatchSimulatedClick(event);
                     event->setDefaultHandled();
@@ -141,7 +141,7 @@ void HTMLButtonElement::defaultEventHandler(Event* event)
                     return;
             }
         }
-        if (event->type() == eventNames().keyupEvent && static_cast<KeyboardEvent*>(event)->keyIdentifier() == "U+0020") {
+        if (event->type() == eventNames().keyupEvent && toKeyboardEvent(event)->keyIdentifier() == "U+0020") {
             if (active())
                 dispatchSimulatedClick(event);
             event->setDefaultHandled();
index 6b793d15e1d82df96eedc57135a15014164a9a55..667bf76c3680c1f44b823629ed20473541d14c9c 100644 (file)
@@ -190,7 +190,7 @@ void HTMLFrameSetElement::willAttachRenderers()
 void HTMLFrameSetElement::defaultEventHandler(Event* evt)
 {
     if (evt->isMouseEvent() && !m_noresize && renderer() && renderer()->isFrameSet()) {
-        if (toRenderFrameSet(renderer())->userResize(static_cast<MouseEvent*>(evt))) {
+        if (toRenderFrameSet(renderer())->userResize(toMouseEvent(evt))) {
             evt->setDefaultHandled();
             return;
         }
index b823fbe968fd8f5e3eeac668d0ceb3cd416a5c60..f8746f9bfe731cb81a22156a81c002fc59afee6c 100644 (file)
@@ -1101,22 +1101,22 @@ void HTMLInputElement::didDispatchClickEvent(Event& event, const InputElementCli
 
 void HTMLInputElement::defaultEventHandler(Event* evt)
 {
-    if (evt->isMouseEvent() && evt->type() == eventNames().clickEvent && static_cast<MouseEvent*>(evt)->button() == LeftButton) {
-        m_inputType->handleClickEvent(static_cast<MouseEvent*>(evt));
+    if (evt->isMouseEvent() && evt->type() == eventNames().clickEvent && toMouseEvent(evt)->button() == LeftButton) {
+        m_inputType->handleClickEvent(toMouseEvent(evt));
         if (evt->defaultHandled())
             return;
     }
 
 #if ENABLE(TOUCH_EVENTS)
     if (evt->isTouchEvent()) {
-        m_inputType->handleTouchEvent(static_cast<TouchEvent*>(evt));
+        m_inputType->handleTouchEvent(toTouchEvent(evt));
         if (evt->defaultHandled())
             return;
     }
 #endif
 
     if (evt->isKeyboardEvent() && evt->type() == eventNames().keydownEvent) {
-        m_inputType->handleKeydownEvent(static_cast<KeyboardEvent*>(evt));
+        m_inputType->handleKeydownEvent(toKeyboardEvent(evt));
         if (evt->defaultHandled())
             return;
     }
@@ -1143,13 +1143,13 @@ void HTMLInputElement::defaultEventHandler(Event* evt)
     // 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(static_cast<KeyboardEvent*>(evt));
+        m_inputType->handleKeypressEvent(toKeyboardEvent(evt));
         if (evt->defaultHandled())
             return;
     }
 
     if (evt->isKeyboardEvent() && evt->type() == eventNames().keyupEvent) {
-        m_inputType->handleKeyupEvent(static_cast<KeyboardEvent*>(evt));
+        m_inputType->handleKeyupEvent(toKeyboardEvent(evt));
         if (evt->defaultHandled())
             return;
     }
@@ -1174,10 +1174,10 @@ void HTMLInputElement::defaultEventHandler(Event* evt)
     }
 
     if (evt->isBeforeTextInsertedEvent())
-        m_inputType->handleBeforeTextInsertedEvent(static_cast<BeforeTextInsertedEvent*>(evt));
+        m_inputType->handleBeforeTextInsertedEvent(toBeforeTextInsertedEvent(evt));
 
     if (evt->isMouseEvent() && evt->type() == eventNames().mousedownEvent) {
-        m_inputType->handleMouseDownEvent(static_cast<MouseEvent*>(evt));
+        m_inputType->handleMouseDownEvent(toMouseEvent(evt));
         if (evt->defaultHandled())
             return;
     }
index c78f3e00d50afcaa2a20e644468d1dbefd67e8d5..88285435198f22d3ac7c44314bd730302a7ee68b 100644 (file)
@@ -1149,7 +1149,7 @@ void HTMLSelectElement::menuListDefaultEventHandler(Event* event)
         if (!event->isKeyboardEvent())
             return;
 
-        if (platformHandleKeydownEvent(static_cast<KeyboardEvent*>(event)))
+        if (platformHandleKeydownEvent(toKeyboardEvent(event)))
             return;
 
         // When using spatial navigation, we want to be able to navigate away
@@ -1160,7 +1160,7 @@ void HTMLSelectElement::menuListDefaultEventHandler(Event* event)
                 return;
         }
 
-        const String& keyIdentifier = static_cast<KeyboardEvent*>(event)->keyIdentifier();
+        const String& keyIdentifier = toKeyboardEvent(event)->keyIdentifier();
         bool handled = true;
         const Vector<HTMLElement*>& listItems = this->listItems();
         int listIndex = optionToListIndex(selectedIndex());
@@ -1201,7 +1201,7 @@ void HTMLSelectElement::menuListDefaultEventHandler(Event* event)
         if (!event->isKeyboardEvent())
             return;
 
-        int keyCode = static_cast<KeyboardEvent*>(event)->keyCode();
+        int keyCode = toKeyboardEvent(event)->keyCode();
         bool handled = false;
 
         if (keyCode == ' ' && isSpatialNavigationEnabled(document().frame())) {
@@ -1256,7 +1256,7 @@ void HTMLSelectElement::menuListDefaultEventHandler(Event* event)
             event->setDefaultHandled();
     }
 
-    if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton) {
+    if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && toMouseEvent(event)->button() == LeftButton) {
         focus();
 #if !PLATFORM(IOS)
         if (renderer() && renderer()->isMenuList()) {
@@ -1339,14 +1339,14 @@ void HTMLSelectElement::listBoxDefaultEventHandler(Event* event)
 {
     const Vector<HTMLElement*>& listItems = this->listItems();
 
-    if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton) {
+    if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && toMouseEvent(event)->button() == LeftButton) {
         focus();
         // Calling focus() may cause us to lose our renderer, in which case do not want to handle the event.
         if (!renderer())
             return;
 
         // Convert to coords relative to the list box if needed.
-        MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
+        MouseEvent* mouseEvent = toMouseEvent(event);
         IntPoint localOffset = roundedIntPoint(renderer()->absoluteToLocal(mouseEvent->absoluteLocation(), UseTransforms));
         int listIndex = toRenderListBox(renderer())->listIndexAtOffset(toIntSize(localOffset));
         if (listIndex >= 0) {
@@ -1363,7 +1363,7 @@ void HTMLSelectElement::listBoxDefaultEventHandler(Event* event)
             event->setDefaultHandled();
         }
     } else if (event->type() == eventNames().mousemoveEvent && event->isMouseEvent() && !toRenderBox(renderer())->canBeScrolledAndHasScrollableArea()) {
-        MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
+        MouseEvent* mouseEvent = toMouseEvent(event);
         if (mouseEvent->button() != LeftButton || !mouseEvent->buttonDown())
             return;
 
@@ -1386,7 +1386,7 @@ void HTMLSelectElement::listBoxDefaultEventHandler(Event* event)
             }
             event->setDefaultHandled();
         }
-    } else if (event->type() == eventNames().mouseupEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton && document().frame()->eventHandler().autoscrollRenderer() != renderer()) {
+    } else if (event->type() == eventNames().mouseupEvent && event->isMouseEvent() && toMouseEvent(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;
@@ -1397,7 +1397,7 @@ void HTMLSelectElement::listBoxDefaultEventHandler(Event* event)
     } else if (event->type() == eventNames().keydownEvent) {
         if (!event->isKeyboardEvent())
             return;
-        const String& keyIdentifier = static_cast<KeyboardEvent*>(event)->keyIdentifier();
+        const String& keyIdentifier = toKeyboardEvent(event)->keyIdentifier();
 
         bool handled = false;
         int endIndex = 0;
@@ -1459,15 +1459,15 @@ void HTMLSelectElement::listBoxDefaultEventHandler(Event* event)
 #if PLATFORM(COCOA)
             m_allowsNonContiguousSelection = m_multiple && isSpatialNavigationEnabled(document().frame());
 #else
-            m_allowsNonContiguousSelection = m_multiple && (isSpatialNavigationEnabled(document().frame()) || static_cast<KeyboardEvent*>(event)->ctrlKey());
+            m_allowsNonContiguousSelection = m_multiple && (isSpatialNavigationEnabled(document().frame()) || toKeyboardEvent(event)->ctrlKey());
 #endif
-            bool selectNewItem = static_cast<KeyboardEvent*>(event)->shiftKey() || !m_allowsNonContiguousSelection;
+            bool selectNewItem = toKeyboardEvent(event)->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 || (!static_cast<KeyboardEvent*>(event)->shiftKey() && selectNewItem);
+            bool deselectOthers = !m_multiple || (!toKeyboardEvent(event)->shiftKey() && selectNewItem);
             if (m_activeSelectionAnchorIndex < 0 || deselectOthers) {
                 if (deselectOthers)
                     deselectItemsWithoutValidation();
@@ -1486,7 +1486,7 @@ void HTMLSelectElement::listBoxDefaultEventHandler(Event* event)
     } else if (event->type() == eventNames().keypressEvent) {
         if (!event->isKeyboardEvent())
             return;
-        int keyCode = static_cast<KeyboardEvent*>(event)->keyCode();
+        int keyCode = toKeyboardEvent(event)->keyCode();
 
         if (keyCode == '\r') {
             if (form())
@@ -1527,7 +1527,7 @@ void HTMLSelectElement::defaultEventHandler(Event* event)
         return;
 
     if (event->type() == eventNames().keypressEvent && event->isKeyboardEvent()) {
-        KeyboardEvent* keyboardEvent = static_cast<KeyboardEvent*>(event);
+        KeyboardEvent* keyboardEvent = toKeyboardEvent(event);
         if (!keyboardEvent->ctrlKey() && !keyboardEvent->altKey() && !keyboardEvent->metaKey() && u_isprint(keyboardEvent->charCode())) {
             typeAheadFind(keyboardEvent);
             event->setDefaultHandled();
index 7c41386e65a26edde344a80ee1f5516f1d1e1c05..d4c9e0ba4de6102a69a7170c7fe024a680f2c742 100644 (file)
@@ -126,13 +126,13 @@ void HTMLSummaryElement::defaultEventHandler(Event* event)
         }
 
         if (event->isKeyboardEvent()) {
-            if (event->type() == eventNames().keydownEvent && static_cast<KeyboardEvent*>(event)->keyIdentifier() == "U+0020") {
+            if (event->type() == eventNames().keydownEvent && toKeyboardEvent(event)->keyIdentifier() == "U+0020") {
                 setActive(true, true);
                 // No setDefaultHandled() - IE dispatches a keypress in this case.
                 return;
             }
             if (event->type() == eventNames().keypressEvent) {
-                switch (static_cast<KeyboardEvent*>(event)->charCode()) {
+                switch (toKeyboardEvent(event)->charCode()) {
                 case '\r':
                     dispatchSimulatedClick(event);
                     event->setDefaultHandled();
@@ -143,7 +143,7 @@ void HTMLSummaryElement::defaultEventHandler(Event* event)
                     return;
                 }
             }
-            if (event->type() == eventNames().keyupEvent && static_cast<KeyboardEvent*>(event)->keyIdentifier() == "U+0020") {
+            if (event->type() == eventNames().keyupEvent && toKeyboardEvent(event)->keyIdentifier() == "U+0020") {
                 if (active())
                     dispatchSimulatedClick(event);
                 event->setDefaultHandled();
index ec951ac62183cea8481c53bf6755c5465e99bd9a..ed69d7e3b8201375e76972f1d4b380e8ef212d89 100644 (file)
@@ -269,7 +269,7 @@ void HTMLTextAreaElement::defaultEventHandler(Event* event)
     if (renderer() && (event->isMouseEvent() || event->isDragEvent() || event->eventInterface() == WheelEventInterfaceType || event->type() == eventNames().blurEvent))
         forwardEvent(event);
     else if (renderer() && event->isBeforeTextInsertedEvent())
-        handleBeforeTextInsertedEvent(static_cast<BeforeTextInsertedEvent*>(event));
+        handleBeforeTextInsertedEvent(toBeforeTextInsertedEvent(event));
 
     HTMLTextFormControlElement::defaultEventHandler(event);
 }
index fd4de6490ab5749b7914455ffb03f77de8b9890a..51db1b2353ce1284bd08aab82d557148f645aae3 100644 (file)
@@ -417,7 +417,7 @@ void ImageEventListener::handleEvent(ScriptExecutionContext*, Event* event)
     if (event->type() == eventNames().resizeEvent)
         m_doc->windowSizeChanged();
     else if (event->type() == eventNames().clickEvent && event->isMouseEvent()) {
-        MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
+        MouseEvent* mouseEvent = toMouseEvent(event);
         m_doc->imageClicked(mouseEvent->x(), mouseEvent->y());
     }
 }
index 56c53943139ff2505075e124691360e2d15e9aa1..791c5dd09123cf5431a4ecec9ef1a541b610e76d 100644 (file)
@@ -470,7 +470,7 @@ void InputType::forwardEvent(Event*)
 
 bool InputType::shouldSubmitImplicitly(Event* event)
 {
-    return event->isKeyboardEvent() && event->type() == eventNames().keypressEvent && static_cast<KeyboardEvent*>(event)->charCode() == '\r';
+    return event->isKeyboardEvent() && event->type() == eventNames().keypressEvent && toKeyboardEvent(event)->charCode() == '\r';
 }
 
 PassRefPtr<HTMLFormElement> InputType::formForSubmission() const
index a4ac2d67d7f18636b679ed5d84f6abbe5f7c0aaa..6ba8ba47d67713db8d67acb360be8825faf5c0d1 100644 (file)
@@ -187,7 +187,7 @@ void MediaDocument::defaultEventHandler(Event* event)
         if (!video)
             return;
 
-        KeyboardEvent* keyboardEvent = static_cast<KeyboardEvent*>(event);
+        KeyboardEvent* keyboardEvent = toKeyboardEvent(event);
         if (keyboardEvent->keyIdentifier() == "U+0020") { // space
             if (video->paused()) {
                 if (video->canPlay())
index c7f79fd5080f5c054571263417d12603e61cb9b0..1c93036ab1c62008f486df73006697a1a3f711c9 100644 (file)
@@ -202,7 +202,7 @@ void TextFieldInputType::handleBlurEvent()
 
 bool TextFieldInputType::shouldSubmitImplicitly(Event* event)
 {
-    return (event->type() == eventNames().textInputEvent && event->eventInterface() == TextEventInterfaceType && static_cast<TextEvent*>(event)->data() == "\n") || InputType::shouldSubmitImplicitly(event);
+    return (event->type() == eventNames().textInputEvent && event->eventInterface() == TextEventInterfaceType && toTextEvent(event)->data() == "\n") || InputType::shouldSubmitImplicitly(event);
 }
 
 RenderPtr<RenderElement> TextFieldInputType::createInputRenderer(PassRef<RenderStyle> style)
index d6049a5087424b0674cbef20f8aa1f0fc3de3265..4d54a492c66577854c7631618828d4d4f03b29a9 100644 (file)
@@ -255,7 +255,7 @@ MediaControlVolumeSliderElement::MediaControlVolumeSliderElement(Document& docum
 void MediaControlVolumeSliderElement::defaultEventHandler(Event* event)
 {
     // Left button is 0. Rejects mouse events not from left button.
-    if (event->isMouseEvent() && static_cast<MouseEvent*>(event)->button())
+    if (event->isMouseEvent() && toMouseEvent(event)->button())
         return;
 
     if (!renderer())
index 0aced786fb4e231a241bc7920f0fa2d224bd7212..177f0f8401e0dd41711c85f0cec0a9e1a9bb853e 100644 (file)
@@ -225,7 +225,7 @@ void MediaControlPanelElement::defaultEventHandler(Event* event)
     MediaControlDivElement::defaultEventHandler(event);
 
     if (event->isMouseEvent()) {
-        LayoutPoint location = static_cast<MouseEvent*>(event)->absoluteLocation();
+        LayoutPoint location = toMouseEvent(event)->absoluteLocation();
         if (event->type() == eventNames().mousedownEvent && event->target() == this) {
             startDrag(location);
             event->setDefaultHandled();
@@ -362,7 +362,7 @@ void MediaControlVolumeSliderContainerElement::defaultEventHandler(Event* event)
         return;
 
     // Poor man's mouseleave event detection.
-    MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
+    MouseEvent* mouseEvent = toMouseEvent(event);
     EventTarget* relatedTarget = mouseEvent->relatedTarget();
     if (!relatedTarget || !relatedTarget->toNode())
         return;
@@ -939,7 +939,7 @@ PassRefPtr<MediaControlTimelineElement> MediaControlTimelineElement::create(Docu
 void MediaControlTimelineElement::defaultEventHandler(Event* event)
 {
     // Left button is 0. Rejects mouse events not from left button.
-    if (event->isMouseEvent() && static_cast<MouseEvent*>(event)->button())
+    if (event->isMouseEvent() && toMouseEvent(event)->button())
         return;
 
     if (!renderer())
index 7bfaf436c2a12b37c69e78ff873129a19ff477cb..dedb506b9d3e53943219e07bd1ccf10c0199d974 100644 (file)
@@ -373,7 +373,7 @@ bool MediaControls::containsRelatedTarget(Event* event)
 {
     if (!event->isMouseEvent())
         return false;
-    EventTarget* relatedTarget = static_cast<MouseEvent*>(event)->relatedTarget();
+    EventTarget* relatedTarget = toMouseEvent(event)->relatedTarget();
     if (!relatedTarget)
         return false;
     return contains(relatedTarget->toNode());
index 660e8ebe8a618b66ea785c7c80c5e2e01601bc0d..878bf0ccc93efd83ade1f1eb1119a676ae0df9f7 100644 (file)
@@ -589,7 +589,7 @@ void MediaControlsAppleEventListener::handleEvent(ScriptExecutionContext*, Event
     if (event->type() == eventNames().clickEvent)
         m_mediaControls->handleClickEvent(event);
     else if ((event->type() == eventNames().wheelEvent || event->type() == eventNames().mousewheelEvent) && event->eventInterface() == WheelEventInterfaceType) {
-        WheelEvent* wheelEvent = static_cast<WheelEvent*>(event);
+        WheelEvent* wheelEvent = toWheelEvent(event);
         if (m_mediaControls->shouldClosedCaptionsContainerPreventPageScrolling(wheelEvent->wheelDeltaY()))
             event->preventDefault();
     }
index 33dbf2e52de3361ebd18e51066280d03add33cdc..bfbb4d92b922d0a229f82f9b1fc6e80ff6f003b8 100644 (file)
@@ -350,7 +350,7 @@ void SliderThumbElement::defaultEventHandler(Event* event)
         return;
     }
 
-    MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
+    MouseEvent* mouseEvent = toMouseEvent(event);
     bool isLeftButton = mouseEvent->button() == LeftButton;
     const AtomicString& eventType = event->type();
 
index 5e4711a6834fcdb3487fdb1f2806cb5e97790bc1..c293b5b8267db60aa75c84723f69c0194b121b01 100644 (file)
@@ -91,7 +91,7 @@ void SpinButtonElement::defaultEventHandler(Event* event)
         return;
     }
 
-    MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
+    MouseEvent* mouseEvent = toMouseEvent(event);
     IntPoint local = roundedIntPoint(box->absoluteToLocal(mouseEvent->absoluteLocation(), UseTransforms));
     if (mouseEvent->type() == eventNames().mousedownEvent && mouseEvent->button() == LeftButton) {
         if (box->pixelSnappedBorderBoxRect().contains(local)) {
@@ -160,7 +160,7 @@ void SpinButtonElement::forwardEvent(Event* event)
     if (!m_spinButtonOwner->shouldSpinButtonRespondToWheelEvents())
         return;
 
-    doStepAction(static_cast<WheelEvent*>(event)->wheelDeltaY());
+    doStepAction(toWheelEvent(event)->wheelDeltaY());
     event->setDefaultHandled();
 }
 
index ac35831f3f6a4e72fa88d89482749dfff0906408..19b5bc86885729e0ff07868e269556595f046604 100644 (file)
@@ -162,7 +162,7 @@ void SearchFieldResultsButtonElement::defaultEventHandler(Event* event)
 {
     // On mousedown, bring up a menu, if needed
     HTMLInputElement* input = toHTMLInputElement(shadowHost());
-    if (input && event->type() == eventNames().mousedownEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton) {
+    if (input && event->type() == eventNames().mousedownEvent && event->isMouseEvent() && toMouseEvent(event)->button() == LeftButton) {
         input->focus();
         input->select();
 #if !PLATFORM(IOS)
@@ -224,7 +224,7 @@ void SearchFieldCancelButtonElement::defaultEventHandler(Event* event)
         return;
     }
 
-    if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton) {
+    if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && toMouseEvent(event)->button() == LeftButton) {
         if (renderer() && renderer()->visibleToHitTesting()) {
             if (Frame* frame = document().frame()) {
                 frame->eventHandler().setCapturingMouseEventsElement(this);
@@ -235,7 +235,7 @@ void SearchFieldCancelButtonElement::defaultEventHandler(Event* event)
         input->select();
         event->setDefaultHandled();
     }
-    if (event->type() == eventNames().mouseupEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton) {
+    if (event->type() == eventNames().mouseupEvent && event->isMouseEvent() && toMouseEvent(event)->button() == LeftButton) {
         if (m_capturing) {
             if (Frame* frame = document().frame()) {
                 frame->eventHandler().setCapturingMouseEventsElement(nullptr);
@@ -313,7 +313,7 @@ void InputFieldSpeechButtonElement::defaultEventHandler(Event* event)
     }
 
     // On mouse down, select the text and set focus.
-    if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton) {
+    if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && toMouseEvent(event)->button() == LeftButton) {
         if (renderer() && renderer()->visibleToHitTesting()) {
             if (Frame* frame = document().frame()) {
                 frame->eventHandler().setCapturingMouseEventsElement(this);
@@ -326,7 +326,7 @@ void InputFieldSpeechButtonElement::defaultEventHandler(Event* event)
         event->setDefaultHandled();
     }
     // On mouse up, release capture cleanly.
-    if (event->type() == eventNames().mouseupEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton) {
+    if (event->type() == eventNames().mouseupEvent && event->isMouseEvent() && toMouseEvent(event)->button() == LeftButton) {
         if (m_capturing && renderer() && renderer()->visibleToHitTesting()) {
             if (Frame* frame = document().frame()) {
                 frame->eventHandler().setCapturingMouseEventsElement(nullptr);
index 2bedc02f6f6de7794c7ecdbe0bf644b18ce06e02..0ca61cb945e2da05620ea059637ab4ab06a31759 100644 (file)
@@ -135,11 +135,11 @@ PassOwnPtr<ContextMenu> ContextMenuController::createContextMenu(Event* event)
     if (!event->isMouseEvent())
         return nullptr;
 
-    MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
-    HitTestResult result(mouseEvent->absoluteLocation());
+    MouseEvent& mouseEvent = toMouseEvent(*event);
+    HitTestResult result(mouseEvent.absoluteLocation());
 
     if (Frame* frame = event->target()->toNode()->document().frame())
-        result = frame->eventHandler().hitTestResultAtPoint(mouseEvent->absoluteLocation());
+        result = frame->eventHandler().hitTestResultAtPoint(mouseEvent.absoluteLocation());
 
     if (!result.innerNonSharedNode())
         return nullptr;
index b6293e27a99bbad29065bae3862931401d29a6f2..7bd095f79ff69584c47ca62e08b44159381957a8 100644 (file)
@@ -3257,7 +3257,7 @@ bool EventHandler::handleTextInputEvent(const String& text, Event* underlyingEve
 {
     // 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() || static_cast<KeyboardEvent*>(underlyingEvent)->type() == eventNames().keypressEvent);
+    ASSERT(!underlyingEvent || !underlyingEvent->isKeyboardEvent() || toKeyboardEvent(underlyingEvent)->type() == eventNames().keypressEvent);
 
     EventTarget* target;
     if (underlyingEvent)
index 88c77f667e97729bdd6a3da8a21e0b782f0546d6..75eb872883f859d0a7323ba700bd0da200ba0a16 100644 (file)
@@ -608,9 +608,9 @@ void RenderEmbeddedObject::handleUnavailablePluginIndicatorEvent(Event* event)
     if (!event->isMouseEvent())
         return;
 
-    MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
+    MouseEvent* mouseEvent = toMouseEvent(event);
     HTMLPlugInElement& element = toHTMLPlugInElement(frameOwnerElement());
-    if (event->type() == eventNames().mousedownEvent && static_cast<MouseEvent*>(event)->button() == LeftButton) {
+    if (event->type() == eventNames().mousedownEvent && toMouseEvent(event)->button() == LeftButton) {
         m_mouseDownWasInUnavailablePluginIndicator = isInUnavailablePluginIndicator(mouseEvent);
         if (m_mouseDownWasInUnavailablePluginIndicator) {
             frame().eventHandler().setCapturingMouseEventsElement(&element);
@@ -619,7 +619,7 @@ void RenderEmbeddedObject::handleUnavailablePluginIndicatorEvent(Event* event)
         }
         event->setDefaultHandled();
     }
-    if (event->type() == eventNames().mouseupEvent && static_cast<MouseEvent*>(event)->button() == LeftButton) {
+    if (event->type() == eventNames().mouseupEvent && toMouseEvent(event)->button() == LeftButton) {
         if (m_unavailablePluginIndicatorIsPressed) {
             frame().eventHandler().setCapturingMouseEventsElement(nullptr);
             element.setIsCapturingMouseEvents(false);
index 1aea333f0ef01efc7a90012ac623e68f0e6cd46a..a164f6d074b0af343259ce3ba872d5f6deb07f13 100644 (file)
@@ -156,7 +156,7 @@ void RenderSnapshottedPlugIn::handleEvent(Event* event)
     if (!event->isMouseEvent())
         return;
 
-    MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
+    MouseEvent* mouseEvent = toMouseEvent(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