Title: [110120] trunk/Source/WebCore
Revision
110120
Author
e...@chromium.org
Date
2012-03-07 16:00:10 -0800 (Wed, 07 Mar 2012)

Log Message

Change remaining scroll methods to integers
https://bugs.webkit.org/show_bug.cgi?id=80539

Reviewed by Eric Seidel.

No new tests, no new functionality.

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::scrollByRecursively):
(WebCore::RenderLayer::scrollToOffset):
(WebCore::RenderLayer::scrollRectToVisible):
(WebCore::RenderLayer::scrollToXOffset):
(WebCore::RenderLayer::scrollToYOffset):
Change scrollTo methods to take integer x and y values as the actual
scrolling is done in increments of full pixels.

(WebCore::cornerStart):
(WebCore::RenderLayer::scrollWidth):
(WebCore::RenderLayer::scrollHeight):
Change scrollWidth/Height to return pixel snapped values and remove
pixelSnapped versions of same as all callers either used snapped the
values or used the pixelSnapped versions of these methods.

* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::scrollWidth):
Change scrollWidth to return snapped client width.

* rendering/RenderListBox.h:
Change scrollSize, scrollPosition and setScrollOffset methods to use
integers in accordance with the interface defined by ScrollableArea.

* rendering/RenderTreeAsText.cpp:
(WebCore::write):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (110119 => 110120)


--- trunk/Source/WebCore/ChangeLog	2012-03-07 23:57:40 UTC (rev 110119)
+++ trunk/Source/WebCore/ChangeLog	2012-03-08 00:00:10 UTC (rev 110120)
@@ -1,3 +1,39 @@
+2012-03-07  Emil A Eklund  <e...@chromium.org>
+
+        Change remaining scroll methods to integers
+        https://bugs.webkit.org/show_bug.cgi?id=80539
+
+        Reviewed by Eric Seidel.
+
+        No new tests, no new functionality.
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::scrollByRecursively):
+        (WebCore::RenderLayer::scrollToOffset):
+        (WebCore::RenderLayer::scrollRectToVisible):
+        (WebCore::RenderLayer::scrollToXOffset):
+        (WebCore::RenderLayer::scrollToYOffset):
+        Change scrollTo methods to take integer x and y values as the actual
+        scrolling is done in increments of full pixels.
+        
+        (WebCore::cornerStart):
+        (WebCore::RenderLayer::scrollWidth):
+        (WebCore::RenderLayer::scrollHeight):
+        Change scrollWidth/Height to return pixel snapped values and remove
+        pixelSnapped versions of same as all callers either used snapped the
+        values or used the pixelSnapped versions of these methods.
+
+        * rendering/RenderListBox.cpp:
+        (WebCore::RenderListBox::scrollWidth):
+        Change scrollWidth to return snapped client width.
+        
+        * rendering/RenderListBox.h:
+        Change scrollSize, scrollPosition and setScrollOffset methods to use
+        integers in accordance with the interface defined by ScrollableArea.
+        
+        * rendering/RenderTreeAsText.cpp:
+        (WebCore::write):
+
 2012-03-07  Caio Marcelo de Oliveira Filho  <caio.olive...@openbossa.org>
 
         Implement getAttributeNode() in terms of ElementAttributeData instead of NamedNodeMap

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (110119 => 110120)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2012-03-07 23:57:40 UTC (rev 110119)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2012-03-08 00:00:10 UTC (rev 110120)
@@ -1387,7 +1387,7 @@
     scrollByRecursively(adjustedScrollDelta(xDelta), adjustedScrollDelta(yDelta), ScrollOffsetClamped);
 }
 
-void RenderLayer::scrollByRecursively(LayoutUnit xDelta, LayoutUnit yDelta, ScrollOffsetClamping clamp)
+void RenderLayer::scrollByRecursively(int xDelta, int yDelta, ScrollOffsetClamping clamp)
 {
     if (!xDelta && !yDelta)
         return;
@@ -1397,13 +1397,13 @@
         restrictedByLineClamp = !renderer()->parent()->style()->lineClamp().isNone();
 
     if (renderer()->hasOverflowClip() && !restrictedByLineClamp) {
-        LayoutUnit newOffsetX = scrollXOffset() + xDelta;
-        LayoutUnit newOffsetY = scrollYOffset() + yDelta;
+        int newOffsetX = scrollXOffset() + xDelta;
+        int newOffsetY = scrollYOffset() + yDelta;
         scrollToOffset(newOffsetX, newOffsetY, clamp);
 
         // If this layer can't do the scroll we ask the next layer up that can scroll to try
-        LayoutUnit leftToScrollX = newOffsetX - scrollXOffset();
-        LayoutUnit leftToScrollY = newOffsetY - scrollYOffset();
+        int leftToScrollX = newOffsetX - scrollXOffset();
+        int leftToScrollY = newOffsetY - scrollYOffset();
         if ((leftToScrollX || leftToScrollY) && renderer()->parent()) {
             if (RenderLayer* scrollableLayer = enclosingScrollableLayer())
                 scrollableLayer->scrollByRecursively(leftToScrollX, leftToScrollY);
@@ -1421,21 +1421,21 @@
     }
 }
 
-void RenderLayer::scrollToOffset(LayoutUnit x, LayoutUnit y, ScrollOffsetClamping clamp)
+void RenderLayer::scrollToOffset(int x, int y, ScrollOffsetClamping clamp)
 {
     if (clamp == ScrollOffsetClamped) {
         RenderBox* box = renderBox();
         if (!box)
             return;
 
-        LayoutUnit maxX = scrollWidth() - box->clientWidth();
-        LayoutUnit maxY = scrollHeight() - box->clientHeight();
+        int maxX = scrollWidth() - box->clientWidth();
+        int maxY = scrollHeight() - box->clientHeight();
 
-        x = min(max<LayoutUnit>(x, 0), maxX);
-        y = min(max<LayoutUnit>(y, 0), maxY);
+        x = min(max(x, 0), maxX);
+        y = min(max(y, 0), maxY);
     }
 
-    LayoutPoint newScrollOffset(x, y);
+    IntPoint newScrollOffset(x, y);
     if (newScrollOffset != LayoutPoint(scrollXOffset(), scrollYOffset()))
         scrollToOffsetWithoutAnimation(newScrollOffset);
 }
@@ -1556,8 +1556,8 @@
         int yOffset = roundToInt(adjustedY);
         
         if (xOffset != scrollXOffset() || yOffset != scrollYOffset()) {
-            LayoutUnit diffX = scrollXOffset();
-            LayoutUnit diffY = scrollYOffset();
+            int diffX = scrollXOffset();
+            int diffY = scrollYOffset();
             scrollToOffset(xOffset, yOffset);
             diffX = scrollXOffset() - diffX;
             diffY = scrollYOffset() - diffY;
@@ -1583,8 +1583,8 @@
                     int xOffset = roundToInt(exposeRect.x());
                     int yOffset = roundToInt(exposeRect.y());
                     // Adjust offsets if they're outside of the allowable range.
-                    xOffset = max<LayoutUnit>(0, min(frameView->contentsWidth(), xOffset));
-                    yOffset = max<LayoutUnit>(0, min(frameView->contentsHeight(), yOffset));
+                    xOffset = max(0, min(frameView->contentsWidth(), xOffset));
+                    yOffset = max(0, min(frameView->contentsHeight(), yOffset));
 
                     frameView->setScrollPosition(IntPoint(xOffset, yOffset));
                     parentLayer = ownerElement->renderer()->enclosingLayer();
@@ -1837,7 +1837,7 @@
     return page && page->focusController()->isActive();
 }
 
-static LayoutUnit cornerStart(const RenderLayer* layer, int minX, int maxX, int thickness)
+static int cornerStart(const RenderLayer* layer, int minX, int maxX, int thickness)
 {
     if (layer->renderer()->style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
         return minX + layer->renderer()->style()->borderLeftWidth();
@@ -2247,30 +2247,20 @@
         m_resizer->setFrameRect(resizerCornerRect(this, borderBox));
 }
 
-LayoutUnit RenderLayer::scrollWidth()
+int RenderLayer::scrollWidth()
 {
     if (m_scrollDimensionsDirty)
         computeScrollDimensions();
     return m_scrollSize.width();
 }
 
-LayoutUnit RenderLayer::scrollHeight()
+int RenderLayer::scrollHeight()
 {
     if (m_scrollDimensionsDirty)
         computeScrollDimensions();
     return m_scrollSize.height();
 }
 
-int RenderLayer::pixelSnappedScrollWidth()
-{
-    return scrollWidth();
-}
-
-int RenderLayer::pixelSnappedScrollHeight()
-{
-    return scrollHeight();
-}
-
 LayoutUnit RenderLayer::overflowTop() const
 {
     RenderBox* box = renderBox();
@@ -2319,9 +2309,9 @@
     setScrollOrigin(IntPoint(-m_scrollOverflow.width(), -m_scrollOverflow.height()));
 
     if (needHBar)
-        *needHBar = pixelSnappedScrollWidth() > box->pixelSnappedClientWidth();
+        *needHBar = scrollWidth() > box->pixelSnappedClientWidth();
     if (needVBar)
-        *needVBar = pixelSnappedScrollHeight() > box->pixelSnappedClientHeight();
+        *needVBar = scrollHeight() > box->pixelSnappedClientHeight();
 }
 
 void RenderLayer::updateScrollInfoAfterLayout()
@@ -2339,8 +2329,8 @@
     if (box->style()->overflowX() != OMARQUEE) {
         // Layout may cause us to be in an invalid scroll position.  In this case we need
         // to pull our scroll offsets back to the max (or push them up to the min).
-        int newX = max(0, min(scrollXOffset(), scrollWidth() - box->clientWidth()));
-        int newY = max(0, min(scrollYOffset(), scrollHeight() - box->clientHeight()));
+        int newX = max(0, min<int>(scrollXOffset(), scrollWidth() - box->clientWidth()));
+        int newY = max(0, min<int>(scrollYOffset(), scrollHeight() - box->clientHeight()));
         if (newX != scrollXOffset() || newY != scrollYOffset())
             scrollToOffset(newX, newY);
     }
@@ -2416,7 +2406,7 @@
     }
 
     if (scrollOffsetOriginal != scrollOffset())
-        scrollToOffsetWithoutAnimation(LayoutPoint(scrollXOffset(), scrollYOffset()));
+        scrollToOffsetWithoutAnimation(IntPoint(scrollXOffset(), scrollYOffset()));
 }
 
 void RenderLayer::paintOverflowControls(GraphicsContext* context, const IntPoint& paintOffset, const IntRect& damageRect, bool paintingOverlayControls)

Modified: trunk/Source/WebCore/rendering/RenderLayer.h (110119 => 110120)


--- trunk/Source/WebCore/rendering/RenderLayer.h	2012-03-07 23:57:40 UTC (rev 110119)
+++ trunk/Source/WebCore/rendering/RenderLayer.h	2012-03-08 00:00:10 UTC (rev 110120)
@@ -280,10 +280,8 @@
 
     LayoutRect rect() const { return LayoutRect(location(), size()); }
 
-    LayoutUnit scrollWidth();
-    LayoutUnit scrollHeight();
-    int pixelSnappedScrollWidth();
-    int pixelSnappedScrollHeight();
+    int scrollWidth();
+    int scrollHeight();
 
     void panScrollFromPoint(const LayoutPoint&);
 
@@ -293,15 +291,15 @@
     };
 
     // Scrolling methods for layers that can scroll their overflow.
-    void scrollByRecursively(LayoutUnit xDelta, LayoutUnit yDelta, ScrollOffsetClamping = ScrollOffsetUnclamped);
+    void scrollByRecursively(int xDelta, int yDelta, ScrollOffsetClamping = ScrollOffsetUnclamped);
 
     int scrollXOffset() const { return m_scrollOffset.width() + scrollOrigin().x(); }
     int scrollYOffset() const { return m_scrollOffset.height() + scrollOrigin().y(); }
     IntSize scrollOffset() const { return IntSize(scrollXOffset(), scrollYOffset()); }
 
-    void scrollToOffset(LayoutUnit, LayoutUnit, ScrollOffsetClamping = ScrollOffsetUnclamped);
-    void scrollToXOffset(LayoutUnit x, ScrollOffsetClamping clamp = ScrollOffsetUnclamped) { scrollToOffset(x, scrollYOffset(), clamp); }
-    void scrollToYOffset(LayoutUnit y, ScrollOffsetClamping clamp = ScrollOffsetUnclamped) { scrollToOffset(scrollXOffset(), y, clamp); }
+    void scrollToOffset(int, int, ScrollOffsetClamping = ScrollOffsetUnclamped);
+    void scrollToXOffset(int x, ScrollOffsetClamping clamp = ScrollOffsetUnclamped) { scrollToOffset(x, scrollYOffset(), clamp); }
+    void scrollToYOffset(int y, ScrollOffsetClamping clamp = ScrollOffsetUnclamped) { scrollToOffset(scrollXOffset(), y, clamp); }
 
     void scrollRectToVisible(const LayoutRect&, const ScrollAlignment& alignX = ScrollAlignment::alignCenterIfNeeded, const ScrollAlignment& alignY = ScrollAlignment::alignCenterIfNeeded);
 
@@ -819,7 +817,7 @@
     // Our scroll offsets if the view is scrolled.
     IntSize m_scrollOffset;
 
-    LayoutSize m_scrollOverflow;
+    IntSize m_scrollOverflow;
     
     // The width/height of our scrolled area.
     LayoutSize m_scrollSize;

Modified: trunk/Source/WebCore/rendering/RenderListBox.cpp (110119 => 110120)


--- trunk/Source/WebCore/rendering/RenderListBox.cpp	2012-03-07 23:57:40 UTC (rev 110119)
+++ trunk/Source/WebCore/rendering/RenderListBox.cpp	2012-03-08 00:00:10 UTC (rev 110120)
@@ -643,10 +643,10 @@
 
 // FIXME: We ignore padding in the vertical direction as far as these values are concerned, since that's
 // how the control currently paints.
-LayoutUnit RenderListBox::scrollWidth() const
+int RenderListBox::scrollWidth() const
 {
     // There is no horizontal scrolling allowed.
-    return clientWidth();
+    return pixelSnappedClientWidth();
 }
 
 int RenderListBox::scrollHeight() const

Modified: trunk/Source/WebCore/rendering/RenderListBox.h (110119 => 110120)


--- trunk/Source/WebCore/rendering/RenderListBox.h	2012-03-07 23:57:40 UTC (rev 110119)
+++ trunk/Source/WebCore/rendering/RenderListBox.h	2012-03-08 00:00:10 UTC (rev 110120)
@@ -97,9 +97,9 @@
     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
 
     // ScrollableArea interface.
-    virtual LayoutUnit scrollSize(ScrollbarOrientation) const;
-    virtual LayoutUnit scrollPosition(Scrollbar*) const;
-    virtual void setScrollOffset(const LayoutPoint&);
+    virtual int scrollSize(ScrollbarOrientation) const;
+    virtual int scrollPosition(Scrollbar*) const;
+    virtual void setScrollOffset(const IntPoint&);
     virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&);
     virtual bool isActive() const;
     virtual bool isScrollCornerVisible() const { return false; } // We don't support resize on list boxes yet. If we did these would have to change.

Modified: trunk/Source/WebCore/rendering/RenderTreeAsText.cpp (110119 => 110120)


--- trunk/Source/WebCore/rendering/RenderTreeAsText.cpp	2012-03-07 23:57:40 UTC (rev 110119)
+++ trunk/Source/WebCore/rendering/RenderTreeAsText.cpp	2012-03-08 00:00:10 UTC (rev 110120)
@@ -616,10 +616,10 @@
             ts << " scrollX " << l.scrollXOffset();
         if (l.scrollYOffset())
             ts << " scrollY " << l.scrollYOffset();
-        if (l.renderBox() && l.renderBox()->pixelSnappedClientWidth() != l.pixelSnappedScrollWidth())
-            ts << " scrollWidth " << l.pixelSnappedScrollWidth();
-        if (l.renderBox() && l.renderBox()->pixelSnappedClientHeight() != l.pixelSnappedScrollHeight())
-            ts << " scrollHeight " << l.pixelSnappedScrollHeight();
+        if (l.renderBox() && l.renderBox()->pixelSnappedClientWidth() != l.scrollWidth())
+            ts << " scrollWidth " << l.scrollWidth();
+        if (l.renderBox() && l.renderBox()->pixelSnappedClientHeight() != l.scrollHeight())
+            ts << " scrollHeight " << l.scrollHeight();
     }
 
     if (paintPhase == LayerPaintPhaseBackground)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to