Bug 1298218 - Back out
bug 1284586. r?tnikkel
MozReview-Commit-ID: FGNKyDcoEyF
--- a/layout/generic/ViewportFrame.cpp
+++ b/layout/generic/ViewportFrame.cpp
@@ -104,17 +104,17 @@ BuildDisplayListForTopLayerFrame(nsDispl
DisplayListClipState::AutoClipMultiple clipState(aBuilder);
nsDisplayListBuilder::OutOfFlowDisplayData*
savedOutOfFlowData = nsDisplayListBuilder::GetOutOfFlowData(aFrame);
if (savedOutOfFlowData) {
dirty = savedOutOfFlowData->mDirtyRect;
clipState.SetClipForContainingBlockDescendants(
&savedOutOfFlowData->mContainingBlockClip);
clipState.SetScrollClipForContainingBlockDescendants(
- aBuilder, savedOutOfFlowData->mContainingBlockScrollClip);
+ savedOutOfFlowData->mContainingBlockScrollClip);
}
nsDisplayList list;
aFrame->BuildDisplayListForStackingContext(aBuilder, dirty, &list);
aList->AppendToTop(&list);
}
void
ViewportFrame::BuildDisplayListForTopLayer(nsDisplayListBuilder* aBuilder,
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -2836,32 +2836,32 @@ nsIFrame::BuildDisplayListForChild(nsDis
DisplayListClipState::AutoClipMultiple clipState(aBuilder);
CheckForApzAwareEventHandlers(aBuilder, child);
if (savedOutOfFlowData) {
aBuilder->SetBuildingInvisibleItems(false);
clipState.SetClipForContainingBlockDescendants(
&savedOutOfFlowData->mContainingBlockClip);
- clipState.SetScrollClipForContainingBlockDescendants(aBuilder,
+ clipState.SetScrollClipForContainingBlockDescendants(
savedOutOfFlowData->mContainingBlockScrollClip);
} else if (GetStateBits() & NS_FRAME_FORCE_DISPLAY_LIST_DESCEND_INTO &&
isPlaceholder) {
NS_ASSERTION(dirty.IsEmpty(), "should have empty dirty rect");
// Every item we build from now until we descent into an out of flow that
// does have saved out of flow data should be invisible. This state gets
// restored when AutoBuildingDisplayList gets out of scope.
aBuilder->SetBuildingInvisibleItems(true);
// If we have nested out-of-flow frames and the outer one isn't visible
// then we won't have stored clip data for it. We can just clear the clip
// instead since we know we won't render anything, and the inner out-of-flow
// frame will setup the correct clip for itself.
clipState.SetClipForContainingBlockDescendants(nullptr);
- clipState.SetScrollClipForContainingBlockDescendants(aBuilder, nullptr);
+ clipState.SetScrollClipForContainingBlockDescendants(nullptr);
}
// Setup clipping for the parent's overflow:-moz-hidden-unscrollable,
// or overflow:hidden on elements that don't support scrolling (and therefore
// don't create nsHTML/XULScrollFrame). This clipping needs to not clip
// anything directly rendered by the parent, only the rendering of its
// children.
// Don't use overflowClip to restrict the dirty rect, since some of the
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -2047,17 +2047,16 @@ ScrollFrameHelper::ScrollFrameHelper(nsC
, mWillBuildScrollableLayer(false)
, mIsScrollParent(false)
, mIsScrollableLayerInRootContainer(false)
, mHasBeenScrolled(false)
, mIgnoreMomentumScroll(false)
, mTransformingByAPZ(false)
, mScrollableByAPZ(false)
, mZoomableByAPZ(false)
- , mScrollsClipOnUnscrolledOutOfFlow(false)
, mVelocityQueue(aOuter->PresContext())
{
if (LookAndFeel::GetInt(LookAndFeel::eIntID_UseOverlayScrollbars) != 0) {
mScrollbarActivity = new ScrollbarActivity(do_QueryFrame(aOuter));
}
EnsureFrameVisPrefsCached();
@@ -2187,22 +2186,16 @@ ScrollFrameHelper::HasPerspective() cons
bool
ScrollFrameHelper::HasBgAttachmentLocal() const
{
const nsStyleBackground* bg = mOuter->StyleBackground();
return bg->HasLocalBackground();
}
void
-ScrollFrameHelper::SetScrollsClipOnUnscrolledOutOfFlow()
-{
- mScrollsClipOnUnscrolledOutOfFlow = true;
-}
-
-void
ScrollFrameHelper::ScrollToCSSPixels(const CSSIntPoint& aScrollPosition,
nsIScrollableFrame::ScrollMode aMode)
{
nsPoint current = GetScrollPosition();
CSSIntPoint currentCSSPixels = GetScrollPositionCSSPixels();
nsPoint pt = CSSPoint::ToAppUnits(aScrollPosition);
nscoord halfPixel = nsPresContext::CSSPixelsToAppUnits(0.5f);
nsRect range(pt.x - halfPixel, pt.y - halfPixel, 2*halfPixel - 1, 2*halfPixel - 1);
@@ -2842,24 +2835,23 @@ ScrollFrameHelper::ScrollToImpl(nsPoint
// that needs to be painted. So even if the final tile-aligned displayport
// is the same, we force a repaint for these elements. Bug 1254260 tracks
// fixing this properly.
nsRect displayPort;
bool usingDisplayPort =
nsLayoutUtils::GetHighResolutionDisplayPort(content, &displayPort);
displayPort.MoveBy(-mScrolledFrame->GetPosition());
- PAINT_SKIP_LOG("New scrollpos %s usingDP %d dpEqual %d scrollableByApz %d plugins %d perspective %d clip %d bglocal %d\n",
+ PAINT_SKIP_LOG("New scrollpos %s usingDP %d dpEqual %d scrollableByApz %d plugins %d perspective %d bglocal %d\n",
Stringify(CSSPoint::FromAppUnits(GetScrollPosition())).c_str(),
usingDisplayPort, displayPort.IsEqualEdges(oldDisplayPort),
mScrollableByAPZ, HasPluginFrames(), HasPerspective(),
- mScrollsClipOnUnscrolledOutOfFlow, HasBgAttachmentLocal());
+ HasBgAttachmentLocal());
if (usingDisplayPort && displayPort.IsEqualEdges(oldDisplayPort) &&
- !HasPerspective() && !mScrollsClipOnUnscrolledOutOfFlow &&
- !HasBgAttachmentLocal()) {
+ !HasPerspective() && !HasBgAttachmentLocal()) {
bool haveScrollLinkedEffects = content->GetComposedDoc()->HasScrollLinkedEffect();
bool apzDisabled = haveScrollLinkedEffects && gfxPrefs::APZDisableForScrollLinkedEffects();
if (!apzDisabled && !HasPluginFrames()) {
if (LastScrollOrigin() == nsGkAtoms::apz) {
schedulePaint = false;
PAINT_SKIP_LOG("Skipping due to APZ scroll\n");
} else if (mScrollableByAPZ) {
nsIWidget* widget = presContext->GetNearestWidget();
--- a/layout/generic/nsGfxScrollFrame.h
+++ b/layout/generic/nsGfxScrollFrame.h
@@ -392,17 +392,16 @@ public:
mOuter->SchedulePaint();
}
}
bool IsTransformingByAPZ() const {
return mTransformingByAPZ;
}
void SetScrollableByAPZ(bool aScrollable);
void SetZoomableByAPZ(bool aZoomable);
- void SetScrollsClipOnUnscrolledOutOfFlow();
bool UsesContainerScrolling() const;
ScrollSnapInfo GetScrollSnapInfo() const;
bool DecideScrollableLayer(nsDisplayListBuilder* aBuilder,
nsRect* aDirtyRect,
bool aAllowCreateDisplayPort);
@@ -592,18 +591,16 @@ public:
bool mScrollableByAPZ:1;
// True if the APZ is allowed to zoom this scrollframe.
bool mZoomableByAPZ:1;
// True if we don't want the scrollbar to repaint itself right now.
bool mSuppressScrollbarRepaints:1;
- bool mScrollsClipOnUnscrolledOutOfFlow:1;
-
mozilla::layout::ScrollVelocityQueue mVelocityQueue;
protected:
class AutoScrollbarRepaintSuppression;
friend class AutoScrollbarRepaintSuppression;
class AutoScrollbarRepaintSuppression {
public:
AutoScrollbarRepaintSuppression(ScrollFrameHelper* aHelper, bool aSuppress)
@@ -1028,19 +1025,16 @@ public:
return mHelper.IsTransformingByAPZ();
}
void SetScrollableByAPZ(bool aScrollable) override {
mHelper.SetScrollableByAPZ(aScrollable);
}
void SetZoomableByAPZ(bool aZoomable) override {
mHelper.SetZoomableByAPZ(aZoomable);
}
- void SetScrollsClipOnUnscrolledOutOfFlow() override {
- mHelper.SetScrollsClipOnUnscrolledOutOfFlow();
- }
ScrollSnapInfo GetScrollSnapInfo() const override {
return mHelper.GetScrollSnapInfo();
}
virtual bool DragScroll(mozilla::WidgetEvent* aEvent) override {
return mHelper.DragScroll(aEvent);
}
@@ -1447,19 +1441,16 @@ public:
return mHelper.IsTransformingByAPZ();
}
void SetScrollableByAPZ(bool aScrollable) override {
mHelper.SetScrollableByAPZ(aScrollable);
}
void SetZoomableByAPZ(bool aZoomable) override {
mHelper.SetZoomableByAPZ(aZoomable);
}
- void SetScrollsClipOnUnscrolledOutOfFlow() override {
- mHelper.SetScrollsClipOnUnscrolledOutOfFlow();
- }
virtual bool DecideScrollableLayer(nsDisplayListBuilder* aBuilder,
nsRect* aDirtyRect,
bool aAllowCreateDisplayPort) override {
return mHelper.DecideScrollableLayer(aBuilder, aDirtyRect, aAllowCreateDisplayPort);
}
virtual void NotifyApproximateFrameVisibilityUpdate() override {
mHelper.NotifyApproximateFrameVisibilityUpdate();
}
--- a/layout/generic/nsIScrollableFrame.h
+++ b/layout/generic/nsIScrollableFrame.h
@@ -469,18 +469,16 @@ public:
*/
virtual void TriggerDisplayPortExpiration() = 0;
/**
* Returns information required to determine where to snap to after a scroll.
*/
virtual ScrollSnapInfo GetScrollSnapInfo() const = 0;
- virtual void SetScrollsClipOnUnscrolledOutOfFlow() = 0;
-
/**
* Given the drag event aEvent, determine whether the mouse is near the edge
* of the scrollable area, and scroll the view in the direction of that edge
* if so. If scrolling occurred, true is returned. When false is returned, the
* caller should look for an ancestor to scroll.
*/
virtual bool DragScroll(mozilla::WidgetEvent* aEvent) = 0;
};
--- a/layout/painting/DisplayListClipState.cpp
+++ b/layout/painting/DisplayListClipState.cpp
@@ -31,52 +31,29 @@ DisplayListClipState::GetCurrentCombined
} else {
mCurrentCombinedClip =
aBuilder->AllocateDisplayItemClip(*mClipContainingBlockDescendants);
}
return mCurrentCombinedClip;
}
void
-DisplayListClipState::SetScrollClipForContainingBlockDescendants(
- nsDisplayListBuilder* aBuilder,
- const DisplayItemScrollClip* aScrollClip)
-{
- if (aBuilder->IsPaintingToWindow() &&
- mClipContentDescendants &&
- aScrollClip != mScrollClipContainingBlockDescendants) {
- // Disable paint skipping for all scroll frames on the way to aScrollClip.
- for (const DisplayItemScrollClip* sc = mClipContentDescendantsScrollClip;
- sc && !DisplayItemScrollClip::IsAncestor(sc, aScrollClip);
- sc = sc->mParent) {
- if (sc->mScrollableFrame) {
- sc->mScrollableFrame->SetScrollsClipOnUnscrolledOutOfFlow();
- }
- }
- mClipContentDescendantsScrollClip = nullptr;
- }
- mScrollClipContainingBlockDescendants = aScrollClip;
- mStackingContextAncestorSC = DisplayItemScrollClip::PickAncestor(mStackingContextAncestorSC, aScrollClip);
-}
-
-void
DisplayListClipState::ClipContainingBlockDescendants(const nsRect& aRect,
const nscoord* aRadii,
DisplayItemClip& aClipOnStack)
{
if (aRadii) {
aClipOnStack.SetTo(aRect, aRadii);
} else {
aClipOnStack.SetTo(aRect);
}
if (mClipContainingBlockDescendants) {
aClipOnStack.IntersectWith(*mClipContainingBlockDescendants);
}
mClipContainingBlockDescendants = &aClipOnStack;
- mClipContentDescendantsScrollClip = GetCurrentInnermostScrollClip();
mCurrentCombinedClip = nullptr;
}
void
DisplayListClipState::ClipContentDescendants(const nsRect& aRect,
const nscoord* aRadii,
DisplayItemClip& aClipOnStack)
{
--- a/layout/painting/DisplayListClipState.h
+++ b/layout/painting/DisplayListClipState.h
@@ -25,17 +25,16 @@ namespace mozilla {
class DisplayListClipState {
public:
DisplayListClipState()
: mClipContentDescendants(nullptr)
, mClipContainingBlockDescendants(nullptr)
, mCurrentCombinedClip(nullptr)
, mScrollClipContentDescendants(nullptr)
, mScrollClipContainingBlockDescendants(nullptr)
- , mClipContentDescendantsScrollClip(nullptr)
, mStackingContextAncestorSC(nullptr)
{}
/**
* Returns intersection of mClipContainingBlockDescendants and
* mClipContentDescendants, allocated on aBuilder's arena.
*/
const DisplayItemClip* GetCurrentCombinedClip(nsDisplayListBuilder* aBuilder);
@@ -71,18 +70,21 @@ public:
private:
void SetClipForContainingBlockDescendants(const DisplayItemClip* aClip)
{
mClipContainingBlockDescendants = aClip;
mCurrentCombinedClip = nullptr;
}
- void SetScrollClipForContainingBlockDescendants(nsDisplayListBuilder* aBuilder,
- const DisplayItemScrollClip* aScrollClip);
+ void SetScrollClipForContainingBlockDescendants(const DisplayItemScrollClip* aScrollClip)
+ {
+ mScrollClipContainingBlockDescendants = aScrollClip;
+ mStackingContextAncestorSC = DisplayItemScrollClip::PickAncestor(mStackingContextAncestorSC, aScrollClip);
+ }
void Clear()
{
mClipContentDescendants = nullptr;
mClipContainingBlockDescendants = nullptr;
mCurrentCombinedClip = nullptr;
// We do not clear scroll clips.
}
@@ -178,21 +180,16 @@ private:
/**
* The same for scroll clips.
*/
const DisplayItemScrollClip* mScrollClipContentDescendants;
const DisplayItemScrollClip* mScrollClipContainingBlockDescendants;
/**
- * The scroll clip that was in effect when mClipContentDescendants was set.
- */
- const DisplayItemScrollClip* mClipContentDescendantsScrollClip;
-
- /**
* A scroll clip that is an ancestor of all the scroll clips that were
* "current" on this clip state since EnterStackingContextContents was
* called.
*/
const DisplayItemScrollClip* mStackingContextAncestorSC;
};
/**
@@ -430,20 +427,19 @@ public:
/**
* *aClip must survive longer than this object. Be careful!!!
*/
void SetClipForContainingBlockDescendants(const DisplayItemClip* aClip)
{
mState.SetClipForContainingBlockDescendants(aClip);
}
- void SetScrollClipForContainingBlockDescendants(nsDisplayListBuilder* aBuilder,
- const DisplayItemScrollClip* aScrollClip)
+ void SetScrollClipForContainingBlockDescendants(const DisplayItemScrollClip* aScrollClip)
{
- mState.SetScrollClipForContainingBlockDescendants(aBuilder, aScrollClip);
+ mState.SetScrollClipForContainingBlockDescendants(aScrollClip);
}
/**
* Intersects the given clip rect (with optional aRadii) with the current
* mClipContainingBlockDescendants and sets mClipContainingBlockDescendants to
* the result, stored in aClipOnStack.
*/
void ClipContainingBlockDescendantsExtra(const nsRect& aRect,