Bug 963829 - Include CSS/SVG transformations when calculating OFFSCREEN state. r=roc
authorEitan Isaacson <eitan@monotonous.org>
Tue, 28 Jan 2014 09:10:28 -0800
changeset 165625 535d21847e396c8d5e6dcd49e6dbca38eab3c259
parent 165624 4cd2059e557fbb459001b38e790cbc7633898474
child 165626 0c3303aa3d4040aad2d134042d31985fe2c1cd27
push id4623
push userryanvm@gmail.com
push dateTue, 28 Jan 2014 21:48:39 +0000
treeherderfx-team@7e79536aca0a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs963829
milestone29.0a1
Bug 963829 - Include CSS/SVG transformations when calculating OFFSCREEN state. r=roc
accessible/src/generic/Accessible.cpp
accessible/tests/mochitest/states/test_visibility.html
--- a/accessible/src/generic/Accessible.cpp
+++ b/accessible/src/generic/Accessible.cpp
@@ -576,17 +576,16 @@ Accessible::VisibilityState()
     return states::INVISIBLE;
 
   // Walk the parent frame chain to see if there's invisible parent or the frame
   // is in background tab.
   if (!frame->StyleVisibility()->IsVisible())
     return states::INVISIBLE;
 
   nsIFrame* curFrame = frame;
-  nsPoint framePos(0, 0);
   do {
     nsView* view = curFrame->GetView();
     if (view && view->GetVisibility() == nsViewVisibility_kHide)
       return states::INVISIBLE;
 
     if (nsLayoutUtils::IsPopup(curFrame))
       return 0;
 
@@ -600,21 +599,21 @@ Accessible::VisibilityState()
         return states::OFFSCREEN;
 
       NS_NOTREACHED("Children of not selected deck panel are not accessible.");
       return states::INVISIBLE;
     }
 
     // If contained by scrollable frame then check that at least 12 pixels
     // around the object is visible, otherwise the object is offscreen.
-    framePos += curFrame->GetPosition();
     nsIScrollableFrame* scrollableFrame = do_QueryFrame(parentFrame);
     if (scrollableFrame) {
       nsRect scrollPortRect = scrollableFrame->GetScrollPortRect();
-      nsRect frameRect(framePos, frame->GetSize());
+      nsRect frameRect = nsLayoutUtils::TransformFrameRectToAncestor(
+        frame, frame->GetRectRelativeToSelf(), parentFrame);
       if (!scrollPortRect.Contains(frameRect)) {
         const nscoord kMinPixels = nsPresContext::CSSPixelsToAppUnits(12);
         scrollPortRect.Deflate(kMinPixels, kMinPixels);
         if (!scrollPortRect.Intersects(frameRect))
           return states::OFFSCREEN;
       }
     }
 
--- a/accessible/tests/mochitest/states/test_visibility.html
+++ b/accessible/tests/mochitest/states/test_visibility.html
@@ -114,16 +114,17 @@
     gDocURI += "  <li>item4</li><li>item5</li><li id='li_last'>item6</li>";
     gDocURI += "</ul>";
     gDocURI += "</body></html>";
 
     function doTests()
     {
       testStates("div", 0, 0, STATE_INVISIBLE | STATE_OFFSCREEN);
       testStates("div_off", STATE_OFFSCREEN, 0, STATE_INVISIBLE);
+      testStates("div_transformed", STATE_OFFSCREEN, 0, STATE_INVISIBLE);
       testStates("div_abschild", 0, 0, STATE_INVISIBLE | STATE_OFFSCREEN);
 
       gQueue = new eventQueue();
 
       gQueue.push(new addTabInvoker("about:blank", testBackgroundTab));
       gQueue.push(new loadURIInvoker(gDocURI, testScrolledOff));
 
       gQueue.onFinish = function() { closeBrowserWindow(); }
@@ -155,16 +156,19 @@
 
   <div id="outer_div">
 
     <!-- trivial cases -->
     <div id="div">div</div>
     <div id="div_off" style="position: absolute; left:-999px; top:-999px">
       offscreen!
     </div>
+    <div id="div_transformed" style="transform: translate(-999px, -999px);">
+      transformed!
+    </div>
 
     <!-- edge case: no rect but has out of flow child -->
     <div id="div_abschild">
       <p style="position: absolute; left: 120px; top:120px;">absolute</p>
     </div>
 
   </div>
 </body>