Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / platform / scroll / ScrollView.cpp
index 4b4840e..12c7d97 100644 (file)
@@ -41,7 +41,6 @@ ScrollView::ScrollView()
     , m_verticalScrollbarMode(ScrollbarAuto)
     , m_horizontalScrollbarLock(false)
     , m_verticalScrollbarLock(false)
-    , m_canBlitOnScroll(true)
     , m_scrollbarsAvoidingResizer(0)
     , m_scrollbarsSuppressed(false)
     , m_inUpdateScrollbars(false)
@@ -81,7 +80,7 @@ void ScrollView::setHasHorizontalScrollbar(bool hasBar)
     } else if (!hasBar && m_horizontalScrollbar) {
         willRemoveScrollbar(m_horizontalScrollbar.get(), HorizontalScrollbar);
         removeChild(m_horizontalScrollbar.get());
-        m_horizontalScrollbar = 0;
+        m_horizontalScrollbar = nullptr;
     }
 }
 
@@ -95,7 +94,7 @@ void ScrollView::setHasVerticalScrollbar(bool hasBar)
     } else if (!hasBar && m_verticalScrollbar) {
         willRemoveScrollbar(m_verticalScrollbar.get(), VerticalScrollbar);
         removeChild(m_verticalScrollbar.get());
-        m_verticalScrollbar = 0;
+        m_verticalScrollbar = nullptr;
     }
 }
 
@@ -164,14 +163,9 @@ void ScrollView::setCanHaveScrollbars(bool canScroll)
     setScrollbarModes(newHorizontalMode, newVerticalMode);
 }
 
-void ScrollView::setCanBlitOnScroll(bool b)
+bool ScrollView::shouldAttemptToScrollUsingFastPath() const
 {
-    m_canBlitOnScroll = b;
-}
-
-bool ScrollView::canBlitOnScroll() const
-{
-    return m_canBlitOnScroll;
+    return true;
 }
 
 void ScrollView::setPaintsEntireContents(bool paintsEntireContents)
@@ -280,9 +274,10 @@ void ScrollView::scrollTo(const IntSize& newOffset)
     if (scrollbarsSuppressed())
         return;
 
-    repaintFixedElementsAfterScrolling();
-    scrollContents(scrollDelta);
-    updateFixedElementsAfterScrolling();
+    if (isFrameView())
+        m_pendingScrollDelta += scrollDelta;
+    else
+        scrollContents(scrollDelta);
 }
 
 void ScrollView::setScrollPosition(const IntPoint& scrollPoint)
@@ -521,6 +516,15 @@ IntRect ScrollView::rectToCopyOnScroll() const
     return scrollViewRect;
 }
 
+void ScrollView::scrollContentsIfNeeded()
+{
+    if (m_pendingScrollDelta.isZero())
+        return;
+    IntSize scrollDelta = m_pendingScrollDelta;
+    m_pendingScrollDelta = IntSize();
+    scrollContents(scrollDelta);
+}
+
 void ScrollView::scrollContents(const IntSize& scrollDelta)
 {
     HostWindow* window = hostWindow();
@@ -544,15 +548,8 @@ void ScrollView::scrollContents(const IntSize& scrollDelta)
         window->invalidateContentsAndRootView(panScrollIconDirtyRect);
     }
 
-    if (canBlitOnScroll()) { // The main frame can just blit the WebView window
-        // FIXME: Find a way to scroll subframes with this faster path
-        if (!scrollContentsFastPath(-scrollDelta, scrollViewRect, clipRect))
-            scrollContentsSlowPath(updateRect);
-    } else {
-       // We need to go ahead and repaint the entire backing store.  Do it now before moving the
-       // windowed plugins.
-       scrollContentsSlowPath(updateRect);
-    }
+    if (!shouldAttemptToScrollUsingFastPath() || !scrollContentsFastPath(-scrollDelta, scrollViewRect, clipRect))
+        scrollContentsSlowPath(updateRect);
 
     // Invalidate the overhang areas if they are visible.
     updateOverhangAreas();
@@ -632,14 +629,6 @@ IntRect ScrollView::contentsToScreen(const IntRect& rect) const
     return window->rootViewToScreen(contentsToRootView(rect));
 }
 
-IntPoint ScrollView::screenToContents(const IntPoint& point) const
-{
-    HostWindow* window = hostWindow();
-    if (!window)
-        return IntPoint();
-    return rootViewToContents(window->screenToRootView(point));
-}
-
 bool ScrollView::containsScrollbarsAvoidingResizer() const
 {
     return !m_scrollbarsAvoidingResizer;
@@ -724,13 +713,6 @@ void ScrollView::frameRectsChanged()
         (*current)->frameRectsChanged();
 }
 
-void ScrollView::clipRectChanged()
-{
-    HashSet<RefPtr<Widget> >::const_iterator end = m_children.end();
-    for (HashSet<RefPtr<Widget> >::const_iterator current = m_children.begin(); current != end; ++current)
-        (*current)->clipRectChanged();
-}
-
 static void positionScrollbarLayer(GraphicsLayer* graphicsLayer, Scrollbar* scrollbar)
 {
     if (!graphicsLayer || !scrollbar)
@@ -825,11 +807,8 @@ bool ScrollView::isScrollCornerVisible() const
     return !scrollCornerRect().isEmpty();
 }
 
-void ScrollView::scrollbarStyleChanged(int, bool forceUpdate)
+void ScrollView::scrollbarStyleChanged()
 {
-    if (!forceUpdate)
-        return;
-
     contentsResized();
     updateScrollbars(scrollOffset());
     positionScrollbarLayers();
@@ -914,6 +893,7 @@ void ScrollView::paint(GraphicsContext* context, const IntRect& rect)
         scrollViewDirtyRect.intersect(visibleAreaWithScrollbars);
         context->translate(x(), y());
         scrollViewDirtyRect.moveBy(-location());
+        context->clip(IntRect(IntPoint(), visibleAreaWithScrollbars.size()));
 
         paintScrollbars(context, scrollViewDirtyRect);
     }
@@ -1140,13 +1120,4 @@ void ScrollView::setScrollOrigin(const IntPoint& origin, bool updatePositionAtAl
         updateScrollbars(scrollOffset());
 }
 
-int ScrollView::pageStep(ScrollbarOrientation orientation) const
-{
-    int length = (orientation == HorizontalScrollbar) ? visibleWidth() : visibleHeight();
-    int minPageStep = static_cast<float>(length) * minFractionToStepWhenPaging();
-    int pageStep = std::max(minPageStep, length - maxOverlapBetweenPages());
-
-    return std::max(pageStep, 1);
-}
-
 } // namespace WebCore