Skip to content

Commit

Permalink
Regression: Content not drawn when scrolling horizontally in an RTL page
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=55077

Reviewed by David Hyatt.

* platform/ScrollView.cpp:
(WebCore::ScrollView::overhangAmount):
(WebCore::ScrollView::calculateOverhangAreasForPainting):
Take the scroll origin into account when calculating overhang.

* platform/ScrollView.h:
* rendering/RenderLayer.h:
* platform/ScrollableArea.h:
(WebCore::ScrollableArea::scrollOrigin):
Move identical scroll origin member from ScrollView and RenderLayer
to shared base ScrollableArea. This is also needed so that the animator
can access it.

* platform/mac/ScrollAnimatorMac.mm:
(WebCore::ScrollAnimatorMac::pinnedInDirection):
(WebCore::ScrollAnimatorMac::smoothScrollWithEvent):
(WebCore::ScrollAnimatorMac::snapRubberBandTimerFired):
Account for a scroll origin when doing calculating scroll offsets.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@80757 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
weinig@apple.com committed Mar 10, 2011
1 parent e84b316 commit 8c01924
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 49 deletions.
26 changes: 26 additions & 0 deletions Source/WebCore/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
2011-03-10 Sam Weinig <sam@webkit.org>

Reviewed by David Hyatt.

Regression: Content not drawn when scrolling horizontally in an RTL page
https://bugs.webkit.org/show_bug.cgi?id=55077

* platform/ScrollView.cpp:
(WebCore::ScrollView::overhangAmount):
(WebCore::ScrollView::calculateOverhangAreasForPainting):
Take the scroll origin into account when calculating overhang.

* platform/ScrollView.h:
* rendering/RenderLayer.h:
* platform/ScrollableArea.h:
(WebCore::ScrollableArea::scrollOrigin):
Move identical scroll origin member from ScrollView and RenderLayer
to shared base ScrollableArea. This is also needed so that the animator
can access it.

* platform/mac/ScrollAnimatorMac.mm:
(WebCore::ScrollAnimatorMac::pinnedInDirection):
(WebCore::ScrollAnimatorMac::smoothScrollWithEvent):
(WebCore::ScrollAnimatorMac::snapRubberBandTimerFired):
Account for a scroll origin when doing calculating scroll offsets.

2011-03-09 Matthew Delaney <mdelaney@apple.com>

Reviewed by Simon Fraser.
Expand Down
40 changes: 22 additions & 18 deletions Source/WebCore/platform/ScrollView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,15 +409,18 @@ bool ScrollView::logicalScroll(ScrollLogicalDirection direction, ScrollGranulari
IntSize ScrollView::overhangAmount() const
{
IntSize stretch;
if (scrollY() < 0)
stretch.setHeight(scrollY());
else if (scrollY() > contentsHeight() - visibleContentRect().height())
stretch.setHeight(scrollY() - (contentsHeight() - visibleContentRect().height()));

if (scrollX() < 0)
stretch.setWidth(scrollX());
else if (scrollX() > contentsWidth() - visibleContentRect().width())
stretch.setWidth(scrollX() - (contentsWidth() - visibleContentRect().width()));
int physicalScrollY = scrollPosition().y() + m_scrollOrigin.y();
if (physicalScrollY < 0)
stretch.setHeight(physicalScrollY);
else if (physicalScrollY > contentsHeight() - visibleContentRect().height())
stretch.setHeight(physicalScrollY - (contentsHeight() - visibleContentRect().height()));

int physicalScrollX = scrollPosition().x() + m_scrollOrigin.x();
if (physicalScrollX < 0)
stretch.setWidth(physicalScrollX);
else if (physicalScrollX > contentsWidth() - visibleContentRect().width())
stretch.setWidth(physicalScrollX - (contentsWidth() - visibleContentRect().width()));

return stretch;
}
Expand Down Expand Up @@ -967,27 +970,28 @@ void ScrollView::calculateOverhangAreasForPainting(IntRect& horizontalOverhangRe
int horizontalScrollbarHeight = (horizontalScrollbar() && !horizontalScrollbar()->isOverlayScrollbar())
? horizontalScrollbar()->height() : 0;

if (scrollY() < 0) {
int physicalScrollY = scrollPosition().y() + m_scrollOrigin.y();
if (physicalScrollY < 0) {
horizontalOverhangRect = frameRect();
horizontalOverhangRect.setHeight(-scrollY());
horizontalOverhangRect.setY(scrollY());
} else if (scrollY() > contentsHeight() - visibleContentRect().height()) {
int height = scrollY() - (contentsHeight() - visibleContentRect().height());
horizontalOverhangRect.setHeight(-physicalScrollY);
} else if (physicalScrollY > contentsHeight() - visibleContentRect().height()) {
int height = physicalScrollY - (contentsHeight() - visibleContentRect().height());
horizontalOverhangRect = frameRect();
horizontalOverhangRect.setY(frameRect().maxY() - height - horizontalScrollbarHeight);
horizontalOverhangRect.setHeight(height);
}

if (scrollX() < 0) {
verticalOverhangRect.setWidth(-scrollX());
int physicalScrollX = scrollPosition().x() + m_scrollOrigin.x();
if (physicalScrollX < 0) {
verticalOverhangRect.setWidth(-physicalScrollX);
verticalOverhangRect.setHeight(frameRect().height() - horizontalOverhangRect.height());
verticalOverhangRect.setX(frameRect().x() + scrollX());
verticalOverhangRect.setX(frameRect().x());
if (horizontalOverhangRect.y() == frameRect().y())
verticalOverhangRect.setY(frameRect().y() + horizontalOverhangRect.height());
else
verticalOverhangRect.setY(frameRect().y());
} else if (scrollX() > contentsWidth() - visibleContentRect().width()) {
int width = scrollX() - (contentsWidth() - visibleContentRect().width());
} else if (physicalScrollX > contentsWidth() - visibleContentRect().width()) {
int width = physicalScrollX - (contentsWidth() - visibleContentRect().width());
verticalOverhangRect.setWidth(width);
verticalOverhangRect.setHeight(frameRect().height() - horizontalOverhangRect.height());
verticalOverhangRect.setX(frameRect().maxX() - width - verticalScrollbarWidth);
Expand Down
13 changes: 0 additions & 13 deletions Source/WebCore/platform/ScrollView.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,19 +347,6 @@ class ScrollView : public Widget, public ScrollableArea {
bool m_clipsRepaints;
bool m_delegatesScrolling;

// 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;

IntSize m_boundsSize;

void init();
Expand Down
15 changes: 15 additions & 0 deletions Source/WebCore/platform/ScrollableArea.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class ScrollableArea {
bool hasOverlayScrollbars() const;

ScrollAnimator* scrollAnimator() const { return m_scrollAnimator.get(); }
const IntPoint& scrollOrigin() const { return m_scrollOrigin; }

virtual int scrollSize(ScrollbarOrientation) const = 0;
virtual int scrollPosition(Scrollbar*) const = 0;
Expand Down Expand Up @@ -124,6 +125,20 @@ class ScrollableArea {
bool m_constrainsScrollingToContentEdge;

bool m_inLiveResize;

protected:
// 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
Expand Down
12 changes: 6 additions & 6 deletions Source/WebCore/platform/mac/ScrollAnimatorMac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -751,18 +751,18 @@ static float scrollWheelMultiplier()
if (fabsf(deltaY) >= fabsf(deltaX)) {
if (deltaY < 0) {
// We are trying to scroll up. Make sure we are not pinned to the top
limitDelta.setHeight(m_scrollableArea->visibleContentRect().y());
limitDelta.setHeight(m_scrollableArea->visibleContentRect().y() + + m_scrollableArea->scrollOrigin().y());
} else {
// We are trying to scroll down. Make sure we are not pinned to the bottom
limitDelta.setHeight(m_scrollableArea->contentsSize().height() - m_scrollableArea->visibleContentRect().maxY());
limitDelta.setHeight(m_scrollableArea->contentsSize().height() - (m_scrollableArea->visibleContentRect().maxY() + m_scrollableArea->scrollOrigin().y()));
}
} else if (deltaX != 0) {
if (deltaX < 0) {
// We are trying to scroll left. Make sure we are not pinned to the left
limitDelta.setWidth(m_scrollableArea->visibleContentRect().x());
limitDelta.setWidth(m_scrollableArea->visibleContentRect().x() + m_scrollableArea->scrollOrigin().x());
} else {
// We are trying to scroll right. Make sure we are not pinned to the right
limitDelta.setWidth(m_scrollableArea->contentsSize().width() - m_scrollableArea->visibleContentRect().maxX());
limitDelta.setWidth(m_scrollableArea->contentsSize().width() - (m_scrollableArea->visibleContentRect().maxX() + m_scrollableArea->scrollOrigin().x()));
}
}

Expand Down Expand Up @@ -925,7 +925,7 @@ static float scrollWheelMultiplier()
m_stretchScrollForce.setHeight(m_stretchScrollForce.height() + deltaY);

FloatSize dampedDelta(ceilf(elasticDeltaForReboundDelta(m_stretchScrollForce.width())), ceilf(elasticDeltaForReboundDelta(m_stretchScrollForce.height())));
FloatPoint origOrigin = m_scrollableArea->visibleContentRect().location() - stretchAmount;
FloatPoint origOrigin = (m_scrollableArea->visibleContentRect().location() + m_scrollableArea->scrollOrigin()) - stretchAmount;
FloatPoint newOrigin = origOrigin + dampedDelta;

if (origOrigin != newOrigin) {
Expand Down Expand Up @@ -1017,7 +1017,7 @@ static inline float roundToDevicePixelTowardZero(float num)
return;
}

m_origOrigin = m_scrollableArea->visibleContentRect().location() - m_startStretch;
m_origOrigin = (m_scrollableArea->visibleContentRect().location() + m_scrollableArea->scrollOrigin()) - m_startStretch;
m_origVelocity = m_momentumVelocity;

// Just like normal scrolling, prefer vertical rubberbanding
Expand Down
12 changes: 0 additions & 12 deletions Source/WebCore/rendering/RenderLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -619,18 +619,6 @@ class RenderLayer : public ScrollableArea {
int m_scrollX;
int m_scrollY;

// There are 8 possible combinations of writing mode and direction. Scroll origin (and its corresponding left/top overflow)
// 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;
int m_scrollLeftOverflow;
int m_scrollTopOverflow;

Expand Down

0 comments on commit 8c01924

Please sign in to comment.