fune/browser/components/firefoxview/recentbrowsing.mjs
Sam Foster 2cd97ee94c Bug 1863783 - Ensure fxview page content only listens/observes and renders updates when visible. r=fxview-reviewers,sclements,jsudiaman
* Add a type=page to the top-level ViewPage instances
* Rename viewTabVisibleCallback and viewTabHiddenCallback to view*Callback and call each when selectedness or visiblity changes
* Ensure active view/pages are always properly initialized during page load and category switching
* Add a test to verify no mutations happen when tabs change while firefox view is inactive
* Fix tests to better account for loading and readiness sequence when activating firefox view

Differential Revision: https://phabricator.services.mozilla.com/D193744
2023-11-23 07:57:33 +00:00

48 lines
1.3 KiB
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { html } from "chrome://global/content/vendor/lit.all.mjs";
import { ViewPage } from "./viewpage.mjs";
class RecentBrowsingInView extends ViewPage {
constructor() {
super();
this.pageType = "recentbrowsing";
}
viewVisibleCallback() {
for (let child of this.children) {
let childView = child.firstElementChild;
childView.paused = false;
childView.viewVisibleCallback();
}
}
viewHiddenCallback() {
for (let child of this.children) {
let childView = child.firstElementChild;
childView.paused = true;
childView.viewHiddenCallback();
}
}
render() {
return html`
<link
rel="stylesheet"
href="chrome://browser/content/firefoxview/firefoxview-next.css"
/>
<div class="sticky-container bottom-fade">
<h2
class="page-header heading-large"
data-l10n-id="firefoxview-overview-header"
></h2>
</div>
<div class="cards-container">
<slot></slot>
</div>
`;
}
}
customElements.define("view-recentbrowsing", RecentBrowsingInView);