Commit e5a78332 authored by arv@chromium.org's avatar arv@chromium.org

Revert "MouseEvent Cleanup: Replace isSimulated with new SyntheticEventType value."

This reverts commit f4f316b59d15194c8caf75b0037276380e978f5a.

Broke webkit_tests fast/forms/input-image-submit.html
on WebKit XP and WebKit Linux 32

BUG=405990
TBR=tkent, rbyers@chromium.org, igsolla@chromium.org, eseidel

Review URL: https://codereview.chromium.org/543793004

git-svn-id: svn://svn.chromium.org/blink/trunk@181396 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 7fe7d9f8
......@@ -87,19 +87,19 @@ void EventDispatcher::dispatchSimulatedClick(Node* node, Event* underlyingEvent,
nodesDispatchingSimulatedClicks->add(node);
if (mouseEventOptions == SendMouseOverUpDownEvents)
EventDispatcher(node, MouseEvent::create(EventTypeNames::mouseover, node->document().domWindow(), underlyingEvent)).dispatch();
EventDispatcher(node, SimulatedMouseEvent::create(EventTypeNames::mouseover, node->document().domWindow(), underlyingEvent)).dispatch();
if (mouseEventOptions != SendNoEvents) {
EventDispatcher(node, MouseEvent::create(EventTypeNames::mousedown, node->document().domWindow(), underlyingEvent)).dispatch();
EventDispatcher(node, SimulatedMouseEvent::create(EventTypeNames::mousedown, node->document().domWindow(), underlyingEvent)).dispatch();
node->setActive(true);
EventDispatcher(node, MouseEvent::create(EventTypeNames::mouseup, node->document().domWindow(), underlyingEvent)).dispatch();
EventDispatcher(node, SimulatedMouseEvent::create(EventTypeNames::mouseup, node->document().domWindow(), underlyingEvent)).dispatch();
}
// Some elements (e.g. the color picker) may set active state to true before
// calling this method and expect the state to be reset during the call.
node->setActive(false);
// always send click
EventDispatcher(node, MouseEvent::create(EventTypeNames::click, node->document().domWindow(), underlyingEvent)).dispatch();
EventDispatcher(node, SimulatedMouseEvent::create(EventTypeNames::click, node->document().domWindow(), underlyingEvent)).dispatch();
nodesDispatchingSimulatedClicks->remove(node);
}
......
......@@ -88,7 +88,7 @@ GestureEvent::GestureEvent()
}
GestureEvent::GestureEvent(const AtomicString& type, PassRefPtrWillBeRawPtr<AbstractView> view, int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, float deltaX, float deltaY)
: MouseRelatedEvent(type, true, true, view, 0, IntPoint(screenX, screenY), IntPoint(clientX, clientY), IntPoint(0, 0), ctrlKey, altKey, shiftKey, metaKey, true)
: MouseRelatedEvent(type, true, true, view, 0, IntPoint(screenX, screenY), IntPoint(clientX, clientY), IntPoint(0, 0), ctrlKey, altKey, shiftKey, metaKey)
, m_deltaX(deltaX)
, m_deltaY(deltaY)
{
......
......@@ -39,7 +39,6 @@ public:
static PassRefPtrWillBeRawPtr<GestureEvent> create(PassRefPtrWillBeRawPtr<AbstractView>, const PlatformGestureEvent&);
virtual bool isGestureEvent() const OVERRIDE;
bool hasPosition() const OVERRIDE { return true; };
virtual const AtomicString& interfaceName() const OVERRIDE;
......
......@@ -62,56 +62,19 @@ PassRefPtrWillBeRawPtr<MouseEvent> MouseEvent::create(const AtomicString& eventT
detail, event.globalPosition().x(), event.globalPosition().y(), event.position().x(), event.position().y(),
event.movementDelta().x(), event.movementDelta().y(),
event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(), event.button(),
relatedTarget, nullptr, event.syntheticEventType());
relatedTarget, nullptr, false, event.syntheticEventType());
}
PassRefPtrWillBeRawPtr<MouseEvent> MouseEvent::create(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView> view,
int detail, int screenX, int screenY, int pageX, int pageY,
int movementX, int movementY,
bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short button,
PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, PassRefPtrWillBeRawPtr<DataTransfer> dataTransfer, PlatformMouseEvent::SyntheticEventType syntheticEventType)
PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, PassRefPtrWillBeRawPtr<DataTransfer> dataTransfer, bool isSimulated, PlatformMouseEvent::SyntheticEventType syntheticEventType)
{
return adoptRefWillBeNoop(new MouseEvent(type, canBubble, cancelable, view,
detail, screenX, screenY, pageX, pageY,
movementX, movementY,
ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget, dataTransfer, syntheticEventType));
}
PassRefPtrWillBeRawPtr<MouseEvent> MouseEvent::create(const AtomicString& eventType, PassRefPtrWillBeRawPtr<AbstractView> view, PassRefPtrWillBeRawPtr<Event> prpUnderlyingEvent)
{
RefPtrWillBeRawPtr<Event> underlyingEvent = prpUnderlyingEvent;
bool ctrlKey = false;
bool altKey = false;
bool shiftKey = false;
bool metaKey = false;
if (UIEventWithKeyState* keyStateEvent = findEventWithKeyState(underlyingEvent.get())) {
ctrlKey = keyStateEvent->ctrlKey();
altKey = keyStateEvent->altKey();
shiftKey = keyStateEvent->shiftKey();
metaKey = keyStateEvent->metaKey();
}
PlatformMouseEvent::SyntheticEventType syntheticType = PlatformMouseEvent::Positionless;
int screenX = 0;
int screenY = 0;
if (underlyingEvent && underlyingEvent->isMouseEvent()) {
syntheticType = PlatformMouseEvent::RealOrIndistinguishable;
MouseEvent* mouseEvent = toMouseEvent(underlyingEvent.get());
screenX = mouseEvent->screenLocation().x();
screenY = mouseEvent->screenLocation().y();
}
RefPtrWillBeRawPtr<MouseEvent> createdEvent = MouseEvent::create(eventType, true, true, view,
0, screenX, screenY, 0, 0, 0, 0, ctrlKey, altKey, shiftKey, metaKey, 0, nullptr, nullptr,
syntheticType);
createdEvent->setUnderlyingEvent(underlyingEvent);
if (syntheticType == PlatformMouseEvent::RealOrIndistinguishable) {
MouseEvent* mouseEvent = toMouseEvent(underlyingEvent.get());
createdEvent->initCoordinates(mouseEvent->clientLocation());
}
return createdEvent.release();
ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget, dataTransfer, isSimulated, syntheticEventType));
}
MouseEvent::MouseEvent()
......@@ -126,11 +89,11 @@ MouseEvent::MouseEvent(const AtomicString& eventType, bool canBubble, bool cance
int movementX, int movementY,
bool ctrlKey, bool altKey, bool shiftKey, bool metaKey,
unsigned short button, PassRefPtrWillBeRawPtr<EventTarget> relatedTarget,
PassRefPtrWillBeRawPtr<DataTransfer> dataTransfer, PlatformMouseEvent::SyntheticEventType syntheticEventType)
PassRefPtrWillBeRawPtr<DataTransfer> dataTransfer, bool isSimulated, PlatformMouseEvent::SyntheticEventType syntheticEventType)
: MouseRelatedEvent(eventType, canBubble, cancelable, view, detail, IntPoint(screenX, screenY),
IntPoint(pageX, pageY),
IntPoint(movementX, movementY),
ctrlKey, altKey, shiftKey, metaKey, syntheticEventType != PlatformMouseEvent::Positionless)
ctrlKey, altKey, shiftKey, metaKey, isSimulated)
, m_button(button == (unsigned short)-1 ? 0 : button)
, m_buttonDown(button != (unsigned short)-1)
, m_relatedTarget(relatedTarget)
......@@ -144,12 +107,11 @@ MouseEvent::MouseEvent(const AtomicString& eventType, const MouseEventInit& init
: MouseRelatedEvent(eventType, initializer.bubbles, initializer.cancelable, initializer.view, initializer.detail, IntPoint(initializer.screenX, initializer.screenY),
IntPoint(0 /* pageX */, 0 /* pageY */),
IntPoint(0 /* movementX */, 0 /* movementY */),
initializer.ctrlKey, initializer.altKey, initializer.shiftKey, initializer.metaKey, true)
initializer.ctrlKey, initializer.altKey, initializer.shiftKey, initializer.metaKey, false /* isSimulated */)
, m_button(initializer.button == (unsigned short)-1 ? 0 : initializer.button)
, m_buttonDown(initializer.button != (unsigned short)-1)
, m_relatedTarget(initializer.relatedTarget)
, m_dataTransfer(nullptr)
, m_syntheticEventType(PlatformMouseEvent::RealOrIndistinguishable)
{
ScriptWrappable::init(this);
initCoordinates(IntPoint(initializer.clientX, initializer.clientY));
......@@ -180,7 +142,7 @@ void MouseEvent::initMouseEvent(const AtomicString& type, bool canBubble, bool c
initCoordinates(IntPoint(clientX, clientY));
// FIXME: SyntheticEventType is not set to RealOrIndistinguishable here.
// FIXME: m_isSimulated is not set to false here.
// FIXME: m_dataTransfer is not set to nullptr here.
}
......@@ -236,6 +198,39 @@ void MouseEvent::trace(Visitor* visitor)
MouseRelatedEvent::trace(visitor);
}
PassRefPtrWillBeRawPtr<SimulatedMouseEvent> SimulatedMouseEvent::create(const AtomicString& eventType, PassRefPtrWillBeRawPtr<AbstractView> view, PassRefPtrWillBeRawPtr<Event> underlyingEvent)
{
return adoptRefWillBeNoop(new SimulatedMouseEvent(eventType, view, underlyingEvent));
}
SimulatedMouseEvent::~SimulatedMouseEvent()
{
}
SimulatedMouseEvent::SimulatedMouseEvent(const AtomicString& eventType, PassRefPtrWillBeRawPtr<AbstractView> view, PassRefPtrWillBeRawPtr<Event> underlyingEvent)
: MouseEvent(eventType, true, true, view, 0, 0, 0, 0, 0, 0, 0, false, false, false, false, 0,
nullptr, nullptr, true, PlatformMouseEvent::RealOrIndistinguishable)
{
if (UIEventWithKeyState* keyStateEvent = findEventWithKeyState(underlyingEvent.get())) {
m_ctrlKey = keyStateEvent->ctrlKey();
m_altKey = keyStateEvent->altKey();
m_shiftKey = keyStateEvent->shiftKey();
m_metaKey = keyStateEvent->metaKey();
}
setUnderlyingEvent(underlyingEvent);
if (this->underlyingEvent() && this->underlyingEvent()->isMouseEvent()) {
MouseEvent* mouseEvent = toMouseEvent(this->underlyingEvent());
m_screenLocation = mouseEvent->screenLocation();
initCoordinates(mouseEvent->clientLocation());
}
}
void SimulatedMouseEvent::trace(Visitor* visitor)
{
MouseEvent::trace(visitor);
}
PassRefPtrWillBeRawPtr<MouseEventDispatchMediator> MouseEventDispatchMediator::create(PassRefPtrWillBeRawPtr<MouseEvent> mouseEvent, MouseEventType mouseEventType)
{
return adoptRefWillBeNoop(new MouseEventDispatchMediator(mouseEvent, mouseEventType));
......
......@@ -61,14 +61,12 @@ public:
int movementX, int movementY,
bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short button,
PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, PassRefPtrWillBeRawPtr<DataTransfer>,
PlatformMouseEvent::SyntheticEventType = PlatformMouseEvent::RealOrIndistinguishable);
bool isSimulated = false, PlatformMouseEvent::SyntheticEventType = PlatformMouseEvent::RealOrIndistinguishable);
static PassRefPtrWillBeRawPtr<MouseEvent> create(const AtomicString& eventType, PassRefPtrWillBeRawPtr<AbstractView>, const PlatformMouseEvent&, int detail, PassRefPtrWillBeRawPtr<Node> relatedTarget);
static PassRefPtrWillBeRawPtr<MouseEvent> create(const AtomicString& eventType, const MouseEventInit&);
static PassRefPtrWillBeRawPtr<MouseEvent> create(const AtomicString& eventType, PassRefPtrWillBeRawPtr<AbstractView>, PassRefPtrWillBeRawPtr<Event> underlyingEvent);
virtual ~MouseEvent();
void initMouseEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView>,
......@@ -89,7 +87,6 @@ public:
DataTransfer* dataTransfer() const { return isDragEvent() ? m_dataTransfer.get() : 0; }
bool fromTouch() const { return m_syntheticEventType == PlatformMouseEvent::FromTouch; }
bool hasPosition() const OVERRIDE { return m_syntheticEventType != PlatformMouseEvent::Positionless; }
virtual const AtomicString& interfaceName() const OVERRIDE;
......@@ -105,7 +102,7 @@ protected:
int movementX, int movementY,
bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short button,
PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, PassRefPtrWillBeRawPtr<DataTransfer>,
PlatformMouseEvent::SyntheticEventType);
bool isSimulated, PlatformMouseEvent::SyntheticEventType);
MouseEvent(const AtomicString& type, const MouseEventInit&);
......@@ -119,6 +116,17 @@ private:
PlatformMouseEvent::SyntheticEventType m_syntheticEventType;
};
class SimulatedMouseEvent FINAL : public MouseEvent {
public:
static PassRefPtrWillBeRawPtr<SimulatedMouseEvent> create(const AtomicString& eventType, PassRefPtrWillBeRawPtr<AbstractView>, PassRefPtrWillBeRawPtr<Event> underlyingEvent);
virtual ~SimulatedMouseEvent();
virtual void trace(Visitor*) OVERRIDE;
private:
SimulatedMouseEvent(const AtomicString& eventType, PassRefPtrWillBeRawPtr<AbstractView>, PassRefPtrWillBeRawPtr<Event> underlyingEvent);
};
class MouseEventDispatchMediator FINAL : public EventDispatchMediator {
public:
enum MouseEventType { SyntheticMouseEvent, NonSyntheticMouseEvent};
......
......@@ -33,7 +33,8 @@
namespace blink {
MouseRelatedEvent::MouseRelatedEvent()
: m_hasCachedRelativePosition(false)
: m_isSimulated(false)
, m_hasCachedRelativePosition(false)
{
}
......@@ -52,18 +53,19 @@ static LayoutSize contentsScrollOffset(AbstractView* abstractView)
}
MouseRelatedEvent::MouseRelatedEvent(const AtomicString& eventType, bool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView> abstractView,
int detail, const IntPoint& screenLocation, const IntPoint& windowLocation, const IntPoint& movementDelta,
bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool hasPosition)
int detail, const IntPoint& screenLocation, const IntPoint& windowLocation,
const IntPoint& movementDelta,
bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool isSimulated)
: UIEventWithKeyState(eventType, canBubble, cancelable, abstractView, detail, ctrlKey, altKey, shiftKey, metaKey)
, m_screenLocation(screenLocation)
, m_movementDelta(movementDelta)
, m_isSimulated(isSimulated)
{
LayoutPoint adjustedPageLocation;
LayoutPoint scrollPosition;
LocalFrame* frame = view() ? view()->frame() : 0;
if (frame && hasPosition) {
if (frame && !isSimulated) {
if (FrameView* frameView = frame->view()) {
scrollPosition = frameView->scrollPosition();
adjustedPageLocation = frameView->windowToContents(windowLocation);
......@@ -183,7 +185,7 @@ int MouseRelatedEvent::layerY()
int MouseRelatedEvent::offsetX()
{
if (!hasPosition())
if (isSimulated())
return 0;
if (!m_hasCachedRelativePosition)
computeRelativePosition();
......@@ -192,7 +194,7 @@ int MouseRelatedEvent::offsetX()
int MouseRelatedEvent::offsetY()
{
if (!hasPosition())
if (isSimulated())
return 0;
if (!m_hasCachedRelativePosition)
computeRelativePosition();
......
......@@ -46,7 +46,10 @@ namespace blink {
virtual int layerY() OVERRIDE FINAL;
int offsetX();
int offsetY();
virtual bool hasPosition() const = 0;
// FIXME: rename isSimulated to fromKeyboard() and replace m_isSimulated with a new value
// in PlatformMouseEvent::SyntheticEventType. isSimulated() is only true for synthetic
// mouse events that derive from keyboard input, which do not have a position.
bool isSimulated() const { return m_isSimulated; }
virtual int pageX() const OVERRIDE FINAL;
virtual int pageY() const OVERRIDE FINAL;
int x() const;
......@@ -64,7 +67,7 @@ namespace blink {
MouseRelatedEvent(const AtomicString& type, bool canBubble, bool cancelable,
PassRefPtrWillBeRawPtr<AbstractView>, int detail, const IntPoint& screenLocation,
const IntPoint& windowLocation, const IntPoint& movementDelta, bool ctrlKey, bool altKey,
bool shiftKey, bool metaKey, bool hasPosition);
bool shiftKey, bool metaKey, bool isSimulated = false);
void initCoordinates();
void initCoordinates(const LayoutPoint& clientLocation);
......@@ -83,6 +86,7 @@ namespace blink {
LayoutPoint m_layerLocation;
LayoutPoint m_offsetLocation;
LayoutPoint m_absoluteLocation;
bool m_isSimulated;
bool m_hasCachedRelativePosition;
};
......
......@@ -65,7 +65,7 @@ WheelEvent::WheelEvent(const FloatPoint& wheelTicks, const FloatPoint& rawDelta,
bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
: MouseEvent(EventTypeNames::wheel, true, true, view, 0, screenLocation.x(), screenLocation.y(),
pageLocation.x(), pageLocation.y(), 0, 0, ctrlKey, altKey, shiftKey, metaKey, 0, nullptr,
nullptr, PlatformMouseEvent::RealOrIndistinguishable)
nullptr, false, PlatformMouseEvent::RealOrIndistinguishable)
, m_wheelDelta(wheelTicks.x() * TickMultiplier, wheelTicks.y() * TickMultiplier)
, m_deltaX(-rawDelta.x())
, m_deltaY(-rawDelta.y())
......
......@@ -126,17 +126,18 @@ void HTMLLabelElement::defaultEventHandler(Event* evt)
static bool processingClick = false;
if (evt->type() == EventTypeNames::click && !processingClick) {
// If the click has a position and the text of label element is
// If the click is not simulated and the text of label element is
// selected, do not pass the event to control element.
// Note: check if it is a MouseEvent because a click event may
// not be an instance of a MouseEvent if created by document.createEvent().
if (evt->isMouseEvent() && toMouseEvent(evt)->hasPosition()) {
// Note: a click event may be not a mouse event if created by
// document.createEvent().
if (evt->isMouseEvent() && !toMouseEvent(evt)->isSimulated()) {
if (LocalFrame* frame = document().frame()) {
if (frame->selection().selection().isRange())
return;
}
}
RefPtrWillBeRawPtr<HTMLElement> element = control();
// If we can't find a control or if the control received the click
......
......@@ -100,7 +100,7 @@ static IntPoint extractClickLocation(Event* event)
if (!event->underlyingEvent() || !event->underlyingEvent()->isMouseEvent())
return IntPoint();
MouseEvent* mouseEvent = toMouseEvent(event->underlyingEvent());
if (!mouseEvent->hasPosition())
if (mouseEvent->isSimulated())
return IntPoint();
return IntPoint(mouseEvent->offsetX(), mouseEvent->offsetY());
}
......
......@@ -37,7 +37,7 @@ void CustomContextMenuProvider::populateContextMenu(ContextMenu* menu)
void CustomContextMenuProvider::contextMenuItemSelected(const ContextMenuItem* item)
{
if (HTMLElement* element = menuItemAt(item->action())) {
RefPtrWillBeRawPtr<MouseEvent> click = MouseEvent::create(EventTypeNames::click, m_menu->document().domWindow(), Event::create());
RefPtrWillBeRawPtr<SimulatedMouseEvent> click = SimulatedMouseEvent::create(EventTypeNames::click, m_menu->document().domWindow(), Event::create());
click->setRelatedTarget(m_subjectElement.get());
element->dispatchEvent(click.release());
}
......
......@@ -39,11 +39,8 @@ public:
enum SyntheticEventType {
// Real mouse input events or synthetic events that behave just like real events
RealOrIndistinguishable,
// Synthetic mouse events derived from touch input
// Mouse events derived from touch input
FromTouch,
// Synthetic mouse events generated without a position, for example those generated
// from keyboard input.
Positionless,
};
PlatformMouseEvent()
......
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