Index: Source/core/rendering/RenderLayer.cpp |
diff --git a/Source/core/rendering/RenderLayer.cpp b/Source/core/rendering/RenderLayer.cpp |
index 922e1a0ac76c8457a90283c6a378e9e52580d84b..18e6c98024aa4ffa81209a36960c7ae22485de67 100644 |
--- a/Source/core/rendering/RenderLayer.cpp |
+++ b/Source/core/rendering/RenderLayer.cpp |
@@ -416,6 +416,7 @@ bool RenderLayer::scrollsWithRespectTo(const RenderLayer* other) const |
const bool isRootFixedPos = position == FixedPosition && containingBlock->enclosingLayer() == rootLayer; |
const bool otherIsRootFixedPos = otherPosition == FixedPosition && otherContainingBlock->enclosingLayer() == rootLayer; |
+ // FIXME: some of these cases don't look quite right. |
if (isRootFixedPos && otherIsRootFixedPos) |
return false; |
if (isRootFixedPos || otherIsRootFixedPos) |
@@ -428,8 +429,13 @@ bool RenderLayer::scrollsWithRespectTo(const RenderLayer* other) const |
// closest scrollable ancestor. |
HashSet<const RenderObject*> containingBlocks; |
while (containingBlock) { |
- if (containingBlock->enclosingLayer()->scrollsOverflow()) |
+ if (containingBlock->enclosingLayer()->scrollsOverflow()) { |
break; |
+ } |
+ if (containingBlock->enclosingLayer() == other) { |
+ // This layer does not scroll with respect to the other layer if the other one does not scroll and this one is a child. |
+ return false; |
+ } |
containingBlocks.add(containingBlock); |
containingBlock = containingBlock->containingBlock(); |
} |
@@ -437,9 +443,14 @@ bool RenderLayer::scrollsWithRespectTo(const RenderLayer* other) const |
// Do the same for the 2nd layer, but if we find a common containing block, |
// it means both layers are contained within a single non-scrolling subtree. |
// Hence, they will not scroll with respect to each other. |
+ bool thisLayerScrollsOverflow = scrollsOverflow(); |
while (otherContainingBlock) { |
if (containingBlocks.contains(otherContainingBlock)) |
return false; |
+ // The other layer scrolls with respect to this one if this one scrolls and it's a child. |
+ if (!thisLayerScrollsOverflow && otherContainingBlock->enclosingLayer() == this) |
+ return false; |
+ // The other layer does not scroll with respect to this one if this one does not scroll and it's a child. |
if (otherContainingBlock->enclosingLayer()->scrollsOverflow()) |
break; |
otherContainingBlock = otherContainingBlock->containingBlock(); |