From ddb35d3718fa5fa6c32dfc93cb1acdb68ad75a90 Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Fri, 10 May 2019 11:22:28 +0000 Subject: [PATCH] Bug 1541253 - Check PresShell::IsUnderHiddenEmbedderElement where we need to check CSS visibility state across the document boundary. r=tnikkel Depends on D26252 Differential Revision: https://phabricator.services.mozilla.com/D26253 --HG-- extra : moz-landing-system : lando --- accessible/generic/Accessible.cpp | 12 ++++++++---- layout/generic/nsFrame.cpp | 6 ++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/accessible/generic/Accessible.cpp b/accessible/generic/Accessible.cpp index 9ab3d69cb396..ac4bc66f7206 100644 --- a/accessible/generic/Accessible.cpp +++ b/accessible/generic/Accessible.cpp @@ -315,13 +315,19 @@ uint64_t Accessible::VisibilityState() const { 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; + // It's invisible if the presshell is hidden by a visibility:hidden element in + // an ancestor document. + if (frame->PresShell()->IsUnderHiddenEmbedderElement()) { + return states::INVISIBLE; + } + // Offscreen state if the document's visibility state is not visible. if (Document()->IsHidden()) return states::OFFSCREEN; + // Walk the parent frame chain to see if the frame is in background tab or + // scrolled out. nsIFrame* curFrame = frame; do { nsView* view = curFrame->GetView(); @@ -366,8 +372,6 @@ uint64_t Accessible::VisibilityState() const { if (!parentFrame) { parentFrame = nsLayoutUtils::GetCrossDocParentFrame(curFrame); - if (parentFrame && !parentFrame->StyleVisibility()->IsVisible()) - return states::INVISIBLE; } curFrame = parentFrame; diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 638c9f2c25d1..f8b7c05e6a5c 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -393,6 +393,10 @@ bool nsIFrame::IsVisibleConsideringAncestors(uint32_t aFlags) const { return false; } + if (PresShell()->IsUnderHiddenEmbedderElement()) { + return false; + } + const nsIFrame* frame = this; while (frame) { nsView* view = frame->GetView(); @@ -416,8 +420,6 @@ bool nsIFrame::IsVisibleConsideringAncestors(uint32_t aFlags) const { break; } - if (!parent->StyleVisibility()->IsVisible()) return false; - frame = parent; } }