diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 536b855531b7..995db67be6c0 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -1302,7 +1302,11 @@ gfx3DMatrix nsLayoutUtils::GetTransformToAncestor(nsIFrame *aFrame, const nsIFrame *aAncestor) { nsIFrame* parent; - gfx3DMatrix ctm = aFrame->GetTransformMatrix(aAncestor, &parent); + gfx3DMatrix ctm; + if (aFrame == aAncestor) { + return ctm; + } + ctm = aFrame->GetTransformMatrix(aAncestor, &parent); while (parent && parent != aAncestor) { if (!parent->Preserves3DChildren()) { ctm.ProjectTo2D(); diff --git a/layout/generic/test/test_bug791616.html b/layout/generic/test/test_bug791616.html index 38b4de30adcb..4fd2b1e0975b 100644 --- a/layout/generic/test/test_bug791616.html +++ b/layout/generic/test/test_bug791616.html @@ -35,7 +35,9 @@ t.scrollTop = 0; var targetY = target.getBoundingClientRect().top; SimpleTest.waitForFocus(function() { + is(target.getBoundingClientRect().top, targetY, "Target should not have scrolled due to waitForFocus"); t.focus(); + is(target.getBoundingClientRect().top, targetY, "Target should not have scrolled due to focus change"); // Move the caret to scroll it into view sel.collapse(target.firstChild, 2);