Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: Source/core/page/EventHandler.cpp

Issue 27183013: Use [ImplementedAs=domWindow] for Document.defaultView() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/events/EventDispatcher.cpp ('k') | Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1723 matching lines...) Expand 10 before | Expand all | Expand 10 after
1734 bool EventHandler::dispatchDragEvent(const AtomicString& eventType, Node* dragTa rget, const PlatformMouseEvent& event, Clipboard* clipboard) 1734 bool EventHandler::dispatchDragEvent(const AtomicString& eventType, Node* dragTa rget, const PlatformMouseEvent& event, Clipboard* clipboard)
1735 { 1735 {
1736 FrameView* view = m_frame->view(); 1736 FrameView* view = m_frame->view();
1737 1737
1738 // FIXME: We might want to dispatch a dragleave even if the view is gone. 1738 // FIXME: We might want to dispatch a dragleave even if the view is gone.
1739 if (!view) 1739 if (!view)
1740 return false; 1740 return false;
1741 1741
1742 view->resetDeferredRepaintDelay(); 1742 view->resetDeferredRepaintDelay();
1743 RefPtr<MouseEvent> me = MouseEvent::create(eventType, 1743 RefPtr<MouseEvent> me = MouseEvent::create(eventType,
1744 true, true, m_frame->document()->defaultView(), 1744 true, true, m_frame->document()->domWindow(),
1745 0, event.globalPosition().x(), event.globalPosition().y(), event.positio n().x(), event.position().y(), 1745 0, event.globalPosition().x(), event.globalPosition().y(), event.positio n().x(), event.position().y(),
1746 event.movementDelta().x(), event.movementDelta().y(), 1746 event.movementDelta().x(), event.movementDelta().y(),
1747 event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(), 1747 event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(),
1748 0, 0, clipboard); 1748 0, 0, clipboard);
1749 1749
1750 dragTarget->dispatchEvent(me.get(), IGNORE_EXCEPTION); 1750 dragTarget->dispatchEvent(me.get(), IGNORE_EXCEPTION);
1751 return me->defaultPrevented(); 1751 return me->defaultPrevented();
1752 } 1752 }
1753 1753
1754 static bool targetIsFrame(Node* target, Frame*& frame) 1754 static bool targetIsFrame(Node* target, Frame*& frame)
(...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after
3033 if (initialKeyEvent.type() == PlatformEvent::KeyDown) 3033 if (initialKeyEvent.type() == PlatformEvent::KeyDown)
3034 matchedAnAccessKey = handleAccessKey(initialKeyEvent); 3034 matchedAnAccessKey = handleAccessKey(initialKeyEvent);
3035 3035
3036 // FIXME: it would be fair to let an input method handle KeyUp events before DOM dispatch. 3036 // FIXME: it would be fair to let an input method handle KeyUp events before DOM dispatch.
3037 if (initialKeyEvent.type() == PlatformEvent::KeyUp || initialKeyEvent.type() == PlatformEvent::Char) 3037 if (initialKeyEvent.type() == PlatformEvent::KeyUp || initialKeyEvent.type() == PlatformEvent::Char)
3038 return !node->dispatchKeyEvent(initialKeyEvent); 3038 return !node->dispatchKeyEvent(initialKeyEvent);
3039 3039
3040 PlatformKeyboardEvent keyDownEvent = initialKeyEvent; 3040 PlatformKeyboardEvent keyDownEvent = initialKeyEvent;
3041 if (keyDownEvent.type() != PlatformEvent::RawKeyDown) 3041 if (keyDownEvent.type() != PlatformEvent::RawKeyDown)
3042 keyDownEvent.disambiguateKeyDownEvent(PlatformEvent::RawKeyDown); 3042 keyDownEvent.disambiguateKeyDownEvent(PlatformEvent::RawKeyDown);
3043 RefPtr<KeyboardEvent> keydown = KeyboardEvent::create(keyDownEvent, m_frame- >document()->defaultView()); 3043 RefPtr<KeyboardEvent> keydown = KeyboardEvent::create(keyDownEvent, m_frame- >document()->domWindow());
3044 if (matchedAnAccessKey) 3044 if (matchedAnAccessKey)
3045 keydown->setDefaultPrevented(true); 3045 keydown->setDefaultPrevented(true);
3046 keydown->setTarget(node); 3046 keydown->setTarget(node);
3047 3047
3048 if (initialKeyEvent.type() == PlatformEvent::RawKeyDown) { 3048 if (initialKeyEvent.type() == PlatformEvent::RawKeyDown) {
3049 node->dispatchEvent(keydown, IGNORE_EXCEPTION); 3049 node->dispatchEvent(keydown, IGNORE_EXCEPTION);
3050 // If frame changed as a result of keydown dispatch, then return true to avoid sending a subsequent keypress message to the new frame. 3050 // If frame changed as a result of keydown dispatch, then return true to avoid sending a subsequent keypress message to the new frame.
3051 bool changedFocusedFrame = m_frame->page() && m_frame != m_frame->page() ->focusController().focusedOrMainFrame(); 3051 bool changedFocusedFrame = m_frame->page() && m_frame != m_frame->page() ->focusController().focusedOrMainFrame();
3052 return keydown->defaultHandled() || keydown->defaultPrevented() || chang edFocusedFrame; 3052 return keydown->defaultHandled() || keydown->defaultPrevented() || chang edFocusedFrame;
3053 } 3053 }
3054 3054
3055 node->dispatchEvent(keydown, IGNORE_EXCEPTION); 3055 node->dispatchEvent(keydown, IGNORE_EXCEPTION);
3056 // If frame changed as a result of keydown dispatch, then return early to av oid sending a subsequent keypress message to the new frame. 3056 // If frame changed as a result of keydown dispatch, then return early to av oid sending a subsequent keypress message to the new frame.
3057 bool changedFocusedFrame = m_frame->page() && m_frame != m_frame->page()->fo cusController().focusedOrMainFrame(); 3057 bool changedFocusedFrame = m_frame->page() && m_frame != m_frame->page()->fo cusController().focusedOrMainFrame();
3058 bool keydownResult = keydown->defaultHandled() || keydown->defaultPrevented( ) || changedFocusedFrame; 3058 bool keydownResult = keydown->defaultHandled() || keydown->defaultPrevented( ) || changedFocusedFrame;
3059 if (keydownResult) 3059 if (keydownResult)
3060 return keydownResult; 3060 return keydownResult;
3061 3061
3062 // Focus may have changed during keydown handling, so refetch node. 3062 // Focus may have changed during keydown handling, so refetch node.
3063 // But if we are dispatching a fake backward compatibility keypress, then we pretend that the keypress happened on the original node. 3063 // But if we are dispatching a fake backward compatibility keypress, then we pretend that the keypress happened on the original node.
3064 node = eventTargetNodeForDocument(m_frame->document()); 3064 node = eventTargetNodeForDocument(m_frame->document());
3065 if (!node) 3065 if (!node)
3066 return false; 3066 return false;
3067 3067
3068 PlatformKeyboardEvent keyPressEvent = initialKeyEvent; 3068 PlatformKeyboardEvent keyPressEvent = initialKeyEvent;
3069 keyPressEvent.disambiguateKeyDownEvent(PlatformEvent::Char); 3069 keyPressEvent.disambiguateKeyDownEvent(PlatformEvent::Char);
3070 if (keyPressEvent.text().isEmpty()) 3070 if (keyPressEvent.text().isEmpty())
3071 return keydownResult; 3071 return keydownResult;
3072 RefPtr<KeyboardEvent> keypress = KeyboardEvent::create(keyPressEvent, m_fram e->document()->defaultView()); 3072 RefPtr<KeyboardEvent> keypress = KeyboardEvent::create(keyPressEvent, m_fram e->document()->domWindow());
3073 keypress->setTarget(node); 3073 keypress->setTarget(node);
3074 if (keydownResult) 3074 if (keydownResult)
3075 keypress->setDefaultPrevented(true); 3075 keypress->setDefaultPrevented(true);
3076 node->dispatchEvent(keypress, IGNORE_EXCEPTION); 3076 node->dispatchEvent(keypress, IGNORE_EXCEPTION);
3077 3077
3078 return keydownResult || keypress->defaultPrevented() || keypress->defaultHan dled(); 3078 return keydownResult || keypress->defaultPrevented() || keypress->defaultHan dled();
3079 } 3079 }
3080 3080
3081 static FocusDirection focusDirectionForKey(const AtomicString& keyIdentifier) 3081 static FocusDirection focusDirectionForKey(const AtomicString& keyIdentifier)
3082 { 3082 {
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
3746 const AtomicString& stateName(eventNameForTouchPointState(static_cast<Pl atformTouchPoint::State>(state))); 3746 const AtomicString& stateName(eventNameForTouchPointState(static_cast<Pl atformTouchPoint::State>(state)));
3747 const EventTargetSet& targetsForState = changedTouches[state].m_targets; 3747 const EventTargetSet& targetsForState = changedTouches[state].m_targets;
3748 3748
3749 for (EventTargetSet::const_iterator it = targetsForState.begin(); it != targetsForState.end(); ++it) { 3749 for (EventTargetSet::const_iterator it = targetsForState.begin(); it != targetsForState.end(); ++it) {
3750 EventTarget* touchEventTarget = it->get(); 3750 EventTarget* touchEventTarget = it->get();
3751 RefPtr<TouchList> targetTouches(isTouchCancelEvent ? emptyList : tou chesByTarget.get(touchEventTarget)); 3751 RefPtr<TouchList> targetTouches(isTouchCancelEvent ? emptyList : tou chesByTarget.get(touchEventTarget));
3752 ASSERT(targetTouches); 3752 ASSERT(targetTouches);
3753 3753
3754 RefPtr<TouchEvent> touchEvent = 3754 RefPtr<TouchEvent> touchEvent =
3755 TouchEvent::create(effectiveTouches.get(), targetTouches.get(), changedTouches[state].m_touches.get(), 3755 TouchEvent::create(effectiveTouches.get(), targetTouches.get(), changedTouches[state].m_touches.get(),
3756 stateName, touchEventTarget->toNode()->docume nt().defaultView(), 3756 stateName, touchEventTarget->toNode()->document().domWindow( ),
3757 0, 0, 0, 0, event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey()); 3757 0, 0, 0, 0, event.ctrlKey(), event.altKey(), event.shiftKey( ), event.metaKey());
3758 touchEventTarget->toNode()->dispatchTouchEvent(touchEvent.get()); 3758 touchEventTarget->toNode()->dispatchTouchEvent(touchEvent.get());
3759 swallowedEvent = swallowedEvent || touchEvent->defaultPrevented() || touchEvent->defaultHandled(); 3759 swallowedEvent = swallowedEvent || touchEvent->defaultPrevented() || touchEvent->defaultHandled();
3760 } 3760 }
3761 } 3761 }
3762 3762
3763 return swallowedEvent; 3763 return swallowedEvent;
3764 } 3764 }
3765 3765
3766 bool EventHandler::dispatchSyntheticTouchEventIfEnabled(const PlatformMouseEvent & event) 3766 bool EventHandler::dispatchSyntheticTouchEventIfEnabled(const PlatformMouseEvent & event)
3767 { 3767 {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
3863 unsigned EventHandler::accessKeyModifiers() 3863 unsigned EventHandler::accessKeyModifiers()
3864 { 3864 {
3865 #if OS(MACOSX) 3865 #if OS(MACOSX)
3866 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 3866 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
3867 #else 3867 #else
3868 return PlatformEvent::AltKey; 3868 return PlatformEvent::AltKey;
3869 #endif 3869 #endif
3870 } 3870 }
3871 3871
3872 } // namespace WebCore 3872 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/events/EventDispatcher.cpp ('k') | Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698