diff options
Diffstat (limited to 'WebCore/page/mac/EventHandlerMac.mm')
-rw-r--r-- | WebCore/page/mac/EventHandlerMac.mm | 226 |
1 files changed, 142 insertions, 84 deletions
diff --git a/WebCore/page/mac/EventHandlerMac.mm b/WebCore/page/mac/EventHandlerMac.mm index 7da1d36..92895d9 100644 --- a/WebCore/page/mac/EventHandlerMac.mm +++ b/WebCore/page/mac/EventHandlerMac.mm @@ -64,6 +64,8 @@ namespace WebCore { const double EventHandler::TextDragDelay = 0.15; #endif +#if !ENABLE(EXPERIMENTAL_SINGLE_VIEW_MODE) + static RetainPtr<NSEvent>& currentNSEventSlot() { DEFINE_STATIC_LOCAL(RetainPtr<NSEvent>, event, ()); @@ -136,65 +138,6 @@ PassRefPtr<KeyboardEvent> EventHandler::currentKeyboardEvent() const } } -static inline bool isKeyboardOptionTab(KeyboardEvent* event) -{ - return event - && (event->type() == eventNames().keydownEvent || event->type() == eventNames().keypressEvent) - && event->altKey() - && event->keyIdentifier() == "U+0009"; -} - -bool EventHandler::invertSenseOfTabsToLinks(KeyboardEvent* event) const -{ - return isKeyboardOptionTab(event); -} - -bool EventHandler::tabsToAllControls(KeyboardEvent* event) const -{ - Page* page = m_frame->page(); - if (!page) - return false; - - KeyboardUIMode keyboardUIMode = page->chrome()->client()->keyboardUIMode(); - bool handlingOptionTab = isKeyboardOptionTab(event); - - // If tab-to-links is off, option-tab always highlights all controls - if ((keyboardUIMode & KeyboardAccessTabsToLinks) == 0 && handlingOptionTab) - return true; - - // If system preferences say to include all controls, we always include all controls - if (keyboardUIMode & KeyboardAccessFull) - return true; - - // Otherwise tab-to-links includes all controls, unless the sense is flipped via option-tab. - if (keyboardUIMode & KeyboardAccessTabsToLinks) - return !handlingOptionTab; - - return handlingOptionTab; -} - -bool EventHandler::needsKeyboardEventDisambiguationQuirks() const -{ - Document* document = m_frame->document(); - - // RSS view needs arrow key keypress events. - if (applicationIsSafari() && document->url().protocolIs("feed") || document->url().protocolIs("feeds")) - return true; - Settings* settings = m_frame->settings(); - if (!settings) - return false; - -#if ENABLE(DASHBOARD_SUPPORT) - if (settings->usesDashboardBackwardCompatibilityMode()) - return true; -#endif - - if (settings->needsKeyboardEventDisambiguationQuirks()) - return true; - - return false; -} - bool EventHandler::keyEvent(NSEvent *event) { BEGIN_BLOCK_OBJC_EXCEPTIONS; @@ -369,11 +312,6 @@ NSView *EventHandler::mouseDownViewIfStillGood() return mouseDownView; } -bool EventHandler::eventActivatedView(const PlatformMouseEvent& event) const -{ - return m_activationEventNumber == event.eventNumber(); -} - #if ENABLE(DRAG_SUPPORT) bool EventHandler::eventLoopHandleMouseDragged(const MouseEventWithHitTestResults&) { @@ -393,15 +331,6 @@ bool EventHandler::eventLoopHandleMouseDragged(const MouseEventWithHitTestResult return true; } - -PassRefPtr<Clipboard> EventHandler::createDraggingClipboard() const -{ - NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard]; - // Must be done before ondragstart adds types and data to the pboard, - // also done for security, as it erases data from the last drag - [pasteboard declareTypes:[NSArray array] owner:nil]; - return ClipboardMac::create(true, pasteboard, ClipboardWritable, m_frame); -} #endif // ENABLE(DRAG_SUPPORT) bool EventHandler::eventLoopHandleMouseUp(const MouseEventWithHitTestResults&) @@ -697,17 +626,6 @@ bool EventHandler::passMouseReleaseEventToSubframe(MouseEventWithHitTestResults& return passSubframeEventToSubframe(mev, subframe); } -unsigned EventHandler::accessKeyModifiers() -{ - // Control+Option key combinations are usually unused on Mac OS X, but not when VoiceOver is enabled. - // So, we use Control in this case, even though it conflicts with Emacs-style key bindings. - // See <https://bugs.webkit.org/show_bug.cgi?id=21107> for more detail. - if (AXObjectCache::accessibilityEnhancedUserInterfaceEnabled()) - return PlatformKeyboardEvent::CtrlKey; - - return PlatformKeyboardEvent::CtrlKey | PlatformKeyboardEvent::AltKey; -} - PlatformMouseEvent EventHandler::currentPlatformMouseEvent() const { NSView *windowView = nil; @@ -736,4 +654,144 @@ bool EventHandler::eventMayStartDrag(NSEvent *event) } #endif // ENABLE(DRAG_SUPPORT) +bool EventHandler::eventActivatedView(const PlatformMouseEvent& event) const +{ + return m_activationEventNumber == event.eventNumber(); +} + +#else // ENABLE(EXPERIMENTAL_SINGLE_VIEW_MODE) + +bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe) +{ + subframe->eventHandler()->handleMousePressEvent(mev.event()); + return true; +} + +bool EventHandler::passMouseMoveEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe, HitTestResult* hoveredNode) +{ + if (m_mouseDownMayStartDrag && !m_mouseDownWasInSubframe) + return false; + subframe->eventHandler()->handleMouseMoveEvent(mev.event(), hoveredNode); + return true; +} + +bool EventHandler::passMouseReleaseEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe) +{ + subframe->eventHandler()->handleMouseReleaseEvent(mev.event()); + return true; +} + +bool EventHandler::passWheelEventToWidget(PlatformWheelEvent& wheelEvent, Widget* widget) +{ + if (!widget->isFrameView()) + return false; + + return static_cast<FrameView*>(widget)->frame()->eventHandler()->handleWheelEvent(wheelEvent); +} + +void EventHandler::focusDocumentView() +{ + Page* page = m_frame->page(); + if (!page) + return; + page->focusController()->setFocusedFrame(m_frame); +} + +bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults&) +{ + notImplemented(); + return false; +} + +bool EventHandler::eventActivatedView(const PlatformMouseEvent& event) const +{ + notImplemented(); + return false; +} + +#endif + +#if ENABLE(DRAG_SUPPORT) + +PassRefPtr<Clipboard> EventHandler::createDraggingClipboard() const +{ + NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard]; + // Must be done before ondragstart adds types and data to the pboard, + // also done for security, as it erases data from the last drag + [pasteboard declareTypes:[NSArray array] owner:nil]; + return ClipboardMac::create(true, pasteboard, ClipboardWritable, m_frame); +} + +#endif + +static inline bool isKeyboardOptionTab(KeyboardEvent* event) +{ + return event + && (event->type() == eventNames().keydownEvent || event->type() == eventNames().keypressEvent) + && event->altKey() + && event->keyIdentifier() == "U+0009"; +} + +bool EventHandler::invertSenseOfTabsToLinks(KeyboardEvent* event) const +{ + return isKeyboardOptionTab(event); +} + +bool EventHandler::tabsToAllControls(KeyboardEvent* event) const +{ + Page* page = m_frame->page(); + if (!page) + return false; + + KeyboardUIMode keyboardUIMode = page->chrome()->client()->keyboardUIMode(); + bool handlingOptionTab = isKeyboardOptionTab(event); + + // If tab-to-links is off, option-tab always highlights all controls + if ((keyboardUIMode & KeyboardAccessTabsToLinks) == 0 && handlingOptionTab) + return true; + + // If system preferences say to include all controls, we always include all controls + if (keyboardUIMode & KeyboardAccessFull) + return true; + + // Otherwise tab-to-links includes all controls, unless the sense is flipped via option-tab. + if (keyboardUIMode & KeyboardAccessTabsToLinks) + return !handlingOptionTab; + + return handlingOptionTab; +} + +bool EventHandler::needsKeyboardEventDisambiguationQuirks() const +{ + Document* document = m_frame->document(); + + // RSS view needs arrow key keypress events. + if (applicationIsSafari() && document->url().protocolIs("feed") || document->url().protocolIs("feeds")) + return true; + Settings* settings = m_frame->settings(); + if (!settings) + return false; + +#if ENABLE(DASHBOARD_SUPPORT) + if (settings->usesDashboardBackwardCompatibilityMode()) + return true; +#endif + + if (settings->needsKeyboardEventDisambiguationQuirks()) + return true; + + return false; +} + +unsigned EventHandler::accessKeyModifiers() +{ + // Control+Option key combinations are usually unused on Mac OS X, but not when VoiceOver is enabled. + // So, we use Control in this case, even though it conflicts with Emacs-style key bindings. + // See <https://bugs.webkit.org/show_bug.cgi?id=21107> for more detail. + if (AXObjectCache::accessibilityEnhancedUserInterfaceEnabled()) + return PlatformKeyboardEvent::CtrlKey; + + return PlatformKeyboardEvent::CtrlKey | PlatformKeyboardEvent::AltKey; +} + } |