| 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 1693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1704 return false; | 1704 return false; |
| 1705 | 1705 |
| 1706 view->resetDeferredRepaintDelay(); | 1706 view->resetDeferredRepaintDelay(); |
| 1707 RefPtr<MouseEvent> me = MouseEvent::create(eventType, | 1707 RefPtr<MouseEvent> me = MouseEvent::create(eventType, |
| 1708 true, true, m_frame->document()->defaultView(), | 1708 true, true, m_frame->document()->defaultView(), |
| 1709 0, event.globalPosition().x(), event.globalPosition().y(), event.positio
n().x(), event.position().y(), | 1709 0, event.globalPosition().x(), event.globalPosition().y(), event.positio
n().x(), event.position().y(), |
| 1710 event.movementDelta().x(), event.movementDelta().y(), | 1710 event.movementDelta().x(), event.movementDelta().y(), |
| 1711 event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(), | 1711 event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(), |
| 1712 0, 0, clipboard); | 1712 0, 0, clipboard); |
| 1713 | 1713 |
| 1714 dragTarget->dispatchEvent(me.get(), IGNORE_EXCEPTION_STATE); | 1714 dragTarget->dispatchEvent(me.get(), IGNORE_EXCEPTION); |
| 1715 return me->defaultPrevented(); | 1715 return me->defaultPrevented(); |
| 1716 } | 1716 } |
| 1717 | 1717 |
| 1718 static bool targetIsFrame(Node* target, Frame*& frame) | 1718 static bool targetIsFrame(Node* target, Frame*& frame) |
| 1719 { | 1719 { |
| 1720 if (!target) | 1720 if (!target) |
| 1721 return false; | 1721 return false; |
| 1722 | 1722 |
| 1723 if (!target->hasTagName(frameTag) && !target->hasTagName(iframeTag)) | 1723 if (!target->hasTagName(frameTag) && !target->hasTagName(iframeTag)) |
| 1724 return false; | 1724 return false; |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2037 } | 2037 } |
| 2038 ASSERT(!element || element->isFocusable()); | 2038 ASSERT(!element || element->isFocusable()); |
| 2039 | 2039 |
| 2040 // To fix <rdar://problem/4895428> Can't drag selected ToDo, we don't focus | 2040 // To fix <rdar://problem/4895428> Can't drag selected ToDo, we don't focus |
| 2041 // a node on mouse down if it's selected and inside a focused node. It will | 2041 // a node on mouse down if it's selected and inside a focused node. It will |
| 2042 // be focused if the user does a mouseup over it, however, because the | 2042 // be focused if the user does a mouseup over it, however, because the |
| 2043 // mouseup will set a selection inside it, which will call | 2043 // mouseup will set a selection inside it, which will call |
| 2044 // FrameSelection::setFocusedNodeIfNeeded. | 2044 // FrameSelection::setFocusedNodeIfNeeded. |
| 2045 if (element | 2045 if (element |
| 2046 && m_frame->selection()->isRange() | 2046 && m_frame->selection()->isRange() |
| 2047 && m_frame->selection()->toNormalizedRange()->compareNode(element, IGNOR
E_EXCEPTION_STATE) == Range::NODE_INSIDE | 2047 && m_frame->selection()->toNormalizedRange()->compareNode(element, IGNOR
E_EXCEPTION) == Range::NODE_INSIDE |
| 2048 && element->isDescendantOf(m_frame->document()->focusedElement())) | 2048 && element->isDescendantOf(m_frame->document()->focusedElement())) |
| 2049 return true; | 2049 return true; |
| 2050 | 2050 |
| 2051 bool elementIsMouseFocusable = element && element->isMouseFocusable(); | 2051 bool elementIsMouseFocusable = element && element->isMouseFocusable(); |
| 2052 | 2052 |
| 2053 // Only change the focus when clicking scrollbars if it can transfered to a | 2053 // Only change the focus when clicking scrollbars if it can transfered to a |
| 2054 // mouse focusable node. | 2054 // mouse focusable node. |
| 2055 if (!elementIsMouseFocusable && isInsideScrollbar(mouseEvent.position())) | 2055 if (!elementIsMouseFocusable && isInsideScrollbar(mouseEvent.position())) |
| 2056 return false; | 2056 return false; |
| 2057 | 2057 |
| (...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3001 | 3001 |
| 3002 PlatformKeyboardEvent keyDownEvent = initialKeyEvent; | 3002 PlatformKeyboardEvent keyDownEvent = initialKeyEvent; |
| 3003 if (keyDownEvent.type() != PlatformEvent::RawKeyDown) | 3003 if (keyDownEvent.type() != PlatformEvent::RawKeyDown) |
| 3004 keyDownEvent.disambiguateKeyDownEvent(PlatformEvent::RawKeyDown); | 3004 keyDownEvent.disambiguateKeyDownEvent(PlatformEvent::RawKeyDown); |
| 3005 RefPtr<KeyboardEvent> keydown = KeyboardEvent::create(keyDownEvent, m_frame-
>document()->defaultView()); | 3005 RefPtr<KeyboardEvent> keydown = KeyboardEvent::create(keyDownEvent, m_frame-
>document()->defaultView()); |
| 3006 if (matchedAnAccessKey) | 3006 if (matchedAnAccessKey) |
| 3007 keydown->setDefaultPrevented(true); | 3007 keydown->setDefaultPrevented(true); |
| 3008 keydown->setTarget(node); | 3008 keydown->setTarget(node); |
| 3009 | 3009 |
| 3010 if (initialKeyEvent.type() == PlatformEvent::RawKeyDown) { | 3010 if (initialKeyEvent.type() == PlatformEvent::RawKeyDown) { |
| 3011 node->dispatchEvent(keydown, IGNORE_EXCEPTION_STATE); | 3011 node->dispatchEvent(keydown, IGNORE_EXCEPTION); |
| 3012 // If frame changed as a result of keydown dispatch, then return true to
avoid sending a subsequent keypress message to the new frame. | 3012 // If frame changed as a result of keydown dispatch, then return true to
avoid sending a subsequent keypress message to the new frame. |
| 3013 bool changedFocusedFrame = m_frame->page() && m_frame != m_frame->page()
->focusController()->focusedOrMainFrame(); | 3013 bool changedFocusedFrame = m_frame->page() && m_frame != m_frame->page()
->focusController()->focusedOrMainFrame(); |
| 3014 return keydown->defaultHandled() || keydown->defaultPrevented() || chang
edFocusedFrame; | 3014 return keydown->defaultHandled() || keydown->defaultPrevented() || chang
edFocusedFrame; |
| 3015 } | 3015 } |
| 3016 | 3016 |
| 3017 node->dispatchEvent(keydown, IGNORE_EXCEPTION_STATE); | 3017 node->dispatchEvent(keydown, IGNORE_EXCEPTION); |
| 3018 // If frame changed as a result of keydown dispatch, then return early to av
oid sending a subsequent keypress message to the new frame. | 3018 // If frame changed as a result of keydown dispatch, then return early to av
oid sending a subsequent keypress message to the new frame. |
| 3019 bool changedFocusedFrame = m_frame->page() && m_frame != m_frame->page()->fo
cusController()->focusedOrMainFrame(); | 3019 bool changedFocusedFrame = m_frame->page() && m_frame != m_frame->page()->fo
cusController()->focusedOrMainFrame(); |
| 3020 bool keydownResult = keydown->defaultHandled() || keydown->defaultPrevented(
) || changedFocusedFrame; | 3020 bool keydownResult = keydown->defaultHandled() || keydown->defaultPrevented(
) || changedFocusedFrame; |
| 3021 if (keydownResult) | 3021 if (keydownResult) |
| 3022 return keydownResult; | 3022 return keydownResult; |
| 3023 | 3023 |
| 3024 // Focus may have changed during keydown handling, so refetch node. | 3024 // Focus may have changed during keydown handling, so refetch node. |
| 3025 // But if we are dispatching a fake backward compatibility keypress, then we
pretend that the keypress happened on the original node. | 3025 // But if we are dispatching a fake backward compatibility keypress, then we
pretend that the keypress happened on the original node. |
| 3026 node = eventTargetNodeForDocument(m_frame->document()); | 3026 node = eventTargetNodeForDocument(m_frame->document()); |
| 3027 if (!node) | 3027 if (!node) |
| 3028 return false; | 3028 return false; |
| 3029 | 3029 |
| 3030 PlatformKeyboardEvent keyPressEvent = initialKeyEvent; | 3030 PlatformKeyboardEvent keyPressEvent = initialKeyEvent; |
| 3031 keyPressEvent.disambiguateKeyDownEvent(PlatformEvent::Char); | 3031 keyPressEvent.disambiguateKeyDownEvent(PlatformEvent::Char); |
| 3032 if (keyPressEvent.text().isEmpty()) | 3032 if (keyPressEvent.text().isEmpty()) |
| 3033 return keydownResult; | 3033 return keydownResult; |
| 3034 RefPtr<KeyboardEvent> keypress = KeyboardEvent::create(keyPressEvent, m_fram
e->document()->defaultView()); | 3034 RefPtr<KeyboardEvent> keypress = KeyboardEvent::create(keyPressEvent, m_fram
e->document()->defaultView()); |
| 3035 keypress->setTarget(node); | 3035 keypress->setTarget(node); |
| 3036 if (keydownResult) | 3036 if (keydownResult) |
| 3037 keypress->setDefaultPrevented(true); | 3037 keypress->setDefaultPrevented(true); |
| 3038 node->dispatchEvent(keypress, IGNORE_EXCEPTION_STATE); | 3038 node->dispatchEvent(keypress, IGNORE_EXCEPTION); |
| 3039 | 3039 |
| 3040 return keydownResult || keypress->defaultPrevented() || keypress->defaultHan
dled(); | 3040 return keydownResult || keypress->defaultPrevented() || keypress->defaultHan
dled(); |
| 3041 } | 3041 } |
| 3042 | 3042 |
| 3043 static FocusDirection focusDirectionForKey(const AtomicString& keyIdentifier) | 3043 static FocusDirection focusDirectionForKey(const AtomicString& keyIdentifier) |
| 3044 { | 3044 { |
| 3045 DEFINE_STATIC_LOCAL(AtomicString, Down, ("Down", AtomicString::ConstructFrom
Literal)); | 3045 DEFINE_STATIC_LOCAL(AtomicString, Down, ("Down", AtomicString::ConstructFrom
Literal)); |
| 3046 DEFINE_STATIC_LOCAL(AtomicString, Up, ("Up", AtomicString::ConstructFromLite
ral)); | 3046 DEFINE_STATIC_LOCAL(AtomicString, Up, ("Up", AtomicString::ConstructFromLite
ral)); |
| 3047 DEFINE_STATIC_LOCAL(AtomicString, Left, ("Left", AtomicString::ConstructFrom
Literal)); | 3047 DEFINE_STATIC_LOCAL(AtomicString, Left, ("Left", AtomicString::ConstructFrom
Literal)); |
| 3048 DEFINE_STATIC_LOCAL(AtomicString, Right, ("Right", AtomicString::ConstructFr
omLiteral)); | 3048 DEFINE_STATIC_LOCAL(AtomicString, Right, ("Right", AtomicString::ConstructFr
omLiteral)); |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3322 target = eventTargetNodeForDocument(m_frame->document()); | 3322 target = eventTargetNodeForDocument(m_frame->document()); |
| 3323 if (!target) | 3323 if (!target) |
| 3324 return false; | 3324 return false; |
| 3325 | 3325 |
| 3326 if (FrameView* view = m_frame->view()) | 3326 if (FrameView* view = m_frame->view()) |
| 3327 view->resetDeferredRepaintDelay(); | 3327 view->resetDeferredRepaintDelay(); |
| 3328 | 3328 |
| 3329 RefPtr<TextEvent> event = TextEvent::create(m_frame->domWindow(), text, inpu
tType); | 3329 RefPtr<TextEvent> event = TextEvent::create(m_frame->domWindow(), text, inpu
tType); |
| 3330 event->setUnderlyingEvent(underlyingEvent); | 3330 event->setUnderlyingEvent(underlyingEvent); |
| 3331 | 3331 |
| 3332 target->dispatchEvent(event, IGNORE_EXCEPTION_STATE); | 3332 target->dispatchEvent(event, IGNORE_EXCEPTION); |
| 3333 return event->defaultHandled(); | 3333 return event->defaultHandled(); |
| 3334 } | 3334 } |
| 3335 | 3335 |
| 3336 bool EventHandler::isKeyboardOptionTab(KeyboardEvent* event) | 3336 bool EventHandler::isKeyboardOptionTab(KeyboardEvent* event) |
| 3337 { | 3337 { |
| 3338 return event | 3338 return event |
| 3339 && (event->type() == eventNames().keydownEvent || event->type() == event
Names().keypressEvent) | 3339 && (event->type() == eventNames().keydownEvent || event->type() == event
Names().keypressEvent) |
| 3340 && event->altKey() | 3340 && event->altKey() |
| 3341 && event->keyIdentifier() == "U+0009"; | 3341 && event->keyIdentifier() == "U+0009"; |
| 3342 } | 3342 } |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3839 unsigned EventHandler::accessKeyModifiers() | 3839 unsigned EventHandler::accessKeyModifiers() |
| 3840 { | 3840 { |
| 3841 #if OS(DARWIN) | 3841 #if OS(DARWIN) |
| 3842 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 3842 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
| 3843 #else | 3843 #else |
| 3844 return PlatformEvent::AltKey; | 3844 return PlatformEvent::AltKey; |
| 3845 #endif | 3845 #endif |
| 3846 } | 3846 } |
| 3847 | 3847 |
| 3848 } // namespace WebCore | 3848 } // namespace WebCore |
| OLD | NEW |