OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/shell/renderer/test_runner/TestPlugin.h" |
| 6 |
| 7 #include "content/shell/renderer/test_runner/TestCommon.h" |
| 8 #include "content/shell/renderer/test_runner/WebTestDelegate.h" |
| 9 #include "third_party/WebKit/public/platform/Platform.h" |
| 10 #include "third_party/WebKit/public/platform/WebCompositorSupport.h" |
| 11 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
| 12 #include "third_party/WebKit/public/web/WebFrame.h" |
| 13 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 14 #include "third_party/WebKit/public/web/WebKit.h" |
| 15 #include "third_party/WebKit/public/web/WebPluginParams.h" |
| 16 #include "third_party/WebKit/public/web/WebTouchPoint.h" |
| 17 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
| 18 |
| 19 using namespace blink; |
| 20 using namespace std; |
| 21 |
| 22 namespace WebTestRunner { |
| 23 |
| 24 namespace { |
| 25 |
| 26 // GLenum values copied from gl2.h. |
| 27 #define GL_FALSE 0 |
| 28 #define GL_TRUE 1 |
| 29 #define GL_ONE 1 |
| 30 #define GL_TRIANGLES 0x0004 |
| 31 #define GL_ONE_MINUS_SRC_ALPHA 0x0303 |
| 32 #define GL_DEPTH_TEST 0x0B71 |
| 33 #define GL_BLEND 0x0BE2 |
| 34 #define GL_SCISSOR_TEST 0x0B90 |
| 35 #define GL_TEXTURE_2D 0x0DE1 |
| 36 #define GL_FLOAT 0x1406 |
| 37 #define GL_RGBA 0x1908 |
| 38 #define GL_UNSIGNED_BYTE 0x1401 |
| 39 #define GL_TEXTURE_MAG_FILTER 0x2800 |
| 40 #define GL_TEXTURE_MIN_FILTER 0x2801 |
| 41 #define GL_TEXTURE_WRAP_S 0x2802 |
| 42 #define GL_TEXTURE_WRAP_T 0x2803 |
| 43 #define GL_NEAREST 0x2600 |
| 44 #define GL_COLOR_BUFFER_BIT 0x4000 |
| 45 #define GL_CLAMP_TO_EDGE 0x812F |
| 46 #define GL_ARRAY_BUFFER 0x8892 |
| 47 #define GL_STATIC_DRAW 0x88E4 |
| 48 #define GL_FRAGMENT_SHADER 0x8B30 |
| 49 #define GL_VERTEX_SHADER 0x8B31 |
| 50 #define GL_COMPILE_STATUS 0x8B81 |
| 51 #define GL_LINK_STATUS 0x8B82 |
| 52 #define GL_COLOR_ATTACHMENT0 0x8CE0 |
| 53 #define GL_FRAMEBUFFER_COMPLETE 0x8CD5 |
| 54 #define GL_FRAMEBUFFER 0x8D40 |
| 55 |
| 56 void premultiplyAlpha(const unsigned colorIn[3], float alpha, float colorOut[4]) |
| 57 { |
| 58 for (int i = 0; i < 3; ++i) |
| 59 colorOut[i] = (colorIn[i] / 255.0f) * alpha; |
| 60 |
| 61 colorOut[3] = alpha; |
| 62 } |
| 63 |
| 64 const char* pointState(WebTouchPoint::State state) |
| 65 { |
| 66 switch (state) { |
| 67 case WebTouchPoint::StateReleased: |
| 68 return "Released"; |
| 69 case WebTouchPoint::StatePressed: |
| 70 return "Pressed"; |
| 71 case WebTouchPoint::StateMoved: |
| 72 return "Moved"; |
| 73 case WebTouchPoint::StateCancelled: |
| 74 return "Cancelled"; |
| 75 default: |
| 76 return "Unknown"; |
| 77 } |
| 78 |
| 79 BLINK_ASSERT_NOT_REACHED(); |
| 80 return 0; |
| 81 } |
| 82 |
| 83 void printTouchList(WebTestDelegate* delegate, const WebTouchPoint* points, int
length) |
| 84 { |
| 85 for (int i = 0; i < length; ++i) { |
| 86 char buffer[100]; |
| 87 snprintf(buffer, sizeof(buffer), "* %d, %d: %s\n", points[i].position.x,
points[i].position.y, pointState(points[i].state)); |
| 88 delegate->printMessage(buffer); |
| 89 } |
| 90 } |
| 91 |
| 92 void printEventDetails(WebTestDelegate* delegate, const WebInputEvent& event) |
| 93 { |
| 94 if (WebInputEvent::isTouchEventType(event.type)) { |
| 95 const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(event); |
| 96 printTouchList(delegate, touch.touches, touch.touchesLength); |
| 97 printTouchList(delegate, touch.changedTouches, touch.changedTouchesLengt
h); |
| 98 printTouchList(delegate, touch.targetTouches, touch.targetTouchesLength)
; |
| 99 } else if (WebInputEvent::isMouseEventType(event.type) || event.type == WebI
nputEvent::MouseWheel) { |
| 100 const WebMouseEvent& mouse = static_cast<const WebMouseEvent&>(event); |
| 101 char buffer[100]; |
| 102 snprintf(buffer, sizeof(buffer), "* %d, %d\n", mouse.x, mouse.y); |
| 103 delegate->printMessage(buffer); |
| 104 } else if (WebInputEvent::isGestureEventType(event.type)) { |
| 105 const WebGestureEvent& gesture = static_cast<const WebGestureEvent&>(eve
nt); |
| 106 char buffer[100]; |
| 107 snprintf(buffer, sizeof(buffer), "* %d, %d\n", gesture.x, gesture.y); |
| 108 delegate->printMessage(buffer); |
| 109 } |
| 110 } |
| 111 |
| 112 WebPluginContainer::TouchEventRequestType parseTouchEventRequestType(const WebSt
ring& string) |
| 113 { |
| 114 if (string == WebString::fromUTF8("raw")) |
| 115 return WebPluginContainer::TouchEventRequestTypeRaw; |
| 116 if (string == WebString::fromUTF8("synthetic")) |
| 117 return WebPluginContainer::TouchEventRequestTypeSynthesizedMouse; |
| 118 return WebPluginContainer::TouchEventRequestTypeNone; |
| 119 } |
| 120 |
| 121 void deferredDelete(void* context) |
| 122 { |
| 123 TestPlugin* plugin = static_cast<TestPlugin*>(context); |
| 124 delete plugin; |
| 125 } |
| 126 |
| 127 } |
| 128 |
| 129 |
| 130 TestPlugin::TestPlugin(WebFrame* frame, const WebPluginParams& params, WebTestDe
legate* delegate) |
| 131 : m_frame(frame) |
| 132 , m_delegate(delegate) |
| 133 , m_container(0) |
| 134 , m_context(0) |
| 135 , m_colorTexture(0) |
| 136 , m_mailboxChanged(false) |
| 137 , m_framebuffer(0) |
| 138 , m_touchEventRequest(WebPluginContainer::TouchEventRequestTypeNone) |
| 139 , m_reRequestTouchEvents(false) |
| 140 , m_printEventDetails(false) |
| 141 , m_printUserGestureStatus(false) |
| 142 , m_canProcessDrag(false) |
| 143 { |
| 144 static const WebString kAttributePrimitive = WebString::fromUTF8("primitive"
); |
| 145 static const WebString kAttributeBackgroundColor = WebString::fromUTF8("back
ground-color"); |
| 146 static const WebString kAttributePrimitiveColor = WebString::fromUTF8("primi
tive-color"); |
| 147 static const WebString kAttributeOpacity = WebString::fromUTF8("opacity"); |
| 148 static const WebString kAttributeAcceptsTouch = WebString::fromUTF8("accepts
-touch"); |
| 149 static const WebString kAttributeReRequestTouchEvents = WebString::fromUTF8(
"re-request-touch"); |
| 150 static const WebString kAttributePrintEventDetails = WebString::fromUTF8("pr
int-event-details"); |
| 151 static const WebString kAttributeCanProcessDrag = WebString::fromUTF8("can-p
rocess-drag"); |
| 152 static const WebString kAttributePrintUserGestureStatus = WebString::fromUTF
8("print-user-gesture-status"); |
| 153 |
| 154 BLINK_ASSERT(params.attributeNames.size() == params.attributeValues.size()); |
| 155 size_t size = params.attributeNames.size(); |
| 156 for (size_t i = 0; i < size; ++i) { |
| 157 const WebString& attributeName = params.attributeNames[i]; |
| 158 const WebString& attributeValue = params.attributeValues[i]; |
| 159 |
| 160 if (attributeName == kAttributePrimitive) |
| 161 m_scene.primitive = parsePrimitive(attributeValue); |
| 162 else if (attributeName == kAttributeBackgroundColor) |
| 163 parseColor(attributeValue, m_scene.backgroundColor); |
| 164 else if (attributeName == kAttributePrimitiveColor) |
| 165 parseColor(attributeValue, m_scene.primitiveColor); |
| 166 else if (attributeName == kAttributeOpacity) |
| 167 m_scene.opacity = parseOpacity(attributeValue); |
| 168 else if (attributeName == kAttributeAcceptsTouch) |
| 169 m_touchEventRequest = parseTouchEventRequestType(attributeValue); |
| 170 else if (attributeName == kAttributeReRequestTouchEvents) |
| 171 m_reRequestTouchEvents = parseBoolean(attributeValue); |
| 172 else if (attributeName == kAttributePrintEventDetails) |
| 173 m_printEventDetails = parseBoolean(attributeValue); |
| 174 else if (attributeName == kAttributeCanProcessDrag) |
| 175 m_canProcessDrag = parseBoolean(attributeValue); |
| 176 else if (attributeName == kAttributePrintUserGestureStatus) |
| 177 m_printUserGestureStatus = parseBoolean(attributeValue); |
| 178 } |
| 179 } |
| 180 |
| 181 TestPlugin::~TestPlugin() |
| 182 { |
| 183 } |
| 184 |
| 185 bool TestPlugin::initialize(WebPluginContainer* container) |
| 186 { |
| 187 WebGraphicsContext3D::Attributes attrs; |
| 188 m_context = Platform::current()->createOffscreenGraphicsContext3D(attrs); |
| 189 if (!m_context) |
| 190 return false; |
| 191 |
| 192 if (!m_context->makeContextCurrent()) |
| 193 return false; |
| 194 |
| 195 if (!initScene()) |
| 196 return false; |
| 197 |
| 198 m_layer = WebScopedPtr<WebExternalTextureLayer>(Platform::current()->composi
torSupport()->createExternalTextureLayer(this)); |
| 199 m_container = container; |
| 200 m_container->setWebLayer(m_layer->layer()); |
| 201 if (m_reRequestTouchEvents) { |
| 202 m_container->requestTouchEventType(WebPluginContainer::TouchEventRequest
TypeSynthesizedMouse); |
| 203 m_container->requestTouchEventType(WebPluginContainer::TouchEventRequest
TypeRaw); |
| 204 } |
| 205 m_container->requestTouchEventType(m_touchEventRequest); |
| 206 m_container->setWantsWheelEvents(true); |
| 207 return true; |
| 208 } |
| 209 |
| 210 void TestPlugin::destroy() |
| 211 { |
| 212 if (m_layer.get()) |
| 213 m_layer->clearTexture(); |
| 214 if (m_container) |
| 215 m_container->setWebLayer(0); |
| 216 m_layer.reset(); |
| 217 destroyScene(); |
| 218 |
| 219 delete m_context; |
| 220 m_context = 0; |
| 221 |
| 222 m_container = 0; |
| 223 m_frame = 0; |
| 224 |
| 225 Platform::current()->callOnMainThread(deferredDelete, this); |
| 226 } |
| 227 |
| 228 void TestPlugin::updateGeometry(const WebRect& frameRect, const WebRect& clipRec
t, const WebVector<WebRect>& cutOutsRects, bool isVisible) |
| 229 { |
| 230 if (clipRect == m_rect) |
| 231 return; |
| 232 m_rect = clipRect; |
| 233 if (m_rect.isEmpty()) |
| 234 return; |
| 235 |
| 236 m_context->reshapeWithScaleFactor(m_rect.width, m_rect.height, 1.f); |
| 237 m_context->viewport(0, 0, m_rect.width, m_rect.height); |
| 238 |
| 239 m_context->bindTexture(GL_TEXTURE_2D, m_colorTexture); |
| 240 m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 241 m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 242 m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)
; |
| 243 m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)
; |
| 244 m_context->texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_rect.width, m_rect.height
, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); |
| 245 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_framebuffer); |
| 246 m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEX
TURE_2D, m_colorTexture, 0); |
| 247 |
| 248 drawScene(); |
| 249 |
| 250 m_context->genMailboxCHROMIUM(m_mailbox.name); |
| 251 m_context->produceTextureCHROMIUM(GL_TEXTURE_2D, m_mailbox.name); |
| 252 |
| 253 m_context->flush(); |
| 254 m_layer->layer()->invalidate(); |
| 255 m_mailboxChanged = true; |
| 256 } |
| 257 |
| 258 bool TestPlugin::prepareMailbox(blink::WebExternalTextureMailbox* mailbox, blink
::WebExternalBitmap*) |
| 259 { |
| 260 if (!m_mailboxChanged) |
| 261 return false; |
| 262 *mailbox = m_mailbox; |
| 263 m_mailboxChanged = false; |
| 264 return true; |
| 265 } |
| 266 |
| 267 void TestPlugin::mailboxReleased(const blink::WebExternalTextureMailbox&) |
| 268 { |
| 269 } |
| 270 |
| 271 TestPlugin::Primitive TestPlugin::parsePrimitive(const WebString& string) |
| 272 { |
| 273 static const WebString kPrimitiveNone = WebString::fromUTF8("none"); |
| 274 static const WebString kPrimitiveTriangle = WebString::fromUTF8("triangle"); |
| 275 |
| 276 Primitive primitive = PrimitiveNone; |
| 277 if (string == kPrimitiveNone) |
| 278 primitive = PrimitiveNone; |
| 279 else if (string == kPrimitiveTriangle) |
| 280 primitive = PrimitiveTriangle; |
| 281 else |
| 282 BLINK_ASSERT_NOT_REACHED(); |
| 283 return primitive; |
| 284 } |
| 285 |
| 286 // FIXME: This method should already exist. Use it. |
| 287 // For now just parse primary colors. |
| 288 void TestPlugin::parseColor(const WebString& string, unsigned color[3]) |
| 289 { |
| 290 color[0] = color[1] = color[2] = 0; |
| 291 if (string == "black") |
| 292 return; |
| 293 |
| 294 if (string == "red") |
| 295 color[0] = 255; |
| 296 else if (string == "green") |
| 297 color[1] = 255; |
| 298 else if (string == "blue") |
| 299 color[2] = 255; |
| 300 else |
| 301 BLINK_ASSERT_NOT_REACHED(); |
| 302 } |
| 303 |
| 304 float TestPlugin::parseOpacity(const WebString& string) |
| 305 { |
| 306 return static_cast<float>(atof(string.utf8().data())); |
| 307 } |
| 308 |
| 309 bool TestPlugin::parseBoolean(const WebString& string) |
| 310 { |
| 311 static const WebString kPrimitiveTrue = WebString::fromUTF8("true"); |
| 312 return string == kPrimitiveTrue; |
| 313 } |
| 314 |
| 315 bool TestPlugin::initScene() |
| 316 { |
| 317 float color[4]; |
| 318 premultiplyAlpha(m_scene.backgroundColor, m_scene.opacity, color); |
| 319 |
| 320 m_colorTexture = m_context->createTexture(); |
| 321 m_framebuffer = m_context->createFramebuffer(); |
| 322 |
| 323 m_context->viewport(0, 0, m_rect.width, m_rect.height); |
| 324 m_context->disable(GL_DEPTH_TEST); |
| 325 m_context->disable(GL_SCISSOR_TEST); |
| 326 |
| 327 m_context->clearColor(color[0], color[1], color[2], color[3]); |
| 328 |
| 329 m_context->enable(GL_BLEND); |
| 330 m_context->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 331 |
| 332 return m_scene.primitive != PrimitiveNone ? initProgram() && initPrimitive()
: true; |
| 333 } |
| 334 |
| 335 void TestPlugin::drawScene() |
| 336 { |
| 337 m_context->viewport(0, 0, m_rect.width, m_rect.height); |
| 338 m_context->clear(GL_COLOR_BUFFER_BIT); |
| 339 |
| 340 if (m_scene.primitive != PrimitiveNone) |
| 341 drawPrimitive(); |
| 342 } |
| 343 |
| 344 void TestPlugin::destroyScene() |
| 345 { |
| 346 if (m_scene.program) { |
| 347 m_context->deleteProgram(m_scene.program); |
| 348 m_scene.program = 0; |
| 349 } |
| 350 if (m_scene.vbo) { |
| 351 m_context->deleteBuffer(m_scene.vbo); |
| 352 m_scene.vbo = 0; |
| 353 } |
| 354 |
| 355 if (m_framebuffer) { |
| 356 m_context->deleteFramebuffer(m_framebuffer); |
| 357 m_framebuffer = 0; |
| 358 } |
| 359 |
| 360 if (m_colorTexture) { |
| 361 m_context->deleteTexture(m_colorTexture); |
| 362 m_colorTexture = 0; |
| 363 } |
| 364 } |
| 365 |
| 366 bool TestPlugin::initProgram() |
| 367 { |
| 368 const string vertexSource( |
| 369 "attribute vec4 position; \n" |
| 370 "void main() { \n" |
| 371 " gl_Position = position; \n" |
| 372 "} \n" |
| 373 ); |
| 374 |
| 375 const string fragmentSource( |
| 376 "precision mediump float; \n" |
| 377 "uniform vec4 color; \n" |
| 378 "void main() { \n" |
| 379 " gl_FragColor = color; \n" |
| 380 "} \n" |
| 381 ); |
| 382 |
| 383 m_scene.program = loadProgram(vertexSource, fragmentSource); |
| 384 if (!m_scene.program) |
| 385 return false; |
| 386 |
| 387 m_scene.colorLocation = m_context->getUniformLocation(m_scene.program, "colo
r"); |
| 388 m_scene.positionLocation = m_context->getAttribLocation(m_scene.program, "po
sition"); |
| 389 return true; |
| 390 } |
| 391 |
| 392 bool TestPlugin::initPrimitive() |
| 393 { |
| 394 BLINK_ASSERT(m_scene.primitive == PrimitiveTriangle); |
| 395 |
| 396 m_scene.vbo = m_context->createBuffer(); |
| 397 if (!m_scene.vbo) |
| 398 return false; |
| 399 |
| 400 const float vertices[] = { |
| 401 0.0f, 0.8f, 0.0f, |
| 402 -0.8f, -0.8f, 0.0f, |
| 403 0.8f, -0.8f, 0.0f }; |
| 404 m_context->bindBuffer(GL_ARRAY_BUFFER, m_scene.vbo); |
| 405 m_context->bufferData(GL_ARRAY_BUFFER, sizeof(vertices), 0, GL_STATIC_DRAW); |
| 406 m_context->bufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertices), vertices); |
| 407 return true; |
| 408 } |
| 409 |
| 410 void TestPlugin::drawPrimitive() |
| 411 { |
| 412 BLINK_ASSERT(m_scene.primitive == PrimitiveTriangle); |
| 413 BLINK_ASSERT(m_scene.vbo); |
| 414 BLINK_ASSERT(m_scene.program); |
| 415 |
| 416 m_context->useProgram(m_scene.program); |
| 417 |
| 418 // Bind primitive color. |
| 419 float color[4]; |
| 420 premultiplyAlpha(m_scene.primitiveColor, m_scene.opacity, color); |
| 421 m_context->uniform4f(m_scene.colorLocation, color[0], color[1], color[2], co
lor[3]); |
| 422 |
| 423 // Bind primitive vertices. |
| 424 m_context->bindBuffer(GL_ARRAY_BUFFER, m_scene.vbo); |
| 425 m_context->enableVertexAttribArray(m_scene.positionLocation); |
| 426 m_context->vertexAttribPointer(m_scene.positionLocation, 3, GL_FLOAT, GL_FAL
SE, 0, 0); |
| 427 m_context->drawArrays(GL_TRIANGLES, 0, 3); |
| 428 } |
| 429 |
| 430 unsigned TestPlugin::loadShader(unsigned type, const string& source) |
| 431 { |
| 432 unsigned shader = m_context->createShader(type); |
| 433 if (shader) { |
| 434 m_context->shaderSource(shader, source.data()); |
| 435 m_context->compileShader(shader); |
| 436 |
| 437 int compiled = 0; |
| 438 m_context->getShaderiv(shader, GL_COMPILE_STATUS, &compiled); |
| 439 if (!compiled) { |
| 440 m_context->deleteShader(shader); |
| 441 shader = 0; |
| 442 } |
| 443 } |
| 444 return shader; |
| 445 } |
| 446 |
| 447 unsigned TestPlugin::loadProgram(const string& vertexSource, const string& fragm
entSource) |
| 448 { |
| 449 unsigned vertexShader = loadShader(GL_VERTEX_SHADER, vertexSource); |
| 450 unsigned fragmentShader = loadShader(GL_FRAGMENT_SHADER, fragmentSource); |
| 451 unsigned program = m_context->createProgram(); |
| 452 if (vertexShader && fragmentShader && program) { |
| 453 m_context->attachShader(program, vertexShader); |
| 454 m_context->attachShader(program, fragmentShader); |
| 455 m_context->linkProgram(program); |
| 456 |
| 457 int linked = 0; |
| 458 m_context->getProgramiv(program, GL_LINK_STATUS, &linked); |
| 459 if (!linked) { |
| 460 m_context->deleteProgram(program); |
| 461 program = 0; |
| 462 } |
| 463 } |
| 464 if (vertexShader) |
| 465 m_context->deleteShader(vertexShader); |
| 466 if (fragmentShader) |
| 467 m_context->deleteShader(fragmentShader); |
| 468 |
| 469 return program; |
| 470 } |
| 471 |
| 472 bool TestPlugin::handleInputEvent(const WebInputEvent& event, WebCursorInfo& inf
o) |
| 473 { |
| 474 const char* eventName = 0; |
| 475 switch (event.type) { |
| 476 case WebInputEvent::Undefined: eventName = "unknown"; break; |
| 477 |
| 478 case WebInputEvent::MouseDown: eventName = "MouseDown"; break; |
| 479 case WebInputEvent::MouseUp: eventName = "MouseUp"; break; |
| 480 case WebInputEvent::MouseMove: eventName = "MouseMove"; break; |
| 481 case WebInputEvent::MouseEnter: eventName = "MouseEnter"; break; |
| 482 case WebInputEvent::MouseLeave: eventName = "MouseLeave"; break; |
| 483 case WebInputEvent::ContextMenu: eventName = "ContextMenu"; break; |
| 484 |
| 485 case WebInputEvent::MouseWheel: eventName = "MouseWheel"; break; |
| 486 |
| 487 case WebInputEvent::RawKeyDown: eventName = "RawKeyDown"; break; |
| 488 case WebInputEvent::KeyDown: eventName = "KeyDown"; break; |
| 489 case WebInputEvent::KeyUp: eventName = "KeyUp"; break; |
| 490 case WebInputEvent::Char: eventName = "Char"; break; |
| 491 |
| 492 case WebInputEvent::GestureScrollBegin: eventName = "GestureScrollBegin"; b
reak; |
| 493 case WebInputEvent::GestureScrollEnd: eventName = "GestureScrollEnd"; bre
ak; |
| 494 case WebInputEvent::GestureScrollUpdateWithoutPropagation: |
| 495 case WebInputEvent::GestureScrollUpdate: eventName = "GestureScrollUpdate";
break; |
| 496 case WebInputEvent::GestureFlingStart: eventName = "GestureFlingStart"; br
eak; |
| 497 case WebInputEvent::GestureFlingCancel: eventName = "GestureFlingCancel"; b
reak; |
| 498 case WebInputEvent::GestureTap: eventName = "GestureTap"; break; |
| 499 case WebInputEvent::GestureTapUnconfirmed: |
| 500 eventName = "GestureTapUnconfirmed"
; break; |
| 501 case WebInputEvent::GestureTapDown: eventName = "GestureTapDown"; break
; |
| 502 case WebInputEvent::GestureShowPress: eventName = "GestureShowPress"; bre
ak; |
| 503 case WebInputEvent::GestureTapCancel: eventName = "GestureTapCancel"; bre
ak; |
| 504 case WebInputEvent::GestureDoubleTap: eventName = "GestureDoubleTap"; bre
ak; |
| 505 case WebInputEvent::GestureTwoFingerTap: eventName = "GestureTwoFingerTap";
break; |
| 506 case WebInputEvent::GestureLongPress: eventName = "GestureLongPress"; bre
ak; |
| 507 case WebInputEvent::GestureLongTap: eventName = "GestureLongTap"; break
; |
| 508 case WebInputEvent::GesturePinchBegin: eventName = "GesturePinchBegin"; br
eak; |
| 509 case WebInputEvent::GesturePinchEnd: eventName = "GesturePinchEnd"; brea
k; |
| 510 case WebInputEvent::GesturePinchUpdate: eventName = "GesturePinchUpdate"; b
reak; |
| 511 |
| 512 case WebInputEvent::TouchStart: eventName = "TouchStart"; break; |
| 513 case WebInputEvent::TouchMove: eventName = "TouchMove"; break; |
| 514 case WebInputEvent::TouchEnd: eventName = "TouchEnd"; break; |
| 515 case WebInputEvent::TouchCancel: eventName = "TouchCancel"; break; |
| 516 } |
| 517 |
| 518 m_delegate->printMessage(std::string("Plugin received event: ") + (eventName
? eventName : "unknown") + "\n"); |
| 519 if (m_printEventDetails) |
| 520 printEventDetails(m_delegate, event); |
| 521 if (m_printUserGestureStatus) |
| 522 m_delegate->printMessage(std::string("* ") + (WebUserGestureIndicator::i
sProcessingUserGesture() ? "" : "not ") + "handling user gesture\n"); |
| 523 return false; |
| 524 } |
| 525 |
| 526 bool TestPlugin::handleDragStatusUpdate(WebDragStatus dragStatus, const WebDragD
ata&, WebDragOperationsMask, const WebPoint& position, const WebPoint& screenPos
ition) |
| 527 { |
| 528 const char* dragStatusName = 0; |
| 529 switch (dragStatus) { |
| 530 case WebDragStatusEnter: |
| 531 dragStatusName = "DragEnter"; |
| 532 break; |
| 533 case WebDragStatusOver: |
| 534 dragStatusName = "DragOver"; |
| 535 break; |
| 536 case WebDragStatusLeave: |
| 537 dragStatusName = "DragLeave"; |
| 538 break; |
| 539 case WebDragStatusDrop: |
| 540 dragStatusName = "DragDrop"; |
| 541 break; |
| 542 case WebDragStatusUnknown: |
| 543 BLINK_ASSERT_NOT_REACHED(); |
| 544 } |
| 545 m_delegate->printMessage(std::string("Plugin received event: ") + dragStatus
Name + "\n"); |
| 546 return false; |
| 547 } |
| 548 |
| 549 TestPlugin* TestPlugin::create(WebFrame* frame, const WebPluginParams& params, W
ebTestDelegate* delegate) |
| 550 { |
| 551 return new TestPlugin(frame, params, delegate); |
| 552 } |
| 553 |
| 554 const WebString& TestPlugin::mimeType() |
| 555 { |
| 556 static const WebString kMimeType = WebString::fromUTF8("application/x-webkit
-test-webplugin"); |
| 557 return kMimeType; |
| 558 } |
| 559 |
| 560 } |
OLD | NEW |