summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/html
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/html')
-rw-r--r--Source/WebCore/html/HTMLInputElement.cpp8
-rw-r--r--Source/WebCore/html/HTMLMediaElement.cpp2
-rw-r--r--Source/WebCore/html/InputType.cpp6
-rw-r--r--Source/WebCore/html/InputType.h4
-rw-r--r--Source/WebCore/html/RangeInputType.cpp16
-rw-r--r--Source/WebCore/html/RangeInputType.h4
-rw-r--r--Source/WebCore/html/shadow/SliderThumbElement.cpp110
-rw-r--r--Source/WebCore/html/shadow/SliderThumbElement.h7
8 files changed, 95 insertions, 62 deletions
diff --git a/Source/WebCore/html/HTMLInputElement.cpp b/Source/WebCore/html/HTMLInputElement.cpp
index 51b87cb..36cdf51 100644
--- a/Source/WebCore/html/HTMLInputElement.cpp
+++ b/Source/WebCore/html/HTMLInputElement.cpp
@@ -1102,6 +1102,14 @@ void HTMLInputElement::defaultEventHandler(Event* evt)
return;
}
+#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
+ if (evt->isTouchEvent() && evt->type() == eventNames().touchstartEvent) {
+ m_inputType->handleTouchStartEvent(static_cast<TouchEvent*>(evt));
+ if (evt->defaultHandled())
+ return;
+ }
+#endif
+
m_inputType->forwardEvent(evt);
if (!callBaseClassEarly && !evt->defaultHandled())
diff --git a/Source/WebCore/html/HTMLMediaElement.cpp b/Source/WebCore/html/HTMLMediaElement.cpp
index 46e8a12..328b6db 100644
--- a/Source/WebCore/html/HTMLMediaElement.cpp
+++ b/Source/WebCore/html/HTMLMediaElement.cpp
@@ -186,8 +186,6 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document* docum
document->registerForMediaVolumeCallbacks(this);
document->registerForPrivateBrowsingStateChangedCallbacks(this);
#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
- // Enable the Media Element to listen to all the touch events
- document->addListenerTypeIfNeeded(eventNames().touchstartEvent);
m_restrictions |= RequireUserGestureForRateChangeRestriction;
#endif
}
diff --git a/Source/WebCore/html/InputType.cpp b/Source/WebCore/html/InputType.cpp
index ba27408..9756313 100644
--- a/Source/WebCore/html/InputType.cpp
+++ b/Source/WebCore/html/InputType.cpp
@@ -310,6 +310,12 @@ void InputType::handleMouseDownEvent(MouseEvent*)
{
}
+#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
+void InputType::handleTouchStartEvent(TouchEvent*)
+{
+}
+#endif
+
void InputType::handleDOMActivateEvent(Event*)
{
}
diff --git a/Source/WebCore/html/InputType.h b/Source/WebCore/html/InputType.h
index ed69883..1b34717 100644
--- a/Source/WebCore/html/InputType.h
+++ b/Source/WebCore/html/InputType.h
@@ -173,6 +173,10 @@ public:
virtual void handleWheelEvent(WheelEvent*);
virtual void forwardEvent(Event*);
+#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
+ virtual void handleTouchStartEvent(TouchEvent*);
+#endif
+
// Helpers for event handlers.
virtual bool shouldSubmitImplicitly(Event*);
virtual PassRefPtr<HTMLFormElement> formForSubmission() const;
diff --git a/Source/WebCore/html/RangeInputType.cpp b/Source/WebCore/html/RangeInputType.cpp
index 88563c7..783eabc 100644
--- a/Source/WebCore/html/RangeInputType.cpp
+++ b/Source/WebCore/html/RangeInputType.cpp
@@ -199,6 +199,22 @@ void RangeInputType::handleKeydownEvent(KeyboardEvent* event)
event->setDefaultHandled();
}
+#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
+void RangeInputType::handleTouchStartEvent(TouchEvent* touchEvent)
+{
+ if (SliderThumbElement* thumb = shadowSliderThumb()) {
+ if (touchEvent->touches() && touchEvent->touches()->item(0)) {
+ IntPoint curPoint;
+ curPoint.setX(touchEvent->touches()->item(0)->pageX());
+ curPoint.setY(touchEvent->touches()->item(0)->pageY());
+ thumb->dragFrom(curPoint);
+ touchEvent->setDefaultHandled();
+ touchEvent->setDefaultPrevented(true);
+ }
+ }
+}
+#endif
+
void RangeInputType::createShadowSubtree()
{
ExceptionCode ec = 0;
diff --git a/Source/WebCore/html/RangeInputType.h b/Source/WebCore/html/RangeInputType.h
index 75e7a17..358a638 100644
--- a/Source/WebCore/html/RangeInputType.h
+++ b/Source/WebCore/html/RangeInputType.h
@@ -71,6 +71,10 @@ private:
virtual bool shouldRespectListAttribute();
SliderThumbElement* shadowSliderThumb() const;
+
+#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
+ virtual void handleTouchStartEvent(TouchEvent*);
+#endif
};
} // namespace WebCore
diff --git a/Source/WebCore/html/shadow/SliderThumbElement.cpp b/Source/WebCore/html/shadow/SliderThumbElement.cpp
index 6f4fedb..210fb7b 100644
--- a/Source/WebCore/html/shadow/SliderThumbElement.cpp
+++ b/Source/WebCore/html/shadow/SliderThumbElement.cpp
@@ -87,39 +87,6 @@ void RenderSliderThumb::layout()
RenderBlock::layout();
}
-#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
-class SliderTouchEventListener : public EventListener {
-public:
- static PassRefPtr<SliderTouchEventListener> create(SliderThumbElement* slider)
- {
- return adoptRef(new SliderTouchEventListener(slider));
- }
- virtual bool operator==(const EventListener& other) {
- return this == &other;
- }
- virtual void handleEvent(ScriptExecutionContext*, Event* event)
- {
- if (!event || !event->isTouchEvent())
- return;
- 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());
- m_slider->setPositionFromPoint(curPoint);
- touchEvent->setDefaultHandled();
- touchEvent->setDefaultPrevented(true);
- }
- }
-private:
- SliderTouchEventListener(SliderThumbElement* slider)
- : EventListener(NativeEventListenerType)
- , m_slider(slider)
- {}
- SliderThumbElement* m_slider;
-};
-#endif
-
void SliderThumbElement::setPositionFromValue()
{
// Since today the code to calculate position is in the RenderSlider layout
@@ -203,6 +170,10 @@ void SliderThumbElement::stopDragging()
if (Frame* frame = document()->frame())
frame->eventHandler()->setCapturingMouseEventsNode(0);
+#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
+ if (Frame* frame = document()->frame())
+ frame->page()->mainFrame()->eventHandler()->setCapturingTouchEventsNode(0);
+#endif
m_inDragMode = false;
if (renderer())
renderer()->setNeedsLayout(true);
@@ -210,23 +181,70 @@ void SliderThumbElement::stopDragging()
void SliderThumbElement::defaultEventHandler(Event* event)
{
- if (!event->isMouseEvent()) {
+ 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 (eventType == eventNames().mousedownEvent && isLeftButton
+#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
+ || eventType == eventNames().touchstartEvent
+#endif
+ ) {
startDragging();
return;
- } else if (eventType == eventNames().mouseupEvent && isLeftButton) {
+ } 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) {
+ } 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;
}
@@ -237,13 +255,7 @@ void SliderThumbElement::defaultEventHandler(Event* event)
void SliderThumbElement::attach()
{
HTMLDivElement::attach();
- // Add a touch event handler to ensure we get touch events.
- if (!m_touchListener)
- m_touchListener = SliderTouchEventListener::create(this);
- addEventListener(eventNames().touchstartEvent,
- m_touchListener, false);
- addEventListener(eventNames().touchmoveEvent,
- m_touchListener, false);
+ document()->addListenerTypeIfNeeded(eventNames().touchstartEvent);
}
#endif
@@ -251,16 +263,8 @@ void SliderThumbElement::detach()
{
if (m_inDragMode) {
if (Frame* frame = document()->frame())
- frame->eventHandler()->setCapturingMouseEventsNode(0);
- }
-#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
- if (m_touchListener) {
- removeEventListener(eventNames().touchstartEvent,
- m_touchListener.get(), false);
- removeEventListener(eventNames().touchmoveEvent,
- m_touchListener.get(), false);
+ frame->eventHandler()->setCapturingMouseEventsNode(0);
}
-#endif
HTMLDivElement::detach();
}
diff --git a/Source/WebCore/html/shadow/SliderThumbElement.h b/Source/WebCore/html/shadow/SliderThumbElement.h
index 47e12f1..cdeb471 100644
--- a/Source/WebCore/html/shadow/SliderThumbElement.h
+++ b/Source/WebCore/html/shadow/SliderThumbElement.h
@@ -44,9 +44,6 @@ class HTMLElement;
class HTMLInputElement;
class Event;
class FloatPoint;
-#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
-class SliderTouchEventListener;
-#endif
class SliderThumbElement : public HTMLDivElement {
public:
@@ -73,10 +70,6 @@ private:
FloatPoint m_offsetToThumb;
bool m_inDragMode;
-#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
- RefPtr<EventListener> m_touchListener;
- friend class SliderTouchEventListener;
-#endif
};
inline SliderThumbElement::SliderThumbElement(Document* document)