Commit 6a5401aa authored by adele's avatar adele

Reviewed by Darin.

        A little cleanup from my last checkin.  Always check if an Event is really a MouseEvent or a KeyboardEvent
        before casting it.

        * html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::defaultEventHandler):
        * html/HTMLSelectElement.cpp:
        (WebCore::HTMLSelectElement::menuListDefaultEventHandler):
        (WebCore::HTMLSelectElement::listBoxDefaultEventHandler):
        * html/HTMLTextFieldInnerElement.cpp:
        (WebCore::HTMLSearchFieldResultsButtonElement::defaultEventHandler):
        (WebCore::HTMLSearchFieldCancelButtonElement::defaultEventHandler):
        * ksvg2/svg/SVGAElement.cpp: (WebCore::SVGAElement::defaultEventHandler):
        * page/ContextMenuController.cpp: (WebCore::ContextMenuController::handleContextMenuEvent):
        * rendering/RenderFrameSet.cpp: (WebCore::RenderFrameSet::userResize):
        * rendering/RenderSlider.cpp: (WebCore::HTMLSliderThumbElement::defaultEventHandler):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@20724 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 2a8a606f
2007-04-05 Adele Peterson <adele@apple.com>
Reviewed by Darin.
A little cleanup from my last checkin. Always check if an Event is really a MouseEvent or a KeyboardEvent
before casting it.
* html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::defaultEventHandler):
* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::menuListDefaultEventHandler):
(WebCore::HTMLSelectElement::listBoxDefaultEventHandler):
* html/HTMLTextFieldInnerElement.cpp:
(WebCore::HTMLSearchFieldResultsButtonElement::defaultEventHandler):
(WebCore::HTMLSearchFieldCancelButtonElement::defaultEventHandler):
* ksvg2/svg/SVGAElement.cpp: (WebCore::SVGAElement::defaultEventHandler):
* page/ContextMenuController.cpp: (WebCore::ContextMenuController::handleContextMenuEvent):
* rendering/RenderFrameSet.cpp: (WebCore::RenderFrameSet::userResize):
* rendering/RenderSlider.cpp: (WebCore::HTMLSliderThumbElement::defaultEventHandler):
2007-04-05 Geoffrey Garen <ggaren@apple.com>
Reviewed by Beth Dakin.
......@@ -127,11 +127,11 @@ void HTMLAnchorElement::defaultEventHandler(Event* evt)
// when pressing Enter in the combo.
if (m_isLink && (evt->type() == clickEvent || (evt->type() == keydownEvent && m_focused))) {
MouseEvent* e = 0;
if (evt->type() == clickEvent)
if (evt->type() == clickEvent && evt->isMouseEvent())
e = static_cast<MouseEvent*>(evt);
KeyboardEvent* k = 0;
if (evt->type() == keydownEvent)
if (evt->type() == keydownEvent && k->isKeyboardEvent())
k = static_cast<KeyboardEvent*>(evt);
if (e && e->button() == 2) {
......@@ -221,7 +221,7 @@ void HTMLAnchorElement::defaultEventHandler(Event* evt)
} else if (m_isLink && isContentEditable()) {
// 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 (evt->type() == mousedownEvent && static_cast<MouseEvent*>(evt)->button() != RightButton && document()->frame() && document()->frame()->selectionController()) {
if (evt->type() == mousedownEvent && evt->isMouseEvent() && static_cast<MouseEvent*>(evt)->button() != RightButton && document()->frame() && document()->frame()->selectionController()) {
MouseEvent* e = static_cast<MouseEvent*>(evt);
m_rootEditableElementForSelectionOnMouseDown = document()->frame()->selectionController()->rootEditableElement();
......
......@@ -675,7 +675,7 @@ void HTMLSelectElement::menuListDefaultEventHandler(Event* evt)
evt->setDefaultHandled();
}
if (evt->type() == mousedownEvent && static_cast<MouseEvent*>(evt)->button() == LeftButton) {
if (evt->type() == mousedownEvent && evt->isMouseEvent() && static_cast<MouseEvent*>(evt)->button() == LeftButton) {
focus();
if (menuList->popupIsVisible())
menuList->hidePopup();
......@@ -694,7 +694,7 @@ void HTMLSelectElement::listBoxDefaultEventHandler(Event* evt)
if (!renderer() || !renderer()->canSelect())
return;
if (evt->type() == mousedownEvent && static_cast<MouseEvent*>(evt)->button() == LeftButton) {
if (evt->type() == mousedownEvent && evt->isMouseEvent() && static_cast<MouseEvent*>(evt)->button() == LeftButton) {
focus();
MouseEvent* mEvt = static_cast<MouseEvent*>(evt);
......@@ -754,7 +754,7 @@ void HTMLSelectElement::listBoxDefaultEventHandler(Event* evt)
evt->setDefaultHandled();
}
} else if (evt->type() == mouseupEvent && static_cast<MouseEvent*>(evt)->button() == LeftButton && document()->frame()->eventHandler()->autoscrollRenderer() != renderer())
} else if (evt->type() == mouseupEvent && evt->isMouseEvent() && static_cast<MouseEvent*>(evt)->button() == LeftButton && document()->frame()->eventHandler()->autoscrollRenderer() != renderer())
// This makes sure we fire onChange for a single click. For drag selection, onChange will fire when the autoscroll timer stops.
listBoxOnChange();
else if (evt->type() == keypressEvent) {
......
......@@ -77,7 +77,7 @@ void HTMLSearchFieldResultsButtonElement::defaultEventHandler(Event* evt)
{
// On mousedown, bring up a menu, if needed
HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowAncestorNode());
if (evt->type() == mousedownEvent && static_cast<MouseEvent*>(evt)->button() == LeftButton) {
if (evt->type() == mousedownEvent && evt->isMouseEvent() && static_cast<MouseEvent*>(evt)->button() == LeftButton) {
input->focus();
input->select();
if (input && input->renderer() && static_cast<RenderTextControl*>(input->renderer())->popupIsVisible())
......@@ -100,14 +100,14 @@ void HTMLSearchFieldCancelButtonElement::defaultEventHandler(Event* evt)
{
// If the element is visible, on mouseup, clear the value, and set selection
HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowAncestorNode());
if (evt->type() == mousedownEvent && static_cast<MouseEvent*>(evt)->button() == LeftButton) {
if (evt->type() == mousedownEvent && evt->isMouseEvent() && static_cast<MouseEvent*>(evt)->button() == LeftButton) {
input->focus();
input->select();
evt->setDefaultHandled();
if (Frame* frame = document()->frame())
frame->eventHandler()->setCapturingMouseEventsNode(this);
m_capturing = true;
} else if (evt->type() == mouseupEvent && static_cast<MouseEvent*>(evt)->button() == LeftButton) {
} else if (evt->type() == mouseupEvent && evt->isMouseEvent() && static_cast<MouseEvent*>(evt)->button() == LeftButton) {
if (m_capturing && renderer() && renderer()->style()->visibility() == VISIBLE) {
if (hovered()) {
input->setValue("");
......
......@@ -95,7 +95,7 @@ RenderObject* SVGAElement::createRenderer(RenderArena* arena, RenderStyle* style
void SVGAElement::defaultEventHandler(Event* evt)
{
// TODO : should use CLICK instead
if ((evt->type() == EventNames::mouseupEvent && static_cast<MouseEvent*>(evt)->button() != RightButton && m_isLink)) {
if ((evt->type() == EventNames::mouseupEvent && evt->isMouseEvent() && static_cast<MouseEvent*>(evt)->button() != RightButton && m_isLink)) {
MouseEvent* e = static_cast<MouseEvent*>(evt);
if (e && e->button() == RightButton) {
......
......@@ -77,6 +77,8 @@ void ContextMenuController::clearContextMenu()
void ContextMenuController::handleContextMenuEvent(Event* event)
{
ASSERT(event->type() == contextmenuEvent);
if (!event->isMouseEvent())
return;
MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
IntPoint point = IntPoint(mouseEvent->pageX(), mouseEvent->pageY());
HitTestResult result(point);
......
......@@ -568,7 +568,7 @@ bool RenderFrameSet::userResize(MouseEvent* evt)
if (evt->type() == mousemoveEvent || (evt->type() == mouseupEvent && evt->button() == LeftButton)) {
continueResizing(m_cols, evt->pageX() - xPos());
continueResizing(m_rows, evt->pageY() - yPos());
if (evt->type() == mouseupEvent && evt->button() == 0) {
if (evt->type() == mouseupEvent && evt->button() == LeftButton) {
setIsResizing(false);
return true;
}
......
......@@ -87,7 +87,7 @@ void HTMLSliderThumbElement::defaultEventHandler(Event* event)
event->setDefaultHandled();
return;
}
} else if (eventType == mouseupEvent && static_cast<MouseEvent*>(event)->button() == LeftButton) {
} else if (eventType == mouseupEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton) {
if (m_inDragMode) {
if (Frame* frame = document()->frame())
frame->eventHandler()->setCapturingMouseEventsNode(0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment