Title: [99002] trunk/Source/WebCore
Revision
99002
Author
x...@chromium.org
Date
2011-11-01 15:06:46 -0700 (Tue, 01 Nov 2011)

Log Message

Refactor: change Scrollable::m_scrollOrigin from protected to private.
https://bugs.webkit.org/show_bug.cgi?id=71236

Reviewed by Darin Adler.

Only refactor, no new tests needed.

* page/FrameView.cpp:
(WebCore::FrameView::scrollXForFixedPosition):
(WebCore::FrameView::scrollYForFixedPosition):
* platform/ScrollView.cpp:
(WebCore::ScrollView::maximumScrollPosition):
(WebCore::ScrollView::minimumScrollPosition):
(WebCore::ScrollView::setScrollOffset):
(WebCore::ScrollView::scrollPosition):
(WebCore::ScrollView::overhangAmount):
(WebCore::ScrollView::updateScrollbars):
(WebCore::ScrollView::wheelEvent):
* platform/ScrollView.h:
* platform/ScrollableArea.h:
(WebCore::ScrollableArea::setScrollOrigin):
(WebCore::ScrollableArea::setScrollOriginX):
(WebCore::ScrollableArea::setScrollOriginY):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::scrollTo):
(WebCore::RenderLayer::scrollPosition):
(WebCore::RenderLayer::minimumScrollPosition):
(WebCore::RenderLayer::maximumScrollPosition):
(WebCore::RenderLayer::computeScrollDimensions):
* rendering/RenderLayer.h:
(WebCore::RenderLayer::scrollXOffset):
(WebCore::RenderLayer::scrollYOffset):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (99001 => 99002)


--- trunk/Source/WebCore/ChangeLog	2011-11-01 21:54:05 UTC (rev 99001)
+++ trunk/Source/WebCore/ChangeLog	2011-11-01 22:06:46 UTC (rev 99002)
@@ -1,3 +1,38 @@
+2011-11-01  Xiaomei Ji  <x...@chromium.org>
+
+        Refactor: change Scrollable::m_scrollOrigin from protected to private.
+        https://bugs.webkit.org/show_bug.cgi?id=71236
+
+        Reviewed by Darin Adler.
+
+        Only refactor, no new tests needed.
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::scrollXForFixedPosition):
+        (WebCore::FrameView::scrollYForFixedPosition):
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::maximumScrollPosition):
+        (WebCore::ScrollView::minimumScrollPosition):
+        (WebCore::ScrollView::setScrollOffset):
+        (WebCore::ScrollView::scrollPosition):
+        (WebCore::ScrollView::overhangAmount):
+        (WebCore::ScrollView::updateScrollbars):
+        (WebCore::ScrollView::wheelEvent):
+        * platform/ScrollView.h:
+        * platform/ScrollableArea.h:
+        (WebCore::ScrollableArea::setScrollOrigin):
+        (WebCore::ScrollableArea::setScrollOriginX):
+        (WebCore::ScrollableArea::setScrollOriginY):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::scrollTo):
+        (WebCore::RenderLayer::scrollPosition):
+        (WebCore::RenderLayer::minimumScrollPosition):
+        (WebCore::RenderLayer::maximumScrollPosition):
+        (WebCore::RenderLayer::computeScrollDimensions):
+        * rendering/RenderLayer.h:
+        (WebCore::RenderLayer::scrollXOffset):
+        (WebCore::RenderLayer::scrollYOffset):
+
 2011-11-01  Dominic Cooney  <domin...@chromium.org>
 
         display: table-cell and box-sizing: border-box calculates content-box height

Modified: trunk/Source/WebCore/page/FrameView.cpp (99001 => 99002)


--- trunk/Source/WebCore/page/FrameView.cpp	2011-11-01 21:54:05 UTC (rev 99001)
+++ trunk/Source/WebCore/page/FrameView.cpp	2011-11-01 22:06:46 UTC (rev 99002)
@@ -1367,7 +1367,7 @@
 
     LayoutUnit x = scrollX();
 
-    if (!ScrollView::scrollOrigin().x()) {
+    if (!scrollOrigin().x()) {
         if (x < 0)
             x = 0;
         else if (x > maxX)
@@ -1402,7 +1402,7 @@
 
     LayoutUnit y = scrollY();
 
-    if (!ScrollView::scrollOrigin().y()) {
+    if (!scrollOrigin().y()) {
         if (y < 0)
             y = 0;
         else if (y > maxY)

Modified: trunk/Source/WebCore/platform/ScrollView.cpp (99001 => 99002)


--- trunk/Source/WebCore/platform/ScrollView.cpp	2011-11-01 21:54:05 UTC (rev 99001)
+++ trunk/Source/WebCore/platform/ScrollView.cpp	2011-11-01 22:06:46 UTC (rev 99002)
@@ -296,14 +296,14 @@
 
 IntPoint ScrollView::maximumScrollPosition() const
 {
-    IntPoint maximumOffset(contentsWidth() - visibleWidth() - m_scrollOrigin.x(), contentsHeight() - visibleHeight() - m_scrollOrigin.y());
+    IntPoint maximumOffset(contentsWidth() - visibleWidth() - scrollOrigin().x(), contentsHeight() - visibleHeight() - scrollOrigin().y());
     maximumOffset.clampNegativeToZero();
     return maximumOffset;
 }
 
 IntPoint ScrollView::minimumScrollPosition() const
 {
-    return IntPoint(-m_scrollOrigin.x(), -m_scrollOrigin.y());
+    return IntPoint(-scrollOrigin().x(), -scrollOrigin().y());
 }
 
 IntPoint ScrollView::adjustScrollPositionWithinRange(const IntPoint& scrollPoint) const
@@ -337,8 +337,8 @@
     }
 
     IntSize newOffset = m_scrollOffset;
-    newOffset.setWidth(horizontalOffset - m_scrollOrigin.x());
-    newOffset.setHeight(verticalOffset - m_scrollOrigin.y());
+    newOffset.setWidth(horizontalOffset - scrollOrigin().x());
+    newOffset.setHeight(verticalOffset - scrollOrigin().y());
 
     scrollTo(newOffset);
 }
@@ -360,9 +360,9 @@
 int ScrollView::scrollPosition(Scrollbar* scrollbar) const
 {
     if (scrollbar->orientation() == HorizontalScrollbar)
-        return scrollPosition().x() + m_scrollOrigin.x();
+        return scrollPosition().x() + scrollOrigin().x();
     if (scrollbar->orientation() == VerticalScrollbar)
-        return scrollPosition().y() + m_scrollOrigin.y();
+        return scrollPosition().y() + scrollOrigin().y();
     return 0;
 }
 
@@ -408,13 +408,13 @@
 {
     IntSize stretch;
 
-    int physicalScrollY = scrollPosition().y() + m_scrollOrigin.y();
+    int physicalScrollY = scrollPosition().y() + scrollOrigin().y();
     if (physicalScrollY < 0)
         stretch.setHeight(physicalScrollY);
     else if (contentsHeight() && physicalScrollY > contentsHeight() - visibleHeight())
         stretch.setHeight(physicalScrollY - (contentsHeight() - visibleHeight()));
 
-    int physicalScrollX = scrollPosition().x() + m_scrollOrigin.x();
+    int physicalScrollX = scrollPosition().x() + scrollOrigin().x();
     if (physicalScrollX < 0)
         stretch.setWidth(physicalScrollX);
     else if (contentsWidth() && physicalScrollX > contentsWidth() - visibleWidth())
@@ -493,8 +493,8 @@
             newHasHorizontalScrollbar = false;
 
         if (hasHorizontalScrollbar != newHasHorizontalScrollbar && (hasHorizontalScrollbar || !avoidScrollbarCreation())) {
-            if (m_scrollOrigin.y() && !newHasHorizontalScrollbar)
-                m_scrollOrigin.setY(m_scrollOrigin.y() - m_horizontalScrollbar->height());
+            if (scrollOrigin().y() && !newHasHorizontalScrollbar)
+                setScrollOriginY(scrollOrigin().y() - m_horizontalScrollbar->height());
             if (m_horizontalScrollbar)
                 m_horizontalScrollbar->invalidate();
             setHasHorizontalScrollbar(newHasHorizontalScrollbar);
@@ -502,8 +502,8 @@
         }
 
         if (hasVerticalScrollbar != newHasVerticalScrollbar && (hasVerticalScrollbar || !avoidScrollbarCreation())) {
-            if (m_scrollOrigin.x() && !newHasVerticalScrollbar)
-                m_scrollOrigin.setX(m_scrollOrigin.x() - m_verticalScrollbar->width());
+            if (scrollOrigin().x() && !newHasVerticalScrollbar)
+                setScrollOriginX(scrollOrigin().x() - m_verticalScrollbar->width());
             if (m_verticalScrollbar)
                 m_verticalScrollbar->invalidate();
             setHasVerticalScrollbar(newHasVerticalScrollbar);
@@ -583,7 +583,7 @@
             invalidateScrollCornerRect(oldScrollCornerRect);
     }
 
-    IntPoint scrollPoint = adjustScrollPositionWithinRange(IntPoint(desiredOffset)) + IntSize(m_scrollOrigin.x(), m_scrollOrigin.y());
+    IntPoint scrollPoint = adjustScrollPositionWithinRange(IntPoint(desiredOffset)) + IntSize(scrollOrigin().x(), scrollOrigin().y());
     if (scrollPoint != scrollPosition())
         ScrollableArea::scrollToOffsetWithoutAnimation(scrollPoint);
 
@@ -1076,7 +1076,7 @@
     int horizontalScrollbarHeight = (horizontalScrollbar() && !horizontalScrollbar()->isOverlayScrollbar())
         ? horizontalScrollbar()->height() : 0;
 
-    int physicalScrollY = scrollPosition().y() + m_scrollOrigin.y();
+    int physicalScrollY = scrollPosition().y() + scrollOrigin().y();
     if (physicalScrollY < 0) {
         horizontalOverhangRect = frameRect();
         horizontalOverhangRect.setHeight(-physicalScrollY);
@@ -1087,7 +1087,7 @@
         horizontalOverhangRect.setHeight(height);
     }
 
-    int physicalScrollX = scrollPosition().x() + m_scrollOrigin.x();
+    int physicalScrollX = scrollPosition().x() + scrollOrigin().x();
     if (physicalScrollX < 0) {
         verticalOverhangRect.setWidth(-physicalScrollX);
         verticalOverhangRect.setHeight(frameRect().height() - horizontalOverhangRect.height());
@@ -1260,10 +1260,10 @@
 
 void ScrollView::setScrollOrigin(const IntPoint& origin, bool updatePositionAtAll, bool updatePositionSynchronously)
 {
-    if (m_scrollOrigin == origin)
+    if (scrollOrigin() == origin)
         return;
 
-    m_scrollOrigin = origin;
+    ScrollableArea::setScrollOrigin(origin);
 
     if (platformWidget()) {
         platformSetScrollOrigin(origin, updatePositionAtAll, updatePositionSynchronously);

Modified: trunk/Source/WebCore/platform/ScrollView.h (99001 => 99002)


--- trunk/Source/WebCore/platform/ScrollView.h	2011-11-01 21:54:05 UTC (rev 99001)
+++ trunk/Source/WebCore/platform/ScrollView.h	2011-11-01 22:06:46 UTC (rev 99002)
@@ -319,7 +319,6 @@
     virtual void scrollContentsSlowPath(const IntRect& updateRect);
 
     void setScrollOrigin(const IntPoint&, bool updatePositionAtAll, bool updatePositionSynchronously);
-    IntPoint scrollOrigin() const { return m_scrollOrigin; }
 
     // Subclassed by FrameView to check the writing-mode of the document.
     virtual bool isVerticalDocument() const { return true; }

Modified: trunk/Source/WebCore/platform/ScrollableArea.h (99001 => 99002)


--- trunk/Source/WebCore/platform/ScrollableArea.h	2011-11-01 21:54:05 UTC (rev 99001)
+++ trunk/Source/WebCore/platform/ScrollableArea.h	2011-11-01 22:06:46 UTC (rev 99002)
@@ -166,6 +166,10 @@
     void setScrollOffsetFromInternals(const IntPoint&);
 
 protected:
+    void setScrollOrigin(const IntPoint& origin) { m_scrollOrigin = origin; } 
+    void setScrollOriginX(int x) { m_scrollOrigin.setX(x); }
+    void setScrollOriginY(int y) { m_scrollOrigin.setY(y); }
+
     virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) = 0;
     virtual void invalidateScrollCornerRect(const IntRect&) = 0;
 
@@ -181,19 +185,6 @@
     bool hasLayerForVerticalScrollbar() const;
     bool hasLayerForScrollCorner() const;
 
-    // There are 8 possible combinations of writing mode and direction. Scroll origin will be non-zero in the x or y axis
-    // if there is any reversed direction or writing-mode. The combinations are:
-    // writing-mode / direction     scrollOrigin.x() set    scrollOrigin.y() set
-    // horizontal-tb / ltr          NO                      NO
-    // horizontal-tb / rtl          YES                     NO
-    // horizontal-bt / ltr          NO                      YES
-    // horizontal-bt / rtl          YES                     YES
-    // vertical-lr / ltr            NO                      NO
-    // vertical-lr / rtl            NO                      YES
-    // vertical-rl / ltr            YES                     NO
-    // vertical-rl / rtl            YES                     YES
-    IntPoint m_scrollOrigin;
-
 private:
     // NOTE: Only called from the ScrollAnimator.
     friend class ScrollAnimator;
@@ -208,6 +199,19 @@
     unsigned m_horizontalScrollElasticity : 2; // ScrollElasticity
 
     unsigned m_scrollbarOverlayStyle : 2; // ScrollbarOverlayStyle
+
+    // There are 8 possible combinations of writing mode and direction. Scroll origin will be non-zero in the x or y axis
+    // if there is any reversed direction or writing-mode. The combinations are:
+    // writing-mode / direction     scrollOrigin.x() set    scrollOrigin.y() set
+    // horizontal-tb / ltr          NO                      NO
+    // horizontal-tb / rtl          YES                     NO
+    // horizontal-bt / ltr          NO                      YES
+    // horizontal-bt / rtl          YES                     YES
+    // vertical-lr / ltr            NO                      NO
+    // vertical-lr / rtl            NO                      YES
+    // vertical-rl / ltr            YES                     NO
+    // vertical-rl / rtl            YES                     YES
+    IntPoint m_scrollOrigin;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (99001 => 99002)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2011-11-01 21:54:05 UTC (rev 99001)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2011-11-01 22:06:46 UTC (rev 99002)
@@ -1385,7 +1385,7 @@
     // complicated (since it will involve testing whether our layer
     // is either occluded by another layer or clipped by an enclosing
     // layer or contains fixed backgrounds, etc.).
-    LayoutSize newScrollOffset = LayoutSize(x - m_scrollOrigin.x(), y - m_scrollOrigin.y());
+    LayoutSize newScrollOffset = LayoutSize(x - scrollOrigin().x(), y - scrollOrigin().y());
     if (m_scrollOffset == newScrollOffset)
         return;
     m_scrollOffset = newScrollOffset;
@@ -1709,18 +1709,18 @@
 
 LayoutPoint RenderLayer::scrollPosition() const
 {
-    return m_scrollOrigin + m_scrollOffset;
+    return scrollOrigin() + m_scrollOffset;
 }
 
 LayoutPoint RenderLayer::minimumScrollPosition() const
 {
-    return m_scrollOrigin;
+    return scrollOrigin();
 }
 
 LayoutPoint RenderLayer::maximumScrollPosition() const
 {
     // FIXME: m_scrollSize may not be up-to-date if m_scrollDimensionsDirty is true.
-    return m_scrollOrigin + m_scrollSize - visibleContentRect(true).size();
+    return scrollOrigin() + m_scrollSize - visibleContentRect(true).size();
 }
 
 IntRect RenderLayer::visibleContentRect(bool includeScrollbars) const
@@ -2207,7 +2207,7 @@
     m_scrollSize.setWidth(overflowRight() - overflowLeft());
     m_scrollSize.setHeight(overflowBottom() - overflowTop());
     
-    m_scrollOrigin = LayoutPoint(-m_scrollOverflow.width(), -m_scrollOverflow.height());
+    setScrollOrigin(LayoutPoint(-m_scrollOverflow.width(), -m_scrollOverflow.height()));
 
     if (needHBar)
         *needHBar = m_scrollSize.width() > box->clientWidth();

Modified: trunk/Source/WebCore/rendering/RenderLayer.h (99001 => 99002)


--- trunk/Source/WebCore/rendering/RenderLayer.h	2011-11-01 21:54:05 UTC (rev 99001)
+++ trunk/Source/WebCore/rendering/RenderLayer.h	2011-11-01 22:06:46 UTC (rev 99002)
@@ -279,8 +279,8 @@
 
     LayoutSize scrolledContentOffset() const { return scrollOffset() + m_scrollOverflow; }
 
-    LayoutUnit scrollXOffset() const { return m_scrollOffset.width() + m_scrollOrigin.x(); }
-    LayoutUnit scrollYOffset() const { return m_scrollOffset.height() + m_scrollOrigin.y(); }
+    LayoutUnit scrollXOffset() const { return m_scrollOffset.width() + scrollOrigin().x(); }
+    LayoutUnit scrollYOffset() const { return m_scrollOffset.height() + scrollOrigin().y(); }
     LayoutSize scrollOffset() const { return LayoutSize(scrollXOffset(), scrollYOffset()); }
 
     void scrollToOffset(LayoutUnit, LayoutUnit, ScrollOffsetClamping = ScrollOffsetUnclamped);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to