Bug 957445: Part 1 - Scrolling moved from nsScrollbarButtonFrame and nsSliderFrame into nsIScrollbarMediator, r=mats
This commit is contained in:
@@ -4155,48 +4155,85 @@ nsTreeBodyFrame::ScrollHorzInternal(const ScrollParts& aParts, int32_t aPosition
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTreeBodyFrame::ScrollbarButtonPressed(nsScrollbarFrame* aScrollbar, int32_t aOldIndex, int32_t aNewIndex)
|
||||
void
|
||||
nsTreeBodyFrame::ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection)
|
||||
{
|
||||
MOZ_ASSERT(aScrollbar != nullptr);
|
||||
ScrollByPages(aDirection);
|
||||
}
|
||||
|
||||
void
|
||||
nsTreeBodyFrame::ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection)
|
||||
{
|
||||
MOZ_ASSERT(aScrollbar != nullptr);
|
||||
int32_t newIndex = aDirection < 0 ? 0 : mTopRowIndex;
|
||||
ScrollToRow(newIndex);
|
||||
}
|
||||
|
||||
void
|
||||
nsTreeBodyFrame::ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection)
|
||||
{
|
||||
MOZ_ASSERT(aScrollbar != nullptr);
|
||||
ScrollByLines(aDirection);
|
||||
}
|
||||
|
||||
void
|
||||
nsTreeBodyFrame::RepeatButtonScroll(nsScrollbarFrame* aScrollbar)
|
||||
{
|
||||
ScrollParts parts = GetScrollParts();
|
||||
int32_t increment = aScrollbar->GetIncrement();
|
||||
int32_t direction = 0;
|
||||
if (increment < 0) {
|
||||
direction = -1;
|
||||
} else if (increment > 0) {
|
||||
direction = 1;
|
||||
}
|
||||
bool isHorizontal = aScrollbar->IsHorizontal();
|
||||
|
||||
if (aScrollbar == parts.mVScrollbar) {
|
||||
if (aNewIndex > aOldIndex)
|
||||
ScrollToRowInternal(parts, mTopRowIndex+1);
|
||||
else if (aNewIndex < aOldIndex)
|
||||
ScrollToRowInternal(parts, mTopRowIndex-1);
|
||||
nsWeakFrame weakFrame(this);
|
||||
if (isHorizontal) {
|
||||
int32_t curpos = aScrollbar->MoveToNewPosition();
|
||||
if (weakFrame.IsAlive()) {
|
||||
ScrollHorzInternal(parts, curpos);
|
||||
}
|
||||
} else {
|
||||
nsresult rv = ScrollHorzInternal(parts, aNewIndex);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
ScrollToRowInternal(parts, mTopRowIndex+direction);
|
||||
}
|
||||
|
||||
UpdateScrollbars(parts);
|
||||
|
||||
return NS_OK;
|
||||
if (weakFrame.IsAlive() && mScrollbarActivity) {
|
||||
mScrollbarActivity->ActivityOccurred();
|
||||
}
|
||||
if (weakFrame.IsAlive()) {
|
||||
UpdateScrollbars(parts);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTreeBodyFrame::PositionChanged(nsScrollbarFrame* aScrollbar, int32_t aOldIndex, int32_t& aNewIndex)
|
||||
|
||||
void
|
||||
nsTreeBodyFrame::ThumbMoved(nsScrollbarFrame* aScrollbar,
|
||||
nscoord aOldPos,
|
||||
nscoord aNewPos)
|
||||
{
|
||||
ScrollParts parts = GetScrollParts();
|
||||
|
||||
if (aOldIndex == aNewIndex)
|
||||
return NS_OK;
|
||||
if (aOldPos == aNewPos)
|
||||
return;
|
||||
|
||||
nsWeakFrame weakFrame(this);
|
||||
|
||||
// Vertical Scrollbar
|
||||
if (parts.mVScrollbar == aScrollbar) {
|
||||
nscoord rh = nsPresContext::AppUnitsToIntCSSPixels(mRowHeight);
|
||||
|
||||
nscoord newrow = aNewIndex/rh;
|
||||
nscoord newIndex = nsPresContext::AppUnitsToIntCSSPixels(aNewPos);
|
||||
nscoord newrow = newIndex/rh;
|
||||
ScrollInternal(parts, newrow);
|
||||
// Horizontal Scrollbar
|
||||
} else if (parts.mHScrollbar == aScrollbar) {
|
||||
nsresult rv = ScrollHorzInternal(parts, aNewIndex);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
int32_t newIndex = nsPresContext::AppUnitsToIntCSSPixels(aNewPos);
|
||||
ScrollHorzInternal(parts, newIndex);
|
||||
}
|
||||
if (weakFrame.IsAlive()) {
|
||||
UpdateScrollbars(parts);
|
||||
}
|
||||
|
||||
UpdateScrollbars(parts);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// The style cache.
|
||||
|
||||
Reference in New Issue
Block a user