Commit a9ce63e5 authored by commit-queue@webkit.org's avatar commit-queue@webkit.org
Browse files

[chromium] Make sure the touch-points in the touch-events have the correct state.

https://bugs.webkit.org/show_bug.cgi?id=98110

Patch by Sadrul Habib Chowdhury <sadrul@chromium.org> on 2012-10-02
Reviewed by Adam Barth.

Source/WebKit/chromium:

It is necessary for the WebTouchPoints in the reconstructed WebTouchEvent
to have the correct state. Without this change, the states were always
unknown.

* src/WebInputEventConversion.cpp:
(WebKit::toWebTouchPointState):
(WebKit):
(WebKit::addTouchPoints):
(WebKit::WebTouchEventBuilder::WebTouchEventBuilder):

Tools:

TestWebPlugin can now be configured to print out some details about
events. For now, details for only touch events are printed. This is
used to verify that touch-points in the touch-events are properly
set.

* DumpRenderTree/chromium/TestWebPlugin.cpp:
(pointState):
(printTouchList):
(printEventDetails):
(TestWebPlugin::TestWebPlugin):
(TestWebPlugin::handleInputEvent):
* DumpRenderTree/chromium/TestWebPlugin.h:
(TestWebPlugin):

LayoutTests:

* platform/chromium/plugins/touch-events-details-expected.txt: Added.
* platform/chromium/plugins/touch-events-details.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130197 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 5e1fdeec
2012-10-02 Sadrul Habib Chowdhury <sadrul@chromium.org>
[chromium] Make sure the touch-points in the touch-events have the correct state.
https://bugs.webkit.org/show_bug.cgi?id=98110
Reviewed by Adam Barth.
* platform/chromium/plugins/touch-events-details-expected.txt: Added.
* platform/chromium/plugins/touch-events-details.html: Added.
2012-10-02 Roger Fong <roger_fong@apple.com>
 
Unreviewed. Adding Windows specific test results. Accelerated 2D canvas not enabled on Windows.
Plugin received event: TouchStart
* 10, 10: Pressed
* 10, 10: Pressed
* 10, 10: Pressed
Plugin received event: TouchMove
* 20, 15: Moved
* 20, 15: Moved
* 20, 15: Moved
Plugin received event: TouchEnd
* 20, 15: Released
<html>
<head>
<style>
#plugin {
width: 150px;
height: 150px;
}
</style>
</head>
<body>
<embed id="plugin" type="application/x-webkit-test-webplugin" accepts-touch="true" print-event-details="true"></embed>
<script>
if (!window.testRunner || !window.eventSender) {
document.write("This test does not work in manual mode.");
} else {
testRunner.dumpAsText();
var positionX = plugin.offsetLeft + 10;
var positionY = plugin.offsetTop + 10;
eventSender.addTouchPoint(positionX, positionY);
eventSender.touchStart();
eventSender.updateTouchPoint(0, positionX + 10, positionY + 5);
eventSender.touchMove();
eventSender.releaseTouchPoint(0);
eventSender.touchEnd();
}
</script>
</body>
</html>
2012-10-02 Sadrul Habib Chowdhury <sadrul@chromium.org>
[chromium] Make sure the touch-points in the touch-events have the correct state.
https://bugs.webkit.org/show_bug.cgi?id=98110
Reviewed by Adam Barth.
It is necessary for the WebTouchPoints in the reconstructed WebTouchEvent
to have the correct state. Without this change, the states were always
unknown.
* src/WebInputEventConversion.cpp:
(WebKit::toWebTouchPointState):
(WebKit):
(WebKit::addTouchPoints):
(WebKit::WebTouchEventBuilder::WebTouchEventBuilder):
2012-10-02 Brian White <bcwhite@chromium.org>
 
WebDocument doesn't export document language to outside users.
......
......@@ -207,7 +207,7 @@ PlatformGestureEventBuilder::PlatformGestureEventBuilder(Widget* widget, const W
// MakePlatformKeyboardEvent --------------------------------------------------
static inline PlatformEvent::Type toPlatformKeyboardEventType(WebInputEvent::Type type)
inline PlatformEvent::Type toPlatformKeyboardEventType(WebInputEvent::Type type)
{
switch (type) {
case WebInputEvent::KeyUp:
......@@ -300,7 +300,7 @@ bool PlatformKeyboardEventBuilder::isCharacterKey() const
}
#if ENABLE(TOUCH_EVENTS)
static inline PlatformEvent::Type toPlatformTouchEventType(const WebInputEvent::Type type)
inline PlatformEvent::Type toPlatformTouchEventType(const WebInputEvent::Type type)
{
switch (type) {
case WebInputEvent::TouchStart:
......@@ -317,7 +317,7 @@ static inline PlatformEvent::Type toPlatformTouchEventType(const WebInputEvent::
return PlatformEvent::TouchStart;
}
static inline PlatformTouchPoint::State toPlatformTouchPointState(const WebTouchPoint::State state)
inline PlatformTouchPoint::State toPlatformTouchPointState(const WebTouchPoint::State state)
{
switch (state) {
case WebTouchPoint::StateReleased:
......@@ -336,6 +336,19 @@ static inline PlatformTouchPoint::State toPlatformTouchPointState(const WebTouch
return PlatformTouchPoint::TouchReleased;
}
inline WebTouchPoint::State toWebTouchPointState(const AtomicString& type)
{
if (type == eventNames().touchendEvent)
return WebTouchPoint::StateReleased;
if (type == eventNames().touchcancelEvent)
return WebTouchPoint::StateCancelled;
if (type == eventNames().touchstartEvent)
return WebTouchPoint::StatePressed;
if (type == eventNames().touchmoveEvent)
return WebTouchPoint::StateMoved;
return WebTouchPoint::StateUndefined;
}
PlatformTouchPointBuilder::PlatformTouchPointBuilder(Widget* widget, const WebTouchPoint& point)
{
m_id = point.id;
......@@ -502,7 +515,7 @@ WebKeyboardEventBuilder::WebKeyboardEventBuilder(const KeyboardEvent& event)
#if ENABLE(TOUCH_EVENTS)
static void addTouchPoints(TouchList* touches, const IntPoint& offset, WebTouchPoint* touchPoints, unsigned* touchPointsLength)
static void addTouchPoints(const AtomicString& touchType, TouchList* touches, const IntPoint& offset, WebTouchPoint* touchPoints, unsigned* touchPointsLength)
{
unsigned numberOfTouches = std::min(touches->length(), static_cast<unsigned>(WebTouchEvent::touchesLengthCap));
for (unsigned i = 0; i < numberOfTouches; ++i) {
......@@ -516,6 +529,7 @@ static void addTouchPoints(TouchList* touches, const IntPoint& offset, WebTouchP
point.radiusY = touch->webkitRadiusY();
point.rotationAngle = touch->webkitRotationAngle();
point.force = touch->webkitForce();
point.state = toWebTouchPointState(touchType);
touchPoints[i] = point;
}
......@@ -541,9 +555,9 @@ WebTouchEventBuilder::WebTouchEventBuilder(const Widget* widget, const TouchEven
modifiers = getWebInputModifiers(event);
timeStampSeconds = event.timeStamp() / millisPerSecond;
addTouchPoints(event.touches(), widget->location(), touches, &touchesLength);
addTouchPoints(event.changedTouches(), widget->location(), changedTouches, &changedTouchesLength);
addTouchPoints(event.targetTouches(), widget->location(), targetTouches, &targetTouchesLength);
addTouchPoints(event.type(), event.touches(), widget->location(), touches, &touchesLength);
addTouchPoints(event.type(), event.changedTouches(), widget->location(), changedTouches, &changedTouchesLength);
addTouchPoints(event.type(), event.targetTouches(), widget->location(), targetTouches, &targetTouchesLength);
}
#endif // ENABLE(TOUCH_EVENTS)
......
2012-10-02 Sadrul Habib Chowdhury <sadrul@chromium.org>
[chromium] Make sure the touch-points in the touch-events have the correct state.
https://bugs.webkit.org/show_bug.cgi?id=98110
Reviewed by Adam Barth.
TestWebPlugin can now be configured to print out some details about
events. For now, details for only touch events are printed. This is
used to verify that touch-points in the touch-events are properly
set.
* DumpRenderTree/chromium/TestWebPlugin.cpp:
(pointState):
(printTouchList):
(printEventDetails):
(TestWebPlugin::TestWebPlugin):
(TestWebPlugin::handleInputEvent):
* DumpRenderTree/chromium/TestWebPlugin.h:
(TestWebPlugin):
2012-10-02 Zan Dobersek <zandobersek@gmail.com>
 
[XvfbDriver] First tests in each worker occasionally crash
......@@ -33,6 +33,7 @@
#include "platform/WebKitPlatformSupport.h"
#include "WebPluginContainer.h"
#include "WebPluginParams.h"
#include "WebTouchPoint.h"
#include <wtf/Assertions.h>
#include <wtf/text/CString.h>
......@@ -76,18 +77,55 @@ static void premultiplyAlpha(const unsigned colorIn[3], float alpha, float color
colorOut[3] = alpha;
}
static const char* pointState(WebKit::WebTouchPoint::State state)
{
switch (state) {
case WebKit::WebTouchPoint::StateReleased:
return "Released";
case WebKit::WebTouchPoint::StatePressed:
return "Pressed";
case WebKit::WebTouchPoint::StateMoved:
return "Moved";
case WebKit::WebTouchPoint::StateCancelled:
return "Cancelled";
default:
return "Unknown";
}
ASSERT_NOT_REACHED();
return 0;
}
static void printTouchList(const WebKit::WebTouchPoint* points, int length)
{
for (int i = 0; i < length; ++i)
printf("* %d, %d: %s\n", points[i].position.x, points[i].position.y, pointState(points[i].state));
}
static void printEventDetails(const WebKit::WebInputEvent& event)
{
if (WebKit::WebInputEvent::isTouchEventType(event.type)) {
const WebKit::WebTouchEvent& touch = static_cast<const WebKit::WebTouchEvent&>(event);
printTouchList(touch.touches, touch.touchesLength);
printTouchList(touch.changedTouches, touch.changedTouchesLength);
printTouchList(touch.targetTouches, touch.targetTouchesLength);
}
}
TestWebPlugin::TestWebPlugin(WebKit::WebFrame* frame,
const WebKit::WebPluginParams& params)
: m_frame(frame)
, m_container(0)
, m_context(0)
, m_acceptsTouchEvent(false)
, m_printEventDetails(false)
{
static const WebString kAttributePrimitive = WebString::fromUTF8("primitive");
static const WebString kAttributeBackgroundColor = WebString::fromUTF8("background-color");
static const WebString kAttributePrimitiveColor = WebString::fromUTF8("primitive-color");
static const WebString kAttributeOpacity = WebString::fromUTF8("opacity");
static const WebString kAttributeAcceptsTouch = WebString::fromUTF8("accepts-touch");
static const WebString kAttributePrintEventDetails = WebString::fromUTF8("print-event-details");
ASSERT(params.attributeNames.size() == params.attributeValues.size());
size_t size = params.attributeNames.size();
......@@ -105,6 +143,8 @@ TestWebPlugin::TestWebPlugin(WebKit::WebFrame* frame,
m_scene.opacity = parseOpacity(attributeValue);
else if (attributeName == kAttributeAcceptsTouch)
m_acceptsTouchEvent = parseBoolean(attributeValue);
else if (attributeName == kAttributePrintEventDetails)
m_printEventDetails = parseBoolean(attributeValue);
}
}
......@@ -418,6 +458,8 @@ bool TestWebPlugin::handleInputEvent(const WebKit::WebInputEvent& event, WebKit:
}
printf("Plugin received event: %s\n", eventName ? eventName : "unknown");
if (m_printEventDetails)
printEventDetails(event);
return false;
}
......@@ -130,6 +130,7 @@ private:
Scene m_scene;
bool m_acceptsTouchEvent;
bool m_printEventDetails;
};
#endif // TestPepperPlugin_h
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