Bug 1917458 - Factor out remote effects update. r=mstange
No behavior change, just moving code around for the following patches. Differential Revision: https://phabricator.services.mozilla.com/D222095
This commit is contained in:
@@ -499,11 +499,11 @@ static Maybe<OopIframeMetrics> GetOopIframeMetrics(
|
||||
return Some(OopIframeMetrics{});
|
||||
}
|
||||
|
||||
if (MOZ_UNLIKELY(browserChild->IsTopLevel())) {
|
||||
// FIXME(bug 1772083): This can be hit, but it's unclear how... When can we
|
||||
// have a top-level BrowserChild for a document that isn't a top-level
|
||||
// content document?
|
||||
MOZ_ASSERT_UNREACHABLE("Top level BrowserChild w/ non-top level Document?");
|
||||
if (MOZ_UNLIKELY(NS_WARN_IF(browserChild->IsTopLevel()))) {
|
||||
// FIXME(bug 1772083): This can be hit with popups, e.g. in
|
||||
// html/browsers/the-window-object/open-close/no_window_open_when_term_nesting_level_nonzero.window.html
|
||||
// temporarily while opening a new popup (on the about:blank doc).
|
||||
// MOZ_ASSERT_UNREACHABLE("Top level BrowserChild but non-top level doc?");
|
||||
return Nothing();
|
||||
}
|
||||
|
||||
|
||||
@@ -16808,42 +16808,39 @@ void Document::UpdateIntersections(TimeStamp aNowTime) {
|
||||
});
|
||||
}
|
||||
|
||||
void Document::UpdateRemoteFrameEffects() {
|
||||
if (auto* wc = GetWindowContext(); wc && !wc->Children().IsEmpty()) {
|
||||
auto margin = DOMIntersectionObserver::LazyLoadingRootMargin();
|
||||
const IntersectionInput input = DOMIntersectionObserver::ComputeInput(
|
||||
*this, /* aRoot = */ nullptr, &margin);
|
||||
for (const RefPtr<BrowsingContext>& child : wc->Children()) {
|
||||
Element* el = child->GetEmbedderElement();
|
||||
static void UpdateEffectsOnBrowsingContext(BrowsingContext* aBc,
|
||||
const IntersectionInput& aInput,
|
||||
bool aIsHidden) {
|
||||
Element* el = aBc->GetEmbedderElement();
|
||||
if (!el) {
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
auto* rb = RemoteBrowser::GetFrom(el);
|
||||
if (!rb) {
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
EffectsInfo info = [&] {
|
||||
if (Hidden()) {
|
||||
// If we're in the background, then the child frame should be hidden
|
||||
// as well.
|
||||
rb->UpdateEffects([&] {
|
||||
if (aIsHidden) {
|
||||
// Fully hidden if in the background.
|
||||
return EffectsInfo::FullyHidden();
|
||||
}
|
||||
const IntersectionOutput output = DOMIntersectionObserver::Intersect(
|
||||
input, *el, DOMIntersectionObserver::BoxToUse::Content);
|
||||
aInput, *el, DOMIntersectionObserver::BoxToUse::Content);
|
||||
if (!output.Intersects()) {
|
||||
// XXX do we want to pass the scale and such down even if out of the
|
||||
// viewport?
|
||||
return EffectsInfo::FullyHidden();
|
||||
}
|
||||
auto* frame = el->GetPrimaryFrame();
|
||||
MOZ_ASSERT(frame, "How do we intersect with no frame?");
|
||||
nsSubDocumentFrame* subDocFrame = do_QueryFrame(frame);
|
||||
MOZ_ASSERT(el->GetPrimaryFrame(), "How do we intersect without a frame?");
|
||||
nsSubDocumentFrame* subDocFrame = do_QueryFrame(el->GetPrimaryFrame());
|
||||
if (MOZ_UNLIKELY(NS_WARN_IF(!subDocFrame))) {
|
||||
// <frame> not inside a <frameset> might not create a subdoc frame,
|
||||
// for example.
|
||||
return EffectsInfo::FullyHidden();
|
||||
}
|
||||
Maybe<nsRect> visibleRect = subDocFrame->GetVisibleRect();
|
||||
Maybe<nsRect> visibleRect;
|
||||
gfx::MatrixScales rasterScale;
|
||||
visibleRect = subDocFrame->GetVisibleRect();
|
||||
if (!visibleRect) {
|
||||
// If we have no visible rect (e.g., because we are zero-sized) we
|
||||
// still want to provide the intersection rect in order to get the
|
||||
@@ -16851,16 +16848,25 @@ void Document::UpdateRemoteFrameEffects() {
|
||||
visibleRect.emplace(*output.mIntersectionRect -
|
||||
output.mTargetRect.TopLeft());
|
||||
}
|
||||
const gfx::MatrixScales rasterScale = subDocFrame->GetRasterScale();
|
||||
const ParentLayerToScreenScale2D transformToAncestorScale =
|
||||
rasterScale = subDocFrame->GetRasterScale();
|
||||
ParentLayerToScreenScale2D transformToAncestorScale =
|
||||
ParentLayerToParentLayerScale(
|
||||
frame->PresShell()->GetCumulativeResolution()) *
|
||||
nsLayoutUtils::
|
||||
GetTransformToAncestorScaleCrossProcessForFrameMetrics(frame);
|
||||
subDocFrame->PresShell()->GetCumulativeResolution()) *
|
||||
nsLayoutUtils::GetTransformToAncestorScaleCrossProcessForFrameMetrics(
|
||||
subDocFrame);
|
||||
return EffectsInfo::VisibleWithinRect(visibleRect, rasterScale,
|
||||
transformToAncestorScale);
|
||||
}();
|
||||
rb->UpdateEffects(std::move(info));
|
||||
}());
|
||||
}
|
||||
|
||||
void Document::UpdateRemoteFrameEffects() {
|
||||
auto margin = DOMIntersectionObserver::LazyLoadingRootMargin();
|
||||
const IntersectionInput input = DOMIntersectionObserver::ComputeInput(
|
||||
*this, /* aRoot = */ nullptr, &margin);
|
||||
const bool hidden = Hidden();
|
||||
if (auto* wc = GetWindowContext()) {
|
||||
for (const RefPtr<BrowsingContext>& child : wc->Children()) {
|
||||
UpdateEffectsOnBrowsingContext(child, input, hidden);
|
||||
}
|
||||
}
|
||||
EnumerateSubDocuments([](Document& aDoc) {
|
||||
|
||||
Reference in New Issue
Block a user