diff options
| author | pdr <pdr@chromium.org> | 2016-03-02 09:41:41 -0800 |
|---|---|---|
| committer | Commit bot <commit-bot@chromium.org> | 2016-03-02 17:42:55 +0000 |
| commit | 608439f1b101096f0c37d8a6577cd37d54a4514f (patch) | |
| tree | 6f5833e45beba7e1b3425aba3faeb988c32c3d55 | |
| parent | 1ce82ea96b06b419a7c82090cd4c561d6bb11da4 (diff) | |
| download | chromium_src-608439f1b101096f0c37d8a6577cd37d54a4514f.zip chromium_src-608439f1b101096f0c37d8a6577cd37d54a4514f.tar.gz chromium_src-608439f1b101096f0c37d8a6577cd37d54a4514f.tar.bz2 | |
Cleanup FrameView::setScrollOrigin to make it easier to understand
I found the logic in FrameView::setScrollOrigin very hard to follow
when working on https://codereview.chromium.org/1753173002. This patch
removes the function entirely by merging it into the only caller. This
makes the simple optimization of not updating scrollbars twice easier
to explain with a comment.
Review URL: https://codereview.chromium.org/1749393003
Cr-Commit-Position: refs/heads/master@{#378769}
| -rw-r--r-- | third_party/WebKit/Source/core/frame/FrameView.cpp | 23 | ||||
| -rw-r--r-- | third_party/WebKit/Source/core/frame/FrameView.h | 2 |
2 files changed, 10 insertions, 15 deletions
diff --git a/third_party/WebKit/Source/core/frame/FrameView.cpp b/third_party/WebKit/Source/core/frame/FrameView.cpp index 9edac1f..315cad0 100644 --- a/third_party/WebKit/Source/core/frame/FrameView.cpp +++ b/third_party/WebKit/Source/core/frame/FrameView.cpp @@ -549,7 +549,16 @@ void FrameView::adjustViewSize() const IntRect rect = layoutView->documentRect(); const IntSize& size = rect.size(); - setScrollOrigin(IntPoint(-rect.x(), -rect.y()), !m_frame->document()->printing(), size == contentsSize()); + + const IntPoint origin(-rect.x(), -rect.y()); + if (scrollOrigin() != origin) { + ScrollableArea::setScrollOrigin(origin); + // setContentSize (below) also calls updateScrollbars so we can avoid + // updating scrollbars twice by skipping the call here when the content + // size does not change. + if (!m_frame->document()->printing() && size == contentsSize()) + updateScrollbars(scrollOffsetDouble()); + } setContentsSize(size); } @@ -3914,18 +3923,6 @@ void FrameView::hide() Widget::hide(); } -void FrameView::setScrollOrigin(const IntPoint& origin, bool updatePositionAtAll, bool updatePositionSynchronously) -{ - if (scrollOrigin() == origin) - return; - - ScrollableArea::setScrollOrigin(origin); - - // Update if the scroll origin changes, since our position will be different if the content size did not change. - if (updatePositionAtAll && updatePositionSynchronously) - updateScrollbars(scrollOffsetDouble()); -} - int FrameView::viewportWidth() const { int viewportWidth = layoutSize(IncludeScrollbars).width(); diff --git a/third_party/WebKit/Source/core/frame/FrameView.h b/third_party/WebKit/Source/core/frame/FrameView.h index 3778766..cdb5033 100644 --- a/third_party/WebKit/Source/core/frame/FrameView.h +++ b/third_party/WebKit/Source/core/frame/FrameView.h @@ -611,8 +611,6 @@ protected: void scrollContentsIfNeeded(); - void setScrollOrigin(const IntPoint&, bool updatePositionAtAll, bool updatePositionSynchronously); - enum ComputeScrollbarExistenceOption { FirstPass, Incremental |
