+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
if (!scriptExecutionContext)
return;
- ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event);
+ ErrorEvent* errorEvent = toErrorEvent(event);
JSLockHolder lock(scriptExecutionContext->vm());
String m_text;
};
+EVENT_TYPE_CASTS(BeforeTextInsertedEvent)
+
} // namespace
#endif
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
return ErrorEventInterfaceType;
}
+bool ErrorEvent::isErrorEvent() const
+{
+ return true;
+}
+
} // namespace WebCore
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
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());
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; }
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
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
{
for (Event* e = event; e; e = e->underlyingEvent())
if (e->isKeyboardEvent())
- return static_cast<KeyboardEvent*>(e);
+ return toKeyboardEvent(e);
return 0;
}
#endif
};
+EVENT_TYPE_CASTS(KeyboardEvent)
+
KeyboardEvent* findKeyboardEvent(Event*);
} // namespace WebCore
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) {
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
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)
} 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;
}
#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;
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) {
return TextEventInterfaceType;
}
+bool TextEvent::isTextEvent() const
+{
+ return true;
+}
+
} // 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;
Vector<DictationAlternative> m_dictationAlternatives;
};
+EVENT_TYPE_CASTS(TextEvent)
+
} // namespace WebCore
#endif // TextEvent_h
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
int m_detail;
};
+EVENT_TYPE_CASTS(UIEvent)
+
} // namespace WebCore
#endif // UIEvent_h
return false;
}
+bool WheelEvent::isWheelEvent() const
+{
+ return true;
+}
+
} // namespace WebCore
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;
bool m_directionInvertedFromDevice;
};
+EVENT_TYPE_CASTS(WheelEvent)
+
} // namespace WebCore
#endif // WheelEvent_h
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('?');
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.
{
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
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)
}
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();
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();
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;
}
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;
}
// 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;
}
}
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;
}
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
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());
if (!event->isKeyboardEvent())
return;
- int keyCode = static_cast<KeyboardEvent*>(event)->keyCode();
+ int keyCode = toKeyboardEvent(event)->keyCode();
bool handled = false;
if (keyCode == ' ' && isSpatialNavigationEnabled(document().frame())) {
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()) {
{
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) {
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;
}
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;
} 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;
#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();
} 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())
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();
}
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();
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();
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);
}
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());
}
}
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
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())
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)
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())
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();
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;
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())
{
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());
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();
}
return;
}
- MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
+ MouseEvent* mouseEvent = toMouseEvent(event);
bool isLeftButton = mouseEvent->button() == LeftButton;
const AtomicString& eventType = event->type();
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)) {
if (!m_spinButtonOwner->shouldSpinButtonRespondToWheelEvents())
return;
- doStepAction(static_cast<WheelEvent*>(event)->wheelDeltaY());
+ doStepAction(toWheelEvent(event)->wheelDeltaY());
event->setDefaultHandled();
}
{
// 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)
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);
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);
}
// 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);
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);
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;
{
// 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)
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);
}
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);
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