From e14391e94c850b8bd03680c23b38978db68687a8 Mon Sep 17 00:00:00 2001 From: John Reck Date: Thu, 4 Nov 2010 12:00:17 -0700 Subject: Merge Webkit at r70949: Initial merge by git. Change-Id: I77b8645c083b5d0da8dba73ed01d4014aab9848e --- WebCore/platform/gtk/ScrollViewGtk.cpp | 61 ++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 22 deletions(-) (limited to 'WebCore/platform/gtk/ScrollViewGtk.cpp') diff --git a/WebCore/platform/gtk/ScrollViewGtk.cpp b/WebCore/platform/gtk/ScrollViewGtk.cpp index ebcdaa1..a8c7562 100644 --- a/WebCore/platform/gtk/ScrollViewGtk.cpp +++ b/WebCore/platform/gtk/ScrollViewGtk.cpp @@ -78,48 +78,29 @@ PassRefPtr ScrollView::createScrollbar(ScrollbarOrientation orientati return MainFrameScrollbarGtk::create(this, orientation, m_verticalAdjustment.get()); } -/* - * The following is assumed: - * (hadj && vadj) || (!hadj && !vadj) - */ -void ScrollView::setGtkAdjustments(GtkAdjustment* hadj, GtkAdjustment* vadj, bool resetValues) +void ScrollView::setHorizontalAdjustment(GtkAdjustment* hadj, bool resetValues) { - ASSERT(!hadj == !vadj); - - // If this is a non-main frame ScrollView, we do not want to set the - // m_horizontalAdjustments & m_verticalAdjustments members. At the same - // time we want to to allow FrameLoaderClientGtk.cpp to call - // ScrollView::setGtkAdjustments(0, 0) unconditionally. ASSERT(!parent() || !hadj); if (parent()) return; m_horizontalAdjustment = hadj; - m_verticalAdjustment = vadj; if (!m_horizontalAdjustment) { MainFrameScrollbarGtk* hScrollbar = reinterpret_cast(horizontalScrollbar()); if (hScrollbar) hScrollbar->detachAdjustment(); - MainFrameScrollbarGtk* vScrollbar = reinterpret_cast(verticalScrollbar()); - if (vScrollbar) - vScrollbar->detachAdjustment(); - return; } // We may be lacking scrollbars when returning to a cached // page, this kicks the page to recreate the scrollbars. - setHasVerticalScrollbar(true); setHasHorizontalScrollbar(true); MainFrameScrollbarGtk* hScrollbar = reinterpret_cast(horizontalScrollbar()); hScrollbar->attachAdjustment(m_horizontalAdjustment.get()); - MainFrameScrollbarGtk* vScrollbar = reinterpret_cast(verticalScrollbar()); - vScrollbar->attachAdjustment(m_verticalAdjustment.get()); - // We used to reset everything to 0 here, but when page cache // is enabled we reuse FrameViews that are cached. Since their // size is not going to change when being restored, (which is @@ -127,7 +108,6 @@ void ScrollView::setGtkAdjustments(GtkAdjustment* hadj, GtkAdjustment* vadj, boo // set in the normal case), we make sure they are up-to-date // here. This is needed for the parent scrolling widget to be // able to report correct values. - int horizontalPageStep = max(max(frameRect().width() * Scrollbar::minFractionToStepWhenPaging(), frameRect().width() - Scrollbar::maxOverlapBetweenPages()), 1); gtk_adjustment_configure(m_horizontalAdjustment.get(), resetValues ? 0 : scrollOffset().width(), 0, @@ -135,8 +115,39 @@ void ScrollView::setGtkAdjustments(GtkAdjustment* hadj, GtkAdjustment* vadj, boo resetValues ? 0 : Scrollbar::pixelsPerLineStep(), resetValues ? 0 : horizontalPageStep, resetValues ? 0 : frameRect().width()); +} + +void ScrollView::setVerticalAdjustment(GtkAdjustment* vadj, bool resetValues) +{ + ASSERT(!parent() || !vadj); + if (parent()) + return; + + m_verticalAdjustment = vadj; + + if (!m_verticalAdjustment) { + MainFrameScrollbarGtk* vScrollbar = reinterpret_cast(verticalScrollbar()); + if (vScrollbar) + vScrollbar->detachAdjustment(); + + return; + } + + // We may be lacking scrollbars when returning to a cached + // page, this kicks the page to recreate the scrollbars. + setHasVerticalScrollbar(true); + + MainFrameScrollbarGtk* vScrollbar = reinterpret_cast(verticalScrollbar()); + vScrollbar->attachAdjustment(m_verticalAdjustment.get()); - int verticalPageStep = max(max(frameRect().height() * Scrollbar::minFractionToStepWhenPaging(), frameRect().height() - Scrollbar::maxOverlapBetweenPages()), 1); + // We used to reset everything to 0 here, but when page cache + // is enabled we reuse FrameViews that are cached. Since their + // size is not going to change when being restored, (which is + // what would cause the upper limit in the adjusments to be + // set in the normal case), we make sure they are up-to-date + // here. This is needed for the parent scrolling widget to be + // able to report correct values. + int verticalPageStep = max(max(frameRect().width() * Scrollbar::minFractionToStepWhenPaging(), frameRect().width() - Scrollbar::maxOverlapBetweenPages()), 1); gtk_adjustment_configure(m_verticalAdjustment.get(), resetValues ? 0 : scrollOffset().height(), 0, resetValues ? 0 : contentsSize().height(), @@ -145,6 +156,12 @@ void ScrollView::setGtkAdjustments(GtkAdjustment* hadj, GtkAdjustment* vadj, boo resetValues ? 0 : frameRect().height()); } +void ScrollView::setGtkAdjustments(GtkAdjustment* hadj, GtkAdjustment* vadj, bool resetValues) +{ + setHorizontalAdjustment(hadj, resetValues); + setVerticalAdjustment(vadj, resetValues); +} + void ScrollView::platformAddChild(Widget* child) { } -- cgit v1.1