Bug 1349750 - Move the scroll track extents from AsyncDragMetrics to ScrollThumbData. r=kats
To conserve space in LayerAttributes, we only store the extents along the relevant axis. MozReview-Commit-ID: GAL8Oa2NOde
This commit is contained in:
@@ -1305,7 +1305,6 @@ struct ParamTraits<mozilla::layers::AsyncDragMetrics>
|
|||||||
WriteParam(aMsg, aParam.mPresShellId);
|
WriteParam(aMsg, aParam.mPresShellId);
|
||||||
WriteParam(aMsg, aParam.mDragStartSequenceNumber);
|
WriteParam(aMsg, aParam.mDragStartSequenceNumber);
|
||||||
WriteParam(aMsg, aParam.mScrollbarDragOffset);
|
WriteParam(aMsg, aParam.mScrollbarDragOffset);
|
||||||
WriteParam(aMsg, aParam.mScrollTrack);
|
|
||||||
WriteParam(aMsg, aParam.mDirection);
|
WriteParam(aMsg, aParam.mDirection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1315,7 +1314,6 @@ struct ParamTraits<mozilla::layers::AsyncDragMetrics>
|
|||||||
ReadParam(aMsg, aIter, &aResult->mPresShellId) &&
|
ReadParam(aMsg, aIter, &aResult->mPresShellId) &&
|
||||||
ReadParam(aMsg, aIter, &aResult->mDragStartSequenceNumber) &&
|
ReadParam(aMsg, aIter, &aResult->mDragStartSequenceNumber) &&
|
||||||
ReadParam(aMsg, aIter, &aResult->mScrollbarDragOffset) &&
|
ReadParam(aMsg, aIter, &aResult->mScrollbarDragOffset) &&
|
||||||
ReadParam(aMsg, aIter, &aResult->mScrollTrack) &&
|
|
||||||
ReadParam(aMsg, aIter, &aResult->mDirection));
|
ReadParam(aMsg, aIter, &aResult->mDirection));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -27,11 +27,15 @@ struct ScrollThumbData {
|
|||||||
ScrollThumbData(ScrollDirection aDirection,
|
ScrollThumbData(ScrollDirection aDirection,
|
||||||
float aThumbRatio,
|
float aThumbRatio,
|
||||||
CSSCoord aThumbLength,
|
CSSCoord aThumbLength,
|
||||||
bool aIsAsyncDraggable)
|
bool aIsAsyncDraggable,
|
||||||
|
CSSCoord aScrollTrackStart,
|
||||||
|
CSSCoord aScrollTrackLength)
|
||||||
: mDirection(aDirection)
|
: mDirection(aDirection)
|
||||||
, mThumbRatio(aThumbRatio)
|
, mThumbRatio(aThumbRatio)
|
||||||
, mThumbLength(aThumbLength)
|
, mThumbLength(aThumbLength)
|
||||||
, mIsAsyncDraggable(aIsAsyncDraggable)
|
, mIsAsyncDraggable(aIsAsyncDraggable)
|
||||||
|
, mScrollTrackStart(aScrollTrackStart)
|
||||||
|
, mScrollTrackLength(aScrollTrackLength)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
ScrollDirection mDirection;
|
ScrollDirection mDirection;
|
||||||
@@ -42,12 +46,16 @@ struct ScrollThumbData {
|
|||||||
CSSCoord mThumbLength;
|
CSSCoord mThumbLength;
|
||||||
// Whether the scrollbar thumb can be dragged asynchronously.
|
// Whether the scrollbar thumb can be dragged asynchronously.
|
||||||
bool mIsAsyncDraggable;
|
bool mIsAsyncDraggable;
|
||||||
|
CSSCoord mScrollTrackStart;
|
||||||
|
CSSCoord mScrollTrackLength;
|
||||||
|
|
||||||
bool operator==(const ScrollThumbData& aOther) const {
|
bool operator==(const ScrollThumbData& aOther) const {
|
||||||
return mDirection == aOther.mDirection &&
|
return mDirection == aOther.mDirection &&
|
||||||
mThumbRatio == aOther.mThumbRatio &&
|
mThumbRatio == aOther.mThumbRatio &&
|
||||||
mThumbLength == aOther.mThumbLength &&
|
mThumbLength == aOther.mThumbLength &&
|
||||||
mIsAsyncDraggable == aOther.mIsAsyncDraggable;
|
mIsAsyncDraggable == aOther.mIsAsyncDraggable &&
|
||||||
|
mScrollTrackStart == aOther.mScrollTrackStart &&
|
||||||
|
mScrollTrackLength == aOther.mScrollTrackLength;
|
||||||
}
|
}
|
||||||
bool operator!=(const ScrollThumbData& aOther) const {
|
bool operator!=(const ScrollThumbData& aOther) const {
|
||||||
return !(*this == aOther);
|
return !(*this == aOther);
|
||||||
|
|||||||
@@ -41,13 +41,11 @@ public:
|
|||||||
uint32_t aPresShellId,
|
uint32_t aPresShellId,
|
||||||
uint64_t aDragStartSequenceNumber,
|
uint64_t aDragStartSequenceNumber,
|
||||||
CSSCoord aScrollbarDragOffset,
|
CSSCoord aScrollbarDragOffset,
|
||||||
const CSSRect& aScrollTrack,
|
|
||||||
DragDirection aDirection)
|
DragDirection aDirection)
|
||||||
: mViewId(aViewId)
|
: mViewId(aViewId)
|
||||||
, mPresShellId(aPresShellId)
|
, mPresShellId(aPresShellId)
|
||||||
, mDragStartSequenceNumber(aDragStartSequenceNumber)
|
, mDragStartSequenceNumber(aDragStartSequenceNumber)
|
||||||
, mScrollbarDragOffset(aScrollbarDragOffset)
|
, mScrollbarDragOffset(aScrollbarDragOffset)
|
||||||
, mScrollTrack(aScrollTrack)
|
|
||||||
, mDirection(aDirection)
|
, mDirection(aDirection)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@@ -55,7 +53,6 @@ public:
|
|||||||
uint32_t mPresShellId;
|
uint32_t mPresShellId;
|
||||||
uint64_t mDragStartSequenceNumber;
|
uint64_t mDragStartSequenceNumber;
|
||||||
CSSCoord mScrollbarDragOffset;
|
CSSCoord mScrollbarDragOffset;
|
||||||
CSSRect mScrollTrack;
|
|
||||||
DragDirection mDirection;
|
DragDirection mDirection;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -926,9 +926,9 @@ nsEventStatus AsyncPanZoomController::HandleDragEvent(const MouseInput& aEvent,
|
|||||||
CSSCoord mousePosition = GetAxisStart(aDragMetrics.mDirection, scrollbarPoint) -
|
CSSCoord mousePosition = GetAxisStart(aDragMetrics.mDirection, scrollbarPoint) -
|
||||||
aDragMetrics.mScrollbarDragOffset -
|
aDragMetrics.mScrollbarDragOffset -
|
||||||
GetAxisStart(aDragMetrics.mDirection, cssCompositionBound) -
|
GetAxisStart(aDragMetrics.mDirection, cssCompositionBound) -
|
||||||
GetAxisStart(aDragMetrics.mDirection, aDragMetrics.mScrollTrack);
|
thumbData.mScrollTrackStart;
|
||||||
|
|
||||||
CSSCoord scrollMax = GetAxisLength(aDragMetrics.mDirection, aDragMetrics.mScrollTrack);
|
CSSCoord scrollMax = thumbData.mScrollTrackLength;
|
||||||
scrollMax -= thumbData.mThumbLength;
|
scrollMax -= thumbData.mThumbLength;
|
||||||
|
|
||||||
float scrollPercent = mousePosition / scrollMax;
|
float scrollPercent = mousePosition / scrollMax;
|
||||||
|
|||||||
@@ -361,10 +361,10 @@ nsSliderFrame::BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder,
|
|||||||
thumb->GetXULMargin(m);
|
thumb->GetXULMargin(m);
|
||||||
thumbRect.Inflate(m);
|
thumbRect.Inflate(m);
|
||||||
|
|
||||||
nsRect crect;
|
nsRect sliderTrack;
|
||||||
GetXULClientRect(crect);
|
GetXULClientRect(sliderTrack);
|
||||||
|
|
||||||
if (crect.width < thumbRect.width || crect.height < thumbRect.height)
|
if (sliderTrack.width < thumbRect.width || sliderTrack.height < thumbRect.height)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// If this scrollbar is the scrollbar of an actively scrolled scroll frame,
|
// If this scrollbar is the scrollbar of an actively scrolled scroll frame,
|
||||||
@@ -394,6 +394,21 @@ nsSliderFrame::BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder,
|
|||||||
nsIFrame* scrollbarBox = GetScrollbar();
|
nsIFrame* scrollbarBox = GetScrollbar();
|
||||||
bool isAsyncDraggable = !UsesCustomScrollbarMediator(scrollbarBox);
|
bool isAsyncDraggable = !UsesCustomScrollbarMediator(scrollbarBox);
|
||||||
|
|
||||||
|
nsPoint scrollPortOrigin;
|
||||||
|
if (nsIScrollableFrame* scrollFrame = do_QueryFrame(scrollbarBox->GetParent())) {
|
||||||
|
scrollPortOrigin = scrollFrame->GetScrollPortRect().TopLeft();
|
||||||
|
} else {
|
||||||
|
isAsyncDraggable = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This rect is the range in which the scroll thumb can slide in.
|
||||||
|
sliderTrack = sliderTrack + GetRect().TopLeft() + scrollbarBox->GetPosition() -
|
||||||
|
scrollPortOrigin;
|
||||||
|
CSSCoord sliderTrackStart = NSAppUnitsToFloatPixels(
|
||||||
|
isHorizontal ? sliderTrack.x : sliderTrack.y, appUnitsPerCss);
|
||||||
|
CSSCoord sliderTrackLength = NSAppUnitsToFloatPixels(
|
||||||
|
isHorizontal ? sliderTrack.width : sliderTrack.height, appUnitsPerCss);
|
||||||
|
|
||||||
nsDisplayListBuilder::AutoContainerASRTracker contASRTracker(aBuilder);
|
nsDisplayListBuilder::AutoContainerASRTracker contASRTracker(aBuilder);
|
||||||
nsDisplayListCollection tempLists;
|
nsDisplayListCollection tempLists;
|
||||||
nsBoxFrame::BuildDisplayListForChildren(aBuilder, aDirtyRect, tempLists);
|
nsBoxFrame::BuildDisplayListForChildren(aBuilder, aDirtyRect, tempLists);
|
||||||
@@ -418,7 +433,9 @@ nsSliderFrame::BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder,
|
|||||||
ScrollThumbData{scrollDirection,
|
ScrollThumbData{scrollDirection,
|
||||||
GetThumbRatio(),
|
GetThumbRatio(),
|
||||||
thumbLength,
|
thumbLength,
|
||||||
isAsyncDraggable}));
|
isAsyncDraggable,
|
||||||
|
sliderTrackStart,
|
||||||
|
sliderTrackLength}));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1044,11 +1061,6 @@ nsSliderFrame::StartAPZDrag(WidgetGUIEvent* aEvent)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIScrollableFrame* scrollFrameAsScrollable = do_QueryFrame(scrollFrame);
|
|
||||||
if (!scrollFrameAsScrollable) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// APZ dragging requires the scrollbar to be layerized, which doesn't
|
// APZ dragging requires the scrollbar to be layerized, which doesn't
|
||||||
// happen for scroll info layers.
|
// happen for scroll info layers.
|
||||||
if (ScrollFrameWillBuildScrollInfoLayer(scrollFrame)) {
|
if (ScrollFrameWillBuildScrollInfoLayer(scrollFrame)) {
|
||||||
@@ -1072,21 +1084,12 @@ nsSliderFrame::StartAPZDrag(WidgetGUIEvent* aEvent)
|
|||||||
|
|
||||||
nsCOMPtr<nsIContent> scrollbar = GetContentOfBox(scrollbarBox);
|
nsCOMPtr<nsIContent> scrollbar = GetContentOfBox(scrollbarBox);
|
||||||
|
|
||||||
nsRect sliderTrack;
|
|
||||||
GetXULClientRect(sliderTrack);
|
|
||||||
|
|
||||||
// This rect is the range in which the scroll thumb can slide in.
|
|
||||||
sliderTrack = sliderTrack + GetRect().TopLeft() + scrollbarBox->GetPosition() -
|
|
||||||
scrollFrameAsScrollable->GetScrollPortRect().TopLeft();
|
|
||||||
CSSRect sliderTrackCSS = CSSRect::FromAppUnits(sliderTrack);
|
|
||||||
|
|
||||||
nsIPresShell* shell = PresContext()->PresShell();
|
nsIPresShell* shell = PresContext()->PresShell();
|
||||||
uint64_t inputblockId = InputAPZContext::GetInputBlockId();
|
uint64_t inputblockId = InputAPZContext::GetInputBlockId();
|
||||||
uint32_t presShellId = shell->GetPresShellId();
|
uint32_t presShellId = shell->GetPresShellId();
|
||||||
AsyncDragMetrics dragMetrics(scrollTargetId, presShellId, inputblockId,
|
AsyncDragMetrics dragMetrics(scrollTargetId, presShellId, inputblockId,
|
||||||
NSAppUnitsToFloatPixels(mDragStart,
|
NSAppUnitsToFloatPixels(mDragStart,
|
||||||
float(AppUnitsPerCSSPixel())),
|
float(AppUnitsPerCSSPixel())),
|
||||||
sliderTrackCSS,
|
|
||||||
isHorizontal ? AsyncDragMetrics::HORIZONTAL :
|
isHorizontal ? AsyncDragMetrics::HORIZONTAL :
|
||||||
AsyncDragMetrics::VERTICAL);
|
AsyncDragMetrics::VERTICAL);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user