void InspectorFrontendHost::dispatchEventAsContextMenuEvent(Event* event) { #if USE(ACCESSIBILITY_CONTEXT_MENUS) if (!event || !event->isMouseEvent()) return; Frame* frame = event->target()->toNode()->document().frame(); MouseEvent* mouseEvent = toMouseEvent(event); IntPoint mousePoint = IntPoint(mouseEvent->clientX(), mouseEvent->clientY()); m_frontendPage->contextMenuController().showContextMenuAt(frame, mousePoint); #else UNUSED_PARAM(event); #endif }
MouseEvent* MouseEvent::create(const AtomicString& eventType, AbstractView* view, Event* underlyingEvent, SimulatedClickCreationScope creationScope) { PlatformEvent::Modifiers modifiers = PlatformEvent::NoModifiers; if (UIEventWithKeyState* keyStateEvent = findEventWithKeyState(underlyingEvent)) { modifiers = keyStateEvent->modifiers(); } PlatformMouseEvent::SyntheticEventType syntheticType = PlatformMouseEvent::Positionless; int screenX = 0; int screenY = 0; if (underlyingEvent && underlyingEvent->isMouseEvent()) { syntheticType = PlatformMouseEvent::RealOrIndistinguishable; MouseEvent* mouseEvent = toMouseEvent(underlyingEvent); screenX = mouseEvent->screenX(); screenY = mouseEvent->screenY(); } double timestamp = underlyingEvent ? underlyingEvent->platformTimeStamp() : monotonicallyIncreasingTime(); MouseEvent* createdEvent = MouseEvent::create( eventType, true, true, view, 0, screenX, screenY, 0, 0, 0, 0, modifiers, 0, 0, nullptr, timestamp, syntheticType, String(), nullptr); createdEvent->setTrusted(creationScope == SimulatedClickCreationScope::FromUserAgent); createdEvent->setUnderlyingEvent(underlyingEvent); if (syntheticType == PlatformMouseEvent::RealOrIndistinguishable) { MouseEvent* mouseEvent = toMouseEvent(createdEvent->underlyingEvent()); createdEvent->initCoordinates(mouseEvent->clientX(), mouseEvent->clientY()); } return createdEvent; }
JSValue* JSMouseEvent::getValueProperty(ExecState* exec, int token) const { switch (token) { case ScreenXAttrNum: { MouseEvent* imp = static_cast<MouseEvent*>(impl()); return jsNumber(imp->screenX()); } case ScreenYAttrNum: { MouseEvent* imp = static_cast<MouseEvent*>(impl()); return jsNumber(imp->screenY()); } case ClientXAttrNum: { MouseEvent* imp = static_cast<MouseEvent*>(impl()); return jsNumber(imp->clientX()); } case ClientYAttrNum: { MouseEvent* imp = static_cast<MouseEvent*>(impl()); return jsNumber(imp->clientY()); } case CtrlKeyAttrNum: { MouseEvent* imp = static_cast<MouseEvent*>(impl()); return jsBoolean(imp->ctrlKey()); } case ShiftKeyAttrNum: { MouseEvent* imp = static_cast<MouseEvent*>(impl()); return jsBoolean(imp->shiftKey()); } case AltKeyAttrNum: { MouseEvent* imp = static_cast<MouseEvent*>(impl()); return jsBoolean(imp->altKey()); } case MetaKeyAttrNum: { MouseEvent* imp = static_cast<MouseEvent*>(impl()); return jsBoolean(imp->metaKey()); } case ButtonAttrNum: { MouseEvent* imp = static_cast<MouseEvent*>(impl()); return jsNumber(imp->button()); } case RelatedTargetAttrNum: { MouseEvent* imp = static_cast<MouseEvent*>(impl()); return toJS(exec, WTF::getPtr(imp->relatedTarget())); } case OffsetXAttrNum: { MouseEvent* imp = static_cast<MouseEvent*>(impl()); return jsNumber(imp->offsetX()); } case OffsetYAttrNum: { MouseEvent* imp = static_cast<MouseEvent*>(impl()); return jsNumber(imp->offsetY()); } case XAttrNum: { MouseEvent* imp = static_cast<MouseEvent*>(impl()); return jsNumber(imp->x()); } case YAttrNum: { MouseEvent* imp = static_cast<MouseEvent*>(impl()); return jsNumber(imp->y()); } case FromElementAttrNum: { MouseEvent* imp = static_cast<MouseEvent*>(impl()); return toJS(exec, WTF::getPtr(imp->fromElement())); } case ToElementAttrNum: { MouseEvent* imp = static_cast<MouseEvent*>(impl()); return toJS(exec, WTF::getPtr(imp->toElement())); } case DataTransferAttrNum: { MouseEvent* imp = static_cast<MouseEvent*>(impl()); return toJS(exec, WTF::getPtr(imp->dataTransfer())); } } return 0; }
static v8::Handle<v8::Value> clientYAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { INC_STATS("DOM.MouseEvent.clientY._get"); MouseEvent* imp = V8MouseEvent::toNative(info.Holder()); return v8::Integer::New(imp->clientY()); }