Merge mozilla-central to mozilla-inbound. a=merge CLOSED TREE

This commit is contained in:
Oana Pop Rus 2019-04-26 01:20:21 +03:00
Родитель b768833e62 0082cd8b08
Коммит c39500b97e
191 изменённых файлов: 3285 добавлений и 1637 удалений

Просмотреть файл

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<blocklist lastupdate="1555528639011" xmlns="http://www.mozilla.org/2006/addons-blocklist">
<blocklist lastupdate="1556112119390" xmlns="http://www.mozilla.org/2006/addons-blocklist">
<emItems>
<emItem blockID="i334" id="{0F827075-B026-42F3-885D-98981EE7B1AE}">
<prefs/>
@ -2836,6 +2836,10 @@
<prefs/>
<versionRange minVersion="0" maxVersion="*" severity="3"/>
</emItem>
<emItem blockID="ae288e5e-78d5-4b49-8b4d-fa9f25c3baa2" id="{3f5f741d-a980-4b58-8552-b1ae328841f4}">
<prefs/>
<versionRange minVersion="0" maxVersion="*" severity="3"/>
</emItem>
</emItems>
<pluginItems>
<pluginItem blockID="p332">

Просмотреть файл

@ -8,6 +8,9 @@
XPCOMUtils.defineLazyScriptGetter(this, ["PlacesToolbar", "PlacesMenu",
"PlacesPanelview", "PlacesPanelMenuView"],
"chrome://browser/content/places/browserPlacesViews.js");
XPCOMUtils.defineLazyModuleGetters(this, {
BookmarkPanelHub: "resource://activity-stream/lib/BookmarkPanelHub.jsm",
});
var StarUI = {
_itemGuids: null,
@ -182,6 +185,21 @@ var StarUI = {
}
},
getRecommendation(data) {
return BookmarkPanelHub.messageRequest(data, window);
},
toggleRecommendation(visible) {
const info = this._element("editBookmarkPanelInfoButton");
info.checked = visible !== undefined ? !!visible : !info.checked;
const recommendation = this._element("editBookmarkPanelRecommendation");
if (info.checked) {
recommendation.removeAttribute("disabled");
} else {
recommendation.setAttribute("disabled", "disabled");
}
},
async showEditBookmarkPopup(aNode, aIsNewBookmark, aUrl) {
// Slow double-clicks (not true double-clicks) shouldn't
// cause the panel to flicker.
@ -223,6 +241,21 @@ var StarUI = {
this._setIconAndPreviewImage();
const showRecommendation = await this.getRecommendation({
container: this._element("editBookmarkPanelRecommendation"),
createElement: elem => document.createElementNS("http://www.w3.org/1999/xhtml", elem),
url: aUrl.href,
close: e => {
e.stopPropagation();
this.toggleRecommendation(false);
},
hidePopup: () => {
this.panel.hidePopup();
},
});
this._element("editBookmarkPanelInfoButton").disabled = !showRecommendation;
this.toggleRecommendation(showRecommendation);
this.beginBatch();
this._anchorElement = BookmarkingUI.anchor;

Просмотреть файл

@ -273,11 +273,17 @@
aria-labelledby="editBookmarkPanelTitle">
<box class="panel-header">
<label id="editBookmarkPanelTitle"/>
<toolbarbutton id="editBookmarkPanelInfoButton" oncommand="StarUI.toggleRecommendation();" >
<image/>
</toolbarbutton>
</box>
<html:div id="editBookmarkPanelFaviconContainer">
<html:img id="editBookmarkPanelFavicon"/>
<html:div id="editBookmarkPanelInfoArea">
<html:div id="editBookmarkPanelRecommendation"></html:div>
<html:div id="editBookmarkPanelFaviconContainer">
<html:img id="editBookmarkPanelFavicon"/>
</html:div>
<html:div id="editBookmarkPanelImage"></html:div>
</html:div>
<box id="editBookmarkPanelImage"/>
#include ../../components/places/content/editBookmarkPanel.inc.xul
<vbox id="editBookmarkPanelBottomContent"
flex="1">

Просмотреть файл

@ -27,7 +27,6 @@ add_task(async function() {
// behaviour when opening a new window, even if windows have been
// opened in previous tests.
Services.obs.notifyObservers(null, "startupcache-invalidate");
Services.obs.notifyObservers(null, "chrome-flush-skin-caches");
Services.obs.notifyObservers(null, "chrome-flush-caches");
let win = window.openDialog(AppConstants.BROWSER_CHROME_URL, "_blank",

Просмотреть файл

@ -25,7 +25,6 @@ class AboutRedirector : public nsIAboutModule {
private:
static bool sNewTabPageEnabled;
static bool sNewCertErrorPageEnabled;
};
} // namespace browser

Просмотреть файл

@ -12,6 +12,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
FxAccounts: "resource://gre/modules/FxAccounts.jsm",
AppConstants: "resource://gre/modules/AppConstants.jsm",
OS: "resource://gre/modules/osfile.jsm",
BookmarkPanelHub: "resource://activity-stream/lib/BookmarkPanelHub.jsm",
});
const {ASRouterActions: ra, actionTypes: at, actionCreators: ac} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm");
const {CFRMessageProvider} = ChromeUtils.import("resource://activity-stream/lib/CFRMessageProvider.jsm");
@ -519,6 +520,7 @@ class _ASRouter {
ASRouterPreferences.init();
ASRouterPreferences.addListener(this.onPrefChange);
BookmarkPanelHub.init(this.dispatch);
const messageBlockList = await this._storage.get("messageBlockList") || [];
const providerBlockList = await this._storage.get("providerBlockList") || [];
@ -547,6 +549,7 @@ class _ASRouter {
ASRouterPreferences.removeListener(this.onPrefChange);
ASRouterPreferences.uninit();
BookmarkPanelHub.uninit();
// Uninitialise all trigger listeners
for (const listener of ASRouterTriggerListeners.values()) {
@ -901,6 +904,14 @@ class _ASRouter {
await this._sendMessageToTarget(message, target, trigger);
}
async handleMessageRequest(trigger, target) {
const msgs = this._getUnblockedMessages();
const message = await this._findMessage(
msgs.filter(m => m.trigger && m.trigger.id === trigger.id),
trigger);
target.sendMessage({message});
}
async setMessageById(id, target, force = true, action = {}) {
await this.setState({lastMessageId: id});
const newMessage = this.getMessageById(id);
@ -1099,9 +1110,18 @@ class _ASRouter {
target.browser.ownerGlobal.ConfirmationHint.show(tab, "pinTab", {showDescription: true});
break;
case ra.SHOW_FIREFOX_ACCOUNTS:
const url = await FxAccounts.config.promiseSignUpURI("snippets");
// We want to replace the current tab.
target.browser.ownerGlobal.openLinkIn(url, "current", {
let url;
const entrypoint = action.entrypoint || "snippets";
switch (action.method) {
case "emailFirst":
url = await FxAccounts.config.promiseEmailFirstURI(entrypoint);
break;
default:
url = await FxAccounts.config.promiseSignUpURI(entrypoint);
break;
}
const where = action.where || "current";
target.browser.ownerGlobal.openLinkIn(url, where, {
private: false,
triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({}),
csp: null,
@ -1222,6 +1242,13 @@ class _ASRouter {
break;
case "FORCE_ATTRIBUTION":
this.forceAttribution(action.data);
break;
case "MESSAGE_REQUEST":
this.handleMessageRequest(action.data.trigger, target);
break;
default:
Cu.reportError("Unknown message received");
break;
}
}
}

Просмотреть файл

@ -235,7 +235,7 @@ const PREFS_CONFIG = new Map([
collapsible: true,
enabled: isEnabled,
show_spocs: showSpocs({geo}),
hardcoded_layout: false,
hardcoded_layout: true,
personalized: false,
// This is currently an exmple layout used for dev purposes.
layout_endpoint: "https://getpocket.cdn.mozilla.net/v3/newtab/layout?version=1&consumer_key=$apiKey&layout_variant=basic",

Просмотреть файл

@ -0,0 +1,145 @@
/* 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/. */
"use strict";
ChromeUtils.defineModuleGetter(this, "DOMLocalization",
"resource://gre/modules/DOMLocalization.jsm");
class _BookmarkPanelHub {
constructor() {
this._id = "BookmarkPanelHub";
this._dispatchToASR = null;
this._initalized = false;
this._response = null;
this._l10n = null;
this.dispatch = this.dispatch.bind(this);
this.messageRequest = this.messageRequest.bind(this);
}
init(dispatch) {
this._dispatchToASR = dispatch;
this._l10n = new DOMLocalization([
"browser/newtab/asrouter.ftl",
]);
this._initalized = true;
}
uninit() {
this._l10n = null;
this._dispatchToASR = null;
this._initalized = false;
}
dispatch(message, target) {
return this._dispatchToASR(message, target);
}
/**
* Checks if a similar cached requests exists before forwarding the request
* to ASRouter. Caches only 1 request, unique identifier is `request.url`.
* Caching ensures we don't duplicate requests and telemetry pings.
*/
async messageRequest(target, win) {
if (this._request && this._message.url === target.url) {
this.onResponse(this._response, target);
return !!this._response;
}
const waitForASRMessage = new Promise((resolve, reject) => {
this.dispatch({
type: "MESSAGE_REQUEST",
source: this._id,
data: {trigger: {id: "bookmark-panel"}},
}, {sendMessage: resolve});
});
const response = await waitForASRMessage;
this.onResponse(response, target, win);
return !!this._response;
}
/**
* If the response contains a message render it and send an impression.
* Otherwise we remove the message from the container.
*/
onResponse(response, target, win) {
if (response && response.message) {
this._response = {
...response,
url: target.url,
};
this.showMessage(response.message.content, target, win);
this.sendImpression();
} else {
// If we didn't get a message response we need to remove and clear
// any existing messages
this._response = null;
this.hideMessage(target);
}
}
showMessage(message, target, win) {
const {createElement} = target;
if (!target.container.querySelector("#cfrMessageContainer")) {
const recommendation = createElement("div");
recommendation.setAttribute("id", "cfrMessageContainer");
recommendation.addEventListener("click", e => {
target.hidePopup();
this._dispatchToASR(
{type: "USER_ACTION", data: {
type: "SHOW_FIREFOX_ACCOUNTS",
entrypoint: "bookmark",
method: "emailFirst",
where: "tabshifted"
}},
{browser: win.gBrowser.selectedBrowser});
});
recommendation.style.color = message.color;
recommendation.style.background = `-moz-linear-gradient(-45deg, ${message.background_color_1} 0%, ${message.background_color_2} 70%)`;
const close = createElement("a");
close.setAttribute("id", "cfrClose");
close.setAttribute("aria-label", "close"); // TODO localize
close.addEventListener("click", target.close);
const title = createElement("h1");
title.setAttribute("id", "editBookmarkPanelRecommendationTitle");
title.textContent = "Sync your bookmarks everywhere.";
this._l10n.setAttributes(title, message.title);
const content = createElement("p");
content.setAttribute("id", "editBookmarkPanelRecommendationContent");
content.textContent = "Great find! Now dont be left without this bookmark on your mobile devices. Get started with a Firefox Account.";
this._l10n.setAttributes(content, message.text);
const cta = createElement("button");
cta.setAttribute("id", "editBookmarkPanelRecommendationCta");
cta.textContent = "Sync my bookmarks …";
this._l10n.setAttributes(cta, message.cta);
recommendation.appendChild(close);
recommendation.appendChild(title);
recommendation.appendChild(content);
recommendation.appendChild(cta);
// this._l10n.translateElements([...recommendation.children]);
target.container.appendChild(recommendation);
}
}
hideMessage(target) {
const container = target.container.querySelector("#cfrMessageContainer");
if (container) {
container.remove();
}
}
sendImpression() {
this.dispatch({
type: "IMPRESSION",
source: this._id,
data: {},
});
}
}
this.BookmarkPanelHub = new _BookmarkPanelHub();
const EXPORTED_SYMBOLS = ["BookmarkPanelHub"];

Просмотреть файл

@ -474,11 +474,11 @@ var gPrivacyPane = {
// If any relevant content blocking pref changes, show a warning that the changes will
// not be implemented until they refresh their tabs.
for (let pref of CONTENT_BLOCKING_PREFS) {
Preferences.get(pref).on("change", gPrivacyPane.notifyUserToReload);
Preferences.get(pref).on("change", gPrivacyPane.maybeNotifyUserToReload);
}
Preferences.get("urlclassifier.trackingTable").on("change", gPrivacyPane.notifyUserToReload);
Preferences.get("urlclassifier.trackingTable").on("change", gPrivacyPane.maybeNotifyUserToReload);
for (let button of document.querySelectorAll(".reload-tabs-button")) {
button.addEventListener("command", gPrivacyPane.reloadAllTabs);
button.addEventListener("command", gPrivacyPane.reloadAllOtherTabs);
}
let cryptoMinersOption = document.getElementById("contentBlockingCryptominersOption");
@ -1121,21 +1121,42 @@ var gPrivacyPane = {
},
/**
* Reload all tabs in all windows.
* Reload all tabs in all windows, except the active Preferences tab.
*/
reloadAllTabs() {
reloadAllOtherTabs() {
let activeWindow = window.BrowserWindowTracker.getTopWindow();
let selectedPrefTab = activeWindow.gBrowser.selectedTab;
for (let win of window.BrowserWindowTracker.orderedWindows) {
let tabbrowser = win.gBrowser;
tabbrowser.reloadTabs(tabbrowser.tabs);
let tabsToReload = [...tabbrowser.tabs];
if (win == activeWindow ) {
tabsToReload = tabsToReload.filter(tab => tab !== selectedPrefTab);
}
tabbrowser.reloadTabs(tabsToReload);
}
for (let notification of document.querySelectorAll(".reload-tabs")) {
notification.hidden = true;
}
},
/**
* Show a warning to the user that they need to reload their tabs to apply the setting.
* If there are more tabs than just the preferences tab, show a warning to the user that
* they need to reload their tabs to apply the setting.
*/
notifyUserToReload() {
for (let notification of document.querySelectorAll(".reload-tabs")) {
notification.hidden = false;
maybeNotifyUserToReload() {
let shouldShow = false;
if (window.BrowserWindowTracker.orderedWindows.length > 1) {
shouldShow = true;
} else {
let tabbrowser = window.BrowserWindowTracker.getTopWindow().gBrowser;
if (tabbrowser.tabs.length > 1) {
shouldShow = true;
}
}
if (shouldShow) {
for (let notification of document.querySelectorAll(".reload-tabs")) {
notification.hidden = false;
}
}
},

Просмотреть файл

@ -11,6 +11,7 @@ const FP_PREF = "privacy.trackingprotection.fingerprinting.enabled";
const CM_PREF = "privacy.trackingprotection.cryptomining.enabled";
const PREF_TEST_NOTIFICATIONS = "browser.safebrowsing.test-notifications.enabled";
const STRICT_PREF = "browser.contentblocking.features.strict";
const PRIVACY_PAGE = "about:preferences#privacy";
const {
EnterprisePolicyTesting,
@ -491,3 +492,45 @@ add_task(async function testContentBlockingReloadWarning() {
Services.prefs.setStringPref(CAT_PREF, "standard");
gBrowser.removeCurrentTab();
});
// Tests that changing a content blocking pref does not show the content blocking warning
// if it is the only tab.
add_task(async function testContentBlockingReloadWarning() {
Services.prefs.setStringPref(CAT_PREF, "standard");
await BrowserTestUtils.loadURI(gBrowser.selectedBrowser, PRIVACY_PAGE);
let reloadWarnings = [...gBrowser.contentDocument.querySelectorAll(".content-blocking-warning.reload-tabs")];
ok(reloadWarnings.every((el) => el.hidden), "all of the warnings to reload tabs are initially hidden");
is(BrowserWindowTracker.windowCount, 1, "There is only one window open");
is(gBrowser.tabs.length, 1, "There is only one tab open");
Services.prefs.setStringPref(CAT_PREF, "strict");
ok(reloadWarnings.every((el) => el.hidden), "all of the warnings to reload tabs are still hidden");
Services.prefs.setStringPref(CAT_PREF, "standard");
await BrowserTestUtils.loadURI(gBrowser.selectedBrowser, "about:newtab");
});
// Checks that the reload tabs message reloads all tabs except the active tab.
add_task(async function testReloadTabsMessage() {
Services.prefs.setStringPref(CAT_PREF, "strict");
let exampleTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com");
await openPreferencesViaOpenPreferencesAPI("privacy", {leaveOpen: true});
let doc = gBrowser.contentDocument;
let standardWarning = doc.querySelector("#contentBlockingOptionStandard .content-blocking-warning.reload-tabs");
let standardReloadButton = doc.querySelector("#contentBlockingOptionStandard .reload-tabs-button");
Services.prefs.setStringPref(CAT_PREF, "standard");
ok(!BrowserTestUtils.is_hidden(standardWarning), "The warning in the standard section should be showing");
standardReloadButton.click();
// The example page had a load event
await BrowserTestUtils.browserLoaded(exampleTab.linkedBrowser);
ok(BrowserTestUtils.is_hidden(standardWarning), "The warning in the standard section should have hidden after being clicked");
// cleanup
Services.prefs.setStringPref(CAT_PREF, "standard");
gBrowser.removeTab(exampleTab);
gBrowser.removeCurrentTab();
});

Просмотреть файл

@ -34,7 +34,7 @@ fieldset > legend {
}
option:nth-child(even) {
background-color: -moz-oddtreerow;
background-color: var(--in-content-box-background-odd);
}
#addresses,

Просмотреть файл

@ -4,10 +4,6 @@
@import url("chrome://browser/skin/error-pages.css");
:root {
--exception-button-container-background: #F5F5F7;
}
body.certerror {
width: 100%;
justify-content: normal;
@ -64,7 +60,7 @@ button:disabled {
}
#advancedPanelButtonContainer {
background-color: var(--exception-button-container-background);
background-color: rgba(128, 128, 147, 0.1);
display: flex;
justify-content: end;
padding: 5px;
@ -124,8 +120,8 @@ body:not(.neterror) #advancedButton {
.advanced-panel {
/* Hidden until the link is clicked */
display: none;
background-color: white;
border: 1px lightgray solid;
background-color: var(--in-content-box-background);
border: 1px solid var(--in-content-box-border-color);
margin: 48px auto;
min-width: var(--in-content-container-min-width);
max-width: var(--in-content-container-max-width);
@ -200,7 +196,6 @@ body:not(.neterror) #advancedButton {
}
.exceptionDialogButtonContainer {
background-color: var(--exception-button-container-background);
display: flex;
justify-content: end;
}

Просмотреть файл

@ -8,6 +8,115 @@
padding: 0;
}
#editBookmarkPanelTitle {
margin-inline-start: 32px;
}
#editBookmarkPanelInfoButton {
border-radius: var(--toolbarbutton-border-radius);
margin-right: 4px;
}
#editBookmarkPanelInfoButton[disabled=true] {
visibility: hidden;
}
#editBookmarkPanelInfoButton[checked] {
background-color: var(--toolbarbutton-active-background);
}
#editBookmarkPanelInfoButton:hover {
background-color: var(--toolbarbutton-hover-background);
}
#editBookmarkPanelInfoButton > image {
list-style-image: url(chrome://browser/skin/identity-icon.svg);
-moz-context-properties: fill, fill-opacity;
fill: currentColor;
fill-opacity: var(--toolbarbutton-icon-fill-opacity);
padding: 2px;
}
#editBookmarkPanelInfoArea {
overflow: hidden;
position: relative;
margin: 6px 8px 0 8px;
}
#editBookmarkPanelRecommendation {
position: absolute;
height: 100%;
transition: all 0.25s cubic-bezier(0.07, 0.95, 0, 1);
}
#editBookmarkPanelRecommendation[disabled] {
transform: translateY(-100%);
}
#editBookmarkPanelRecommendation > div {
border-radius: 2px;
display: flex;
flex-direction: column;
text-align: left;
height: 150px;
cursor: pointer;
position: relative;
padding: 0 16px;
}
#editBookmarkPanelRecommendation > div::-moz-focus-inner {
border: none;
}
#editBookmarkPanelRecommendation > div * {
max-width: 220px;
}
#editBookmarkPanelRecommendationTitle {
font-size: 1.5rem;
font-weight: 400;
line-height: 1.25;
margin-bottom: 6px;
padding-top: 2px;
}
#editBookmarkPanelRecommendationContent {
font-size: 1rem;
line-height: 1.5;
margin: 0;
}
#editBookmarkPanelRecommendationCta {
-moz-appearance: none;
background: transparent;
border: none;
color: inherit;
cursor: pointer;
font-size: 1rem;
font-weight: 700;
margin: auto 0;
padding: 0;
text-align: start;
}
#editBookmarkPanelRecommendation #cfrClose {
position: absolute;
right: 18px;
top: 18px;
width: 12px;
height: 12px;
background-image: url(chrome://browser/skin/stop.svg);
background-size: 12px;
background-repeat: no-repeat;
-moz-context-properties: fill, fill-opacity;
fill: currentColor;
fill-opacity: 0.6;
}
#editBookmarkPanelRecommendation #cfrClose:hover {
fill-opacity: 1;
}
html|div#editBookmarkPanelFaviconContainer {
display: flex;
}
@ -26,11 +135,12 @@ html|img#editBookmarkPanelFavicon[src] {
}
#editBookmarkPanelImage {
border-bottom: 1px solid var(--panel-separator-color);
border-radius: 2px;
height: 150px;
background-image: -moz-element(#editBookmarkPanelImageCanvas);
background-repeat: no-repeat;
background-size: cover;
margin: 0 2px;
}
#editBookmarkPanelRows,

Просмотреть файл

@ -41,7 +41,6 @@ nsChromeRegistry* nsChromeRegistry::gChromeRegistry;
using mozilla::PresShell;
using mozilla::StyleSheet;
using mozilla::dom::Document;
using mozilla::dom::IsChromeURI;
using mozilla::dom::Location;
////////////////////////////////////////////////////////////////////////////////
@ -273,146 +272,6 @@ nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURI, nsIURI** aResult) {
////////////////////////////////////////////////////////////////////////
// theme stuff
static void FlushSkinBindingsForWindow(nsPIDOMWindowOuter* aWindow) {
// Get the document.
RefPtr<Document> document = aWindow->GetDoc();
if (!document) return;
// Annihilate all XBL bindings.
document->FlushSkinBindings();
}
// XXXbsmedberg: move this to nsIWindowMediator
NS_IMETHODIMP nsChromeRegistry::RefreshSkins() {
nsCOMPtr<nsIWindowMediator> windowMediator(
do_GetService(NS_WINDOWMEDIATOR_CONTRACTID));
if (!windowMediator) return NS_OK;
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
windowMediator->GetEnumerator(nullptr, getter_AddRefs(windowEnumerator));
bool more;
windowEnumerator->HasMoreElements(&more);
while (more) {
nsCOMPtr<nsISupports> protoWindow;
windowEnumerator->GetNext(getter_AddRefs(protoWindow));
if (protoWindow) {
nsCOMPtr<nsPIDOMWindowOuter> domWindow = do_QueryInterface(protoWindow);
if (domWindow) FlushSkinBindingsForWindow(domWindow);
}
windowEnumerator->HasMoreElements(&more);
}
FlushSkinCaches();
windowMediator->GetEnumerator(nullptr, getter_AddRefs(windowEnumerator));
windowEnumerator->HasMoreElements(&more);
while (more) {
nsCOMPtr<nsISupports> protoWindow;
windowEnumerator->GetNext(getter_AddRefs(protoWindow));
if (protoWindow) {
nsCOMPtr<nsPIDOMWindowOuter> domWindow = do_QueryInterface(protoWindow);
if (domWindow) RefreshWindow(domWindow);
}
windowEnumerator->HasMoreElements(&more);
}
return NS_OK;
}
void nsChromeRegistry::FlushSkinCaches() {
nsCOMPtr<nsIObserverService> obsSvc = mozilla::services::GetObserverService();
NS_ASSERTION(obsSvc, "Couldn't get observer service.");
obsSvc->NotifyObservers(static_cast<nsIChromeRegistry*>(this),
NS_CHROME_FLUSH_SKINS_TOPIC, nullptr);
}
// XXXbsmedberg: move this to windowmediator
nsresult nsChromeRegistry::RefreshWindow(nsPIDOMWindowOuter* aWindow) {
// Deal with our subframes first.
nsDOMWindowList* frames = aWindow->GetFrames();
uint32_t length = frames->GetLength();
for (uint32_t j = 0; j < length; j++) {
nsCOMPtr<nsPIDOMWindowOuter> piWindow = frames->IndexedGetter(j);
RefreshWindow(piWindow);
}
nsresult rv;
// Get the document.
RefPtr<Document> document = aWindow->GetDoc();
if (!document) return NS_OK;
// Deal with the agent sheets first. Have to do all the style sets by hand.
RefPtr<PresShell> presShell = document->GetPresShell();
if (presShell) {
// Reload only the chrome URL agent style sheets.
nsTArray<RefPtr<StyleSheet>> agentSheets;
rv = presShell->GetAgentStyleSheets(agentSheets);
NS_ENSURE_SUCCESS(rv, rv);
nsTArray<RefPtr<StyleSheet>> newAgentSheets;
for (StyleSheet* sheet : agentSheets) {
nsIURI* uri = sheet->GetSheetURI();
if (IsChromeURI(uri)) {
// Reload the sheet.
RefPtr<StyleSheet> newSheet;
rv = document->LoadChromeSheetSync(uri, true, &newSheet);
if (NS_FAILED(rv)) return rv;
if (newSheet) {
newAgentSheets.AppendElement(newSheet);
return NS_OK;
}
} else { // Just use the same sheet.
rv = newAgentSheets.AppendElement(sheet) ? NS_OK : NS_ERROR_FAILURE;
if (NS_FAILED(rv)) return rv;
}
}
rv = presShell->SetAgentStyleSheets(newAgentSheets);
NS_ENSURE_SUCCESS(rv, rv);
}
size_t count = document->SheetCount();
// Build an array of style sheets we need to reload.
nsTArray<RefPtr<StyleSheet>> oldSheets(count);
nsTArray<RefPtr<StyleSheet>> newSheets(count);
// Iterate over the style sheets.
for (size_t i = 0; i < count; i++) {
// Get the style sheet
oldSheets.AppendElement(document->SheetAt(i));
}
// Iterate over our old sheets and kick off a sync load of the new
// sheet if and only if it's a non-inline sheet with a chrome URL.
for (StyleSheet* sheet : oldSheets) {
MOZ_ASSERT(sheet,
"SheetAt shouldn't return nullptr for "
"in-range sheet indexes");
nsIURI* uri = sheet->GetSheetURI();
if (!sheet->IsInline() && IsChromeURI(uri)) {
// Reload the sheet.
RefPtr<StyleSheet> newSheet;
// XXX what about chrome sheets that have a title or are disabled? This
// only works by sheer dumb luck.
document->LoadChromeSheetSync(uri, false, &newSheet);
// Even if it's null, we put in in there.
newSheets.AppendElement(newSheet);
} else {
// Just use the same sheet.
newSheets.AppendElement(sheet);
}
}
// Now notify the document that multiple sheets have been added and removed.
document->UpdateStyleSheets(oldSheets, newSheets);
return NS_OK;
}
void nsChromeRegistry::FlushAllCaches() {
nsCOMPtr<nsIObserverService> obsSvc = mozilla::services::GetObserverService();

Просмотреть файл

@ -42,7 +42,6 @@ class nsChromeRegistry : public nsIToolkitChromeRegistry,
NS_DECL_ISUPPORTS
// nsIXULChromeRegistry methods:
NS_IMETHOD RefreshSkins() override;
NS_IMETHOD AllowScriptsForPackage(nsIURI* url, bool* _retval) override;
NS_IMETHOD AllowContentToAccess(nsIURI* url, bool* _retval) override;
NS_IMETHOD CanLoadURLRemotely(nsIURI* url, bool* _retval) override;

Просмотреть файл

@ -37,8 +37,8 @@
#include "nsIScriptError.h"
#include "nsIXULRuntime.h"
#define SELECTED_SKIN_PREF "general.skins.selectedSkin"
#define PACKAGE_OVERRIDE_BRANCH "chrome.override_package."
#define SKIN NS_LITERAL_CSTRING("classic/1.0")
using namespace mozilla;
using mozilla::dom::ContentParent;
@ -94,33 +94,10 @@ nsresult nsChromeRegistryChrome::Init() {
nsresult rv = nsChromeRegistry::Init();
if (NS_FAILED(rv)) return rv;
mSelectedSkin = NS_LITERAL_CSTRING("classic/1.0");
bool safeMode = false;
nsCOMPtr<nsIXULRuntime> xulrun(do_GetService(XULAPPINFO_SERVICE_CONTRACTID));
if (xulrun) xulrun->GetInSafeMode(&safeMode);
nsCOMPtr<nsIPrefService> prefserv(do_GetService(NS_PREFSERVICE_CONTRACTID));
nsCOMPtr<nsIPrefBranch> prefs;
if (prefserv) {
if (safeMode) {
prefserv->GetDefaultBranch(nullptr, getter_AddRefs(prefs));
} else {
prefs = do_QueryInterface(prefserv);
}
}
if (!prefs) {
NS_WARNING("Could not get pref service!");
} else {
nsAutoCString provider;
rv = prefs->GetCharPref(SELECTED_SKIN_PREF, provider);
if (NS_SUCCEEDED(rv)) mSelectedSkin = provider;
rv = prefs->AddObserver(SELECTED_SKIN_PREF, this, true);
}
nsCOMPtr<nsIObserverService> obsService =
mozilla::services::GetObserverService();
if (obsService) {
@ -131,27 +108,6 @@ nsresult nsChromeRegistryChrome::Init() {
return NS_OK;
}
NS_IMETHODIMP
nsChromeRegistryChrome::CheckForOSAccessibility() {
int32_t useAccessibilityTheme =
LookAndFeel::GetInt(LookAndFeel::eIntID_UseAccessibilityTheme, 0);
if (useAccessibilityTheme) {
/* Set the skin to classic and remove pref observers */
if (!mSelectedSkin.EqualsLiteral("classic/1.0")) {
mSelectedSkin.AssignLiteral("classic/1.0");
RefreshSkins();
}
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefs) {
prefs->RemoveObserver(SELECTED_SKIN_PREF, this);
}
}
return NS_OK;
}
NS_IMETHODIMP
nsChromeRegistryChrome::GetLocalesForPackage(
const nsACString& aPackage, nsIUTF8StringEnumerator** aResult) {
@ -240,26 +196,7 @@ nsChromeRegistryChrome::Observe(nsISupports* aSubject, const char* aTopic,
const char16_t* someData) {
nsresult rv = NS_OK;
if (!strcmp(NS_PREFBRANCH_PREFCHANGE_TOPIC_ID, aTopic)) {
nsCOMPtr<nsIPrefBranch> prefs(do_QueryInterface(aSubject));
NS_ASSERTION(prefs, "Bad observer call!");
NS_ConvertUTF16toUTF8 pref(someData);
if (pref.EqualsLiteral(SELECTED_SKIN_PREF)) {
nsAutoCString provider;
rv = prefs->GetCharPref(pref.get(), provider);
if (NS_FAILED(rv)) {
NS_ERROR("Couldn't get new skin pref!");
return rv;
}
mSelectedSkin = provider;
RefreshSkins();
} else {
NS_ERROR("Unexpected pref!");
}
} else if (!strcmp("profile-initial-state", aTopic)) {
if (!strcmp("profile-initial-state", aTopic)) {
mProfileLoaded = true;
} else if (!strcmp("intl:app-locales-changed", aTopic)) {
if (mProfileLoaded) {
@ -308,7 +245,7 @@ void nsChromeRegistryChrome::SendRegisteredChrome(
for (auto iter = mPackagesHash.Iter(); !iter.Done(); iter.Next()) {
ChromePackage chromePackage;
ChromePackageFromPackageEntry(iter.Key(), iter.UserData(), &chromePackage,
mSelectedSkin);
SKIN);
packages.AppendElement(chromePackage);
}
@ -402,7 +339,7 @@ nsIURI* nsChromeRegistryChrome::GetBaseURIFromPackage(
LocaleService::GetInstance()->GetAppLocaleAsLangTag(appLocale);
return entry->locales.GetBase(appLocale, nsProviderArray::LOCALE);
} else if (aProvider.EqualsLiteral("skin")) {
return entry->skins.GetBase(mSelectedSkin, nsProviderArray::ANY);
return entry->skins.GetBase(SKIN, nsProviderArray::ANY);
} else if (aProvider.EqualsLiteral("content")) {
return entry->baseURI;
}
@ -554,8 +491,7 @@ void nsChromeRegistryChrome::ManifestContent(ManifestProcessingContext& cx,
if (mDynamicRegistration) {
ChromePackage chromePackage;
ChromePackageFromPackageEntry(packageName, entry, &chromePackage,
mSelectedSkin);
ChromePackageFromPackageEntry(packageName, entry, &chromePackage, SKIN);
SendManifestEntry(chromePackage);
}
}
@ -591,8 +527,7 @@ void nsChromeRegistryChrome::ManifestLocale(ManifestProcessingContext& cx,
if (mDynamicRegistration) {
ChromePackage chromePackage;
ChromePackageFromPackageEntry(packageName, entry, &chromePackage,
mSelectedSkin);
ChromePackageFromPackageEntry(packageName, entry, &chromePackage, SKIN);
SendManifestEntry(chromePackage);
}
@ -638,8 +573,7 @@ void nsChromeRegistryChrome::ManifestSkin(ManifestProcessingContext& cx,
if (mDynamicRegistration) {
ChromePackage chromePackage;
ChromePackageFromPackageEntry(packageName, entry, &chromePackage,
mSelectedSkin);
ChromePackageFromPackageEntry(packageName, entry, &chromePackage, SKIN);
SendManifestEntry(chromePackage);
}
}

Просмотреть файл

@ -29,7 +29,6 @@ class nsChromeRegistryChrome : public nsChromeRegistry {
nsresult Init() override;
NS_IMETHOD CheckForNewChrome() override;
NS_IMETHOD CheckForOSAccessibility() override;
NS_IMETHOD GetLocalesForPackage(const nsACString& aPackage,
nsIUTF8StringEnumerator** aResult) override;
NS_IMETHOD IsLocaleRTL(const nsACString& package, bool* aResult) override;
@ -104,8 +103,6 @@ class nsChromeRegistryChrome : public nsChromeRegistry {
bool mProfileLoaded;
bool mDynamicRegistration;
nsCString mSelectedSkin;
// Hash of package names ("global") to PackageEntry objects
nsClassHashtable<nsCStringHashKey, PackageEntry> mPackagesHash;

Просмотреть файл

@ -159,11 +159,6 @@ nsChromeRegistryContent::GetLocalesForPackage(
CONTENT_NOT_IMPLEMENTED();
}
NS_IMETHODIMP
nsChromeRegistryContent::CheckForOSAccessibility() {
CONTENT_NOT_IMPLEMENTED();
}
NS_IMETHODIMP
nsChromeRegistryContent::CheckForNewChrome() { CONTENT_NOT_IMPLEMENTED(); }

Просмотреть файл

@ -26,7 +26,6 @@ class nsChromeRegistryContent : public nsChromeRegistry {
NS_IMETHOD GetLocalesForPackage(const nsACString& aPackage,
nsIUTF8StringEnumerator** aResult) override;
NS_IMETHOD CheckForNewChrome() override;
NS_IMETHOD CheckForOSAccessibility() override;
NS_IMETHOD Observe(nsISupports* aSubject, const char* aTopic,
const char16_t* aData) override;
NS_IMETHOD IsLocaleRTL(const nsACString& package, bool* aResult) override;

Просмотреть файл

@ -54,9 +54,6 @@ interface nsIXULChromeRegistry : nsIChromeRegistry
// (or may be overridden by intl.uidirection pref)
boolean isLocaleRTL(in ACString package);
/* Should be called when skins change. Reloads only stylesheets. */
void refreshSkins();
/**
* Installable skin XBL is not always granted the same privileges as other
* chrome. This asks the chrome registry whether scripts are allowed to be
@ -99,11 +96,4 @@ interface nsIXULChromeRegistry : nsIChromeRegistry
#define NS_CHROME_FLUSH_TOPIC \
"chrome-flush-caches"
/**
* Chrome registry will notify various caches that skin files need flushing.
* If "chrome-flush-caches" is notified, this topic will *not* be notified.
*/
#define NS_CHROME_FLUSH_SKINS_TOPIC \
"chrome-flush-skin-caches"
%}

Просмотреть файл

@ -11,16 +11,6 @@ interface nsIUTF8StringEnumerator;
[scriptable, uuid(8727651c-9530-45a0-b81e-0e0690c30c50)]
interface nsIToolkitChromeRegistry : nsIXULChromeRegistry
{
/**
* If the OS has a "high-visibility" or "disabled-friendly" theme set,
* we want to force mozilla into the classic theme, which (for the most part
* obeys the system color/font settings. We cannot do this at initialization,
* because it depends on the toolkit (GTK2) being initialized, which is
* not the case in some embedding situations. Embedders have to manually
* call this method during the startup process.
*/
void checkForOSAccessibility();
/**
* Get a list of locales available for the specified package.
*/

Просмотреть файл

@ -26,6 +26,7 @@
@import "resource://devtools/client/aboutdebugging-new/src/components/debugtarget/FieldPair.css";
@import "resource://devtools/client/aboutdebugging-new/src/components/debugtarget/ServiceWorkerAction.css";
@import "resource://devtools/client/aboutdebugging-new/src/components/debugtarget/TemporaryExtensionInstallSection.css";
@import "resource://devtools/client/aboutdebugging-new/src/components/shared/IconLabel.css";
@import "resource://devtools/client/aboutdebugging-new/src/components/shared/Message.css";
@import "resource://devtools/client/aboutdebugging-new/src/components/sidebar/Sidebar.css";
@import "resource://devtools/client/aboutdebugging-new/src/components/sidebar/SidebarFixedItem.css";

Просмотреть файл

@ -27,11 +27,13 @@
--link-color-hover: #0060df;
/* Colors from Photon */
--success-50: #30e60b;
--warning-50: #ffe900;
--warning-90: #3e2800;
--error-50: #ff0039;
--error-60: #d70022;
--success-background: #30e60b;
--warning-background: #fffbd6; /* from the Web Console */
--warning-icon: var(--yellow-65); /* from the Web Console */
--warning-text: var(--yellow-80); /* from the Web Console */
--error-background: #fdf2f5; /* from the Web Console */
--error-icon: var(--red-60); /* from the Web Console */
--error-text: var(--red-70); /* from the Web Console */
--highlight-50: #0a84ff;
--grey-20: #ededf0; /* for ui, no special semantic */
--grey-30: #d7d7db; /* for ui, no special semantic */
@ -43,7 +45,6 @@
--grey-90-a60: rgba(12, 12, 13, 0.6);
--grey-90-a80: rgba(12, 12, 13, 0.8);
--red-70: #a4000f; /* for ui, no special semantic */
--red-80: #5a0002; /* for ui, no special semantic */
--white-100: #fff; /* for ui, no special semantic */
--yellow-60: #d7b600; /* for ui, no special semantic */
--yellow-70: #a47f00; /* for ui, no special semantic */
@ -60,8 +61,8 @@
--caption-20-font-size: 13px;
--caption-20-font-weight: 400;
--caption-20-color: var(--grey-50);
--display-20-font-size: 36px;
--display-20-font-weight: 200;
--display-10-font-size: 28px;
--display-10-font-weight: 200;
--title-20-font-size: 17px;
--title-20-font-weight: 600;
--title-30-font-size: 22px;
@ -76,7 +77,8 @@
--base-font-size: var(--body-10-font-size);
--base-font-weight: var(--body-10-font-weight);
--base-line-height: 1.8;
--message-font-size: 13px; /* Body 10 in Photon - https://design.firefox.com/photon/visuals/typography.html */
--icon-label-font-size: var(--body-10-font-size);
--message-font-size: var(--body-10-font-size);
--button-font-size: var(--base-font-size);
--micro-font-size: 11px;
--monospace-font-family: monospace;
@ -178,8 +180,8 @@ p, h1 {
/* Main style for heading (i.e. h1) */
.main-heading {
font-size: var(--display-20-font-size);
font-weight: var(--display-20-font-weight);
font-size: var(--display-10-font-size);
font-weight: var(--display-10-font-weight);
line-height: 1.2;
color: var(--in-content-text-color);
}
@ -224,6 +226,11 @@ p, h1 {
margin-block-end: calc(var(--base-unit) * 4);
}
.alt-heading--larger {
font-size: var(--title-30-font-size);
font-weight: var(--title-30-font-weight);
}
/* Alternative style for a subheading (i.e. h2). It features an icon */
/* +--------+-------------+
* | [Icon] | Lorem ipsum |
@ -395,15 +402,15 @@ Form controls
}
.badge--success {
background: var(--success-50);
background: var(--success-background);
}
.badge--warning {
background: var(--warning-50);
background: var(--warning-background);
}
.badge--error {
background: var(--error-50);
background: var(--error-background);
}
/*
@ -413,7 +420,7 @@ Form controls
background-color: var(--white-100); /* from common.inc.css */
border-radius: var(--card-shadow-blur-radius); /* from common.inc.css */
box-shadow: 0 1px 4px var(--grey-90-a10); /* from common.inc.css */
padding-block: calc(var(--base-unit) * 3) calc(var(--base-unit) * 2);
padding-block: calc(var(--base-unit) * 5);
}
.card__heading {

Просмотреть файл

@ -17,7 +17,7 @@
.app {
/* from common */
--sidebar-width: 240px;
--sidebar-width: 320px;
--app-top-padding: 70px;
--app-bottom-padding: 40px;
--app-left-padding: 34px;
@ -57,4 +57,6 @@
.page {
max-width: var(--page-width);
font-size: var(--body-20-font-size);
font-weight: var(--body-20-font-weight);
}

Просмотреть файл

@ -21,7 +21,7 @@
grid-column-gap: var(--main-heading-icon-gap);
grid-template-areas:
"icon title action"
"icon subtitle action";
"icon subtitle .";
grid-template-columns: var(--main-heading-icon-size) 1fr max-content;
grid-template-rows: 1fr max-content;
@ -38,9 +38,5 @@
grid-area: subtitle;
}
.runtime-info__action {
align-self: start;
/* The default-button has a font-size of 1em at the moment, this rule should not be
* necessary after the first patch from Bug 1525615 lands. */
font-size: var(--base-font-size);
grid-area: action;
}

Просмотреть файл

@ -20,6 +20,7 @@
"status . toggle";
grid-template-columns: auto 1fr auto;
grid-column-gap: calc(var(--base-unit) * 2);
grid-row-gap: var(--base-unit);
}
.connect-page__usb-section__heading__toggle {

Просмотреть файл

@ -207,7 +207,7 @@ class ConnectPage extends PureComponent {
},
dom.h1(
{
className: "alt-heading",
className: "alt-heading alt-heading--larger",
},
"Setup"
),
@ -258,7 +258,7 @@ class ConnectPage extends PureComponent {
{
id: "about-debugging-setup-connect-heading",
},
dom.h1(
dom.h2(
{
className: "alt-heading",
},

Просмотреть файл

@ -20,7 +20,7 @@
grid-column-gap: var(--header-col-gap);
align-items: center;
padding-block: calc(var(--base-unit) * 4);
padding-block-end: calc(var(--base-unit) * 4);
padding-inline: calc(var(--base-unit) * 5);
}
@ -39,10 +39,8 @@
padding-inline-start: calc(var(--base-unit) * 5
+ var(--header-col-gap) + var(--icon-size));
padding-inline-end: calc(var(--base-unit) * 5);
padding-block-end: calc(var(--base-unit) * 4);
}
.connect-section__extra {
border-block-start: 1px solid var(--card-separator-color);
padding-block-end: calc(var(--base-unit) * 4);
}

Просмотреть файл

@ -35,7 +35,7 @@ class DebugTargetList extends PureComponent {
{
id: "about-debugging-debug-target-list-empty",
},
dom.span(
dom.p(
{
className: "js-debug-target-list-empty",
},
@ -53,22 +53,23 @@ class DebugTargetList extends PureComponent {
targets,
} = this.props;
return dom.ul(
{
className: "debug-target-list js-debug-target-list",
},
targets.length === 0
? this.renderEmptyList()
: targets.map((target, key) =>
DebugTargetItem({
actionComponent,
additionalActionsComponent,
detailComponent,
dispatch,
key,
target,
})),
);
return targets.length === 0
? this.renderEmptyList()
: dom.ul(
{
className: "debug-target-list js-debug-target-list",
},
targets.map((target, key) =>
DebugTargetItem({
actionComponent,
additionalActionsComponent,
detailComponent,
dispatch,
key,
target,
})
),
);
}
}

Просмотреть файл

@ -22,5 +22,5 @@
}
.service-worker-action__status--running::before {
background-color: var(--success-50);
background-color: var(--success-background);
}

Просмотреть файл

@ -0,0 +1,23 @@
.icon-label {
display: flex;
column-gap: var(--base-unit);
align-items: center;
margin: calc(var(--base-unit) * 2) 0;
-moz-context-properties: fill;
font-size: var(--icon-label-font-size);
}
.icon-label--ok {
--icon-color: var(--green-70);
}
.icon-label--info {
--icon-color: var(--grey-90);
}
.icon-label__icon {
padding: var(--base-unit);
fill: var(--icon-color);
width: calc(var(--base-unit) * 4);
height: calc(var(--base-unit) * 4);
}

Просмотреть файл

@ -0,0 +1,46 @@
/* 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/. */
"use strict";
const { PureComponent } = require("devtools/client/shared/vendor/react");
const dom = require("devtools/client/shared/vendor/react-dom-factories");
const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
const { ICON_LABEL_LEVEL } = require("../../constants");
const ICONS = {
[ICON_LABEL_LEVEL.INFO]: "chrome://global/skin/icons/info.svg",
[ICON_LABEL_LEVEL.OK]: "chrome://global/skin/icons/check.svg",
};
/* This component displays an icon accompanied by some content. It's similar
to a message, but it's not interactive */
class IconLabel extends PureComponent {
static get propTypes() {
return {
children: PropTypes.node.isRequired,
className: PropTypes.string,
level: PropTypes.oneOf(Object.values(ICON_LABEL_LEVEL)).isRequired,
};
}
render() {
const { children, className, level } = this.props;
return dom.span(
{
className: `icon-label icon-label--${level} ${className || ""}`,
},
dom.img(
{
className: "icon-label__icon",
src: ICONS[level],
}
),
children,
);
}
}
module.exports = IconLabel;

Просмотреть файл

@ -3,18 +3,21 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
.message--level-error {
--message-color: var(--white-100);
--message-background-color: var(--error-60);
--message-color: var(--error-text);
--message-background-color: var(--error-background);
--message-icon-color: var(--error-icon);
}
.message--level-info {
--message-color: var(--grey-90);
--message-background-color: var(--grey-20);
--message-icon-color: var(--grey-90);
}
.message--level-warning {
--message-color: var(--warning-90);
--message-background-color: var(--warning-50);
--message-color: var(--warning-text);
--message-background-color: var(--warning-background);
--message-icon-color: var(--warning-icon);
}
/*
@ -31,9 +34,8 @@
border-radius: var(--base-unit);
color: var(--message-color);
display: grid;
fill: var(--message-color);
grid-column-gap: var(--base-unit);
grid-template-columns: calc(var(--base-unit) * 6) 1fr auto;
grid-template-columns: calc(var(--base-unit) * 6) 1fr auto;
grid-template-areas:
"icon body button";
margin: calc(var(--base-unit) * 2) 0;
@ -43,6 +45,7 @@
.message__icon {
margin: var(--base-unit);
fill: var(--message-icon-color);
grid-area: icon;
}
@ -54,24 +57,18 @@
.message__button {
grid-area: button;
fill: var(--message-icon-color);
}
.message__button--warning:hover {
background-color: var(--yellow-60);
.message__button:hover {
/* reverse colors with icon when hover state */
background-color: var(--message-icon-color);
fill: var(--message-background-color);
}
.message__button--warning:active {
background-color: var(--yellow-70);
.message__button:active {
/* reverse colors with text when active state */
background-color: var(--message-color);
fill: var(--message-background-color);
}
.message__button--error {
fill: white;
}
.message__button--error:hover {
background-color: var(--red-70);
}
.message__button--error:active {
background-color: var(--red-80);
}

Просмотреть файл

@ -3,6 +3,8 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DevToolsModules(
'IconLabel.css',
'IconLabel.js',
'Message.css',
'Message.js',
)

Просмотреть файл

@ -15,6 +15,10 @@
font-size: var(--message-font-size);
}
.sidebar__adb-status {
margin-block-end: calc(var(--base-unit) * 2);
}
.sidebar__refresh-usb {
text-align: center;
}

Просмотреть файл

@ -11,11 +11,11 @@ const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
const FluentReact = require("devtools/client/shared/vendor/fluent-react");
const Localized = createFactory(FluentReact.Localized);
const { MESSAGE_LEVEL, PAGE_TYPES, RUNTIMES } = require("../../constants");
const { ICON_LABEL_LEVEL, PAGE_TYPES, RUNTIMES } = require("../../constants");
const Types = require("../../types/index");
loader.lazyRequireGetter(this, "ADB_ADDON_STATES", "devtools/shared/adb/adb-addon", true);
const Message = createFactory(require("../shared/Message"));
const IconLabel = createFactory(require("../shared/IconLabel"));
const SidebarItem = createFactory(require("./SidebarItem"));
const SidebarFixedItem = createFactory(require("./SidebarFixedItem"));
const SidebarRuntimeItem = createFactory(require("./SidebarRuntimeItem"));
@ -45,21 +45,20 @@ class Sidebar extends PureComponent {
this.props.adbAddonStatus === ADB_ADDON_STATES.INSTALLED;
const localizationId = isUsbEnabled ? "about-debugging-sidebar-usb-enabled" :
"about-debugging-sidebar-usb-disabled";
return Message(
return IconLabel(
{
level: MESSAGE_LEVEL.INFO,
isCloseable: true,
level: isUsbEnabled ? ICON_LABEL_LEVEL.OK : ICON_LABEL_LEVEL.INFO,
},
Localized(
Localized(
{
id: localizationId,
},
dom.span(
{
id: localizationId,
className: "js-sidebar-usb-status",
},
dom.div(
{
className: "js-sidebar-usb-status",
},
localizationId
)
localizationId
)
)
);
}
@ -207,7 +206,7 @@ class Sidebar extends PureComponent {
),
SidebarItem(
{
className: "sidebar-item--overflow sidebar-item--full-width",
className: "sidebar__adb-status",
},
dom.hr({ className: "separator separator--breathe" }),
this.renderAdbStatus(),

Просмотреть файл

@ -25,16 +25,6 @@
height: calc(var(--base-unit) * 9);
}
.sidebar-item--full-width {
padding-inline-start: 0;
padding-inline-end: 0;
}
/* .sidebar-item--overflow {
min-height: var(--category-height);
height: auto;
} */
.sidebar-item__link {
display: block;
height: 100%;
@ -46,7 +36,7 @@
}
.sidebar-item:not(.sidebar-item--selectable) {
color: var(--grey-40);
color: var(--grey-50);
}
.sidebar-item--selectable:hover {

Просмотреть файл

@ -11,11 +11,12 @@
*/
.sidebar-runtime-item__container {
box-sizing: border-box;
height: var(--category-height);
align-items: center;
display: grid;
grid-column-gap: var(--base-unit);
grid-template-columns: calc(var(--base-unit) * 6) 1fr auto;
height: 100%;
font-size: var(--body-20-font-size);
font-weight: var(--body-20-font-weight);
}
@ -26,10 +27,14 @@
}
.sidebar-runtime-item__runtime {
line-height: 1.2;
line-height: 1;
}
.sidebar-runtime-item__runtime__details {
font-size: var(--caption-10-font-size);
font-weight: var(--caption-10-font-weight);
}
.sidebar-runtime-item__message:first-of-type {
margin-block-start: calc(var(--base-unit) * -1);
}

Просмотреть файл

@ -71,8 +71,7 @@ class SidebarRuntimeItem extends PureComponent {
return Message(
{
level,
key: className,
className,
className: `${className} sidebar-runtime-item__message`,
},
Localized(
{
@ -159,29 +158,25 @@ class SidebarRuntimeItem extends PureComponent {
getString("aboutdebugging-sidebar-runtime-connection-status-connected") :
getString("aboutdebugging-sidebar-runtime-connection-status-disconnected");
return [
SidebarItem(
return SidebarItem(
{
isSelected,
to: isConnected ? `/runtime/${encodeURIComponent(runtimeId)}` : null,
},
dom.section(
{
className: "sidebar-item--tall",
key: "sidebar-item",
isSelected,
to: isConnected ? `/runtime/${encodeURIComponent(runtimeId)}` : null,
className: "sidebar-runtime-item__container",
},
dom.section(
dom.img(
{
className: "sidebar-runtime-item__container",
},
dom.img(
{
className: "sidebar-runtime-item__icon ",
src: icon,
alt: connectionStatus,
title: connectionStatus,
}
),
this.renderName(),
!isUnavailable && !isConnected ? this.renderConnectButton() : null
className: "sidebar-runtime-item__icon ",
src: icon,
alt: connectionStatus,
title: connectionStatus,
}
),
this.renderName(),
!isUnavailable && !isConnected ? this.renderConnectButton() : null
),
this.renderMessage(
isConnectionFailed,
@ -201,7 +196,7 @@ class SidebarRuntimeItem extends PureComponent {
"about-debugging-sidebar-item-connect-button-connection-not-responding",
"qa-connection-not-responding"
),
];
);
}
}

Просмотреть файл

@ -84,6 +84,11 @@ const DEBUG_TARGET_PANE = {
TEMPORARY_EXTENSION: "temporaryExtension",
};
const ICON_LABEL_LEVEL = {
INFO: "info",
OK: "ok",
};
const MESSAGE_LEVEL = {
ERROR: "error",
INFO: "info",
@ -139,6 +144,7 @@ const USB_STATES = {
module.exports = Object.assign({}, {
DEBUG_TARGETS,
DEBUG_TARGET_PANE,
ICON_LABEL_LEVEL,
MESSAGE_LEVEL,
PAGE_TYPES,
PREFERENCES,

Просмотреть файл

@ -3,24 +3,42 @@
"use strict";
/**
* This test asserts that the sidebar shows a message with a closing button describing
* the status of the USB devices debugging.
*/
/* import-globals-from helper-addons.js */
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-addons.js", this);
// Test that Message component can be closed with the X button
add_task(async function() {
const { document, tab } = await openAboutDebugging();
const EXTENSION_NAME = "Temporary web extension";
const EXTENSION_ID = "test-devtools@mozilla.org";
const usbStatusElement = document.querySelector(".js-sidebar-usb-status");
ok(usbStatusElement, "Sidebar shows the USB status element");
ok(usbStatusElement.textContent.includes("USB disabled"),
"USB status element has the expected content");
const { document, tab, window } = await openAboutDebugging();
await selectThisFirefoxPage(document, window.AboutDebugging.store);
const button = document.querySelector(".js-sidebar-item .qa-message-button-close");
await installTemporaryExtensionFromXPI({
id: EXTENSION_ID,
name: EXTENSION_NAME,
extraProperties: {
// This property is not expected in the manifest and should trigger a warning!
"wrongProperty": {},
},
}, document);
info("Wait until a debug target item appears");
await waitUntil(() => findDebugTargetByText(EXTENSION_NAME, document));
const target = findDebugTargetByText(EXTENSION_NAME, document);
const warningMessage = target.querySelector(".js-message");
ok(!!warningMessage, "A warning message is displayed for the installed addon");
const button = warningMessage.querySelector(".qa-message-button-close");
ok(!!button, "The warning message has a close button");
info("Closing the message and waiting for it to disappear");
button.click();
await waitUntil(() => {
return target.querySelector(".js-message") === null;
});
// new search for element
ok(document.querySelector(".js-sidebar-usb-status") === null,
"USB status element is no longer displayed");
await removeTemporaryExtension(EXTENSION_NAME, document);
await removeTab(tab);
});

Просмотреть файл

@ -35,7 +35,7 @@ class ChangesApp extends PureComponent {
}
renderCopyAllChangesButton() {
return dom.button(
const button = dom.button(
{
className: "changes__copy-all-changes-button",
onClick: e => {
@ -46,6 +46,8 @@ class ChangesApp extends PureComponent {
},
getStr("changes.contextmenu.copyAllChanges")
);
return dom.div({ className: "changes__toolbar" }, button);
}
renderCopyButton(ruleId) {

Просмотреть файл

@ -77,6 +77,20 @@
var(--diff-level-offset) * var(--diff-level));
}
#sidebar-panel-changes .changes__toolbar {
background: var(--theme-sidebar-background);
border-bottom: 1px solid var(--theme-splitter-color);
padding: 2px 5px;
position: sticky;
top: 0;
z-index: 1;
}
/* Remove the top border of the first source to avoid double border from sticky toolbar */
#sidebar-panel-changes .changes__toolbar + .source .href {
border-top: none;
}
.changes__copy-all-changes-button {
-moz-context-properties: fill;
/* Use the Firefox copy icon (16px) instead of the smaller DevTools one (12px) */
@ -87,7 +101,6 @@
border-radius: 3px;
color: var(--theme-body-color);
fill: currentColor;
margin: 2px 5px;
padding: 4px 5px 4px 25px;
}

Просмотреть файл

@ -91,6 +91,11 @@ html|button > * {
pointer-events: none;
}
/* Prevent buttons from having a text selection highlight. Bug 1546366 */
button::selection {
all: unset;
}
/* Autocomplete Popup */
.devtools-autocomplete-popup {
overflow: hidden;

Просмотреть файл

@ -251,10 +251,10 @@
}
.font-value-input {
margin-left: 10px;
text-align: right;
width: 60px;
padding: 2px 3px;
padding-inline-end: 5px;
}
.font-value-input,
@ -287,25 +287,24 @@
-moz-appearance: textfield;
}
/* Do not show number stepper for line height and font-size */
.font-value-input[name=line-height],
.font-value-input[name=font-size] {
-moz-appearance: textfield;
padding-right: 5px;
border-right: none;
/* Swap around order of value input and unit dropdown for RTL */
.font-value-input:dir(rtl) {
order: 3;
}
.font-value-label {
/* Combined width of .font-value-input and .font-value-select */
width: calc(60px + 3.8em);
margin-left: 10px;
padding-top: 2px;
padding-bottom: 4px;
}
/* Mock separator because inputs don't have distinguishable borders in dark theme */
.theme-dark .font-value-input + .font-value-select {
margin-left: 2px;
.theme-dark .font-value-input + .font-value-select:dir(ltr) {
margin-inline-start: 2px;
}
.theme-dark .font-value-input + .font-value-select:dir(rtl) {
margin-inline-end: 2px;
}
/* Custom styles for <select> elements within the font editor. */
@ -321,6 +320,17 @@
min-width: 3.8em;
}
.font-value-input + .font-value-select:dir(ltr){
border-inline-start: none;
}
/* Swap around order of value input and unit dropdown for RTL */
.font-value-input + .font-value-select:dir(rtl){
border-inline-end: none;
order: 2;
text-align: left;
}
.font-value-select:-moz-focusring {
color: transparent;
text-shadow: 0 0 0 var(--theme-text-color-strong);
@ -336,6 +346,7 @@
flex: 1;
min-width: 50px;
position: relative;
margin-inline-end: 10px;
}
/* Firefox doesn't support pseudo-elements on inputs. Using the container instead. */

Просмотреть файл

@ -1213,6 +1213,8 @@ Document::Document(const char* aContentType)
mNeedsReleaseAfterStackRefCntRelease(false),
mStyleSetFilled(false),
mQuirkSheetAdded(false),
mContentEditableSheetAdded(false),
mDesignModeSheetAdded(false),
mSSApplicableStateNotificationPending(false),
mMayHaveTitleElement(false),
mDOMLoadingSet(false),
@ -2401,6 +2403,58 @@ void Document::FillStyleSet() {
mStyleSetFilled = true;
}
void Document::RemoveContentEditableStyleSheets() {
MOZ_ASSERT(IsHTMLOrXHTML());
auto* cache = nsLayoutStylesheetCache::Singleton();
bool changed = false;
if (mDesignModeSheetAdded) {
mStyleSet->RemoveStyleSheet(StyleOrigin::UserAgent,
cache->DesignModeSheet());
mDesignModeSheetAdded = false;
changed = true;
}
if (mContentEditableSheetAdded) {
mStyleSet->RemoveStyleSheet(StyleOrigin::UserAgent,
cache->ContentEditableSheet());
mContentEditableSheetAdded = false;
changed = true;
}
if (changed) {
MOZ_ASSERT(mStyleSetFilled);
ApplicableStylesChanged();
}
}
void Document::AddContentEditableStyleSheetsToStyleSet(bool aDesignMode) {
MOZ_ASSERT(IsHTMLOrXHTML());
MOZ_DIAGNOSTIC_ASSERT(mStyleSetFilled,
"Caller should ensure we're being rendered");
auto* cache = nsLayoutStylesheetCache::Singleton();
bool changed = false;
if (!mContentEditableSheetAdded) {
mStyleSet->AppendStyleSheet(StyleOrigin::UserAgent,
cache->ContentEditableSheet());
mContentEditableSheetAdded = true;
changed = true;
}
if (mDesignModeSheetAdded != aDesignMode) {
if (mDesignModeSheetAdded) {
mStyleSet->RemoveStyleSheet(StyleOrigin::UserAgent,
cache->DesignModeSheet());
} else {
mStyleSet->AppendStyleSheet(StyleOrigin::UserAgent,
cache->DesignModeSheet());
}
mDesignModeSheetAdded = !mDesignModeSheetAdded;
changed = true;
}
if (changed) {
ApplicableStylesChanged();
}
}
void Document::FillStyleSetDocumentSheets() {
MOZ_ASSERT(mStyleSet->SheetCount(StyleOrigin::Author) == 0,
"Style set already has document sheets?");
@ -4008,6 +4062,8 @@ void Document::DeletePresShell() {
mStyleSet->ShellDetachedFromDocument();
mStyleSetFilled = false;
mQuirkSheetAdded = false;
mContentEditableSheetAdded = false;
mDesignModeSheetAdded = false;
}
void Document::SetBFCacheEntry(nsIBFCacheEntry* aEntry) {
@ -4293,36 +4349,6 @@ void Document::RemoveStyleSheet(StyleSheet* aSheet) {
sheet->ClearAssociatedDocumentOrShadowRoot();
}
void Document::UpdateStyleSheets(nsTArray<RefPtr<StyleSheet>>& aOldSheets,
nsTArray<RefPtr<StyleSheet>>& aNewSheets) {
// XXX Need to set the sheet on the ownernode, if any
MOZ_ASSERT(aOldSheets.Length() == aNewSheets.Length(),
"The lists must be the same length!");
int32_t count = aOldSheets.Length();
RefPtr<StyleSheet> oldSheet;
int32_t i;
for (i = 0; i < count; ++i) {
oldSheet = aOldSheets[i];
// First remove the old sheet.
NS_ASSERTION(oldSheet, "None of the old sheets should be null");
int32_t oldIndex = mStyleSheets.IndexOf(oldSheet);
RemoveStyleSheet(oldSheet); // This does the right notifications
// Now put the new one in its place. If it's null, just ignore it.
StyleSheet* newSheet = aNewSheets[i];
if (newSheet) {
DocumentOrShadowRoot::InsertSheetAt(oldIndex, *newSheet);
if (newSheet->IsApplicable()) {
AddStyleSheetToStyleSets(newSheet);
}
NotifyStyleSheetAdded(newSheet, true);
}
}
}
void Document::InsertSheetAt(size_t aIndex, StyleSheet& aSheet) {
DocumentOrShadowRoot::InsertSheetAt(aIndex, aSheet);
@ -6231,8 +6257,6 @@ already_AddRefed<MediaQueryList> Document::MatchMedia(
return result.forget();
}
void Document::FlushSkinBindings() { BindingManager()->FlushSkinBindings(); }
void Document::SetMayStartLayout(bool aMayStartLayout) {
mMayStartLayout = aMayStartLayout;
if (MayStartLayout()) {
@ -8747,11 +8771,10 @@ void Document::PreloadStyle(
aReferrerPolicy, aIntegrity);
}
nsresult Document::LoadChromeSheetSync(nsIURI* uri, bool isAgentSheet,
RefPtr<mozilla::StyleSheet>* aSheet) {
css::SheetParsingMode mode =
isAgentSheet ? css::eAgentSheetFeatures : css::eAuthorSheetFeatures;
return CSSLoader()->LoadSheetSync(uri, mode, isAgentSheet, aSheet);
RefPtr<StyleSheet> Document::LoadChromeSheetSync(nsIURI* uri) {
RefPtr<StyleSheet> sheet;
CSSLoader()->LoadSheetSync(uri, css::eAuthorSheetFeatures, false, &sheet);
return sheet;
}
void Document::ResetDocumentDirection() {

Просмотреть файл

@ -1660,17 +1660,6 @@ class Document : public nsINode,
void InsertSheetAt(size_t aIndex, StyleSheet&);
/**
* Replace the stylesheets in aOldSheets with the stylesheets in
* aNewSheets. The two lists must have equal length, and the sheet
* at positon J in the first list will be replaced by the sheet at
* position J in the second list. Some sheets in the second list
* may be null; if so the corresponding sheets in the first list
* will simply be removed.
*/
void UpdateStyleSheets(nsTArray<RefPtr<StyleSheet>>& aOldSheets,
nsTArray<RefPtr<StyleSheet>>& aNewSheets);
/**
* Add a stylesheet to the document
*
@ -2415,10 +2404,6 @@ class Document : public nsINode,
nsAtom* aAttrName,
const nsAString& aAttrValue) const;
/**
* See FlushSkinBindings on nsBindingManager
*/
void FlushSkinBindings();
/**
* To batch DOMSubtreeModified, document needs to be informed when
@ -2853,9 +2838,8 @@ class Document : public nsINode,
void ForgetImagePreload(nsIURI* aURI);
/**
* Called by nsParser to preload style sheets. Can also be merged into the
* parser if and when the parser is merged with libgklayout. aCrossOriginAttr
* should be a void string if the attr is not present.
* Called by nsParser to preload style sheets. aCrossOriginAttr should be a
* void string if the attr is not present.
*/
void PreloadStyle(nsIURI* aURI, const Encoding* aEncoding,
const nsAString& aCrossOriginAttr,
@ -2863,15 +2847,11 @@ class Document : public nsINode,
const nsAString& aIntegrity);
/**
* Called by the chrome registry to load style sheets. Can be put
* back there if and when when that module is merged with libgklayout.
* Called by the chrome registry to load style sheets.
*
* This always does a synchronous load. If aIsAgentSheet is true,
* it also uses the system principal and enables unsafe rules.
* DO NOT USE FOR UNTRUSTED CONTENT.
* This always does a synchronous load, and parses as a normal document sheet.
*/
nsresult LoadChromeSheetSync(nsIURI* aURI, bool aIsAgentSheet,
RefPtr<StyleSheet>* aSheet);
RefPtr<StyleSheet> LoadChromeSheetSync(nsIURI* aURI);
/**
* Returns true if the locale used for the document specifies a direction of
@ -3830,8 +3810,11 @@ class Document : public nsINode,
void CompatibilityModeChanged();
bool NeedsQuirksSheet() const {
// SVG documents never load quirk.css.
// FIXME(emilio): Can SVG documents be in quirks mode anyway?
return mCompatMode == eCompatibility_NavQuirks && !IsSVGDocument();
}
void AddContentEditableStyleSheetsToStyleSet(bool aDesignMode);
void RemoveContentEditableStyleSheets();
void AddStyleSheetToStyleSets(StyleSheet* aSheet);
void RemoveStyleSheetFromStyleSets(StyleSheet* aSheet);
void NotifyStyleSheetAdded(StyleSheet* aSheet, bool aDocumentSheet);
@ -4225,6 +4208,12 @@ class Document : public nsINode,
// Whether we have a quirks mode stylesheet in the style set.
bool mQuirkSheetAdded : 1;
// Whether we have a contenteditable.css stylesheet in the style set.
bool mContentEditableSheetAdded : 1;
// Whether we have a designmode.css stylesheet in the style set.
bool mDesignModeSheetAdded : 1;
// Keeps track of whether we have a pending
// 'style-sheet-applicable-state-changed' notification.
bool mSSApplicableStateNotificationPending : 1;

Просмотреть файл

@ -156,7 +156,18 @@ ThirdPartyUtil::IsThirdPartyWindow(mozIDOMWindowProxy* aWindow, nsIURI* aURI,
nsCString bottomDomain =
GetBaseDomainFromWindow(nsPIDOMWindowOuter::From(aWindow));
if (bottomDomain.IsEmpty()) {
return NS_ERROR_FAILURE;
// We may have an about:blank window here. Fall back to the slower code
// path which is principal aware.
nsCOMPtr<nsIURI> currentURI;
nsresult rv = GetURIFromWindow(aWindow, getter_AddRefs(currentURI));
if (NS_FAILED(rv)) {
return rv;
}
rv = GetBaseDomain(currentURI, bottomDomain);
if (NS_FAILED(rv)) {
return rv;
}
}
if (aURI) {
@ -188,10 +199,19 @@ ThirdPartyUtil::IsThirdPartyWindow(mozIDOMWindowProxy* aWindow, nsIURI* aURI,
nsCString parentDomain = GetBaseDomainFromWindow(parent);
if (parentDomain.IsEmpty()) {
return NS_ERROR_FAILURE;
}
// We may have an about:blank window here. Fall back to the slower code
// path which is principal aware.
nsCOMPtr<nsIURI> parentURI;
nsresult rv = GetURIFromWindow(parent, getter_AddRefs(parentURI));
NS_ENSURE_SUCCESS(rv, rv);
result = IsThirdPartyInternal(bottomDomain, parentDomain);
rv = IsThirdPartyInternal(bottomDomain, parentURI, &result);
if (NS_FAILED(rv)) {
return rv;
}
} else {
result = IsThirdPartyInternal(bottomDomain, parentDomain);
}
if (result) {
*aResult = true;

Просмотреть файл

@ -251,13 +251,17 @@ already_AddRefed<Promise> OffscreenCanvas::ToBlob(JSContext* aCx,
RefPtr<EncodeCompleteCallback> callback = new EncodeCallback(global, promise);
// TODO: Can we obtain the context and document here somehow
// so that we can decide when usePlaceholder should be true/false?
// See https://trac.torproject.org/18599
// For now, we always return a placeholder if fingerprinting resistance is on.
dom::WorkerPrivate* workerPrivate = dom::GetCurrentThreadWorkerPrivate();
bool usePlaceholder =
nsContentUtils::ShouldResistFingerprinting(workerPrivate->GetPrincipal());
bool usePlaceholder;
if (NS_IsMainThread()) {
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(GetGlobalObject());
Document* doc = window->GetExtantDoc();
usePlaceholder =
doc ? nsContentUtils::ShouldResistFingerprinting(doc) : false;
} else {
dom::WorkerPrivate* workerPrivate = dom::GetCurrentThreadWorkerPrivate();
usePlaceholder = nsContentUtils::ShouldResistFingerprinting(
workerPrivate->GetPrincipal());
}
CanvasRenderingContextHelper::ToBlob(aCx, global, callback, aType, aParams,
usePlaceholder, aRv);

Просмотреть файл

@ -0,0 +1,11 @@
<html>
<head>
<script>
function start () {
new OffscreenCanvas(1, 127).toBlob()
}
window.addEventListener('load', start)
</script>
</head>
</html>

Просмотреть файл

@ -52,3 +52,4 @@ pref(gfx.offscreencanvas.enabled,true) load 1348976-1.html
load 1357092.html
load 1441613.html
pref(gfx.offscreencanvas.enabled,true) load 1443671.html
pref(gfx.offscreencanvas.enabled,true) load 1546390.html

Просмотреть файл

@ -1712,25 +1712,8 @@ static void NotifyEditableStateChange(nsINode* aNode, Document* aDocument) {
void nsHTMLDocument::TearingDownEditor() {
if (IsEditingOn()) {
EditingState oldState = mEditingState;
mEditingState = eTearingDown;
RefPtr<PresShell> presShell = GetPresShell();
if (!presShell) {
return;
}
nsTArray<RefPtr<StyleSheet>> agentSheets;
presShell->GetAgentStyleSheets(agentSheets);
auto cache = nsLayoutStylesheetCache::Singleton();
agentSheets.RemoveElement(cache->ContentEditableSheet());
if (oldState == eDesignMode)
agentSheets.RemoveElement(cache->DesignModeSheet());
presShell->SetAgentStyleSheets(agentSheets);
ApplicableStylesChanged();
RemoveContentEditableStyleSheets();
}
}
@ -1864,44 +1847,22 @@ nsresult nsHTMLDocument::EditingStateChanged() {
RefPtr<PresShell> presShell = GetPresShell();
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
MOZ_ASSERT(mStyleSetFilled);
// Before making this window editable, we need to modify UA style sheet
// because new style may change whether focused element will be focusable
// or not.
nsTArray<RefPtr<StyleSheet>> agentSheets;
rv = presShell->GetAgentStyleSheets(agentSheets);
NS_ENSURE_SUCCESS(rv, rv);
auto cache = nsLayoutStylesheetCache::Singleton();
StyleSheet* contentEditableSheet = cache->ContentEditableSheet();
if (!agentSheets.Contains(contentEditableSheet)) {
agentSheets.AppendElement(contentEditableSheet);
}
AddContentEditableStyleSheetsToStyleSet(designMode);
// Should we update the editable state of all the nodes in the document? We
// need to do this when the designMode value changes, as that overrides
// specific states on the elements.
updateState = designMode || oldState == eDesignMode;
if (designMode) {
// designMode is being turned on (overrides contentEditable).
StyleSheet* designModeSheet = cache->DesignModeSheet();
if (!agentSheets.Contains(designModeSheet)) {
agentSheets.AppendElement(designModeSheet);
}
updateState = true;
spellRecheckAll = oldState == eContentEditable;
} else if (oldState == eDesignMode) {
// designMode is being turned off (contentEditable is still on).
agentSheets.RemoveElement(cache->DesignModeSheet());
updateState = true;
}
rv = presShell->SetAgentStyleSheets(agentSheets);
NS_ENSURE_SUCCESS(rv, rv);
ApplicableStylesChanged();
// Adjust focused element with new style but blur event shouldn't be fired
// until mEditingState is modified with newState.
nsAutoScriptBlocker scriptBlocker;

Просмотреть файл

@ -609,10 +609,18 @@ nsresult PersistentStoragePermissionRequest::Start() {
MOZ_ASSERT(NS_IsMainThread());
PromptResult pr;
#ifdef MOZ_WIDGET_ANDROID
// on Android calling `ShowPrompt` here calls `nsContentPermissionUtils::AskPermission`
// once, and a response of `PromptResult::Pending` calls it again. This results in
// multiple requests for storage access, so we check the prompt prefs only to ensure we
// only request it once.
pr = CheckPromptPrefs();
#else
nsresult rv = ShowPrompt(pr);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
#endif
if (pr == PromptResult::Granted) {
return Allow(JS::UndefinedHandleValue);
}

Просмотреть файл

@ -454,27 +454,6 @@ void nsBindingManager::RemoveLoadingDocListener(nsIURI* aURL) {
}
}
void nsBindingManager::FlushSkinBindings() {
if (!mBoundContentSet) {
return;
}
for (auto iter = mBoundContentSet->Iter(); !iter.Done(); iter.Next()) {
nsXBLBinding* binding = iter.Get()->GetKey()->GetXBLBinding();
if (binding->MarkedForDeath()) {
continue;
}
nsAutoCString path;
binding->PrototypeBinding()->DocURI()->GetPathQueryRef(path);
if (!strncmp(path.get(), "/skin", 5)) {
binding->MarkForDeath();
}
}
}
// Used below to protect from recurring in QI calls through XPConnect.
struct AntiRecursionData {
nsIContent* element;

Просмотреть файл

@ -111,8 +111,6 @@ class nsBindingManager final : public nsStubMutationObserver {
nsIStreamListener* GetLoadingDocListener(nsIURI* aURL);
void RemoveLoadingDocListener(nsIURI* aURL);
void FlushSkinBindings();
nsresult GetBindingImplementation(nsIContent* aContent, REFNSIID aIID,
void** aResult);

Просмотреть файл

@ -90,7 +90,6 @@ nsXULPrototypeCache* nsXULPrototypeCache::GetInstance() {
mozilla::services::GetObserverService();
if (obsSvc) {
nsXULPrototypeCache* p = sInstance;
obsSvc->AddObserver(p, "chrome-flush-skin-caches", false);
obsSvc->AddObserver(p, "chrome-flush-caches", false);
obsSvc->AddObserver(p, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
obsSvc->AddObserver(p, "startupcache-invalidate", false);
@ -104,10 +103,8 @@ nsXULPrototypeCache* nsXULPrototypeCache::GetInstance() {
NS_IMETHODIMP
nsXULPrototypeCache::Observe(nsISupports* aSubject, const char* aTopic,
const char16_t* aData) {
if (!strcmp(aTopic, "chrome-flush-skin-caches")) {
FlushSkinFiles();
} else if (!strcmp(aTopic, "chrome-flush-caches") ||
!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
if (!strcmp(aTopic, "chrome-flush-caches") ||
!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
Flush();
} else if (!strcmp(aTopic, "startupcache-invalidate")) {
AbortCaching();
@ -211,26 +208,6 @@ nsresult nsXULPrototypeCache::PutXBLDocumentInfo(
return NS_OK;
}
void nsXULPrototypeCache::FlushSkinFiles() {
// Flush out skin XBL files from the cache.
for (auto iter = mXBLDocTable.Iter(); !iter.Done(); iter.Next()) {
nsAutoCString str;
iter.Key()->GetPathQueryRef(str);
if (strncmp(str.get(), "/skin", 5) == 0) {
iter.Remove();
}
}
// Now flush out our skin stylesheets from the cache.
for (auto iter = mStyleSheetTable.Iter(); !iter.Done(); iter.Next()) {
nsAutoCString str;
iter.Data()->GetSheetURI()->GetPathQueryRef(str);
if (strncmp(str.get(), "/skin", 5) == 0) {
iter.Remove();
}
}
}
void nsXULPrototypeCache::FlushScripts() { mScriptTable.Clear(); }
void nsXULPrototypeCache::Flush() {

Просмотреть файл

@ -114,8 +114,6 @@ class nsXULPrototypeCache : public nsIObserver {
static nsXULPrototypeCache* sInstance;
void FlushSkinFiles();
using StyleSheetTable = nsRefPtrHashtable<nsURIHashKey, mozilla::StyleSheet>;
using XBLDocTable = nsRefPtrHashtable<nsURIHashKey, nsXBLDocumentInfo>;

Просмотреть файл

@ -936,7 +936,7 @@ bool WebRenderBridgeParent::SetDisplayList(
// cache items.
rect = LayoutDeviceIntRect(LayoutDeviceIntPoint(), widgetSize);
}
aTxn.SetDocumentView(rect, widgetSize);
aTxn.SetDocumentView(rect);
}
gfx::Color clearColor(0.f, 0.f, 0.f, 0.f);
aTxn.SetDisplayList(clearColor, aWrEpoch,

Просмотреть файл

@ -855,6 +855,19 @@ void gfxPlatform::Init() {
if (XRE_IsParentProcess()) {
WrRolloutPrefShutdownSaver::AddShutdownObserver();
nsCOMPtr<nsIFile> profDir;
nsresult rv = NS_GetSpecialDirectory(NS_APP_PROFILE_DIR_STARTUP,
getter_AddRefs(profDir));
if (NS_FAILED(rv)) {
gfxVars::SetProfDirectory(nsString());
} else {
nsAutoString path;
profDir->GetPath(path);
gfxVars::SetProfDirectory(nsString(path));
}
gfxUtils::RemoveShaderCacheFromDiskIfNecessary();
}
// Drop a note in the crash report if we end up forcing an option that could
@ -1048,19 +1061,6 @@ void gfxPlatform::Init() {
Preferences::SetBool(FONT_VARIATIONS_PREF, false);
Preferences::Lock(FONT_VARIATIONS_PREF);
}
nsCOMPtr<nsIFile> profDir;
rv = NS_GetSpecialDirectory(NS_APP_PROFILE_DIR_STARTUP,
getter_AddRefs(profDir));
if (NS_FAILED(rv)) {
gfxVars::SetProfDirectory(nsString());
} else {
nsAutoString path;
profDir->GetPath(path);
gfxVars::SetProfDirectory(nsString(path));
}
gfxUtils::RemoveShaderCacheFromDiskIfNecessary();
}
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();

Просмотреть файл

@ -210,12 +210,10 @@ bool TransactionBuilder::IsRenderedFrameInvalidated() const {
}
void TransactionBuilder::SetDocumentView(
const LayoutDeviceIntRect& aDocumentRect,
const LayoutDeviceIntSize& aWidgetSize) {
wr::FramebufferIntRect wrDocRect;
const LayoutDeviceIntRect& aDocumentRect) {
wr::DeviceIntRect wrDocRect;
wrDocRect.origin.x = aDocumentRect.x;
wrDocRect.origin.y =
aWidgetSize.height - aDocumentRect.y - aDocumentRect.height;
wrDocRect.origin.y = aDocumentRect.y;
wrDocRect.size.width = aDocumentRect.width;
wrDocRect.size.height = aDocumentRect.height;
wr_transaction_set_document_view(mTxn, &wrDocRect);
@ -302,7 +300,7 @@ already_AddRefed<WebRenderAPI> WebRenderAPI::Clone() {
already_AddRefed<WebRenderAPI> WebRenderAPI::CreateDocument(
LayoutDeviceIntSize aSize, int8_t aLayerIndex, wr::RenderRoot aRenderRoot) {
wr::FramebufferIntSize wrSize;
wr::DeviceIntSize wrSize;
wrSize.width = aSize.width;
wrSize.height = aSize.height;
wr::DocumentHandle* newDoc;

Просмотреть файл

@ -104,8 +104,7 @@ class TransactionBuilder final {
const nsTArray<wr::WrOpacityProperty>& aOpacityArray,
const nsTArray<wr::WrTransformProperty>& aTransformArray);
void SetDocumentView(const LayoutDeviceIntRect& aDocRect,
const LayoutDeviceIntSize& aWidgetSize);
void SetDocumentView(const LayoutDeviceIntRect& aDocRect);
void UpdateScrollPosition(
const wr::WrPipelineId& aPipelineId,

Просмотреть файл

@ -210,7 +210,7 @@ pub struct DocumentHandle {
}
impl DocumentHandle {
pub fn new(api: RenderApi, size: FramebufferIntSize, layer: i8) -> DocumentHandle {
pub fn new(api: RenderApi, size: DeviceIntSize, layer: i8) -> DocumentHandle {
let doc = api.add_document(size, layer);
DocumentHandle {
api: api,
@ -218,7 +218,7 @@ impl DocumentHandle {
}
}
pub fn new_with_id(api: RenderApi, size: FramebufferIntSize, layer: i8, id: u32) -> DocumentHandle {
pub fn new_with_id(api: RenderApi, size: DeviceIntSize, layer: i8, id: u32) -> DocumentHandle {
let doc = api.add_document_with_id(size, layer, id);
DocumentHandle {
api: api,
@ -660,7 +660,7 @@ pub extern "C" fn wr_renderer_render(renderer: &mut Renderer,
if had_slow_frame {
renderer.notify_slow_frame();
}
match renderer.render(FramebufferIntSize::new(width, height)) {
match renderer.render(DeviceIntSize::new(width, height)) {
Ok(results) => {
*out_stats = results.stats;
true
@ -1233,7 +1233,7 @@ pub extern "C" fn wr_window_new(window_id: WrWindowId,
// Ensure the WR profiler callbacks are hooked up to the Gecko profiler.
set_profiler_hooks(Some(&PROFILER_HOOKS));
let window_size = FramebufferIntSize::new(window_width, window_height);
let window_size = DeviceIntSize::new(window_width, window_height);
let notifier = Box::new(CppNotifier {
window_id: window_id,
});
@ -1265,7 +1265,7 @@ pub extern "C" fn wr_window_new(window_id: WrWindowId,
pub extern "C" fn wr_api_create_document(
root_dh: &mut DocumentHandle,
out_handle: &mut *mut DocumentHandle,
doc_size: FramebufferIntSize,
doc_size: DeviceIntSize,
layer: i8,
document_id: u32
) {
@ -1452,7 +1452,7 @@ pub extern "C" fn wr_transaction_set_display_list(
#[no_mangle]
pub extern "C" fn wr_transaction_set_document_view(
txn: &mut Transaction,
doc_rect: &FramebufferIntRect,
doc_rect: &DeviceIntRect,
) {
txn.set_document_view(
*doc_rect,

10
gfx/wr/Cargo.lock сгенерированный
Просмотреть файл

@ -371,7 +371,7 @@ version = "0.1.0"
dependencies = [
"euclid 0.19.5 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)",
"mozangle 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"mozangle 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender 0.60.0",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"winit 0.16.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -865,7 +865,7 @@ dependencies = [
[[package]]
name = "mozangle"
version = "0.1.6"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1646,7 +1646,7 @@ dependencies = [
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"mozangle 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"mozangle 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"pathfinder_font_renderer 0.5.0 (git+https://github.com/pcwalton/pathfinder?branch=webrender)",
"pathfinder_gfx_utils 0.2.0 (git+https://github.com/pcwalton/pathfinder?branch=webrender)",
@ -1798,7 +1798,7 @@ dependencies = [
"image 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"mozangle 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"mozangle 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"osmesa-src 0.1.1 (git+https://github.com/servo/osmesa-src)",
"osmesa-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"ron 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1975,7 +1975,7 @@ dependencies = [
"checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3"
"checksum mio 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "75f72a93f046f1517e3cfddc0a096eb756a2ba727d36edc8227dee769a50a9b0"
"checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919"
"checksum mozangle 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1f0583e6792917f498bb3a7440f777a59353102063445ab7f5e9d1dc4ed593aa"
"checksum mozangle 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "45a8a18a41cfab0fde25cc2f43ea89064d211a0fbb33225b8ff93ab20406e0e7"
"checksum net2 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)" = "9044faf1413a1057267be51b5afba8eb1090bd2231c693664aa1db716fe1eae0"
"checksum nix 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d37e713a259ff641624b6cb20e3b12b2952313ba36b6823c0f16e6cfd9e5de17"
"checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2"

Просмотреть файл

@ -95,13 +95,13 @@ struct Rectangle {
renderer: Option<webrender::Renderer>,
api: api::RenderApi,
document_id: api::DocumentId,
size: api::units::FramebufferIntSize,
size: api::units::DeviceIntSize,
color: api::ColorF,
}
impl Rectangle {
fn new(composition: &DirectComposition, notifier: &Box<Notifier>,
device_pixel_ratio: f32, size: api::units::FramebufferIntSize, r: f32, g: f32, b: f32, a: f32)
device_pixel_ratio: f32, size: api::units::DeviceIntSize, r: f32, g: f32, b: f32, a: f32)
-> Self {
let visual = composition.create_angle_visual(size.width as u32, size.height as u32);
visual.make_current();

Просмотреть файл

@ -14,7 +14,7 @@ mod boilerplate;
use boilerplate::{Example, HandyDandyRectBuilder};
use std::cmp;
use webrender::api::*;
use webrender::api::units::FramebufferIntSize;
use webrender::api::units::DeviceIntSize;
struct App {
@ -27,7 +27,7 @@ impl Example for App {
_api: &RenderApi,
builder: &mut DisplayListBuilder,
_txn: &mut Transaction,
_framebuffer_size: FramebufferIntSize,
_device_size: DeviceIntSize,
pipeline_id: PipelineId,
_document_id: DocumentId,
) {

Просмотреть файл

@ -111,7 +111,7 @@ impl Example for App {
_api: &RenderApi,
builder: &mut DisplayListBuilder,
_txn: &mut Transaction,
_framebuffer_size: FramebufferIntSize,
_device_size: DeviceIntSize,
pipeline_id: PipelineId,
_document_id: DocumentId,
) {

Просмотреть файл

@ -186,7 +186,7 @@ impl Example for App {
api: &RenderApi,
builder: &mut DisplayListBuilder,
txn: &mut Transaction,
_: FramebufferIntSize,
_: DeviceIntSize,
pipeline_id: PipelineId,
_document_id: DocumentId,
) {

Просмотреть файл

@ -200,7 +200,7 @@ impl Example for App {
api: &RenderApi,
builder: &mut DisplayListBuilder,
txn: &mut Transaction,
_framebuffer_size: FramebufferIntSize,
_device_size: DeviceIntSize,
pipeline_id: PipelineId,
_document_id: DocumentId,
) {

Просмотреть файл

@ -80,7 +80,7 @@ pub trait Example {
api: &RenderApi,
builder: &mut DisplayListBuilder,
txn: &mut Transaction,
framebuffer_size: FramebufferIntSize,
device_size: DeviceIntSize,
pipeline_id: PipelineId,
document_id: DocumentId,
);
@ -160,12 +160,12 @@ pub fn main_wrapper<E: Example>(
..options.unwrap_or(webrender::RendererOptions::default())
};
let framebuffer_size = {
let device_size = {
let size = window
.get_inner_size()
.unwrap()
.to_physical(device_pixel_ratio as f64);
FramebufferIntSize::new(size.width as i32, size.height as i32)
DeviceIntSize::new(size.width as i32, size.height as i32)
};
let notifier = Box::new(Notifier::new(events_loop.create_proxy()));
let (mut renderer, sender) = webrender::Renderer::new(
@ -173,10 +173,10 @@ pub fn main_wrapper<E: Example>(
notifier,
opts,
None,
framebuffer_size,
device_size,
).unwrap();
let api = sender.create_api();
let document_id = api.add_document(framebuffer_size, 0);
let document_id = api.add_document(device_size, 0);
let (external, output) = example.get_image_handlers(&*gl);
@ -190,7 +190,7 @@ pub fn main_wrapper<E: Example>(
let epoch = Epoch(0);
let pipeline_id = PipelineId(0, 0);
let layout_size = framebuffer_size.to_f32() / euclid::TypedScale::new(device_pixel_ratio);
let layout_size = device_size.to_f32() / euclid::TypedScale::new(device_pixel_ratio);
let mut builder = DisplayListBuilder::new(pipeline_id, layout_size);
let mut txn = Transaction::new();
@ -198,7 +198,7 @@ pub fn main_wrapper<E: Example>(
&api,
&mut builder,
&mut txn,
framebuffer_size,
device_size,
pipeline_id,
document_id,
);
@ -250,11 +250,11 @@ pub fn main_wrapper<E: Example>(
),
winit::VirtualKeyCode::G => debug_flags.toggle(DebugFlags::GPU_CACHE_DBG),
winit::VirtualKeyCode::Key1 => txn.set_document_view(
framebuffer_size.into(),
device_size.into(),
1.0
),
winit::VirtualKeyCode::Key2 => txn.set_document_view(
framebuffer_size.into(),
device_size.into(),
2.0
),
winit::VirtualKeyCode::M => api.notify_memory_pressure(),
@ -291,7 +291,7 @@ pub fn main_wrapper<E: Example>(
&api,
&mut builder,
&mut txn,
framebuffer_size,
device_size,
pipeline_id,
document_id,
);
@ -307,7 +307,7 @@ pub fn main_wrapper<E: Example>(
api.send_transaction(document_id, txn);
renderer.update();
renderer.render(framebuffer_size).unwrap();
renderer.render(device_size).unwrap();
let _ = renderer.flush_pipeline_info();
example.draw_custom(&*gl);
window.swap_buffers().ok();

Просмотреть файл

@ -39,33 +39,33 @@ impl App {
let init_data = vec![
(
PipelineId(1, 0),
1,
-2,
ColorF::new(0.0, 1.0, 0.0, 1.0),
FramebufferIntPoint::new(0, 400),
DeviceIntPoint::new(0, 0),
),
(
PipelineId(2, 0),
2,
-1,
ColorF::new(1.0, 1.0, 0.0, 1.0),
FramebufferIntPoint::new(200, 400),
DeviceIntPoint::new(200, 0),
),
(
PipelineId(3, 0),
3,
0,
ColorF::new(1.0, 0.0, 0.0, 1.0),
FramebufferIntPoint::new(200, 600),
DeviceIntPoint::new(200, 200),
),
(
PipelineId(4, 0),
4,
1,
ColorF::new(1.0, 0.0, 1.0, 1.0),
FramebufferIntPoint::new(0, 600),
DeviceIntPoint::new(0, 200),
),
];
for (pipeline_id, layer, color, offset) in init_data {
let size = FramebufferIntSize::new(250, 250);
let bounds = FramebufferIntRect::new(offset, size);
let size = DeviceIntSize::new(250, 250);
let bounds = DeviceIntRect::new(offset, size);
let document_id = api.add_document(size, layer);
let mut txn = Transaction::new();
@ -92,12 +92,12 @@ impl Example for App {
api: &RenderApi,
base_builder: &mut DisplayListBuilder,
_txn: &mut Transaction,
framebuffer_size: FramebufferIntSize,
device_size: DeviceIntSize,
_pipeline_id: PipelineId,
_: DocumentId,
) {
if self.documents.is_empty() {
let device_pixel_ratio = framebuffer_size.width as f32 /
let device_pixel_ratio = device_size.width as f32 /
base_builder.content_size().width;
// this is the first run, hack around the boilerplate,
// which assumes an example only needs one document

Просмотреть файл

@ -70,7 +70,7 @@ impl App {
fn init_output_document(
&mut self,
api: &RenderApi,
framebuffer_size: FramebufferIntSize,
device_size: DeviceIntSize,
device_pixel_ratio: f32,
) {
// Generate the external image key that will be used to render the output document to the root document.
@ -79,14 +79,11 @@ impl App {
let pipeline_id = PipelineId(1, 0);
let layer = 1;
let color = ColorF::new(1., 1., 0., 1.);
let document_id = api.add_document(framebuffer_size, layer);
let document_id = api.add_document(device_size, layer);
api.enable_frame_output(document_id, pipeline_id, true);
api.set_document_view(
document_id,
FramebufferIntRect::new(
FramebufferIntPoint::new(0, 1000),
framebuffer_size,
),
device_size.into(),
device_pixel_ratio,
);
@ -95,7 +92,7 @@ impl App {
pipeline_id,
content_rect: LayoutRect::new(
LayoutPoint::zero(),
framebuffer_size.to_f32() / TypedScale::new(device_pixel_ratio),
device_size.to_f32() / TypedScale::new(device_pixel_ratio),
),
color,
};
@ -151,14 +148,14 @@ impl Example for App {
api: &RenderApi,
builder: &mut DisplayListBuilder,
_txn: &mut Transaction,
framebuffer_size: FramebufferIntSize,
device_size: DeviceIntSize,
pipeline_id: PipelineId,
_document_id: DocumentId,
) {
if self.output_document.is_none() {
let device_pixel_ratio = framebuffer_size.width as f32 /
let device_pixel_ratio = device_size.width as f32 /
builder.content_size().width;
self.init_output_document(api, FramebufferIntSize::new(200, 200), device_pixel_ratio);
self.init_output_document(api, DeviceIntSize::new(200, 200), device_pixel_ratio);
}
let bounds = (100, 100).to(200, 200);

Просмотреть файл

@ -26,7 +26,7 @@ impl Example for App {
api: &RenderApi,
builder: &mut DisplayListBuilder,
_txn: &mut Transaction,
_framebuffer_size: FramebufferIntSize,
_device_size: DeviceIntSize,
pipeline_id: PipelineId,
document_id: DocumentId,
) {

Просмотреть файл

@ -26,7 +26,7 @@ impl Example for App {
_api: &RenderApi,
builder: &mut DisplayListBuilder,
txn: &mut Transaction,
_framebuffer_size: FramebufferIntSize,
_device_size: DeviceIntSize,
pipeline_id: PipelineId,
_document_id: DocumentId,
) {

Просмотреть файл

@ -97,17 +97,17 @@ impl Window {
..webrender::RendererOptions::default()
};
let framebuffer_size = {
let device_size = {
let size = window
.get_inner_size()
.unwrap()
.to_physical(device_pixel_ratio as f64);
FramebufferIntSize::new(size.width as i32, size.height as i32)
DeviceIntSize::new(size.width as i32, size.height as i32)
};
let notifier = Box::new(Notifier::new(events_loop.create_proxy()));
let (renderer, sender) = webrender::Renderer::new(gl.clone(), notifier, opts, None, framebuffer_size).unwrap();
let (renderer, sender) = webrender::Renderer::new(gl.clone(), notifier, opts, None, device_size).unwrap();
let api = sender.create_api();
let document_id = api.add_document(framebuffer_size, 0);
let document_id = api.add_document(device_size, 0);
let epoch = Epoch(0);
let pipeline_id = PipelineId(0, 0);
@ -176,14 +176,14 @@ impl Window {
}
let device_pixel_ratio = self.window.get_hidpi_factor() as f32;
let framebuffer_size = {
let device_size = {
let size = self.window
.get_inner_size()
.unwrap()
.to_physical(device_pixel_ratio as f64);
FramebufferIntSize::new(size.width as i32, size.height as i32)
DeviceIntSize::new(size.width as i32, size.height as i32)
};
let layout_size = framebuffer_size.to_f32() / euclid::TypedScale::new(device_pixel_ratio);
let layout_size = device_size.to_f32() / euclid::TypedScale::new(device_pixel_ratio);
let mut txn = Transaction::new();
let mut builder = DisplayListBuilder::new(self.pipeline_id, layout_size);
let space_and_clip = SpaceAndClipInfo::root_scroll(self.pipeline_id);
@ -286,7 +286,7 @@ impl Window {
api.send_transaction(self.document_id, txn);
renderer.update();
renderer.render(framebuffer_size).unwrap();
renderer.render(device_size).unwrap();
self.window.swap_buffers().ok();
false

Просмотреть файл

@ -28,7 +28,7 @@ impl Example for App {
_api: &RenderApi,
builder: &mut DisplayListBuilder,
_txn: &mut Transaction,
_framebuffer_size: FramebufferIntSize,
_device_size: DeviceIntSize,
pipeline_id: PipelineId,
_document_id: DocumentId,
) {

Просмотреть файл

@ -92,7 +92,7 @@ impl Example for App {
api: &RenderApi,
builder: &mut DisplayListBuilder,
txn: &mut Transaction,
_framebuffer_size: FramebufferIntSize,
_device_size: DeviceIntSize,
pipeline_id: PipelineId,
_document_id: DocumentId,
) {

Просмотреть файл

@ -89,7 +89,7 @@ impl Example for App {
api: &RenderApi,
builder: &mut DisplayListBuilder,
txn: &mut Transaction,
_framebuffer_size: FramebufferIntSize,
_device_size: DeviceIntSize,
pipeline_id: PipelineId,
_document_id: DocumentId,
) {

Просмотреть файл

@ -312,7 +312,7 @@ impl DebugRenderer {
pub fn render(
&mut self,
device: &mut Device,
viewport_size: Option<FramebufferIntSize>,
viewport_size: Option<DeviceIntSize>,
scale: f32,
) {
if let Some(viewport_size) = viewport_size {

Просмотреть файл

@ -1033,10 +1033,11 @@ pub enum DrawTarget<'a> {
}
impl<'a> DrawTarget<'a> {
pub fn new_default(size: FramebufferIntSize) -> Self {
pub fn new_default(size: DeviceIntSize) -> Self {
let total_size = FramebufferIntSize::from_untyped(&size.to_untyped());
DrawTarget::Default {
rect: size.into(),
total_size: size,
rect: total_size.into(),
total_size,
}
}

Просмотреть файл

@ -343,7 +343,7 @@ impl<'a> DisplayListFlattener<'a> {
new_scene.pipelines = scene.pipelines.clone();
FrameBuilder::with_display_list_flattener(
DeviceIntSize::from_untyped(&view.framebuffer_rect.size.to_untyped()).into(),
view.device_rect.size.into(),
background_color,
flattener,
)

Просмотреть файл

@ -493,7 +493,7 @@ impl FrameBuilder {
pipelines: &FastHashMap<PipelineId, Arc<ScenePipeline>>,
global_device_pixel_scale: DevicePixelScale,
layer: DocumentLayer,
framebuffer_origin: FramebufferIntPoint,
device_origin: DeviceIntPoint,
pan: WorldPoint,
texture_cache_profile: &mut TextureCacheProfileCounters,
gpu_cache_profile: &mut GpuCacheProfileCounters,
@ -644,9 +644,9 @@ impl FrameBuilder {
Frame {
content_origin: self.output_rect.origin,
framebuffer_rect: FramebufferIntRect::new(
framebuffer_origin,
FramebufferIntSize::from_untyped(&self.output_rect.size.to_untyped()),
device_rect: DeviceIntRect::new(
device_origin,
self.output_rect.size,
),
background_color: self.background_color,
layer,

Просмотреть файл

@ -68,7 +68,7 @@ use util::{Recycler, VecHelper, drain_filter};
#[cfg_attr(feature = "replay", derive(Deserialize))]
#[derive(Clone)]
pub struct DocumentView {
pub framebuffer_rect: FramebufferIntRect,
pub device_rect: DeviceIntRect,
pub layer: DocumentLayer,
pub pan: DeviceIntPoint,
pub device_pixel_ratio: f32,
@ -359,7 +359,7 @@ struct Document {
impl Document {
pub fn new(
id: DocumentId,
size: FramebufferIntSize,
size: DeviceIntSize,
layer: DocumentLayer,
default_device_pixel_ratio: f32,
) -> Self {
@ -368,7 +368,7 @@ impl Document {
scene: Scene::new(),
removed_pipelines: Vec::new(),
view: DocumentView {
framebuffer_rect: FramebufferIntRect::new(FramebufferIntPoint::zero(), size),
device_rect: size.into(),
layer,
pan: DeviceIntPoint::zero(),
page_zoom_factor: 1.0,
@ -396,7 +396,7 @@ impl Document {
}
fn has_pixels(&self) -> bool {
!self.view.framebuffer_rect.size.is_empty_or_negative()
!self.view.device_rect.size.is_empty_or_negative()
}
fn process_frame_msg(
@ -517,7 +517,7 @@ impl Document {
&self.scene.pipelines,
accumulated_scale_factor,
self.view.layer,
self.view.framebuffer_rect.origin,
self.view.device_rect.origin,
pan,
&mut resource_profile.texture_cache,
&mut resource_profile.gpu_cache,
@ -756,10 +756,10 @@ impl RenderBackend {
doc.view.page_zoom_factor = factor.get();
}
SceneMsg::SetDocumentView {
framebuffer_rect,
device_rect,
device_pixel_ratio,
} => {
doc.view.framebuffer_rect = framebuffer_rect;
doc.view.device_rect = device_rect;
doc.view.device_pixel_ratio = device_pixel_ratio;
}
SceneMsg::SetDisplayList {

Просмотреть файл

@ -1935,7 +1935,7 @@ pub struct Renderer {
/// Notification requests to be fulfilled after rendering.
notifications: Vec<NotificationRequest>,
framebuffer_size: Option<FramebufferIntSize>,
device_size: Option<DeviceIntSize>,
/// A lazily created texture for the zoom debugging widget.
zoom_debug_texture: Option<Texture>,
@ -1999,7 +1999,7 @@ impl Renderer {
notifier: Box<RenderNotifier>,
mut options: RendererOptions,
shaders: Option<&mut WrShaders>,
start_size: FramebufferIntSize,
start_size: DeviceIntSize,
) -> Result<(Self, RenderApiSender), RendererError> {
HAS_BEEN_INITIALIZED.store(true, Ordering::SeqCst);
@ -2418,7 +2418,7 @@ impl Renderer {
#[cfg(feature = "replay")]
owned_external_images: FastHashMap::default(),
notifications: Vec::new(),
framebuffer_size: None,
device_size: None,
zoom_debug_texture: None,
cursor_position: DeviceIntPoint::zero(),
};
@ -2431,8 +2431,8 @@ impl Renderer {
Ok((renderer, sender))
}
pub fn framebuffer_size(&self) -> Option<FramebufferIntSize> {
self.framebuffer_size
pub fn device_size(&self) -> Option<DeviceIntSize> {
self.device_size
}
/// Update the current position of the debug cursor.
@ -2497,8 +2497,8 @@ impl Renderer {
// (in order to update the texture cache), issue
// a render just to off-screen targets.
if self.active_documents[pos].1.frame.must_be_drawn() {
let framebuffer_size = self.framebuffer_size;
self.render_impl(framebuffer_size).ok();
let device_size = self.device_size;
self.render_impl(device_size).ok();
}
self.active_documents[pos].1 = doc;
}
@ -2933,11 +2933,11 @@ impl Renderer {
/// A Frame is supplied by calling [`generate_frame()`][webrender_api::Transaction::generate_frame].
pub fn render(
&mut self,
framebuffer_size: FramebufferIntSize,
device_size: DeviceIntSize,
) -> Result<RenderResults, Vec<RendererError>> {
self.framebuffer_size = Some(framebuffer_size);
self.device_size = Some(device_size);
let result = self.render_impl(Some(framebuffer_size));
let result = self.render_impl(Some(device_size));
drain_filter(
&mut self.notifications,
@ -2953,13 +2953,13 @@ impl Renderer {
result
}
// If framebuffer_size is None, don't render
// If device_size is None, don't render
// to the main frame buffer. This is useful
// to update texture cache render tasks but
// avoid doing a full frame render.
fn render_impl(
&mut self,
framebuffer_size: Option<FramebufferIntSize>,
device_size: Option<DeviceIntSize>,
) -> Result<RenderResults, Vec<RendererError>> {
profile_scope!("render");
let mut results = RenderResults::default();
@ -3033,13 +3033,13 @@ impl Renderer {
self.draw_tile_frame(
frame,
framebuffer_size,
device_size,
cpu_frame_id,
&mut results.stats,
doc_index == 0,
);
if let Some(_) = framebuffer_size {
if let Some(_) = device_size {
self.draw_frame_debug_items(&frame.debug_items);
}
if self.debug_flags.contains(DebugFlags::PROFILER_DBG) {
@ -3063,16 +3063,16 @@ impl Renderer {
self.active_documents = active_documents;
});
if let Some(framebuffer_size) = framebuffer_size {
self.draw_render_target_debug(framebuffer_size);
self.draw_texture_cache_debug(framebuffer_size);
self.draw_gpu_cache_debug(framebuffer_size);
self.draw_zoom_debug(framebuffer_size);
if let Some(device_size) = device_size {
self.draw_render_target_debug(device_size);
self.draw_texture_cache_debug(device_size);
self.draw_gpu_cache_debug(device_size);
self.draw_zoom_debug(device_size);
self.draw_epoch_debug();
}
let current_time = precise_time_ns();
if framebuffer_size.is_some() {
if device_size.is_some() {
let ns = current_time - self.last_time;
self.profile_counters.frame_time.set(ns);
}
@ -3091,10 +3091,10 @@ impl Renderer {
}
if self.debug_flags.contains(DebugFlags::PROFILER_DBG) {
if let Some(framebuffer_size) = framebuffer_size {
if let Some(device_size) = device_size {
//TODO: take device/pixel ratio into equation?
if let Some(debug_renderer) = self.debug.get_mut(&mut self.device) {
let screen_fraction = 1.0 / framebuffer_size.to_f32().area();
let screen_fraction = 1.0 / device_size.to_f32().area();
self.profiler.draw_profile(
&frame_profiles,
&self.backend_profile_counters,
@ -3162,7 +3162,7 @@ impl Renderer {
if let Some(debug_renderer) = self.debug.try_get_mut() {
let small_screen = self.debug_flags.contains(DebugFlags::SMALL_SCREEN);
let scale = if small_screen { 1.6 } else { 1.0 };
debug_renderer.render(&mut self.device, framebuffer_size, scale);
debug_renderer.render(&mut self.device, device_size, scale);
}
// See comment for texture_resolver.begin_frame() for explanation
// of why this must be done after all rendering, including debug
@ -3173,7 +3173,7 @@ impl Renderer {
self.device.end_frame();
});
if framebuffer_size.is_some() {
if device_size.is_some() {
self.last_time = current_time;
}
@ -4630,7 +4630,7 @@ impl Renderer {
fn draw_tile_frame(
&mut self,
frame: &mut Frame,
framebuffer_size: Option<FramebufferIntSize>,
device_size: Option<DeviceIntSize>,
frame_id: GpuFrameId,
stats: &mut RendererStats,
clear_framebuffer: bool,
@ -4642,25 +4642,6 @@ impl Renderer {
return;
}
// TODO(gw): This is a hack / workaround for a resizing glitch. What
// happens is that the framebuffer rect / content origin are
// determined during frame building, rather than at render
// time (which is what used to happen). This means that the
// framebuffer rect/origin can be wrong by the time a frame
// is drawn, if resizing is occurring. This hack just makes
// the framebuffer rect/origin be hard coded to the current
// framebuffer size at render time. It seems like this probably
// breaks some assumptions elsewhere, but it seems to fix the
// bug and I haven't noticed any other issues so far. We will
// need to investigate this further and make a "proper" fix.
if let Some(framebuffer_size) = framebuffer_size {
frame.framebuffer_rect = FramebufferIntRect::new(
FramebufferIntPoint::zero(),
framebuffer_size,
);
frame.content_origin = DeviceIntPoint::zero();
}
self.device.disable_depth_write();
self.set_blend(false, FramebufferKind::Other);
self.device.disable_stencil();
@ -4683,11 +4664,11 @@ impl Renderer {
match pass.kind {
RenderPassKind::MainFramebuffer(ref target) => {
if let Some(framebuffer_size) = framebuffer_size {
if let Some(device_size) = device_size {
stats.color_target_count += 1;
let offset = frame.content_origin.to_f32();
let size = frame.framebuffer_rect.size.to_f32();
let size = frame.device_rect.size.to_f32();
let projection = Transform3D::ortho(
offset.x,
offset.x + size.width,
@ -4697,9 +4678,13 @@ impl Renderer {
ORTHO_FAR_PLANE,
);
let fb_scale = TypedScale::<_, _, FramebufferPixel>::new(1i32);
let mut fb_rect = frame.device_rect * fb_scale;
fb_rect.origin.y = device_size.height - fb_rect.origin.y - fb_rect.size.height;
let draw_target = DrawTarget::Default {
rect: frame.framebuffer_rect,
total_size: framebuffer_size,
rect: fb_rect,
total_size: device_size * fb_scale,
};
if clear_framebuffer {
self.device.bind_draw_target(draw_target);
@ -4817,12 +4802,12 @@ impl Renderer {
}
}
if let Some(framebuffer_size) = framebuffer_size {
if let Some(device_size) = device_size {
self.draw_frame_debug_items(&frame.debug_items);
self.draw_render_target_debug(framebuffer_size);
self.draw_texture_cache_debug(framebuffer_size);
self.draw_gpu_cache_debug(framebuffer_size);
self.draw_zoom_debug(framebuffer_size);
self.draw_render_target_debug(device_size);
self.draw_texture_cache_debug(device_size);
self.draw_gpu_cache_debug(device_size);
self.draw_zoom_debug(device_size);
}
self.draw_epoch_debug();
@ -4973,7 +4958,7 @@ impl Renderer {
}
}
fn draw_render_target_debug(&mut self, framebuffer_size: FramebufferIntSize) {
fn draw_render_target_debug(&mut self, device_size: DeviceIntSize) {
if !self.debug_flags.contains(DebugFlags::RENDER_TARGET_DBG) {
return;
}
@ -4990,7 +4975,7 @@ impl Renderer {
&mut self.device,
debug_renderer,
textures,
framebuffer_size,
device_size,
0,
&|_| [0.0, 1.0, 0.0, 1.0], // Use green for all RTs.
);
@ -4998,7 +4983,7 @@ impl Renderer {
fn draw_zoom_debug(
&mut self,
framebuffer_size: FramebufferIntSize,
device_size: DeviceIntSize,
) {
if !self.debug_flags.contains(DebugFlags::ZOOM_DBG) {
return;
@ -5014,10 +4999,10 @@ impl Renderer {
let source_origin = DeviceIntPoint::new(
(self.cursor_position.x - source_size.width / 2)
.min(framebuffer_size.width - source_size.width)
.min(device_size.width - source_size.width)
.max(0),
(self.cursor_position.y - source_size.height / 2)
.min(framebuffer_size.height - source_size.height)
.min(device_size.height - source_size.height)
.max(0),
);
@ -5028,8 +5013,8 @@ impl Renderer {
let target_rect = DeviceIntRect::new(
DeviceIntPoint::new(
framebuffer_size.width - target_size.width - 64,
framebuffer_size.height - target_size.height - 64,
device_size.width - target_size.width - 64,
device_size.height - target_size.height - 64,
),
target_size,
);
@ -5059,7 +5044,7 @@ impl Renderer {
}
// Copy frame buffer into the zoom texture
let read_target = DrawTarget::new_default(framebuffer_size);
let read_target = DrawTarget::new_default(device_size);
self.device.blit_render_target(
read_target.into(),
read_target.to_framebuffer_rect(source_rect),
@ -5085,7 +5070,7 @@ impl Renderer {
);
}
fn draw_texture_cache_debug(&mut self, framebuffer_size: FramebufferIntSize) {
fn draw_texture_cache_debug(&mut self, device_size: DeviceIntSize) {
if !self.debug_flags.contains(DebugFlags::TEXTURE_CACHE_DBG) {
return;
}
@ -5110,7 +5095,7 @@ impl Renderer {
&mut self.device,
debug_renderer,
textures,
framebuffer_size,
device_size,
if self.debug_flags.contains(DebugFlags::RENDER_TARGET_DBG) { 544 } else { 0 },
&select_color,
);
@ -5120,15 +5105,15 @@ impl Renderer {
device: &mut Device,
debug_renderer: &mut DebugRenderer,
mut textures: Vec<&Texture>,
framebuffer_size: FramebufferIntSize,
device_size: DeviceIntSize,
bottom: i32,
select_color: &Fn(&Texture) -> [f32; 4],
) {
let mut spacing = 16;
let mut size = 512;
let fb_width = framebuffer_size.width as i32;
let fb_height = framebuffer_size.height as i32;
let fb_width = device_size.width;
let fb_height = device_size.height;
let num_layers: i32 = textures.iter()
.map(|texture| texture.get_layer_count())
.sum();
@ -5198,7 +5183,7 @@ impl Renderer {
device.blit_render_target_invert_y(
ReadTarget::Texture { texture, layer },
src_rect,
DrawTarget::new_default(framebuffer_size),
DrawTarget::new_default(device_size),
FramebufferIntRect::from_untyped(&dest_rect),
);
i += 1;
@ -5243,7 +5228,7 @@ impl Renderer {
);
}
fn draw_gpu_cache_debug(&mut self, framebuffer_size: FramebufferIntSize) {
fn draw_gpu_cache_debug(&mut self, device_size: DeviceIntSize) {
if !self.debug_flags.contains(DebugFlags::GPU_CACHE_DBG) {
return;
}
@ -5256,7 +5241,7 @@ impl Renderer {
let (x_off, y_off) = (30f32, 30f32);
let height = self.gpu_cache_texture.texture
.as_ref().map_or(0, |t| t.get_dimensions().height)
.min(framebuffer_size.height - (y_off as i32) * 2) as usize;
.min(device_size.height - (y_off as i32) * 2) as usize;
debug_renderer.add_quad(
x_off,
y_off,
@ -5291,7 +5276,7 @@ impl Renderer {
pixels
}
pub fn read_gpu_cache(&mut self) -> (FramebufferIntSize, Vec<u8>) {
pub fn read_gpu_cache(&mut self) -> (DeviceIntSize, Vec<u8>) {
let texture = self.gpu_cache_texture.texture.as_ref().unwrap();
let size = FramebufferIntSize::from_untyped(&texture.get_dimensions().to_untyped());
let mut texels = vec![0; (size.width * size.height * 16) as usize];
@ -5304,7 +5289,7 @@ impl Renderer {
);
self.device.reset_read_target();
self.device.end_frame();
(size, texels)
(texture.get_dimensions(), texels)
}
// De-initialize the Renderer safely, assuming the GL is still alive and active.
@ -5704,7 +5689,7 @@ struct PlainTexture {
#[cfg_attr(feature = "capture", derive(Serialize))]
#[cfg_attr(feature = "replay", derive(Deserialize))]
struct PlainRenderer {
framebuffer_size: Option<FramebufferIntSize>,
device_size: Option<DeviceIntSize>,
gpu_cache: PlainTexture,
gpu_cache_frame_id: FrameId,
textures: FastHashMap<CacheTextureId, PlainTexture>,
@ -5939,7 +5924,7 @@ impl Renderer {
info!("saving GPU cache");
self.update_gpu_cache(); // flush pending updates
let mut plain_self = PlainRenderer {
framebuffer_size: self.framebuffer_size,
device_size: self.device_size,
gpu_cache: Self::save_texture(
&self.gpu_cache_texture.texture.as_ref().unwrap(),
"gpu", &config.root, &mut self.device,
@ -6002,7 +5987,7 @@ impl Renderer {
if let Some(renderer) = CaptureConfig::deserialize::<PlainRenderer, _>(&root, "renderer") {
info!("loading cached textures");
self.framebuffer_size = renderer.framebuffer_size;
self.device_size = renderer.device_size;
self.device.begin_frame();
for (_id, texture) in self.texture_resolver.texture_cache_map.drain() {

Просмотреть файл

@ -2208,7 +2208,7 @@ impl ResourceCache {
self.texture_cache.max_texture_size(),
self.texture_cache.max_texture_layers(),
self.texture_cache.picture_tile_size(),
FramebufferIntSize::zero(),
DeviceIntSize::zero(),
);
}
}

Просмотреть файл

@ -527,7 +527,7 @@ impl TextureCache {
max_texture_size: i32,
mut max_texture_layers: usize,
picture_tile_size: Option<DeviceIntSize>,
initial_size: FramebufferIntSize,
initial_size: DeviceIntSize,
) -> Self {
if cfg!(target_os = "macos") {
// On MBP integrated Intel GPUs, texture arrays appear to be
@ -598,7 +598,7 @@ impl TextureCache {
/// directly from unit test code.
#[cfg(test)]
pub fn new_for_testing(max_texture_size: i32, max_texture_layers: usize) -> Self {
let mut cache = Self::new(max_texture_size, max_texture_layers, None, FramebufferIntSize::zero());
let mut cache = Self::new(max_texture_size, max_texture_layers, None, DeviceIntSize::zero());
let mut now = FrameStamp::first(DocumentId::new(IdNamespace(1), 1));
now.advance();
cache.begin_frame(now);

Просмотреть файл

@ -1172,7 +1172,7 @@ pub struct Frame {
/// The origin on content produced by the render tasks.
pub content_origin: DeviceIntPoint,
/// The rectangle to show the frame in, on screen.
pub framebuffer_rect: FramebufferIntRect,
pub device_rect: DeviceIntRect,
pub background_color: Option<ColorF>,
pub layer: DocumentLayer,
pub passes: Vec<RenderPass>,

Просмотреть файл

@ -202,12 +202,12 @@ impl Transaction {
/// Setup the output region in the framebuffer for a given document.
pub fn set_document_view(
&mut self,
framebuffer_rect: FramebufferIntRect,
device_rect: DeviceIntRect,
device_pixel_ratio: f32,
) {
self.scene_ops.push(
SceneMsg::SetDocumentView {
framebuffer_rect,
device_rect,
device_pixel_ratio,
},
);
@ -600,7 +600,7 @@ pub enum SceneMsg {
preserve_frame_state: bool,
},
SetDocumentView {
framebuffer_rect: FramebufferIntRect,
device_rect: DeviceIntRect,
device_pixel_ratio: f32,
},
}
@ -729,7 +729,7 @@ pub enum ApiMsg {
/// Adds a new document namespace.
CloneApiByClient(IdNamespace),
/// Adds a new document with given initial size.
AddDocument(DocumentId, FramebufferIntSize, DocumentLayer),
AddDocument(DocumentId, DeviceIntSize, DocumentLayer),
/// A message targeted at a particular document.
UpdateDocuments(Vec<DocumentId>, Vec<TransactionMsg>),
/// Deletes an existing document.
@ -1078,13 +1078,13 @@ impl RenderApi {
RenderApiSender::new(self.api_sender.clone(), self.payload_sender.clone())
}
pub fn add_document(&self, initial_size: FramebufferIntSize, layer: DocumentLayer) -> DocumentId {
pub fn add_document(&self, initial_size: DeviceIntSize, layer: DocumentLayer) -> DocumentId {
let new_id = self.next_unique_id();
self.add_document_with_id(initial_size, layer, new_id)
}
pub fn add_document_with_id(&self,
initial_size: FramebufferIntSize,
initial_size: DeviceIntSize,
layer: DocumentLayer,
id: u32) -> DocumentId {
let document_id = DocumentId::new(self.namespace_id, id);
@ -1284,12 +1284,12 @@ impl RenderApi {
pub fn set_document_view(
&self,
document_id: DocumentId,
framebuffer_rect: FramebufferIntRect,
device_rect: DeviceIntRect,
device_pixel_ratio: f32,
) {
self.send_scene_msg(
document_id,
SceneMsg::SetDocumentView { framebuffer_rect, device_pixel_ratio },
SceneMsg::SetDocumentView { device_rect, device_pixel_ratio },
);
}

Просмотреть файл

@ -180,18 +180,18 @@ impl WindowWrapper {
}
}
fn get_inner_size(&self) -> FramebufferIntSize {
fn inner_size(window: &winit::Window) -> FramebufferIntSize {
fn get_inner_size(&self) -> DeviceIntSize {
fn inner_size(window: &winit::Window) -> DeviceIntSize {
let size = window
.get_inner_size()
.unwrap()
.to_physical(window.get_hidpi_factor());
FramebufferIntSize::new(size.width as i32, size.height as i32)
DeviceIntSize::new(size.width as i32, size.height as i32)
}
match *self {
WindowWrapper::Window(ref window, _) => inner_size(window.window()),
WindowWrapper::Angle(ref window, ..) => inner_size(window),
WindowWrapper::Headless(ref context, _) => FramebufferIntSize::new(context.width, context.height),
WindowWrapper::Headless(ref context, _) => DeviceIntSize::new(context.width, context.height),
}
}
@ -203,7 +203,7 @@ impl WindowWrapper {
}
}
fn resize(&mut self, size: FramebufferIntSize) {
fn resize(&mut self, size: DeviceIntSize) {
match *self {
WindowWrapper::Window(ref mut window, _) => {
window.set_inner_size(LogicalSize::new(size.width as f64, size.height as f64))
@ -241,7 +241,7 @@ impl WindowWrapper {
}
fn make_window(
size: FramebufferIntSize,
size: DeviceIntSize,
dp_ratio: Option<f32>,
vsync: bool,
events_loop: &Option<winit::EventsLoop>,
@ -427,20 +427,20 @@ fn main() {
});
let size = args.value_of("size")
.map(|s| if s == "720p" {
FramebufferIntSize::new(1280, 720)
DeviceIntSize::new(1280, 720)
} else if s == "1080p" {
FramebufferIntSize::new(1920, 1080)
DeviceIntSize::new(1920, 1080)
} else if s == "4k" {
FramebufferIntSize::new(3840, 2160)
DeviceIntSize::new(3840, 2160)
} else {
let x = s.find('x').expect(
"Size must be specified exactly as 720p, 1080p, 4k, or width x height",
);
let w = s[0 .. x].parse::<i32>().expect("Invalid size width");
let h = s[x + 1 ..].parse::<i32>().expect("Invalid size height");
FramebufferIntSize::new(w, h)
DeviceIntSize::new(w, h)
})
.unwrap_or(FramebufferIntSize::new(1920, 1080));
.unwrap_or(DeviceIntSize::new(1920, 1080));
let zoom_factor = args.value_of("zoom").map(|z| z.parse::<f32>().unwrap());
let chase_primitive = match args.value_of("chase") {
Some(s) => {
@ -545,7 +545,7 @@ fn main() {
fn render<'a>(
wrench: &mut Wrench,
window: &mut WindowWrapper,
size: FramebufferIntSize,
size: DeviceIntSize,
events_loop: &mut Option<winit::EventsLoop>,
subargs: &clap::ArgMatches<'a>,
) {
@ -556,7 +556,7 @@ fn render<'a>(
let mut documents = wrench.api.load_capture(input_path);
println!("loaded {:?}", documents.iter().map(|cd| cd.document_id).collect::<Vec<_>>());
let captured = documents.swap_remove(0);
if let Some(fb_size) = wrench.renderer.framebuffer_size() {
if let Some(fb_size) = wrench.renderer.device_size() {
window.resize(fb_size);
}
wrench.document_id = captured.document_id;
@ -787,7 +787,8 @@ fn render<'a>(
match *events_loop {
None => {
while body(wrench, vec![winit::Event::Awakened]) == winit::ControlFlow::Continue {}
let pixels = wrench.renderer.read_pixels_rgba8(size.into());
let fb_rect = FramebufferIntSize::new(size.width, size.height).into();
let pixels = wrench.renderer.read_pixels_rgba8(fb_rect);
save_flipped("screenshot.png", pixels, size);
}
Some(ref mut events_loop) => {

Просмотреть файл

@ -25,7 +25,7 @@ pub struct SaveSettings {
pub fn save<P: Clone + AsRef<Path>>(
path: P,
orig_pixels: Vec<u8>,
size: FramebufferIntSize,
size: DeviceIntSize,
settings: SaveSettings
) {
let mut width = size.width as u32;
@ -66,7 +66,7 @@ pub fn save<P: Clone + AsRef<Path>>(
pub fn save_flipped<P: Clone + AsRef<Path>>(
path: P,
orig_pixels: Vec<u8>,
size: FramebufferIntSize,
size: DeviceIntSize,
) {
save(path, orig_pixels, size, SaveSettings {
flip_vertical: true,
@ -91,8 +91,8 @@ pub fn png(
let (fb_size, data, settings) = match surface {
ReadSurface::Screen => {
let dim = window.get_inner_size();
let data = wrench.renderer
.read_pixels_rgba8(dim.into());
let rect = FramebufferIntSize::new(dim.width, dim.height).into();
let data = wrench.renderer.read_pixels_rgba8(rect);
(dim, data, SaveSettings {
flip_vertical: true,
try_crop: true,

Просмотреть файл

@ -1143,7 +1143,7 @@ impl<'a> RawtestHarness<'a> {
println!("\tzero height test...");
let layout_size = LayoutSize::new(120.0, 0.0);
let window_size = FramebufferIntSize::new(layout_size.width as i32, layout_size.height as i32);
let window_size = DeviceIntSize::new(layout_size.width as i32, layout_size.height as i32);
let doc_id = self.wrench.api.add_document(window_size, 1);
let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id, layout_size);

Просмотреть файл

@ -123,7 +123,7 @@ impl Display for Reftest {
struct ReftestImage {
data: Vec<u8>,
size: FramebufferIntSize,
size: DeviceIntSize,
}
enum ReftestImageComparison {
Equal,
@ -520,14 +520,14 @@ impl<'a> ReftestHarness<'a> {
let size = img.dimensions();
ReftestImage {
data: img.into_raw(),
size: FramebufferIntSize::new(size.0 as i32, size.1 as i32),
size: DeviceIntSize::new(size.0 as i32, size.1 as i32),
}
}
fn render_yaml(
&mut self,
filename: &Path,
size: FramebufferIntSize,
size: DeviceIntSize,
font_render_mode: Option<FontRenderMode>,
allow_mipmaps: bool,
) -> YamlRenderOutput {
@ -552,7 +552,7 @@ impl<'a> ReftestHarness<'a> {
// taking the bottom left sub-rectangle
let rect = FramebufferIntRect::new(
FramebufferIntPoint::new(0, window_size.height - size.height),
size,
FramebufferIntSize::new(size.width, size.height),
);
let pixels = self.wrench.renderer.read_pixels_rgba8(rect);
self.window.swap_buffers();

Просмотреть файл

@ -143,7 +143,7 @@ impl WrenchThing for CapturedDocument {
}
pub struct Wrench {
window_size: FramebufferIntSize,
window_size: DeviceIntSize,
pub device_pixel_ratio: f32,
page_zoom_factor: ZoomFactor,
@ -171,7 +171,7 @@ impl Wrench {
shader_override_path: Option<PathBuf>,
dp_ratio: f32,
save_type: Option<SaveType>,
size: FramebufferIntSize,
size: DeviceIntSize,
do_rebuild: bool,
no_subpixel_aa: bool,
verbose: bool,
@ -517,7 +517,7 @@ impl Wrench {
self.api.update_resources(txn.resource_updates);
}
pub fn update(&mut self, dim: FramebufferIntSize) {
pub fn update(&mut self, dim: DeviceIntSize) {
if dim != self.window_size {
self.window_size = dim;
}

Просмотреть файл

@ -1269,7 +1269,6 @@ nsresult imgLoader::InitCache() {
}
os->AddObserver(this, "memory-pressure", false);
os->AddObserver(this, "chrome-flush-skin-caches", false);
os->AddObserver(this, "chrome-flush-caches", false);
os->AddObserver(this, "last-pb-context-exited", false);
os->AddObserver(this, "profile-before-change", false);
@ -1307,8 +1306,7 @@ imgLoader::Observe(nsISupports* aSubject, const char* aTopic,
} else if (strcmp(aTopic, "memory-pressure") == 0) {
MinimizeCaches();
} else if (strcmp(aTopic, "chrome-flush-skin-caches") == 0 ||
strcmp(aTopic, "chrome-flush-caches") == 0) {
} else if (strcmp(aTopic, "chrome-flush-caches") == 0) {
MinimizeCaches();
ClearChromeImageCache();
} else if (strcmp(aTopic, "last-pb-context-exited") == 0) {

Просмотреть файл

@ -417,7 +417,7 @@ bool BytecodeCompiler::canLazilyParse() const {
return options.canLazilyParse &&
!cx->realm()->behaviors().disableLazyParsing() &&
!cx->realm()->behaviors().discardSource() && !options.sourceIsLazy &&
!cx->lcovEnabled() &&
!coverage::IsLCovEnabled() &&
// Disabled during record/replay. The replay debugger requires
// scripts to be constructed in a consistent order, which might not
// happen with lazy parsing.

Просмотреть файл

@ -8175,7 +8175,7 @@ void GCRuntime::mergeRealms(Realm* source, Realm* target) {
atomMarking.adoptMarkedAtoms(target->zone(), source->zone());
// Merge script name maps in the target realm's map.
if (rt->lcovOutput().isEnabled() && source->scriptNameMap) {
if (coverage::IsLCovEnabled() && source->scriptNameMap) {
AutoEnterOOMUnsafeRegion oomUnsafe;
if (!target->scriptNameMap) {

Просмотреть файл

@ -50,6 +50,11 @@ var funAdd6 = (a, b) => { return a + b; }
warmup(funAdd6, [["x", 10, "x10"], [10, "bba", "10bba"], ["x", 1.2, "x1.2"],
[1.2, "bba", "1.2bba"]]);
// Add: String Boolean
var funAddStrBool = (a, b) => { return a + b; }
warmup(funAddStrBool, [[true, "true", "truetrue"], [false, "true", "falsetrue"],
["a string", true, "a stringtrue"]]);
// Sub Int32
var funSub1 = (a, b) => { return a - b; }
warmup(funSub1, [[7, 0, 7], [7, 8, -1], [4294967295, 2, 4294967293], [0,0,0]]);

Просмотреть файл

@ -284,6 +284,7 @@ static MIRType ParseCacheIRStub(ICStub* stub) {
case CacheOp::CallStringConcatResult:
case CacheOp::CallStringObjectConcatResult:
case CacheOp::CallInt32ToString:
case CacheOp::BooleanToString:
case CacheOp::CallNumberToString:
return MIRType::String;
case CacheOp::DoubleAddResult:

Просмотреть файл

@ -6403,6 +6403,11 @@ bool BinaryArithIRGenerator::tryAttachStub() {
return true;
}
// String + Boolean
if (tryAttachStringBooleanConcat()) {
return true;
}
trackAttached(IRGenerator::NotAttached);
return false;
}
@ -6621,6 +6626,39 @@ bool BinaryArithIRGenerator::tryAttachStringNumberConcat() {
return true;
}
bool BinaryArithIRGenerator::tryAttachStringBooleanConcat() {
// Only Addition
if (op_ != JSOP_ADD) {
return false;
}
if ((!lhs_.isString() || !rhs_.isBoolean()) &&
(!lhs_.isBoolean() || !rhs_.isString())) {
return false;
}
ValOperandId lhsId(writer.setInputOperandId(0));
ValOperandId rhsId(writer.setInputOperandId(1));
auto guardToString = [&](ValOperandId id, HandleValue v) {
if (v.isString()) {
return writer.guardIsString(id);
}
MOZ_ASSERT(v.isBoolean());
Int32OperandId intId = writer.guardIsBoolean(id);
return writer.booleanToString(intId);
};
StringOperandId lhsStrId = guardToString(lhsId, lhs_);
StringOperandId rhsStrId = guardToString(rhsId, rhs_);
writer.callStringConcatResult(lhsStrId, rhsStrId);
writer.returnFromIC();
trackAttached("BinaryArith.StringBooleanConcat");
return true;
}
bool BinaryArithIRGenerator::tryAttachStringConcat() {
// Only Addition
if (op_ != JSOP_ADD) {

Просмотреть файл

@ -294,6 +294,7 @@ extern const uint32_t ArgLengths[];
_(CallAddOrUpdateSparseElementHelper, Id, Id, Id, Byte) \
_(CallInt32ToString, Id, Id) \
_(CallNumberToString, Id, Id) \
_(BooleanToString, Id, Id) \
_(CallScriptedFunction, Id, Id, Byte) \
_(CallNativeFunction, Id, Id, Byte, IF_SIMULATOR(Field, Byte)) \
_(CallClassHook, Id, Id, Byte, Field) \
@ -1297,6 +1298,12 @@ class MOZ_RAII CacheIRWriter : public JS::CustomAutoRooter {
writeOperandId(res);
return res;
}
StringOperandId booleanToString(Int32OperandId id) {
StringOperandId res(nextOperandId_++);
writeOpWithOperandId(CacheOp::BooleanToString, id);
writeOperandId(res);
return res;
}
void callScriptedFunction(ObjOperandId calleeId, Int32OperandId argc,
CallFlags flags) {
writeOpWithOperandId(CacheOp::CallScriptedFunction, calleeId);
@ -2440,6 +2447,7 @@ class MOZ_RAII BinaryArithIRGenerator : public IRGenerator {
bool tryAttachStringConcat();
bool tryAttachStringObjectConcat();
bool tryAttachStringNumberConcat();
bool tryAttachStringBooleanConcat();
public:
BinaryArithIRGenerator(JSContext* cx, HandleScript, jsbytecode* pc,

Просмотреть файл

@ -4284,6 +4284,27 @@ bool CacheIRCompiler::emitCallNumberToString() {
return true;
}
bool CacheIRCompiler::emitBooleanToString() {
JitSpew(JitSpew_Codegen, __FUNCTION__);
Register boolean = allocator.useRegister(masm, reader.int32OperandId());
Register result = allocator.defineRegister(masm, reader.stringOperandId());
const JSAtomState& names = cx_->names();
Label true_, done;
masm.branchTest32(Assembler::NonZero, boolean, boolean, &true_);
// False case
masm.movePtr(ImmGCPtr(names.false_), result);
masm.jump(&done);
// True case
masm.bind(&true_);
masm.movePtr(ImmGCPtr(names.true_), result);
masm.bind(&done);
return true;
}
void js::jit::LoadTypedThingData(MacroAssembler& masm, TypedThingLayout layout,
Register obj, Register result) {
switch (layout) {

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше