- Revision
- 243905
- Author
- [email protected]
- Date
- 2019-04-04 14:10:29 -0700 (Thu, 04 Apr 2019)
Log Message
Move "inProgrammaticScroll" down to ScrollableArea
https://bugs.webkit.org/show_bug.cgi?id=196614
Reviewed by Zalan Bujtas.
A future patch will need to update "inProgrammaticScroll" on RenderLayers, so push
inProgrammaticScroll() down to ScrollableArea.
ScrollableArea already has "isScrolledProgrammatically", which I rename to "scrollShouldClearLatchedState"
to reduce confusion. It might be possible to remove this in future with some refactoring.
Sadly we can no longer use SetForScope<> in FrameView after this change so add some manual save/restore code.
* dom/Element.cpp:
(WebCore::Element::setScrollLeft):
(WebCore::Element::setScrollTop):
* page/EventHandler.cpp:
(WebCore::EventHandler::completeWidgetWheelEvent):
(WebCore::EventHandler::handleWheelEvent):
* page/FrameView.cpp:
(WebCore::FrameView::setFrameRect):
(WebCore::FrameView::topContentInsetDidChange):
(WebCore::FrameView::updateLayoutViewport):
(WebCore::FrameView::setScrollPosition):
(WebCore::FrameView::setWasScrolledByUser):
* page/FrameView.h:
* platform/ScrollView.h:
(WebCore::ScrollView::inProgrammaticScroll const): Deleted.
* platform/ScrollableArea.cpp:
(WebCore::ScrollableArea::ScrollableArea):
* platform/ScrollableArea.h:
(WebCore::ScrollableArea::inProgrammaticScroll const):
(WebCore::ScrollableArea::setInProgrammaticScroll):
(WebCore::ScrollableArea::scrollShouldClearLatchedState const):
(WebCore::ScrollableArea::setScrollShouldClearLatchedState):
(WebCore::ScrollableArea::isScrolledProgrammatically const): Deleted.
(WebCore::ScrollableArea::setScrolledProgrammatically): Deleted.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (243904 => 243905)
--- trunk/Source/WebCore/ChangeLog 2019-04-04 20:54:02 UTC (rev 243904)
+++ trunk/Source/WebCore/ChangeLog 2019-04-04 21:10:29 UTC (rev 243905)
@@ -1,3 +1,43 @@
+2019-04-04 Simon Fraser <[email protected]>
+
+ Move "inProgrammaticScroll" down to ScrollableArea
+ https://bugs.webkit.org/show_bug.cgi?id=196614
+
+ Reviewed by Zalan Bujtas.
+
+ A future patch will need to update "inProgrammaticScroll" on RenderLayers, so push
+ inProgrammaticScroll() down to ScrollableArea.
+
+ ScrollableArea already has "isScrolledProgrammatically", which I rename to "scrollShouldClearLatchedState"
+ to reduce confusion. It might be possible to remove this in future with some refactoring.
+
+ Sadly we can no longer use SetForScope<> in FrameView after this change so add some manual save/restore code.
+
+ * dom/Element.cpp:
+ (WebCore::Element::setScrollLeft):
+ (WebCore::Element::setScrollTop):
+ * page/EventHandler.cpp:
+ (WebCore::EventHandler::completeWidgetWheelEvent):
+ (WebCore::EventHandler::handleWheelEvent):
+ * page/FrameView.cpp:
+ (WebCore::FrameView::setFrameRect):
+ (WebCore::FrameView::topContentInsetDidChange):
+ (WebCore::FrameView::updateLayoutViewport):
+ (WebCore::FrameView::setScrollPosition):
+ (WebCore::FrameView::setWasScrolledByUser):
+ * page/FrameView.h:
+ * platform/ScrollView.h:
+ (WebCore::ScrollView::inProgrammaticScroll const): Deleted.
+ * platform/ScrollableArea.cpp:
+ (WebCore::ScrollableArea::ScrollableArea):
+ * platform/ScrollableArea.h:
+ (WebCore::ScrollableArea::inProgrammaticScroll const):
+ (WebCore::ScrollableArea::setInProgrammaticScroll):
+ (WebCore::ScrollableArea::scrollShouldClearLatchedState const):
+ (WebCore::ScrollableArea::setScrollShouldClearLatchedState):
+ (WebCore::ScrollableArea::isScrolledProgrammatically const): Deleted.
+ (WebCore::ScrollableArea::setScrolledProgrammatically): Deleted.
+
2019-04-04 Sihui Liu <[email protected]>
Leak of UniqueIDBDatabase in network process running layout tests
Modified: trunk/Source/WebCore/dom/Element.cpp (243904 => 243905)
--- trunk/Source/WebCore/dom/Element.cpp 2019-04-04 20:54:02 UTC (rev 243904)
+++ trunk/Source/WebCore/dom/Element.cpp 2019-04-04 21:10:29 UTC (rev 243905)
@@ -1140,7 +1140,7 @@
if (auto* renderer = renderBox()) {
renderer->setScrollLeft(static_cast<int>(newLeft * renderer->style().effectiveZoom()), ScrollType::Programmatic);
if (auto* scrollableArea = renderer->layer())
- scrollableArea->setScrolledProgrammatically(true);
+ scrollableArea->setScrollShouldClearLatchedState(true);
}
}
@@ -1157,7 +1157,7 @@
if (auto* renderer = renderBox()) {
renderer->setScrollTop(static_cast<int>(newTop * renderer->style().effectiveZoom()), ScrollType::Programmatic);
if (auto* scrollableArea = renderer->layer())
- scrollableArea->setScrolledProgrammatically(true);
+ scrollableArea->setScrollShouldClearLatchedState(true);
}
}
Modified: trunk/Source/WebCore/page/EventHandler.cpp (243904 => 243905)
--- trunk/Source/WebCore/page/EventHandler.cpp 2019-04-04 20:54:02 UTC (rev 243904)
+++ trunk/Source/WebCore/page/EventHandler.cpp 2019-04-04 21:10:29 UTC (rev 243905)
@@ -2749,7 +2749,7 @@
return false;
if (scrollableArea)
- scrollableArea->setScrolledProgrammatically(false);
+ scrollableArea->setScrollShouldClearLatchedState(false);
platformNotifyIfEndGesture(event, scrollableArea);
@@ -2812,10 +2812,10 @@
if (!element->dispatchWheelEvent(adjustedEvent)) {
m_isHandlingWheelEvent = false;
- if (scrollableArea && scrollableArea->isScrolledProgrammatically()) {
+ if (scrollableArea && scrollableArea->scrollShouldClearLatchedState()) {
// Web developer is controlling scrolling, so don't attempt to latch.
clearLatchedState();
- scrollableArea->setScrolledProgrammatically(false);
+ scrollableArea->setScrollShouldClearLatchedState(false);
}
platformNotifyIfEndGesture(adjustedEvent, scrollableArea);
@@ -2824,7 +2824,7 @@
}
if (scrollableArea)
- scrollableArea->setScrolledProgrammatically(false);
+ scrollableArea->setScrollShouldClearLatchedState(false);
bool handledEvent = platformCompleteWheelEvent(adjustedEvent, scrollableContainer.get(), scrollableArea);
platformNotifyIfEndGesture(adjustedEvent, scrollableArea);
Modified: trunk/Source/WebCore/page/FrameView.cpp (243904 => 243905)
--- trunk/Source/WebCore/page/FrameView.cpp 2019-04-04 20:54:02 UTC (rev 243904)
+++ trunk/Source/WebCore/page/FrameView.cpp 2019-04-04 21:10:29 UTC (rev 243905)
@@ -460,7 +460,8 @@
if (newRect == oldRect)
return;
// Every scroll that happens as the result of frame size change is programmatic.
- SetForScope<bool> changeInProgrammaticScroll(m_inProgrammaticScroll, true);
+ bool wasInProgrammaticScroll = inProgrammaticScroll();
+ setInProgrammaticScroll(true);
ScrollView::setFrameRect(newRect);
updateScrollableAreaSet();
@@ -474,6 +475,7 @@
frame().page()->pageOverlayController().didChangeViewSize();
viewportContentsChanged();
+ setInProgrammaticScroll(wasInProgrammaticScroll);
}
bool FrameView::scheduleAnimation()
@@ -1090,7 +1092,8 @@
layoutContext().layout();
// Every scroll that happens as the result of content inset change is programmatic.
- SetForScope<bool> changeInProgrammaticScroll(m_inProgrammaticScroll, true);
+ bool wasInProgrammaticScroll = inProgrammaticScroll();
+ setInProgrammaticScroll(true);
updateScrollbars(scrollPosition());
if (renderView->usesCompositing())
renderView->compositor().frameViewDidChangeSize();
@@ -1097,6 +1100,8 @@
if (TiledBacking* tiledBacking = this->tiledBacking())
tiledBacking->setTopContentInset(newTopContentInset);
+
+ setInProgrammaticScroll(wasInProgrammaticScroll);
}
void FrameView::topContentDirectionDidChange()
@@ -1670,7 +1675,7 @@
LOG_WITH_STREAM(Scrolling, stream << "stable origins: min: " << minStableLayoutViewportOrigin() << " max: "<< maxStableLayoutViewportOrigin());
if (m_layoutViewportOverrideRect) {
- if (m_inProgrammaticScroll) {
+ if (inProgrammaticScroll()) {
LOG_WITH_STREAM(Scrolling, stream << "computing new override layout viewport because of programmatic scrolling");
LayoutPoint newOrigin = computeLayoutViewportOrigin(visualViewportRect(), minStableLayoutViewportOrigin(), maxStableLayoutViewportOrigin(), layoutViewport, StickToDocumentBounds);
setLayoutViewportOverrideRect(LayoutRect(newOrigin, m_layoutViewportOverrideRect.value().size()));
@@ -2274,7 +2279,9 @@
{
LOG_WITH_STREAM(Scrolling, stream << "FrameView::setScrollPosition " << scrollPosition << " , clearing anchor");
- SetForScope<bool> changeInProgrammaticScroll(m_inProgrammaticScroll, true);
+ bool wasInProgrammaticScroll = inProgrammaticScroll();
+ setInProgrammaticScroll(true);
+
m_maintainScrollPositionAnchor = nullptr;
m_shouldScrollToFocusedElement = false;
m_delayedScrollToFocusedElementTimer.stop();
@@ -2282,6 +2289,8 @@
if (page && page->expectsWheelEventTriggers())
scrollAnimator().setWheelEventTestTrigger(page->testTrigger());
ScrollView::setScrollPosition(scrollPosition);
+
+ setInProgrammaticScroll(wasInProgrammaticScroll);
}
void FrameView::resetScrollAnchor()
@@ -4100,7 +4109,7 @@
m_shouldScrollToFocusedElement = false;
m_delayedScrollToFocusedElementTimer.stop();
- if (m_inProgrammaticScroll)
+ if (inProgrammaticScroll())
return;
m_maintainScrollPositionAnchor = nullptr;
if (m_wasScrolledByUser == wasScrolledByUser)
Modified: trunk/Source/WebCore/page/FrameView.h (243904 => 243905)
--- trunk/Source/WebCore/page/FrameView.h 2019-04-04 20:54:02 UTC (rev 243904)
+++ trunk/Source/WebCore/page/FrameView.h 2019-04-04 21:10:29 UTC (rev 243905)
@@ -555,9 +555,6 @@
const Pagination& pagination() const;
void setPagination(const Pagination&);
- bool inProgrammaticScroll() const final { return m_inProgrammaticScroll; }
- void setInProgrammaticScroll(bool programmaticScroll) { m_inProgrammaticScroll = programmaticScroll; }
-
#if ENABLE(CSS_DEVICE_ADAPTATION)
IntSize initialViewportSize() const { return m_initialViewportSize; }
void setInitialViewportSize(const IntSize& size) { m_initialViewportSize = size; }
@@ -923,7 +920,6 @@
bool m_isTrackingRepaints { false }; // Used for testing.
bool m_wasScrolledByUser { false };
- bool m_inProgrammaticScroll { false };
bool m_shouldScrollToFocusedElement { false };
bool m_isPainting { false };
Modified: trunk/Source/WebCore/platform/ScrollView.h (243904 => 243905)
--- trunk/Source/WebCore/platform/ScrollView.h 2019-04-04 20:54:02 UTC (rev 243904)
+++ trunk/Source/WebCore/platform/ScrollView.h 2019-04-04 21:10:29 UTC (rev 243905)
@@ -196,8 +196,6 @@
LegacyTileCache* legacyTileCache();
#endif
- virtual bool inProgrammaticScroll() const { return false; }
-
// Size available for view contents, including content inset areas. Not affected by zooming.
IntSize sizeForVisibleContent(VisibleContentRectIncludesScrollbars = ExcludeScrollbars) const;
// FIXME: remove this. It's only used for the incorrectly behaving ScrollView::unobscuredContentRectInternal().
Modified: trunk/Source/WebCore/platform/ScrollableArea.cpp (243904 => 243905)
--- trunk/Source/WebCore/platform/ScrollableArea.cpp 2019-04-04 20:54:02 UTC (rev 243904)
+++ trunk/Source/WebCore/platform/ScrollableArea.cpp 2019-04-04 21:10:29 UTC (rev 243905)
@@ -66,7 +66,8 @@
, m_horizontalScrollElasticity(ScrollElasticityNone)
, m_scrollbarOverlayStyle(ScrollbarOverlayStyleDefault)
, m_scrollOriginChanged(false)
- , m_scrolledProgrammatically(false)
+ , m_inProgrammaticScroll(false)
+ , m_scrollShouldClearLatchedState(false)
{
}
Modified: trunk/Source/WebCore/platform/ScrollableArea.h (243904 => 243905)
--- trunk/Source/WebCore/platform/ScrollableArea.h 2019-04-04 20:54:02 UTC (rev 243904)
+++ trunk/Source/WebCore/platform/ScrollableArea.h 2019-04-04 21:10:29 UTC (rev 243905)
@@ -228,9 +228,12 @@
WEBCORE_EXPORT virtual bool scrolledToLeft() const;
WEBCORE_EXPORT virtual bool scrolledToRight() const;
- bool isScrolledProgrammatically() const { return m_scrolledProgrammatically; }
- void setScrolledProgrammatically(bool state) { m_scrolledProgrammatically = state; }
+ bool inProgrammaticScroll() const { return m_inProgrammaticScroll; }
+ void setInProgrammaticScroll(bool inProgrammaticScroll) { m_inProgrammaticScroll = inProgrammaticScroll; }
+ bool scrollShouldClearLatchedState() const { return m_scrollShouldClearLatchedState; }
+ void setScrollShouldClearLatchedState(bool shouldClear) { m_scrollShouldClearLatchedState = shouldClear; }
+
enum VisibleContentRectIncludesScrollbars { ExcludeScrollbars, IncludeScrollbars };
enum VisibleContentRectBehavior {
ContentsVisibleRect,
@@ -391,7 +394,8 @@
unsigned m_scrollbarOverlayStyle : 2; // ScrollbarOverlayStyle
unsigned m_scrollOriginChanged : 1;
- unsigned m_scrolledProgrammatically : 1;
+ unsigned m_inProgrammaticScroll : 1;
+ unsigned m_scrollShouldClearLatchedState : 1;
};
} // namespace WebCore