Bug 963829 - Include CSS/SVG transformations when calculating OFFSCREEN state. r=roc
--- 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>