Changeset 87951 in webkit
- Timestamp:
- Jun 2, 2011 2:29:46 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r87949 r87951 1 2011-06-02 Ryosuke Niwa <rniwa@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 Make more functions static local in EventHandlers.cpp 6 https://bugs.webkit.org/show_bug.cgi?id=58503 7 8 Removed canHandleDragAndDropForTarget and made focusDirectionForKey local to EventHandler.cpp. 9 10 * page/EventHandler.cpp: 11 (WebCore::targetIsFrame): Extracted from canHandleDragAndDropForTarget. 12 (WebCore::EventHandler::updateDragAndDrop): Calls contentFrameForTarget instead of canHandleDragAndDropForTarget. 13 (WebCore::EventHandler::cancelDragAndDrop): Ditto. 14 (WebCore::EventHandler::performDragAndDrop): Ditto. 15 (WebCore::focusDirectionForKey): No longer a member function of EventHandler class. 16 (WebCore::handleKeyboardSelectionMovement): No longer a member function of EventHandler class; also calls 17 focusDirectionForKey instead of manually comparing. 18 * page/EventHandler.h: 19 1 20 2011-06-02 Alok Priyadarshi <alokp@chromium.org> 2 21 -
trunk/Source/WebCore/page/EventHandler.cpp
r87499 r87951 1761 1761 } 1762 1762 1763 bool EventHandler::canHandleDragAndDropForTarget(DragAndDropHandleType type, Node* target, const PlatformMouseEvent& event, Clipboard* clipboard, bool* accepted) 1764 { 1765 bool canHandle = false; 1766 bool wasAccepted = false; 1767 1768 if (target->hasTagName(frameTag) || target->hasTagName(iframeTag)) { 1769 Frame* frame = static_cast<HTMLFrameElementBase*>(target)->contentFrame(); 1770 if (frame) { 1771 switch (type) { 1772 case UpdateDragAndDrop: 1773 wasAccepted = frame->eventHandler()->updateDragAndDrop(event, clipboard); 1774 break; 1775 case CancelDragAndDrop: 1776 frame->eventHandler()->cancelDragAndDrop(event, clipboard); 1777 break; 1778 case PerformDragAndDrop: 1779 wasAccepted = frame->eventHandler()->performDragAndDrop(event, clipboard); 1780 break; 1781 } 1782 } 1783 } else 1784 canHandle = true; 1785 1786 if (accepted) 1787 *accepted = wasAccepted; 1788 1789 return canHandle; 1763 static bool targetIsFrame(Node* target, Frame*& frame) 1764 { 1765 if (!target) 1766 return false; 1767 1768 if (!target->hasTagName(frameTag) && !target->hasTagName(iframeTag)) 1769 return false; 1770 1771 frame = static_cast<HTMLFrameElementBase*>(target)->contentFrame(); 1772 1773 return true; 1790 1774 } 1791 1775 … … 1849 1833 // 1850 1834 // Moreover, this ordering conforms to section 7.9.4 of the HTML 5 spec. <http://dev.w3.org/html5/spec/Overview.html#drag-and-drop-processing-model>. 1851 if (newTarget && canHandleDragAndDropForTarget(UpdateDragAndDrop, newTarget, event, clipboard, &accept)) { 1835 Frame* targetFrame; 1836 if (targetIsFrame(newTarget, targetFrame)) { 1837 if (targetFrame) 1838 accept = targetFrame->eventHandler()->updateDragAndDrop(event, clipboard); 1839 } else if (newTarget) { 1852 1840 // As per section 7.9.4 of the HTML 5 spec., we must always fire a drag event before firing a dragenter, dragleave, or dragover event. 1853 1841 if (dragState().m_dragSrc && dragState().shouldDispatchEvents()) { … … 1860 1848 } 1861 1849 1862 if (m_dragTarget && canHandleDragAndDropForTarget(UpdateDragAndDrop, m_dragTarget.get(), event, clipboard, &accept)) 1850 if (targetIsFrame(m_dragTarget.get(), targetFrame)) { 1851 if (targetFrame) 1852 accept = targetFrame->eventHandler()->updateDragAndDrop(event, clipboard); 1853 } else if (m_dragTarget) 1863 1854 dispatchDragEvent(eventNames().dragleaveEvent, m_dragTarget.get(), event, clipboard); 1864 1855 1865 1856 if (newTarget) { 1866 1857 // We do not explicitly call dispatchDragEvent here because it could ultimately result in the appearance that … … 1869 1860 } 1870 1861 } else { 1871 if (newTarget && canHandleDragAndDropForTarget(UpdateDragAndDrop, newTarget, event, clipboard, &accept)) { 1862 Frame* targetFrame; 1863 if (targetIsFrame(newTarget, targetFrame)) { 1864 if (targetFrame) 1865 accept = targetFrame->eventHandler()->updateDragAndDrop(event, clipboard); 1866 } else if (newTarget) { 1872 1867 // Note, when dealing with sub-frames, we may need to fire only a dragover event as a drag event may have been fired earlier. 1873 1868 if (!m_shouldOnlyFireDragOverEvent && dragState().m_dragSrc && dragState().shouldDispatchEvents()) { … … 1888 1883 void EventHandler::cancelDragAndDrop(const PlatformMouseEvent& event, Clipboard* clipboard) 1889 1884 { 1890 if (m_dragTarget && canHandleDragAndDropForTarget(CancelDragAndDrop, m_dragTarget.get(), event, clipboard)) { 1885 Frame* targetFrame; 1886 if (targetIsFrame(m_dragTarget.get(), targetFrame)) { 1887 if (targetFrame) 1888 targetFrame->eventHandler()->cancelDragAndDrop(event, clipboard); 1889 } else if (m_dragTarget.get()) { 1891 1890 if (dragState().m_dragSrc && dragState().shouldDispatchEvents()) 1892 1891 dispatchDragSrcEvent(eventNames().dragEvent, event); … … 1896 1895 } 1897 1896 1898 bool EventHandler::performDragAndDrop(const PlatformMouseEvent& event, Clipboard* clipboard) 1899 { 1900 bool accept = false; 1901 if (m_dragTarget && canHandleDragAndDropForTarget(PerformDragAndDrop, m_dragTarget.get(), event, clipboard, &accept)) 1897 void EventHandler::performDragAndDrop(const PlatformMouseEvent& event, Clipboard* clipboard) 1898 { 1899 Frame* targetFrame; 1900 if (targetIsFrame(m_dragTarget.get(), targetFrame)) { 1901 if (targetFrame) 1902 targetFrame->eventHandler()->performDragAndDrop(event, clipboard); 1903 } else if (m_dragTarget.get()) 1902 1904 dispatchDragEvent(eventNames().dropEvent, m_dragTarget.get(), event, clipboard); 1903 1905 clearDragState(); 1904 return accept;1905 1906 } 1906 1907 … … 2589 2590 } 2590 2591 2591 void EventHandler::handleKeyboardSelectionMovement(KeyboardEvent* event) 2592 static FocusDirection focusDirectionForKey(const AtomicString& keyIdentifier) 2593 { 2594 DEFINE_STATIC_LOCAL(AtomicString, Down, ("Down")); 2595 DEFINE_STATIC_LOCAL(AtomicString, Up, ("Up")); 2596 DEFINE_STATIC_LOCAL(AtomicString, Left, ("Left")); 2597 DEFINE_STATIC_LOCAL(AtomicString, Right, ("Right")); 2598 2599 FocusDirection retVal = FocusDirectionNone; 2600 2601 if (keyIdentifier == Down) 2602 retVal = FocusDirectionDown; 2603 else if (keyIdentifier == Up) 2604 retVal = FocusDirectionUp; 2605 else if (keyIdentifier == Left) 2606 retVal = FocusDirectionLeft; 2607 else if (keyIdentifier == Right) 2608 retVal = FocusDirectionRight; 2609 2610 return retVal; 2611 } 2612 2613 static void handleKeyboardSelectionMovement(FrameSelection* selection, KeyboardEvent* event) 2592 2614 { 2593 2615 if (!event) 2594 2616 return; 2595 2596 const String& key = event->keyIdentifier(); 2597 bool isShifted = event->getModifierState("Shift"); 2617 2598 2618 bool isOptioned = event->getModifierState("Alt"); 2599 2619 bool isCommanded = event->getModifierState("Meta"); 2600 2601 if (key == "Up") { 2602 m_frame->selection()->modify((isShifted) ? FrameSelection::AlterationExtend : FrameSelection::AlterationMove, DirectionBackward, (isCommanded) ? DocumentBoundary : LineGranularity, true); 2603 event->setDefaultHandled(); 2604 } else if (key == "Down") { 2605 m_frame->selection()->modify((isShifted) ? FrameSelection::AlterationExtend : FrameSelection::AlterationMove, DirectionForward, (isCommanded) ? DocumentBoundary : LineGranularity, true); 2606 event->setDefaultHandled(); 2607 } else if (key == "Left") { 2608 m_frame->selection()->modify((isShifted) ? FrameSelection::AlterationExtend : FrameSelection::AlterationMove, DirectionLeft, (isCommanded) ? LineBoundary : (isOptioned) ? WordGranularity : CharacterGranularity, true); 2609 event->setDefaultHandled(); 2610 } else if (key == "Right") { 2611 m_frame->selection()->modify((isShifted) ? FrameSelection::AlterationExtend : FrameSelection::AlterationMove, DirectionRight, (isCommanded) ? LineBoundary : (isOptioned) ? WordGranularity : CharacterGranularity, true); 2612 event->setDefaultHandled(); 2613 } 2620 2621 SelectionDirection direction = DirectionForward; 2622 TextGranularity granularity = CharacterGranularity; 2623 2624 switch (focusDirectionForKey(event->keyIdentifier())) { 2625 case FocusDirectionNone: 2626 return; 2627 case FocusDirectionForward: 2628 case FocusDirectionBackward: 2629 ASSERT_NOT_REACHED(); 2630 return; 2631 case FocusDirectionUp: 2632 direction = DirectionBackward; 2633 granularity = isCommanded ? DocumentBoundary : LineGranularity; 2634 break; 2635 case FocusDirectionDown: 2636 direction = DirectionForward; 2637 granularity = isCommanded ? DocumentBoundary : LineGranularity; 2638 break; 2639 case FocusDirectionLeft: 2640 direction = DirectionLeft; 2641 granularity = (isCommanded) ? LineBoundary : (isOptioned) ? WordGranularity : CharacterGranularity; 2642 break; 2643 case FocusDirectionRight: 2644 direction = DirectionRight; 2645 granularity = (isCommanded) ? LineBoundary : (isOptioned) ? WordGranularity : CharacterGranularity; 2646 break; 2647 } 2648 2649 FrameSelection::EAlteration alternation = event->getModifierState("Shift") ? FrameSelection::AlterationExtend : FrameSelection::AlterationMove; 2650 selection->modify(alternation, direction, granularity, true); 2651 event->setDefaultHandled(); 2614 2652 } 2615 2653 … … 2632 2670 // provides KB navigation and selection for enhanced accessibility users 2633 2671 if (AXObjectCache::accessibilityEnhancedUserInterfaceEnabled()) 2634 handleKeyboardSelectionMovement( event);2672 handleKeyboardSelectionMovement(m_frame->selection(), event); 2635 2673 } 2636 2674 if (event->type() == eventNames().keypressEvent) { … … 2641 2679 defaultSpaceEventHandler(event); 2642 2680 } 2643 }2644 2645 FocusDirection EventHandler::focusDirectionForKey(const AtomicString& keyIdentifier) const2646 {2647 DEFINE_STATIC_LOCAL(AtomicString, Down, ("Down"));2648 DEFINE_STATIC_LOCAL(AtomicString, Up, ("Up"));2649 DEFINE_STATIC_LOCAL(AtomicString, Left, ("Left"));2650 DEFINE_STATIC_LOCAL(AtomicString, Right, ("Right"));2651 2652 FocusDirection retVal = FocusDirectionNone;2653 2654 if (keyIdentifier == Down)2655 retVal = FocusDirectionDown;2656 else if (keyIdentifier == Up)2657 retVal = FocusDirectionUp;2658 else if (keyIdentifier == Left)2659 retVal = FocusDirectionLeft;2660 else if (keyIdentifier == Right)2661 retVal = FocusDirectionRight;2662 2663 return retVal;2664 2681 } 2665 2682 -
trunk/Source/WebCore/page/EventHandler.h
r87096 r87951 132 132 bool updateDragAndDrop(const PlatformMouseEvent&, Clipboard*); 133 133 void cancelDragAndDrop(const PlatformMouseEvent&, Clipboard*); 134 boolperformDragAndDrop(const PlatformMouseEvent&, Clipboard*);134 void performDragAndDrop(const PlatformMouseEvent&, Clipboard*); 135 135 #endif 136 136 … … 218 218 private: 219 219 #if ENABLE(DRAG_SUPPORT) 220 enum DragAndDropHandleType {221 UpdateDragAndDrop,222 CancelDragAndDrop,223 PerformDragAndDrop224 };225 226 220 static DragState& dragState(); 227 221 static const double TextDragDelay; 228 229 bool canHandleDragAndDropForTarget(DragAndDropHandleType, Node* target, const PlatformMouseEvent&, Clipboard*, bool* accepted = 0);230 222 231 223 PassRefPtr<Clipboard> createDraggingClipboard() const; … … 251 243 bool handleMouseReleaseEvent(const MouseEventWithHitTestResults&); 252 244 253 void handleKeyboardSelectionMovement(KeyboardEvent*);254 255 245 Cursor selectCursor(const MouseEventWithHitTestResults&, Scrollbar*); 256 246 #if ENABLE(PAN_SCROLLING) … … 340 330 void setFrameWasScrolledByUser(); 341 331 342 FocusDirection focusDirectionForKey(const AtomicString&) const;343 344 332 bool capturesDragging() const { return m_capturesDragging; } 345 333
Note: See TracChangeset
for help on using the changeset viewer.