Commit 336cdb95 authored by trchen@chromium.org's avatar trchen@chromium.org

Refactor ScrollView::updateScrollbars()

This CL splits ScrollView::updateScrollbars() into 3 independent helper
functions, namely:

computeScrollbarExistence() computes whether scrollbars are needed given
the current ScrollView state.

adjustScrollbarExistence() creates/removes scrollbars and invoke appropriate
callbacks to update layout (if applicable).

updateScrollbarGeometry() positions the scrollbars and pushes the scroll
extents.

Also we no longer do update scrollbar passes in recursion. Instead we do
it in a loop and early exits if updateScrollbars() is re-entered.

No tests as there should be no behavior difference.

Review URL: https://codereview.chromium.org/314583008

git-svn-id: svn://svn.chromium.org/blink/trunk@175852 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent d5298521
......@@ -120,8 +120,8 @@ public:
// included.
virtual IntRect visibleContentRect(IncludeScrollbarsInRect = ExcludeScrollbars) const OVERRIDE;
IntSize visibleSize() const { return visibleContentRect().size(); }
virtual int visibleWidth() const OVERRIDE { return visibleContentRect().width(); }
virtual int visibleHeight() const OVERRIDE { return visibleContentRect().height(); }
virtual int visibleWidth() const OVERRIDE FINAL { return visibleContentRect().width(); }
virtual int visibleHeight() const OVERRIDE FINAL { return visibleContentRect().height(); }
// visibleContentRect().size() is computed from unscaledVisibleContentSize() divided by the value of visibleContentScaleFactor.
// For the main frame, visibleContentScaleFactor is equal to the page's pageScaleFactor; it's 1 otherwise.
......@@ -282,12 +282,21 @@ protected:
virtual bool isVerticalDocument() const { return true; }
virtual bool isFlippedDocument() const { return false; }
enum ComputeScrollbarExistenceOption {
FirstPass,
Incremental
};
void computeScrollbarExistence(bool& newHasHorizontalScrollbar, bool& newHasVerticalScrollbar, ComputeScrollbarExistenceOption = FirstPass) const;
void updateScrollbarGeometry();
// Called to update the scrollbars to accurately reflect the state of the view.
void updateScrollbars(const IntSize& desiredOffset);
IntSize excludeScrollbars(const IntSize&) const;
private:
bool adjustScrollbarExistence(ComputeScrollbarExistenceOption = FirstPass);
RefPtr<Scrollbar> m_horizontalScrollbar;
RefPtr<Scrollbar> m_verticalScrollbar;
ScrollbarMode m_horizontalScrollbarMode;
......@@ -307,7 +316,6 @@ private:
bool m_scrollbarsSuppressed;
bool m_inUpdateScrollbars;
unsigned m_updateScrollbarsPass;
IntPoint m_panScrollIconPoint;
bool m_drawPanScrollIcon;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment