Skip to content

Commit

Permalink
🔨 Add full compatibility with DevTools and RDM to browser frame
Browse files Browse the repository at this point in the history
  • Loading branch information
kierandrewett committed Dec 16, 2023
1 parent c9881bc commit f57cefe
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 61 deletions.
16 changes: 16 additions & 0 deletions base/content/browser-compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,27 @@ var gBrowser = {
return gDot.tabs.getTabForWebContents(browser);
},

/**
* @param {BrowserTab} tab
* @returns {ChromeBrowser}
*/
getBrowserForTab(tab) {
return tab.linkedBrowser;
},

/**
* @param {ChromeBrowser} browser
* @returns {HTMLElement}
*/
getBrowserContainer(browser) {
return this.getPanel(browser).querySelector("browser-web-container");
},

/**
* @param {ChromeBrowser} browser
* @returns {HTMLElement}
*/
getPanel(browser) {
const tab = gDot.tabs.getTabForWebContents(browser);
return tab.webContentsPanel;
},
Expand Down
1 change: 1 addition & 0 deletions base/content/browser-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ let elements = {
"browser-status": "chrome://dot/content/widgets/browser-status.js",
"browser-tabs": "chrome://dot/content/widgets/browser-tabs.js",
"browser-tabs-collator": "chrome://dot/content/widgets/browser-tabs-collator.js",
"browser-web-container": "chrome://dot/content/widgets/browser-web-container.js",
"browser-web-frame": "chrome://dot/content/widgets/browser-web-frame.js",
"browser-web-panel": "chrome://dot/content/widgets/browser-web-panel.js",
"browser-window-controls": "chrome://dot/content/widgets/browser-window-controls.js",
Expand Down
7 changes: 6 additions & 1 deletion components/tabs/BrowserTabs.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -850,13 +850,18 @@ BrowserTabs.prototype = {
const panelId = this._generateUniquePanelID();
panel.id = panelId;

const container = this._win.document.createElement(
"browser-web-container"
);

const frame = this._win.document.createElement("browser-web-frame");

tab.webContents.classList.add("browser-web-contents");
frame.appendChild(tab.webContents);
tab._webContentsPanelId = panelId;

panel.appendChild(frame);
container.appendChild(frame);
panel.appendChild(container);
this._tabpanelBoxEl.appendChild(panel);

if (this._isWebContentsBrowserElement(tab.webContents)) {
Expand Down
26 changes: 26 additions & 0 deletions components/tabs/content/browser-web-container.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* 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/. */

class BrowserWebContainer extends MozHTMLElement {
constructor() {
super();
}

get webContents() {
return this.querySelector(".browser-web-contents");
}

connectedCallback() {
if (this.delayConnectedCallback()) return;

// Needed for compatibility with external modules like DevTools
this.classList.add("browserContainer");
}

disconnectedCallback() {
if (this.delayConnectedCallback()) return;
}
}

customElements.define("browser-web-container", BrowserWebContainer);
3 changes: 3 additions & 0 deletions components/tabs/content/browser-web-frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class BrowserWebFrame extends MozHTMLElement {
connectedCallback() {
if (this.delayConnectedCallback()) return;

// Needed for compatibility with external modules like DevTools
this.classList.add("browserStack");

this.appendChild(html("browser-status"));
this.appendChild(html("browser-modals"));
}
Expand Down
20 changes: 16 additions & 4 deletions components/tabs/content/browser-web-panel.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

browser-web-panel {
position: absolute;
background-color: var(--browser-frame-background-color, var(--lwt-accent-color));
}

browser-web-panel,
browser-web-panel browser-web-container {
display: flex;
flex: 10000 10000;
min-height: 0;
flex-direction: column;
position: absolute;
flex-direction: row;
width: 100%;
height: 100%;
z-index: 1;
Expand All @@ -17,14 +22,21 @@ browser-web-panel:not([visible]) {
z-index: -2147483647;
}

browser-web-panel browser-web-frame {
browser-web-panel browser-web-container {
flex-direction: column;

--browser-stack-z-index-rdm-toolbar: 3;
}

browser-web-panel browser-web-container browser-web-frame {
display: grid;
flex: 10000 10000;
min-height: 25px;
min-width: 25px;
position: relative;
}

browser-web-panel browser-web-frame .browser-web-contents {
browser-web-panel browser-web-container browser-web-frame .browser-web-contents {
width: 100%;
height: 100%;
}
2 changes: 2 additions & 0 deletions components/tabs/jar.mn
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ dot.jar:
content/widgets/browser-web-panel.js (content/browser-web-panel.js)
content/widgets/browser-web-panel.css (content/browser-web-panel.css)

content/widgets/browser-web-container.js (content/browser-web-container.js)

content/widgets/browser-status.js (content/browser-status.js)
content/widgets/browser-status.css (content/browser-status.css)

Expand Down
53 changes: 0 additions & 53 deletions themes/shared/browser-box.css

This file was deleted.

2 changes: 0 additions & 2 deletions themes/shared/browser-shared.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/* Base */
@import url("chrome://dot/skin/browser-box.css");
@import url("chrome://dot/skin/browser-dialog.css");
@import url("chrome://dot/skin/browser-layouts.css");
@import url("chrome://dot/skin/browser-theme.css");
Expand Down Expand Up @@ -161,7 +160,6 @@ hr.fdn-separator {
z-index: 300;
-moz-window-dragging: no-drag;
color-scheme: unset;
background-color: var(--browser-frame-background-color, var(--lwt-accent-color));
}

#tabspanel:not([status]) browser-status {
Expand Down
1 change: 0 additions & 1 deletion themes/shared/jar.inc.mn
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# be specified once. As a result, the source file paths are relative
# to the location of the actual manifest.

skin/classic/dot/browser-box.css (../shared/browser-box.css)
skin/classic/dot/browser-dialog.css (../shared/browser-dialog.css)
skin/classic/dot/browser-layouts.css (../shared/browser-layouts.css)
skin/classic/dot/browser-shared.css (../shared/browser-shared.css)
Expand Down

0 comments on commit f57cefe

Please sign in to comment.