Backed out changeset 04b102bec363 (bug 1147673)
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Wed, 16 Dec 2015 11:52:39 +0100
changeset 315809 89edfed8aa0eadfcc33767b4993b0edd628ce900
parent 315808 7001bc09174eb854db0bd242c93317b29f708577
child 315810 2a6fc436951bc28fd4261c9f5d12e838737149a2
push id8468
push userhurley@todesschaf.org
push dateWed, 16 Dec 2015 19:25:06 +0000
bugs1147673
milestone46.0a1
backs out04b102bec36340d84ef40658fae4a0856d762540
Backed out changeset 04b102bec363 (bug 1147673)
layout/generic/nsGfxScrollFrame.cpp
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -3040,37 +3040,29 @@ ScrollFrameHelper::BuildDisplayList(nsDi
             ? nsLayoutUtils::FindOrCreateIDFor(mScrolledFrame->GetContent())
             : aBuilder->GetCurrentScrollParentId());
 
     // We need to apply at least one clip, potentially more, and each needs to be applied
     // through a separate DisplayListClipState::AutoSaveRestore object.
     // clipStatePtr will always point to the innermost used one.
     DisplayListClipState::AutoSaveRestore clipState(aBuilder);
     DisplayListClipState::AutoSaveRestore* clipStatePtr = &clipState;
-
-    nsRect clipRect = mScrollPort + aBuilder->ToReferenceFrame(mOuter);
-    // Our override of GetBorderRadii ensures we never have a radius at
-    // the corners where we have a scrollbar.
-    nscoord radii[8];
-    bool haveRadii = mOuter->GetPaddingBoxBorderRadii(radii);
-    if (mIsRoot) {
-      clipRect.SizeTo(nsLayoutUtils::CalculateCompositionSizeForFrame(mOuter));
-      if (mOuter->PresContext()->IsRootContentDocument()) {
-        double res = mOuter->PresContext()->PresShell()->GetResolution();
-        clipRect.width = NSToCoordRound(clipRect.width / res);
-        clipRect.height = NSToCoordRound(clipRect.height / res);
+    if (!mIsRoot || !usingDisplayPort) {
+      nsRect clip = mScrollPort + aBuilder->ToReferenceFrame(mOuter);
+      nscoord radii[8];
+      bool haveRadii = mOuter->GetPaddingBoxBorderRadii(radii);
+      // Our override of GetBorderRadii ensures we never have a radius at
+      // the corners where we have a scrollbar.
+      if (mClipAllDescendants) {
+        clipState.ClipContentDescendants(clip, haveRadii ? radii : nullptr);
+      } else {
+        clipState.ClipContainingBlockDescendants(clip, haveRadii ? radii : nullptr);
       }
     }
 
-    if (mClipAllDescendants) {
-      clipState.ClipContentDescendants(clipRect, haveRadii ? radii : nullptr);
-    } else {
-      clipState.ClipContainingBlockDescendants(clipRect, haveRadii ? radii : nullptr);
-    }
-
     Maybe<DisplayListClipState::AutoSaveRestore> clipStateCaret;
     if (contentBoxClipForCaret) {
       clipStateCaret.emplace(aBuilder);
       clipStatePtr = &*clipStateCaret;
       if (mClipAllDescendants) {
         clipStateCaret->ClipContentDescendants(*contentBoxClipForCaret);
       } else {
         clipStateCaret->ClipContainingBlockDescendants(*contentBoxClipForCaret);
@@ -3266,28 +3258,44 @@ ScrollFrameHelper::ComputeFrameMetrics(L
                                        nsIFrame* aContainerReferenceFrame,
                                        const ContainerLayerParameters& aParameters,
                                        bool aIsForCaret) const
 {
   if (!mWillBuildScrollableLayer || mIsScrollableLayerInRootContainer) {
     return Nothing();
   }
 
+  bool needsParentLayerClip = true;
+  if (gfxPrefs::LayoutUseContainersForRootFrames() && !mAddClipRectToLayer) {
+    // For containerful frames, the clip is on the container frame.
+    needsParentLayerClip = false;
+  }
+
   const Maybe<DisplayItemClip>& ancestorClip = aIsForCaret ? mAncestorClipForCaret : mAncestorClip;
 
   nsPoint toReferenceFrame = mOuter->GetOffsetToCrossDoc(aContainerReferenceFrame);
+  bool isRootContent = mIsRoot && mOuter->PresContext()->IsRootContentDocument();
 
   Maybe<nsRect> parentLayerClip;
-  // For containerful frames, the clip is on the container layer.
-  if (ancestorClip &&
-      (!gfxPrefs::LayoutUseContainersForRootFrames() || mAddClipRectToLayer)) {
-    parentLayerClip = Some(ancestorClip->GetClipRect());
-  }
-
-  bool isRootContent = mIsRoot && mOuter->PresContext()->IsRootContentDocument();
+  if (needsParentLayerClip) {
+    nsRect clip = nsRect(mScrollPort.TopLeft() + toReferenceFrame,
+                         nsLayoutUtils::CalculateCompositionSizeForFrame(mOuter));
+    if (isRootContent) {
+      double res = mOuter->PresContext()->PresShell()->GetResolution();
+      clip.width = NSToCoordRound(clip.width / res);
+      clip.height = NSToCoordRound(clip.height / res);
+    }
+
+    if (ancestorClip && ancestorClip->HasClip()) {
+      clip = ancestorClip->GetClipRect().Intersect(clip);
+    }
+
+    parentLayerClip = Some(clip);
+  }
+
   bool thisScrollFrameUsesAsyncScrolling = nsLayoutUtils::UsesAsyncScrolling(mOuter);
 #if defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_ANDROID_APZ)
   // Android without apzc (aka the java pan zoom code) only uses async scrolling
   // for the root scroll frame of the root content document.
   if (!isRootContent) {
     thisScrollFrameUsesAsyncScrolling = false;
   }
 #endif