Bug 1368103 - Use DOM doc visibilityState to determine if a tab is hidden. r=surkov
authorEitan Isaacson <eitan@monotonous.org>
Fri, 26 May 2017 15:10:57 -0700
changeset 410327 6f99018495e75047836b845fa90e8289c7832303
parent 410326 31d8f2665ea0dd7c26b79b86656fc9f61feee26d
child 410328 e2cf349598c8fcd283fe6ba997d3b0d65ad0e6ae
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs1368103
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1368103 - Use DOM doc visibilityState to determine if a tab is hidden. r=surkov
accessible/generic/Accessible.cpp
accessible/generic/DocAccessible.h
--- a/accessible/generic/Accessible.cpp
+++ b/accessible/generic/Accessible.cpp
@@ -330,16 +330,20 @@ Accessible::VisibilityState()
   if (!frame)
     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;
 
+  // Offscreen state if the document's visibility state is not visible.
+  if (Document()->IsHidden())
+    return states::OFFSCREEN;
+
   nsIFrame* curFrame = frame;
   do {
     nsView* view = curFrame->GetView();
     if (view && view->GetVisibility() == nsViewVisibility_kHide)
       return states::INVISIBLE;
 
     if (nsLayoutUtils::IsPopup(curFrame))
       return 0;
--- a/accessible/generic/DocAccessible.h
+++ b/accessible/generic/DocAccessible.h
@@ -132,16 +132,21 @@ public:
   {
     // eDOMLoaded flag check is used for error pages as workaround to make this
     // method return correct result since error pages do not receive 'pageshow'
     // event and as consequence nsIDocument::IsShowing() returns false.
     return mDocumentNode && mDocumentNode->IsVisible() &&
       (mDocumentNode->IsShowing() || HasLoadState(eDOMLoaded));
   }
 
+  bool IsHidden() const
+  {
+    return mDocumentNode->Hidden();
+  }
+
   /**
    * Document load states.
    */
   enum LoadState {
     // initial tree construction is pending
     eTreeConstructionPending = 0,
     // initial tree construction done
     eTreeConstructed = 1,