summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/html
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/html')
-rw-r--r--Source/WebCore/html/HTMLInputElement.cpp12
-rw-r--r--Source/WebCore/html/InputType.cpp6
-rw-r--r--Source/WebCore/html/InputType.h9
-rw-r--r--Source/WebCore/html/RangeInputType.cpp29
-rw-r--r--Source/WebCore/html/RangeInputType.h3
-rw-r--r--Source/WebCore/html/shadow/SliderThumbElement.cpp118
6 files changed, 99 insertions, 78 deletions
diff --git a/Source/WebCore/html/HTMLInputElement.cpp b/Source/WebCore/html/HTMLInputElement.cpp
index 637e831..0d20389 100644
--- a/Source/WebCore/html/HTMLInputElement.cpp
+++ b/Source/WebCore/html/HTMLInputElement.cpp
@@ -57,6 +57,10 @@
#include "PlatformBridge.h"
#endif
+#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
+#include "TouchEvent.h"
+#endif
+
using namespace std;
namespace WebCore {
@@ -1054,6 +1058,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/InputType.cpp b/Source/WebCore/html/InputType.cpp
index 2f8d414..8e3a9e3 100644
--- a/Source/WebCore/html/InputType.cpp
+++ b/Source/WebCore/html/InputType.cpp
@@ -309,6 +309,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 e6ceb96..40606d1 100644
--- a/Source/WebCore/html/InputType.h
+++ b/Source/WebCore/html/InputType.h
@@ -54,6 +54,10 @@ class RenderObject;
class RenderStyle;
class WheelEvent;
+#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
+class TouchEvent;
+#endif
+
typedef int ExceptionCode;
struct ClickHandlingState {
@@ -165,6 +169,11 @@ public:
virtual void handleBeforeTextInsertedEvent(BeforeTextInsertedEvent*);
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 e9ac295..7c74206 100644
--- a/Source/WebCore/html/RangeInputType.cpp
+++ b/Source/WebCore/html/RangeInputType.cpp
@@ -45,6 +45,10 @@
#include <wtf/MathExtras.h>
#include <wtf/PassOwnPtr.h>
+#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
+#include "TouchEvent.h"
+#endif
+
namespace WebCore {
using namespace HTMLNames;
@@ -192,21 +196,22 @@ void RangeInputType::handleKeydownEvent(KeyboardEvent* event)
event->setDefaultHandled();
}
-<<<<<<< HEAD
-void RangeInputType::forwardEvent(Event* event)
-{
- if (element()->renderer()
- && (event->isMouseEvent()
#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
- || event->isTouchEvent()
-#endif
- || event->isDragEvent()
- || event->isWheelEvent()))
- toRenderSlider(element()->renderer())->forwardEvent(event);
+void RangeInputType::handleTouchStartEvent(TouchEvent* touchEvent)
+{
+ if (SliderThumbElement* thumb = toSliderThumbElement(element()->shadowRoot())) {
+ 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
-=======
->>>>>>> WebKit.org at r76408
void RangeInputType::createShadowSubtree()
{
element()->setShadowRoot(SliderThumbElement::create(element()->document()));
diff --git a/Source/WebCore/html/RangeInputType.h b/Source/WebCore/html/RangeInputType.h
index 15d224d..1447018 100644
--- a/Source/WebCore/html/RangeInputType.h
+++ b/Source/WebCore/html/RangeInputType.h
@@ -66,6 +66,9 @@ private:
virtual String fallbackValue();
virtual String sanitizeValue(const String& proposedValue);
virtual bool shouldRespectListAttribute();
+#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 ad93261..758d3c7 100644
--- a/Source/WebCore/html/shadow/SliderThumbElement.cpp
+++ b/Source/WebCore/html/shadow/SliderThumbElement.cpp
@@ -43,12 +43,13 @@
#include "StepRange.h"
#include <wtf/MathExtras.h>
-using namespace std;
-
#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
+#include "Page.h"
#include "TouchEvent.h"
#endif
+using namespace std;
+
namespace WebCore {
// FIXME: Find a way to cascade appearance (see the layout method) and get rid of this class.
@@ -139,6 +140,12 @@ void SliderThumbElement::startDragging()
{
if (Frame* frame = document()->frame()) {
frame->eventHandler()->setCapturingMouseEventsNode(this);
+#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
+ // Touch events come from Java to the main frame event handler, so we need
+ // to flag we are capturing those events also on the main frame event
+ // handler.
+ frame->page()->mainFrame()->eventHandler()->setCapturingTouchEventsNode(this);
+#endif
m_inDragMode = true;
}
}
@@ -150,6 +157,11 @@ 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;
}
@@ -164,88 +176,62 @@ void SliderThumbElement::defaultEventHandler(Event* 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();
-<<<<<<< HEAD
if (eventType == eventNames().mousedownEvent && isLeftButton
#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
- || eventType == eventNames().touchstartEvent
+ || eventType == eventNames().touchstartEvent
#endif
- ) {
- if (document()->frame() && renderer()) {
- RenderSlider* slider = toRenderSlider(renderer()->parent());
- if (slider) {
- if (slider->mouseEventIsInThumb(mouseEvent)) {
- // We selected the thumb, we want the cursor to always stay at
- // the same position relative to the thumb.
- m_offsetToThumb = slider->mouseEventOffsetToThumb(mouseEvent);
- } else {
- // We are outside the thumb, move the thumb to the point were
- // we clicked. We'll be exactly at the center of the thumb.
- m_offsetToThumb.setX(0);
- m_offsetToThumb.setY(0);
- }
-
- m_inDragMode = true;
- document()->frame()->eventHandler()->setCapturingMouseEventsNode(shadowHost());
- event->setDefaultHandled();
- return;
- }
- }
+ ) {
+ startDragging();
+ return;
} else if (eventType == eventNames().mouseupEvent && isLeftButton
#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
- || eventType == eventNames().touchendEvent
+ || eventType == eventNames().touchendEvent
+ || eventType == eventNames().touchcancelEvent
#endif
- ) {
- if (m_inDragMode) {
- if (Frame* frame = document()->frame())
- frame->eventHandler()->setCapturingMouseEventsNode(0);
- m_inDragMode = false;
- event->setDefaultHandled();
- return;
- }
+ ) {
+ stopDragging();
+ return;
} else if (eventType == eventNames().mousemoveEvent
#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
- || eventType == eventNames().touchmoveEvent
+ || eventType == eventNames().touchmoveEvent
#endif
- ) {
- if (m_inDragMode && renderer() && renderer()->parent()) {
- RenderSlider* slider = toRenderSlider(renderer()->parent());
- if (slider) {
- FloatPoint curPoint = slider->absoluteToLocal(mouseEvent->absoluteLocation(), false, true);
+ ) {
+ if (m_inDragMode)
#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
- // Update the position when it is a touch event
- if (event->isTouchEvent()) {
- TouchEvent* touchEvent = static_cast<TouchEvent*>(event);
- if (touchEvent && touchEvent->touches() && touchEvent->touches()->item(0)) {
- curPoint.setX(touchEvent->touches()->item(0)->pageX());
- curPoint.setY(touchEvent->touches()->item(0)->pageY());
- curPoint = slider->absoluteToLocal(curPoint, false, true);
- }
- }
- // Tell the webview that webkit will handle the following move events
- event->setDefaultPrevented(true);
+ {
+ if (event->isMouseEvent()) {
+ MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
#endif
- IntPoint eventOffset(curPoint.x() + m_offsetToThumb.x(), curPoint.y() + m_offsetToThumb.y());
- slider->setValueForPosition(slider->positionForOffset(eventOffset));
- event->setDefaultHandled();
- return;
+ setPosition(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());
+ setPosition(curPoint);
+ // Tell the webview that webkit will handle the following move events
+ event->setDefaultPrevented(true);
+ }
}
+
}
-=======
- if (eventType == eventNames().mousedownEvent && isLeftButton) {
- startDragging();
- return;
- } else if (eventType == eventNames().mouseupEvent && isLeftButton) {
- stopDragging();
- return;
- } else if (eventType == eventNames().mousemoveEvent) {
- if (m_inDragMode)
- setPosition(mouseEvent->absoluteLocation());
+#endif
return;
->>>>>>> WebKit.org at r76408
}
HTMLDivElement::defaultEventHandler(event);