OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. |
3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) | 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 #include "sky/engine/core/page/ChromeClient.h" | 53 #include "sky/engine/core/page/ChromeClient.h" |
54 #include "sky/engine/core/page/EditorClient.h" | 54 #include "sky/engine/core/page/EditorClient.h" |
55 #include "sky/engine/core/page/EventWithHitTestResults.h" | 55 #include "sky/engine/core/page/EventWithHitTestResults.h" |
56 #include "sky/engine/core/page/FocusController.h" | 56 #include "sky/engine/core/page/FocusController.h" |
57 #include "sky/engine/core/page/Page.h" | 57 #include "sky/engine/core/page/Page.h" |
58 #include "sky/engine/core/rendering/HitTestRequest.h" | 58 #include "sky/engine/core/rendering/HitTestRequest.h" |
59 #include "sky/engine/core/rendering/HitTestResult.h" | 59 #include "sky/engine/core/rendering/HitTestResult.h" |
60 #include "sky/engine/core/rendering/RenderLayer.h" | 60 #include "sky/engine/core/rendering/RenderLayer.h" |
61 #include "sky/engine/core/rendering/RenderView.h" | 61 #include "sky/engine/core/rendering/RenderView.h" |
62 #include "sky/engine/core/rendering/style/RenderStyle.h" | 62 #include "sky/engine/core/rendering/style/RenderStyle.h" |
63 #include "sky/engine/platform/PlatformKeyboardEvent.h" | |
64 #include "sky/engine/platform/TraceEvent.h" | 63 #include "sky/engine/platform/TraceEvent.h" |
65 #include "sky/engine/platform/WindowsKeyboardCodes.h" | 64 #include "sky/engine/platform/KeyboardCodes.h" |
66 #include "sky/engine/platform/geometry/FloatPoint.h" | 65 #include "sky/engine/platform/geometry/FloatPoint.h" |
67 #include "sky/engine/platform/graphics/Image.h" | 66 #include "sky/engine/platform/graphics/Image.h" |
68 #include "sky/engine/platform/heap/Handle.h" | 67 #include "sky/engine/platform/heap/Handle.h" |
69 #include "sky/engine/platform/scroll/ScrollAnimator.h" | 68 #include "sky/engine/platform/scroll/ScrollAnimator.h" |
70 #include "sky/engine/platform/scroll/Scrollbar.h" | 69 #include "sky/engine/platform/scroll/Scrollbar.h" |
71 #include "sky/engine/wtf/Assertions.h" | 70 #include "sky/engine/wtf/Assertions.h" |
72 #include "sky/engine/wtf/CurrentTime.h" | 71 #include "sky/engine/wtf/CurrentTime.h" |
73 #include "sky/engine/wtf/StdLibExtras.h" | 72 #include "sky/engine/wtf/StdLibExtras.h" |
74 #include "sky/engine/wtf/TemporaryChange.h" | 73 #include "sky/engine/wtf/TemporaryChange.h" |
75 | 74 |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 } | 492 } |
494 | 493 |
495 void EventHandler::notifyElementActivated() | 494 void EventHandler::notifyElementActivated() |
496 { | 495 { |
497 // Since another element has been set to active, stop current timer and clea
r reference. | 496 // Since another element has been set to active, stop current timer and clea
r reference. |
498 if (m_activeIntervalTimer.isActive()) | 497 if (m_activeIntervalTimer.isActive()) |
499 m_activeIntervalTimer.stop(); | 498 m_activeIntervalTimer.stop(); |
500 m_lastDeferredTapElement = nullptr; | 499 m_lastDeferredTapElement = nullptr; |
501 } | 500 } |
502 | 501 |
503 bool EventHandler::keyEvent(const PlatformKeyboardEvent& initialKeyEvent) | |
504 { | |
505 RefPtr<FrameView> protector(m_frame->view()); | |
506 | |
507 if (initialKeyEvent.windowsVirtualKeyCode() == VK_CAPITAL) | |
508 capsLockStateMayHaveChanged(); | |
509 | |
510 // Check for cases where we are too early for events -- possible unmatched k
ey up | |
511 // from pressing return in the location bar. | |
512 RefPtr<Node> node = eventTargetNodeForDocument(m_frame->document()); | |
513 if (!node) | |
514 return false; | |
515 | |
516 // FIXME: it would be fair to let an input method handle KeyUp events before
DOM dispatch. | |
517 if (initialKeyEvent.type() == PlatformEvent::KeyUp || initialKeyEvent.type()
== PlatformEvent::Char) | |
518 return !node->dispatchKeyEvent(initialKeyEvent); | |
519 | |
520 PlatformKeyboardEvent keyDownEvent = initialKeyEvent; | |
521 if (keyDownEvent.type() != PlatformEvent::RawKeyDown) | |
522 keyDownEvent.disambiguateKeyDownEvent(PlatformEvent::RawKeyDown); | |
523 RefPtr<KeyboardEvent> keydown = KeyboardEvent::create(keyDownEvent, m_frame-
>document()->domWindow()); | |
524 | |
525 keydown->setTarget(node); | |
526 | |
527 if (initialKeyEvent.type() == PlatformEvent::RawKeyDown) { | |
528 node->dispatchEvent(keydown, IGNORE_EXCEPTION); | |
529 // If frame changed as a result of keydown dispatch, then return true to
avoid sending a subsequent keypress message to the new frame. | |
530 bool changedFocusedFrame = m_frame->page() && m_frame != m_frame->page()
->focusController().focusedOrMainFrame(); | |
531 return keydown->defaultHandled() || keydown->defaultPrevented() || chang
edFocusedFrame; | |
532 } | |
533 | |
534 node->dispatchEvent(keydown, IGNORE_EXCEPTION); | |
535 // If frame changed as a result of keydown dispatch, then return early to av
oid sending a subsequent keypress message to the new frame. | |
536 bool changedFocusedFrame = m_frame->page() && m_frame != m_frame->page()->fo
cusController().focusedOrMainFrame(); | |
537 bool keydownResult = keydown->defaultHandled() || keydown->defaultPrevented(
) || changedFocusedFrame; | |
538 if (keydownResult) | |
539 return keydownResult; | |
540 | |
541 // Focus may have changed during keydown handling, so refetch node. | |
542 // But if we are dispatching a fake backward compatibility keypress, then we
pretend that the keypress happened on the original node. | |
543 node = eventTargetNodeForDocument(m_frame->document()); | |
544 if (!node) | |
545 return false; | |
546 | |
547 PlatformKeyboardEvent keyPressEvent = initialKeyEvent; | |
548 keyPressEvent.disambiguateKeyDownEvent(PlatformEvent::Char); | |
549 if (keyPressEvent.text().isEmpty()) | |
550 return keydownResult; | |
551 RefPtr<KeyboardEvent> keypress = KeyboardEvent::create(keyPressEvent, m_fram
e->document()->domWindow()); | |
552 keypress->setTarget(node); | |
553 if (keydownResult) | |
554 keypress->setDefaultPrevented(true); | |
555 node->dispatchEvent(keypress, IGNORE_EXCEPTION); | |
556 | |
557 return keydownResult || keypress->defaultPrevented() || keypress->defaultHan
dled(); | |
558 } | |
559 | |
560 void EventHandler::defaultKeyboardEventHandler(KeyboardEvent* event) | 502 void EventHandler::defaultKeyboardEventHandler(KeyboardEvent* event) |
561 { | 503 { |
562 if (event->type() == EventTypeNames::keydown) { | 504 if (event->type() == EventTypeNames::keydown) { |
563 // Clear caret blinking suspended state to make sure that caret blinks | 505 // Clear caret blinking suspended state to make sure that caret blinks |
564 // when we type again after long pressing on an empty input field. | 506 // when we type again after long pressing on an empty input field. |
565 if (m_frame && m_frame->selection().isCaretBlinkingSuspended()) | 507 if (m_frame && m_frame->selection().isCaretBlinkingSuspended()) |
566 m_frame->selection().setCaretBlinkingSuspended(false); | 508 m_frame->selection().setCaretBlinkingSuspended(false); |
567 | 509 |
568 m_frame->editor().handleKeyboardEvent(event); | 510 m_frame->editor().handleKeyboardEvent(event); |
569 if (event->defaultHandled()) | 511 if (event->defaultHandled()) |
570 return; | 512 return; |
571 if (event->keyIdentifier() == "U+0009") | 513 if (event->key() == VKEY_TAB) |
572 defaultTabEventHandler(event); | 514 defaultTabEventHandler(event); |
573 } | 515 } |
574 if (event->type() == EventTypeNames::keypress) { | 516 if (event->type() == EventTypeNames::keypress) { |
575 m_frame->editor().handleKeyboardEvent(event); | 517 m_frame->editor().handleKeyboardEvent(event); |
576 if (event->defaultHandled()) | 518 if (event->defaultHandled()) |
577 return; | 519 return; |
578 } | 520 } |
579 } | 521 } |
580 | 522 |
581 bool EventHandler::dragHysteresisExceeded(const FloatPoint& floatDragViewportLoc
ation) const | 523 bool EventHandler::dragHysteresisExceeded(const FloatPoint& floatDragViewportLoc
ation) const |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 | 621 |
680 void EventHandler::focusDocumentView() | 622 void EventHandler::focusDocumentView() |
681 { | 623 { |
682 Page* page = m_frame->page(); | 624 Page* page = m_frame->page(); |
683 if (!page) | 625 if (!page) |
684 return; | 626 return; |
685 page->focusController().focusDocumentView(m_frame); | 627 page->focusController().focusDocumentView(m_frame); |
686 } | 628 } |
687 | 629 |
688 } // namespace blink | 630 } // namespace blink |
OLD | NEW |