diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index aa04b078f76..91c478d384b 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -4958,7 +4958,13 @@ static void LocateAnonymousFrame(nsIPresContext* aPresContext, nsCOMPtr content; aParentFrame->GetContent(getter_AddRefs(content)); if (content.get() == aTargetContent) { - *aResult = aParentFrame; + // We must take into account if the parent is a scrollframe. If it is, we + // need to bypass the scrolling mechanics and get at the true frame. + nsCOMPtr scrollFrame ( do_QueryInterface(aParentFrame) ); + if ( scrollFrame ) + scrollFrame->GetScrolledFrame ( aPresContext, *aResult ); + else + *aResult = aParentFrame; return; } diff --git a/layout/html/style/src/nsCSSFrameConstructor.cpp b/layout/html/style/src/nsCSSFrameConstructor.cpp index aa04b078f76..91c478d384b 100644 --- a/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -4958,7 +4958,13 @@ static void LocateAnonymousFrame(nsIPresContext* aPresContext, nsCOMPtr content; aParentFrame->GetContent(getter_AddRefs(content)); if (content.get() == aTargetContent) { - *aResult = aParentFrame; + // We must take into account if the parent is a scrollframe. If it is, we + // need to bypass the scrolling mechanics and get at the true frame. + nsCOMPtr scrollFrame ( do_QueryInterface(aParentFrame) ); + if ( scrollFrame ) + scrollFrame->GetScrolledFrame ( aPresContext, *aResult ); + else + *aResult = aParentFrame; return; }