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; 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__ #endif // nsLayoutUtils_h__

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

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

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

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