Skip to content

Commit

Permalink
Use WTF::Optional for ScrollView's m_deferredScrollDelta / m_deferred…
Browse files Browse the repository at this point in the history
…ScrollOffsets

https://bugs.webkit.org/show_bug.cgi?id=157747

Reviewed by Zalan Bujtas.

Use WTF::Optional for ScrollView's m_deferredScrollDelta / m_deferredScrollOffsets
instead of std::unique_ptr as it is more suited for this purpose.

* platform/ScrollView.cpp:
(WebCore::ScrollView::scrollOffsetChangedViaPlatformWidget):
(WebCore::ScrollView::handleDeferredScrollUpdateAfterContentSizeChange):
(WebCore::ScrollView::scrollTo):
* platform/ScrollView.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@200963 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
cdumez@apple.com committed May 16, 2016
1 parent 4d22963 commit caf9068
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
16 changes: 16 additions & 0 deletions Source/WebCore/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
2016-05-16 Chris Dumez <cdumez@apple.com>

Use WTF::Optional for ScrollView's m_deferredScrollDelta / m_deferredScrollOffsets
https://bugs.webkit.org/show_bug.cgi?id=157747

Reviewed by Zalan Bujtas.

Use WTF::Optional for ScrollView's m_deferredScrollDelta / m_deferredScrollOffsets
instead of std::unique_ptr as it is more suited for this purpose.

* platform/ScrollView.cpp:
(WebCore::ScrollView::scrollOffsetChangedViaPlatformWidget):
(WebCore::ScrollView::handleDeferredScrollUpdateAfterContentSizeChange):
(WebCore::ScrollView::scrollTo):
* platform/ScrollView.h:

2016-05-16 Zalan Bujtas <zalan@apple.com>

containingBlockFor*Position functions should take the renderer instead of the parent.
Expand Down
12 changes: 6 additions & 6 deletions Source/WebCore/platform/ScrollView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ void ScrollView::scrollOffsetChangedViaPlatformWidget(const ScrollOffset& oldOff
// is not complete. Instead, defer the scroll event until the layout finishes.
if (shouldDeferScrollUpdateAfterContentSizeChange()) {
// We only care about the most recent scroll position change request
m_deferredScrollOffsets = std::make_unique<std::pair<ScrollOffset, ScrollOffset>>(std::make_pair(oldOffset, newOffset));
m_deferredScrollOffsets = std::make_pair(oldOffset, newOffset);
return;
}

Expand All @@ -465,12 +465,12 @@ void ScrollView::handleDeferredScrollUpdateAfterContentSizeChange()
ASSERT(static_cast<bool>(m_deferredScrollDelta) != static_cast<bool>(m_deferredScrollOffsets));

if (m_deferredScrollDelta)
completeUpdatesAfterScrollTo(*m_deferredScrollDelta);
completeUpdatesAfterScrollTo(m_deferredScrollDelta.value());
else if (m_deferredScrollOffsets)
scrollOffsetChangedViaPlatformWidgetImpl(m_deferredScrollOffsets->first, m_deferredScrollOffsets->second);
scrollOffsetChangedViaPlatformWidgetImpl(m_deferredScrollOffsets.value().first, m_deferredScrollOffsets.value().second);

m_deferredScrollDelta = nullptr;
m_deferredScrollOffsets = nullptr;
m_deferredScrollDelta = Nullopt;
m_deferredScrollOffsets = Nullopt;
}

void ScrollView::scrollTo(const ScrollPosition& newPosition)
Expand All @@ -496,7 +496,7 @@ void ScrollView::scrollTo(const ScrollPosition& newPosition)
// is not complete. Instead, defer the scroll event until the layout finishes.
if (shouldDeferScrollUpdateAfterContentSizeChange()) {
ASSERT(!m_deferredScrollDelta);
m_deferredScrollDelta = std::make_unique<IntSize>(scrollDelta);
m_deferredScrollDelta = scrollDelta;
return;
}

Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/platform/ScrollView.h
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,8 @@ class ScrollView : public Widget, public ScrollableArea {
IntSize m_fixedLayoutSize;
IntSize m_contentsSize;

std::unique_ptr<IntSize> m_deferredScrollDelta; // Needed for WebKit scrolling
std::unique_ptr<std::pair<ScrollOffset, ScrollOffset>> m_deferredScrollOffsets; // Needed for platform widget scrolling
Optional<IntSize> m_deferredScrollDelta; // Needed for WebKit scrolling
Optional<std::pair<ScrollOffset, ScrollOffset>> m_deferredScrollOffsets; // Needed for platform widget scrolling

bool m_scrollbarsSuppressed;

Expand Down

0 comments on commit caf9068

Please sign in to comment.