Title: [259282] trunk/Source/WebCore
- Revision
- 259282
- Author
- simon.fra...@apple.com
- Date
- 2020-03-30 23:19:49 -0700 (Mon, 30 Mar 2020)
Log Message
Scroll latching state is not a stack
https://bugs.webkit.org/show_bug.cgi?id=209790
Reviewed by Zalan Bujtas.
No-one ever called Page::popLatchingState(), so the fact that latchingState on Page
was a stack was never important. Just make it a single state.
* page/Page.cpp:
(WebCore::Page::latchingState):
(WebCore::Page::setLatchingState):
(WebCore::Page::resetLatchingState):
(WebCore::Page::removeLatchingStateForTarget):
(WebCore::Page::pushNewLatchingState): Deleted.
(WebCore::Page::popLatchingState): Deleted.
* page/Page.h:
(WebCore::Page::latchingStateStack const): Deleted.
* page/mac/EventHandlerMac.mm:
(WebCore::EventHandler::platformPrepareForWheelEvents):
* page/scrolling/ScrollLatchingState.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (259281 => 259282)
--- trunk/Source/WebCore/ChangeLog 2020-03-31 05:59:07 UTC (rev 259281)
+++ trunk/Source/WebCore/ChangeLog 2020-03-31 06:19:49 UTC (rev 259282)
@@ -1,3 +1,26 @@
+2020-03-30 Simon Fraser <simon.fra...@apple.com>
+
+ Scroll latching state is not a stack
+ https://bugs.webkit.org/show_bug.cgi?id=209790
+
+ Reviewed by Zalan Bujtas.
+
+ No-one ever called Page::popLatchingState(), so the fact that latchingState on Page
+ was a stack was never important. Just make it a single state.
+
+ * page/Page.cpp:
+ (WebCore::Page::latchingState):
+ (WebCore::Page::setLatchingState):
+ (WebCore::Page::resetLatchingState):
+ (WebCore::Page::removeLatchingStateForTarget):
+ (WebCore::Page::pushNewLatchingState): Deleted.
+ (WebCore::Page::popLatchingState): Deleted.
+ * page/Page.h:
+ (WebCore::Page::latchingStateStack const): Deleted.
+ * page/mac/EventHandlerMac.mm:
+ (WebCore::EventHandler::platformPrepareForWheelEvents):
+ * page/scrolling/ScrollLatchingState.h:
+
2020-03-28 Simon Fraser <simon.fra...@apple.com>
ScrollLatchingState should use WeakPtr<Element>
Modified: trunk/Source/WebCore/page/Page.cpp (259281 => 259282)
--- trunk/Source/WebCore/page/Page.cpp 2020-03-31 05:59:07 UTC (rev 259281)
+++ trunk/Source/WebCore/page/Page.cpp 2020-03-31 06:19:49 UTC (rev 259282)
@@ -2943,41 +2943,26 @@
#if ENABLE(WHEEL_EVENT_LATCHING)
ScrollLatchingState* Page::latchingState()
{
- if (m_latchingState.isEmpty())
- return nullptr;
-
- return &m_latchingState.last();
+ return m_latchingState.get();
}
-void Page::pushNewLatchingState(ScrollLatchingState&& state)
+void Page::setLatchingState(std::unique_ptr<ScrollLatchingState>&& state)
{
- m_latchingState.append(WTFMove(state));
+ m_latchingState = WTFMove(state);
}
void Page::resetLatchingState()
{
- m_latchingState.clear();
+ m_latchingState = nullptr;
}
-void Page::popLatchingState()
-{
- m_latchingState.removeLast();
- LOG_WITH_STREAM(ScrollLatching, stream << "Page::popLatchingState() - new state " << m_latchingState);
-}
-
void Page::removeLatchingStateForTarget(Element& targetNode)
{
- if (m_latchingState.isEmpty())
+ if (!m_latchingState)
return;
- m_latchingState.removeAllMatching([&targetNode] (ScrollLatchingState& state) {
- auto* wheelElement = state.wheelEventElement();
- if (!wheelElement)
- return false;
-
- return targetNode.isEqualNode(wheelElement);
- });
- LOG_WITH_STREAM(ScrollLatching, stream << "Page::removeLatchingStateForTarget() - new state " << m_latchingState);
+ if (m_latchingState->wheelEventElement() == &targetNode)
+ m_latchingState = nullptr;
}
#endif // ENABLE(WHEEL_EVENT_LATCHING)
Modified: trunk/Source/WebCore/page/Page.h (259281 => 259282)
--- trunk/Source/WebCore/page/Page.h 2020-03-31 05:59:07 UTC (rev 259281)
+++ trunk/Source/WebCore/page/Page.h 2020-03-31 06:19:49 UTC (rev 259282)
@@ -430,9 +430,7 @@
#if ENABLE(WHEEL_EVENT_LATCHING)
ScrollLatchingState* latchingState();
- const Vector<ScrollLatchingState>& latchingStateStack() const { return m_latchingState; }
- void pushNewLatchingState(ScrollLatchingState&&);
- void popLatchingState();
+ void setLatchingState(std::unique_ptr<ScrollLatchingState>&&);
void resetLatchingState();
void removeLatchingStateForTarget(Element&);
#endif // ENABLE(WHEEL_EVENT_LATCHING)
@@ -980,7 +978,7 @@
std::unique_ptr<PerformanceLogging> m_performanceLogging;
#if ENABLE(WHEEL_EVENT_LATCHING)
- Vector<ScrollLatchingState> m_latchingState;
+ std::unique_ptr<ScrollLatchingState> m_latchingState;
#endif
#if PLATFORM(MAC) && (ENABLE(SERVICE_CONTROLS) || ENABLE(TELEPHONE_NUMBER_DETECTION))
std::unique_ptr<ServicesOverlayController> m_servicesOverlayController;
Modified: trunk/Source/WebCore/page/mac/EventHandlerMac.mm (259281 => 259282)
--- trunk/Source/WebCore/page/mac/EventHandlerMac.mm 2020-03-31 05:59:07 UTC (rev 259281)
+++ trunk/Source/WebCore/page/mac/EventHandlerMac.mm 2020-03-31 06:19:49 UTC (rev 259282)
@@ -980,23 +980,23 @@
if (scrollableContainer && scrollableArea && page) {
bool startingAtScrollLimit = scrolledToEdgeInDominantDirection(*scrollableContainer, *scrollableArea.get(), wheelEvent.deltaX(), wheelEvent.deltaY());
if (!startingAtScrollLimit) {
- ScrollLatchingState latchingState;
- latchingState.setStartedGestureAtScrollLimit(false);
- latchingState.setWheelEventElement(wheelEventTarget.get());
- latchingState.setFrame(&m_frame);
- latchingState.setScrollableContainer(scrollableContainer.get());
- latchingState.setWidgetIsLatched(result.isOverWidget());
- page->pushNewLatchingState(WTFMove(latchingState));
+ auto latchingState = WTF::makeUnique<ScrollLatchingState>();
+ latchingState->setStartedGestureAtScrollLimit(false);
+ latchingState->setWheelEventElement(wheelEventTarget.get());
+ latchingState->setFrame(&m_frame);
+ latchingState->setScrollableContainer(scrollableContainer.get());
+ latchingState->setWidgetIsLatched(result.isOverWidget());
+ page->setLatchingState(WTFMove(latchingState));
page->wheelEventDeltaFilter()->beginFilteringDeltas();
isOverWidget = result.isOverWidget();
}
- LOG_WITH_STREAM(ScrollLatching, stream << "EventHandler::platformPrepareForWheelEvents() - considering latching for " << wheelEvent << ", at scroll limit " << startingAtScrollLimit << ", latching state " << page->latchingStateStack());
+ LOG_WITH_STREAM(ScrollLatching, stream << "EventHandler::platformPrepareForWheelEvents() - considering latching for " << wheelEvent << ", at scroll limit " << startingAtScrollLimit << ", latching state " << ValueOrNull(page->latchingState()));
}
} else if (wheelEvent.shouldResetLatching()) {
clearLatchedState();
- LOG_WITH_STREAM(ScrollLatching, stream << "EventHandler::platformPrepareForWheelEvents() - reset latching for event " << wheelEvent << " latching state " << page->latchingStateStack());
+ LOG_WITH_STREAM(ScrollLatching, stream << "EventHandler::platformPrepareForWheelEvents() - reset latching for event " << wheelEvent << " latching state " << ValueOrNull(page->latchingState()));
}
if (!wheelEvent.shouldResetLatching() && latchingState && latchingState->wheelEventElement()) {
Modified: trunk/Source/WebCore/page/scrolling/ScrollLatchingState.h (259281 => 259282)
--- trunk/Source/WebCore/page/scrolling/ScrollLatchingState.h 2020-03-31 05:59:07 UTC (rev 259281)
+++ trunk/Source/WebCore/page/scrolling/ScrollLatchingState.h 2020-03-31 06:19:49 UTC (rev 259282)
@@ -38,6 +38,7 @@
class Frame;
class ScrollLatchingState final {
+ WTF_MAKE_FAST_ALLOCATED;
public:
ScrollLatchingState();
~ScrollLatchingState();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes