Bug 1363922 - Part 1: Remember about the reference frame during BuildDisplayList for ScrollFrameHelper so GetScrolledRect can use it. r=mstange

MozReview-Commit-ID: 8GO6xuSH5xY
This commit is contained in:
Bas Schouten 2017-08-17 15:45:30 +02:00
Родитель ea56f9328d
Коммит fe49d64a98
3 изменённых файлов: 22 добавлений и 1 удалений

Просмотреть файл

@ -3134,4 +3134,21 @@ public:
nsCOMPtr<nsIAtom> mAttrName;
};
// This class allows you to easily set any pointer variable and ensure it's
// set to nullptr when leaving its scope.
template<typename T>
class MOZ_RAII SetAndNullOnExit
{
public:
SetAndNullOnExit(T* &aVariable, T* aValue) {
aVariable = aValue;
mVariable = &aVariable;
}
~SetAndNullOnExit() {
*mVariable = nullptr;
}
private:
T** mVariable;
};
#endif // nsLayoutUtils_h__

Просмотреть файл

@ -2006,6 +2006,7 @@ ScrollFrameHelper::ScrollFrameHelper(nsContainerFrame* aOuter,
, mScrollCornerBox(nullptr)
, mResizerBox(nullptr)
, mOuter(aOuter)
, mReferenceFrameDuringPainting(nullptr)
, mAsyncScroll(nullptr)
, mAsyncSmoothMSDScroll(nullptr)
, mLastScrollOrigin(nsGkAtoms::other)
@ -3263,6 +3264,7 @@ void
ScrollFrameHelper::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists)
{
SetAndNullOnExit<const nsIFrame> tmpBuilder(mReferenceFrameDuringPainting, aBuilder->GetCurrentReferenceFrame());
if (aBuilder->IsForFrameVisibility()) {
NotifyApproximateFrameVisibilityUpdate(false);
}
@ -5866,7 +5868,8 @@ ScrollFrameHelper::GetScrolledRect() const
// relative to the reference frame, since that's the space where painting does
// snapping.
nsSize scrollPortSize = GetScrollPositionClampingScrollPortSize();
nsIFrame* referenceFrame = nsLayoutUtils::GetReferenceFrame(mOuter);
const nsIFrame* referenceFrame =
mReferenceFrameDuringPainting ? mReferenceFrameDuringPainting : nsLayoutUtils::GetReferenceFrame(mOuter);
nsPoint toReferenceFrame = mOuter->GetOffsetToCrossDoc(referenceFrame);
nsRect scrollPort(mScrollPort.TopLeft() + toReferenceFrame, scrollPortSize);
nsRect scrolledRect = result + scrollPort.TopLeft();

Просмотреть файл

@ -493,6 +493,7 @@ public:
nsIFrame* mScrollCornerBox;
nsIFrame* mResizerBox;
nsContainerFrame* mOuter;
const nsIFrame* mReferenceFrameDuringPainting;
RefPtr<AsyncScroll> mAsyncScroll;
RefPtr<AsyncSmoothMSDScroll> mAsyncSmoothMSDScroll;
RefPtr<ScrollbarActivity> mScrollbarActivity;