Bug 703241. Part 3: nsLayoutUtils::GetTransformToAncestor should handle the case where aAncestor == aFrame. r=matspal
authorRobert O'Callahan <robert@ocallahan.org>
Wed, 17 Oct 2012 16:13:24 +1300
changeset 110780 9d5f464dc1c011439ef075789c6b3df2c7ceb257
parent 110779 4033a060e7af1e2ae99194e0c489d3788ba2f944
child 110781 06f60c3d1f86cb05c64fe51e661b7074ccaf734d
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersmatspal
bugs703241
milestone19.0a1
Bug 703241. Part 3: nsLayoutUtils::GetTransformToAncestor should handle the case where aAncestor == aFrame. r=matspal
layout/base/nsLayoutUtils.cpp
layout/generic/test/test_bug791616.html
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -1297,17 +1297,21 @@ nsLayoutUtils::MatrixTransformPoint(cons
   return nsPoint(NSFloatPixelsToAppUnits(float(image.x), aFactor),
                  NSFloatPixelsToAppUnits(float(image.y), aFactor));
 }
 
 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();
     }
     ctm = ctm * parent->GetTransformMatrix(aAncestor, &parent);
   }
   return ctm;
 }
--- a/layout/generic/test/test_bug791616.html
+++ b/layout/generic/test/test_bug791616.html
@@ -30,17 +30,19 @@ var sel = window.getSelection();
 var smoothScrollPref = "general.smoothScroll";
 
 SimpleTest.waitForExplicitFinish();
 SpecialPowers.setBoolPref(smoothScrollPref, false);
 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);
   synthesizeKey("VK_LEFT", {});
 
   // Delay until next repaint in case stuff is asynchronous. Also
   // take a trip through the event loop.
   setTimeout(function() {