Changeset 156397 in webkit
- Timestamp:
- Sep 25, 2013 8:40:58 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r156394 r156397 1 2013-09-25 Andreas Kling <akling@apple.com> 2 3 Move wheel event dispatch from Node to Element. 4 <https://webkit.org/b/121908> 5 6 Reviewed by Anders Carlsson. 7 8 Wheel events are only ever dispatched on Elements, so move the logic out of Node. 9 10 Had to make RenderBox::scroll() and friends return a stopElement instead of a 11 stopNode (out argument) to make this work, though it was only ever returning 12 Elements there anyway. 13 1 14 2013-09-25 Allan Sandfeld Jensen <allan.jensen@digia.com> 2 15 -
trunk/Source/WebCore/dom/Element.cpp
r156372 r156397 87 87 #include "TextIterator.h" 88 88 #include "VoidCallback.h" 89 #include "WheelEvent.h" 89 90 #include "XMLNSNames.h" 90 91 #include "XMLNames.h" … … 238 239 { 239 240 return isContentEditable(UserSelectAllIsAlwaysNonEditable); 241 } 242 243 bool Element::dispatchWheelEvent(const PlatformWheelEvent& event) 244 { 245 return EventDispatcher::dispatchEvent(this, WheelEventDispatchMediator::create(event, document().defaultView())); 240 246 } 241 247 … … 584 590 units = -units; 585 591 } 586 Node* stopNode= this;587 toRenderBox(renderer())->scroll(direction, granularity, units, &stop Node);592 Element* stopElement = this; 593 toRenderBox(renderer())->scroll(direction, granularity, units, &stopElement); 588 594 } 589 595 -
trunk/Source/WebCore/dom/Element.h
r156372 r156397 44 44 class IntSize; 45 45 class Locale; 46 class PlatformWheelEvent; 46 47 class PseudoElement; 47 48 class RenderElement; … … 535 536 void setSavedLayerScrollOffset(const IntSize&); 536 537 538 bool dispatchWheelEvent(const PlatformWheelEvent&); 537 539 bool dispatchKeyEvent(const PlatformKeyboardEvent&); 538 540 void dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEventOptions = SendNoEvents, SimulatedClickVisualOptions = ShowPressedLook); -
trunk/Source/WebCore/dom/Node.cpp
r156372 r156397 2152 2152 } 2153 2153 2154 bool Node::dispatchWheelEvent(const PlatformWheelEvent& event)2155 {2156 return EventDispatcher::dispatchEvent(this, WheelEventDispatchMediator::create(event, document().defaultView()));2157 }2158 2159 2154 void Node::dispatchInputEvent() 2160 2155 { -
trunk/Source/WebCore/dom/Node.h
r156372 r156397 73 73 class PlatformKeyboardEvent; 74 74 class PlatformMouseEvent; 75 class PlatformWheelEvent;76 75 class QualifiedName; 77 76 class RadioNodeList; … … 550 549 bool dispatchDOMActivateEvent(int detail, PassRefPtr<Event> underlyingEvent); 551 550 552 bool dispatchWheelEvent(const PlatformWheelEvent&);553 551 bool dispatchMouseEvent(const PlatformMouseEvent&, const AtomicString& eventType, int clickCount = 0, Node* relatedTarget = 0); 554 552 #if ENABLE(GESTURE_EVENTS) -
trunk/Source/WebCore/page/EventHandler.cpp
r156390 r156397 273 273 } 274 274 275 static inline bool scrollNode(float delta, ScrollGranularity granularity, ScrollDirection positiveDirection, ScrollDirection negativeDirection, Node* node, Node** stopNode)275 static inline bool scrollNode(float delta, ScrollGranularity granularity, ScrollDirection positiveDirection, ScrollDirection negativeDirection, Node* node, Element** stopElement) 276 276 { 277 277 if (!delta) … … 281 281 RenderBox* enclosingBox = node->renderer()->enclosingBox(); 282 282 float absDelta = delta > 0 ? delta : -delta; 283 return enclosingBox->scroll(delta < 0 ? negativeDirection : positiveDirection, granularity, absDelta, stop Node);283 return enclosingBox->scroll(delta < 0 ? negativeDirection : positiveDirection, granularity, absDelta, stopElement); 284 284 } 285 285 … … 406 406 m_capturesDragging = false; 407 407 m_capturingMouseEventsNode = 0; 408 m_latchedWheelEvent Node = 0;409 m_previousWheelScrolled Node = 0;408 m_latchedWheelEventElement = nullptr; 409 m_previousWheelScrolledElement = nullptr; 410 410 #if ENABLE(TOUCH_EVENTS) 411 411 m_originatingTouchPointTargets.clear(); … … 416 416 m_scrollGestureHandlingNode = 0; 417 417 m_lastHitTestResultOverWidget = false; 418 m_previousGestureScrolled Node = 0;418 m_previousGestureScrolledElement = nullptr; 419 419 m_scrollbarHandlingScrollGesture = 0; 420 420 #endif … … 2477 2477 doc->renderView()->hitTest(request, result); 2478 2478 2479 bool useLatchedWheelEventNode = e.useLatchedEventNode(); 2480 2481 // FIXME: This code should use Element* instead of Node*. 2482 Node* node = result.innerElement(); 2479 bool useLatchedWheelEventElement = e.useLatchedEventElement(); 2480 2481 Element* element = result.innerElement(); 2483 2482 2484 2483 bool isOverWidget; 2485 if (useLatchedWheelEvent Node) {2486 if (!m_latchedWheelEvent Node) {2487 m_latchedWheelEvent Node = node;2484 if (useLatchedWheelEventElement) { 2485 if (!m_latchedWheelEventElement) { 2486 m_latchedWheelEventElement = element; 2488 2487 m_widgetIsLatched = result.isOverWidget(); 2489 2488 } else 2490 node = m_latchedWheelEventNode.get();2489 element = m_latchedWheelEventElement.get(); 2491 2490 2492 2491 isOverWidget = m_widgetIsLatched; 2493 2492 } else { 2494 if (m_latchedWheelEvent Node)2495 m_latchedWheelEvent Node = 0;2496 if (m_previousWheelScrolled Node)2497 m_previousWheelScrolled Node = 0;2493 if (m_latchedWheelEventElement) 2494 m_latchedWheelEventElement = nullptr; 2495 if (m_previousWheelScrolledElement) 2496 m_previousWheelScrolledElement = nullptr; 2498 2497 2499 2498 isOverWidget = result.isOverWidget(); … … 2523 2522 recordWheelEventDelta(event); 2524 2523 2525 if ( node) {2524 if (element) { 2526 2525 // Figure out which view to send the event to. 2527 Render Object* target = node->renderer();2526 RenderElement* target = element->renderer(); 2528 2527 2529 2528 if (isOverWidget && target && target->isWidget()) { … … 2535 2534 } 2536 2535 2537 if ( node && !node->dispatchWheelEvent(event)) {2536 if (!element->dispatchWheelEvent(event)) { 2538 2537 m_isHandlingWheelEvent = false; 2539 2538 return true; … … 2554 2553 return; 2555 2554 2556 Node* stopNode = m_previousWheelScrolledNode.get();2555 Element* stopElement = m_previousWheelScrolledElement.get(); 2557 2556 ScrollGranularity granularity = wheelGranularityToScrollGranularity(wheelEvent->deltaMode()); 2558 2557 … … 2564 2563 // Break up into two scrolls if we need to. Diagonal movement on 2565 2564 // a MacBook pro is an example of a 2-dimensional mouse wheel event (where both deltaX and deltaY can be set). 2566 if (dominantDirection != DominantScrollDirectionVertical && scrollNode(wheelEvent->deltaX(), granularity, ScrollRight, ScrollLeft, startNode, &stop Node))2565 if (dominantDirection != DominantScrollDirectionVertical && scrollNode(wheelEvent->deltaX(), granularity, ScrollRight, ScrollLeft, startNode, &stopElement)) 2567 2566 wheelEvent->setDefaultHandled(); 2568 2567 2569 if (dominantDirection != DominantScrollDirectionHorizontal && scrollNode(wheelEvent->deltaY(), granularity, ScrollDown, ScrollUp, startNode, &stop Node))2568 if (dominantDirection != DominantScrollDirectionHorizontal && scrollNode(wheelEvent->deltaY(), granularity, ScrollDown, ScrollUp, startNode, &stopElement)) 2570 2569 wheelEvent->setDefaultHandled(); 2571 2570 2572 if (!m_latchedWheelEvent Node)2573 m_previousWheelScrolled Node = stopNode;2571 if (!m_latchedWheelEventElement) 2572 m_previousWheelScrolledElement = stopElement; 2574 2573 } 2575 2574 … … 2809 2808 m_lastHitTestResultOverWidget = result.isOverWidget(); 2810 2809 m_scrollGestureHandlingNode = result.innerNode(); 2811 m_previousGestureScrolled Node = 0;2810 m_previousGestureScrolledElement = nullptr; 2812 2811 2813 2812 Node* node = m_scrollGestureHandlingNode.get(); … … 2842 2841 return true; 2843 2842 2844 Node* stopNode= 0;2843 Element* stopElement = 0; 2845 2844 bool scrollShouldNotPropagate = gestureEvent.type() == PlatformEvent::GestureScrollUpdateWithoutPropagation; 2846 2845 if (scrollShouldNotPropagate) 2847 stop Node = m_previousGestureScrolledNode.get();2846 stopElement = m_previousGestureScrolledElement.get(); 2848 2847 2849 2848 // First try to scroll the closest scrollable RenderBox ancestor of |node|. 2850 2849 ScrollGranularity granularity = ScrollByPixel; 2851 bool horizontalScroll = scrollNode(delta.width(), granularity, ScrollLeft, ScrollRight, node, &stop Node);2852 bool verticalScroll = scrollNode(delta.height(), granularity, ScrollUp, ScrollDown, node, &stop Node);2850 bool horizontalScroll = scrollNode(delta.width(), granularity, ScrollLeft, ScrollRight, node, &stopElement); 2851 bool verticalScroll = scrollNode(delta.height(), granularity, ScrollUp, ScrollDown, node, &stopElement); 2853 2852 2854 2853 if (scrollShouldNotPropagate) 2855 m_previousGestureScrolled Node = stopNode;2854 m_previousGestureScrolledElement = stopElement; 2856 2855 2857 2856 if (horizontalScroll || verticalScroll) { … … 2892 2891 { 2893 2892 m_scrollGestureHandlingNode = 0; 2894 m_previousGestureScrolled Node = 0;2893 m_previousGestureScrolledElement = nullptr; 2895 2894 } 2896 2895 -
trunk/Source/WebCore/page/EventHandler.h
r155548 r156397 477 477 478 478 Deque<FloatSize> m_recentWheelEventDeltas; 479 RefPtr< Node> m_latchedWheelEventNode;479 RefPtr<Element> m_latchedWheelEventElement; 480 480 bool m_inTrackingScrollGesturePhase; 481 481 bool m_widgetIsLatched; 482 482 483 RefPtr< Node> m_previousWheelScrolledNode;483 RefPtr<Element> m_previousWheelScrolledElement; 484 484 485 485 #if PLATFORM(MAC) … … 499 499 RefPtr<Node> m_scrollGestureHandlingNode; 500 500 bool m_lastHitTestResultOverWidget; 501 RefPtr< Node> m_previousGestureScrolledNode;501 RefPtr<Element> m_previousGestureScrolledElement; 502 502 RefPtr<Scrollbar> m_scrollbarHandlingScrollGesture; 503 503 #endif -
trunk/Source/WebCore/platform/PlatformWheelEvent.h
r153483 r156397 149 149 float unacceleratedScrollingDeltaX() const { return m_unacceleratedScrollingDeltaX; } 150 150 float unacceleratedScrollingDeltaY() const { return m_unacceleratedScrollingDeltaY; } 151 bool useLatchedEvent Node() const { return m_momentumPhase == PlatformWheelEventPhaseBegan || m_momentumPhase == PlatformWheelEventPhaseChanged; }151 bool useLatchedEventElement() const { return m_momentumPhase == PlatformWheelEventPhaseBegan || m_momentumPhase == PlatformWheelEventPhaseChanged; } 152 152 #else 153 bool useLatchedEvent Node() const { return false; }153 bool useLatchedEventElement() const { return false; } 154 154 #endif 155 155 -
trunk/Source/WebCore/rendering/RenderBox.cpp
r156310 r156397 747 747 } 748 748 749 bool RenderBox::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, Node** stopNode)749 bool RenderBox::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, Element** stopElement) 750 750 { 751 751 RenderLayer* l = layer(); 752 752 if (l && l->scroll(direction, granularity, multiplier)) { 753 if (stop Node)754 *stop Node= element();753 if (stopElement) 754 *stopElement = element(); 755 755 return true; 756 756 } 757 757 758 if (stop Node && *stopNode && *stopNode== element())758 if (stopElement && *stopElement && *stopElement == element()) 759 759 return true; 760 760 761 761 RenderBlock* b = containingBlock(); 762 762 if (b && !b->isRenderView()) 763 return b->scroll(direction, granularity, multiplier, stop Node);763 return b->scroll(direction, granularity, multiplier, stopElement); 764 764 return false; 765 765 } 766 766 767 bool RenderBox::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, float multiplier, Node** stopNode)767 bool RenderBox::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, float multiplier, Element** stopElement) 768 768 { 769 769 bool scrolled = false; … … 780 780 781 781 if (scrolled) { 782 if (stop Node)783 *stop Node= element();782 if (stopElement) 783 *stopElement = element(); 784 784 return true; 785 785 } 786 786 } 787 787 788 if (stop Node && *stopNode && *stopNode== element())788 if (stopElement && *stopElement && *stopElement == element()) 789 789 return true; 790 790 791 791 RenderBlock* b = containingBlock(); 792 792 if (b && !b->isRenderView()) 793 return b->logicalScroll(direction, granularity, multiplier, stop Node);793 return b->logicalScroll(direction, granularity, multiplier, stopElement); 794 794 return false; 795 795 } -
trunk/Source/WebCore/rendering/RenderBox.h
r155374 r156397 448 448 int instrinsicScrollbarLogicalWidth() const; 449 449 int scrollbarLogicalHeight() const { return style()->isHorizontalWritingMode() ? horizontalScrollbarHeight() : verticalScrollbarWidth(); } 450 virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Node** stopNode= 0);451 virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Node** stopNode= 0);450 virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = 0); 451 virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = 0); 452 452 bool canBeScrolledAndHasScrollableArea() const; 453 453 virtual bool canBeProgramaticallyScrolled() const; -
trunk/Source/WebCore/rendering/RenderEmbeddedObject.cpp
r156278 r156397 570 570 } 571 571 572 bool RenderEmbeddedObject::scroll(ScrollDirection direction, ScrollGranularity granularity, float, Node**)572 bool RenderEmbeddedObject::scroll(ScrollDirection direction, ScrollGranularity granularity, float, Element**) 573 573 { 574 574 if (!widget() || !widget()->isPluginViewBase()) … … 578 578 } 579 579 580 bool RenderEmbeddedObject::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, float multiplier, Node** stopNode)580 bool RenderEmbeddedObject::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, float multiplier, Element** stopElement) 581 581 { 582 582 // Plugins don't expose a writing direction, so assuming horizontal LTR. 583 return scroll(logicalToPhysical(direction, true, false), granularity, multiplier, stop Node);583 return scroll(logicalToPhysical(direction, true, false), granularity, multiplier, stopElement); 584 584 } 585 585 -
trunk/Source/WebCore/rendering/RenderEmbeddedObject.h
r156278 r156397 91 91 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE FINAL; 92 92 93 virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier, Node** stopNode) OVERRIDE FINAL;94 virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier, Node** stopNode) OVERRIDE FINAL;93 virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier, Element** stopElement) OVERRIDE FINAL; 94 virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier, Element** stopElement) OVERRIDE FINAL; 95 95 96 96 void setUnavailablePluginIndicatorIsPressed(bool); -
trunk/Source/WebCore/rendering/RenderListBox.cpp
r156155 r156397 595 595 } 596 596 597 bool RenderListBox::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, Node**)597 bool RenderListBox::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, Element**) 598 598 { 599 599 return ScrollableArea::scroll(direction, granularity, multiplier); 600 600 } 601 601 602 bool RenderListBox::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, float multiplier, Node**)602 bool RenderListBox::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, float multiplier, Element**) 603 603 { 604 604 return ScrollableArea::scroll(logicalToPhysical(direction, style()->isHorizontalWritingMode(), style()->isFlippedBlocksWritingMode()), granularity, multiplier); -
trunk/Source/WebCore/rendering/RenderListBox.h
r155669 r156397 75 75 virtual bool isPointInOverflowControl(HitTestResult&, const LayoutPoint& locationInContainer, const LayoutPoint& accumulatedOffset); 76 76 77 virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0);78 virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0);77 virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = 0) OVERRIDE; 78 virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = 0) OVERRIDE; 79 79 80 80 virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const OVERRIDE; -
trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp
r156314 r156397 448 448 } 449 449 450 bool RenderTextControlSingleLine::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, Node** stopNode)450 bool RenderTextControlSingleLine::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, Element** stopElement) 451 451 { 452 452 RenderBox* renderer = innerTextElement()->renderBox(); … … 456 456 if (layer && layer->scroll(direction, granularity, multiplier)) 457 457 return true; 458 return RenderBlock::scroll(direction, granularity, multiplier, stop Node);459 } 460 461 bool RenderTextControlSingleLine::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, float multiplier, Node** stopNode)458 return RenderBlock::scroll(direction, granularity, multiplier, stopElement); 459 } 460 461 bool RenderTextControlSingleLine::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, float multiplier, Element** stopElement) 462 462 { 463 463 RenderLayer* layer = innerTextElement()->renderBox()->layer(); 464 464 if (layer && layer->scroll(logicalToPhysical(direction, style()->isHorizontalWritingMode(), style()->isFlippedBlocksWritingMode()), granularity, multiplier)) 465 465 return true; 466 return RenderBlock::logicalScroll(direction, granularity, multiplier, stop Node);466 return RenderBlock::logicalScroll(direction, granularity, multiplier, stopElement); 467 467 } 468 468 -
trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h
r156314 r156397 69 69 virtual void setScrollLeft(int) OVERRIDE; 70 70 virtual void setScrollTop(int) OVERRIDE; 71 virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0) OVERRIDE;72 virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0) OVERRIDE;71 virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = 0) OVERRIDE FINAL; 72 virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = 0) OVERRIDE FINAL; 73 73 74 74 int textBlockWidth() const;
Note: See TracChangeset
for help on using the changeset viewer.