Title: [254631] trunk/Source/WebCore
Revision
254631
Author
[email protected]
Date
2020-01-15 13:22:55 -0800 (Wed, 15 Jan 2020)

Log Message

Add more mousewheel-scrolling logging and improve the latching code
https://bugs.webkit.org/show_bug.cgi?id=206298

Reviewed by Tim Horton.

Make PlatformWheelEvent TextStream-loggable, and add more Scrolling logging in some places
related to mouseWheel scrolling and latching.

Make the ownership of Elements and Nodes given to ScrollLatchingState more explicit by passing in
RefPtr<>&&.

* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* page/EventHandler.cpp:
(WebCore::handleWheelEventInAppropriateEnclosingBox):
(WebCore::EventHandler::defaultWheelEventHandler):
* page/mac/EventHandlerMac.mm:
(WebCore::EventHandler::platformPrepareForWheelEvents):
(WebCore::EventHandler::platformCompleteWheelEvent):
* page/scrolling/ScrollLatchingState.cpp:
(WebCore::ScrollLatchingState::setWheelEventElement):
(WebCore::ScrollLatchingState::setPreviousWheelScrolledElement):
(WebCore::ScrollLatchingState::setScrollableContainer):
* page/scrolling/ScrollLatchingState.h:
* page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::shouldHandleWheelEventSynchronously):
* platform/PlatformWheelEvent.cpp: Copied from Source/WebCore/page/scrolling/ScrollLatchingState.cpp.
(WebCore::operator<<):
* platform/PlatformWheelEvent.h:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (254630 => 254631)


--- trunk/Source/WebCore/ChangeLog	2020-01-15 21:17:50 UTC (rev 254630)
+++ trunk/Source/WebCore/ChangeLog	2020-01-15 21:22:55 UTC (rev 254631)
@@ -1,3 +1,35 @@
+2020-01-15  Simon Fraser  <[email protected]>
+
+        Add more mousewheel-scrolling logging and improve the latching code
+        https://bugs.webkit.org/show_bug.cgi?id=206298
+
+        Reviewed by Tim Horton.
+
+        Make PlatformWheelEvent TextStream-loggable, and add more Scrolling logging in some places
+        related to mouseWheel scrolling and latching.
+
+        Make the ownership of Elements and Nodes given to ScrollLatchingState more explicit by passing in
+        RefPtr<>&&.
+
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * page/EventHandler.cpp:
+        (WebCore::handleWheelEventInAppropriateEnclosingBox):
+        (WebCore::EventHandler::defaultWheelEventHandler):
+        * page/mac/EventHandlerMac.mm:
+        (WebCore::EventHandler::platformPrepareForWheelEvents):
+        (WebCore::EventHandler::platformCompleteWheelEvent):
+        * page/scrolling/ScrollLatchingState.cpp:
+        (WebCore::ScrollLatchingState::setWheelEventElement):
+        (WebCore::ScrollLatchingState::setPreviousWheelScrolledElement):
+        (WebCore::ScrollLatchingState::setScrollableContainer):
+        * page/scrolling/ScrollLatchingState.h:
+        * page/scrolling/ScrollingTree.cpp:
+        (WebCore::ScrollingTree::shouldHandleWheelEventSynchronously):
+        * platform/PlatformWheelEvent.cpp: Copied from Source/WebCore/page/scrolling/ScrollLatchingState.cpp.
+        (WebCore::operator<<):
+        * platform/PlatformWheelEvent.h:
+
 2020-01-15  Zalan Bujtas  <[email protected]>
 
         [LFC][IFC] LineLayoutContext::nextContentForLine should take LineCandidateContent&

Modified: trunk/Source/WebCore/Sources.txt (254630 => 254631)


--- trunk/Source/WebCore/Sources.txt	2020-01-15 21:17:50 UTC (rev 254630)
+++ trunk/Source/WebCore/Sources.txt	2020-01-15 21:22:55 UTC (rev 254631)
@@ -1753,6 +1753,7 @@
 platform/PlatformSpeechSynthesisVoice.cpp
 platform/PlatformSpeechSynthesizer.cpp
 platform/PlatformStrategies.cpp
+platform/PlatformWheelEvent.cpp
 platform/PreviewConverter.cpp
 platform/ProcessIdentifier.cpp
 platform/ReferrerPolicy.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (254630 => 254631)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-01-15 21:17:50 UTC (rev 254630)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-01-15 21:22:55 UTC (rev 254631)
@@ -5822,6 +5822,7 @@
 		0FD41E6721F80282000C006D /* ScrollingTreeFrameHostingNode.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollingTreeFrameHostingNode.cpp; sourceTree = "<group>"; };
 		0FD723800EC8BD9300CA5DD7 /* FloatQuad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FloatQuad.h; sourceTree = "<group>"; };
 		0FD723810EC8BD9300CA5DD7 /* FloatQuad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FloatQuad.cpp; sourceTree = "<group>"; };
+		0FD7C21D23CE41E30096D102 /* PlatformWheelEvent.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformWheelEvent.cpp; sourceTree = "<group>"; };
 		0FDA7C10188322EB00C954B5 /* JSTouch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTouch.cpp; sourceTree = "<group>"; };
 		0FDA7C11188322EB00C954B5 /* JSTouch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTouch.h; sourceTree = "<group>"; };
 		0FDA7C12188322EB00C954B5 /* JSTouchEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTouchEvent.cpp; sourceTree = "<group>"; };
@@ -25987,6 +25988,7 @@
 				29E4D8DF16B0940F00C84704 /* PlatformSpeechSynthesizer.h */,
 				1AD8F81A11CAB9E900E93E54 /* PlatformStrategies.cpp */,
 				1AD8F81911CAB9E900E93E54 /* PlatformStrategies.h */,
+				0FD7C21D23CE41E30096D102 /* PlatformWheelEvent.cpp */,
 				935C476A09AC4D4F00A6AAB4 /* PlatformWheelEvent.h */,
 				BCBB8AB513F1AFB000734DF0 /* PODInterval.h */,
 				BCBB8AB613F1AFB000734DF0 /* PODIntervalTree.h */,

Modified: trunk/Source/WebCore/page/EventHandler.cpp (254630 => 254631)


--- trunk/Source/WebCore/page/EventHandler.cpp	2020-01-15 21:17:50 UTC (rev 254630)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2020-01-15 21:22:55 UTC (rev 254631)
@@ -302,7 +302,7 @@
     return didHandleWheelEvent;
 }
 
-static inline bool handleWheelEventInAppropriateEnclosingBox(Node* startNode, WheelEvent& wheelEvent, Element** stopElement, const FloatSize& filteredPlatformDelta, const FloatSize& filteredVelocity)
+static inline bool handleWheelEventInAppropriateEnclosingBox(Node* startNode, WheelEvent& wheelEvent, RefPtr<Element>& stopElement, const FloatSize& filteredPlatformDelta, const FloatSize& filteredVelocity)
 {
     bool shouldHandleEvent = wheelEvent.deltaX() || wheelEvent.deltaY();
 #if PLATFORM(MAC)
@@ -330,13 +330,12 @@
                 scrollingWasHandled = didScrollInScrollableArea(boxLayer, wheelEvent);
 
             if (scrollingWasHandled) {
-                if (stopElement)
-                    *stopElement = currentEnclosingBox->element();
+                stopElement = currentEnclosingBox->element();
                 return true;
             }
         }
 
-        if (stopElement && *stopElement && *stopElement == currentEnclosingBox->element())
+        if (stopElement.get() && stopElement.get() == currentEnclosingBox->element())
             return true;
 
         currentEnclosingBox = currentEnclosingBox->containingBlock();
@@ -2911,7 +2910,7 @@
 
 #if PLATFORM(MAC)
     ScrollLatchingState* latchedState = m_frame.page() ? m_frame.page()->latchingState() : nullptr;
-    Element* stopElement = latchedState ? latchedState->previousWheelScrolledElement() : nullptr;
+    RefPtr<Element> stopElement = latchedState ? latchedState->previousWheelScrolledElement() : nullptr;
 
     if (m_frame.page() && m_frame.page()->wheelEventDeltaFilter()->isFilteringDeltas()) {
         filteredPlatformDelta = m_frame.page()->wheelEventDeltaFilter()->filteredDelta();
@@ -2918,15 +2917,15 @@
         filteredVelocity = m_frame.page()->wheelEventDeltaFilter()->filteredVelocity();
     }
 #else
-    Element* stopElement = nullptr;
+    RefPtr<Element> stopElement;
 #endif
 
-    if (handleWheelEventInAppropriateEnclosingBox(startNode, wheelEvent, &stopElement, filteredPlatformDelta, filteredVelocity))
+    if (handleWheelEventInAppropriateEnclosingBox(startNode, wheelEvent, stopElement, filteredPlatformDelta, filteredVelocity))
         wheelEvent.setDefaultHandled();
 
 #if PLATFORM(MAC)
     if (latchedState && !latchedState->wheelEventElement())
-        latchedState->setPreviousWheelScrolledElement(stopElement);
+        latchedState->setPreviousWheelScrolledElement(WTFMove(stopElement));
 #endif
 }
 

Modified: trunk/Source/WebCore/page/mac/EventHandlerMac.mm (254630 => 254631)


--- trunk/Source/WebCore/page/mac/EventHandlerMac.mm	2020-01-15 21:17:50 UTC (rev 254630)
+++ trunk/Source/WebCore/page/mac/EventHandlerMac.mm	2020-01-15 21:22:55 UTC (rev 254631)
@@ -45,6 +45,7 @@
 #include "HTMLHtmlElement.h"
 #include "HTMLIFrameElement.h"
 #include "KeyboardEvent.h"
+#include "Logging.h"
 #include "MouseEventWithHitTestResults.h"
 #include "Page.h"
 #include "Pasteboard.h"
@@ -977,8 +978,7 @@
                 latchingState->setStartedGestureAtScrollLimit(false);
                 latchingState->setWheelEventElement(wheelEventTarget.get());
                 latchingState->setFrame(&m_frame);
-                // FIXME: What prevents us from deleting this scrollable container while still holding a pointer to it?
-                latchingState->setScrollableContainer(scrollableContainer.get());
+                latchingState->setScrollableContainer(scrollableContainer.copyRef());
                 latchingState->setWidgetIsLatched(result.isOverWidget());
                 isOverWidget = latchingState->widgetIsLatched();
                 page->wheelEventDeltaFilter()->beginFilteringDeltas();
@@ -1034,6 +1034,8 @@
 
 bool EventHandler::platformCompleteWheelEvent(const PlatformWheelEvent& wheelEvent, ContainerNode* scrollableContainer, const WeakPtr<ScrollableArea>& scrollableArea)
 {
+    LOG_WITH_STREAM(Scrolling, stream << "EventHandler::platformCompleteWheelEvent " << wheelEvent << " - scrollableContainer " << scrollableContainer << " scrollableArea " << scrollableArea.get() << " use latched element " << wheelEvent.useLatchedEventElement());
+
     Ref<Frame> protectedFrame(m_frame);
 
     FrameView* view = m_frame.view();
@@ -1043,12 +1045,12 @@
 
     ScrollLatchingState* latchingState = m_frame.page() ? m_frame.page()->latchingState() : nullptr;
     if (wheelEvent.useLatchedEventElement() && !latchingIsLockedToAncestorOfThisFrame(m_frame) && latchingState && latchingState->scrollableContainer()) {
-
         m_isHandlingWheelEvent = false;
 
         // WebKit2 code path
         if (!frameHasPlatformWidget(m_frame) && !latchingState->startedGestureAtScrollLimit() && scrollableContainer == latchingState->scrollableContainer() && scrollableArea && view != scrollableArea) {
             // If we did not start at the scroll limit, do not pass the event on to be handled by enclosing scrollable regions.
+            LOG_WITH_STREAM(Scrolling, stream << "EventHandler " << this << " platformCompleteWheelEvent - latched to " << scrollableArea.get() << " and not propagating");
             return true;
         }
 

Modified: trunk/Source/WebCore/page/scrolling/ScrollLatchingState.cpp (254630 => 254631)


--- trunk/Source/WebCore/page/scrolling/ScrollLatchingState.cpp	2020-01-15 21:17:50 UTC (rev 254630)
+++ trunk/Source/WebCore/page/scrolling/ScrollLatchingState.cpp	2020-01-15 21:22:55 UTC (rev 254631)
@@ -43,9 +43,9 @@
     m_previousWheelScrolledElement = nullptr;
 }
 
-void ScrollLatchingState::setWheelEventElement(Element* element)
+void ScrollLatchingState::setWheelEventElement(RefPtr<Element>&& element)
 {
-    m_wheelEventElement = element;
+    m_wheelEventElement = WTFMove(element);
 }
 
 void ScrollLatchingState::setWidgetIsLatched(bool isOverWidget)
@@ -53,14 +53,14 @@
     m_widgetIsLatched = isOverWidget;
 }
 
-void ScrollLatchingState::setPreviousWheelScrolledElement(Element* element)
+void ScrollLatchingState::setPreviousWheelScrolledElement(RefPtr<Element>&& element)
 {
-    m_previousWheelScrolledElement = element;
+    m_previousWheelScrolledElement = WTFMove(element);
 }
 
-void ScrollLatchingState::setScrollableContainer(ContainerNode* container)
+void ScrollLatchingState::setScrollableContainer(RefPtr<ContainerNode>&& container)
 {
-    m_scrollableContainer = container;
+    m_scrollableContainer = WTFMove(container);
 }
 
 }

Modified: trunk/Source/WebCore/page/scrolling/ScrollLatchingState.h (254630 => 254631)


--- trunk/Source/WebCore/page/scrolling/ScrollLatchingState.h	2020-01-15 21:17:50 UTC (rev 254630)
+++ trunk/Source/WebCore/page/scrolling/ScrollLatchingState.h	2020-01-15 21:22:55 UTC (rev 254631)
@@ -41,7 +41,7 @@
     void clear();
 
     Element* wheelEventElement() { return m_wheelEventElement.get(); }
-    void setWheelEventElement(Element*);
+    void setWheelEventElement(RefPtr<Element>&&);
     Frame* frame() { return m_frame; }
     void setFrame(Frame* frame) { m_frame = frame; }
 
@@ -49,10 +49,10 @@
     void setWidgetIsLatched(bool isOverWidget);
 
     Element* previousWheelScrolledElement() { return m_previousWheelScrolledElement.get(); }
-    void setPreviousWheelScrolledElement(Element*);
+    void setPreviousWheelScrolledElement(RefPtr<Element>&&);
     
     ContainerNode* scrollableContainer() { return m_scrollableContainer.get(); }
-    void setScrollableContainer(ContainerNode*);
+    void setScrollableContainer(RefPtr<ContainerNode>&&);
     bool startedGestureAtScrollLimit() const { return m_startedGestureAtScrollLimit; }
     void setStartedGestureAtScrollLimit(bool startedAtLimit) { m_startedGestureAtScrollLimit = startedAtLimit; }
 

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp (254630 => 254631)


--- trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp	2020-01-15 21:17:50 UTC (rev 254630)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp	2020-01-15 21:22:55 UTC (rev 254631)
@@ -71,7 +71,7 @@
         // Event regions are affected by page scale, so no need to map through scale.
         bool isSynchronousDispatchRegion = m_treeState.eventTrackingRegions.trackingTypeForPoint(names.wheelEvent, roundedPosition) == TrackingType::Synchronous
             || m_treeState.eventTrackingRegions.trackingTypeForPoint(names.mousewheelEvent, roundedPosition) == TrackingType::Synchronous;
-        LOG_WITH_STREAM(Scrolling, stream << "ScrollingTree::shouldHandleWheelEventSynchronously: wheelEvent at " << wheelEvent.position() << " mapped to content point " << position << ", in non-fast region " << isSynchronousDispatchRegion);
+        LOG_WITH_STREAM(Scrolling, stream << "\n\nScrollingTree::shouldHandleWheelEventSynchronously: wheelEvent " << wheelEvent << " mapped to content point " << position << ", in non-fast region " << isSynchronousDispatchRegion);
 
         if (isSynchronousDispatchRegion)
             return true;

Copied: trunk/Source/WebCore/platform/PlatformWheelEvent.cpp (from rev 254630, trunk/Source/WebCore/page/scrolling/ScrollLatchingState.cpp) (0 => 254631)


--- trunk/Source/WebCore/platform/PlatformWheelEvent.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/PlatformWheelEvent.cpp	2020-01-15 21:22:55 UTC (rev 254631)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "PlatformWheelEvent.h"
+
+#include <wtf/text/TextStream.h>
+
+namespace WebCore {
+
+#if ENABLE(KINETIC_SCROLLING)
+
+TextStream& operator<<(TextStream& ts, PlatformWheelEventPhase phase)
+{
+    switch (phase) {
+    case PlatformWheelEventPhaseNone: ts << "none"; break;
+    case PlatformWheelEventPhaseBegan: ts << "began"; break;
+    case PlatformWheelEventPhaseStationary: ts << "stationary"; break;
+    case PlatformWheelEventPhaseChanged: ts << "changed"; break;
+    case PlatformWheelEventPhaseEnded: ts << "ended"; break;
+    case PlatformWheelEventPhaseCancelled: ts << "cancelled"; break;
+    case PlatformWheelEventPhaseMayBegin: ts << "mayBegin"; break;
+    }
+    return ts;
+}
+
+#endif
+
+TextStream& operator<<(TextStream& ts, const PlatformWheelEvent& event)
+{
+    ts << "PlatformWheelEvent " << &event << " at " << event.position() << " deltaX " << event.deltaX() << " deltaY " << event.deltaY();
+
+#if ENABLE(KINETIC_SCROLLING)
+    ts << " phase \"" << event.phase() << "\" momentumum phase \"" << event.momentumPhase() << "\"";
+#endif
+
+    return ts;
+}
+
+} // namespace WebCore

Modified: trunk/Source/WebCore/platform/PlatformWheelEvent.h (254630 => 254631)


--- trunk/Source/WebCore/platform/PlatformWheelEvent.h	2020-01-15 21:17:50 UTC (rev 254630)
+++ trunk/Source/WebCore/platform/PlatformWheelEvent.h	2020-01-15 21:22:55 UTC (rev 254631)
@@ -34,6 +34,12 @@
 typedef struct _GdkEventScroll GdkEventScroll;
 #endif
 
+#if ENABLE(KINETIC_SCROLLING)
+namespace WTF {
+class TextStream;
+}
+#endif
+
 namespace WebCore {
 
 // The ScrollByPixelWheelEvent is a fine-grained event that specifies the precise number of pixels to scroll.
@@ -60,6 +66,8 @@
     PlatformWheelEventPhaseMayBegin = 1 << 5,
 };
 
+WTF::TextStream& operator<<(WTF::TextStream&, PlatformWheelEventPhase);
+
 #endif
 
 #if PLATFORM(WIN)
@@ -231,4 +239,6 @@
 
 #endif // ENABLE(KINETIC_SCROLLING)
 
+WTF::TextStream& operator<<(WTF::TextStream&, const PlatformWheelEvent&);
+
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to