зеркало из https://github.com/mozilla/gecko-dev.git
Merge autoland to mozilla-central. a=merge
This commit is contained in:
Коммит
f3a72771ea
|
@ -15,7 +15,7 @@ module.exports = {
|
|||
"no-sequences": "error",
|
||||
"no-shadow": "error",
|
||||
"no-throw-literal": "error",
|
||||
"no-unused-vars": ["error", { "args": "after-used", "varsIgnorePattern": "^EXPORTED_SYMBOLS$", "vars": "all" }],
|
||||
"no-unused-vars": ["error", { "args": "after-used", "vars": "all" }],
|
||||
"padded-blocks": ["error", "never"],
|
||||
"semi-spacing": ["error", {"before": false, "after": true}],
|
||||
"space-in-parens": ["error", "never"],
|
||||
|
|
|
@ -1072,7 +1072,7 @@ var gEditItemOverlay = {
|
|||
|
||||
switch (aProperty) {
|
||||
case "uri":
|
||||
let newURI = Services.ui.newURI(aValue);
|
||||
let newURI = Services.io.newURI(aValue);
|
||||
if (!newURI.equals(this._paneInfo.uri)) {
|
||||
this._paneInfo.uri = newURI;
|
||||
if (this._paneInfo.visibleRows.has("locationRow"))
|
||||
|
|
|
@ -63,10 +63,12 @@ add_task(async function test_change_location_from_Toolbar() {
|
|||
// Update the "location" field.
|
||||
fillBookmarkTextField("editBMPanel_locationField", TEST_URL2, dialogWin, false);
|
||||
await waitForCondition(() => locationPicker.value === TEST_URL2, "The location is correct after update.");
|
||||
|
||||
locationPicker.blur();
|
||||
await promiseLocationChange;
|
||||
Assert.equal(dialogWin.gEditItemOverlay.uri.spec, TEST_URL2, "The location is the expected one.");
|
||||
locationPicker.focus();
|
||||
// Confirm and close the dialog.
|
||||
EventUtils.synthesizeKey("VK_RETURN", {}, dialogWin);
|
||||
await promiseLocationChange;
|
||||
|
||||
let updatedBm = await PlacesUtils.bookmarks.fetch(toolbarBookmark.guid);
|
||||
Assert.equal(updatedBm.url, TEST_URL2, "Should have updated the bookmark location in the database.");
|
||||
|
|
|
@ -66,7 +66,7 @@ var gSearchPane = {
|
|||
urlbarSuggestsPref.on("change", updateSuggestionCheckboxes);
|
||||
let urlbarSuggests = document.getElementById("urlBarSuggestion");
|
||||
urlbarSuggests.addEventListener("command", () => {
|
||||
urlbarSuggestsPref.value = !urlbarSuggests.checked;
|
||||
urlbarSuggestsPref.value = urlbarSuggests.checked;
|
||||
});
|
||||
|
||||
this._initShowSearchSuggestionsFirst();
|
||||
|
|
|
@ -41,7 +41,7 @@ add_task(async function() {
|
|||
Assert.deepEqual(msg, {
|
||||
value: null,
|
||||
attrs: [
|
||||
["label", elem.getAttribute("label")]
|
||||
{name: "label", value: elem.getAttribute("label")}
|
||||
]
|
||||
});
|
||||
|
||||
|
|
|
@ -19,13 +19,13 @@ add_task(async function() {
|
|||
is(urlbarBox.checked, INITIAL_URLBAR_SUGGEST_VALUE,
|
||||
"Checkbox should match initial pref value: " + INITIAL_URLBAR_SUGGEST_VALUE);
|
||||
|
||||
urlbarBox.doCommand();
|
||||
await BrowserTestUtils.synthesizeMouseAtCenter("#urlBarSuggestion", {}, gBrowser.selectedBrowser);
|
||||
is(urlbarBox.checked, !INITIAL_URLBAR_SUGGEST_VALUE,
|
||||
"Checkbox should be flipped after clicking it");
|
||||
let prefValue = Services.prefs.getBoolPref(URLBAR_SUGGEST_PREF_NAME);
|
||||
is(prefValue, urlbarBox.checked, "Pref should match checkbox. Pref: " + prefValue);
|
||||
|
||||
urlbarBox.doCommand();
|
||||
await BrowserTestUtils.synthesizeMouseAtCenter("#urlBarSuggestion", {}, gBrowser.selectedBrowser);
|
||||
is(urlbarBox.checked, INITIAL_URLBAR_SUGGEST_VALUE,
|
||||
"Checkbox should be back to initial value after clicking it");
|
||||
prefValue = Services.prefs.getBoolPref(URLBAR_SUGGEST_PREF_NAME);
|
||||
|
|
|
@ -4,8 +4,7 @@ module.exports = {
|
|||
"rules": {
|
||||
"no-unused-vars": ["error", {
|
||||
"args": "none",
|
||||
"vars": "all",
|
||||
"varsIgnorePattern": "^EXPORTED_SYMBOLS$",
|
||||
"vars": "all"
|
||||
}]
|
||||
}
|
||||
};
|
||||
|
|
|
@ -8,7 +8,6 @@ module.exports = {
|
|||
"rules": {
|
||||
"no-unused-vars": ["error", {
|
||||
"vars": "all",
|
||||
"varsIgnorePattern": "^(Cc|Ci|Cr|Cu|EXPORTED_SYMBOLS)$",
|
||||
"args": "none"
|
||||
}]
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ module.exports = {
|
|||
|
||||
// No declaring variables that are never used
|
||||
"no-unused-vars": ["error", {
|
||||
"args": "none", "vars": "all", "varsIgnorePattern": "^EXPORTED_SYMBOLS$"
|
||||
"args": "none", "vars": "all"
|
||||
}],
|
||||
|
||||
// No using variables before defined
|
||||
|
|
|
@ -8,8 +8,7 @@ module.exports = {
|
|||
"rules": {
|
||||
"no-unused-vars": ["error", {
|
||||
"args": "none",
|
||||
"vars": "all",
|
||||
"varsIgnorePattern": "^EXPORTED_SYMBOLS$",
|
||||
"vars": "all"
|
||||
}]
|
||||
}
|
||||
};
|
||||
|
|
|
@ -9,6 +9,8 @@ const Services = require("Services");
|
|||
const SwatchColorPickerTooltip = require("devtools/client/shared/widgets/tooltip/SwatchColorPickerTooltip");
|
||||
const { throttle } = require("devtools/client/inspector/shared/utils");
|
||||
const { compareFragmentsGeometry } = require("devtools/client/inspector/grids/utils/utils");
|
||||
const asyncStorage = require("devtools/shared/async-storage");
|
||||
const { parseURL } = require("devtools/client/shared/source-utils");
|
||||
|
||||
const {
|
||||
updateGridColor,
|
||||
|
@ -148,16 +150,20 @@ class GridInspector {
|
|||
*
|
||||
* @param {NodeFront} nodeFront
|
||||
* The NodeFront for which we need the color.
|
||||
* @param {String} customColor
|
||||
* The color fetched from the custom palette, if it exists.
|
||||
* @param {String} fallbackColor
|
||||
* The color to use if no color could be found for the node front.
|
||||
* @return {String} color
|
||||
* The color to use.
|
||||
*/
|
||||
getInitialGridColor(nodeFront, fallbackColor) {
|
||||
getInitialGridColor(nodeFront, customColor, fallbackColor) {
|
||||
let highlighted = nodeFront == this.highlighters.gridHighlighterShown;
|
||||
|
||||
let color;
|
||||
if (highlighted && this.highlighters.state.grid.options) {
|
||||
if (customColor) {
|
||||
color = customColor;
|
||||
} else if (highlighted && this.highlighters.state.grid.options) {
|
||||
// If the node front is currently highlighted, use the color from the highlighter
|
||||
// options.
|
||||
color = this.highlighters.state.grid.options.color;
|
||||
|
@ -288,6 +294,11 @@ class GridInspector {
|
|||
if (!this.inspector || !this.store) {
|
||||
return;
|
||||
}
|
||||
let currentUrl = this.inspector.target.url;
|
||||
// Get the hostname, if there is no hostname, fall back on protocol
|
||||
// ex: `data:` uri, and `about:` pages
|
||||
let hostname = parseURL(currentUrl).hostname || parseURL(currentUrl).protocol;
|
||||
let customColors = await asyncStorage.getItem("gridInspectorHostColors") || {};
|
||||
|
||||
// Get all the GridFront from the server if no gridFronts were provided.
|
||||
let gridFronts;
|
||||
|
@ -301,9 +312,9 @@ class GridInspector {
|
|||
|
||||
// Log how many CSS Grid elements DevTools sees.
|
||||
if (gridFronts.length > 0 &&
|
||||
this.inspector.target.url != this.inspector.previousURL) {
|
||||
currentUrl != this.inspector.previousURL) {
|
||||
this.telemetry.log(CSS_GRID_COUNT_HISTOGRAM_ID, gridFronts.length);
|
||||
this.inspector.previousURL = this.inspector.target.url;
|
||||
this.inspector.previousURL = currentUrl;
|
||||
}
|
||||
|
||||
let grids = [];
|
||||
|
@ -325,8 +336,9 @@ class GridInspector {
|
|||
}
|
||||
}
|
||||
|
||||
let colorForHost = customColors[hostname] ? customColors[hostname][i] : undefined;
|
||||
let fallbackColor = GRID_COLORS[i % GRID_COLORS.length];
|
||||
let color = this.getInitialGridColor(nodeFront, fallbackColor);
|
||||
let color = this.getInitialGridColor(nodeFront, colorForHost, fallbackColor);
|
||||
|
||||
grids.push({
|
||||
id: i,
|
||||
|
@ -341,6 +353,7 @@ class GridInspector {
|
|||
}
|
||||
|
||||
this.store.dispatch(updateGrids(grids));
|
||||
this.inspector.emit("grid-panel-updated");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -455,16 +468,30 @@ class GridInspector {
|
|||
* @param {String} color
|
||||
* A hex string representing the color to use.
|
||||
*/
|
||||
onSetGridOverlayColor(node, color) {
|
||||
async onSetGridOverlayColor(node, color) {
|
||||
this.store.dispatch(updateGridColor(node, color));
|
||||
let { grids } = this.store.getState();
|
||||
let currentUrl = this.inspector.target.url;
|
||||
// Get the hostname, if there is no hostname, fall back on protocol
|
||||
// ex: `data:` uri, and `about:` pages
|
||||
let hostname = parseURL(currentUrl).hostname || parseURL(currentUrl).protocol;
|
||||
let customGridColors = await asyncStorage.getItem("gridInspectorHostColors") || {};
|
||||
|
||||
// If the grid for which the color was updated currently has a highlighter, update
|
||||
// the color.
|
||||
for (let grid of grids) {
|
||||
if (grid.nodeFront === node && grid.highlighted) {
|
||||
let highlighterSettings = this.getGridHighlighterSettings(node);
|
||||
this.showGridHighlighter(node, highlighterSettings);
|
||||
if (grid.nodeFront === node) {
|
||||
if (!customGridColors[hostname]) {
|
||||
customGridColors[hostname] = [];
|
||||
}
|
||||
// Update the custom color for the grid in this position.
|
||||
customGridColors[hostname][grid.id] = color;
|
||||
await asyncStorage.setItem("gridInspectorHostColors", customGridColors);
|
||||
|
||||
// If the grid for which the color was updated currently has a highlighter, update
|
||||
// the color.
|
||||
if (grid.highlighted) {
|
||||
let highlighterSettings = this.getGridHighlighterSettings(node);
|
||||
this.showGridHighlighter(node, highlighterSettings);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,4 +34,5 @@ support-files =
|
|||
[browser_grids_grid-outline-writing-mode.js]
|
||||
[browser_grids_highlighter-setting-rules-grid-toggle.js]
|
||||
[browser_grids_number-of-css-grids-telemetry.js]
|
||||
[browser_grids_persist-color-palette.js]
|
||||
[browser_grids_restored-after-reload.js]
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
// Tests that the when a custom color has been previously set, we initialize
|
||||
// the grid with that color.
|
||||
|
||||
const TEST_URI = `
|
||||
<style type='text/css'>
|
||||
#grid {
|
||||
display: grid;
|
||||
}
|
||||
</style>
|
||||
<div id="grid">
|
||||
<div class="cell1">cell1</div>
|
||||
<div class="cell2">cell2</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
add_task(async function () {
|
||||
await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
|
||||
let { inspector, gridInspector, toolbox } = await openLayoutView();
|
||||
let { document: doc } = gridInspector;
|
||||
let { store } = inspector;
|
||||
let cPicker = gridInspector.getSwatchColorPickerTooltip();
|
||||
let swatch = doc.querySelector(".grid-color-swatch");
|
||||
|
||||
info("Scrolling into view of the #grid color swatch.");
|
||||
swatch.scrollIntoView();
|
||||
|
||||
info("Opening the color picker by clicking on the #grid color swatch.");
|
||||
let onColorPickerReady = cPicker.once("ready");
|
||||
swatch.click();
|
||||
await onColorPickerReady;
|
||||
|
||||
await simulateColorPickerChange(cPicker, [51, 48, 0, 1]);
|
||||
|
||||
info("Closing the toolbox.");
|
||||
await toolbox.destroy();
|
||||
info("Open the toolbox again.");
|
||||
await openLayoutView();
|
||||
|
||||
info("Check that the previously set custom color is used.");
|
||||
is(swatch.style.backgroundColor, "rgb(51, 48, 0)",
|
||||
"The color swatch's background is correct.");
|
||||
is(store.getState().grids[0].color, "#333000", "The grid color state is correct.");
|
||||
});
|
|
@ -21,6 +21,7 @@ registerCleanupFunction(() => {
|
|||
Services.prefs.clearUserPref("devtools.toolbox.footer.height");
|
||||
});
|
||||
|
||||
const asyncStorage = require("devtools/shared/async-storage");
|
||||
const HIGHLIGHTER_TYPE = "CssGridHighlighter";
|
||||
|
||||
/**
|
||||
|
@ -40,3 +41,7 @@ var simulateColorPickerChange = Task.async(function* (colorPicker, newRgba) {
|
|||
spectrum.updateUI();
|
||||
spectrum.onChange();
|
||||
});
|
||||
|
||||
registerCleanupFunction(async function () {
|
||||
await asyncStorage.removeItem("gridInspectorHostColors");
|
||||
});
|
||||
|
|
|
@ -54,8 +54,12 @@ var openInspectorSidebarTab = Task.async(function* (id) {
|
|||
if (id === "computedview" || id === "layoutview") {
|
||||
// The layout and computed views should wait until the box-model widget is ready.
|
||||
let onBoxModelViewReady = inspector.once("boxmodel-view-updated");
|
||||
// The layout view also needs to wait for the grid panel to be fully updated.
|
||||
let onGridPanelReady = id === "layoutview" ?
|
||||
inspector.once("grid-panel-updated") : Promise.resolve();
|
||||
inspector.sidebar.select(id);
|
||||
yield onBoxModelViewReady;
|
||||
yield onGridPanelReady;
|
||||
} else {
|
||||
inspector.sidebar.select(id);
|
||||
}
|
||||
|
|
|
@ -50,11 +50,9 @@ add_task(function* () {
|
|||
|
||||
checkCell("ls2", "value", "ls2-changed");
|
||||
|
||||
// Clearing items. Bug 1233497 makes it so that we can no longer yield
|
||||
// CPOWs from Tasks. We work around this by calling clear via a ContentTask
|
||||
// instead.
|
||||
yield ContentTask.spawn(gBrowser.selectedBrowser, null, function* () {
|
||||
return Task.spawn(content.wrappedJSObject.clear);
|
||||
// Clearing items.
|
||||
yield ContentTask.spawn(gBrowser.selectedBrowser, null, function () {
|
||||
content.wrappedJSObject.clear();
|
||||
});
|
||||
|
||||
yield gUI.once("store-objects-cleared");
|
||||
|
|
|
@ -64,11 +64,9 @@ add_task(function* () {
|
|||
|
||||
yield findVariableViewProperties([{name: "ss2", value: "changed=ss2"}]);
|
||||
|
||||
// Clearing items. Bug 1233497 makes it so that we can no longer yield
|
||||
// CPOWs from Tasks. We work around this by calling clear via a ContentTask
|
||||
// instead.
|
||||
yield ContentTask.spawn(gBrowser.selectedBrowser, null, function* () {
|
||||
return Task.spawn(content.wrappedJSObject.clear);
|
||||
// Clearing items.
|
||||
yield ContentTask.spawn(gBrowser.selectedBrowser, null, function () {
|
||||
content.wrappedJSObject.clear();
|
||||
});
|
||||
|
||||
yield gUI.once("store-objects-cleared");
|
||||
|
|
|
@ -37,7 +37,7 @@ window.removeCookie = function(name, path) {
|
|||
* after the test is complete. this is so that the store-objects-cleared event
|
||||
* can be tested.
|
||||
*/
|
||||
window.clear = function*() {
|
||||
window.clear = function() {
|
||||
localStorage.clear();
|
||||
dump("removed localStorage from " + document.location + "\n");
|
||||
|
||||
|
|
|
@ -241,7 +241,7 @@ StyleEditorUI.prototype = {
|
|||
yield this._addStyleSheet(sheet);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
this.emit("error", { key: LOAD_ERROR });
|
||||
this.emit("error", { key: LOAD_ERROR, level: "warning" });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -407,7 +407,7 @@ StyleEditorUI.prototype = {
|
|||
contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER
|
||||
}, (stream, status) => {
|
||||
if (!Components.isSuccessCode(status)) {
|
||||
this.emit("error", { key: LOAD_ERROR });
|
||||
this.emit("error", { key: LOAD_ERROR, level: "warning" });
|
||||
return;
|
||||
}
|
||||
let source =
|
||||
|
|
|
@ -293,7 +293,8 @@ StyleSheetEditor.prototype = {
|
|||
console.error(e);
|
||||
} else {
|
||||
console.error(e);
|
||||
this.emit("error", { key: LOAD_ERROR, append: this.styleSheet.href });
|
||||
this.emit("error", { key: LOAD_ERROR, append: this.styleSheet.href,
|
||||
level: "warning" });
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -87,9 +87,13 @@ StyleEditorPanel.prototype = {
|
|||
let notificationBox = this._toolbox.getNotificationBox();
|
||||
let notification =
|
||||
notificationBox.getNotificationWithValue("styleeditor-error");
|
||||
let level = (data.level === "info") ?
|
||||
notificationBox.PRIORITY_INFO_LOW :
|
||||
notificationBox.PRIORITY_CRITICAL_LOW;
|
||||
|
||||
let level = notificationBox.PRIORITY_CRITICAL_LOW;
|
||||
if (data.level === "info") {
|
||||
level = notificationBox.PRIORITY_INFO_LOW;
|
||||
} else if (data.level === "warning") {
|
||||
level = notificationBox.PRIORITY_WARNING_LOW;
|
||||
}
|
||||
|
||||
if (!notification) {
|
||||
notificationBox.appendNotification(errorMessage, "styleeditor-error",
|
||||
|
|
|
@ -167,7 +167,6 @@ support-files =
|
|||
|
||||
[browser_console.js]
|
||||
[browser_console_addonsdk_loader_exception.js]
|
||||
skip-if = true # Bug 1437807
|
||||
[browser_console_clear_method.js]
|
||||
skip-if = true # Bug 1437843
|
||||
[browser_console_consolejsm_output.js]
|
||||
|
|
|
@ -7,88 +7,58 @@
|
|||
|
||||
// Check that exceptions from scripts loaded with the addon-sdk loader are
|
||||
// opened correctly in View Source from the Browser Console.
|
||||
// See bug 866950.
|
||||
|
||||
"use strict";
|
||||
|
||||
const TEST_URI = "data:text/html;charset=utf8,<p>hello world from bug 866950";
|
||||
const TEST_URI =
|
||||
"data:text/html;charset=utf8,<p>browser_console_addonsdk_loader_exception.js</p>";
|
||||
|
||||
function test() {
|
||||
requestLongerTimeout(2);
|
||||
add_task(async function () {
|
||||
let wcHud = await openNewTabAndConsole(TEST_URI);
|
||||
ok(wcHud, "web console opened");
|
||||
|
||||
let webconsole, browserconsole;
|
||||
let bcHud = await HUDService.toggleBrowserConsole();
|
||||
ok(bcHud, "browser console opened");
|
||||
|
||||
Task.spawn(runner).then(finishTest);
|
||||
// Cause an exception in a script loaded with the addon-sdk loader.
|
||||
let toolbox = gDevTools.getToolbox(wcHud.target);
|
||||
let oldPanels = toolbox._toolPanels;
|
||||
// non-iterable
|
||||
toolbox._toolPanels = {};
|
||||
|
||||
function* runner() {
|
||||
let {tab} = yield loadTab(TEST_URI);
|
||||
webconsole = yield openConsole(tab);
|
||||
ok(webconsole, "web console opened");
|
||||
|
||||
browserconsole = yield HUDService.toggleBrowserConsole();
|
||||
ok(browserconsole, "browser console opened");
|
||||
|
||||
// Cause an exception in a script loaded with the addon-sdk loader.
|
||||
let toolbox = gDevTools.getToolbox(webconsole.target);
|
||||
let oldPanels = toolbox._toolPanels;
|
||||
// non-iterable
|
||||
toolbox._toolPanels = {};
|
||||
|
||||
function fixToolbox() {
|
||||
toolbox._toolPanels = oldPanels;
|
||||
}
|
||||
|
||||
info("generate exception and wait for message");
|
||||
|
||||
executeSoon(() => {
|
||||
executeSoon(fixToolbox);
|
||||
expectUncaughtException();
|
||||
toolbox.getToolPanels();
|
||||
});
|
||||
|
||||
let [result] = yield waitForMessages({
|
||||
webconsole: browserconsole,
|
||||
messages: [{
|
||||
text: "TypeError: this._toolPanels is not iterable",
|
||||
category: CATEGORY_JS,
|
||||
severity: SEVERITY_ERROR,
|
||||
}],
|
||||
});
|
||||
|
||||
fixToolbox();
|
||||
|
||||
let msg = [...result.matched][0];
|
||||
ok(msg, "message element found");
|
||||
let locationNode = msg
|
||||
.querySelector(".message .message-location > .frame-link");
|
||||
ok(locationNode, "message location element found");
|
||||
|
||||
let url = locationNode.getAttribute("data-url");
|
||||
info("location node url: " + url);
|
||||
ok(url.indexOf("resource://") === 0, "error comes from a subscript");
|
||||
|
||||
let viewSource = browserconsole.viewSource;
|
||||
let URL = null;
|
||||
let clickPromise = defer();
|
||||
browserconsole.viewSourceInDebugger = (sourceURL) => {
|
||||
info("browserconsole.viewSourceInDebugger() was invoked: " + sourceURL);
|
||||
URL = sourceURL;
|
||||
clickPromise.resolve(null);
|
||||
};
|
||||
|
||||
msg.scrollIntoView();
|
||||
EventUtils.synthesizeMouse(locationNode, 2, 2, {},
|
||||
browserconsole.iframeWindow);
|
||||
|
||||
info("wait for click on locationNode");
|
||||
yield clickPromise.promise;
|
||||
|
||||
info("view-source url: " + URL);
|
||||
ok(URL, "we have some source URL after the click");
|
||||
isnot(URL.indexOf("toolbox.js"), -1,
|
||||
"we have the expected view source URL");
|
||||
is(URL.indexOf("->"), -1, "no -> in the URL given to view-source");
|
||||
|
||||
browserconsole.viewSourceInDebugger = viewSource;
|
||||
function fixToolbox() {
|
||||
toolbox._toolPanels = oldPanels;
|
||||
}
|
||||
}
|
||||
|
||||
info("generate exception and wait for message");
|
||||
|
||||
executeSoon(() => {
|
||||
expectUncaughtException();
|
||||
executeSoon(fixToolbox);
|
||||
toolbox.getToolPanels();
|
||||
});
|
||||
|
||||
let msg = await waitFor(() => findMessage(bcHud,
|
||||
"TypeError: this._toolPanels is not iterable"));
|
||||
|
||||
fixToolbox();
|
||||
|
||||
ok(msg, `Message found: "TypeError: this._toolPanels is not iterable"`);
|
||||
|
||||
let locationNode = msg.querySelector(".message-location .frame-link-source");
|
||||
ok(locationNode, "Message location link element found");
|
||||
|
||||
let url = locationNode.href;
|
||||
info("view-source url: " + url);
|
||||
ok(url, "we have some source URL after the click");
|
||||
ok(url.includes("toolbox.js"), "we have the expected view source URL");
|
||||
ok(!url.includes("->"), "no -> in the URL given to view-source");
|
||||
|
||||
let onTabOpen = BrowserTestUtils.waitForNewTab(gBrowser, null, true);
|
||||
locationNode.click();
|
||||
|
||||
let newTab = await onTabOpen;
|
||||
ok(true, "The view source tab was opened in response to clicking the link");
|
||||
|
||||
await BrowserTestUtils.removeTab(newTab);
|
||||
});
|
||||
|
|
|
@ -106,7 +106,7 @@
|
|||
#include "HTMLImageElement.h"
|
||||
#include "HTMLCanvasElement.h"
|
||||
#include "mozilla/css/ImageLoader.h"
|
||||
#include "mozilla/layers/APZCTreeManager.h" // for layers::ZoomToRectBehavior
|
||||
#include "mozilla/layers/IAPZCTreeManager.h" // for layers::ZoomToRectBehavior
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "mozilla/StyleSheetInlines.h"
|
||||
#include "mozilla/gfx/GPUProcessManager.h"
|
||||
|
|
|
@ -300,6 +300,9 @@ GK_ATOM(cutoutregion, "cutoutregion")
|
|||
GK_ATOM(cycler, "cycler")
|
||||
GK_ATOM(data, "data")
|
||||
GK_ATOM(datalist, "datalist")
|
||||
GK_ATOM(datal10nid, "data-l10n-id")
|
||||
GK_ATOM(datal10nargs, "data-l10n-args")
|
||||
GK_ATOM(datal10nattrs, "data-l10n-attrs")
|
||||
GK_ATOM(dataType, "data-type")
|
||||
GK_ATOM(dateTime, "date-time")
|
||||
GK_ATOM(datasources, "datasources")
|
||||
|
|
|
@ -30,6 +30,9 @@
|
|||
#endif
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/Event.h"
|
||||
#include "mozilla/dom/L10nUtilsBinding.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "mozilla/dom/PromiseNativeHandler.h"
|
||||
#include "mozilla/dom/ShadowRoot.h"
|
||||
#include "nsAttrValueOrString.h"
|
||||
#include "nsBindingManager.h"
|
||||
|
@ -3067,3 +3070,217 @@ nsINode::GetDocGroup() const
|
|||
{
|
||||
return OwnerDoc()->GetDocGroup();
|
||||
}
|
||||
|
||||
class LocalizationHandler : public PromiseNativeHandler
|
||||
{
|
||||
public:
|
||||
LocalizationHandler() = default;
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS(LocalizationHandler)
|
||||
|
||||
nsTArray<nsCOMPtr<Element>>& Elements() { return mElements; }
|
||||
|
||||
void SetReturnValuePromise(Promise* aReturnValuePromise)
|
||||
{
|
||||
mReturnValuePromise = aReturnValuePromise;
|
||||
}
|
||||
|
||||
virtual void
|
||||
ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override
|
||||
{
|
||||
nsTArray<L10nValue> l10nData;
|
||||
if (aValue.isObject()) {
|
||||
JS::ForOfIterator iter(aCx);
|
||||
if (!iter.init(aValue, JS::ForOfIterator::AllowNonIterable)) {
|
||||
mReturnValuePromise->MaybeRejectWithUndefined();
|
||||
return;
|
||||
}
|
||||
if (!iter.valueIsIterable()) {
|
||||
mReturnValuePromise->MaybeRejectWithUndefined();
|
||||
return;
|
||||
}
|
||||
|
||||
JS::Rooted<JS::Value> temp(aCx);
|
||||
while (true) {
|
||||
bool done;
|
||||
if (!iter.next(&temp, &done)) {
|
||||
mReturnValuePromise->MaybeRejectWithUndefined();
|
||||
return;
|
||||
}
|
||||
|
||||
if (done) {
|
||||
break;
|
||||
}
|
||||
|
||||
L10nValue* slotPtr =
|
||||
l10nData.AppendElement(mozilla::fallible);
|
||||
if (!slotPtr) {
|
||||
mReturnValuePromise->MaybeRejectWithUndefined();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!slotPtr->Init(aCx, temp)) {
|
||||
mReturnValuePromise->MaybeRejectWithUndefined();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mElements.Length() != l10nData.Length()) {
|
||||
mReturnValuePromise->MaybeRejectWithUndefined();
|
||||
return;
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> untranslatedElements(aCx,
|
||||
JS_NewArrayObject(aCx, mElements.Length()));
|
||||
if (!untranslatedElements) {
|
||||
mReturnValuePromise->MaybeRejectWithUndefined();
|
||||
return;
|
||||
}
|
||||
|
||||
ErrorResult rv;
|
||||
for (size_t i = 0; i < l10nData.Length(); ++i) {
|
||||
Element* elem = mElements[i];
|
||||
nsString& content = l10nData[i].mValue;
|
||||
if (!content.IsVoid()) {
|
||||
elem->SetTextContent(content, rv);
|
||||
if (NS_WARN_IF(rv.Failed())) {
|
||||
mReturnValuePromise->MaybeRejectWithUndefined();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Nullable<Sequence<AttributeNameValue>>& attributes =
|
||||
l10nData[i].mAttrs;
|
||||
if (!attributes.IsNull()) {
|
||||
for (size_t j = 0; j < attributes.Value().Length(); ++j) {
|
||||
// Use SetAttribute here to validate the attribute name!
|
||||
elem->SetAttribute(attributes.Value()[j].mName,
|
||||
attributes.Value()[j].mValue,
|
||||
rv);
|
||||
if (rv.Failed()) {
|
||||
mReturnValuePromise->MaybeRejectWithUndefined();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (content.IsVoid() && attributes.IsNull()) {
|
||||
JS::Rooted<JS::Value> wrappedElem(aCx);
|
||||
if (!ToJSValue(aCx, elem, &wrappedElem)) {
|
||||
mReturnValuePromise->MaybeRejectWithUndefined();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!JS_DefineElement(aCx, untranslatedElements, i, wrappedElem, JSPROP_ENUMERATE)) {
|
||||
mReturnValuePromise->MaybeRejectWithUndefined();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
mReturnValuePromise->MaybeResolve(untranslatedElements);
|
||||
}
|
||||
|
||||
virtual void
|
||||
RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override
|
||||
{
|
||||
mReturnValuePromise->MaybeRejectWithUndefined();
|
||||
}
|
||||
|
||||
private:
|
||||
~LocalizationHandler() = default;
|
||||
|
||||
nsTArray<nsCOMPtr<Element>> mElements;
|
||||
RefPtr<Promise> mReturnValuePromise;
|
||||
};
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(LocalizationHandler)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(LocalizationHandler)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(LocalizationHandler)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(LocalizationHandler)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(LocalizationHandler)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mElements)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mReturnValuePromise)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(LocalizationHandler)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mElements)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mReturnValuePromise)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
|
||||
already_AddRefed<Promise>
|
||||
nsINode::Localize(JSContext* aCx,
|
||||
mozilla::dom::L10nCallback& aCallback,
|
||||
mozilla::ErrorResult& aRv)
|
||||
{
|
||||
Sequence<L10nElement> l10nElements;
|
||||
SequenceRooter<L10nElement> rooter(aCx, &l10nElements);
|
||||
RefPtr<LocalizationHandler> nativeHandler = new LocalizationHandler();
|
||||
nsTArray<nsCOMPtr<Element>>& domElements = nativeHandler->Elements();
|
||||
nsIContent* node = IsContent() ? AsContent() : GetFirstChild();
|
||||
nsAutoString l10nId;
|
||||
nsAutoString l10nArgs;
|
||||
nsAutoString l10nAttrs;
|
||||
nsAutoString type;
|
||||
for (; node; node = node->GetNextNode(this)) {
|
||||
if (!node->IsElement()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Element* domElement = node->AsElement();
|
||||
if (!domElement->GetAttr(kNameSpaceID_None, nsGkAtoms::datal10nid, l10nId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
domElement->GetAttr(kNameSpaceID_None, nsGkAtoms::datal10nargs, l10nArgs);
|
||||
domElement->GetAttr(kNameSpaceID_None, nsGkAtoms::datal10nattrs, l10nAttrs);
|
||||
L10nElement* element = l10nElements.AppendElement(fallible);
|
||||
if (!element) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return nullptr;
|
||||
}
|
||||
domElements.AppendElement(domElement, fallible);
|
||||
|
||||
domElement->GetNamespaceURI(element->mNamespaceURI);
|
||||
element->mLocalName = domElement->LocalName();
|
||||
domElement->GetAttr(kNameSpaceID_None, nsGkAtoms::type, type);
|
||||
if (!type.IsEmpty()) {
|
||||
element->mType = type;
|
||||
}
|
||||
element->mL10nId = l10nId;
|
||||
if (!l10nAttrs.IsEmpty()) {
|
||||
element->mL10nAttrs = l10nAttrs;
|
||||
}
|
||||
if (!l10nArgs.IsEmpty()) {
|
||||
JS::Rooted<JS::Value> json(aCx);
|
||||
if (!JS_ParseJSON(aCx, l10nArgs.get(), l10nArgs.Length(), &json) ||
|
||||
!json.isObject()) {
|
||||
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
element->mL10nArgs = &json.toObject();
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<Promise> callbackResult = aCallback.Call(l10nElements, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<Promise> promise = Promise::Create(OwnerDoc()->GetParentObject(), aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nativeHandler->SetReturnValuePromise(promise);
|
||||
callbackResult->AppendNativeHandler(nativeHandler);
|
||||
|
||||
return promise.forget();
|
||||
}
|
||||
|
|
|
@ -83,8 +83,10 @@ class DOMQuad;
|
|||
class DOMRectReadOnly;
|
||||
class Element;
|
||||
class EventHandlerNonNull;
|
||||
class L10nCallback;
|
||||
template<typename T> class Optional;
|
||||
class OwningNodeOrString;
|
||||
class Promise;
|
||||
template<typename> class Sequence;
|
||||
class Text;
|
||||
class TextOrElementOrDocument;
|
||||
|
@ -1884,6 +1886,9 @@ public:
|
|||
void GetBoundMutationObservers(nsTArray<RefPtr<nsDOMMutationObserver> >& aResult);
|
||||
void GenerateXPath(nsAString& aResult);
|
||||
|
||||
already_AddRefed<mozilla::dom::Promise>
|
||||
Localize(JSContext* aCx, mozilla::dom::L10nCallback& aCallback, mozilla::ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<mozilla::dom::AccessibleNode> GetAccessibleNode();
|
||||
|
||||
/**
|
||||
|
|
|
@ -68,6 +68,7 @@ support-files = ../file_bug357450.js
|
|||
[test_domparsing.xul]
|
||||
[test_fileconstructor.xul]
|
||||
[test_nsITextInputProcessor.xul]
|
||||
[test_node_localize.xul]
|
||||
[test_permission_isHandlingUserInput.xul]
|
||||
support-files = ../dummy.html
|
||||
[test_range_getClientRectsAndTexts.html]
|
||||
|
|
|
@ -0,0 +1,143 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
||||
type="text/css"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1363862
|
||||
-->
|
||||
<window title="Node.localize - Bug 1363862"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
xmlns:html="http://www.w3.org/1999/xhtml">
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1363862"
|
||||
target="_blank">Mozilla Bug 1363862</a>
|
||||
</body>
|
||||
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript"><![CDATA[
|
||||
|
||||
/** Test for Bug 1363862 **/
|
||||
|
||||
const translations = {
|
||||
"key1": {
|
||||
value: "Value 1",
|
||||
attrs: null,
|
||||
},
|
||||
"key2": {
|
||||
value: null,
|
||||
attrs: [
|
||||
{name: "label", value: "Value 2"},
|
||||
{name: "accesskey", value: "K"},
|
||||
]
|
||||
},
|
||||
"key3": {
|
||||
value: "Value 3",
|
||||
attrs: [
|
||||
{name: "accesskey", value: "V"},
|
||||
]
|
||||
},
|
||||
"key4": undefined,
|
||||
"key5": {
|
||||
value: null,
|
||||
attrs: [
|
||||
{name: "value", value: "Submit Value"},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function serves as an approximation of what Localization does.
|
||||
*/
|
||||
async function mockFormatTranslations(l10nItems) {
|
||||
testL10nItems(l10nItems);
|
||||
return l10nItems.map(l10nItem => {
|
||||
return translations[l10nItem.l10nId];
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function serves as an approximation of what DOMLocalization does.
|
||||
*/
|
||||
async function translateFragment(frag) {
|
||||
const untranslatedElements = await frag.localize(async l10nItems => {
|
||||
const translations = await mockFormatTranslations(l10nItems);
|
||||
return translations;
|
||||
});
|
||||
return untranslatedElements;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test items returned from Node.localize to make sure they match what
|
||||
* we would read using JS DOM.
|
||||
*/
|
||||
function testL10nItems(l10nItems) {
|
||||
for (l10nItem of l10nItems) {
|
||||
const elem = document.querySelector(`[data-l10n-id=${l10nItem.l10nId}]`);
|
||||
SimpleTest.isDeeply(
|
||||
l10nItem.l10nArgs,
|
||||
JSON.parse(elem.getAttribute("data-l10n-args") || null),
|
||||
"l10nArgs should match data-l10n-args"
|
||||
);
|
||||
ok(l10nItem.l10nAttrs === (elem.getAttribute("data-l10n-attrs") || null),
|
||||
"l10nAttrs should match data-l10n-attrs");
|
||||
ok(l10nItem.localName === elem.localName,
|
||||
"l10nItem.localeName should match elem.localName");
|
||||
ok(l10nItem.namespaceURI === elem.namespaceURI,
|
||||
"l10nItem.namespaceURI should match elem.namespaceURI");
|
||||
ok(l10nItem.type === (elem.getAttribute("type") || null),
|
||||
"l10nItem.type should match elem.type");
|
||||
}
|
||||
}
|
||||
|
||||
async function testLocalization() {
|
||||
const container = document.getElementById("testContainer");
|
||||
|
||||
const untranslatedElements = await translateFragment(container);
|
||||
|
||||
// We will walk through all translations and check if they
|
||||
// were correctly populated onto the DOM.
|
||||
for (const [l10nId, translation] of Object.entries(translations)) {
|
||||
const elem = document.querySelector(`[data-l10n-id=${l10nId}]`);
|
||||
|
||||
// If there is no translation then the element should be returned
|
||||
// as part of the `untranslatedElements`.
|
||||
if (translation === undefined) {
|
||||
const i = Object.keys(translations).indexOf(l10nId);
|
||||
ok(untranslatedElements[i] === elem);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (translation.value !== null) {
|
||||
ok(elem.textContent === translation.value,
|
||||
"element's textContent should be populated with the translation value");
|
||||
}
|
||||
|
||||
if (translation.attrs !== null) {
|
||||
for (const {name, value} of translation.attrs) {
|
||||
ok(elem.getAttribute(name) === value,
|
||||
"attribute value should be populated from the translation");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(testLocalization);
|
||||
|
||||
]]></script>
|
||||
<box id="testContainer">
|
||||
<label data-l10n-id="key1" />
|
||||
<label data-l10n-id="key2" data-l10n-args='{"unreadCount": 5}' />
|
||||
<label data-l10n-id="key3" />
|
||||
<label data-l10n-id="key4" />
|
||||
<html:input type="submit" data-l10n-id="key5" />
|
||||
</box>
|
||||
</window>
|
|
@ -624,6 +624,7 @@ DOMInterfaces = {
|
|||
'Node': {
|
||||
'nativeType': 'nsINode',
|
||||
'concrete': False,
|
||||
'implicitJSContext': [ 'localize' ],
|
||||
},
|
||||
|
||||
'NodeIterator': {
|
||||
|
|
|
@ -91,7 +91,6 @@
|
|||
#include "mozilla/LookAndFeel.h"
|
||||
#include "GeckoProfiler.h"
|
||||
#include "Units.h"
|
||||
#include "mozilla/layers/APZCTreeManager.h"
|
||||
#include "nsIObjectLoadingContent.h"
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "mozilla/ipc/URIUtils.h"
|
||||
#include "mozilla/layers/APZChild.h"
|
||||
#include "mozilla/layers/APZCCallbackHelper.h"
|
||||
#include "mozilla/layers/APZCTreeManager.h"
|
||||
#include "mozilla/layers/APZCTreeManagerChild.h"
|
||||
#include "mozilla/layers/APZEventState.h"
|
||||
#include "mozilla/layers/ContentProcessController.h"
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The following dictionaries are for Mozilla use only. They allow startup
|
||||
* localization runtime to work around the performance cost of Stylo having
|
||||
* to resolve XBL bindings in order to localize DOM in JS.
|
||||
*
|
||||
* Instead, we use `Node.localize` method which handles scanning for localizable
|
||||
* elements and applies the result translations without having to create
|
||||
* JS reflections for them.
|
||||
*
|
||||
* For details on the implementation of the API, see `Node.webidl`.
|
||||
*/
|
||||
dictionary L10nElement {
|
||||
required DOMString namespaceURI;
|
||||
required DOMString localName;
|
||||
required DOMString l10nId; // value of data-l10n-id
|
||||
DOMString? type = null;
|
||||
DOMString? l10nAttrs = null; // value of data-l10n-attrs
|
||||
object? l10nArgs = null; // json value of data-l10n-args attribute
|
||||
};
|
||||
|
||||
dictionary AttributeNameValue {
|
||||
required DOMString name;
|
||||
required DOMString value;
|
||||
};
|
||||
|
||||
dictionary L10nValue {
|
||||
DOMString? value = null;
|
||||
sequence<AttributeNameValue>? attrs = null;
|
||||
};
|
||||
|
||||
callback L10nCallback =
|
||||
Promise<sequence<L10nValue>> (sequence<L10nElement> l10nElements);
|
|
@ -112,6 +112,107 @@ interface Node : EventTarget {
|
|||
[ChromeOnly]
|
||||
DOMString generateXPath();
|
||||
|
||||
/**
|
||||
* This method provides a fast-path for the Fluent localization system to
|
||||
* bypass the slowdowns in performance during initial document translation.
|
||||
* The slowdowns are specific to XBL+Stylo.
|
||||
* To learn more, see bug 1441037.
|
||||
*
|
||||
* The API is designed to fit into the DOMLocalization flow with minimal
|
||||
* overhead, which dictates much of its signature.
|
||||
* It takes the following steps:
|
||||
*
|
||||
* 1) The API can be called at any point on any DOM element and it
|
||||
* synchronously scans the element subtree for all children with
|
||||
* `data-l10n-id` attribute set.
|
||||
*
|
||||
* 2) Next, the API collects all of the l10n attributes
|
||||
* (l10n-id, l10n-args and l10n-attrs), and passes them to the
|
||||
* callback function together with three `Element` properties:
|
||||
* `name` - name of the element as lowercase
|
||||
* `namespaceURI` - namespace URI
|
||||
* `type` - the type prop of the element (used for input sanitization)
|
||||
*
|
||||
* 3) The callback function is responsible for (asynchronously) collecting
|
||||
* the translations for all l10n id+args pairs, sanitizing them and then
|
||||
* return them back to this API.
|
||||
*
|
||||
* 4) The API takes the list of elements collected in step (1) and their
|
||||
* translations and applies all of the translation values onto
|
||||
* the elements.
|
||||
*
|
||||
* 5) The API returns a list with empty slots for all translated elements
|
||||
* and references to elements that could not be translated.
|
||||
*
|
||||
* 6) The JS handles the translations of remaining elements.
|
||||
*
|
||||
*
|
||||
* Through the whole cycle, the API uses the same list of elements and
|
||||
* corresponding translations. It means that after step (1), the element
|
||||
* at index 1 will match the l10nData at index 1, translations at index 1
|
||||
* and in the final return list, the element will be also stored at index 1
|
||||
* or the slot will be empty if the translations was applied on the C++ side.
|
||||
*
|
||||
* Note: There are several reasons why the JS callback may pass undefined for
|
||||
* a given element including missing translation, or the need to
|
||||
* translate the element using DOM Overlays.
|
||||
*
|
||||
*
|
||||
* Example of use from JS:
|
||||
*
|
||||
* async function translateFragment(frag) {
|
||||
* let untranslatedElements = await frag.localize(
|
||||
* async cb(l10nItems) => { // 1
|
||||
* let trans = await getTranslations(l10nItems); // 2
|
||||
* return trans;
|
||||
* }
|
||||
* );
|
||||
*
|
||||
* annotateMissingTranslations(untranslatedElements); // 3
|
||||
* }
|
||||
*
|
||||
* [1] l10nItems == [
|
||||
* {
|
||||
* l10nId: "key1",
|
||||
* l10nArgs: null,
|
||||
* l10nAttrs: null,
|
||||
* name: "button"
|
||||
* namespaceURI: "..."
|
||||
* type: null
|
||||
* },
|
||||
* {
|
||||
* l10nId: "key2",
|
||||
* l10nArgs: {unreadCount: 5},
|
||||
* l10nAttrs: null,
|
||||
* name: "label"
|
||||
* namespaceURI: "..."
|
||||
* type: null
|
||||
* },
|
||||
* {
|
||||
* l10nId: "key3",
|
||||
* l10nArgs: null,
|
||||
* l10nAttrs: "title",
|
||||
* name: "window"
|
||||
* namespaceURI: "..."
|
||||
* type: null
|
||||
* },
|
||||
* ]
|
||||
* [2] trans == [
|
||||
* {value: "Key 1", attrs: {accesskey: "K"} },
|
||||
* undefined,
|
||||
* {value: null, attrs: {title: "Unread emails: 5"} },
|
||||
* ]
|
||||
* [3] untranslatedElements == [
|
||||
* ,
|
||||
* <label>
|
||||
* ,
|
||||
* ]
|
||||
*
|
||||
* For exact dictionary structures, see `L10nUtils.webidl`.
|
||||
*/
|
||||
[ChromeOnly, Throws]
|
||||
Promise<void> localize(L10nCallback l10nCallback);
|
||||
|
||||
#ifdef ACCESSIBILITY
|
||||
[Pref="accessibility.AOM.enabled"]
|
||||
readonly attribute AccessibleNode? accessibleNode;
|
||||
|
|
|
@ -645,6 +645,7 @@ WEBIDL_FILES = [
|
|||
'KeyframeAnimationOptions.webidl',
|
||||
'KeyframeEffect.webidl',
|
||||
'KeyIdsInitData.webidl',
|
||||
'L10nUtils.webidl',
|
||||
'LegacyQueryInterface.webidl',
|
||||
'LinkStyle.webidl',
|
||||
'ListBoxObject.webidl',
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "mozilla/ipc/CrashReporterClient.h"
|
||||
#include "mozilla/ipc/ProcessChild.h"
|
||||
#include "mozilla/layers/APZThreadUtils.h"
|
||||
#include "mozilla/layers/APZCTreeManager.h"
|
||||
#include "mozilla/layers/APZUtils.h" // for apz::InitializeGlobalState
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
#include "mozilla/layers/CompositorManagerParent.h"
|
||||
#include "mozilla/layers/CompositorThread.h"
|
||||
|
@ -126,7 +126,7 @@ GPUParent::Init(base::ProcessId aParentPid,
|
|||
// TODO: Bug 1406327, Start VRListenerThreadHolder when loading VR content.
|
||||
VRListenerThreadHolder::Start();
|
||||
APZThreadUtils::SetControllerThread(CompositorThreadHolder::Loop());
|
||||
APZCTreeManager::InitializeGlobalState();
|
||||
apz::InitializeGlobalState();
|
||||
LayerTreeOwnerTracker::Initialize();
|
||||
mozilla::ipc::SetThisProcessName("GPU Process");
|
||||
#ifdef XP_WIN
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include "mozilla/StaticPtr.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/gfx/gfxVars.h"
|
||||
#include "mozilla/layers/APZCTreeManager.h"
|
||||
#include "mozilla/layers/APZCTreeManagerChild.h"
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
#include "mozilla/layers/CompositorManagerChild.h"
|
||||
|
|
|
@ -9,8 +9,17 @@
|
|||
|
||||
#include "mozilla/layers/APZTestData.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class TimeStamp;
|
||||
|
||||
namespace wr {
|
||||
class TransactionBuilder;
|
||||
struct WrTransformProperty;
|
||||
} // namespace wr
|
||||
|
||||
namespace layers {
|
||||
|
||||
class APZCTreeManager;
|
||||
|
@ -48,8 +57,19 @@ public:
|
|||
const RefPtr<APZSampler>& aOldSampler);
|
||||
void NotifyLayerTreeRemoved(uint64_t aLayersId);
|
||||
|
||||
bool PushStateToWR(wr::TransactionBuilder& aTxn,
|
||||
const TimeStamp& aSampleTime,
|
||||
nsTArray<wr::WrTransformProperty>& aTransformArray);
|
||||
|
||||
bool GetAPZTestData(uint64_t aLayersId, APZTestData* aOutData);
|
||||
|
||||
void SetTestAsyncScrollOffset(uint64_t aLayersId,
|
||||
const FrameMetrics::ViewID& aScrollId,
|
||||
const CSSPoint& aOffset);
|
||||
void SetTestAsyncZoom(uint64_t aLayersId,
|
||||
const FrameMetrics::ViewID& aScrollId,
|
||||
const LayerToParentLayerScale& aZoom);
|
||||
|
||||
protected:
|
||||
virtual ~APZSampler();
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "mozilla/layers/AsyncCompositionManager.h" // for ViewTransform
|
||||
#include "mozilla/layers/AsyncDragMetrics.h" // for AsyncDragMetrics
|
||||
#include "mozilla/layers/CompositorBridgeParent.h" // for CompositorBridgeParent, etc
|
||||
#include "mozilla/layers/FocusState.h" // for FocusState
|
||||
#include "mozilla/layers/LayerMetricsWrapper.h"
|
||||
#include "mozilla/layers/WebRenderScrollDataWrapper.h"
|
||||
#include "mozilla/MouseEvents.h"
|
||||
|
@ -223,15 +222,6 @@ private:
|
|||
bool mMayChangeFocus;
|
||||
};
|
||||
|
||||
/*static*/ const ScreenMargin
|
||||
APZCTreeManager::CalculatePendingDisplayPort(
|
||||
const FrameMetrics& aFrameMetrics,
|
||||
const ParentLayerPoint& aVelocity)
|
||||
{
|
||||
return AsyncPanZoomController::CalculatePendingDisplayPort(
|
||||
aFrameMetrics, aVelocity);
|
||||
}
|
||||
|
||||
APZCTreeManager::APZCTreeManager(uint64_t aRootLayersId)
|
||||
: mInputQueue(new InputQueue()),
|
||||
mRootLayersId(aRootLayersId),
|
||||
|
@ -258,13 +248,6 @@ APZCTreeManager::~APZCTreeManager()
|
|||
{
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
APZCTreeManager::InitializeGlobalState()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
AsyncPanZoomController::InitializeGlobalState();
|
||||
}
|
||||
|
||||
void
|
||||
APZCTreeManager::NotifyLayerTreeAdopted(uint64_t aLayersId,
|
||||
const RefPtr<APZCTreeManager>& aOldApzcTreeManager)
|
||||
|
|
|
@ -9,21 +9,21 @@
|
|||
|
||||
#include <unordered_map> // for std::unordered_map
|
||||
|
||||
#include "FocusState.h" // for FocusState
|
||||
#include "gfxPoint.h" // for gfxPoint
|
||||
#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2
|
||||
#include "mozilla/gfx/CompositorHitTestInfo.h"
|
||||
#include "mozilla/gfx/Logging.h" // for gfx::TreeLog
|
||||
#include "mozilla/gfx/Matrix.h" // for Matrix4x4
|
||||
#include "mozilla/layers/APZTestData.h" // for APZTestData
|
||||
#include "mozilla/layers/FocusState.h" // for FocusState
|
||||
#include "mozilla/layers/IAPZCTreeManager.h" // for IAPZCTreeManager
|
||||
#include "mozilla/layers/KeyboardMap.h" // for KeyboardMap
|
||||
#include "mozilla/layers/TouchCounter.h"// for TouchCounter
|
||||
#include "mozilla/RecursiveMutex.h" // for RecursiveMutex
|
||||
#include "mozilla/RefPtr.h" // for RefPtr
|
||||
#include "mozilla/TimeStamp.h" // for mozilla::TimeStamp
|
||||
#include "mozilla/UniquePtr.h" // for UniquePtr
|
||||
#include "nsCOMPtr.h" // for already_AddRefed
|
||||
#include "TouchCounter.h" // for TouchCounter
|
||||
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
#include "mozilla/layers/AndroidDynamicToolbarAnimator.h"
|
||||
|
@ -112,14 +112,6 @@ class APZCTreeManager : public IAPZCTreeManager {
|
|||
public:
|
||||
explicit APZCTreeManager(uint64_t aRootLayersId);
|
||||
|
||||
/**
|
||||
* Initializes the global state used in AsyncPanZoomController.
|
||||
* This is normally called when it is first needed in the constructor
|
||||
* of APZCTreeManager, but can be called manually to force it to be
|
||||
* initialized earlier.
|
||||
*/
|
||||
static void InitializeGlobalState();
|
||||
|
||||
/**
|
||||
* Notifies this APZCTreeManager that the associated compositor is now
|
||||
* responsible for managing another layers id, which got moved over from
|
||||
|
@ -346,15 +338,6 @@ public:
|
|||
*/
|
||||
bool HitTestAPZC(const ScreenIntPoint& aPoint);
|
||||
|
||||
/**
|
||||
* See AsyncPanZoomController::CalculatePendingDisplayPort. This
|
||||
* function simply delegates to that one, so that non-layers code
|
||||
* never needs to include AsyncPanZoomController.h
|
||||
*/
|
||||
static const ScreenMargin CalculatePendingDisplayPort(
|
||||
const FrameMetrics& aFrameMetrics,
|
||||
const ParentLayerPoint& aVelocity);
|
||||
|
||||
/**
|
||||
* Sets the dpi value used by all AsyncPanZoomControllers.
|
||||
* DPI defaults to 72 if not set using SetDPI() at any point.
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "mozilla/layers/APZSampler.h"
|
||||
|
||||
#include "mozilla/layers/APZCTreeManager.h"
|
||||
#include "APZCTreeManager.h"
|
||||
#include "mozilla/layers/CompositorThread.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -77,6 +77,16 @@ APZSampler::NotifyLayerTreeRemoved(uint64_t aLayersId)
|
|||
mApz->NotifyLayerTreeRemoved(aLayersId);
|
||||
}
|
||||
|
||||
bool
|
||||
APZSampler::PushStateToWR(wr::TransactionBuilder& aTxn,
|
||||
const TimeStamp& aSampleTime,
|
||||
nsTArray<wr::WrTransformProperty>& aTransformArray)
|
||||
{
|
||||
// This function will be removed eventually since we'll have WR pull
|
||||
// the transforms from APZ instead.
|
||||
return mApz->PushStateToWR(aTxn, aSampleTime, aTransformArray);
|
||||
}
|
||||
|
||||
bool
|
||||
APZSampler::GetAPZTestData(uint64_t aLayersId,
|
||||
APZTestData* aOutData)
|
||||
|
@ -85,5 +95,33 @@ APZSampler::GetAPZTestData(uint64_t aLayersId,
|
|||
return mApz->GetAPZTestData(aLayersId, aOutData);
|
||||
}
|
||||
|
||||
void
|
||||
APZSampler::SetTestAsyncScrollOffset(uint64_t aLayersId,
|
||||
const FrameMetrics::ViewID& aScrollId,
|
||||
const CSSPoint& aOffset)
|
||||
{
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
RefPtr<AsyncPanZoomController> apzc = mApz->GetTargetAPZC(aLayersId, aScrollId);
|
||||
if (apzc) {
|
||||
apzc->SetTestAsyncScrollOffset(aOffset);
|
||||
} else {
|
||||
NS_WARNING("Unable to find APZC in SetTestAsyncScrollOffset");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
APZSampler::SetTestAsyncZoom(uint64_t aLayersId,
|
||||
const FrameMetrics::ViewID& aScrollId,
|
||||
const LayerToParentLayerScale& aZoom)
|
||||
{
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
RefPtr<AsyncPanZoomController> apzc = mApz->GetTargetAPZC(aLayersId, aScrollId);
|
||||
if (apzc) {
|
||||
apzc->SetTestAsyncZoom(aZoom);
|
||||
} else {
|
||||
NS_WARNING("Unable to find APZC in SetTestAsyncZoom");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#include "mozilla/layers/APZUtils.h"
|
||||
|
||||
#include "AsyncPanZoomController.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
namespace apz {
|
||||
|
||||
/*static*/ void
|
||||
InitializeGlobalState()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
AsyncPanZoomController::InitializeGlobalState();
|
||||
}
|
||||
|
||||
/*static*/ const ScreenMargin
|
||||
CalculatePendingDisplayPort(const FrameMetrics& aFrameMetrics,
|
||||
const ParentLayerPoint& aVelocity)
|
||||
{
|
||||
return AsyncPanZoomController::CalculatePendingDisplayPort(
|
||||
aFrameMetrics, aVelocity);
|
||||
}
|
||||
|
||||
} // namespace apz
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
|
@ -8,6 +8,7 @@
|
|||
#define mozilla_layers_APZUtils_h
|
||||
|
||||
#include <stdint.h> // for uint32_t
|
||||
#include "FrameMetrics.h"
|
||||
#include "LayersTypes.h"
|
||||
#include "UnitTransforms.h"
|
||||
#include "mozilla/gfx/CompositorHitTestInfo.h"
|
||||
|
@ -93,6 +94,26 @@ struct TargetConfirmationFlags {
|
|||
bool mRequiresTargetConfirmation : 1;
|
||||
};
|
||||
|
||||
namespace apz {
|
||||
|
||||
/**
|
||||
* Initializes the global state used in AsyncPanZoomController.
|
||||
* This is normally called when it is first needed in the constructor
|
||||
* of APZCTreeManager, but can be called manually to force it to be
|
||||
* initialized earlier.
|
||||
*/
|
||||
void InitializeGlobalState();
|
||||
|
||||
/**
|
||||
* See AsyncPanZoomController::CalculatePendingDisplayPort. This
|
||||
* function simply delegates to that one, so that non-layers code
|
||||
* never needs to include AsyncPanZoomController.h
|
||||
*/
|
||||
const ScreenMargin CalculatePendingDisplayPort(const FrameMetrics& aFrameMetrics,
|
||||
const ParentLayerPoint& aVelocity);
|
||||
|
||||
} // namespace apz
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
|
@ -7,13 +7,14 @@
|
|||
#include "mozilla/layers/AndroidDynamicToolbarAnimator.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "APZCTreeManager.h"
|
||||
#include "FrameMetrics.h"
|
||||
#include "gfxPrefs.h"
|
||||
#include "mozilla/EventForwards.h"
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/gfx/Types.h"
|
||||
#include "mozilla/layers/APZCTreeManager.h"
|
||||
#include "mozilla/layers/APZThreadUtils.h"
|
||||
#include "mozilla/layers/AsyncCompositionManager.h"
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
|
|
|
@ -4,11 +4,15 @@
|
|||
* 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/. */
|
||||
|
||||
#include "AsyncPanZoomController.h" // for AsyncPanZoomController, etc
|
||||
|
||||
#include <math.h> // for fabsf, fabs, atan2
|
||||
#include <stdint.h> // for uint32_t, uint64_t
|
||||
#include <sys/types.h> // for int32_t
|
||||
#include <algorithm> // for max, min
|
||||
#include "AsyncPanZoomController.h" // for AsyncPanZoomController, etc
|
||||
|
||||
#include "APZCTreeManager.h" // for APZCTreeManager
|
||||
#include "AsyncPanZoomAnimation.h" // for AsyncPanZoomAnimation
|
||||
#include "AutoscrollAnimation.h" // for AutoscrollAnimation
|
||||
#include "Axis.h" // for AxisX, AxisY, Axis, etc
|
||||
#include "CheckerboardEvent.h" // for CheckerboardEvent
|
||||
|
@ -50,7 +54,6 @@
|
|||
#include "mozilla/gfx/Point.h" // for Point, RoundedToInt, etc
|
||||
#include "mozilla/gfx/Rect.h" // for RoundedIn
|
||||
#include "mozilla/gfx/ScaleFactor.h" // for ScaleFactor
|
||||
#include "mozilla/layers/APZCTreeManager.h" // for ScrollableLayerGuid
|
||||
#include "mozilla/layers/APZThreadUtils.h" // for AssertOnControllerThread, etc
|
||||
#include "mozilla/layers/AsyncCompositionManager.h" // for ViewTransform
|
||||
#include "mozilla/layers/AxisPhysicsModel.h" // for AxisPhysicsModel
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
|
||||
#include "CrossProcessMutex.h"
|
||||
#include "mozilla/layers/GeckoContentController.h"
|
||||
#include "mozilla/layers/APZCTreeManager.h"
|
||||
#include "mozilla/layers/AsyncPanZoomAnimation.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/EventForwards.h"
|
||||
#include "mozilla/Monitor.h"
|
||||
|
@ -43,6 +41,7 @@ class SharedMemoryBasic;
|
|||
namespace layers {
|
||||
|
||||
class AsyncDragMetrics;
|
||||
class APZCTreeManager;
|
||||
struct ScrollableLayerGuid;
|
||||
class CompositorController;
|
||||
class MetricsSharingController;
|
||||
|
@ -52,9 +51,11 @@ class AsyncPanZoomAnimation;
|
|||
class AndroidFlingAnimation;
|
||||
class GenericFlingAnimation;
|
||||
class InputBlockState;
|
||||
struct FlingHandoffState;
|
||||
class TouchBlockState;
|
||||
class PanGestureBlockState;
|
||||
class OverscrollHandoffChain;
|
||||
struct OverscrollHandoffState;
|
||||
class StateChangeNotificationBlocker;
|
||||
class CheckerboardEvent;
|
||||
class OverscrollEffectBase;
|
||||
|
|
|
@ -5,10 +5,12 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "Axis.h"
|
||||
|
||||
#include <math.h> // for fabsf, pow, powf
|
||||
#include <algorithm> // for max
|
||||
|
||||
#include "APZCTreeManager.h" // for APZCTreeManager
|
||||
#include "AsyncPanZoomController.h" // for AsyncPanZoomController
|
||||
#include "mozilla/layers/APZCTreeManager.h" // for APZCTreeManager
|
||||
#include "mozilla/layers/APZThreadUtils.h" // for AssertOnControllerThread
|
||||
#include "FrameMetrics.h" // for FrameMetrics
|
||||
#include "mozilla/Attributes.h" // for final
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* 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/. */
|
||||
|
||||
#include "mozilla/layers/FocusState.h"
|
||||
#include "FocusState.h"
|
||||
|
||||
// #define FS_LOG(...) printf_stderr("FS: " __VA_ARGS__)
|
||||
#define FS_LOG(...)
|
||||
|
|
|
@ -5,12 +5,14 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "InputBlockState.h"
|
||||
|
||||
#include "APZCTreeManager.h" // for APZCTreeManager::GetDPI
|
||||
#include "AsyncPanZoomController.h" // for AsyncPanZoomController
|
||||
#include "ScrollAnimationPhysics.h" // for kScrollSeriesTimeoutMs
|
||||
#include "gfxPrefs.h" // for gfxPrefs
|
||||
#include "mozilla/MouseEvents.h"
|
||||
#include "mozilla/Telemetry.h" // for Telemetry
|
||||
#include "mozilla/layers/APZCTreeManager.h" // for AllowedTouchBehavior
|
||||
#include "mozilla/layers/IAPZCTreeManager.h" // for AllowedTouchBehavior
|
||||
#include "OverscrollHandoffState.h"
|
||||
#include "QueuedInput.h"
|
||||
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
#include "mozilla/layers/AsyncCompositionManager.h" // for ViewTransform
|
||||
#include "mozilla/layers/GeckoContentController.h"
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
#include "mozilla/layers/APZCTreeManager.h"
|
||||
#include "mozilla/layers/LayerMetricsWrapper.h"
|
||||
#include "mozilla/layers/APZThreadUtils.h"
|
||||
#include "mozilla/TypedEnumBits.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "apz/src/APZCTreeManager.h"
|
||||
#include "apz/src/AsyncPanZoomController.h"
|
||||
#include "apz/src/HitTestingTreeNode.h"
|
||||
#include "base/task.h"
|
||||
|
|
|
@ -84,4 +84,4 @@
|
|||
[test_group_overrides.html]
|
||||
skip-if = (toolkit == 'android') || webrender # wheel events not supported on mobile; bug 1429521 for webrender
|
||||
[test_group_hittest.html]
|
||||
skip-if = (toolkit == 'android') # mouse events not supported on mobile
|
||||
skip-if = (toolkit == 'android') || webrender # mouse events not supported on mobile; re-enable on webrender when bug 1391318 is fixed
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "TouchActionHelper.h"
|
||||
|
||||
#include "mozilla/layers/APZCTreeManager.h"
|
||||
#include "mozilla/layers/IAPZCTreeManager.h"
|
||||
#include "nsContainerFrame.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "gfxPrefs.h"
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
# include <android/log.h>
|
||||
# include "apz/src/APZCTreeManager.h"
|
||||
# include "mozilla/layers/UiCompositorControllerParent.h"
|
||||
# include "mozilla/widget/AndroidCompositorWidget.h"
|
||||
#endif
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
#include <android/log.h>
|
||||
#include <android/native_window.h>
|
||||
#include "apz/src/APZCTreeManager.h"
|
||||
#include "mozilla/widget/AndroidCompositorWidget.h"
|
||||
#include "opengl/CompositorOGL.h"
|
||||
#include "GLConsts.h"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "mozilla/layers/APZCTreeManagerParent.h"
|
||||
|
||||
#include "mozilla/layers/APZCTreeManager.h"
|
||||
#include "apz/src/APZCTreeManager.h"
|
||||
#include "mozilla/layers/APZThreadUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
|
|
@ -5,10 +5,13 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
|
||||
#include <stdio.h> // for fprintf, stdout
|
||||
#include <stdint.h> // for uint64_t
|
||||
#include <map> // for _Rb_tree_iterator, etc
|
||||
#include <utility> // for pair
|
||||
|
||||
#include "apz/src/APZCTreeManager.h" // for APZCTreeManager
|
||||
#include "LayerTransactionParent.h" // for LayerTransactionParent
|
||||
#include "RenderTrace.h" // for RenderTraceLayers
|
||||
#include "base/message_loop.h" // for MessageLoop
|
||||
|
@ -37,7 +40,6 @@
|
|||
#include "mozilla/gfx/gfxVars.h"
|
||||
#include "mozilla/gfx/GPUParent.h"
|
||||
#include "mozilla/layers/AnimationHelper.h" // for CompositorAnimationStorage
|
||||
#include "mozilla/layers/APZCTreeManager.h" // for APZCTreeManager
|
||||
#include "mozilla/layers/APZCTreeManagerParent.h" // for APZCTreeManagerParent
|
||||
#include "mozilla/layers/APZSampler.h" // for APZSampler
|
||||
#include "mozilla/layers/APZThreadUtils.h" // for APZThreadUtils
|
||||
|
@ -1146,6 +1148,17 @@ CompositorBridgeParent::DeallocPAPZCTreeManagerParent(PAPZCTreeManagerParent* aA
|
|||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
CompositorBridgeParent::AllocateAPZCTreeManagerParent(const MonitorAutoLock& aProofOfLayerTreeStateLock,
|
||||
const uint64_t& aLayersId,
|
||||
LayerTreeState& aState)
|
||||
{
|
||||
MOZ_ASSERT(aState.mParent == this);
|
||||
MOZ_ASSERT(mApzcTreeManager);
|
||||
MOZ_ASSERT(!aState.mApzcTreeManagerParent);
|
||||
aState.mApzcTreeManagerParent = new APZCTreeManagerParent(aLayersId, mApzcTreeManager);
|
||||
}
|
||||
|
||||
PAPZParent*
|
||||
CompositorBridgeParent::AllocPAPZParent(const uint64_t& aLayersId)
|
||||
{
|
||||
|
@ -1174,11 +1187,13 @@ CompositorBridgeParent::DeallocPAPZParent(PAPZParent* aActor)
|
|||
return true;
|
||||
}
|
||||
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
RefPtr<APZCTreeManager>
|
||||
CompositorBridgeParent::GetAPZCTreeManager()
|
||||
{
|
||||
return mApzcTreeManager;
|
||||
}
|
||||
#endif
|
||||
|
||||
RefPtr<APZSampler>
|
||||
CompositorBridgeParent::GetAPZSampler()
|
||||
|
@ -1367,6 +1382,30 @@ CompositorBridgeParent::RecvGetFrameUniformity(FrameUniformityData* aOutData)
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
void
|
||||
CompositorBridgeParent::SetTestAsyncScrollOffset(
|
||||
const uint64_t& aLayersId,
|
||||
const FrameMetrics::ViewID& aScrollId,
|
||||
const CSSPoint& aPoint)
|
||||
{
|
||||
if (mApzSampler) {
|
||||
uint64_t layersId = (aLayersId == 0 ? mRootLayerTreeID : aLayersId);
|
||||
mApzSampler->SetTestAsyncScrollOffset(layersId, aScrollId, aPoint);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CompositorBridgeParent::SetTestAsyncZoom(
|
||||
const uint64_t& aLayersId,
|
||||
const FrameMetrics::ViewID& aScrollId,
|
||||
const LayerToParentLayerScale& aZoom)
|
||||
{
|
||||
if (mApzSampler) {
|
||||
uint64_t layersId = (aLayersId == 0 ? mRootLayerTreeID : aLayersId);
|
||||
mApzSampler->SetTestAsyncZoom(layersId, aScrollId, aZoom);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CompositorBridgeParent::FlushApzRepaints(const uint64_t& aLayersId)
|
||||
{
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include "mozilla/layers/CompositorController.h"
|
||||
#include "mozilla/layers/CompositorOptions.h"
|
||||
#include "mozilla/layers/CompositorVsyncSchedulerOwner.h"
|
||||
#include "mozilla/layers/FocusState.h"
|
||||
#include "mozilla/layers/GeckoContentController.h"
|
||||
#include "mozilla/layers/ISurfaceAllocator.h" // for ShmemAllocator
|
||||
#include "mozilla/layers/LayersMessages.h" // for TargetConfig
|
||||
|
@ -114,6 +113,12 @@ public:
|
|||
const TimeStamp& aTime) { return true; }
|
||||
virtual void LeaveTestMode(const uint64_t& aId) { }
|
||||
virtual void ApplyAsyncProperties(LayerTransactionParent* aLayerTree) = 0;
|
||||
virtual void SetTestAsyncScrollOffset(const uint64_t& aLayersId,
|
||||
const FrameMetrics::ViewID& aScrollId,
|
||||
const CSSPoint& aPoint) = 0;
|
||||
virtual void SetTestAsyncZoom(const uint64_t& aLayersId,
|
||||
const FrameMetrics::ViewID& aScrollId,
|
||||
const LayerToParentLayerScale& aZoom) = 0;
|
||||
virtual void FlushApzRepaints(const uint64_t& aLayersId) = 0;
|
||||
virtual void GetAPZTestData(const uint64_t& aLayersId,
|
||||
APZTestData* aOutData) { }
|
||||
|
@ -248,6 +253,12 @@ public:
|
|||
void LeaveTestMode(const uint64_t& aId) override;
|
||||
void ApplyAsyncProperties(LayerTransactionParent* aLayerTree) override;
|
||||
CompositorAnimationStorage* GetAnimationStorage();
|
||||
void SetTestAsyncScrollOffset(const uint64_t& aLayersId,
|
||||
const FrameMetrics::ViewID& aScrollId,
|
||||
const CSSPoint& aPoint) override;
|
||||
void SetTestAsyncZoom(const uint64_t& aLayersId,
|
||||
const FrameMetrics::ViewID& aScrollId,
|
||||
const LayerToParentLayerScale& aZoom) override;
|
||||
void FlushApzRepaints(const uint64_t& aLayersId) override;
|
||||
void GetAPZTestData(const uint64_t& aLayersId,
|
||||
APZTestData* aOutData) override;
|
||||
|
@ -443,10 +454,18 @@ public:
|
|||
PAPZCTreeManagerParent* AllocPAPZCTreeManagerParent(const uint64_t& aLayersId) override;
|
||||
bool DeallocPAPZCTreeManagerParent(PAPZCTreeManagerParent* aActor) override;
|
||||
|
||||
// Helper method so that we don't have to expose mApzcTreeManager to
|
||||
// CrossProcessCompositorBridgeParent.
|
||||
void AllocateAPZCTreeManagerParent(const MonitorAutoLock& aProofOfLayerTreeStateLock,
|
||||
const uint64_t& aLayersId,
|
||||
LayerTreeState& aLayerTreeStateToUpdate);
|
||||
|
||||
PAPZParent* AllocPAPZParent(const uint64_t& aLayersId) override;
|
||||
bool DeallocPAPZParent(PAPZParent* aActor) override;
|
||||
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
RefPtr<APZCTreeManager> GetAPZCTreeManager();
|
||||
#endif
|
||||
RefPtr<APZSampler> GetAPZSampler();
|
||||
|
||||
CompositorOptions GetOptions() const {
|
||||
|
|
|
@ -5,8 +5,11 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/layers/CrossProcessCompositorBridgeParent.h"
|
||||
|
||||
#include <stdint.h> // for uint64_t
|
||||
|
||||
#include "LayerTransactionParent.h" // for LayerTransactionParent
|
||||
#include "apz/src/APZCTreeManager.h" // for APZCTreeManager
|
||||
#include "base/message_loop.h" // for MessageLoop
|
||||
#include "base/task.h" // for CancelableTask, etc
|
||||
#include "base/thread.h" // for Thread
|
||||
|
@ -15,9 +18,7 @@
|
|||
#endif
|
||||
#include "mozilla/ipc/Transport.h" // for Transport
|
||||
#include "mozilla/layers/AnimationHelper.h" // for CompositorAnimationStorage
|
||||
#include "mozilla/layers/APZCTreeManager.h" // for APZCTreeManager
|
||||
#include "mozilla/layers/APZCTreeManagerParent.h" // for APZCTreeManagerParent
|
||||
#include "mozilla/layers/APZThreadUtils.h" // for APZCTreeManager
|
||||
#include "mozilla/layers/AsyncCompositionManager.h"
|
||||
#include "mozilla/layers/CompositorOptions.h"
|
||||
#include "mozilla/layers/CompositorThread.h"
|
||||
|
@ -136,9 +137,7 @@ CrossProcessCompositorBridgeParent::AllocPAPZCTreeManagerParent(const uint64_t&
|
|||
return new APZCTreeManagerParent(aLayersId, temp);
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!state.mApzcTreeManagerParent);
|
||||
state.mApzcTreeManagerParent = new APZCTreeManagerParent(aLayersId, state.mParent->GetAPZCTreeManager());
|
||||
|
||||
state.mParent->AllocateAPZCTreeManagerParent(lock, aLayersId, state);
|
||||
return state.mApzcTreeManagerParent;
|
||||
}
|
||||
bool
|
||||
|
@ -466,6 +465,40 @@ CrossProcessCompositorBridgeParent::ApplyAsyncProperties(
|
|||
state->mParent->ApplyAsyncProperties(aLayerTree);
|
||||
}
|
||||
|
||||
void
|
||||
CrossProcessCompositorBridgeParent::SetTestAsyncScrollOffset(
|
||||
const uint64_t& aLayersId,
|
||||
const FrameMetrics::ViewID& aScrollId,
|
||||
const CSSPoint& aPoint)
|
||||
{
|
||||
MOZ_ASSERT(aLayersId != 0);
|
||||
const CompositorBridgeParent::LayerTreeState* state =
|
||||
CompositorBridgeParent::GetIndirectShadowTree(aLayersId);
|
||||
if (!state) {
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(state->mParent);
|
||||
state->mParent->SetTestAsyncScrollOffset(aLayersId, aScrollId, aPoint);
|
||||
}
|
||||
|
||||
void
|
||||
CrossProcessCompositorBridgeParent::SetTestAsyncZoom(
|
||||
const uint64_t& aLayersId,
|
||||
const FrameMetrics::ViewID& aScrollId,
|
||||
const LayerToParentLayerScale& aZoom)
|
||||
{
|
||||
MOZ_ASSERT(aLayersId != 0);
|
||||
const CompositorBridgeParent::LayerTreeState* state =
|
||||
CompositorBridgeParent::GetIndirectShadowTree(aLayersId);
|
||||
if (!state) {
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(state->mParent);
|
||||
state->mParent->SetTestAsyncZoom(aLayersId, aScrollId, aZoom);
|
||||
}
|
||||
|
||||
void
|
||||
CrossProcessCompositorBridgeParent::FlushApzRepaints(const uint64_t& aLayersId)
|
||||
{
|
||||
|
|
|
@ -95,6 +95,12 @@ public:
|
|||
const TimeStamp& aTime) override;
|
||||
void LeaveTestMode(const uint64_t& aId) override;
|
||||
void ApplyAsyncProperties(LayerTransactionParent* aLayerTree) override;
|
||||
void SetTestAsyncScrollOffset(const uint64_t& aLayersId,
|
||||
const FrameMetrics::ViewID& aScrollId,
|
||||
const CSSPoint& aPoint) override;
|
||||
void SetTestAsyncZoom(const uint64_t& aLayersId,
|
||||
const FrameMetrics::ViewID& aScrollId,
|
||||
const LayerToParentLayerScale& aZoom) override;
|
||||
void FlushApzRepaints(const uint64_t& aLayersId) override;
|
||||
void GetAPZTestData(const uint64_t& aLayersId,
|
||||
APZTestData* aOutData) override;
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include "LayerTransactionParent.h"
|
||||
#include <vector> // for vector
|
||||
#include "apz/src/AsyncPanZoomController.h"
|
||||
#include "CompositableHost.h" // for CompositableParent, Get, etc
|
||||
#include "ImageLayers.h" // for ImageLayer
|
||||
#include "Layers.h" // for Layer, ContainerLayer, etc
|
||||
|
@ -751,25 +750,6 @@ LayerTransactionParent::RecvGetAnimationTransform(const uint64_t& aCompositorAni
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
static AsyncPanZoomController*
|
||||
GetAPZCForViewID(Layer* aLayer, FrameMetrics::ViewID aScrollID)
|
||||
{
|
||||
AsyncPanZoomController* resultApzc = nullptr;
|
||||
ForEachNode<ForwardIterator>(
|
||||
aLayer,
|
||||
[aScrollID, &resultApzc] (Layer* layer)
|
||||
{
|
||||
for (uint32_t i = 0; i < layer->GetScrollMetadataCount(); i++) {
|
||||
if (layer->GetFrameMetrics(i).GetScrollId() == aScrollID) {
|
||||
resultApzc = layer->GetAsyncPanZoomController(i);
|
||||
return TraversalFlag::Abort;
|
||||
}
|
||||
}
|
||||
return TraversalFlag::Continue;
|
||||
});
|
||||
return resultApzc;
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
LayerTransactionParent::RecvSetAsyncScrollOffset(const FrameMetrics::ViewID& aScrollID,
|
||||
const float& aX, const float& aY)
|
||||
|
@ -778,11 +758,7 @@ LayerTransactionParent::RecvSetAsyncScrollOffset(const FrameMetrics::ViewID& aSc
|
|||
return IPC_FAIL_NO_REASON(this);
|
||||
}
|
||||
|
||||
AsyncPanZoomController* controller = GetAPZCForViewID(mRoot, aScrollID);
|
||||
if (!controller) {
|
||||
return IPC_FAIL_NO_REASON(this);
|
||||
}
|
||||
controller->SetTestAsyncScrollOffset(CSSPoint(aX, aY));
|
||||
mCompositorBridge->SetTestAsyncScrollOffset(GetId(), aScrollID, CSSPoint(aX, aY));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
@ -794,11 +770,7 @@ LayerTransactionParent::RecvSetAsyncZoom(const FrameMetrics::ViewID& aScrollID,
|
|||
return IPC_FAIL_NO_REASON(this);
|
||||
}
|
||||
|
||||
AsyncPanZoomController* controller = GetAPZCForViewID(mRoot, aScrollID);
|
||||
if (!controller) {
|
||||
return IPC_FAIL_NO_REASON(this);
|
||||
}
|
||||
controller->SetTestAsyncZoom(LayerToParentLayerScale(aValue));
|
||||
mCompositorBridge->SetTestAsyncZoom(GetId(), aScrollID, LayerToParentLayerScale(aValue));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ class IpcResourceUpdateQueue;
|
|||
namespace layers {
|
||||
|
||||
class CompositorManagerChild;
|
||||
class ImageContainer;
|
||||
class WebRenderLayerManager;
|
||||
|
||||
class SharedSurfacesChild final
|
||||
|
|
|
@ -4,7 +4,10 @@
|
|||
* 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/. */
|
||||
#include "UiCompositorControllerParent.h"
|
||||
#include "mozilla/layers/APZCTreeManager.h"
|
||||
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
#include "apz/src/APZCTreeManager.h"
|
||||
#endif
|
||||
#include "mozilla/layers/Compositor.h"
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
#include "mozilla/layers/CompositorThread.h"
|
||||
|
|
|
@ -99,15 +99,11 @@ EXPORTS.mozilla.layers += [
|
|||
'apz/public/MetricsSharingController.h',
|
||||
# exporting things from apz/src is temporary until we extract a
|
||||
# proper interface for the code there
|
||||
'apz/src/APZCTreeManager.h',
|
||||
'apz/src/APZUtils.h',
|
||||
'apz/src/AsyncDragMetrics.h',
|
||||
'apz/src/AsyncPanZoomAnimation.h',
|
||||
'apz/src/FocusState.h',
|
||||
'apz/src/FocusTarget.h',
|
||||
'apz/src/KeyboardMap.h',
|
||||
'apz/src/KeyboardScrollAction.h',
|
||||
'apz/src/TouchCounter.h',
|
||||
'apz/testutil/APZTestData.h',
|
||||
'apz/util/ActiveElementManager.h',
|
||||
'apz/util/APZCCallbackHelper.h',
|
||||
|
@ -299,6 +295,7 @@ UNIFIED_SOURCES += [
|
|||
'apz/public/IAPZCTreeManager.cpp',
|
||||
'apz/src/APZCTreeManager.cpp',
|
||||
'apz/src/APZSampler.cpp',
|
||||
'apz/src/APZUtils.cpp',
|
||||
'apz/src/AsyncPanZoomController.cpp',
|
||||
'apz/src/AutoscrollAnimation.cpp',
|
||||
'apz/src/Axis.cpp',
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "gfxTypes.h"
|
||||
#include "mozilla/Attributes.h" // for override
|
||||
#include "mozilla/gfx/Point.h" // for IntSize
|
||||
#include "mozilla/gfx/Types.h" // for SurfaceFormat
|
||||
#include "mozilla/layers/CompositorTypes.h"
|
||||
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor
|
||||
#include "mozilla/layers/TextureClient.h" // for TextureClient, etc
|
||||
|
@ -23,6 +24,12 @@
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
namespace gfx {
|
||||
|
||||
class DrawTarget;
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
namespace layers {
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
|
@ -60,14 +67,10 @@ protected:
|
|||
const bool mContinuous;
|
||||
};
|
||||
|
||||
#endif // MOZ_WIDGET_ANDROID
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
|
||||
class AndroidNativeWindowTextureData : public TextureData
|
||||
{
|
||||
public:
|
||||
static AndroidNativeWindowTextureData* Create(gfx::IntSize aSize, SurfaceFormat aFormat);
|
||||
static AndroidNativeWindowTextureData* Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat);
|
||||
|
||||
virtual void FillInfo(TextureData::Info& aInfo) const override;
|
||||
|
||||
|
@ -79,14 +82,14 @@ public:
|
|||
virtual void Forget(LayersIPCChannel*) override;
|
||||
virtual void Deallocate(LayersIPCChannel*) override {}
|
||||
|
||||
virtual already_AddRefed<DrawTarget> BorrowDrawTarget() override;
|
||||
virtual already_AddRefed<gfx::DrawTarget> BorrowDrawTarget() override;
|
||||
|
||||
virtual void OnForwardedToHost() override;
|
||||
|
||||
protected:
|
||||
AndroidNativeWindowTextureData(java::GeckoSurface::Param aSurface,
|
||||
gfx::IntSize aSize,
|
||||
SurfaceFormat aFormat);
|
||||
gfx::SurfaceFormat aFormat);
|
||||
|
||||
private:
|
||||
java::GeckoSurface::GlobalRef mSurface;
|
||||
|
@ -96,7 +99,7 @@ private:
|
|||
bool mIsLocked;
|
||||
|
||||
const gfx::IntSize mSize;
|
||||
const SurfaceFormat mFormat;
|
||||
const gfx::SurfaceFormat mFormat;
|
||||
};
|
||||
|
||||
#endif // MOZ_WIDGET_ANDROID
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include "mozilla/layers/WebRenderBridgeParent.h"
|
||||
|
||||
#include "apz/src/AsyncPanZoomController.h"
|
||||
#include "CompositableHost.h"
|
||||
#include "gfxEnv.h"
|
||||
#include "gfxPrefs.h"
|
||||
|
@ -16,7 +15,7 @@
|
|||
#include "GLContextProvider.h"
|
||||
#include "mozilla/Range.h"
|
||||
#include "mozilla/layers/AnimationHelper.h"
|
||||
#include "mozilla/layers/APZCTreeManager.h"
|
||||
#include "mozilla/layers/APZSampler.h"
|
||||
#include "mozilla/layers/Compositor.h"
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
#include "mozilla/layers/CompositorThread.h"
|
||||
|
@ -515,11 +514,11 @@ WebRenderBridgeParent::UpdateAPZ(bool aUpdateHitTestingTree)
|
|||
if (!rootWrbp) {
|
||||
return;
|
||||
}
|
||||
if (RefPtr<APZCTreeManager> apzc = cbp->GetAPZCTreeManager()) {
|
||||
apzc->UpdateFocusState(rootLayersId, GetLayersId(),
|
||||
mScrollData.GetFocusTarget());
|
||||
if (RefPtr<APZSampler> apz = cbp->GetAPZSampler()) {
|
||||
apz->UpdateFocusState(rootLayersId, GetLayersId(),
|
||||
mScrollData.GetFocusTarget());
|
||||
if (aUpdateHitTestingTree) {
|
||||
apzc->UpdateHitTestingTree(rootLayersId, rootWrbp->GetScrollData(),
|
||||
apz->UpdateHitTestingTree(rootLayersId, rootWrbp->GetScrollData(),
|
||||
mScrollData.IsFirstPaint(), GetLayersId(),
|
||||
mScrollData.GetPaintSequenceNumber());
|
||||
}
|
||||
|
@ -534,7 +533,7 @@ WebRenderBridgeParent::PushAPZStateToWR(wr::TransactionBuilder& aTxn,
|
|||
if (!cbp) {
|
||||
return false;
|
||||
}
|
||||
if (RefPtr<APZCTreeManager> apzc = cbp->GetAPZCTreeManager()) {
|
||||
if (RefPtr<APZSampler> apz = cbp->GetAPZSampler()) {
|
||||
TimeStamp animationTime = cbp->GetTestingTimeStamp().valueOr(
|
||||
mCompositorScheduler->GetLastComposeTime());
|
||||
TimeDuration frameInterval = cbp->GetVsyncInterval();
|
||||
|
@ -543,7 +542,7 @@ WebRenderBridgeParent::PushAPZStateToWR(wr::TransactionBuilder& aTxn,
|
|||
if (frameInterval != TimeDuration::Forever()) {
|
||||
animationTime += frameInterval;
|
||||
}
|
||||
return apzc->PushStateToWR(aTxn, animationTime, aTransformArray);
|
||||
return apz->PushStateToWR(aTxn, animationTime, aTransformArray);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1016,18 +1015,6 @@ WebRenderBridgeParent::RecvCapture()
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
already_AddRefed<AsyncPanZoomController>
|
||||
WebRenderBridgeParent::GetTargetAPZC(const FrameMetrics::ViewID& aScrollId)
|
||||
{
|
||||
RefPtr<AsyncPanZoomController> apzc;
|
||||
if (CompositorBridgeParent* cbp = GetRootCompositorBridgeParent()) {
|
||||
if (RefPtr<APZCTreeManager> apzctm = cbp->GetAPZCTreeManager()) {
|
||||
apzc = apzctm->GetTargetAPZC(GetLayersId(), aScrollId);
|
||||
}
|
||||
}
|
||||
return apzc.forget();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
WebRenderBridgeParent::RecvSetConfirmedTargetAPZC(const uint64_t& aBlockId,
|
||||
nsTArray<ScrollableLayerGuid>&& aTargets)
|
||||
|
@ -1105,11 +1092,7 @@ WebRenderBridgeParent::RecvSetAsyncScrollOffset(const FrameMetrics::ViewID& aScr
|
|||
if (mDestroyed) {
|
||||
return IPC_OK();
|
||||
}
|
||||
RefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(aScrollId);
|
||||
if (!apzc) {
|
||||
return IPC_FAIL_NO_REASON(this);
|
||||
}
|
||||
apzc->SetTestAsyncScrollOffset(CSSPoint(aX, aY));
|
||||
mCompositorBridge->SetTestAsyncScrollOffset(GetLayersId(), aScrollId, CSSPoint(aX, aY));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
@ -1120,11 +1103,7 @@ WebRenderBridgeParent::RecvSetAsyncZoom(const FrameMetrics::ViewID& aScrollId,
|
|||
if (mDestroyed) {
|
||||
return IPC_OK();
|
||||
}
|
||||
RefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(aScrollId);
|
||||
if (!apzc) {
|
||||
return IPC_FAIL_NO_REASON(this);
|
||||
}
|
||||
apzc->SetTestAsyncZoom(LayerToParentLayerScale(aZoom));
|
||||
mCompositorBridge->SetTestAsyncZoom(GetLayersId(), aScrollId, LayerToParentLayerScale(aZoom));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
|
|
@ -228,10 +228,6 @@ private:
|
|||
bool PushAPZStateToWR(wr::TransactionBuilder& aTxn,
|
||||
nsTArray<wr::WrTransformProperty>& aTransformArray);
|
||||
|
||||
// Helper method to get an APZC reference from a scroll id. Uses the layers
|
||||
// id of this bridge, and may return null if the APZC wasn't found.
|
||||
already_AddRefed<AsyncPanZoomController> GetTargetAPZC(const FrameMetrics::ViewID& aId);
|
||||
|
||||
uint32_t GetNextWrEpoch();
|
||||
|
||||
private:
|
||||
|
|
|
@ -107,9 +107,9 @@ function overlayElement(targetElement, translation) {
|
|||
}
|
||||
|
||||
if (translation.attrs) {
|
||||
for (const [name, val] of translation.attrs) {
|
||||
for (const {name, value} of translation.attrs) {
|
||||
if (isAttrNameLocalizable(name, targetElement, explicitlyAllowed)) {
|
||||
targetElement.setAttribute(name, val);
|
||||
targetElement.setAttribute(name, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -304,6 +304,47 @@ function shiftNamedElement(element, localName) {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitizes a translation before passing them to Node.localize API.
|
||||
*
|
||||
* It returns `false` if the translation contains DOM Overlays and should
|
||||
* not go into Node.localize.
|
||||
*
|
||||
* Note: There's a third item of work that JS DOM Overlays do - removal
|
||||
* of attributes from the previous translation.
|
||||
* This is not trivial to implement for Node.localize scenario, so
|
||||
* at the moment it is not supported.
|
||||
*
|
||||
* @param {{
|
||||
* localName: string,
|
||||
* namespaceURI: string,
|
||||
* type: string || null
|
||||
* l10nId: string,
|
||||
* l10nArgs: Array<Object> || null,
|
||||
* l10nAttrs: string ||null,
|
||||
* }} l10nItems
|
||||
* @param {{value: string, attrs: Object}} translations
|
||||
* @returns boolean
|
||||
* @private
|
||||
*/
|
||||
function sanitizeTranslationForNodeLocalize(l10nItem, translation) {
|
||||
if (reOverlay.test(translation.value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (translation.attrs) {
|
||||
const explicitlyAllowed = l10nItem.l10nAttrs === null ? null :
|
||||
l10nItem.l10nAttrs.split(",").map(i => i.trim());
|
||||
for (const [j, {name}] of translation.attrs.entries()) {
|
||||
if (!isAttrNameLocalizable(name, l10nItem, explicitlyAllowed)) {
|
||||
translation.attrs.splice(j, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
const L10NID_ATTR_NAME = "data-l10n-id";
|
||||
const L10NARGS_ATTR_NAME = "data-l10n-args";
|
||||
|
||||
|
@ -468,7 +509,7 @@ class DOMLocalization extends Localization {
|
|||
translateRoots() {
|
||||
const roots = Array.from(this.roots);
|
||||
return Promise.all(
|
||||
roots.map(root => this.translateElements(this.getTranslatables(root)))
|
||||
roots.map(root => this.translateFragment(root))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -533,7 +574,6 @@ class DOMLocalization extends Localization {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Translate a DOM element or fragment asynchronously using this
|
||||
* `DOMLocalization` object.
|
||||
|
@ -548,6 +588,59 @@ class DOMLocalization extends Localization {
|
|||
* @returns {Promise}
|
||||
*/
|
||||
translateFragment(frag) {
|
||||
if (frag.localize) {
|
||||
// This is a temporary fast-path offered by Gecko to workaround performance
|
||||
// issues coming from Fluent and XBL+Stylo performing unnecesary
|
||||
// operations during startup.
|
||||
// For details see bug 1441037, bug 1442262, and bug 1363862.
|
||||
|
||||
// A sparse array which will store translations separated out from
|
||||
// all translations that is needed for DOM Overlay.
|
||||
const overlayTranslations = [];
|
||||
|
||||
const getTranslationsForItems = async l10nItems => {
|
||||
const keys = l10nItems.map(l10nItem => [l10nItem.l10nId, l10nItem.l10nArgs]);
|
||||
const translations = await this.formatMessages(keys);
|
||||
|
||||
// Here we want to separate out elements that require DOM Overlays.
|
||||
// Those elements will have to be translated using our JS
|
||||
// implementation, while everything else is going to use the fast-path.
|
||||
for (const [i, translation] of translations.entries()) {
|
||||
if (translation === undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const hasOnlyText =
|
||||
sanitizeTranslationForNodeLocalize(l10nItems[i], translation);
|
||||
if (!hasOnlyText) {
|
||||
// Removing from translations to make Node.localize skip it.
|
||||
// We will translate it below using JS DOM Overlays.
|
||||
overlayTranslations[i] = translations[i];
|
||||
translations[i] = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// We pause translation observing here because Node.localize
|
||||
// will translate the whole DOM next, using the `translations`.
|
||||
//
|
||||
// The observer will be resumed after DOM Overlays are localized
|
||||
// in the next microtask.
|
||||
this.pauseObserving();
|
||||
return translations;
|
||||
};
|
||||
|
||||
return frag.localize(getTranslationsForItems.bind(this))
|
||||
.then(untranslatedElements => {
|
||||
for (let i = 0; i < overlayTranslations.length; i++) {
|
||||
if (overlayTranslations[i] !== undefined &&
|
||||
untranslatedElements[i] !== undefined) {
|
||||
overlayElement(untranslatedElements[i], overlayTranslations[i]);
|
||||
}
|
||||
}
|
||||
this.resumeObserving();
|
||||
})
|
||||
.catch(() => this.resumeObserving());
|
||||
}
|
||||
return this.translateElements(this.getTranslatables(frag));
|
||||
}
|
||||
|
||||
|
@ -585,7 +678,9 @@ class DOMLocalization extends Localization {
|
|||
this.pauseObserving();
|
||||
|
||||
for (let i = 0; i < elements.length; i++) {
|
||||
overlayElement(elements[i], translations[i]);
|
||||
if (translations[i] !== undefined) {
|
||||
overlayElement(elements[i], translations[i]);
|
||||
}
|
||||
}
|
||||
|
||||
this.resumeObserving();
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm", {});
|
||||
const { L10nRegistry } = ChromeUtils.import("resource://gre/modules/L10nRegistry.jsm", {});
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm", {});
|
||||
const { AppConstants } = ChromeUtils.import("resource://gre/modules/AppConstants.jsm", {});
|
||||
|
||||
/*
|
||||
* CachedIterable caches the elements yielded by an iterable.
|
||||
|
@ -91,24 +92,6 @@ class CachedIterable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Specialized version of an Error used to indicate errors that are result
|
||||
* of a problem during the localization process.
|
||||
*
|
||||
* We use them to identify the class of errors the require a fallback
|
||||
* mechanism to be triggered vs errors that should be reported, but
|
||||
* do not prevent the message from being used.
|
||||
*
|
||||
* An example of an L10nError is a missing entry.
|
||||
*/
|
||||
class L10nError extends Error {
|
||||
constructor(message) {
|
||||
super();
|
||||
this.name = "L10nError";
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The default localization strategy for Gecko. It comabines locales
|
||||
* available in L10nRegistry, with locales requested by the user to
|
||||
* generate the iterator over MessageContexts.
|
||||
|
@ -156,17 +139,26 @@ class Localization {
|
|||
*/
|
||||
async formatWithFallback(keys, method) {
|
||||
const translations = [];
|
||||
|
||||
for await (let ctx of this.ctxs) {
|
||||
// This can operate on synchronous and asynchronous
|
||||
// contexts coming from the iterator.
|
||||
if (typeof ctx.then === "function") {
|
||||
ctx = await ctx;
|
||||
}
|
||||
const errors = keysFromContext(method, ctx, keys, translations);
|
||||
if (!errors) {
|
||||
const missingIds = keysFromContext(method, ctx, keys, translations);
|
||||
|
||||
if (missingIds.size === 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (AppConstants.NIGHTLY_BUILD) {
|
||||
const locale = ctx.locales[0];
|
||||
const ids = Array.from(missingIds).join(", ");
|
||||
console.warn(`Missing translations in ${locale}: ${ids}`);
|
||||
}
|
||||
}
|
||||
|
||||
return translations;
|
||||
}
|
||||
|
||||
|
@ -312,11 +304,6 @@ Localization.prototype.QueryInterface = XPCOMUtils.generateQI([
|
|||
function valueFromContext(ctx, errors, id, args) {
|
||||
const msg = ctx.getMessage(id);
|
||||
|
||||
if (msg === undefined) {
|
||||
errors.push(new L10nError(`Unknown entity: ${id}`));
|
||||
return id;
|
||||
}
|
||||
|
||||
return ctx.format(msg, args, errors);
|
||||
}
|
||||
|
||||
|
@ -345,11 +332,6 @@ function valueFromContext(ctx, errors, id, args) {
|
|||
function messageFromContext(ctx, errors, id, args) {
|
||||
const msg = ctx.getMessage(id);
|
||||
|
||||
if (msg === undefined) {
|
||||
errors.push(new L10nError(`Unknown message: ${id}`));
|
||||
return { value: id, attrs: null };
|
||||
}
|
||||
|
||||
const formatted = {
|
||||
value: ctx.format(msg, args, errors),
|
||||
attrs: null,
|
||||
|
@ -357,13 +339,10 @@ function messageFromContext(ctx, errors, id, args) {
|
|||
|
||||
if (msg.attrs) {
|
||||
formatted.attrs = [];
|
||||
for (const attrName in msg.attrs) {
|
||||
const formattedAttr = ctx.format(msg.attrs[attrName], args, errors);
|
||||
if (formattedAttr !== null) {
|
||||
formatted.attrs.push([
|
||||
attrName,
|
||||
formattedAttr
|
||||
]);
|
||||
for (const name in msg.attrs) {
|
||||
const value = ctx.format(msg.attrs[name], args, errors);
|
||||
if (value !== null) {
|
||||
formatted.attrs.push({ name, value });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -375,7 +354,7 @@ function messageFromContext(ctx, errors, id, args) {
|
|||
* This function is an inner function for `Localization.formatWithFallback`.
|
||||
*
|
||||
* It takes a `MessageContext`, list of l10n-ids and a method to be used for
|
||||
* key resolution (either `valueFromContext` or `entityFromContext`) and
|
||||
* key resolution (either `valueFromContext` or `messageFromContext`) and
|
||||
* optionally a value returned from `keysFromContext` executed against
|
||||
* another `MessageContext`.
|
||||
*
|
||||
|
@ -390,8 +369,8 @@ function messageFromContext(ctx, errors, id, args) {
|
|||
* we return it. If it does, we'll try to resolve the key using the passed
|
||||
* `MessageContext`.
|
||||
*
|
||||
* In the end, we fill the translations array, and return if we
|
||||
* encountered at least one error.
|
||||
* In the end, we fill the translations array, and return the Set with
|
||||
* missing ids.
|
||||
*
|
||||
* See `Localization.formatWithFallback` for more info on how this is used.
|
||||
*
|
||||
|
@ -400,34 +379,28 @@ function messageFromContext(ctx, errors, id, args) {
|
|||
* @param {Array<string>} keys
|
||||
* @param {{Array<{value: string, attrs: Object}>}} translations
|
||||
*
|
||||
* @returns {Boolean}
|
||||
* @returns {Set<string>}
|
||||
* @private
|
||||
*/
|
||||
function keysFromContext(method, ctx, keys, translations) {
|
||||
const messageErrors = [];
|
||||
let hasErrors = false;
|
||||
const missingIds = new Set();
|
||||
|
||||
keys.forEach((key, i) => {
|
||||
if (translations[i] !== undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
messageErrors.length = 0;
|
||||
const translation = method(ctx, messageErrors, key[0], key[1]);
|
||||
|
||||
if (messageErrors.length === 0 ||
|
||||
!messageErrors.some(e => e instanceof L10nError)) {
|
||||
translations[i] = translation;
|
||||
if (ctx.hasMessage(key[0])) {
|
||||
messageErrors.length = 0;
|
||||
translations[i] = method(ctx, messageErrors, key[0], key[1]);
|
||||
// XXX: Report resolver errors
|
||||
} else {
|
||||
hasErrors = true;
|
||||
}
|
||||
|
||||
if (messageErrors.length) {
|
||||
messageErrors.forEach(error => console.warn(error));
|
||||
missingIds.add(key[0]);
|
||||
}
|
||||
});
|
||||
|
||||
return hasErrors;
|
||||
return missingIds;
|
||||
}
|
||||
|
||||
this.Localization = Localization;
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
[dom/test_domloc_attr_sanitized.html]
|
||||
[dom/test_domloc_getAttributes.html]
|
||||
[dom/test_domloc_setAttributes.html]
|
||||
[dom/test_domloc_translateElements.html]
|
||||
[dom/test_domloc_translateFragment.html]
|
||||
[dom/test_domloc_connectRoot.html]
|
||||
[dom/test_domloc_disconnectRoot.html]
|
||||
[dom/test_domloc_repeated_l10nid.html]
|
||||
[dom/test_domloc_translateRoots.html]
|
||||
[dom/test_domloc_mutations.html]
|
||||
[dom/test_domloc_overlay.html]
|
||||
[dom/test_domloc_overlay_repeated.html]
|
||||
[dom/test_domloc_overlay_missing_all.html]
|
||||
[dom/test_domloc_overlay_missing_children.html]
|
||||
[dom/test_domloc_overlay_sanitized.html]
|
||||
[dom/test_domloc.xul]
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test DOMLocalization's attr sanitization functionality</title>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
|
||||
<script type="application/javascript">
|
||||
"use strict";
|
||||
const { DOMLocalization } =
|
||||
ChromeUtils.import("resource://gre/modules/DOMLocalization.jsm", {});
|
||||
const { MessageContext } =
|
||||
ChromeUtils.import("resource://gre/modules/MessageContext.jsm", {});
|
||||
|
||||
async function* mockGenerateMessages(locales, resourceIds) {
|
||||
const mc = new MessageContext(locales);
|
||||
mc.addMessages(`
|
||||
key1 = Value for Key 1
|
||||
|
||||
key2 = Value for <a>Key 2<a/>.
|
||||
`);
|
||||
yield mc;
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(async () => {
|
||||
const domLoc = new DOMLocalization(
|
||||
window,
|
||||
[],
|
||||
mockGenerateMessages
|
||||
);
|
||||
|
||||
await domLoc.translateFragment(document.body);
|
||||
|
||||
const elem1 = document.querySelector("#elem1");
|
||||
const elem2 = document.querySelector("#elem2");
|
||||
|
||||
ok(elem1.textContent.includes("Value for"));
|
||||
// This is a limitation of us using Node.localize API
|
||||
// Documenting it here to make sure we notice when we fix it
|
||||
is(elem1.getAttribute("title"), "Old Translation");
|
||||
|
||||
ok(elem2.textContent.includes("Value for"));
|
||||
ok(!elem2.hasAttribute("title"));
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<p id="elem1" title="Old Translation" data-l10n-id="key1"></p>
|
||||
<p id="elem2" title="Old Translation" data-l10n-id="key2"></p>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,46 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test DOMLocalization's DOMOverlay functionality</title>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
|
||||
<script type="application/javascript">
|
||||
"use strict";
|
||||
const { DOMLocalization } =
|
||||
ChromeUtils.import("resource://gre/modules/DOMLocalization.jsm", {});
|
||||
const { MessageContext } =
|
||||
ChromeUtils.import("resource://gre/modules/MessageContext.jsm", {});
|
||||
|
||||
async function* mockGenerateMessages(locales, resourceIds) {
|
||||
const mc = new MessageContext(locales);
|
||||
// No translations!
|
||||
yield mc;
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(async () => {
|
||||
|
||||
const domLoc = new DOMLocalization(
|
||||
window,
|
||||
[],
|
||||
mockGenerateMessages
|
||||
);
|
||||
|
||||
await domLoc.translateFragment(document.body);
|
||||
|
||||
// we just care that it doesn't throw here.
|
||||
ok(1);
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<p data-l10n-id="title">
|
||||
<a href="http://www.mozilla.org"></a>
|
||||
<a href="http://www.firefox.com"></a>
|
||||
<a href="http://www.w3.org"></a>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,55 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test DOMLocalization's DOMOverlay functionality</title>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
|
||||
<script type="application/javascript">
|
||||
"use strict";
|
||||
const { DOMLocalization } =
|
||||
ChromeUtils.import("resource://gre/modules/DOMLocalization.jsm", {});
|
||||
const { MessageContext } =
|
||||
ChromeUtils.import("resource://gre/modules/MessageContext.jsm", {});
|
||||
|
||||
async function* mockGenerateMessages(locales, resourceIds) {
|
||||
const mc = new MessageContext(locales);
|
||||
mc.addMessages(`
|
||||
key1 =
|
||||
.href = https://www.hacked.com
|
||||
|
||||
key2 =
|
||||
.href = https://pl.wikipedia.org
|
||||
`);
|
||||
yield mc;
|
||||
}
|
||||
|
||||
async function test() {
|
||||
const domLoc = new DOMLocalization(
|
||||
window,
|
||||
[],
|
||||
mockGenerateMessages
|
||||
);
|
||||
|
||||
await domLoc.translateFragment(document.body);
|
||||
|
||||
const key1Elem = document.querySelector("[data-l10n-id=key1]");
|
||||
const key2Elem = document.querySelector("[data-l10n-id=key2]");
|
||||
|
||||
|
||||
is(key1Elem.hasAttribute("href"), false, "href translation should not be allowed");
|
||||
is(key2Elem.getAttribute("href"), "https://pl.wikipedia.org",
|
||||
"href translation should be allowed");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(test);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a data-l10n-id="key1"></a>
|
||||
<a data-l10n-id="key2" data-l10n-attrs="href"></a>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,63 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test DOMLocalization's matching l10nIds functionality</title>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
|
||||
<script type="application/javascript">
|
||||
"use strict";
|
||||
const { DOMLocalization } =
|
||||
ChromeUtils.import("resource://gre/modules/DOMLocalization.jsm", {});
|
||||
const { MessageContext } =
|
||||
ChromeUtils.import("resource://gre/modules/MessageContext.jsm", {});
|
||||
|
||||
async function* mockGenerateMessages(locales, resourceIds) {
|
||||
const mc = new MessageContext(locales);
|
||||
mc.addMessages(`
|
||||
key1 = Translation For Key 1
|
||||
|
||||
key2 = Visit <a>this link<a/>.
|
||||
`);
|
||||
yield mc;
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(async () => {
|
||||
const domLoc = new DOMLocalization(
|
||||
window,
|
||||
[],
|
||||
mockGenerateMessages
|
||||
);
|
||||
|
||||
await domLoc.translateFragment(document.body);
|
||||
|
||||
ok(document.querySelector("#elem1").textContent.includes("Key 1"));
|
||||
ok(document.querySelector("#elem2").textContent.includes("Key 1"));
|
||||
|
||||
const elem3 = document.querySelector("#elem3");
|
||||
const elem4 = document.querySelector("#elem4");
|
||||
|
||||
ok(elem3.textContent.includes("Visit"));
|
||||
is(elem3.querySelector("a").getAttribute("href"), "http://www.mozilla.org");
|
||||
|
||||
ok(elem4.textContent.includes("Visit"));
|
||||
is(elem4.querySelector("a").getAttribute("href"), "http://www.firefox.com");
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="elem1" data-l10n-id="key1"></h1>
|
||||
<h2 id="elem2" data-l10n-id="key1"></h2>
|
||||
|
||||
<p id="elem3" data-l10n-id="key2">
|
||||
<a href="http://www.mozilla.org"></a>
|
||||
</p>
|
||||
|
||||
<p id="elem4" data-l10n-id="key2">
|
||||
<a href="http://www.firefox.com"></a>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
|
@ -3747,7 +3747,7 @@ PresShell::ScheduleViewManagerFlush(PaintType aType)
|
|||
SetNeedLayoutFlush();
|
||||
}
|
||||
|
||||
bool
|
||||
static bool
|
||||
FlushLayoutRecursive(nsIDocument* aDocument,
|
||||
void* aData = nullptr)
|
||||
{
|
||||
|
@ -6740,7 +6740,8 @@ PresShell::RecordMouseLocation(WidgetGUIEvent* aEvent)
|
|||
}
|
||||
}
|
||||
|
||||
nsIFrame* GetNearestFrameContainingPresShell(nsIPresShell* aPresShell)
|
||||
static nsIFrame*
|
||||
GetNearestFrameContainingPresShell(nsIPresShell* aPresShell)
|
||||
{
|
||||
nsView* view = aPresShell->GetViewManager()->GetRootView();
|
||||
while (view && !view->GetFrame()) {
|
||||
|
|
|
@ -850,7 +850,7 @@ GetFrameForChildrenOnlyTransformHint(nsIFrame* aFrame)
|
|||
// Returns true if this function managed to successfully move a frame, and
|
||||
// false if it could not process the position change, and a reflow should
|
||||
// be performed instead.
|
||||
bool
|
||||
static bool
|
||||
RecomputePosition(nsIFrame* aFrame)
|
||||
{
|
||||
// Don't process position changes on table frames, since we already handle
|
||||
|
|
|
@ -176,7 +176,7 @@ ZoomConstraintsClient::ScreenSizeChanged()
|
|||
RefreshZoomConstraints();
|
||||
}
|
||||
|
||||
mozilla::layers::ZoomConstraints
|
||||
static mozilla::layers::ZoomConstraints
|
||||
ComputeZoomConstraintsFromViewportInfo(const nsViewportInfo& aViewportInfo)
|
||||
{
|
||||
mozilla::layers::ZoomConstraints constraints;
|
||||
|
|
|
@ -91,8 +91,9 @@ public:
|
|||
};
|
||||
|
||||
// Print the name of the state for debugging.
|
||||
::std::ostream& operator<<(::std::ostream& aOstream,
|
||||
const MockAccessibleCaretEventHub::State* aState)
|
||||
static ::std::ostream&
|
||||
operator<<(::std::ostream& aOstream,
|
||||
const MockAccessibleCaretEventHub::State* aState)
|
||||
{
|
||||
return aOstream << aState->Name();
|
||||
}
|
||||
|
|
|
@ -92,7 +92,9 @@ nsLayoutDebugger::GetShowEventTargetFrameBorder(bool* aResult)
|
|||
|
||||
#endif
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const nsPrintfCString& rhs) {
|
||||
static std::ostream&
|
||||
operator<<(std::ostream& os, const nsPrintfCString& rhs)
|
||||
{
|
||||
os << rhs.get();
|
||||
return os;
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
#include "mozilla/Preferences.h"
|
||||
#include "nsFrameSelection.h"
|
||||
#include "FrameLayerBuilder.h"
|
||||
#include "mozilla/layers/APZCTreeManager.h"
|
||||
#include "mozilla/layers/APZUtils.h" // for apz::CalculatePendingDisplayPort
|
||||
#include "mozilla/layers/CompositorBridgeChild.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
|
@ -833,7 +833,7 @@ nsLayoutUtils::FindContentFor(ViewID aId)
|
|||
}
|
||||
}
|
||||
|
||||
nsIFrame*
|
||||
static nsIFrame*
|
||||
GetScrollFrameFromContent(nsIContent* aContent)
|
||||
{
|
||||
nsIFrame* frame = aContent->GetPrimaryFrame();
|
||||
|
@ -1316,7 +1316,7 @@ GetDisplayPortImpl(nsIContent* aContent, nsRect* aResult, float aMultiplier,
|
|||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
TranslateFromScrollPortToScrollFrame(nsIContent* aContent, nsRect* aRect)
|
||||
{
|
||||
MOZ_ASSERT(aRect);
|
||||
|
@ -3421,7 +3421,7 @@ nsLayoutUtils::CalculateAndSetDisplayPortMargins(nsIScrollableFrame* aScrollFram
|
|||
MOZ_ASSERT(content);
|
||||
|
||||
FrameMetrics metrics = CalculateBasicFrameMetrics(aScrollFrame);
|
||||
ScreenMargin displayportMargins = APZCTreeManager::CalculatePendingDisplayPort(
|
||||
ScreenMargin displayportMargins = apz::CalculatePendingDisplayPort(
|
||||
metrics, ParentLayerPoint(0.0f, 0.0f));
|
||||
nsIPresShell* presShell = frame->PresContext()->GetPresShell();
|
||||
return nsLayoutUtils::SetDisplayPortMargins(
|
||||
|
|
|
@ -117,7 +117,7 @@ nsContentDLF::~nsContentDLF()
|
|||
NS_IMPL_ISUPPORTS(nsContentDLF,
|
||||
nsIDocumentLoaderFactory)
|
||||
|
||||
bool
|
||||
static bool
|
||||
MayUseXULXBL(nsIChannel* aChannel)
|
||||
{
|
||||
nsIScriptSecurityManager *securityManager =
|
||||
|
|
|
@ -265,8 +265,7 @@ static bool gInitialized = false;
|
|||
|
||||
// Perform our one-time intialization for this module
|
||||
|
||||
// static
|
||||
nsresult
|
||||
static nsresult
|
||||
Initialize()
|
||||
{
|
||||
if (gInitialized) {
|
||||
|
|
|
@ -1979,7 +1979,7 @@ ReflowInput::InitAbsoluteConstraints(nsPresContext* aPresContext,
|
|||
|
||||
// This will not be converted to abstract coordinates because it's only
|
||||
// used in CalcQuirkContainingBlockHeight
|
||||
nscoord
|
||||
static nscoord
|
||||
GetBlockMarginBorderPadding(const ReflowInput* aReflowInput)
|
||||
{
|
||||
nscoord result = 0;
|
||||
|
|
|
@ -1072,7 +1072,7 @@ BuildStrutInfoFromCollapsedItems(const FlexLine* aFirstLine,
|
|||
}
|
||||
}
|
||||
|
||||
uint8_t
|
||||
static uint8_t
|
||||
SimplifyAlignOrJustifyContentForOneItem(uint16_t aAlignmentVal,
|
||||
bool aIsAlign)
|
||||
{
|
||||
|
@ -2320,7 +2320,7 @@ nsFlexContainerFrame::GetLogicalBaseline(mozilla::WritingMode aWM) const
|
|||
// normal flow, except that 'z-index' values other than 'auto' create
|
||||
// a stacking context even if 'position' is 'static'.
|
||||
// http://www.w3.org/TR/2012/CR-css3-flexbox-20120918/#painting
|
||||
uint32_t
|
||||
static uint32_t
|
||||
GetDisplayFlagsForFlexItem(nsIFrame* aFrame)
|
||||
{
|
||||
MOZ_ASSERT(aFrame->IsFlexItem(), "Should only be called on flex items");
|
||||
|
|
|
@ -5064,8 +5064,8 @@ static FrameTarget GetSelectionClosestFrame(nsIFrame* aFrame,
|
|||
return FrameTarget(aFrame, false, false);
|
||||
}
|
||||
|
||||
nsIFrame::ContentOffsets OffsetsForSingleFrame(nsIFrame* aFrame,
|
||||
const nsPoint& aPoint)
|
||||
static nsIFrame::ContentOffsets
|
||||
OffsetsForSingleFrame(nsIFrame* aFrame, const nsPoint& aPoint)
|
||||
{
|
||||
nsIFrame::ContentOffsets offsets;
|
||||
FrameContentRange range = GetRangeForFrame(aFrame);
|
||||
|
@ -6990,7 +6990,7 @@ static void InvalidateRenderingObservers(nsIFrame* aDisplayRoot, nsIFrame* aFram
|
|||
aFrame->MarkNeedsDisplayItemRebuild();
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
SchedulePaintInternal(nsIFrame* aDisplayRoot, nsIFrame* aFrame,
|
||||
nsIFrame::PaintType aType = nsIFrame::PAINT_DEFAULT)
|
||||
{
|
||||
|
|
|
@ -871,7 +871,7 @@ GetBrowserRoot(nsIContent* aContent)
|
|||
// scrollable overflow by determining the scroll position at which the child
|
||||
// becomes completely visible within the scrollport rather than using the union
|
||||
// of the overflow areas at their current position.
|
||||
void
|
||||
static void
|
||||
GetScrollableOverflowForPerspective(nsIFrame* aScrolledFrame,
|
||||
nsIFrame* aCurrentFrame,
|
||||
const nsRect aScrollPort,
|
||||
|
@ -2531,7 +2531,7 @@ bool ScrollFrameHelper::IsAlwaysActive() const
|
|||
styles.mVertical != NS_STYLE_OVERFLOW_HIDDEN);
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
static void
|
||||
RemoveDisplayPortCallback(nsITimer* aTimer, void* aClosure)
|
||||
{
|
||||
ScrollFrameHelper* helper = static_cast<ScrollFrameHelper*>(aClosure);
|
||||
|
@ -6315,7 +6315,7 @@ nsIScrollableFrame::GetPerceivedScrollingDirections() const
|
|||
* Collect the scroll-snap-coordinates of frames in the subtree rooted at
|
||||
* |aFrame|, relative to |aScrolledFrame|, into |aOutCoords|.
|
||||
*/
|
||||
void
|
||||
static void
|
||||
CollectScrollSnapCoordinates(nsIFrame* aFrame, nsIFrame* aScrolledFrame,
|
||||
nsTArray<nsPoint>& aOutCoords)
|
||||
{
|
||||
|
@ -6356,7 +6356,7 @@ CollectScrollSnapCoordinates(nsIFrame* aFrame, nsIFrame* aScrolledFrame,
|
|||
}
|
||||
}
|
||||
|
||||
layers::ScrollSnapInfo
|
||||
static layers::ScrollSnapInfo
|
||||
ComputeScrollSnapInfo(const ScrollFrameHelper& aScrollFrame)
|
||||
{
|
||||
ScrollSnapInfo result;
|
||||
|
|
|
@ -440,8 +440,9 @@ nsSimplePageSequenceFrame::StartPrint(nsPresContext* aPresContext,
|
|||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
GetPrintCanvasElementsInFrame(nsIFrame* aFrame, nsTArray<RefPtr<HTMLCanvasElement> >* aArr)
|
||||
static void
|
||||
GetPrintCanvasElementsInFrame(nsIFrame* aFrame,
|
||||
nsTArray<RefPtr<HTMLCanvasElement> >* aArr)
|
||||
{
|
||||
if (!aFrame) {
|
||||
return;
|
||||
|
|
|
@ -5539,7 +5539,7 @@ struct EmphasisMarkInfo
|
|||
|
||||
NS_DECLARE_FRAME_PROPERTY_DELETABLE(EmphasisMarkProperty, EmphasisMarkInfo)
|
||||
|
||||
already_AddRefed<gfxTextRun>
|
||||
static already_AddRefed<gfxTextRun>
|
||||
GenerateTextRunForEmphasisMarks(nsTextFrame* aFrame,
|
||||
nsFontMetrics* aFontMetrics,
|
||||
nsStyleContext* aStyleContext,
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/TabChild.h"
|
||||
#include "mozilla/dom/TabParent.h"
|
||||
#include "mozilla/layers/APZCTreeManager.h"
|
||||
#include "mozilla/layers/APZThreadUtils.h"
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
#include "mozilla/layers/LayerTransactionParent.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
@ -76,7 +74,7 @@ IsTempLayerManager(LayerManager* aManager)
|
|||
!static_cast<BasicLayerManager*>(aManager)->IsRetained());
|
||||
}
|
||||
|
||||
already_AddRefed<LayerManager>
|
||||
static already_AddRefed<LayerManager>
|
||||
GetLayerManager(nsFrameLoader* aFrameLoader)
|
||||
{
|
||||
if (nsIContent* content = aFrameLoader->GetOwnerContent()) {
|
||||
|
|
|
@ -246,7 +246,7 @@ NS_IMPL_ISUPPORTS(nsMathMLmactionFrame::MouseListener,
|
|||
|
||||
// helper to show a msg on the status bar
|
||||
// curled from nsPluginFrame.cpp ...
|
||||
void
|
||||
static void
|
||||
ShowStatus(nsPresContext* aPresContext, nsString& aStatusMsg)
|
||||
{
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShellItem(aPresContext->GetDocShell());
|
||||
|
|
|
@ -185,8 +185,9 @@ DisplayItemClip::ApproximateIntersectInward(const nsRect& aRect) const
|
|||
|
||||
// Test if (aXPoint, aYPoint) is in the ellipse with center (aXCenter, aYCenter)
|
||||
// and radii aXRadius, aYRadius.
|
||||
bool IsInsideEllipse(nscoord aXRadius, nscoord aXCenter, nscoord aXPoint,
|
||||
nscoord aYRadius, nscoord aYCenter, nscoord aYPoint)
|
||||
static bool
|
||||
IsInsideEllipse(nscoord aXRadius, nscoord aXCenter, nscoord aXPoint,
|
||||
nscoord aYRadius, nscoord aYCenter, nscoord aYPoint)
|
||||
{
|
||||
float scaledX = float(aXPoint - aXCenter) / float(aXRadius);
|
||||
float scaledY = float(aYPoint - aYCenter) / float(aYRadius);
|
||||
|
|
|
@ -1838,7 +1838,8 @@ private:
|
|||
RefPtr<TextureClient> mTextureClient;
|
||||
};
|
||||
|
||||
PaintedDisplayItemLayerUserData* GetPaintedDisplayItemLayerUserData(Layer* aLayer)
|
||||
static PaintedDisplayItemLayerUserData*
|
||||
GetPaintedDisplayItemLayerUserData(Layer* aLayer)
|
||||
{
|
||||
return static_cast<PaintedDisplayItemLayerUserData*>(
|
||||
aLayer->GetUserData(&gPaintedDisplayItemLayerUserData));
|
||||
|
@ -1891,7 +1892,8 @@ FrameLayerBuilder::GetDisplayItemData(nsIFrame* aFrame, uint32_t aKey)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
nsACString&
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
static nsACString&
|
||||
AppendToString(nsACString& s, const nsIntRect& r,
|
||||
const char* pfx="", const char* sfx="")
|
||||
{
|
||||
|
@ -1902,7 +1904,7 @@ AppendToString(nsACString& s, const nsIntRect& r,
|
|||
return s += sfx;
|
||||
}
|
||||
|
||||
nsACString&
|
||||
static nsACString&
|
||||
AppendToString(nsACString& s, const nsIntRegion& r,
|
||||
const char* pfx="", const char* sfx="")
|
||||
{
|
||||
|
@ -1916,6 +1918,7 @@ AppendToString(nsACString& s, const nsIntRegion& r,
|
|||
|
||||
return s += sfx;
|
||||
}
|
||||
#endif // MOZ_DUMP_PAINTING
|
||||
|
||||
/**
|
||||
* Invalidate aRegion in aLayer. aLayer is in the coordinate system
|
||||
|
@ -4038,7 +4041,7 @@ GetASRForPerspective(const ActiveScrolledRoot* aASR, nsIFrame* aPerspectiveFrame
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
CSSMaskLayerUserData*
|
||||
static CSSMaskLayerUserData*
|
||||
GetCSSMaskLayerUserData(Layer* aMaskLayer)
|
||||
{
|
||||
if (!aMaskLayer) {
|
||||
|
@ -4048,7 +4051,7 @@ GetCSSMaskLayerUserData(Layer* aMaskLayer)
|
|||
return static_cast<CSSMaskLayerUserData*>(aMaskLayer->GetUserData(&gCSSMaskLayerUserData));
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
SetCSSMaskLayerUserData(Layer* aMaskLayer)
|
||||
{
|
||||
MOZ_ASSERT(aMaskLayer);
|
||||
|
@ -5132,8 +5135,9 @@ FindOpaqueRegionEntry(nsTArray<OpaqueRegionEntry>& aEntries,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
const ActiveScrolledRoot*
|
||||
FindDirectChildASR(const ActiveScrolledRoot* aParent, const ActiveScrolledRoot* aDescendant)
|
||||
static const ActiveScrolledRoot*
|
||||
FindDirectChildASR(const ActiveScrolledRoot* aParent,
|
||||
const ActiveScrolledRoot* aDescendant)
|
||||
{
|
||||
MOZ_ASSERT(aDescendant, "can't start at the root when looking for a child");
|
||||
MOZ_ASSERT(ActiveScrolledRoot::IsAncestor(aParent, aDescendant));
|
||||
|
@ -6361,7 +6365,7 @@ ContainerState::SetupMaskLayer(Layer *aLayer,
|
|||
return aRoundedRectClipCount;
|
||||
}
|
||||
|
||||
MaskLayerUserData*
|
||||
static MaskLayerUserData*
|
||||
GetMaskLayerUserData(Layer* aMaskLayer)
|
||||
{
|
||||
if (!aMaskLayer) {
|
||||
|
@ -6371,7 +6375,7 @@ GetMaskLayerUserData(Layer* aMaskLayer)
|
|||
return static_cast<MaskLayerUserData*>(aMaskLayer->GetUserData(&gMaskLayerUserData));
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
SetMaskLayerUserData(Layer* aMaskLayer)
|
||||
{
|
||||
MOZ_ASSERT(aMaskLayer);
|
||||
|
|
|
@ -40,7 +40,8 @@
|
|||
|
||||
using namespace mozilla;
|
||||
|
||||
void MarkFramesWithItemsAndImagesModified(nsDisplayList* aList)
|
||||
static void
|
||||
MarkFramesWithItemsAndImagesModified(nsDisplayList* aList)
|
||||
{
|
||||
for (nsDisplayItem* i = aList->GetBottom(); i != nullptr; i = i->GetAbove()) {
|
||||
if (!i->HasDeletedFrame() && i->CanBeReused() && !i->Frame()->IsFrameModified()) {
|
||||
|
@ -69,7 +70,8 @@ void MarkFramesWithItemsAndImagesModified(nsDisplayList* aList)
|
|||
}
|
||||
}
|
||||
|
||||
bool IsAnyAncestorModified(nsIFrame* aFrame)
|
||||
static bool
|
||||
IsAnyAncestorModified(nsIFrame* aFrame)
|
||||
{
|
||||
nsIFrame* f = aFrame;
|
||||
while (f) {
|
||||
|
@ -146,7 +148,8 @@ RetainedDisplayListBuilder::PreProcessDisplayList(nsDisplayList* aList,
|
|||
return modified;
|
||||
}
|
||||
|
||||
bool IsSameItem(nsDisplayItem* aFirst, nsDisplayItem* aSecond)
|
||||
static bool
|
||||
IsSameItem(nsDisplayItem* aFirst, nsDisplayItem* aSecond)
|
||||
{
|
||||
if (!aFirst || !aSecond) {
|
||||
return aFirst == aSecond;
|
||||
|
@ -309,8 +312,9 @@ RetainedDisplayListBuilder::IncrementSubDocPresShellPaintCount(nsDisplayItem* aI
|
|||
mBuilder.IncrementPresShellPaintCount(presShell);
|
||||
}
|
||||
|
||||
void UpdateASR(nsDisplayItem* aItem,
|
||||
Maybe<const ActiveScrolledRoot*>& aContainerASR)
|
||||
static void
|
||||
UpdateASR(nsDisplayItem* aItem,
|
||||
Maybe<const ActiveScrolledRoot*>& aContainerASR)
|
||||
{
|
||||
if (!aContainerASR) {
|
||||
return;
|
||||
|
|
|
@ -787,7 +787,7 @@ nsCSSRendering::CreateWebRenderCommandsForBorder(nsDisplayItem* aItem,
|
|||
return true;
|
||||
}
|
||||
|
||||
nsCSSBorderRenderer
|
||||
static nsCSSBorderRenderer
|
||||
ConstructBorderRenderer(nsPresContext* aPresContext,
|
||||
nsStyleContext* aStyleContext,
|
||||
DrawTarget* aDrawTarget,
|
||||
|
|
|
@ -2618,7 +2618,8 @@ nsCSSBorderRenderer::AllBordersSolid()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool IsVisible(int aStyle)
|
||||
static bool
|
||||
IsVisible(int aStyle)
|
||||
{
|
||||
if (aStyle != NS_STYLE_BORDER_STYLE_NONE &&
|
||||
aStyle != NS_STYLE_BORDER_STYLE_HIDDEN) {
|
||||
|
|
|
@ -2898,7 +2898,8 @@ struct FramesWithDepth
|
|||
};
|
||||
|
||||
// Sort the frames by depth and then moves all the contained frames to the destination
|
||||
void FlushFramesArray(nsTArray<FramesWithDepth>& aSource, nsTArray<nsIFrame*>* aDest)
|
||||
static void
|
||||
FlushFramesArray(nsTArray<FramesWithDepth>& aSource, nsTArray<nsIFrame*>* aDest)
|
||||
{
|
||||
if (aSource.IsEmpty()) {
|
||||
return;
|
||||
|
@ -3607,7 +3608,7 @@ static nsIFrame* GetBackgroundStyleContextFrame(nsIFrame* aFrame)
|
|||
return f;
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
static void
|
||||
SetBackgroundClipRegion(DisplayListClipState::AutoSaveRestore& aClipState,
|
||||
nsIFrame* aFrame, const nsPoint& aToReferenceFrame,
|
||||
const nsStyleImageLayers::Layer& aLayer,
|
||||
|
|
|
@ -317,7 +317,8 @@ IsRenderNoImages(uint32_t aDisplayItemKey)
|
|||
return flags & TYPE_RENDERS_NO_IMAGES;
|
||||
}
|
||||
|
||||
void InvalidateImages(nsIFrame* aFrame)
|
||||
static void
|
||||
InvalidateImages(nsIFrame* aFrame)
|
||||
{
|
||||
bool invalidateFrame = false;
|
||||
const SmallPointerArray<DisplayItemData>& array = aFrame->DisplayItemData();
|
||||
|
|
|
@ -441,7 +441,7 @@ Gecko_UnsetDirtyStyleAttr(RawGeckoElementBorrowed aElement)
|
|||
decl->UnsetDirty();
|
||||
}
|
||||
|
||||
const RawServoDeclarationBlockStrong*
|
||||
static const RawServoDeclarationBlockStrong*
|
||||
AsRefRawStrong(const RefPtr<RawServoDeclarationBlock>& aDecl)
|
||||
{
|
||||
static_assert(sizeof(RefPtr<RawServoDeclarationBlock>) ==
|
||||
|
|
|
@ -464,7 +464,7 @@ CalcValueToCSSValue(const PixelCalcValue& aCalc, nsCSSValue& aValue)
|
|||
aValue.SetArrayValue(arr, eCSSUnit_Calc);
|
||||
}
|
||||
|
||||
double
|
||||
static double
|
||||
CalcPositionSquareDistance(const nsCSSValue& aPos1,
|
||||
const nsCSSValue& aPos2)
|
||||
{
|
||||
|
@ -520,7 +520,7 @@ CalcBackgroundCoord(const nsCSSValue& aCoord)
|
|||
return ExtractCalcValue(array->Item(1));
|
||||
}
|
||||
|
||||
double
|
||||
static double
|
||||
CalcPositionCoordSquareDistance(const nsCSSValue& aPos1,
|
||||
const nsCSSValue& aPos2)
|
||||
{
|
||||
|
@ -2031,7 +2031,7 @@ AddWeightedColorsAndClamp(double aCoeff1, const RGBAColorData& aValue1,
|
|||
: AddWeightedColors(aCoeff1, aValue1, aCoeff2, aValue2).ToColor();
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
AppendToCSSValueList(UniquePtr<nsCSSValueList>& aHead,
|
||||
UniquePtr<nsCSSValueList>&& aValueToAppend,
|
||||
nsCSSValueList** aTail)
|
||||
|
@ -2047,7 +2047,7 @@ AppendToCSSValueList(UniquePtr<nsCSSValueList>& aHead,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
AppendToCSSValuePairList(UniquePtr<nsCSSValuePairList>& aHead,
|
||||
UniquePtr<nsCSSValuePairList>&& aValueToAppend,
|
||||
nsCSSValuePairList** aTail)
|
||||
|
@ -3419,7 +3419,7 @@ StyleAnimationValue::Accumulate(nsCSSPropertyID aProperty,
|
|||
return result;
|
||||
}
|
||||
|
||||
already_AddRefed<css::StyleRule>
|
||||
static already_AddRefed<css::StyleRule>
|
||||
BuildStyleRule(nsCSSPropertyID aProperty,
|
||||
dom::Element* aTargetElement,
|
||||
const nsAString& aSpecifiedValue,
|
||||
|
@ -3454,7 +3454,7 @@ BuildStyleRule(nsCSSPropertyID aProperty,
|
|||
return rule.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<css::StyleRule>
|
||||
static already_AddRefed<css::StyleRule>
|
||||
BuildStyleRule(nsCSSPropertyID aProperty,
|
||||
dom::Element* aTargetElement,
|
||||
const nsCSSValue& aSpecifiedValue,
|
||||
|
|
|
@ -161,7 +161,7 @@ static nsCSSPropertyID gAliases[eCSSAliasCount != 0 ? eCSSAliasCount : 1] = {
|
|||
#undef CSS_PROP_ALIAS
|
||||
};
|
||||
|
||||
nsStaticCaseInsensitiveNameTable*
|
||||
static nsStaticCaseInsensitiveNameTable*
|
||||
CreateStaticTable(const char* const aRawTable[], int32_t aLength)
|
||||
{
|
||||
auto table = new nsStaticCaseInsensitiveNameTable(aRawTable, aLength);
|
||||
|
|
|
@ -37,22 +37,22 @@ static uint8_t sWinThemeId = LookAndFeel::eWindowsTheme_Generic;
|
|||
#endif
|
||||
|
||||
static const nsCSSProps::KTableEntry kOrientationKeywords[] = {
|
||||
{ eCSSKeyword_portrait, NS_STYLE_ORIENTATION_PORTRAIT },
|
||||
{ eCSSKeyword_landscape, NS_STYLE_ORIENTATION_LANDSCAPE },
|
||||
{ eCSSKeyword_portrait, StyleOrientation::Portrait },
|
||||
{ eCSSKeyword_landscape, StyleOrientation::Landscape },
|
||||
{ eCSSKeyword_UNKNOWN, -1 }
|
||||
};
|
||||
|
||||
static const nsCSSProps::KTableEntry kScanKeywords[] = {
|
||||
{ eCSSKeyword_progressive, NS_STYLE_SCAN_PROGRESSIVE },
|
||||
{ eCSSKeyword_interlace, NS_STYLE_SCAN_INTERLACE },
|
||||
{ eCSSKeyword_progressive, StyleScan::Progressive },
|
||||
{ eCSSKeyword_interlace, StyleScan::Interlace },
|
||||
{ eCSSKeyword_UNKNOWN, -1 }
|
||||
};
|
||||
|
||||
static const nsCSSProps::KTableEntry kDisplayModeKeywords[] = {
|
||||
{ eCSSKeyword_browser, NS_STYLE_DISPLAY_MODE_BROWSER },
|
||||
{ eCSSKeyword_minimal_ui, NS_STYLE_DISPLAY_MODE_MINIMAL_UI },
|
||||
{ eCSSKeyword_standalone, NS_STYLE_DISPLAY_MODE_STANDALONE },
|
||||
{ eCSSKeyword_fullscreen, NS_STYLE_DISPLAY_MODE_FULLSCREEN },
|
||||
{ eCSSKeyword_browser, StyleDisplayMode::Browser },
|
||||
{ eCSSKeyword_minimal_ui, StyleDisplayMode::MinimalUi },
|
||||
{ eCSSKeyword_standalone, StyleDisplayMode::Standalone },
|
||||
{ eCSSKeyword_fullscreen, StyleDisplayMode::Fullscreen },
|
||||
{ eCSSKeyword_UNKNOWN, -1 }
|
||||
};
|
||||
|
||||
|
@ -189,9 +189,9 @@ GetOrientation(nsIDocument* aDocument, const nsMediaFeature*,
|
|||
{
|
||||
nsSize size = GetSize(aDocument);
|
||||
// Per spec, square viewports should be 'portrait'
|
||||
int32_t orientation = size.width > size.height
|
||||
? NS_STYLE_ORIENTATION_LANDSCAPE : NS_STYLE_ORIENTATION_PORTRAIT;
|
||||
aResult.SetIntValue(orientation, eCSSUnit_Enumerated);
|
||||
auto orientation = size.width > size.height
|
||||
? StyleOrientation::Landscape : StyleOrientation::Portrait;
|
||||
aResult.SetEnumValue(orientation);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -200,9 +200,9 @@ GetDeviceOrientation(nsIDocument* aDocument, const nsMediaFeature*,
|
|||
{
|
||||
nsSize size = GetDeviceSize(aDocument);
|
||||
// Per spec, square viewports should be 'portrait'
|
||||
int32_t orientation = size.width > size.height
|
||||
? NS_STYLE_ORIENTATION_LANDSCAPE : NS_STYLE_ORIENTATION_PORTRAIT;
|
||||
aResult.SetIntValue(orientation, eCSSUnit_Enumerated);
|
||||
auto orientation = size.width > size.height
|
||||
? StyleOrientation::Landscape : StyleOrientation::Portrait;
|
||||
aResult.SetEnumValue(orientation);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -351,28 +351,27 @@ GetDisplayMode(nsIDocument* aDocument, const nsMediaFeature*,
|
|||
nsCOMPtr<nsIWidget> mainWidget;
|
||||
baseWindow->GetMainWidget(getter_AddRefs(mainWidget));
|
||||
if (mainWidget && mainWidget->SizeMode() == nsSizeMode_Fullscreen) {
|
||||
aResult.SetIntValue(NS_STYLE_DISPLAY_MODE_FULLSCREEN, eCSSUnit_Enumerated);
|
||||
aResult.SetEnumValue(StyleDisplayMode::Fullscreen);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static_assert(nsIDocShell::DISPLAY_MODE_BROWSER == NS_STYLE_DISPLAY_MODE_BROWSER &&
|
||||
nsIDocShell::DISPLAY_MODE_MINIMAL_UI == NS_STYLE_DISPLAY_MODE_MINIMAL_UI &&
|
||||
nsIDocShell::DISPLAY_MODE_STANDALONE == NS_STYLE_DISPLAY_MODE_STANDALONE &&
|
||||
nsIDocShell::DISPLAY_MODE_FULLSCREEN == NS_STYLE_DISPLAY_MODE_FULLSCREEN,
|
||||
static_assert(nsIDocShell::DISPLAY_MODE_BROWSER == static_cast<int32_t>(StyleDisplayMode::Browser) &&
|
||||
nsIDocShell::DISPLAY_MODE_MINIMAL_UI == static_cast<int32_t>(StyleDisplayMode::MinimalUi) &&
|
||||
nsIDocShell::DISPLAY_MODE_STANDALONE == static_cast<int32_t>(StyleDisplayMode::Standalone) &&
|
||||
nsIDocShell::DISPLAY_MODE_FULLSCREEN == static_cast<int32_t>(StyleDisplayMode::Fullscreen),
|
||||
"nsIDocShell display modes must mach nsStyleConsts.h");
|
||||
|
||||
uint32_t displayMode = NS_STYLE_DISPLAY_MODE_BROWSER;
|
||||
uint32_t displayMode = nsIDocShell::DISPLAY_MODE_BROWSER;
|
||||
if (nsIDocShell* docShell = rootDocument->GetDocShell()) {
|
||||
docShell->GetDisplayMode(&displayMode);
|
||||
}
|
||||
|
||||
aResult.SetIntValue(displayMode, eCSSUnit_Enumerated);
|
||||
aResult.SetEnumValue(static_cast<StyleDisplayMode>(displayMode));
|
||||
}
|
||||
|
||||
static void
|
||||
GetGrid(nsIDocument* aDocument, const nsMediaFeature*,
|
||||
nsCSSValue& aResult)
|
||||
GetGrid(nsIDocument* aDocument, const nsMediaFeature*, nsCSSValue& aResult)
|
||||
{
|
||||
// Gecko doesn't support grid devices (e.g., ttys), so the 'grid'
|
||||
// feature is always 0.
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче