void SliderThumbElement::defaultEventHandler(Event* event) { if (!event->isMouseEvent() #if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS) && !event->isTouchEvent() #endif ) { HTMLDivElement::defaultEventHandler(event); return; } #if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS) bool isLeftButton = false; if (event->isMouseEvent()) { MouseEvent* mouseEvent = static_cast<MouseEvent*>(event); isLeftButton = mouseEvent->button() == LeftButton; } #else MouseEvent* mouseEvent = static_cast<MouseEvent*>(event); bool isLeftButton = mouseEvent->button() == LeftButton; #endif const AtomicString& eventType = event->type(); if (eventType == eventNames().mousedownEvent && isLeftButton #if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS) || eventType == eventNames().touchstartEvent #endif ) { startDragging(); return; } else if (eventType == eventNames().mouseupEvent && isLeftButton #if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS) || eventType == eventNames().touchendEvent || eventType == eventNames().touchcancelEvent #endif ) { stopDragging(); return; } else if (eventType == eventNames().mousemoveEvent #if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS) || eventType == eventNames().touchmoveEvent #endif ) { if (m_inDragMode) #if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS) { if (event->isMouseEvent()) { MouseEvent* mouseEvent = static_cast<MouseEvent*>(event); #endif setPositionFromPoint(mouseEvent->absoluteLocation()); #if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS) } else if (event->isTouchEvent()) { TouchEvent* touchEvent = static_cast<TouchEvent*>(event); if (touchEvent->touches() && touchEvent->touches()->item(0)) { IntPoint curPoint; curPoint.setX(touchEvent->touches()->item(0)->pageX()); curPoint.setY(touchEvent->touches()->item(0)->pageY()); setPositionFromPoint(curPoint); // Tell the webview that webkit will handle the following move events event->setDefaultPrevented(true); } } } #endif return; } HTMLDivElement::defaultEventHandler(event); }
void Backtrace::touchesBegan( TouchEvent event ) { for( vector<TouchEvent::Touch>::const_iterator touchIt = event.getTouches().begin(); touchIt != event.getTouches().end(); ++touchIt ) { mPoints.push_back( touchIt->getPos() ); } }
WebTouchEventBuilder::WebTouchEventBuilder(const LayoutObject* layoutObject, const TouchEvent& event) { if (event.type() == EventTypeNames::touchstart) type = TouchStart; else if (event.type() == EventTypeNames::touchmove) type = TouchMove; else if (event.type() == EventTypeNames::touchend) type = TouchEnd; else if (event.type() == EventTypeNames::touchcancel) type = TouchCancel; else { ASSERT_NOT_REACHED(); type = Undefined; return; } timeStampSeconds = event.platformTimeStamp(); modifiers = event.modifiers(); cancelable = event.cancelable(); causesScrollingIfUncanceled = event.causesScrollingIfUncanceled(); // Currently touches[] is empty, add stationary points as-is. for (unsigned i = 0; i < event.touches()->length() && i < static_cast<unsigned>(WebTouchEvent::touchesLengthCap); ++i) { touches[i] = toWebTouchPoint(event.touches()->item(i), layoutObject, WebTouchPoint::StateStationary); ++touchesLength; } // If any existing points are also in the change list, we should update // their state, otherwise just add the new points. addTouchPointsUpdateStateIfNecessary(toWebTouchPointState(event.type()), event.changedTouches(), touches, &touchesLength, layoutObject); }
void SlidingActor::_newEvent(Event* event) { if (!_content) return; TouchEvent* te = safeCast<TouchEvent*>(event); //if (te->) timeMS tm = getTimeMS(); switch (te->type) { case TouchEvent::TOUCH_DOWN: { _finger = te->index; _current = 0; _lastIterTime = tm; _prev[0].pos = _content->getPosition(); _prev[0].tm = tm; for (int i = 1; i < NUM; ++i) _prev[i].tm = 0; _holded = event->target; _downPos = te->localPosition; _downTime = tm; } break; case TouchEvent::TOUCH_UP: { if (_ignoreTouchUp) { te->stopImmediatePropagation(); } if (_drag.getDragEnabled() && te->index == _finger && _ignoreTouchUp == false) { _finger = 0; _downTime = 0; Vector2 pos = _content->getPosition(); _holded = 0; const iter* old = 0; const iter* mid = 0; const iter* last = _prev + _current; for (int i = 1; i < NUM; ++i) { int n = (_current + NUM - i) % NUM; if (_prev[n].tm) last = _prev + n; else break; if (!mid && (last->tm + 50 <= tm)) mid = last; if (last->tm + 150 <= tm) { old = last; break; } } if (!old) old = last; if (!mid) mid = last; Vector2 midpos = mid->pos; Vector2 dir = pos - midpos; if (dir.sqlength() < 10 * 10) _speed = Vector2(0, 0); else { timeMS v = tm - old->tm; if (!v) return; Vector2 dr = pos - old->pos; Vector2 ns = (dr * 1000.0f) / v; if (_speed.dot(ns) < 0) _speed = ns; else _speed += ns; } if (!_sliding) { _sliding = true; } SlidingEvent sd(SlidingEvent::BEGIN); sd.speed = _speed; dispatchEvent(&sd); _speed = sd.speed; _lastIterTime = tm; } } break; case TouchEvent::MOVE: { if (te->index == _finger) { Vector2 offset = _downPos - te->localPosition; float d = offset.dot(offset); if (_holded && (d >= _rad * _rad)) { spActor act = safeSpCast<Actor>(_holded); while (act && act.get() != _content.get()) { for (int i = 0; i < MouseButton_Num; ++i) { act->setNotPressed((MouseButton)i); TouchEvent ev(TouchEvent::TOUCH_UP, true, Vector2(-100000, -100000)); ev.mouseButton = (MouseButton)i; ev.index = te->index; ev.bubbles = false; act->dispatchEvent(&ev); } act = act->getParent(); } _holded = 0; } } } break; } }
void Flow::blockedTouch(Event* ev) { TouchEvent* event = safeCast<TouchEvent*>(ev); _blockedTouchPosition = event->getPointer()->getPosition(); _wasTouchBlocked = true; }
// Generate a synthetic WebMouseEvent given a TouchEvent (eg. for emulating a mouse // with touch input for plugins that don't support touch input). WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const LayoutObject* layoutObject, const TouchEvent& event) { if (!event.touches()) return; if (event.touches()->length() != 1) { if (event.touches()->length() || event.type() != EventTypeNames::touchend || !event.changedTouches() || event.changedTouches()->length() != 1) return; } const Touch* touch = event.touches()->length() == 1 ? event.touches()->item(0) : event.changedTouches()->item(0); if (touch->identifier()) return; if (event.type() == EventTypeNames::touchstart) type = MouseDown; else if (event.type() == EventTypeNames::touchmove) type = MouseMove; else if (event.type() == EventTypeNames::touchend) type = MouseUp; else return; timeStampSeconds = event.platformTimeStamp(); modifiers = event.modifiers(); // The mouse event co-ordinates should be generated from the co-ordinates of the touch point. FrameView* view = toFrameView(widget->parent()); // FIXME: if view == nullptr, pointInRootFrame will really be pointInRootContent. IntPoint pointInRootFrame = roundedIntPoint(touch->absoluteLocation()); if (view) pointInRootFrame = view->contentsToRootFrame(pointInRootFrame); IntPoint screenPoint = roundedIntPoint(touch->screenLocation()); globalX = screenPoint.x(); globalY = screenPoint.y(); windowX = pointInRootFrame.x(); windowY = pointInRootFrame.y(); button = WebMouseEvent::ButtonLeft; modifiers |= WebInputEvent::LeftButtonDown; clickCount = (type == MouseDown || type == MouseUp); IntPoint localPoint = convertAbsoluteLocationForLayoutObject(touch->absoluteLocation(), *layoutObject); x = localPoint.x(); y = localPoint.y(); }
static v8::Handle<v8::Value> changedTouchesAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { INC_STATS("DOM.TouchEvent.changedTouches._get"); TouchEvent* imp = V8TouchEvent::toNative(info.Holder()); return toV8(imp->changedTouches()); }
static v8::Handle<v8::Value> metaKeyAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { INC_STATS("DOM.TouchEvent.metaKey._get"); TouchEvent* imp = V8TouchEvent::toNative(info.Holder()); return v8Boolean(imp->metaKey()); }
static v8::Handle<v8::Value> altKeyAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { TouchEvent* imp = V8TouchEvent::toNative(info.Holder()); return v8Boolean(imp->altKey(), info.GetIsolate()); }
void MultiTouchApp::touchesMoved( TouchEvent event ) { console() << "Moved: " << event << std::endl; for( vector<TouchEvent::Touch>::const_iterator touchIt = event.getTouches().begin(); touchIt != event.getTouches().end(); ++touchIt ) mActivePoints[touchIt->getId()].addPoint( touchIt->getPos() ); }
void iosAppTestApp::touchesMoved( TouchEvent event ) { for( vector<TouchEvent::Touch>::const_iterator touchIt = event.getTouches().begin(); touchIt != event.getTouches().end(); ++touchIt ) mActivePoints[touchIt->getId()].addPoint( touchIt->getPos() ); }
WebTouchEventBuilder::WebTouchEventBuilder(const Widget* widget, const WebCore::RenderObject* renderObject, const TouchEvent& event) { if (event.type() == EventTypeNames::touchstart) type = TouchStart; else if (event.type() == EventTypeNames::touchmove) type = TouchMove; else if (event.type() == EventTypeNames::touchend) type = TouchEnd; else if (event.type() == EventTypeNames::touchcancel) type = TouchCancel; else { ASSERT_NOT_REACHED(); type = Undefined; return; } modifiers = getWebInputModifiers(event); timeStampSeconds = event.timeStamp() / millisPerSecond; cancelable = event.cancelable(); addTouchPoints(widget, event.type(), event.touches(), touches, &touchesLength, renderObject); addTouchPoints(widget, event.type(), event.changedTouches(), changedTouches, &changedTouchesLength, renderObject); addTouchPoints(widget, event.type(), event.targetTouches(), targetTouches, &targetTouchesLength, renderObject); }
void WidgetManager::onTouch(TouchEvent& event) { for (auto widget : _widgets) { if (event.isAccepted()) break; widget->onTouch(event); } }