OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 bool PlatformKeyboardEventBuilder::isCharacterKey() const | 318 bool PlatformKeyboardEventBuilder::isCharacterKey() const |
319 { | 319 { |
320 switch (windowsVirtualKeyCode()) { | 320 switch (windowsVirtualKeyCode()) { |
321 case VKEY_BACK: | 321 case VKEY_BACK: |
322 case VKEY_ESCAPE: | 322 case VKEY_ESCAPE: |
323 return false; | 323 return false; |
324 } | 324 } |
325 return true; | 325 return true; |
326 } | 326 } |
327 | 327 |
328 #if ENABLE(TOUCH_EVENTS) | |
329 inline PlatformEvent::Type toPlatformTouchEventType(const WebInputEvent::Type ty
pe) | 328 inline PlatformEvent::Type toPlatformTouchEventType(const WebInputEvent::Type ty
pe) |
330 { | 329 { |
331 switch (type) { | 330 switch (type) { |
332 case WebInputEvent::TouchStart: | 331 case WebInputEvent::TouchStart: |
333 return PlatformEvent::TouchStart; | 332 return PlatformEvent::TouchStart; |
334 case WebInputEvent::TouchMove: | 333 case WebInputEvent::TouchMove: |
335 return PlatformEvent::TouchMove; | 334 return PlatformEvent::TouchMove; |
336 case WebInputEvent::TouchEnd: | 335 case WebInputEvent::TouchEnd: |
337 return PlatformEvent::TouchEnd; | 336 return PlatformEvent::TouchEnd; |
338 case WebInputEvent::TouchCancel: | 337 case WebInputEvent::TouchCancel: |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 if (event.modifiers & WebInputEvent::AltKey) | 399 if (event.modifiers & WebInputEvent::AltKey) |
401 m_modifiers |= PlatformEvent::AltKey; | 400 m_modifiers |= PlatformEvent::AltKey; |
402 if (event.modifiers & WebInputEvent::MetaKey) | 401 if (event.modifiers & WebInputEvent::MetaKey) |
403 m_modifiers |= PlatformEvent::MetaKey; | 402 m_modifiers |= PlatformEvent::MetaKey; |
404 | 403 |
405 m_timestamp = event.timeStampSeconds; | 404 m_timestamp = event.timeStampSeconds; |
406 | 405 |
407 for (unsigned i = 0; i < event.touchesLength; ++i) | 406 for (unsigned i = 0; i < event.touchesLength; ++i) |
408 m_touchPoints.append(PlatformTouchPointBuilder(widget, event.touches[i])
); | 407 m_touchPoints.append(PlatformTouchPointBuilder(widget, event.touches[i])
); |
409 } | 408 } |
410 #endif | |
411 | 409 |
412 static int getWebInputModifiers(const UIEventWithKeyState& event) | 410 static int getWebInputModifiers(const UIEventWithKeyState& event) |
413 { | 411 { |
414 int modifiers = 0; | 412 int modifiers = 0; |
415 if (event.ctrlKey()) | 413 if (event.ctrlKey()) |
416 modifiers |= WebInputEvent::ControlKey; | 414 modifiers |= WebInputEvent::ControlKey; |
417 if (event.shiftKey()) | 415 if (event.shiftKey()) |
418 modifiers |= WebInputEvent::ShiftKey; | 416 modifiers |= WebInputEvent::ShiftKey; |
419 if (event.altKey()) | 417 if (event.altKey()) |
420 modifiers |= WebInputEvent::AltKey; | 418 modifiers |= WebInputEvent::AltKey; |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 return; | 567 return; |
570 nativeKeyCode = event.keyEvent()->nativeVirtualKeyCode(); | 568 nativeKeyCode = event.keyEvent()->nativeVirtualKeyCode(); |
571 unsigned numberOfCharacters = std::min(event.keyEvent()->text().length(), st
atic_cast<unsigned>(textLengthCap)); | 569 unsigned numberOfCharacters = std::min(event.keyEvent()->text().length(), st
atic_cast<unsigned>(textLengthCap)); |
572 for (unsigned i = 0; i < numberOfCharacters; ++i) { | 570 for (unsigned i = 0; i < numberOfCharacters; ++i) { |
573 text[i] = event.keyEvent()->text()[i]; | 571 text[i] = event.keyEvent()->text()[i]; |
574 unmodifiedText[i] = event.keyEvent()->unmodifiedText()[i]; | 572 unmodifiedText[i] = event.keyEvent()->unmodifiedText()[i]; |
575 } | 573 } |
576 memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), event.keyIdentif
ier().length()); | 574 memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), event.keyIdentif
ier().length()); |
577 } | 575 } |
578 | 576 |
579 #if ENABLE(TOUCH_EVENTS) | |
580 | |
581 static void addTouchPoints(const Widget* widget, const AtomicString& touchType,
TouchList* touches, WebTouchPoint* touchPoints, unsigned* touchPointsLength, con
st WebCore::RenderObject* renderObject) | 577 static void addTouchPoints(const Widget* widget, const AtomicString& touchType,
TouchList* touches, WebTouchPoint* touchPoints, unsigned* touchPointsLength, con
st WebCore::RenderObject* renderObject) |
582 { | 578 { |
583 unsigned numberOfTouches = std::min(touches->length(), static_cast<unsigned>
(WebTouchEvent::touchesLengthCap)); | 579 unsigned numberOfTouches = std::min(touches->length(), static_cast<unsigned>
(WebTouchEvent::touchesLengthCap)); |
584 for (unsigned i = 0; i < numberOfTouches; ++i) { | 580 for (unsigned i = 0; i < numberOfTouches; ++i) { |
585 const Touch* touch = touches->item(i); | 581 const Touch* touch = touches->item(i); |
586 | 582 |
587 WebTouchPoint point; | 583 WebTouchPoint point; |
588 point.id = touch->identifier(); | 584 point.id = touch->identifier(); |
589 point.screenPosition = WebPoint(touch->screenX(), touch->screenY()); | 585 point.screenPosition = WebPoint(touch->screenX(), touch->screenY()); |
590 point.position = convertAbsoluteLocationForRenderObject(touch->absoluteL
ocation(), *renderObject); | 586 point.position = convertAbsoluteLocationForRenderObject(touch->absoluteL
ocation(), *renderObject); |
(...skipping 25 matching lines...) Expand all Loading... |
616 } | 612 } |
617 | 613 |
618 modifiers = getWebInputModifiers(event); | 614 modifiers = getWebInputModifiers(event); |
619 timeStampSeconds = event.timeStamp() / millisPerSecond; | 615 timeStampSeconds = event.timeStamp() / millisPerSecond; |
620 | 616 |
621 addTouchPoints(widget, event.type(), event.touches(), touches, &touchesLengt
h, renderObject); | 617 addTouchPoints(widget, event.type(), event.touches(), touches, &touchesLengt
h, renderObject); |
622 addTouchPoints(widget, event.type(), event.changedTouches(), changedTouches,
&changedTouchesLength, renderObject); | 618 addTouchPoints(widget, event.type(), event.changedTouches(), changedTouches,
&changedTouchesLength, renderObject); |
623 addTouchPoints(widget, event.type(), event.targetTouches(), targetTouches, &
targetTouchesLength, renderObject); | 619 addTouchPoints(widget, event.type(), event.targetTouches(), targetTouches, &
targetTouchesLength, renderObject); |
624 } | 620 } |
625 | 621 |
626 #endif // ENABLE(TOUCH_EVENTS) | |
627 | |
628 WebGestureEventBuilder::WebGestureEventBuilder(const Widget* widget, const WebCo
re::RenderObject* renderObject, const GestureEvent& event) | 622 WebGestureEventBuilder::WebGestureEventBuilder(const Widget* widget, const WebCo
re::RenderObject* renderObject, const GestureEvent& event) |
629 { | 623 { |
630 if (event.type() == eventNames().gesturetapEvent) | 624 if (event.type() == eventNames().gesturetapEvent) |
631 type = GestureTap; | 625 type = GestureTap; |
632 else if (event.type() == eventNames().gesturetapdownEvent) | 626 else if (event.type() == eventNames().gesturetapdownEvent) |
633 type = GestureTapDown; | 627 type = GestureTapDown; |
634 else if (event.type() == eventNames().gesturescrollstartEvent) | 628 else if (event.type() == eventNames().gesturescrollstartEvent) |
635 type = GestureScrollBegin; | 629 type = GestureScrollBegin; |
636 else if (event.type() == eventNames().gesturescrollendEvent) | 630 else if (event.type() == eventNames().gesturescrollendEvent) |
637 type = GestureScrollEnd; | 631 type = GestureScrollEnd; |
638 else if (event.type() == eventNames().gesturescrollupdateEvent) { | 632 else if (event.type() == eventNames().gesturescrollupdateEvent) { |
639 type = GestureScrollUpdate; | 633 type = GestureScrollUpdate; |
640 data.scrollUpdate.deltaX = event.deltaX(); | 634 data.scrollUpdate.deltaX = event.deltaX(); |
641 data.scrollUpdate.deltaY = event.deltaY(); | 635 data.scrollUpdate.deltaY = event.deltaY(); |
642 } | 636 } |
643 | 637 |
644 timeStampSeconds = event.timeStamp() / millisPerSecond; | 638 timeStampSeconds = event.timeStamp() / millisPerSecond; |
645 modifiers = getWebInputModifiers(event); | 639 modifiers = getWebInputModifiers(event); |
646 | 640 |
647 globalX = event.screenX(); | 641 globalX = event.screenX(); |
648 globalY = event.screenY(); | 642 globalY = event.screenY(); |
649 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), *renderObject); | 643 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), *renderObject); |
650 x = localPoint.x(); | 644 x = localPoint.x(); |
651 y = localPoint.y(); | 645 y = localPoint.y(); |
652 } | 646 } |
653 | 647 |
654 } // namespace WebKit | 648 } // namespace WebKit |
OLD | NEW |