зеркало из https://github.com/mozilla/gecko-dev.git
Merge mozilla-central to mozilla-inbound
This commit is contained in:
Коммит
9abc7cd713
|
@ -281,7 +281,7 @@ XULLinkAccessible::AnchorURIAt(uint32_t aAnchorIndex)
|
|||
|
||||
nsCOMPtr<nsIURI> anchorURI;
|
||||
NS_NewURI(getter_AddRefs(anchorURI), href,
|
||||
document->GetDocumentCharacterSet().get(),
|
||||
document->GetDocumentCharacterSet(),
|
||||
baseURI);
|
||||
|
||||
return anchorURI.forget();
|
||||
|
|
|
@ -1634,6 +1634,10 @@ var gBrowserInit = {
|
|||
FullScreen.init();
|
||||
PointerLock.init();
|
||||
|
||||
if (AppConstants.isPlatformAndVersionAtLeast("win", "10")) {
|
||||
ContextMenuTouchModeObserver.init();
|
||||
}
|
||||
|
||||
// initialize the sync UI
|
||||
gSync.init();
|
||||
|
||||
|
@ -1843,6 +1847,9 @@ var gBrowserInit = {
|
|||
this.gmpInstallManager.uninit();
|
||||
}
|
||||
|
||||
if (AppConstants.isPlatformAndVersionAtLeast("win", "10")) {
|
||||
ContextMenuTouchModeObserver.uninit();
|
||||
}
|
||||
BrowserOffline.uninit();
|
||||
IndexedDBPromptHelper.uninit();
|
||||
PanelUI.uninit();
|
||||
|
@ -8219,6 +8226,77 @@ function restoreLastSession() {
|
|||
SessionStore.restoreLastSession();
|
||||
}
|
||||
|
||||
/* Observes context menus and adjusts their size for better
|
||||
* usability when opened via a touch screen. */
|
||||
var ContextMenuTouchModeObserver = {
|
||||
get _searchBarContextMenu() {
|
||||
let searchbar = document.getElementById("searchbar");
|
||||
let textBox = document.getAnonymousElementByAttribute(searchbar,
|
||||
"anonid", "searchbar-textbox");
|
||||
let inputBox = document.getAnonymousElementByAttribute(textBox,
|
||||
"anonid", "textbox-input-box");
|
||||
let menu = document.getAnonymousElementByAttribute(inputBox,
|
||||
"anonid", "input-box-contextmenu");
|
||||
return menu;
|
||||
},
|
||||
|
||||
get _urlBarContextMenu() {
|
||||
let urlbar = document.getElementById("urlbar");
|
||||
let textBox = document.getAnonymousElementByAttribute(urlbar,
|
||||
"anonid", "textbox-input-box");
|
||||
let menu = document.getAnonymousElementByAttribute(textBox,
|
||||
"anonid", "input-box-contextmenu");
|
||||
return menu;
|
||||
},
|
||||
|
||||
_addListener(el) {
|
||||
el.addEventListener("popupshowing", this);
|
||||
},
|
||||
|
||||
_removeListener(el) {
|
||||
el.removeEventListener("popupshowing", this);
|
||||
},
|
||||
|
||||
init() {
|
||||
// Start observing different context menus for popupshowing.
|
||||
|
||||
// The main popup set, which contains several context menus,
|
||||
// e.g. the page content area context menu.
|
||||
this._addListener(document.getElementById("mainPopupSet"));
|
||||
|
||||
// The navigation context menu of the back and forward button.
|
||||
this._addListener(document.getElementById("back-button"));
|
||||
this._addListener(document.getElementById("forward-button"));
|
||||
|
||||
// The search bar context menu.
|
||||
this._addListener(this._searchBarContextMenu);
|
||||
|
||||
// The url bar context menu.
|
||||
this._addListener(this._urlBarContextMenu);
|
||||
},
|
||||
|
||||
handleEvent(event) {
|
||||
let target = event.target;
|
||||
if (target.localName != "menupopup") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.mozInputSource == MouseEvent.MOZ_SOURCE_TOUCH) {
|
||||
target.setAttribute("touchmode", "true");
|
||||
} else {
|
||||
target.removeAttribute("touchmode");
|
||||
}
|
||||
},
|
||||
|
||||
uninit() {
|
||||
this._removeListener(document.getElementById("mainPopupSet"));
|
||||
this._removeListener(document.getElementById("back-button"));
|
||||
this._removeListener(document.getElementById("forward-button"));
|
||||
this._removeListener(this._searchBarContextMenu);
|
||||
this._removeListener(this._urlBarContextMenu);
|
||||
},
|
||||
};
|
||||
|
||||
var TabContextMenu = {
|
||||
contextTab: null,
|
||||
_updateToggleMuteMenuItem(aTab, aConditionFn) {
|
||||
|
|
|
@ -62,14 +62,14 @@ function openContextMenu(aMessage) {
|
|||
let popup = browser.ownerDocument.getElementById("contentAreaContextMenu");
|
||||
let event = gContextMenuContentData.event;
|
||||
|
||||
// Set touch mode to get larger menu items.
|
||||
if (event.mozInputSource == MouseEvent.MOZ_SOURCE_TOUCH) {
|
||||
popup.setAttribute("touchmode", "true");
|
||||
} else {
|
||||
popup.removeAttribute("touchmode");
|
||||
}
|
||||
// The event is a CPOW that can't be passed into the native openPopupAtScreen
|
||||
// function. Therefore we synthesize a new MouseEvent to propagate the
|
||||
// inputSource to the subsequently triggered popupshowing event.
|
||||
var newEvent = document.createEvent("MouseEvent");
|
||||
newEvent.initNSMouseEvent("contextmenu", true, true, null, 0, event.screenX, event.screenY,
|
||||
0, 0, false, false, false, false, 0, null, 0, event.mozInputSource);
|
||||
|
||||
popup.openPopupAtScreen(event.screenX, event.screenY, true);
|
||||
popup.openPopupAtScreen(newEvent.screenX, newEvent.screenY, true, newEvent);
|
||||
}
|
||||
|
||||
function nsContextMenu(aXulMenu, aIsShift) {
|
||||
|
|
|
@ -4,3 +4,5 @@ support-files =
|
|||
subtst_contextmenu_webext.html
|
||||
|
||||
[browser_contextmenu_mozextension.js]
|
||||
[browser_contextmenu_touch.js]
|
||||
skip-if = !(os == 'win' && os_version == '10.0')
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
/* 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/. */
|
||||
|
||||
/* This test checks that context menus are in touchmode
|
||||
* when opened through a touch event (long tap). */
|
||||
|
||||
async function openAndCheckContextMenu(contextMenu, target) {
|
||||
is(contextMenu.state, "closed", "Context menu is initally closed.");
|
||||
|
||||
let popupshown = BrowserTestUtils.waitForEvent(contextMenu, "popupshown");
|
||||
EventUtils.synthesizeNativeTapAtCenter(target, true);
|
||||
await popupshown;
|
||||
|
||||
is(contextMenu.state, "open", "Context menu is open.");
|
||||
is(contextMenu.getAttribute("touchmode"), "true", "Context menu is in touchmode.");
|
||||
|
||||
contextMenu.hidePopup();
|
||||
|
||||
popupshown = BrowserTestUtils.waitForEvent(contextMenu, "popupshown");
|
||||
EventUtils.synthesizeMouseAtCenter(target, {type: "contextmenu"});
|
||||
await popupshown;
|
||||
|
||||
is(contextMenu.state, "open", "Context menu is open.");
|
||||
ok(!contextMenu.hasAttribute("touchmode"), "Context menu is not in touchmode.");
|
||||
|
||||
contextMenu.hidePopup();
|
||||
}
|
||||
|
||||
// Test the content area context menu.
|
||||
add_task(async function test_contentarea_contextmenu_touch() {
|
||||
await BrowserTestUtils.withNewTab("about:blank", async function(browser) {
|
||||
let contextMenu = document.getElementById("contentAreaContextMenu");
|
||||
await openAndCheckContextMenu(contextMenu, browser);
|
||||
});
|
||||
});
|
||||
|
||||
// Test the back and forward buttons.
|
||||
add_task(async function test_back_forward_button_contextmenu_touch() {
|
||||
await BrowserTestUtils.withNewTab("http://example.com", async function(browser) {
|
||||
let contextMenu = document.getElementById("backForwardMenu");
|
||||
|
||||
let backbutton = document.getElementById("back-button");
|
||||
let notDisabled = BrowserTestUtils.waitForCondition(() => !backbutton.hasAttribute("disabled"));
|
||||
BrowserTestUtils.loadURI(browser, "http://example.org");
|
||||
await notDisabled;
|
||||
await openAndCheckContextMenu(contextMenu, backbutton);
|
||||
|
||||
|
||||
let forwardbutton = document.getElementById("forward-button");
|
||||
notDisabled = BrowserTestUtils.waitForCondition(() => !forwardbutton.hasAttribute("disabled"));
|
||||
backbutton.click();
|
||||
await notDisabled;
|
||||
await openAndCheckContextMenu(contextMenu, forwardbutton);
|
||||
});
|
||||
});
|
||||
|
||||
// Test the toolbar context menu.
|
||||
add_task(async function test_toolbar_contextmenu_touch() {
|
||||
let toolbarContextMenu = document.getElementById("toolbar-context-menu");
|
||||
let target = document.getElementById("PanelUI-menu-button");
|
||||
await openAndCheckContextMenu(toolbarContextMenu, target);
|
||||
});
|
||||
|
||||
// Test the urlbar input context menu.
|
||||
add_task(async function test_urlbar_contextmenu_touch() {
|
||||
let urlbar = document.getElementById("urlbar");
|
||||
let textBox = document.getAnonymousElementByAttribute(urlbar,
|
||||
"anonid", "textbox-input-box");
|
||||
let menu = document.getAnonymousElementByAttribute(textBox,
|
||||
"anonid", "input-box-contextmenu");
|
||||
await openAndCheckContextMenu(menu, textBox);
|
||||
});
|
|
@ -124,7 +124,6 @@ skip-if = debug || asan # Bug 1354681
|
|||
[browser_ext_tabs_getCurrent.js]
|
||||
[browser_ext_tabs_insertCSS.js]
|
||||
[browser_ext_tabs_removeCSS.js]
|
||||
[browser_ext_tabs_move.js]
|
||||
[browser_ext_tabs_move_array.js]
|
||||
[browser_ext_tabs_move_window.js]
|
||||
[browser_ext_tabs_move_window_multiple.js]
|
||||
|
|
|
@ -1,103 +0,0 @@
|
|||
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set sts=2 sw=2 et tw=80: */
|
||||
"use strict";
|
||||
|
||||
add_task(async function() {
|
||||
let tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:robots");
|
||||
let tab2 = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:config");
|
||||
|
||||
gBrowser.selectedTab = tab1;
|
||||
|
||||
let extension = ExtensionTestUtils.loadExtension({
|
||||
manifest: {
|
||||
"permissions": ["tabs"],
|
||||
},
|
||||
|
||||
background: async function() {
|
||||
let [tab] = await browser.tabs.query({lastFocusedWindow: true});
|
||||
|
||||
browser.tabs.move(tab.id, {index: 0});
|
||||
let tabs = await browser.tabs.query({lastFocusedWindow: true});
|
||||
|
||||
browser.test.assertEq(tabs[0].url, tab.url, "should be first tab");
|
||||
browser.test.notifyPass("tabs.move.single");
|
||||
},
|
||||
});
|
||||
|
||||
await extension.startup();
|
||||
await extension.awaitFinish("tabs.move.single");
|
||||
await extension.unload();
|
||||
|
||||
extension = ExtensionTestUtils.loadExtension({
|
||||
manifest: {
|
||||
"permissions": ["tabs"],
|
||||
},
|
||||
|
||||
background: async function() {
|
||||
let tabs = await browser.tabs.query({lastFocusedWindow: true});
|
||||
|
||||
tabs.sort(function(a, b) { return a.url > b.url; });
|
||||
|
||||
browser.tabs.move(tabs.map(tab => tab.id), {index: 0});
|
||||
|
||||
tabs = await browser.tabs.query({lastFocusedWindow: true});
|
||||
|
||||
browser.test.assertEq(tabs[0].url, "about:blank", "should be first tab");
|
||||
browser.test.assertEq(tabs[1].url, "about:config", "should be second tab");
|
||||
browser.test.assertEq(tabs[2].url, "about:robots", "should be third tab");
|
||||
|
||||
browser.test.notifyPass("tabs.move.multiple");
|
||||
},
|
||||
});
|
||||
|
||||
await extension.startup();
|
||||
await extension.awaitFinish("tabs.move.multiple");
|
||||
await extension.unload();
|
||||
|
||||
extension = ExtensionTestUtils.loadExtension({
|
||||
manifest: {
|
||||
"permissions": ["tabs"],
|
||||
},
|
||||
|
||||
async background() {
|
||||
let [, tab] = await browser.tabs.query({lastFocusedWindow: true});
|
||||
|
||||
// Assuming that tab.id of 12345 does not exist.
|
||||
await browser.test.assertRejects(
|
||||
browser.tabs.move([tab.id, 12345], {index: 0}),
|
||||
/Invalid tab/,
|
||||
"Should receive invalid tab error");
|
||||
|
||||
let tabs = await browser.tabs.query({lastFocusedWindow: true});
|
||||
browser.test.assertEq(tabs[1].url, tab.url, "should be second tab");
|
||||
browser.test.notifyPass("tabs.move.invalid");
|
||||
},
|
||||
});
|
||||
|
||||
await extension.startup();
|
||||
await extension.awaitFinish("tabs.move.invalid");
|
||||
await extension.unload();
|
||||
|
||||
extension = ExtensionTestUtils.loadExtension({
|
||||
manifest: {
|
||||
"permissions": ["tabs"],
|
||||
},
|
||||
|
||||
background: async function() {
|
||||
let [tab] = await browser.tabs.query({lastFocusedWindow: true});
|
||||
browser.tabs.move(tab.id, {index: -1});
|
||||
|
||||
let tabs = await browser.tabs.query({lastFocusedWindow: true});
|
||||
|
||||
browser.test.assertEq(tabs[2].url, tab.url, "should be last tab");
|
||||
browser.test.notifyPass("tabs.move.last");
|
||||
},
|
||||
});
|
||||
|
||||
await extension.startup();
|
||||
await extension.awaitFinish("tabs.move.last");
|
||||
await extension.unload();
|
||||
|
||||
await BrowserTestUtils.removeTab(tab1);
|
||||
await BrowserTestUtils.removeTab(tab2);
|
||||
});
|
|
@ -41,7 +41,10 @@ add_task(async function moveMultiple() {
|
|||
}
|
||||
|
||||
let tests = [
|
||||
{"move": [2], "index": 0, "result": [2, 1, 3, 4]},
|
||||
{"move": [2], "index": -1, "result": [1, 3, 4, 2]},
|
||||
// Start -> After first tab -> After second tab
|
||||
{"move": [4, 3], "index": 0, "result": [4, 3, 1, 2]},
|
||||
// [1, 2, 3, 4] -> [1, 4, 2, 3] -> [1, 4, 3, 2]
|
||||
{"move": [4, 3], "index": 1, "result": [1, 4, 3, 2]},
|
||||
// [1, 2, 3, 4] -> [2, 3, 1, 4] -> [3, 1, 2, 4]
|
||||
|
@ -58,6 +61,15 @@ add_task(async function moveMultiple() {
|
|||
await check(test.result);
|
||||
}
|
||||
|
||||
let firstId = (await browser.tabs.query({url: "http://example.com/*"}))[0].id;
|
||||
// Assuming that tab.id of 12345 does not exist.
|
||||
await browser.test.assertRejects(
|
||||
browser.tabs.move([firstId, 12345], {index: -1}),
|
||||
/Invalid tab/,
|
||||
"Should receive invalid tab error");
|
||||
// The first argument got moved, the second on failed.
|
||||
await check([2, 3, 1, 4]);
|
||||
|
||||
browser.test.notifyPass("tabs.move");
|
||||
},
|
||||
});
|
||||
|
|
|
@ -18,6 +18,19 @@ var gSearchResultsPane = {
|
|||
if (!this.searchInput.hidden) {
|
||||
this.searchInput.addEventListener("command", this);
|
||||
this.searchInput.addEventListener("focus", this);
|
||||
|
||||
// Throttling the resize event to reduce the callback frequency
|
||||
let callbackId;
|
||||
window.addEventListener("resize", () => {
|
||||
if (!callbackId) {
|
||||
callbackId = window.requestAnimationFrame(() => {
|
||||
this.listSearchTooltips.forEach((anchorNode) => {
|
||||
this.calculateTooltipPosition(anchorNode);
|
||||
});
|
||||
callbackId = null;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -275,7 +288,10 @@ var gSearchResultsPane = {
|
|||
*/
|
||||
searchWithinNode(nodeObject, searchPhrase) {
|
||||
let matchesFound = false;
|
||||
if (nodeObject.childElementCount == 0 || nodeObject.tagName == "menulist") {
|
||||
if (nodeObject.childElementCount == 0 ||
|
||||
nodeObject.tagName == "label" ||
|
||||
nodeObject.tagName == "description" ||
|
||||
nodeObject.tagName == "menulist") {
|
||||
let simpleTextNodes = this.textNodeDescendants(nodeObject);
|
||||
|
||||
for (let node of simpleTextNodes) {
|
||||
|
@ -283,12 +299,16 @@ var gSearchResultsPane = {
|
|||
matchesFound = matchesFound || result;
|
||||
}
|
||||
|
||||
// Collecting data from boxObject
|
||||
// Collecting data from boxObject / label / description
|
||||
let nodeSizes = [];
|
||||
let allNodeText = "";
|
||||
let runningSize = 0;
|
||||
let accessKeyTextNodes = this.textNodeDescendants(nodeObject.boxObject);
|
||||
|
||||
if (nodeObject.tagName == "label" || nodeObject.tagName == "description") {
|
||||
accessKeyTextNodes.push(...this.textNodeDescendants(nodeObject));
|
||||
}
|
||||
|
||||
for (let node of accessKeyTextNodes) {
|
||||
runningSize += node.textContent.length;
|
||||
allNodeText += node.textContent;
|
||||
|
@ -391,6 +411,12 @@ var gSearchResultsPane = {
|
|||
anchorNode.parentElement.classList.add("search-tooltip-parent");
|
||||
anchorNode.parentElement.appendChild(searchTooltip);
|
||||
|
||||
this.calculateTooltipPosition(anchorNode);
|
||||
},
|
||||
|
||||
calculateTooltipPosition(anchorNode) {
|
||||
let searchTooltip = anchorNode.parentElement.querySelector(":scope > .search-tooltip");
|
||||
|
||||
// In order to get the up-to-date position of each of the nodes that we're
|
||||
// putting tooltips on, we have to flush layout intentionally, and that
|
||||
// this is the result of a XUL limitation (bug 1363730).
|
||||
|
|
|
@ -61,8 +61,9 @@ var gPrivacyPane = {
|
|||
|
||||
this.trackingProtectionReadPrefs();
|
||||
|
||||
document.getElementById("trackingprotectionbox").hidden = false;
|
||||
document.getElementById("trackingprotectionpbmbox").hidden = true;
|
||||
document.getElementById("trackingProtectionExceptions").hidden = false;
|
||||
document.getElementById("trackingProtectionBox").hidden = false;
|
||||
document.getElementById("trackingProtectionPBMBox").hidden = true;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -189,10 +190,6 @@ var gPrivacyPane = {
|
|||
gPrivacyPane.clearPrivateDataNow(true);
|
||||
return false;
|
||||
});
|
||||
setEventListener("doNotTrackSettings", "click", function() {
|
||||
gPrivacyPane.showDoNotTrackSettings();
|
||||
return false;
|
||||
});
|
||||
setEventListener("privateBrowsingAutoStart", "command",
|
||||
gPrivacyPane.updateAutostart);
|
||||
setEventListener("cookieExceptions", "command",
|
||||
|
@ -207,8 +204,6 @@ var gPrivacyPane = {
|
|||
gPrivacyPane.showTrackingProtectionExceptions);
|
||||
setEventListener("changeBlockList", "command",
|
||||
gPrivacyPane.showBlockLists);
|
||||
setEventListener("changeBlockListPBM", "command",
|
||||
gPrivacyPane.showBlockLists);
|
||||
setEventListener("browserContainersCheckbox", "command",
|
||||
gPrivacyPane._checkBrowserContainers);
|
||||
setEventListener("browserContainersSettings", "command",
|
||||
|
|
|
@ -76,7 +76,10 @@
|
|||
<preference id="browser.privatebrowsing.autostart"
|
||||
name="browser.privatebrowsing.autostart"
|
||||
type="bool"/>
|
||||
|
||||
<!-- Do not track -->
|
||||
<preference id="privacy.donottrackheader.enabled"
|
||||
name="privacy.donottrackheader.enabled"
|
||||
type="bool"/>
|
||||
<!-- DRM content -->
|
||||
<preference id="media.eme.enabled"
|
||||
name="media.eme.enabled"
|
||||
|
@ -401,22 +404,48 @@
|
|||
<!-- Tracking -->
|
||||
<groupbox id="trackingGroup" data-category="panePrivacy" hidden="true">
|
||||
<caption><label>&trackingProtectionHeader2.label;</label></caption>
|
||||
<vbox id="trackingprotectionbox" hidden="true">
|
||||
<vbox>
|
||||
<hbox align="start">
|
||||
<vbox flex="1">
|
||||
<description>
|
||||
&trackingProtection.description;
|
||||
<label id="trackingProtectionLearnMore" class="learnMore text-link">&trackingProtectionLearnMore.label;</label>
|
||||
</description>
|
||||
<description id="trackingProtectionDesc"
|
||||
control="trackingProtectionRadioGroup">
|
||||
&trackingProtection.radioGroupLabel;
|
||||
</description>
|
||||
</vbox>
|
||||
<spacer flex="1"/>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<vbox id="trackingProtectionBox" flex="1" hidden="true">
|
||||
<description id="trackingProtectionDesc"
|
||||
control="trackingProtectionRadioGroup">
|
||||
&trackingProtection.radioGroupLabel;
|
||||
<label id="trackingProtectionLearnMore" class="learnMore text-link">&trackingProtectionLearnMore.label;</label>
|
||||
</description>
|
||||
<radiogroup id="trackingProtectionRadioGroup" aria-labelledby="trackingProtectionDesc">
|
||||
<radio value="always"
|
||||
label="&trackingProtectionAlways.label;"
|
||||
accesskey="&trackingProtectionAlways.accesskey;"/>
|
||||
<radio value="private"
|
||||
label="&trackingProtectionPrivate.label;"
|
||||
accesskey="&trackingProtectionPrivate.accesskey;"/>
|
||||
<radio value="never"
|
||||
label="&trackingProtectionNever.label;"
|
||||
accesskey="&trackingProtectionNever.accesskey;"/>
|
||||
</radiogroup>
|
||||
</vbox>
|
||||
<vbox id="trackingProtectionPBMBox" flex="1">
|
||||
<hbox align="center">
|
||||
<checkbox id="trackingProtectionPBM"
|
||||
preference="privacy.trackingprotection.pbmode.enabled"
|
||||
accesskey="&trackingProtectionPBM6.accesskey;"/>
|
||||
<label flex="1">&trackingProtectionPBM6.label;<label id="trackingProtectionPBMLearnMore"
|
||||
class="learnMore text-link">&trackingProtectionPBMLearnMore.label;</label>
|
||||
</label>
|
||||
</hbox>
|
||||
</vbox>
|
||||
<vbox id="trackingProtectionAdvancedSettings">
|
||||
<button id="trackingProtectionExceptions"
|
||||
class="accessory-button"
|
||||
hidden="true"
|
||||
label="&trackingProtectionExceptions.label;"
|
||||
accesskey="&trackingProtectionExceptions.accesskey;"
|
||||
preference="pref.privacy.disable_button.tracking_protection_exceptions"
|
||||
|
@ -432,37 +461,15 @@
|
|||
searchkeywords="&button.cancel.label; &button.ok.label;"/>
|
||||
</vbox>
|
||||
</hbox>
|
||||
<radiogroup id="trackingProtectionRadioGroup" aria-labelledby="trackingProtectionDesc">
|
||||
<radio value="always"
|
||||
label="&trackingProtectionAlways.label;"
|
||||
accesskey="&trackingProtectionAlways.accesskey;"/>
|
||||
<radio value="private"
|
||||
label="&trackingProtectionPrivate.label;"
|
||||
accesskey="&trackingProtectionPrivate.accesskey;"/>
|
||||
<radio value="never"
|
||||
label="&trackingProtectionNever.label;"
|
||||
accesskey="&trackingProtectionNever.accesskey;"/>
|
||||
<vbox id="doNotTrackLearnMoreBox">
|
||||
<label>&doNotTrack.description;<label
|
||||
class="learnMore text-link" href="https://www.mozilla.org/dnt"
|
||||
>&doNotTrack.learnMore.label;</label></label>
|
||||
<radiogroup id="doNotTrackRadioGroup" aria-labelledby="doNotTrackDesc" preference="privacy.donottrackheader.enabled">
|
||||
<radio value="false" label="&doNotTrack.default.label;"/>
|
||||
<radio value="true" label="&doNotTrack.always.label;"/>
|
||||
</radiogroup>
|
||||
</vbox>
|
||||
<vbox id="trackingprotectionpbmbox">
|
||||
<caption><label>&tracking.label;</label></caption>
|
||||
<hbox align="center">
|
||||
<checkbox id="trackingProtectionPBM"
|
||||
preference="privacy.trackingprotection.pbmode.enabled"
|
||||
accesskey="&trackingProtectionPBM5.accesskey;"
|
||||
label="&trackingProtectionPBM5.label;" />
|
||||
<label id="trackingProtectionPBMLearnMore"
|
||||
class="learnMore text-link">&trackingProtectionPBMLearnMore.label;</label>
|
||||
<spacer flex="1" />
|
||||
<button id="changeBlockListPBM"
|
||||
label="&changeBlockList.label;" accesskey="&changeBlockList.accesskey;"
|
||||
preference="pref.privacy.disable_button.change_blocklist"/>
|
||||
</hbox>
|
||||
</vbox>
|
||||
<vbox>
|
||||
<description>&doNotTrack.pre.label;<label
|
||||
class="text-link" id="doNotTrackSettings"
|
||||
>&doNotTrack.settings.label;</label>&doNotTrack.post.label;</description>
|
||||
</vbox>
|
||||
</groupbox>
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@
|
|||
<checkbox id="trackingProtectionPBM"
|
||||
preference="privacy.trackingprotection.pbmode.enabled"
|
||||
accesskey="&trackingProtectionPBM5.accesskey;"
|
||||
label="&trackingProtectionPBM5.label;" />
|
||||
label="&trackingProtectionPBM5.label;"/>
|
||||
<label id="trackingProtectionPBMLearnMore"
|
||||
class="learnMore text-link"
|
||||
value="&trackingProtectionPBMLearnMore.label;"/>
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<!ENTITY trackingProtectionHeader2.label "Tracking Protection">
|
||||
<!ENTITY trackingProtection.description "Tracking is when companies collect information about you to build a profile and display content based on your browsing and personal data.">
|
||||
<!ENTITY trackingProtection.radioGroupLabel "Block known tracking companies from displaying content">
|
||||
<!ENTITY trackingProtection.description "Tracking is the collection of your browsing data across multiple websites. Tracking can be used to build a profile and display content based on your browsing and personal information.">
|
||||
<!ENTITY trackingProtection.radioGroupLabel "Use Tracking Protection to block known trackers">
|
||||
<!ENTITY trackingProtectionAlways.label "Always">
|
||||
<!ENTITY trackingProtectionAlways.accesskey "y">
|
||||
<!ENTITY trackingProtectionPrivate.label "Only in private windows">
|
||||
|
@ -15,18 +15,18 @@
|
|||
<!ENTITY trackingProtectionExceptions.label "Exceptions…">
|
||||
<!ENTITY trackingProtectionExceptions.accesskey "x">
|
||||
|
||||
<!ENTITY tracking.label "Tracking">
|
||||
<!ENTITY trackingProtectionPBM5.label "Use Tracking Protection in Private Windows">
|
||||
<!ENTITY trackingProtectionPBM5.accesskey "v">
|
||||
<!ENTITY trackingProtectionPBM6.label "Use Tracking Protection in Private Browsing to block known trackers">
|
||||
<!ENTITY trackingProtectionPBM6.accesskey "v">
|
||||
<!ENTITY trackingProtectionPBMLearnMore.label "Learn more">
|
||||
<!ENTITY changeBlockList.label "Change Block List">
|
||||
<!ENTITY changeBlockList.accesskey "C">
|
||||
|
||||
<!-- LOCALIZATION NOTE (doNotTrack.pre.label): include a trailing space as needed -->
|
||||
<!-- LOCALIZATION NOTE (doNotTrack.post.label): include a starting space as needed -->
|
||||
<!ENTITY doNotTrack.pre.label "You can also ">
|
||||
<!ENTITY doNotTrack.settings.label "manage your Do Not Track settings">
|
||||
<!ENTITY doNotTrack.post.label ".">
|
||||
<!ENTITY doNotTrack.description "Send websites a “Do Not Track” signal that you don’t want to be tracked">
|
||||
<!ENTITY doNotTrack.learnMore.label "Learn more">
|
||||
<!ENTITY doNotTrack.default.label "Only when using Tracking Protection">
|
||||
<!ENTITY doNotTrack.always.label "Always">
|
||||
|
||||
<!ENTITY history.label "History">
|
||||
<!ENTITY permissions.label "Permissions">
|
||||
|
|
|
@ -236,11 +236,8 @@ treecol {
|
|||
margin-left: 0;
|
||||
}
|
||||
|
||||
/* This learn-more link is inserted at the end of a
|
||||
xul:description element so it should behave like normal text. */
|
||||
#trackingProtectionLearnMore {
|
||||
white-space: normal;
|
||||
margin-inline-start: 0;
|
||||
#doNotTrackLearnMoreBox {
|
||||
margin-top: 30px
|
||||
}
|
||||
|
||||
#trackingProtectionAdvancedSettings {
|
||||
|
|
|
@ -1970,8 +1970,8 @@ notification.pluginVulnerable > .notification-inner > .messageCloseButton {
|
|||
%include ../shared/contextmenu.inc.css
|
||||
|
||||
/* Make context menu items larger when opened through touch. */
|
||||
#contentAreaContextMenu[touchmode] menu,
|
||||
#contentAreaContextMenu[touchmode] menuitem {
|
||||
menupopup[touchmode] menu,
|
||||
menupopup[touchmode] menuitem {
|
||||
padding-top: 12px;
|
||||
padding-bottom: 12px;
|
||||
}
|
||||
|
|
|
@ -374,14 +374,15 @@ ForEachPing(nsIContent* aContent, ForEachPingCallback aCallback, void* aClosure)
|
|||
}
|
||||
|
||||
nsIDocument* doc = aContent->OwnerDoc();
|
||||
nsAutoCString charset;
|
||||
doc->GetDocumentCharacterSet()->Name(charset);
|
||||
|
||||
nsWhitespaceTokenizer tokenizer(value);
|
||||
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
nsCOMPtr<nsIURI> uri, baseURI = aContent->GetBaseURI();
|
||||
ios->NewURI(NS_ConvertUTF16toUTF8(tokenizer.nextToken()),
|
||||
doc->GetDocumentCharacterSet().get(),
|
||||
baseURI, getter_AddRefs(uri));
|
||||
charset.get(), baseURI, getter_AddRefs(uri));
|
||||
// if we can't generate a valid URI, then there is nothing to do
|
||||
if (!uri) {
|
||||
continue;
|
||||
|
@ -835,6 +836,8 @@ nsDocShell::nsDocShell()
|
|||
, mDefaultLoadFlags(nsIRequest::LOAD_NORMAL)
|
||||
, mFrameType(FRAME_TYPE_REGULAR)
|
||||
, mPrivateBrowsingId(0)
|
||||
, mForcedCharset(nullptr)
|
||||
, mParentCharset(nullptr)
|
||||
, mParentCharsetSource(0)
|
||||
, mJSRunToCompletionDepth(0)
|
||||
, mTouchEventsOverride(nsIDocShell::TOUCHEVENTS_OVERRIDE_NONE)
|
||||
|
@ -2035,7 +2038,7 @@ nsDocShell::GetCharset(nsACString& aCharset)
|
|||
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
|
||||
nsIDocument* doc = presShell->GetDocument();
|
||||
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
|
||||
aCharset = doc->GetDocumentCharacterSet();
|
||||
doc->GetDocumentCharacterSet()->Name(aCharset);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -2121,7 +2124,7 @@ NS_IMETHODIMP
|
|||
nsDocShell::SetForcedCharset(const nsACString& aCharset)
|
||||
{
|
||||
if (aCharset.IsEmpty()) {
|
||||
mForcedCharset.Truncate();
|
||||
mForcedCharset = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
const Encoding* encoding = Encoding::ForLabel(aCharset);
|
||||
|
@ -2133,19 +2136,19 @@ nsDocShell::SetForcedCharset(const nsACString& aCharset)
|
|||
// Reject XSS hazards
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
encoding->Name(mForcedCharset);
|
||||
mForcedCharset = encoding;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetForcedCharset(nsACString& aResult)
|
||||
{
|
||||
aResult = mForcedCharset;
|
||||
mForcedCharset->Name(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShell::SetParentCharset(const nsACString& aCharset,
|
||||
nsDocShell::SetParentCharset(const Encoding*& aCharset,
|
||||
int32_t aCharsetSource,
|
||||
nsIPrincipal* aPrincipal)
|
||||
{
|
||||
|
@ -2155,7 +2158,7 @@ nsDocShell::SetParentCharset(const nsACString& aCharset,
|
|||
}
|
||||
|
||||
void
|
||||
nsDocShell::GetParentCharset(nsACString& aCharset,
|
||||
nsDocShell::GetParentCharset(const Encoding*& aCharset,
|
||||
int32_t* aCharsetSource,
|
||||
nsIPrincipal** aPrincipal)
|
||||
{
|
||||
|
@ -4197,7 +4200,7 @@ nsDocShell::AddChild(nsIDocShellTreeItem* aChild)
|
|||
// the actual source charset, which is what we're trying to
|
||||
// expose here.
|
||||
|
||||
const nsACString& parentCS = doc->GetDocumentCharacterSet();
|
||||
const Encoding* parentCS = doc->GetDocumentCharacterSet();
|
||||
int32_t charsetSource = doc->GetDocumentCharacterSetSource();
|
||||
// set the child's parentCharset
|
||||
childAsDocShell->SetParentCharset(parentCS,
|
||||
|
@ -11633,7 +11636,8 @@ nsDocShell::ScrollToAnchor(bool aCurHasRef, bool aNewHasRef,
|
|||
NS_ENSURE_TRUE(mContentViewer, NS_ERROR_FAILURE);
|
||||
nsIDocument* doc = mContentViewer->GetDocument();
|
||||
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
|
||||
const nsACString& charset = doc->GetDocumentCharacterSet();
|
||||
nsAutoCString charset;
|
||||
doc->GetDocumentCharacterSet()->Name(charset);
|
||||
|
||||
nsCOMPtr<nsITextToSubURI> textToSubURI =
|
||||
do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv);
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
#include "nsIDeprecationWarner.h"
|
||||
|
||||
namespace mozilla {
|
||||
class Encoding;
|
||||
enum class TaskCategory;
|
||||
namespace dom {
|
||||
class EventTarget;
|
||||
|
@ -155,6 +156,7 @@ class nsDocShell final
|
|||
{
|
||||
friend class nsDSURIContentListener;
|
||||
friend class FramingChecker;
|
||||
using Encoding = mozilla::Encoding;
|
||||
|
||||
public:
|
||||
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(nsDocShell)
|
||||
|
@ -274,6 +276,8 @@ public:
|
|||
}
|
||||
bool InFrameSwap();
|
||||
|
||||
const Encoding* GetForcedCharset() { return mForcedCharset; }
|
||||
|
||||
private:
|
||||
bool CanSetOriginAttributes();
|
||||
|
||||
|
@ -1040,8 +1044,8 @@ protected:
|
|||
nsString mInterceptedDocumentId;
|
||||
|
||||
private:
|
||||
nsCString mForcedCharset;
|
||||
nsCString mParentCharset;
|
||||
const Encoding* mForcedCharset;
|
||||
const Encoding* mParentCharset;
|
||||
int32_t mParentCharsetSource;
|
||||
nsCOMPtr<nsIPrincipal> mParentCharsetPrincipal;
|
||||
nsTObserverArray<nsWeakPtr> mPrivacyObservers;
|
||||
|
|
|
@ -11,8 +11,12 @@
|
|||
%{ C++
|
||||
#include "js/TypeDecls.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/NotNull.h"
|
||||
class nsPresContext;
|
||||
class nsIPresShell;
|
||||
namespace mozilla {
|
||||
class Encoding;
|
||||
}
|
||||
%}
|
||||
|
||||
/**
|
||||
|
@ -22,6 +26,7 @@ class nsIPresShell;
|
|||
[ptr] native nsPresContext(nsPresContext);
|
||||
[ptr] native nsIPresShell(nsIPresShell);
|
||||
[ref] native MaybeURI(mozilla::Maybe<nsCOMPtr<nsIURI>>);
|
||||
[ref] native Encoding(const mozilla::Encoding*);
|
||||
|
||||
interface nsIURI;
|
||||
interface nsIChannel;
|
||||
|
@ -713,11 +718,11 @@ interface nsIDocShell : nsIDocShellTreeItem
|
|||
* In a child docshell, this is the charset of the parent docshell
|
||||
*/
|
||||
[noscript, notxpcom, nostdcall] void setParentCharset(
|
||||
in ACString parentCharset,
|
||||
in Encoding parentCharset,
|
||||
in int32_t parentCharsetSource,
|
||||
in nsIPrincipal parentCharsetPrincipal);
|
||||
[noscript, notxpcom, nostdcall] void getParentCharset(
|
||||
out ACString parentCharset,
|
||||
out Encoding parentCharset,
|
||||
out int32_t parentCharsetSource,
|
||||
out nsIPrincipal parentCharsetPrincipal);
|
||||
|
||||
|
|
|
@ -1059,8 +1059,9 @@ addAsyncAnimTest("tree_ordering", { observe: div, subtree: true }, function*() {
|
|||
var extraStyle = document.createElement('style');
|
||||
document.head.appendChild(extraStyle);
|
||||
var sheet = extraStyle.sheet;
|
||||
var rules = { ".before::before": "animation: anim 100s;",
|
||||
".after::after" : "animation: anim 100s, anim 100s;" };
|
||||
var rules = { ".before::before": "animation: anim 100s; content: '';",
|
||||
".after::after" : "animation: anim 100s, anim 100s; " +
|
||||
"content: '';"};
|
||||
for (var selector in rules) {
|
||||
sheet.insertRule(selector + '{' + rules[selector] + '}',
|
||||
sheet.cssRules.length);
|
||||
|
|
|
@ -429,7 +429,7 @@ nsIContent::GetBaseURI(bool aTryUseXHRDocBaseURI) const
|
|||
for (uint32_t i = baseAttrs.Length() - 1; i != uint32_t(-1); --i) {
|
||||
nsCOMPtr<nsIURI> newBase;
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(newBase), baseAttrs[i],
|
||||
doc->GetDocumentCharacterSet().get(), base);
|
||||
doc->GetDocumentCharacterSet(), base);
|
||||
// Do a security check, almost the same as nsDocument::SetBaseURL()
|
||||
// Only need to do this on the final uri
|
||||
if (NS_SUCCEEDED(rv) && i == 0) {
|
||||
|
|
|
@ -39,18 +39,6 @@
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
static nsresult
|
||||
GetDocumentCharacterSetForURI(const nsAString& aHref, nsACString& aCharset)
|
||||
{
|
||||
aCharset.Truncate();
|
||||
|
||||
if (nsIDocument* doc = GetEntryDocument()) {
|
||||
aCharset = doc->GetDocumentCharacterSet();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Location::Location(nsPIDOMWindowInner* aWindow, nsIDocShell *aDocShell)
|
||||
: mInnerWindow(aWindow)
|
||||
{
|
||||
|
@ -506,11 +494,12 @@ Location::SetHrefWithBase(const nsAString& aHref, nsIURI* aBase,
|
|||
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell));
|
||||
|
||||
nsAutoCString docCharset;
|
||||
if (NS_SUCCEEDED(GetDocumentCharacterSetForURI(aHref, docCharset)))
|
||||
result = NS_NewURI(getter_AddRefs(newUri), aHref, docCharset.get(), aBase);
|
||||
else
|
||||
if (nsIDocument* doc = GetEntryDocument()) {
|
||||
result = NS_NewURI(getter_AddRefs(newUri), aHref,
|
||||
doc->GetDocumentCharacterSet(), aBase);
|
||||
} else {
|
||||
result = NS_NewURI(getter_AddRefs(newUri), aHref, nullptr, aBase);
|
||||
}
|
||||
|
||||
if (newUri) {
|
||||
/* Check with the scriptContext if it is currently processing a script tag.
|
||||
|
|
|
@ -846,10 +846,9 @@ nsContentSink::PrefetchHref(const nsAString &aHref,
|
|||
nsCOMPtr<nsIPrefetchService> prefetchService(do_GetService(NS_PREFETCHSERVICE_CONTRACTID));
|
||||
if (prefetchService) {
|
||||
// construct URI using document charset
|
||||
const nsACString &charset = mDocument->GetDocumentCharacterSet();
|
||||
auto encoding = mDocument->GetDocumentCharacterSet();
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
NS_NewURI(getter_AddRefs(uri), aHref,
|
||||
charset.IsEmpty() ? nullptr : PromiseFlatCString(charset).get(),
|
||||
NS_NewURI(getter_AddRefs(uri), aHref, encoding,
|
||||
mDocument->GetDocBaseURI());
|
||||
if (uri) {
|
||||
nsCOMPtr<nsIDOMNode> domNode = do_QueryInterface(aSource);
|
||||
|
@ -893,10 +892,9 @@ void
|
|||
nsContentSink::Preconnect(const nsAString& aHref, const nsAString& aCrossOrigin)
|
||||
{
|
||||
// construct URI using document charset
|
||||
const nsACString& charset = mDocument->GetDocumentCharacterSet();
|
||||
auto encoding = mDocument->GetDocumentCharacterSet();
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
NS_NewURI(getter_AddRefs(uri), aHref,
|
||||
charset.IsEmpty() ? nullptr : PromiseFlatCString(charset).get(),
|
||||
NS_NewURI(getter_AddRefs(uri), aHref, encoding,
|
||||
mDocument->GetDocBaseURI());
|
||||
|
||||
if (uri && mDocument) {
|
||||
|
|
|
@ -3162,9 +3162,12 @@ nsContentUtils::NewURIWithDocumentCharset(nsIURI** aResult,
|
|||
nsIDocument* aDocument,
|
||||
nsIURI* aBaseURI)
|
||||
{
|
||||
if (aDocument) {
|
||||
return NS_NewURI(aResult, aSpec,
|
||||
aDocument ? aDocument->GetDocumentCharacterSet().get() : nullptr,
|
||||
aDocument->GetDocumentCharacterSet(),
|
||||
aBaseURI, sIOService);
|
||||
}
|
||||
return NS_NewURI(aResult, aSpec, nullptr, aBaseURI, sIOService);
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "nsDOMSerializer.h"
|
||||
|
||||
#include "mozilla/Encoding.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDocumentEncoder.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
|
@ -71,7 +72,7 @@ SetUpEncoder(nsIDOMNode *aRoot, const nsACString& aCharset,
|
|||
if (charset.IsEmpty()) {
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
|
||||
NS_ASSERTION(doc, "Need a document");
|
||||
charset = doc->GetDocumentCharacterSet();
|
||||
doc->GetDocumentCharacterSet()->Name(charset);
|
||||
}
|
||||
rv = encoder->SetCharset(charset);
|
||||
if (NS_FAILED(rv))
|
||||
|
|
|
@ -1294,7 +1294,7 @@ nsIDocument::nsIDocument()
|
|||
mBlockAllMixedContentPreloads(false),
|
||||
mUpgradeInsecureRequests(false),
|
||||
mUpgradeInsecurePreloads(false),
|
||||
mCharacterSet(NS_LITERAL_CSTRING("windows-1252")),
|
||||
mCharacterSet(WINDOWS_1252_ENCODING),
|
||||
mCharacterSetSource(0),
|
||||
mParentDocument(nullptr),
|
||||
mCachedRootElement(nullptr),
|
||||
|
@ -3678,13 +3678,14 @@ nsDocument::GetBaseTarget(nsAString &aBaseTarget)
|
|||
}
|
||||
|
||||
void
|
||||
nsDocument::SetDocumentCharacterSet(const nsACString& aCharSetID)
|
||||
nsDocument::SetDocumentCharacterSet(NotNull<const Encoding*> aEncoding)
|
||||
{
|
||||
// XXX it would be a good idea to assert the sanity of the argument,
|
||||
// but before we figure out what to do about non-Encoding Standard
|
||||
// encodings in the charset menu and in mailnews, assertions are futile.
|
||||
if (!mCharacterSet.Equals(aCharSetID)) {
|
||||
mCharacterSet = aCharSetID;
|
||||
if (mCharacterSet != aEncoding) {
|
||||
mCharacterSet = aEncoding;
|
||||
|
||||
nsAutoCString charsetID;
|
||||
aEncoding->Name(charsetID);
|
||||
NS_ConvertASCIItoUTF16 charset16(charsetID);
|
||||
|
||||
int32_t n = mCharSetObservers.Length();
|
||||
|
||||
|
@ -3692,7 +3693,7 @@ nsDocument::SetDocumentCharacterSet(const nsACString& aCharSetID)
|
|||
nsIObserver* observer = mCharSetObservers.ElementAt(i);
|
||||
|
||||
observer->Observe(static_cast<nsIDocument *>(this), "charset",
|
||||
NS_ConvertASCIItoUTF16(aCharSetID).get());
|
||||
charset16.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3849,7 +3850,7 @@ nsDocument::SetHeaderData(nsIAtom* aHeaderField, const nsAString& aData)
|
|||
void
|
||||
nsDocument::TryChannelCharset(nsIChannel *aChannel,
|
||||
int32_t& aCharsetSource,
|
||||
nsACString& aCharset,
|
||||
NotNull<const Encoding*>& aEncoding,
|
||||
nsHtml5TreeOpExecutor* aExecutor)
|
||||
{
|
||||
if (aChannel) {
|
||||
|
@ -3858,7 +3859,7 @@ nsDocument::TryChannelCharset(nsIChannel *aChannel,
|
|||
if (NS_SUCCEEDED(rv)) {
|
||||
const Encoding* preferred = Encoding::ForLabel(charsetVal);
|
||||
if (preferred) {
|
||||
preferred->Name(aCharset);
|
||||
aEncoding = WrapNotNull(preferred);
|
||||
aCharsetSource = kCharsetFromChannel;
|
||||
return;
|
||||
} else if (aExecutor && !charsetVal.IsEmpty()) {
|
||||
|
@ -6495,7 +6496,9 @@ nsDocument::GetCharacterSet(nsAString& aCharacterSet)
|
|||
void
|
||||
nsIDocument::GetCharacterSet(nsAString& aCharacterSet) const
|
||||
{
|
||||
CopyASCIItoUTF16(GetDocumentCharacterSet(), aCharacterSet);
|
||||
nsAutoCString charset;
|
||||
GetDocumentCharacterSet()->Name(charset);
|
||||
CopyASCIItoUTF16(charset, aCharacterSet);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -6592,9 +6595,7 @@ nsIDocument::LoadBindingDocument(const nsAString& aURI,
|
|||
ErrorResult& rv)
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = NS_NewURI(getter_AddRefs(uri), aURI,
|
||||
mCharacterSet.get(),
|
||||
GetDocBaseURI());
|
||||
rv = NS_NewURI(getter_AddRefs(uri), aURI, mCharacterSet, GetDocBaseURI());
|
||||
if (rv.Failed()) {
|
||||
return;
|
||||
}
|
||||
|
@ -9920,8 +9921,7 @@ nsDocument::ScrollToRef()
|
|||
// document's charset.
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
const nsACString &docCharset = GetDocumentCharacterSet();
|
||||
const Encoding* encoding = Encoding::ForName(docCharset);
|
||||
auto encoding = GetDocumentCharacterSet();
|
||||
|
||||
rv = encoding->DecodeWithoutBOMHandling(unescapedRef, ref);
|
||||
|
||||
|
|
|
@ -424,10 +424,11 @@ public:
|
|||
virtual void GetBaseTarget(nsAString &aBaseTarget) override;
|
||||
|
||||
/**
|
||||
* Return a standard name for the document's character set. This will
|
||||
* Set the document's character encoding. This will
|
||||
* trigger a startDocumentLoad if necessary to answer the question.
|
||||
*/
|
||||
virtual void SetDocumentCharacterSet(const nsACString& aCharSetID) override;
|
||||
virtual void
|
||||
SetDocumentCharacterSet(NotNull<const Encoding*> aEncoding) override;
|
||||
|
||||
/**
|
||||
* Add an observer that gets notified whenever the charset changes.
|
||||
|
@ -1048,7 +1049,7 @@ protected:
|
|||
|
||||
void TryChannelCharset(nsIChannel *aChannel,
|
||||
int32_t& aCharsetSource,
|
||||
nsACString& aCharset,
|
||||
NotNull<const Encoding*>& aEncoding,
|
||||
nsHtml5TreeOpExecutor* aExecutor);
|
||||
|
||||
// Call this before the document does something that will unbind all content.
|
||||
|
|
|
@ -272,16 +272,15 @@ nsFrameLoader::LoadFrame()
|
|||
}
|
||||
|
||||
nsCOMPtr<nsIURI> base_uri = mOwnerContent->GetBaseURI();
|
||||
const nsCString& doc_charset = doc->GetDocumentCharacterSet();
|
||||
const char *charset = doc_charset.IsEmpty() ? nullptr : doc_charset.get();
|
||||
auto encoding = doc->GetDocumentCharacterSet();
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(uri), src, charset, base_uri);
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(uri), src, encoding, base_uri);
|
||||
|
||||
// If the URI was malformed, try to recover by loading about:blank.
|
||||
if (rv == NS_ERROR_MALFORMED_URI) {
|
||||
rv = NS_NewURI(getter_AddRefs(uri), NS_LITERAL_STRING("about:blank"),
|
||||
charset, base_uri);
|
||||
encoding, base_uri);
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
|
|
@ -13491,14 +13491,14 @@ nsGlobalWindow::SecurityCheckURL(const char *aURL)
|
|||
// used to actually kick off the load in nsWindowWatcher.cpp.
|
||||
nsCOMPtr<nsIDocument> doc = sourceWindow->GetDoc();
|
||||
nsIURI* baseURI = nullptr;
|
||||
nsAutoCString charset(NS_LITERAL_CSTRING("UTF-8")); // default to utf-8
|
||||
auto encoding = UTF_8_ENCODING; // default to utf-8
|
||||
if (doc) {
|
||||
baseURI = doc->GetDocBaseURI();
|
||||
charset = doc->GetDocumentCharacterSet();
|
||||
encoding = doc->GetDocumentCharacterSet();
|
||||
}
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(uri), nsDependentCString(aURL),
|
||||
charset.get(), baseURI);
|
||||
encoding, baseURI);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "mozilla/CORSMode.h"
|
||||
#include "mozilla/dom/DispatcherTrait.h"
|
||||
#include "mozilla/LinkedList.h"
|
||||
#include "mozilla/NotNull.h"
|
||||
#include "mozilla/SegmentedVector.h"
|
||||
#include "mozilla/StyleBackendType.h"
|
||||
#include "mozilla/StyleSheet.h"
|
||||
|
@ -104,6 +105,7 @@ struct nsCSSSelectorList;
|
|||
namespace mozilla {
|
||||
class AbstractThread;
|
||||
class CSSStyleSheet;
|
||||
class Encoding;
|
||||
class ErrorResult;
|
||||
class EventStates;
|
||||
class PendingAnimationTracker;
|
||||
|
@ -211,6 +213,10 @@ class nsIDocument : public nsINode,
|
|||
{
|
||||
typedef mozilla::dom::GlobalObject GlobalObject;
|
||||
|
||||
protected:
|
||||
using Encoding = mozilla::Encoding;
|
||||
template <typename T> using NotNull = mozilla::NotNull<T>;
|
||||
|
||||
public:
|
||||
typedef mozilla::net::ReferrerPolicy ReferrerPolicyEnum;
|
||||
typedef mozilla::dom::Element Element;
|
||||
|
@ -504,16 +510,15 @@ public:
|
|||
/**
|
||||
* Return a standard name for the document's character set.
|
||||
*/
|
||||
const nsCString& GetDocumentCharacterSet() const
|
||||
NotNull<const Encoding*> GetDocumentCharacterSet() const
|
||||
{
|
||||
return mCharacterSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the document's character encoding. |aCharSetID| should be canonical.
|
||||
* That is, callers are responsible for the charset alias resolution.
|
||||
* Set the document's character encoding.
|
||||
*/
|
||||
virtual void SetDocumentCharacterSet(const nsACString& aCharSetID) = 0;
|
||||
virtual void SetDocumentCharacterSet(NotNull<const Encoding*> aEncoding) = 0;
|
||||
|
||||
int32_t GetDocumentCharacterSetSource() const
|
||||
{
|
||||
|
@ -3061,7 +3066,7 @@ protected:
|
|||
|
||||
mozilla::WeakPtr<nsDocShell> mDocumentContainer;
|
||||
|
||||
nsCString mCharacterSet;
|
||||
NotNull<const Encoding*> mCharacterSet;
|
||||
int32_t mCharacterSetSource;
|
||||
|
||||
// This is just a weak pointer; the parent document owns its children.
|
||||
|
|
|
@ -1128,12 +1128,12 @@ nsImageLoadingContent::StringToURI(const nsAString& aSpec,
|
|||
nsCOMPtr<nsIURI> baseURL = thisContent->GetBaseURI();
|
||||
|
||||
// (2) Get the charset
|
||||
const nsCString& charset = aDocument->GetDocumentCharacterSet();
|
||||
auto encoding = aDocument->GetDocumentCharacterSet();
|
||||
|
||||
// (3) Construct the silly thing
|
||||
return NS_NewURI(aURI,
|
||||
aSpec,
|
||||
charset.IsEmpty() ? nullptr : charset.get(),
|
||||
encoding,
|
||||
baseURL,
|
||||
nsContentUtils::GetIOService());
|
||||
}
|
||||
|
|
|
@ -33,8 +33,10 @@ nsReferencedElement::Reset(nsIContent* aFromContent, nsIURI* aURI,
|
|||
|
||||
nsAutoCString charset;
|
||||
aURI->GetOriginCharset(charset);
|
||||
const Encoding* encoding = charset.IsEmpty() ?
|
||||
UTF_8_ENCODING : Encoding::ForName(charset);
|
||||
auto encoding = Encoding::ForLabelNoReplacement(charset);
|
||||
if (!encoding) {
|
||||
encoding = UTF_8_ENCODING;
|
||||
}
|
||||
nsAutoString ref;
|
||||
nsresult rv = encoding->DecodeWithoutBOMHandling(refPart, ref);
|
||||
if (NS_FAILED(rv) || ref.IsEmpty()) {
|
||||
|
|
|
@ -53,6 +53,11 @@ ChooseValidatorCompileOptions(const ShBuiltInResources& resources,
|
|||
// Work around that Mac drivers handle struct scopes incorrectly.
|
||||
options |= SH_REGENERATE_STRUCT_NAMES;
|
||||
options |= SH_INIT_OUTPUT_VARIABLES;
|
||||
|
||||
// Work around that Intel drivers on Mac OSX handle for-loop incorrectly.
|
||||
if (gl->Vendor() == gl::GLVendor::Intel) {
|
||||
options |= SH_ADD_AND_TRUE_TO_LOOP_CONDITION;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!gl->IsANGLE() && gl->Vendor() == gl::GLVendor::Intel) {
|
||||
|
|
|
@ -36,34 +36,33 @@ FallbackEncoding* FallbackEncoding::sInstance = nullptr;
|
|||
bool FallbackEncoding::sGuessFallbackFromTopLevelDomain = true;
|
||||
|
||||
FallbackEncoding::FallbackEncoding()
|
||||
: mFallback(nullptr)
|
||||
{
|
||||
MOZ_ASSERT(!FallbackEncoding::sInstance,
|
||||
"Singleton already exists.");
|
||||
}
|
||||
|
||||
void
|
||||
FallbackEncoding::Get(nsACString& aFallback)
|
||||
NotNull<const Encoding*>
|
||||
FallbackEncoding::Get()
|
||||
{
|
||||
if (!mFallback.IsEmpty()) {
|
||||
aFallback = mFallback;
|
||||
return;
|
||||
if (mFallback) {
|
||||
return WrapNotNull(mFallback);
|
||||
}
|
||||
|
||||
const nsAdoptingCString& override =
|
||||
Preferences::GetCString("intl.charset.fallback.override");
|
||||
// Don't let the user break things by setting the override to unreasonable
|
||||
// values via about:config
|
||||
const Encoding* encoding = Encoding::ForLabel(override);
|
||||
auto encoding = Encoding::ForLabel(override);
|
||||
if (!encoding || !encoding->IsAsciiCompatible() ||
|
||||
encoding == UTF_8_ENCODING) {
|
||||
mFallback.Truncate();
|
||||
mFallback = nullptr;
|
||||
} else {
|
||||
encoding->Name(mFallback);
|
||||
mFallback = encoding;
|
||||
}
|
||||
|
||||
if (!mFallback.IsEmpty()) {
|
||||
aFallback = mFallback;
|
||||
return;
|
||||
if (mFallback) {
|
||||
return WrapNotNull(mFallback);
|
||||
}
|
||||
|
||||
nsAutoCString locale;
|
||||
|
@ -80,9 +79,8 @@ FallbackEncoding::Get(nsACString& aFallback)
|
|||
locale.EqualsLiteral("zh-hk") ||
|
||||
locale.EqualsLiteral("zh-mo") ||
|
||||
locale.EqualsLiteral("zh-hant")) {
|
||||
mFallback.AssignLiteral("Big5");
|
||||
aFallback = mFallback;
|
||||
return;
|
||||
mFallback = BIG5_ENCODING;
|
||||
return WrapNotNull(mFallback);
|
||||
}
|
||||
|
||||
// Throw away regions and other variants to accommodate weird stuff seen
|
||||
|
@ -92,20 +90,23 @@ FallbackEncoding::Get(nsACString& aFallback)
|
|||
locale.Truncate(index);
|
||||
}
|
||||
|
||||
nsAutoCString fallback;
|
||||
if (NS_FAILED(nsUConvPropertySearch::SearchPropertyValue(
|
||||
localesFallbacks, ArrayLength(localesFallbacks), locale, mFallback))) {
|
||||
mFallback.AssignLiteral("windows-1252");
|
||||
localesFallbacks, ArrayLength(localesFallbacks), locale, fallback))) {
|
||||
mFallback = WINDOWS_1252_ENCODING;
|
||||
} else {
|
||||
mFallback = Encoding::ForName(fallback);
|
||||
}
|
||||
|
||||
aFallback = mFallback;
|
||||
return WrapNotNull(mFallback);
|
||||
}
|
||||
|
||||
void
|
||||
FallbackEncoding::FromLocale(nsACString& aFallback)
|
||||
NotNull<const Encoding*>
|
||||
FallbackEncoding::FromLocale()
|
||||
{
|
||||
MOZ_ASSERT(FallbackEncoding::sInstance,
|
||||
"Using uninitialized fallback cache.");
|
||||
FallbackEncoding::sInstance->Get(aFallback);
|
||||
return FallbackEncoding::sInstance->Get();
|
||||
}
|
||||
|
||||
// PrefChangedFunc
|
||||
|
@ -169,14 +170,15 @@ FallbackEncoding::IsParticipatingTopLevelDomain(const nsACString& aTLD)
|
|||
dummy));
|
||||
}
|
||||
|
||||
void
|
||||
FallbackEncoding::FromTopLevelDomain(const nsACString& aTLD,
|
||||
nsACString& aFallback)
|
||||
NotNull<const Encoding*>
|
||||
FallbackEncoding::FromTopLevelDomain(const nsACString& aTLD)
|
||||
{
|
||||
nsAutoCString fallback;
|
||||
if (NS_FAILED(nsUConvPropertySearch::SearchPropertyValue(
|
||||
domainsFallbacks, ArrayLength(domainsFallbacks), aTLD, aFallback))) {
|
||||
aFallback.AssignLiteral("windows-1252");
|
||||
domainsFallbacks, ArrayLength(domainsFallbacks), aTLD, fallback))) {
|
||||
return WINDOWS_1252_ENCODING;
|
||||
}
|
||||
return Encoding::ForName(fallback);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -7,10 +7,12 @@
|
|||
#ifndef mozilla_dom_FallbackEncoding_h_
|
||||
#define mozilla_dom_FallbackEncoding_h_
|
||||
|
||||
#include "mozilla/NotNull.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsString.h"
|
||||
|
||||
namespace mozilla {
|
||||
class Encoding;
|
||||
namespace dom {
|
||||
|
||||
class FallbackEncoding : public nsIObserver
|
||||
|
@ -30,7 +32,7 @@ public:
|
|||
*
|
||||
* @param aFallback the outparam for the fallback encoding
|
||||
*/
|
||||
static void FromLocale(nsACString& aFallback);
|
||||
static NotNull<const Encoding*> FromLocale();
|
||||
|
||||
/**
|
||||
* Checks if it is appropriate to call FromTopLevelDomain() for a given TLD.
|
||||
|
@ -47,7 +49,7 @@ public:
|
|||
* @param aTLD the top-level domain (in Punycode)
|
||||
* @param aFallback the outparam for the fallback encoding
|
||||
*/
|
||||
static void FromTopLevelDomain(const nsACString& aTLD, nsACString& aFallback);
|
||||
static NotNull<const Encoding*> FromTopLevelDomain(const nsACString& aTLD);
|
||||
|
||||
// public API ends here!
|
||||
|
||||
|
@ -78,7 +80,7 @@ private:
|
|||
*/
|
||||
void Invalidate()
|
||||
{
|
||||
mFallback.Truncate();
|
||||
mFallback = nullptr;
|
||||
}
|
||||
|
||||
static void PrefChanged(const char*, void*);
|
||||
|
@ -87,9 +89,9 @@ private:
|
|||
* Gets the fallback encoding label.
|
||||
* @param aFallback the fallback encoding
|
||||
*/
|
||||
void Get(nsACString& aFallback);
|
||||
NotNull<const Encoding*> Get();
|
||||
|
||||
nsCString mFallback;
|
||||
const Encoding* mFallback;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -887,7 +887,7 @@ GetSubmitEncoding(nsGenericHTMLElement* aForm)
|
|||
// Get the charset from document
|
||||
nsIDocument* doc = aForm->GetComposedDoc();
|
||||
if (doc) {
|
||||
return Encoding::ForName(doc->GetDocumentCharacterSet());
|
||||
return doc->GetDocumentCharacterSet();
|
||||
}
|
||||
return UTF_8_ENCODING;
|
||||
}
|
||||
|
|
|
@ -171,17 +171,16 @@ MediaDocument::StartDocumentLoad(const char* aCommand,
|
|||
// not being able to set the charset is not critical.
|
||||
NS_ENSURE_TRUE(docShell, NS_OK);
|
||||
|
||||
nsAutoCString charset;
|
||||
const Encoding* encoding;
|
||||
int32_t source;
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
// opening in a new tab
|
||||
docShell->GetParentCharset(charset, &source, getter_AddRefs(principal));
|
||||
docShell->GetParentCharset(encoding, &source, getter_AddRefs(principal));
|
||||
|
||||
if (!charset.IsEmpty() &&
|
||||
!charset.EqualsLiteral("UTF-8") &&
|
||||
if (encoding && encoding != UTF_8_ENCODING &&
|
||||
NodePrincipal()->Equals(principal)) {
|
||||
SetDocumentCharacterSetSource(source);
|
||||
SetDocumentCharacterSet(charset);
|
||||
SetDocumentCharacterSet(WrapNotNull(encoding));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -299,11 +298,14 @@ MediaDocument::GetFileName(nsAString& aResult, nsIChannel* aChannel)
|
|||
// window or a new tab, in which case |originCharset| of |nsIURI| is not
|
||||
// reliable.
|
||||
if (mCharacterSetSource != kCharsetUninitialized) {
|
||||
docCharset = mCharacterSet;
|
||||
mCharacterSet->Name(docCharset);
|
||||
} else {
|
||||
// resort to |originCharset|
|
||||
url->GetOriginCharset(docCharset);
|
||||
SetDocumentCharacterSet(docCharset);
|
||||
auto encoding = Encoding::ForLabelNoReplacement(docCharset);
|
||||
if (encoding) {
|
||||
SetDocumentCharacterSet(WrapNotNull(encoding));
|
||||
}
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
|
|
|
@ -136,7 +136,7 @@ public:
|
|||
NS_IMETHOD WillResume(void) override;
|
||||
NS_IMETHOD SetParser(nsParserBase* aParser) override;
|
||||
virtual void FlushPendingNotifications(FlushType aType) override;
|
||||
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) override;
|
||||
virtual void SetDocumentCharset(NotNull<const Encoding*> aEncoding) override;
|
||||
virtual nsISupports *GetTarget() override;
|
||||
virtual bool IsScriptExecuting() override;
|
||||
|
||||
|
@ -1087,11 +1087,10 @@ HTMLContentSink::FlushTags()
|
|||
return mCurrentContext ? mCurrentContext->FlushTags() : NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLContentSink::SetDocumentCharset(nsACString& aCharset)
|
||||
void
|
||||
HTMLContentSink::SetDocumentCharset(NotNull<const Encoding*> aEncoding)
|
||||
{
|
||||
MOZ_ASSERT_UNREACHABLE("<meta charset> case doesn't occur with about:blank");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsISupports *
|
||||
|
|
|
@ -164,6 +164,12 @@ IsAsciiCompatible(const nsACString& aPreferredName)
|
|||
aPreferredName.LowerCaseEqualsLiteral("x-imap4-modified-utf7"));
|
||||
}
|
||||
|
||||
static bool
|
||||
IsAsciiCompatible(const Encoding* aEncoding)
|
||||
{
|
||||
return aEncoding->IsAsciiCompatible() || aEncoding == ISO_2022_JP_ENCODING;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewHTMLDocument(nsIDocument** aInstancePtrResult, bool aLoadedAsData)
|
||||
{
|
||||
|
@ -286,7 +292,8 @@ nsHTMLDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup,
|
|||
|
||||
void
|
||||
nsHTMLDocument::TryHintCharset(nsIContentViewer* aCv,
|
||||
int32_t& aCharsetSource, nsACString& aCharset)
|
||||
int32_t& aCharsetSource,
|
||||
NotNull<const Encoding*>& aEncoding)
|
||||
{
|
||||
if (aCv) {
|
||||
int32_t requestCharsetSource;
|
||||
|
@ -297,13 +304,15 @@ nsHTMLDocument::TryHintCharset(nsIContentViewer* aCv,
|
|||
rv = aCv->GetHintCharacterSet(requestCharset);
|
||||
aCv->SetHintCharacterSetSource((int32_t)(kCharsetUninitialized));
|
||||
|
||||
if(requestCharsetSource <= aCharsetSource)
|
||||
if (requestCharsetSource <= aCharsetSource)
|
||||
return;
|
||||
|
||||
if(NS_SUCCEEDED(rv) && IsAsciiCompatible(requestCharset)) {
|
||||
if (NS_SUCCEEDED(rv) && !requestCharset.IsEmpty()) {
|
||||
auto encoding = Encoding::ForName(requestCharset);
|
||||
if (IsAsciiCompatible(encoding)) {
|
||||
aCharsetSource = requestCharsetSource;
|
||||
aCharset = requestCharset;
|
||||
|
||||
aEncoding = encoding;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -316,15 +325,15 @@ void
|
|||
nsHTMLDocument::TryUserForcedCharset(nsIContentViewer* aCv,
|
||||
nsIDocShell* aDocShell,
|
||||
int32_t& aCharsetSource,
|
||||
nsACString& aCharset)
|
||||
NotNull<const Encoding*>& aEncoding)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if(kCharsetFromUserForced <= aCharsetSource)
|
||||
return;
|
||||
|
||||
// mCharacterSet not updated yet for channel, so check aCharset, too.
|
||||
if (WillIgnoreCharsetOverride() || !IsAsciiCompatible(aCharset)) {
|
||||
// mCharacterSet not updated yet for channel, so check aEncoding, too.
|
||||
if (WillIgnoreCharsetOverride() || !IsAsciiCompatible(aEncoding)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -337,21 +346,20 @@ nsHTMLDocument::TryUserForcedCharset(nsIContentViewer* aCv,
|
|||
if(NS_SUCCEEDED(rv) &&
|
||||
!forceCharsetFromDocShell.IsEmpty() &&
|
||||
IsAsciiCompatible(forceCharsetFromDocShell)) {
|
||||
aCharset = forceCharsetFromDocShell;
|
||||
aEncoding = Encoding::ForName(forceCharsetFromDocShell);
|
||||
aCharsetSource = kCharsetFromUserForced;
|
||||
return;
|
||||
}
|
||||
|
||||
if (aDocShell) {
|
||||
// This is the Character Encoding menu code path in Firefox
|
||||
nsAutoCString charset;
|
||||
rv = aDocShell->GetForcedCharset(charset);
|
||||
auto encoding = nsDocShell::Cast(aDocShell)->GetForcedCharset();
|
||||
|
||||
if (NS_SUCCEEDED(rv) && !charset.IsEmpty()) {
|
||||
if (!IsAsciiCompatible(charset)) {
|
||||
if (encoding) {
|
||||
if (!IsAsciiCompatible(encoding)) {
|
||||
return;
|
||||
}
|
||||
aCharset = charset;
|
||||
aEncoding = WrapNotNull(encoding);
|
||||
aCharsetSource = kCharsetFromUserForced;
|
||||
aDocShell->SetForcedCharset(NS_LITERAL_CSTRING(""));
|
||||
}
|
||||
|
@ -361,7 +369,7 @@ nsHTMLDocument::TryUserForcedCharset(nsIContentViewer* aCv,
|
|||
void
|
||||
nsHTMLDocument::TryCacheCharset(nsICachingChannel* aCachingChannel,
|
||||
int32_t& aCharsetSource,
|
||||
nsACString& aCharset)
|
||||
NotNull<const Encoding*>& aEncoding)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
@ -389,15 +397,14 @@ nsHTMLDocument::TryCacheCharset(nsICachingChannel* aCachingChannel,
|
|||
if (!encoding->IsAsciiCompatible() && encoding != ISO_2022_JP_ENCODING) {
|
||||
return;
|
||||
}
|
||||
encoding->Name(cachedCharset);
|
||||
aCharset = cachedCharset;
|
||||
aEncoding = WrapNotNull(encoding);
|
||||
aCharsetSource = kCharsetFromCache;
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLDocument::TryParentCharset(nsIDocShell* aDocShell,
|
||||
int32_t& aCharsetSource,
|
||||
nsACString& aCharset)
|
||||
NotNull<const Encoding*>& aEncoding)
|
||||
{
|
||||
if (!aDocShell) {
|
||||
return;
|
||||
|
@ -407,22 +414,22 @@ nsHTMLDocument::TryParentCharset(nsIDocShell* aDocShell,
|
|||
}
|
||||
|
||||
int32_t parentSource;
|
||||
nsAutoCString parentCharset;
|
||||
const Encoding* parentCharset;
|
||||
nsCOMPtr<nsIPrincipal> parentPrincipal;
|
||||
aDocShell->GetParentCharset(parentCharset,
|
||||
&parentSource,
|
||||
getter_AddRefs(parentPrincipal));
|
||||
if (parentCharset.IsEmpty()) {
|
||||
if (!parentCharset) {
|
||||
return;
|
||||
}
|
||||
if (kCharsetFromParentForced == parentSource ||
|
||||
kCharsetFromUserForced == parentSource) {
|
||||
if (WillIgnoreCharsetOverride() ||
|
||||
!IsAsciiCompatible(aCharset) || // if channel said UTF-16
|
||||
!IsAsciiCompatible(aEncoding) || // if channel said UTF-16
|
||||
!IsAsciiCompatible(parentCharset)) {
|
||||
return;
|
||||
}
|
||||
aCharset.Assign(parentCharset);
|
||||
aEncoding = WrapNotNull(parentCharset);
|
||||
aCharsetSource = kCharsetFromParentForced;
|
||||
return;
|
||||
}
|
||||
|
@ -438,13 +445,14 @@ nsHTMLDocument::TryParentCharset(nsIDocShell* aDocShell,
|
|||
return;
|
||||
}
|
||||
|
||||
aCharset.Assign(parentCharset);
|
||||
aEncoding = WrapNotNull(parentCharset);
|
||||
aCharsetSource = kCharsetFromParentFrame;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLDocument::TryTLD(int32_t& aCharsetSource, nsACString& aCharset)
|
||||
nsHTMLDocument::TryTLD(int32_t& aCharsetSource,
|
||||
NotNull<const Encoding*>& aEncoding)
|
||||
{
|
||||
if (aCharsetSource >= kCharsetFromTopLevelDomain) {
|
||||
return;
|
||||
|
@ -500,29 +508,32 @@ nsHTMLDocument::TryTLD(int32_t& aCharsetSource, nsACString& aCharset)
|
|||
return;
|
||||
}
|
||||
aCharsetSource = kCharsetFromTopLevelDomain;
|
||||
FallbackEncoding::FromTopLevelDomain(tld, aCharset);
|
||||
aEncoding = FallbackEncoding::FromTopLevelDomain(tld);
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLDocument::TryFallback(int32_t& aCharsetSource, nsACString& aCharset)
|
||||
nsHTMLDocument::TryFallback(int32_t& aCharsetSource,
|
||||
NotNull<const Encoding*>& aEncoding)
|
||||
{
|
||||
if (kCharsetFromFallback <= aCharsetSource)
|
||||
return;
|
||||
|
||||
aCharsetSource = kCharsetFromFallback;
|
||||
FallbackEncoding::FromLocale(aCharset);
|
||||
aEncoding = FallbackEncoding::FromLocale();
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLDocument::SetDocumentCharacterSet(const nsACString& aCharSetID)
|
||||
nsHTMLDocument::SetDocumentCharacterSet(NotNull<const Encoding*> aEncoding)
|
||||
{
|
||||
nsDocument::SetDocumentCharacterSet(aCharSetID);
|
||||
nsDocument::SetDocumentCharacterSet(aEncoding);
|
||||
// Make sure to stash this charset on our channel as needed if it's a wyciwyg
|
||||
// channel.
|
||||
nsCOMPtr<nsIWyciwygChannel> wyciwygChannel = do_QueryInterface(mChannel);
|
||||
if (wyciwygChannel) {
|
||||
nsAutoCString charset;
|
||||
aEncoding->Name(charset);
|
||||
wyciwygChannel->SetCharsetAndSource(GetDocumentCharacterSetSource(),
|
||||
aCharSetID);
|
||||
charset);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -671,12 +682,12 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
|||
|
||||
// These are the charset source and charset for our document
|
||||
int32_t charsetSource;
|
||||
nsAutoCString charset;
|
||||
auto encoding = UTF_8_ENCODING;
|
||||
|
||||
// These are the charset source and charset for the parser. This can differ
|
||||
// from that for the document if the channel is a wyciwyg channel.
|
||||
int32_t parserCharsetSource;
|
||||
nsAutoCString parserCharset;
|
||||
auto parserCharset = UTF_8_ENCODING;
|
||||
|
||||
nsCOMPtr<nsIWyciwygChannel> wyciwygChannel;
|
||||
|
||||
|
@ -693,16 +704,13 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
|||
|
||||
if (forceUtf8) {
|
||||
charsetSource = kCharsetFromUtf8OnlyMime;
|
||||
charset.AssignLiteral("UTF-8");
|
||||
parserCharsetSource = charsetSource;
|
||||
parserCharset = charset;
|
||||
} else if (!IsHTMLDocument() || !docShell) { // no docshell for text/html XHR
|
||||
charsetSource = IsHTMLDocument() ? kCharsetFromFallback
|
||||
: kCharsetFromDocTypeDefault;
|
||||
charset.AssignLiteral("UTF-8");
|
||||
TryChannelCharset(aChannel, charsetSource, charset, executor);
|
||||
TryChannelCharset(aChannel, charsetSource, encoding, executor);
|
||||
parserCharset = encoding;
|
||||
parserCharsetSource = charsetSource;
|
||||
parserCharset = charset;
|
||||
} else {
|
||||
NS_ASSERTION(docShell, "Unexpected null value");
|
||||
|
||||
|
@ -726,24 +734,24 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
|||
// content to a UTF-16 site such that the byte have a dangerous
|
||||
// interpretation as ASCII and the user can be lured to using the
|
||||
// charset menu.
|
||||
TryChannelCharset(aChannel, charsetSource, charset, executor);
|
||||
TryChannelCharset(aChannel, charsetSource, encoding, executor);
|
||||
}
|
||||
|
||||
TryUserForcedCharset(cv, docShell, charsetSource, charset);
|
||||
TryUserForcedCharset(cv, docShell, charsetSource, encoding);
|
||||
|
||||
TryHintCharset(cv, charsetSource, charset); // XXX mailnews-only
|
||||
TryParentCharset(docShell, charsetSource, charset);
|
||||
TryHintCharset(cv, charsetSource, encoding); // XXX mailnews-only
|
||||
TryParentCharset(docShell, charsetSource, encoding);
|
||||
|
||||
if (cachingChan && !urlSpec.IsEmpty()) {
|
||||
TryCacheCharset(cachingChan, charsetSource, charset);
|
||||
TryCacheCharset(cachingChan, charsetSource, encoding);
|
||||
}
|
||||
|
||||
TryTLD(charsetSource, charset);
|
||||
TryFallback(charsetSource, charset);
|
||||
TryTLD(charsetSource, encoding);
|
||||
TryFallback(charsetSource, encoding);
|
||||
|
||||
if (wyciwygChannel) {
|
||||
// We know for sure that the parser needs to be using UTF16.
|
||||
parserCharset = "UTF-16LE";
|
||||
parserCharset = UTF_16LE_ENCODING;
|
||||
parserCharsetSource = charsetSource < kCharsetFromChannel ?
|
||||
kCharsetFromChannel : charsetSource;
|
||||
|
||||
|
@ -752,27 +760,34 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
|||
rv = wyciwygChannel->GetCharsetAndSource(&cachedSource, cachedCharset);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (cachedSource > charsetSource) {
|
||||
auto cachedEncoding = Encoding::ForLabel(cachedCharset);
|
||||
if (!cachedEncoding && cachedCharset.EqualsLiteral("replacement")) {
|
||||
cachedEncoding = REPLACEMENT_ENCODING;
|
||||
}
|
||||
if (cachedEncoding) {
|
||||
charsetSource = cachedSource;
|
||||
charset = cachedCharset;
|
||||
encoding = WrapNotNull(cachedEncoding);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Don't propagate this error.
|
||||
rv = NS_OK;
|
||||
}
|
||||
|
||||
} else {
|
||||
parserCharset = charset;
|
||||
parserCharset = encoding;
|
||||
parserCharsetSource = charsetSource;
|
||||
}
|
||||
}
|
||||
|
||||
SetDocumentCharacterSetSource(charsetSource);
|
||||
SetDocumentCharacterSet(charset);
|
||||
SetDocumentCharacterSet(encoding);
|
||||
|
||||
if (cachingChan) {
|
||||
NS_ASSERTION(charset == parserCharset,
|
||||
NS_ASSERTION(encoding == parserCharset,
|
||||
"How did those end up different here? wyciwyg channels are "
|
||||
"not nsICachingChannel");
|
||||
nsAutoCString charset;
|
||||
encoding->Name(charset);
|
||||
rv = cachingChan->SetCacheTokenCachedCharset(charset);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "cannot SetMetaDataElement");
|
||||
rv = NS_OK; // don't propagate error
|
||||
|
@ -2416,8 +2431,9 @@ nsHTMLDocument::CreateAndAddWyciwygChannel(void)
|
|||
// Note: we want to treat this like a "previous document" hint so that,
|
||||
// e.g. a <meta> tag in the document.write content can override it.
|
||||
SetDocumentCharacterSetSource(kCharsetFromHintPrevDoc);
|
||||
mWyciwygChannel->SetCharsetAndSource(kCharsetFromHintPrevDoc,
|
||||
GetDocumentCharacterSet());
|
||||
nsAutoCString charset;
|
||||
GetDocumentCharacterSet()->Name(charset);
|
||||
mWyciwygChannel->SetCharsetAndSource(kCharsetFromHintPrevDoc, charset);
|
||||
|
||||
// Inherit load flags from the original document's channel
|
||||
channel->SetLoadFlags(mLoadFlags);
|
||||
|
@ -3745,7 +3761,8 @@ nsHTMLDocument::WillIgnoreCharsetOverride()
|
|||
if (mCharacterSetSource >= kCharsetFromByteOrderMark) {
|
||||
return true;
|
||||
}
|
||||
if (!IsAsciiCompatible(mCharacterSet)) {
|
||||
if (!mCharacterSet->IsAsciiCompatible() &&
|
||||
mCharacterSet != ISO_2022_JP_ENCODING) {
|
||||
return true;
|
||||
}
|
||||
nsCOMPtr<nsIWyciwygChannel> wyciwyg = do_QueryInterface(mChannel);
|
||||
|
|
|
@ -321,21 +321,24 @@ protected:
|
|||
|
||||
static void TryHintCharset(nsIContentViewer* aContentViewer,
|
||||
int32_t& aCharsetSource,
|
||||
nsACString& aCharset);
|
||||
NotNull<const Encoding*>& aEncoding);
|
||||
void TryUserForcedCharset(nsIContentViewer* aCv,
|
||||
nsIDocShell* aDocShell,
|
||||
int32_t& aCharsetSource,
|
||||
nsACString& aCharset);
|
||||
NotNull<const Encoding*>& aEncoding);
|
||||
static void TryCacheCharset(nsICachingChannel* aCachingChannel,
|
||||
int32_t& aCharsetSource,
|
||||
nsACString& aCharset);
|
||||
NotNull<const Encoding*>& aEncoding);
|
||||
void TryParentCharset(nsIDocShell* aDocShell,
|
||||
int32_t& charsetSource, nsACString& aCharset);
|
||||
void TryTLD(int32_t& aCharsetSource, nsACString& aCharset);
|
||||
static void TryFallback(int32_t& aCharsetSource, nsACString& aCharset);
|
||||
int32_t& charsetSource,
|
||||
NotNull<const Encoding*>& aEncoding);
|
||||
void TryTLD(int32_t& aCharsetSource, NotNull<const Encoding*>& aCharset);
|
||||
static void TryFallback(int32_t& aCharsetSource,
|
||||
NotNull<const Encoding*>& aEncoding);
|
||||
|
||||
// Override so we can munge the charset on our wyciwyg channel as needed.
|
||||
virtual void SetDocumentCharacterSet(const nsACString& aCharSetID) override;
|
||||
virtual void
|
||||
SetDocumentCharacterSet(NotNull<const Encoding*> aEncoding) override;
|
||||
|
||||
// Tracks if we are currently processing any document.write calls (either
|
||||
// implicit or explicit). Note that if a write call writes out something which
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "mozilla/dom/Notification.h"
|
||||
|
||||
#include "mozilla/Encoding.h"
|
||||
#include "mozilla/JSONWriter.h"
|
||||
#include "mozilla/Move.h"
|
||||
#include "mozilla/OwningNonNull.h"
|
||||
|
@ -1922,7 +1923,7 @@ Notification::ResolveIconAndSoundURL(nsString& iconUrl, nsString& soundUrl)
|
|||
// the API base URL and no override encoding. So we've to use UTF-8 on
|
||||
// workers, but for backwards compat keeping it document charset on main
|
||||
// thread.
|
||||
const char* charset = "UTF-8";
|
||||
auto encoding = UTF_8_ENCODING;
|
||||
|
||||
if (mWorkerPrivate) {
|
||||
baseUri = mWorkerPrivate->GetBaseURI();
|
||||
|
@ -1930,7 +1931,7 @@ Notification::ResolveIconAndSoundURL(nsString& iconUrl, nsString& soundUrl)
|
|||
nsIDocument* doc = GetOwner() ? GetOwner()->GetExtantDoc() : nullptr;
|
||||
if (doc) {
|
||||
baseUri = doc->GetBaseURI();
|
||||
charset = doc->GetDocumentCharacterSet().get();
|
||||
encoding = doc->GetDocumentCharacterSet();
|
||||
} else {
|
||||
NS_WARNING("No document found for main thread notification!");
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -1940,7 +1941,7 @@ Notification::ResolveIconAndSoundURL(nsString& iconUrl, nsString& soundUrl)
|
|||
if (baseUri) {
|
||||
if (mIconUrl.Length() > 0) {
|
||||
nsCOMPtr<nsIURI> srcUri;
|
||||
rv = NS_NewURI(getter_AddRefs(srcUri), mIconUrl, charset, baseUri);
|
||||
rv = NS_NewURI(getter_AddRefs(srcUri), mIconUrl, encoding, baseUri);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsAutoCString src;
|
||||
srcUri->GetSpec(src);
|
||||
|
@ -1949,7 +1950,7 @@ Notification::ResolveIconAndSoundURL(nsString& iconUrl, nsString& soundUrl)
|
|||
}
|
||||
if (mBehavior.mSoundFile.Length() > 0) {
|
||||
nsCOMPtr<nsIURI> srcUri;
|
||||
rv = NS_NewURI(getter_AddRefs(srcUri), mBehavior.mSoundFile, charset, baseUri);
|
||||
rv = NS_NewURI(getter_AddRefs(srcUri), mBehavior.mSoundFile, encoding, baseUri);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsAutoCString src;
|
||||
srcUri->GetSpec(src);
|
||||
|
|
|
@ -47,11 +47,13 @@ GetAbsoluteURL(const nsAString& aUrl,
|
|||
nsAString& aAbsoluteUrl)
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(uri),
|
||||
aUrl,
|
||||
aDocument ? aDocument->GetDocumentCharacterSet().get()
|
||||
: nullptr,
|
||||
aBaseUri);
|
||||
nsresult rv;
|
||||
if (aDocument) {
|
||||
rv = NS_NewURI(getter_AddRefs(uri), aUrl,
|
||||
aDocument->GetDocumentCharacterSet(), aBaseUri);
|
||||
} else {
|
||||
rv = NS_NewURI(getter_AddRefs(uri), aUrl, nullptr, aBaseUri);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
|
|
|
@ -228,8 +228,7 @@ ScriptLoadHandler::EnsureDecoder(nsIIncrementalStreamLoader* aLoader,
|
|||
|
||||
// Get the charset from the charset of the document.
|
||||
if (mScriptLoader->mDocument) {
|
||||
encoding =
|
||||
Encoding::ForName(mScriptLoader->mDocument->GetDocumentCharacterSet());
|
||||
encoding = mScriptLoader->mDocument->GetDocumentCharacterSet();
|
||||
mDecoder = encoding->NewDecoderWithoutBOMHandling();
|
||||
encoding->Name(oCharset);
|
||||
return true;
|
||||
|
|
|
@ -2569,7 +2569,7 @@ ScriptLoader::ConvertToUTF16(nsIChannel* aChannel, const uint8_t* aData,
|
|||
}
|
||||
|
||||
if (!unicodeDecoder && aDocument) {
|
||||
unicodeDecoder = Encoding::ForName(aDocument->GetDocumentCharacterSet())
|
||||
unicodeDecoder = aDocument->GetDocumentCharacterSet()
|
||||
->NewDecoderWithoutBOMHandling();
|
||||
}
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ WebBrowserPersistLocalDocument::GetContentType(nsACString& aContentType)
|
|||
NS_IMETHODIMP
|
||||
WebBrowserPersistLocalDocument::GetCharacterSet(nsACString& aCharSet)
|
||||
{
|
||||
aCharSet = GetCharacterSet();
|
||||
GetCharacterSet()->Name(aCharSet);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,7 @@ WebBrowserPersistLocalDocument::GetHistory()
|
|||
return history.forget();
|
||||
}
|
||||
|
||||
const nsCString&
|
||||
NotNull<const Encoding*>
|
||||
WebBrowserPersistLocalDocument::GetCharacterSet() const
|
||||
{
|
||||
return mDocument->GetDocumentCharacterSet();
|
||||
|
@ -397,7 +397,7 @@ ResourceReader::OnWalkURI(const nsACString& aURISpec)
|
|||
|
||||
rv = NS_NewURI(getter_AddRefs(uri),
|
||||
aURISpec,
|
||||
mParent->GetCharacterSet().get(),
|
||||
mParent->GetCharacterSet(),
|
||||
mCurrentBaseURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return OnWalkURI(uri);
|
||||
|
@ -552,7 +552,7 @@ ResourceReader::OnWalkDOMNode(nsIDOMNode* aNode)
|
|||
if (!codebase.IsEmpty()) {
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
rv = NS_NewURI(getter_AddRefs(baseURI), codebase,
|
||||
mParent->GetCharacterSet().get(), mCurrentBaseURI);
|
||||
mParent->GetCharacterSet(), mCurrentBaseURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (baseURI) {
|
||||
mCurrentBaseURI = baseURI;
|
||||
|
@ -717,7 +717,7 @@ PersistNodeFixup::FixupURI(nsAString &aURI)
|
|||
// get the current location of the file (absolutized)
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(uri), aURI,
|
||||
mParent->GetCharacterSet().get(), mCurrentBaseURI);
|
||||
mParent->GetCharacterSet(), mCurrentBaseURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsAutoCString spec;
|
||||
rv = uri->GetSpec(spec);
|
||||
|
@ -804,7 +804,7 @@ PersistNodeFixup::FixupAnchor(nsIDOMNode *aNode)
|
|||
// Make a new URI to replace the current one
|
||||
nsCOMPtr<nsIURI> newURI;
|
||||
rv = NS_NewURI(getter_AddRefs(newURI), oldCValue,
|
||||
mParent->GetCharacterSet().get(), relativeURI);
|
||||
mParent->GetCharacterSet(), relativeURI);
|
||||
if (NS_SUCCEEDED(rv) && newURI) {
|
||||
newURI->SetUserPass(EmptyCString());
|
||||
nsAutoCString uriSpec;
|
||||
|
@ -1130,7 +1130,7 @@ PersistNodeFixup::FixupNode(nsIDOMNode *aNodeIn,
|
|||
if (!codebase.IsEmpty()) {
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
NS_NewURI(getter_AddRefs(baseURI), codebase,
|
||||
mParent->GetCharacterSet().get(), mCurrentBaseURI);
|
||||
mParent->GetCharacterSet(), mCurrentBaseURI);
|
||||
if (baseURI) {
|
||||
mCurrentBaseURI = baseURI;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class WebBrowserPersistLocalDocument final
|
|||
public:
|
||||
explicit WebBrowserPersistLocalDocument(nsIDocument* aDocument);
|
||||
|
||||
const nsCString& GetCharacterSet() const;
|
||||
NotNull<const Encoding*> GetCharacterSet() const;
|
||||
uint32_t GetPersistFlags() const;
|
||||
already_AddRefed<nsIURI> GetBaseURI() const;
|
||||
|
||||
|
|
|
@ -1632,7 +1632,7 @@ nsXBLPrototypeBinding::ResolveBaseBinding()
|
|||
mBinding->UnsetAttr(kNameSpaceID_None, nsGkAtoms::display, false);
|
||||
|
||||
return NS_NewURI(getter_AddRefs(mBaseBindingURI), value,
|
||||
doc->GetDocumentCharacterSet().get(),
|
||||
doc->GetDocumentCharacterSet(),
|
||||
doc->GetDocBaseURI());
|
||||
}
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ nsXBLResourceLoader::LoadResources(nsIContent* aBoundElement)
|
|||
continue;
|
||||
|
||||
if (NS_FAILED(NS_NewURI(getter_AddRefs(url), curr->mSrc,
|
||||
doc->GetDocumentCharacterSet().get(), docURL)))
|
||||
doc->GetDocumentCharacterSet(), docURL)))
|
||||
continue;
|
||||
|
||||
if (curr->mType == nsGkAtoms::image) {
|
||||
|
|
|
@ -182,6 +182,7 @@ XMLHttpRequestMainThread::sDontWarnAboutSyncXHR = false;
|
|||
|
||||
XMLHttpRequestMainThread::XMLHttpRequestMainThread()
|
||||
: mResponseBodyDecodedPos(0),
|
||||
mResponseCharset(nullptr),
|
||||
mResponseType(XMLHttpRequestResponseType::_empty),
|
||||
mRequestObserver(nullptr),
|
||||
mState(State::unsent),
|
||||
|
@ -496,7 +497,7 @@ XMLHttpRequestMainThread::GetResponseXML(ErrorResult& aRv)
|
|||
nsresult
|
||||
XMLHttpRequestMainThread::DetectCharset()
|
||||
{
|
||||
mResponseCharset.Truncate();
|
||||
mResponseCharset = nullptr;
|
||||
mDecoder = nullptr;
|
||||
|
||||
if (mResponseType != XMLHttpRequestResponseType::_empty &&
|
||||
|
@ -523,7 +524,7 @@ XMLHttpRequestMainThread::DetectCharset()
|
|||
encoding = UTF_8_ENCODING;
|
||||
}
|
||||
|
||||
encoding->Name(mResponseCharset);
|
||||
mResponseCharset = encoding;
|
||||
mDecoder = encoding->NewDecoderWithBOMRemoval();
|
||||
|
||||
return NS_OK;
|
||||
|
@ -2435,7 +2436,7 @@ XMLHttpRequestMainThread::MatchCharsetAndDecoderToResponseDocument()
|
|||
mResponseCharset = mResponseXML->GetDocumentCharacterSet();
|
||||
TruncateResponseText();
|
||||
mResponseBodyDecodedPos = 0;
|
||||
mDecoder = Encoding::ForName(mResponseCharset)->NewDecoderWithBOMRemoval();
|
||||
mDecoder = mResponseCharset->NewDecoderWithBOMRemoval();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -708,7 +708,7 @@ protected:
|
|||
// part of the surrogate.
|
||||
mozilla::UniquePtr<mozilla::Decoder> mDecoder;
|
||||
|
||||
nsCString mResponseCharset;
|
||||
const Encoding* mResponseCharset;
|
||||
|
||||
void MatchCharsetAndDecoderToResponseDocument();
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
|
|||
|
||||
// XMLDocuments and documents "created in memory" get to be UTF-8 by default,
|
||||
// unlike the legacy HTML mess
|
||||
doc->SetDocumentCharacterSet(NS_LITERAL_CSTRING("UTF-8"));
|
||||
doc->SetDocumentCharacterSet(UTF_8_ENCODING);
|
||||
|
||||
if (aDoctype) {
|
||||
nsCOMPtr<nsINode> doctypeAsNode = do_QueryInterface(aDoctype);
|
||||
|
@ -322,7 +322,7 @@ XMLDocument::Load(const nsAString& aUrl, CallerType aCallerType,
|
|||
|
||||
if (callingDoc) {
|
||||
baseURI = callingDoc->GetDocBaseURI();
|
||||
charset = callingDoc->GetDocumentCharacterSet();
|
||||
callingDoc->GetDocumentCharacterSet()->Name(charset);
|
||||
}
|
||||
|
||||
// Create a new URI
|
||||
|
@ -530,8 +530,8 @@ XMLDocument::StartDocumentLoad(const char* aCommand,
|
|||
|
||||
|
||||
int32_t charsetSource = kCharsetFromDocTypeDefault;
|
||||
nsAutoCString charset(NS_LITERAL_CSTRING("UTF-8"));
|
||||
TryChannelCharset(aChannel, charsetSource, charset, nullptr);
|
||||
NotNull<const Encoding*> encoding = UTF_8_ENCODING;
|
||||
TryChannelCharset(aChannel, charsetSource, encoding, nullptr);
|
||||
|
||||
nsCOMPtr<nsIURI> aUrl;
|
||||
rv = aChannel->GetURI(getter_AddRefs(aUrl));
|
||||
|
@ -565,8 +565,8 @@ XMLDocument::StartDocumentLoad(const char* aCommand,
|
|||
NS_ASSERTION(mChannel, "How can we not have a channel here?");
|
||||
mChannelIsPending = true;
|
||||
|
||||
SetDocumentCharacterSet(charset);
|
||||
mParser->SetDocumentCharset(charset, charsetSource);
|
||||
SetDocumentCharacterSet(encoding);
|
||||
mParser->SetDocumentCharset(encoding, charsetSource);
|
||||
mParser->SetCommand(aCommand);
|
||||
mParser->SetContentSink(sink);
|
||||
mParser->Parse(aUrl, nullptr, (void *)this);
|
||||
|
|
|
@ -115,15 +115,14 @@ XMLStylesheetProcessingInstruction::GetStyleSheetURL(bool* aIsInline)
|
|||
}
|
||||
|
||||
nsIURI *baseURL;
|
||||
nsAutoCString charset;
|
||||
nsIDocument *document = OwnerDoc();
|
||||
baseURL = mOverriddenBaseURI ?
|
||||
mOverriddenBaseURI.get() :
|
||||
document->GetDocBaseURI();
|
||||
charset = document->GetDocumentCharacterSet();
|
||||
auto encoding = document->GetDocumentCharacterSet();
|
||||
|
||||
nsCOMPtr<nsIURI> aURI;
|
||||
NS_NewURI(getter_AddRefs(aURI), href, charset.get(), baseURL);
|
||||
NS_NewURI(getter_AddRefs(aURI), href, encoding, baseURL);
|
||||
return aURI.forget();
|
||||
}
|
||||
|
||||
|
|
|
@ -731,14 +731,12 @@ nsXMLContentSink::ProcessStyleLink(nsIContent* aElement,
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLContentSink::SetDocumentCharset(nsACString& aCharset)
|
||||
void
|
||||
nsXMLContentSink::SetDocumentCharset(NotNull<const Encoding*> aEncoding)
|
||||
{
|
||||
if (mDocument) {
|
||||
mDocument->SetDocumentCharacterSet(aCharset);
|
||||
mDocument->SetDocumentCharacterSet(aEncoding);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsISupports *
|
||||
|
|
|
@ -70,7 +70,7 @@ public:
|
|||
NS_IMETHOD WillResume(void) override;
|
||||
NS_IMETHOD SetParser(nsParserBase* aParser) override;
|
||||
virtual void FlushPendingNotifications(mozilla::FlushType aType) override;
|
||||
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) override;
|
||||
virtual void SetDocumentCharset(NotNull<const Encoding*> aEncoding) override;
|
||||
virtual nsISupports *GetTarget() override;
|
||||
virtual bool IsScriptExecuting() override;
|
||||
virtual void ContinueInterruptedParsingAsync() override;
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
// nsIContentSink
|
||||
NS_IMETHOD WillBuildModel(nsDTDMode aDTDMode) override;
|
||||
NS_IMETHOD DidBuildModel(bool aTerminated) override;
|
||||
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) override;
|
||||
virtual void SetDocumentCharset(NotNull<const Encoding*> aEncoding) override;
|
||||
virtual nsISupports* GetTarget() override;
|
||||
NS_IMETHOD DidProcessATokenImpl();
|
||||
|
||||
|
@ -173,11 +173,11 @@ nsXMLFragmentContentSink::DidBuildModel(bool aTerminated)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLFragmentContentSink::SetDocumentCharset(nsACString& aCharset)
|
||||
void
|
||||
nsXMLFragmentContentSink::SetDocumentCharset(
|
||||
NotNull<const Encoding*> aEncoding)
|
||||
{
|
||||
NS_NOTREACHED("fragments shouldn't set charset");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsISupports *
|
||||
|
|
|
@ -84,7 +84,8 @@ public:
|
|||
NS_IMETHOD WillResume(void) override { return NS_OK; }
|
||||
NS_IMETHOD SetParser(nsParserBase* aParser) override { return NS_OK; }
|
||||
virtual void FlushPendingNotifications(mozilla::FlushType aType) override { }
|
||||
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) override { return NS_OK; }
|
||||
virtual void SetDocumentCharset(NotNull<const Encoding*> aEncoding)
|
||||
override { }
|
||||
virtual nsISupports *GetTarget() override { return nullptr; }
|
||||
|
||||
private:
|
||||
|
@ -269,9 +270,7 @@ txStylesheetSink::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext)
|
|||
encoding = UTF_8_ENCODING;
|
||||
}
|
||||
|
||||
nsAutoCString charset;
|
||||
encoding->Name(charset);
|
||||
mParser->SetDocumentCharset(charset, charsetSource);
|
||||
mParser->SetDocumentCharset(WrapNotNull(encoding), charsetSource);
|
||||
|
||||
nsAutoCString contentType;
|
||||
channel->GetContentType(contentType);
|
||||
|
|
|
@ -163,9 +163,7 @@ txMozillaTextOutput::createResultDocument(nsIDOMDocument* aSourceDocument,
|
|||
const Encoding* encoding = Encoding::ForLabel(mOutputFormat.mEncoding);
|
||||
if (encoding) {
|
||||
mDocument->SetDocumentCharacterSetSource(kCharsetFromOtherComponent);
|
||||
nsAutoCString canonicalCharset;
|
||||
encoding->Name(canonicalCharset);
|
||||
mDocument->SetDocumentCharacterSet(canonicalCharset);
|
||||
mDocument->SetDocumentCharacterSet(WrapNotNull(encoding));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -823,9 +823,7 @@ txMozillaXMLOutput::createResultDocument(const nsAString& aName, int32_t aNsID,
|
|||
const Encoding* encoding = Encoding::ForLabel(mOutputFormat.mEncoding);
|
||||
if (encoding) {
|
||||
mDocument->SetDocumentCharacterSetSource(kCharsetFromOtherComponent);
|
||||
nsAutoCString canonicalCharset;
|
||||
encoding->Name(canonicalCharset);
|
||||
mDocument->SetDocumentCharacterSet(canonicalCharset);
|
||||
mDocument->SetDocumentCharacterSet(WrapNotNull(encoding));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -213,7 +213,7 @@ XULDocument::XULDocument(void)
|
|||
mHandlingDelayedBroadcasters(false)
|
||||
{
|
||||
// Override the default in nsDocument
|
||||
mCharacterSet.AssignLiteral("UTF-8");
|
||||
mCharacterSet = UTF_8_ENCODING;
|
||||
|
||||
mDefaultElementType = kNameSpaceID_XUL;
|
||||
mType = eXUL;
|
||||
|
@ -2025,7 +2025,7 @@ XULDocument::PrepareToLoadPrototype(nsIURI* aURI, const char* aCommand,
|
|||
parser->SetCommand(nsCRT::strcmp(aCommand, "view-source") ? eViewNormal :
|
||||
eViewSource);
|
||||
|
||||
parser->SetDocumentCharset(NS_LITERAL_CSTRING("UTF-8"),
|
||||
parser->SetDocumentCharset(UTF_8_ENCODING,
|
||||
kCharsetFromDocTypeDefault);
|
||||
parser->SetContentSink(sink); // grabs a reference to the parser
|
||||
|
||||
|
|
|
@ -256,15 +256,13 @@ XULContentSinkImpl::SetParser(nsParserBase* aParser)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULContentSinkImpl::SetDocumentCharset(nsACString& aCharset)
|
||||
void
|
||||
XULContentSinkImpl::SetDocumentCharset(NotNull<const Encoding*> aEncoding)
|
||||
{
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocument);
|
||||
if (doc) {
|
||||
doc->SetDocumentCharacterSet(aCharset);
|
||||
doc->SetDocumentCharacterSet(aEncoding);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsISupports *
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
NS_IMETHOD WillResume(void) override;
|
||||
NS_IMETHOD SetParser(nsParserBase* aParser) override;
|
||||
virtual void FlushPendingNotifications(mozilla::FlushType aType) override { }
|
||||
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) override;
|
||||
virtual void SetDocumentCharset(NotNull<const Encoding*> aEncoding) override;
|
||||
virtual nsISupports *GetTarget() override;
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "mozilla/EditorBase.h"
|
||||
|
||||
#include "mozilla/DebugOnly.h" // for DebugOnly
|
||||
#include "mozilla/Encoding.h" // for Encoding
|
||||
|
||||
#include <stdio.h> // for nullptr, stdout
|
||||
#include <string.h> // for strcmp
|
||||
|
@ -1180,7 +1181,7 @@ EditorBase::GetDocumentCharacterSet(nsACString& characterSet)
|
|||
if (NS_WARN_IF(!document)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
characterSet = document->GetDocumentCharacterSet();
|
||||
document->GetDocumentCharacterSet()->Name(characterSet);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1191,7 +1192,13 @@ EditorBase::SetDocumentCharacterSet(const nsACString& characterSet)
|
|||
if (NS_WARN_IF(!document)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
document->SetDocumentCharacterSet(characterSet);
|
||||
// This method is scriptable, so add-ons could pass in something other
|
||||
// than a canonical name.
|
||||
auto encoding = Encoding::ForLabelNoReplacement(characterSet);
|
||||
if (!encoding) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
document->SetDocumentCharacterSet(WrapNotNull(encoding));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ GPUVideoTextureHost::AddWRImage(wr::WebRenderAPI* aAPI,
|
|||
void
|
||||
GPUVideoTextureHost::PushExternalImage(wr::DisplayListBuilder& aBuilder,
|
||||
const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
wr::ImageRendering aFilter,
|
||||
Range<const wr::ImageKey>& aImageKeys)
|
||||
{
|
||||
|
|
|
@ -57,7 +57,7 @@ public:
|
|||
|
||||
virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
|
||||
const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
wr::ImageRendering aFilter,
|
||||
Range<const wr::ImageKey>& aImageKeys) override;
|
||||
|
||||
|
|
|
@ -625,7 +625,7 @@ BufferTextureHost::AddWRImage(wr::WebRenderAPI* aAPI,
|
|||
void
|
||||
BufferTextureHost::PushExternalImage(wr::DisplayListBuilder& aBuilder,
|
||||
const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
wr::ImageRendering aFilter,
|
||||
Range<const wr::ImageKey>& aImageKeys)
|
||||
{
|
||||
|
|
|
@ -644,7 +644,7 @@ public:
|
|||
// Put all necessary WR commands into DisplayListBuilder for this textureHost rendering.
|
||||
virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
|
||||
const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
wr::ImageRendering aFilter,
|
||||
Range<const wr::ImageKey>& aKeys)
|
||||
{
|
||||
|
@ -750,7 +750,7 @@ public:
|
|||
|
||||
virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
|
||||
const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
wr::ImageRendering aFilter,
|
||||
Range<const wr::ImageKey>& aImageKeys) override;
|
||||
|
||||
|
|
|
@ -918,7 +918,7 @@ DXGITextureHostD3D11::AddWRImage(wr::WebRenderAPI* aAPI,
|
|||
void
|
||||
DXGITextureHostD3D11::PushExternalImage(wr::DisplayListBuilder& aBuilder,
|
||||
const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
wr::ImageRendering aFilter,
|
||||
Range<const wr::ImageKey>& aImageKeys)
|
||||
{
|
||||
|
@ -1085,7 +1085,7 @@ DXGIYCbCrTextureHostD3D11::AddWRImage(wr::WebRenderAPI* aAPI,
|
|||
void
|
||||
DXGIYCbCrTextureHostD3D11::PushExternalImage(wr::DisplayListBuilder& aBuilder,
|
||||
const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
wr::ImageRendering aFilter,
|
||||
Range<const wr::ImageKey>& aImageKeys)
|
||||
{
|
||||
|
|
|
@ -335,7 +335,7 @@ public:
|
|||
|
||||
virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
|
||||
const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
wr::ImageRendering aFilter,
|
||||
Range<const wr::ImageKey>& aImageKeys) override;
|
||||
|
||||
|
@ -396,7 +396,7 @@ public:
|
|||
|
||||
virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
|
||||
const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
wr::ImageRendering aFilter,
|
||||
Range<const wr::ImageKey>& aImageKeys) override;
|
||||
|
||||
|
|
|
@ -225,7 +225,7 @@ MacIOSurfaceTextureHostOGL::AddWRImage(wr::WebRenderAPI* aAPI,
|
|||
void
|
||||
MacIOSurfaceTextureHostOGL::PushExternalImage(wr::DisplayListBuilder& aBuilder,
|
||||
const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
wr::ImageRendering aFilter,
|
||||
Range<const wr::ImageKey>& aImageKeys)
|
||||
{
|
||||
|
|
|
@ -73,7 +73,7 @@ public:
|
|||
|
||||
virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
|
||||
const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
wr::ImageRendering aFilter,
|
||||
Range<const wr::ImageKey>& aImageKeys) override;
|
||||
|
||||
|
|
|
@ -217,9 +217,8 @@ WebRenderBridgeChild::PushGlyphs(wr::DisplayListBuilder& aBuilder, const nsTArra
|
|||
LayerPoint::FromUnknownPoint(glyphs[j].mPosition));
|
||||
}
|
||||
|
||||
WrClipRegionToken clipRegion = aBuilder.PushClipRegion(aSc.ToRelativeWrRect(aClip));
|
||||
aBuilder.PushText(aSc.ToRelativeWrRect(aBounds),
|
||||
clipRegion,
|
||||
aSc.ToRelativeWrRect(aClip),
|
||||
glyph_array.color().value(),
|
||||
key,
|
||||
Range<const WrGlyphInstance>(wr_glyph_instances.Elements(), wr_glyph_instances.Length()),
|
||||
|
|
|
@ -69,8 +69,6 @@ WebRenderCanvasLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
|
|||
LayerRect rect(0, 0, mBounds.width, mBounds.height);
|
||||
DumpLayerInfo("CanvasLayer", rect);
|
||||
|
||||
WrClipRegionToken clip = aBuilder.PushClipRegion(sc.ToRelativeWrRect(rect));
|
||||
|
||||
wr::ImageRendering filter = wr::ToImageRendering(mSamplingFilter);
|
||||
|
||||
if (gfxPrefs::LayersDump()) {
|
||||
|
@ -83,7 +81,8 @@ WebRenderCanvasLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
|
|||
WrBridge()->AddWebRenderParentCommand(OpAddExternalImage(mExternalImageId.value(), key));
|
||||
WrManager()->AddImageKeyForDiscard(key);
|
||||
|
||||
aBuilder.PushImage(sc.ToRelativeWrRect(rect), clip, filter, key);
|
||||
WrRect r = sc.ToRelativeWrRect(rect);
|
||||
aBuilder.PushImage(r, r, filter, key);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -28,9 +28,8 @@ WebRenderColorLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
|
|||
LayerRect rect = Bounds();
|
||||
DumpLayerInfo("ColorLayer", rect);
|
||||
|
||||
WrClipRegionToken clip = aBuilder.PushClipRegion(sc.ToRelativeWrRect(rect));
|
||||
|
||||
aBuilder.PushRect(sc.ToRelativeWrRect(rect), clip, wr::ToWrColor(mColor));
|
||||
WrRect r = sc.ToRelativeWrRect(rect);
|
||||
aBuilder.PushRect(r, r, wr::ToWrColor(mColor));
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
|
|
|
@ -279,22 +279,20 @@ WebRenderCompositableHolder::ApplyAsyncImages(wr::WebRenderAPI* aApi)
|
|||
if (holder->mScaleToSize.isSome()) {
|
||||
rect = LayerRect(0, 0, holder->mScaleToSize.value().width, holder->mScaleToSize.value().height);
|
||||
}
|
||||
WrClipRegionToken clip = builder.PushClipRegion(
|
||||
wr::ToWrRect(rect), nullptr);
|
||||
|
||||
if (useExternalImage) {
|
||||
MOZ_ASSERT(holder->mCurrentTexture->AsWebRenderTextureHost());
|
||||
Range<const wr::ImageKey> range_keys(&keys[0], keys.Length());
|
||||
holder->mCurrentTexture->PushExternalImage(builder,
|
||||
wr::ToWrRect(rect),
|
||||
clip,
|
||||
wr::ToWrRect(rect),
|
||||
holder->mFilter,
|
||||
range_keys);
|
||||
HoldExternalImage(pipelineId, epoch, holder->mCurrentTexture->AsWebRenderTextureHost());
|
||||
} else {
|
||||
MOZ_ASSERT(keys.Length() == 1);
|
||||
builder.PushImage(wr::ToWrRect(rect),
|
||||
clip,
|
||||
wr::ToWrRect(rect),
|
||||
holder->mFilter,
|
||||
keys[0]);
|
||||
}
|
||||
|
|
|
@ -150,8 +150,8 @@ WebRenderRefLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
|
|||
PixelCastJustification::MovingDownToChildren);
|
||||
DumpLayerInfo("RefLayer", rect);
|
||||
|
||||
WrClipRegionToken clipRegion = aBuilder.PushClipRegion(aSc.ToRelativeWrRect(rect));
|
||||
aBuilder.PushIFrame(aSc.ToRelativeWrRect(rect), clipRegion, wr::AsPipelineId(mId));
|
||||
WrRect r = aSc.ToRelativeWrRect(rect);
|
||||
aBuilder.PushIFrame(r, r, wr::AsPipelineId(mId));
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
|
|
|
@ -139,13 +139,12 @@ WebRenderDisplayItemLayer::PushItemAsBlobImage(wr::DisplayListBuilder& aBuilder,
|
|||
wr::ByteBuffer bytes(recorder->mOutputStream.mLength, (uint8_t*)recorder->mOutputStream.mData);
|
||||
|
||||
WrRect dest = aSc.ToRelativeWrRect(imageRect + offset);
|
||||
WrClipRegionToken clipRegion = aBuilder.PushClipRegion(dest);
|
||||
WrImageKey key = GetImageKey();
|
||||
WrBridge()->SendAddBlobImage(key, imageSize.ToUnknownSize(), imageSize.width * 4, dt->GetFormat(), bytes);
|
||||
WrManager()->AddImageKeyForDiscard(key);
|
||||
|
||||
aBuilder.PushImage(dest,
|
||||
clipRegion,
|
||||
dest,
|
||||
wr::ImageRendering::Auto,
|
||||
key);
|
||||
return true;
|
||||
|
|
|
@ -159,8 +159,8 @@ WebRenderImageLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
|
|||
PixelCastJustification::MovingDownToChildren);
|
||||
DumpLayerInfo("Image Layer async", rect);
|
||||
|
||||
WrClipRegionToken clipRegion = aBuilder.PushClipRegion(aSc.ToRelativeWrRect(rect));
|
||||
aBuilder.PushIFrame(aSc.ToRelativeWrRect(rect), clipRegion, mPipelineId.ref());
|
||||
WrRect r = aSc.ToRelativeWrRect(rect);
|
||||
aBuilder.PushIFrame(r, r, mPipelineId.ref());
|
||||
|
||||
gfx::Matrix4x4 scTransform = GetTransform();
|
||||
// Translate is applied as part of PushIFrame()
|
||||
|
@ -215,8 +215,6 @@ WebRenderImageLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
|
|||
rect = LayerRect(0, 0, mScaleToSize.width, mScaleToSize.height);
|
||||
}
|
||||
|
||||
WrClipRegionToken clip = aBuilder.PushClipRegion(
|
||||
sc.ToRelativeWrRect(rect));
|
||||
wr::ImageRendering filter = wr::ToImageRendering(mSamplingFilter);
|
||||
|
||||
DumpLayerInfo("Image Layer", rect);
|
||||
|
@ -225,7 +223,8 @@ WebRenderImageLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
|
|||
GetLayer(),
|
||||
Stringify(filter).c_str());
|
||||
}
|
||||
aBuilder.PushImage(sc.ToRelativeWrRect(rect), clip, filter, mKey.value());
|
||||
WrRect r = sc.ToRelativeWrRect(rect);
|
||||
aBuilder.PushImage(r, r, filter, mKey.value());
|
||||
}
|
||||
|
||||
Maybe<WrImageMask>
|
||||
|
|
|
@ -100,13 +100,12 @@ WebRenderPaintedLayer::CreateWebRenderDisplayList(wr::DisplayListBuilder& aBuild
|
|||
LayerRect rect = Bounds();
|
||||
DumpLayerInfo("PaintedLayer", rect);
|
||||
|
||||
WrClipRegionToken clip = aBuilder.PushClipRegion(sc.ToRelativeWrRect(rect));
|
||||
|
||||
WrImageKey key = GetImageKey();
|
||||
WrBridge()->AddWebRenderParentCommand(OpAddExternalImage(mExternalImageId.value(), key));
|
||||
WrManager()->AddImageKeyForDiscard(key);
|
||||
|
||||
aBuilder.PushImage(sc.ToRelativeWrRect(rect), clip, wr::ImageRendering::Auto, key);
|
||||
WrRect r = sc.ToRelativeWrRect(rect);
|
||||
aBuilder.PushImage(r, r, wr::ImageRendering::Auto, key);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -89,9 +89,8 @@ WebRenderPaintedLayerBlob::RenderLayer(wr::DisplayListBuilder& aBuilder,
|
|||
LayerRect rect = Bounds();
|
||||
DumpLayerInfo("PaintedLayer", rect);
|
||||
|
||||
WrClipRegionToken clip = aBuilder.PushClipRegion(sc.ToRelativeWrRect(rect));
|
||||
|
||||
aBuilder.PushImage(sc.ToRelativeWrRect(rect), clip, wr::ImageRendering::Auto, mImageKey.value());
|
||||
WrRect r = sc.ToRelativeWrRect(rect);
|
||||
aBuilder.PushImage(r, r, wr::ImageRendering::Auto, mImageKey.value());
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
|
|
|
@ -179,7 +179,7 @@ WebRenderTextureHost::AddWRImage(wr::WebRenderAPI* aAPI,
|
|||
void
|
||||
WebRenderTextureHost::PushExternalImage(wr::DisplayListBuilder& aBuilder,
|
||||
const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
wr::ImageRendering aFilter,
|
||||
Range<const wr::ImageKey>& aImageKeys)
|
||||
{
|
||||
|
|
|
@ -74,7 +74,7 @@ public:
|
|||
|
||||
virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
|
||||
const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
wr::ImageRendering aFilter,
|
||||
Range<const wr::ImageKey>& aImageKeys) override;
|
||||
|
||||
|
|
|
@ -652,18 +652,20 @@ DisplayListBuilder::PopClipAndScrollInfo()
|
|||
|
||||
void
|
||||
DisplayListBuilder::PushRect(const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
const WrColor& aColor)
|
||||
{
|
||||
WRDL_LOG("PushRect b=%s c=%s\n",
|
||||
WRDL_LOG("PushRect b=%s cl=%s c=%s\n",
|
||||
Stringify(aBounds).c_str(),
|
||||
Stringify(aClip).c_str(),
|
||||
Stringify(aColor).c_str());
|
||||
wr_dp_push_rect(mWrState, aBounds, aClip, aColor);
|
||||
WrClipRegionToken tok = wr_dp_push_clip_region(mWrState, aClip, nullptr, 0, nullptr);
|
||||
wr_dp_push_rect(mWrState, aBounds, tok, aColor);
|
||||
}
|
||||
|
||||
void
|
||||
DisplayListBuilder::PushLinearGradient(const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
const WrPoint& aStartPoint,
|
||||
const WrPoint& aEndPoint,
|
||||
const nsTArray<WrGradientStop>& aStops,
|
||||
|
@ -671,8 +673,9 @@ DisplayListBuilder::PushLinearGradient(const WrRect& aBounds,
|
|||
const WrSize aTileSize,
|
||||
const WrSize aTileSpacing)
|
||||
{
|
||||
WrClipRegionToken tok = wr_dp_push_clip_region(mWrState, aClip, nullptr, 0, nullptr);
|
||||
wr_dp_push_linear_gradient(mWrState,
|
||||
aBounds, aClip,
|
||||
aBounds, tok,
|
||||
aStartPoint, aEndPoint,
|
||||
aStops.Elements(), aStops.Length(),
|
||||
aExtendMode,
|
||||
|
@ -681,7 +684,7 @@ DisplayListBuilder::PushLinearGradient(const WrRect& aBounds,
|
|||
|
||||
void
|
||||
DisplayListBuilder::PushRadialGradient(const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
const WrPoint& aCenter,
|
||||
const WrSize& aRadius,
|
||||
const nsTArray<WrGradientStop>& aStops,
|
||||
|
@ -689,8 +692,9 @@ DisplayListBuilder::PushRadialGradient(const WrRect& aBounds,
|
|||
const WrSize aTileSize,
|
||||
const WrSize aTileSpacing)
|
||||
{
|
||||
WrClipRegionToken tok = wr_dp_push_clip_region(mWrState, aClip, nullptr, 0, nullptr);
|
||||
wr_dp_push_radial_gradient(mWrState,
|
||||
aBounds, aClip,
|
||||
aBounds, tok,
|
||||
aCenter, aRadius,
|
||||
aStops.Elements(), aStops.Length(),
|
||||
aExtendMode,
|
||||
|
@ -699,7 +703,7 @@ DisplayListBuilder::PushRadialGradient(const WrRect& aBounds,
|
|||
|
||||
void
|
||||
DisplayListBuilder::PushImage(const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
wr::ImageRendering aFilter,
|
||||
wr::ImageKey aImage)
|
||||
{
|
||||
|
@ -711,29 +715,32 @@ DisplayListBuilder::PushImage(const WrRect& aBounds,
|
|||
|
||||
void
|
||||
DisplayListBuilder::PushImage(const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
const WrSize& aStretchSize,
|
||||
const WrSize& aTileSpacing,
|
||||
wr::ImageRendering aFilter,
|
||||
wr::ImageKey aImage)
|
||||
{
|
||||
WRDL_LOG("PushImage b=%s s=%s t=%s\n", Stringify(aBounds).c_str(),
|
||||
Stringify(aStretchSize).c_str(), Stringify(aTileSpacing).c_str());
|
||||
wr_dp_push_image(mWrState, aBounds, aClip, aStretchSize, aTileSpacing, aFilter, aImage);
|
||||
WrClipRegionToken tok = wr_dp_push_clip_region(mWrState, aClip, nullptr, 0, nullptr);
|
||||
WRDL_LOG("PushImage b=%s cl=%s s=%s t=%s\n", Stringify(aBounds).c_str(),
|
||||
Stringify(aClip).c_str(), Stringify(aStretchSize).c_str(),
|
||||
Stringify(aTileSpacing).c_str());
|
||||
wr_dp_push_image(mWrState, aBounds, tok, aStretchSize, aTileSpacing, aFilter, aImage);
|
||||
}
|
||||
|
||||
void
|
||||
DisplayListBuilder::PushYCbCrPlanarImage(const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
wr::ImageKey aImageChannel0,
|
||||
wr::ImageKey aImageChannel1,
|
||||
wr::ImageKey aImageChannel2,
|
||||
WrYuvColorSpace aColorSpace,
|
||||
wr::ImageRendering aRendering)
|
||||
{
|
||||
WrClipRegionToken tok = wr_dp_push_clip_region(mWrState, aClip, nullptr, 0, nullptr);
|
||||
wr_dp_push_yuv_planar_image(mWrState,
|
||||
aBounds,
|
||||
aClip,
|
||||
tok,
|
||||
aImageChannel0,
|
||||
aImageChannel1,
|
||||
aImageChannel2,
|
||||
|
@ -743,15 +750,16 @@ DisplayListBuilder::PushYCbCrPlanarImage(const WrRect& aBounds,
|
|||
|
||||
void
|
||||
DisplayListBuilder::PushNV12Image(const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
wr::ImageKey aImageChannel0,
|
||||
wr::ImageKey aImageChannel1,
|
||||
WrYuvColorSpace aColorSpace,
|
||||
wr::ImageRendering aRendering)
|
||||
{
|
||||
WrClipRegionToken tok = wr_dp_push_clip_region(mWrState, aClip, nullptr, 0, nullptr);
|
||||
wr_dp_push_yuv_NV12_image(mWrState,
|
||||
aBounds,
|
||||
aClip,
|
||||
tok,
|
||||
aImageChannel0,
|
||||
aImageChannel1,
|
||||
aColorSpace,
|
||||
|
@ -760,14 +768,15 @@ DisplayListBuilder::PushNV12Image(const WrRect& aBounds,
|
|||
|
||||
void
|
||||
DisplayListBuilder::PushYCbCrInterleavedImage(const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
wr::ImageKey aImageChannel0,
|
||||
WrYuvColorSpace aColorSpace,
|
||||
wr::ImageRendering aRendering)
|
||||
{
|
||||
WrClipRegionToken tok = wr_dp_push_clip_region(mWrState, aClip, nullptr, 0, nullptr);
|
||||
wr_dp_push_yuv_interleaved_image(mWrState,
|
||||
aBounds,
|
||||
aClip,
|
||||
tok,
|
||||
aImageChannel0,
|
||||
aColorSpace,
|
||||
aRendering);
|
||||
|
@ -775,15 +784,16 @@ DisplayListBuilder::PushYCbCrInterleavedImage(const WrRect& aBounds,
|
|||
|
||||
void
|
||||
DisplayListBuilder::PushIFrame(const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
PipelineId aPipeline)
|
||||
{
|
||||
wr_dp_push_iframe(mWrState, aBounds, aClip, aPipeline);
|
||||
WrClipRegionToken tok = wr_dp_push_clip_region(mWrState, aClip, nullptr, 0, nullptr);
|
||||
wr_dp_push_iframe(mWrState, aBounds, tok, aPipeline);
|
||||
}
|
||||
|
||||
void
|
||||
DisplayListBuilder::PushBorder(const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
const WrBorderWidths& aWidths,
|
||||
const WrBorderSide& aTop,
|
||||
const WrBorderSide& aRight,
|
||||
|
@ -791,13 +801,14 @@ DisplayListBuilder::PushBorder(const WrRect& aBounds,
|
|||
const WrBorderSide& aLeft,
|
||||
const WrBorderRadius& aRadius)
|
||||
{
|
||||
wr_dp_push_border(mWrState, aBounds, aClip,
|
||||
WrClipRegionToken tok = wr_dp_push_clip_region(mWrState, aClip, nullptr, 0, nullptr);
|
||||
wr_dp_push_border(mWrState, aBounds, tok,
|
||||
aWidths, aTop, aRight, aBottom, aLeft, aRadius);
|
||||
}
|
||||
|
||||
void
|
||||
DisplayListBuilder::PushBorderImage(const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
const WrBorderWidths& aWidths,
|
||||
wr::ImageKey aImage,
|
||||
const WrNinePatchDescriptor& aPatch,
|
||||
|
@ -805,14 +816,15 @@ DisplayListBuilder::PushBorderImage(const WrRect& aBounds,
|
|||
const WrRepeatMode& aRepeatHorizontal,
|
||||
const WrRepeatMode& aRepeatVertical)
|
||||
{
|
||||
wr_dp_push_border_image(mWrState, aBounds, aClip,
|
||||
WrClipRegionToken tok = wr_dp_push_clip_region(mWrState, aClip, nullptr, 0, nullptr);
|
||||
wr_dp_push_border_image(mWrState, aBounds, tok,
|
||||
aWidths, aImage, aPatch, aOutset,
|
||||
aRepeatHorizontal, aRepeatVertical);
|
||||
}
|
||||
|
||||
void
|
||||
DisplayListBuilder::PushBorderGradient(const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
const WrBorderWidths& aWidths,
|
||||
const WrPoint& aStartPoint,
|
||||
const WrPoint& aEndPoint,
|
||||
|
@ -820,7 +832,8 @@ DisplayListBuilder::PushBorderGradient(const WrRect& aBounds,
|
|||
wr::GradientExtendMode aExtendMode,
|
||||
const WrSideOffsets2Df32& aOutset)
|
||||
{
|
||||
wr_dp_push_border_gradient(mWrState, aBounds, aClip,
|
||||
WrClipRegionToken tok = wr_dp_push_clip_region(mWrState, aClip, nullptr, 0, nullptr);
|
||||
wr_dp_push_border_gradient(mWrState, aBounds, tok,
|
||||
aWidths, aStartPoint, aEndPoint,
|
||||
aStops.Elements(), aStops.Length(),
|
||||
aExtendMode, aOutset);
|
||||
|
@ -828,7 +841,7 @@ DisplayListBuilder::PushBorderGradient(const WrRect& aBounds,
|
|||
|
||||
void
|
||||
DisplayListBuilder::PushBorderRadialGradient(const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
const WrBorderWidths& aWidths,
|
||||
const WrPoint& aCenter,
|
||||
const WrSize& aRadius,
|
||||
|
@ -836,21 +849,23 @@ DisplayListBuilder::PushBorderRadialGradient(const WrRect& aBounds,
|
|||
wr::GradientExtendMode aExtendMode,
|
||||
const WrSideOffsets2Df32& aOutset)
|
||||
{
|
||||
WrClipRegionToken tok = wr_dp_push_clip_region(mWrState, aClip, nullptr, 0, nullptr);
|
||||
wr_dp_push_border_radial_gradient(
|
||||
mWrState, aBounds, aClip, aWidths, aCenter,
|
||||
mWrState, aBounds, tok, aWidths, aCenter,
|
||||
aRadius, aStops.Elements(), aStops.Length(),
|
||||
aExtendMode, aOutset);
|
||||
}
|
||||
|
||||
void
|
||||
DisplayListBuilder::PushText(const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
const gfx::Color& aColor,
|
||||
wr::FontKey aFontKey,
|
||||
Range<const WrGlyphInstance> aGlyphBuffer,
|
||||
float aGlyphSize)
|
||||
{
|
||||
wr_dp_push_text(mWrState, aBounds, aClip,
|
||||
WrClipRegionToken tok = wr_dp_push_clip_region(mWrState, aClip, nullptr, 0, nullptr);
|
||||
wr_dp_push_text(mWrState, aBounds, tok,
|
||||
ToWrColor(aColor),
|
||||
aFontKey,
|
||||
&aGlyphBuffer[0], aGlyphBuffer.length(),
|
||||
|
@ -859,7 +874,7 @@ DisplayListBuilder::PushText(const WrRect& aBounds,
|
|||
|
||||
void
|
||||
DisplayListBuilder::PushBoxShadow(const WrRect& aRect,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
const WrRect& aBoxBounds,
|
||||
const WrPoint& aOffset,
|
||||
const WrColor& aColor,
|
||||
|
@ -868,38 +883,13 @@ DisplayListBuilder::PushBoxShadow(const WrRect& aRect,
|
|||
const float& aBorderRadius,
|
||||
const WrBoxShadowClipMode& aClipMode)
|
||||
{
|
||||
wr_dp_push_box_shadow(mWrState, aRect, aClip,
|
||||
WrClipRegionToken tok = wr_dp_push_clip_region(mWrState, aClip, nullptr, 0, nullptr);
|
||||
wr_dp_push_box_shadow(mWrState, aRect, tok,
|
||||
aBoxBounds, aOffset, aColor,
|
||||
aBlurRadius, aSpreadRadius, aBorderRadius,
|
||||
aClipMode);
|
||||
}
|
||||
|
||||
WrClipRegionToken
|
||||
DisplayListBuilder::PushClipRegion(const WrRect& aMain,
|
||||
const WrImageMask* aMask)
|
||||
{
|
||||
WRDL_LOG("PushClipRegion r=%s m=%p b=%s\n", Stringify(aMain).c_str(), aMask,
|
||||
aMask ? Stringify(aMask->rect).c_str() : "none");
|
||||
return wr_dp_push_clip_region(mWrState,
|
||||
aMain,
|
||||
nullptr, 0,
|
||||
aMask);
|
||||
}
|
||||
|
||||
WrClipRegionToken
|
||||
DisplayListBuilder::PushClipRegion(const WrRect& aMain,
|
||||
const nsTArray<WrComplexClipRegion>& aComplex,
|
||||
const WrImageMask* aMask)
|
||||
{
|
||||
WRDL_LOG("PushClipRegion r=%s cl=%d m=%p b=%s\n", Stringify(aMain).c_str(),
|
||||
(int)aComplex.Length(), aMask,
|
||||
aMask ? Stringify(aMask->rect).c_str() : "none");
|
||||
return wr_dp_push_clip_region(mWrState,
|
||||
aMain,
|
||||
aComplex.Elements(), aComplex.Length(),
|
||||
aMask);
|
||||
}
|
||||
|
||||
Maybe<WrClipId>
|
||||
DisplayListBuilder::TopmostClipId()
|
||||
{
|
||||
|
|
|
@ -174,11 +174,11 @@ public:
|
|||
void PopClipAndScrollInfo();
|
||||
|
||||
void PushRect(const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
const WrColor& aColor);
|
||||
|
||||
void PushLinearGradient(const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
const WrPoint& aStartPoint,
|
||||
const WrPoint& aEndPoint,
|
||||
const nsTArray<WrGradientStop>& aStops,
|
||||
|
@ -187,7 +187,7 @@ public:
|
|||
const WrSize aTileSpacing);
|
||||
|
||||
void PushRadialGradient(const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
const WrPoint& aCenter,
|
||||
const WrSize& aRadius,
|
||||
const nsTArray<WrGradientStop>& aStops,
|
||||
|
@ -196,19 +196,19 @@ public:
|
|||
const WrSize aTileSpacing);
|
||||
|
||||
void PushImage(const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
wr::ImageRendering aFilter,
|
||||
wr::ImageKey aImage);
|
||||
|
||||
void PushImage(const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
const WrSize& aStretchSize,
|
||||
const WrSize& aTileSpacing,
|
||||
wr::ImageRendering aFilter,
|
||||
wr::ImageKey aImage);
|
||||
|
||||
void PushYCbCrPlanarImage(const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
wr::ImageKey aImageChannel0,
|
||||
wr::ImageKey aImageChannel1,
|
||||
wr::ImageKey aImageChannel2,
|
||||
|
@ -216,24 +216,24 @@ public:
|
|||
wr::ImageRendering aFilter);
|
||||
|
||||
void PushNV12Image(const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
wr::ImageKey aImageChannel0,
|
||||
wr::ImageKey aImageChannel1,
|
||||
WrYuvColorSpace aColorSpace,
|
||||
wr::ImageRendering aFilter);
|
||||
|
||||
void PushYCbCrInterleavedImage(const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
wr::ImageKey aImageChannel0,
|
||||
WrYuvColorSpace aColorSpace,
|
||||
wr::ImageRendering aFilter);
|
||||
|
||||
void PushIFrame(const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
wr::PipelineId aPipeline);
|
||||
|
||||
void PushBorder(const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
const WrBorderWidths& aWidths,
|
||||
const WrBorderSide& aTop,
|
||||
const WrBorderSide& aRight,
|
||||
|
@ -242,7 +242,7 @@ public:
|
|||
const WrBorderRadius& aRadius);
|
||||
|
||||
void PushBorderImage(const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
const WrBorderWidths& aWidths,
|
||||
wr::ImageKey aImage,
|
||||
const WrNinePatchDescriptor& aPatch,
|
||||
|
@ -251,7 +251,7 @@ public:
|
|||
const WrRepeatMode& aRepeatVertical);
|
||||
|
||||
void PushBorderGradient(const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
const WrBorderWidths& aWidths,
|
||||
const WrPoint& aStartPoint,
|
||||
const WrPoint& aEndPoint,
|
||||
|
@ -260,7 +260,7 @@ public:
|
|||
const WrSideOffsets2Df32& aOutset);
|
||||
|
||||
void PushBorderRadialGradient(const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
const WrBorderWidths& aWidths,
|
||||
const WrPoint& aCenter,
|
||||
const WrSize& aRadius,
|
||||
|
@ -269,14 +269,14 @@ public:
|
|||
const WrSideOffsets2Df32& aOutset);
|
||||
|
||||
void PushText(const WrRect& aBounds,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
const gfx::Color& aColor,
|
||||
wr::FontKey aFontKey,
|
||||
Range<const WrGlyphInstance> aGlyphBuffer,
|
||||
float aGlyphSize);
|
||||
|
||||
void PushBoxShadow(const WrRect& aRect,
|
||||
const WrClipRegionToken aClip,
|
||||
const WrRect& aClip,
|
||||
const WrRect& aBoxBounds,
|
||||
const WrPoint& aOffset,
|
||||
const WrColor& aColor,
|
||||
|
@ -285,12 +285,6 @@ public:
|
|||
const float& aBorderRadius,
|
||||
const WrBoxShadowClipMode& aClipMode);
|
||||
|
||||
WrClipRegionToken PushClipRegion(const WrRect& aMain,
|
||||
const WrImageMask* aMask = nullptr);
|
||||
WrClipRegionToken PushClipRegion(const WrRect& aMain,
|
||||
const nsTArray<WrComplexClipRegion>& aComplex,
|
||||
const WrImageMask* aMask = nullptr);
|
||||
|
||||
// Returns the clip id that was most recently pushed with PushClip and that
|
||||
// has not yet been popped with PopClip. Return Nothing() if the clip stack
|
||||
// is empty.
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "nsIAtom.h"
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/Encoding.h"
|
||||
#include "mozilla/intl/OSPreferences.h"
|
||||
#include "mozilla/ServoBindings.h"
|
||||
|
||||
|
@ -46,11 +47,13 @@ nsLanguageAtomService::LookupLanguage(const nsACString &aLanguage)
|
|||
}
|
||||
|
||||
already_AddRefed<nsIAtom>
|
||||
nsLanguageAtomService::LookupCharSet(const nsACString& aCharSet)
|
||||
nsLanguageAtomService::LookupCharSet(NotNull<const Encoding*> aEncoding)
|
||||
{
|
||||
nsAutoCString charset;
|
||||
aEncoding->Name(charset);
|
||||
nsAutoCString group;
|
||||
if (NS_FAILED(nsUConvPropertySearch::SearchPropertyValue(
|
||||
encodingsGroups, ArrayLength(encodingsGroups), aCharSet, group))) {
|
||||
encodingsGroups, ArrayLength(encodingsGroups), charset, group))) {
|
||||
return RefPtr<nsIAtom>(nsGkAtoms::Unicode).forget();
|
||||
}
|
||||
return NS_Atomize(group);
|
||||
|
|
|
@ -11,17 +11,24 @@
|
|||
#ifndef nsLanguageAtomService_h_
|
||||
#define nsLanguageAtomService_h_
|
||||
|
||||
#include "mozilla/NotNull.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsInterfaceHashtable.h"
|
||||
|
||||
class nsLanguageAtomService
|
||||
namespace mozilla {
|
||||
class Encoding;
|
||||
}
|
||||
|
||||
class nsLanguageAtomService final
|
||||
{
|
||||
using Encoding = mozilla::Encoding;
|
||||
template <typename T> using NotNull = mozilla::NotNull<T>;
|
||||
public:
|
||||
static nsLanguageAtomService* GetService();
|
||||
|
||||
nsIAtom* LookupLanguage(const nsACString &aLanguage);
|
||||
already_AddRefed<nsIAtom> LookupCharSet(const nsACString& aCharSet);
|
||||
already_AddRefed<nsIAtom> LookupCharSet(NotNull<const Encoding*> aCharSet);
|
||||
nsIAtom* GetLocaleLanguage();
|
||||
|
||||
// Returns the language group that the specified language is a part of.
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/Encoding.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventStateManager.h"
|
||||
|
||||
|
@ -120,7 +121,7 @@ class CharSetChangingRunnable : public Runnable
|
|||
{
|
||||
public:
|
||||
CharSetChangingRunnable(nsPresContext* aPresContext,
|
||||
const nsCString& aCharSet)
|
||||
NotNull<const Encoding*> aCharSet)
|
||||
: Runnable("CharSetChangingRunnable"),
|
||||
mPresContext(aPresContext),
|
||||
mCharSet(aCharSet)
|
||||
|
@ -135,7 +136,7 @@ public:
|
|||
|
||||
private:
|
||||
RefPtr<nsPresContext> mPresContext;
|
||||
nsCString mCharSet;
|
||||
NotNull<const Encoding*> mCharSet;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
@ -196,15 +197,9 @@ nsPresContext::PrefChangedUpdateTimerCallback(nsITimer *aTimer, void *aClosure)
|
|||
}
|
||||
|
||||
static bool
|
||||
IsVisualCharset(const nsCString& aCharset)
|
||||
IsVisualCharset(NotNull<const Encoding*> aCharset)
|
||||
{
|
||||
if (aCharset.LowerCaseEqualsLiteral("ibm862") // Hebrew
|
||||
|| aCharset.LowerCaseEqualsLiteral("iso-8859-8") ) { // Hebrew
|
||||
return true; // visual text type
|
||||
}
|
||||
else {
|
||||
return false; // logical text type
|
||||
}
|
||||
return aCharset == ISO_8859_8_ENCODING;
|
||||
}
|
||||
|
||||
nsPresContext::nsPresContext(nsIDocument* aDocument, nsPresContextType aType)
|
||||
|
@ -1070,7 +1065,7 @@ nsPresContext::DetachShell()
|
|||
}
|
||||
|
||||
void
|
||||
nsPresContext::DoChangeCharSet(const nsCString& aCharSet)
|
||||
nsPresContext::DoChangeCharSet(NotNull<const Encoding*> aCharSet)
|
||||
{
|
||||
UpdateCharSet(aCharSet);
|
||||
mDeviceContext->FlushFontCache();
|
||||
|
@ -1078,7 +1073,7 @@ nsPresContext::DoChangeCharSet(const nsCString& aCharSet)
|
|||
}
|
||||
|
||||
void
|
||||
nsPresContext::UpdateCharSet(const nsCString& aCharSet)
|
||||
nsPresContext::UpdateCharSet(NotNull<const Encoding*> aCharSet)
|
||||
{
|
||||
mLanguage = mLangService->LookupCharSet(aCharSet);
|
||||
// this will be a language group (or script) code rather than a true language code
|
||||
|
@ -1112,8 +1107,9 @@ nsPresContext::Observe(nsISupports* aSubject,
|
|||
const char16_t* aData)
|
||||
{
|
||||
if (!nsCRT::strcmp(aTopic, "charset")) {
|
||||
auto encoding = Encoding::ForName(NS_LossyConvertUTF16toASCII(aData));
|
||||
RefPtr<CharSetChangingRunnable> runnable =
|
||||
new CharSetChangingRunnable(this, NS_LossyConvertUTF16toASCII(aData));
|
||||
new CharSetChangingRunnable(this, encoding);
|
||||
return Document()->Dispatch("CharSetChangingRunnable",
|
||||
TaskCategory::Other,
|
||||
runnable.forget());
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#define nsPresContext_h___
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/NotNull.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/WeakPtr.h"
|
||||
#include "nsColor.h"
|
||||
|
@ -71,6 +72,7 @@ class gfxMissingFontRecorder;
|
|||
|
||||
namespace mozilla {
|
||||
class EffectCompositor;
|
||||
class Encoding;
|
||||
class EventStateManager;
|
||||
class CounterStyleManager;
|
||||
class RestyleManager;
|
||||
|
@ -125,6 +127,8 @@ class nsRootPresContext;
|
|||
class nsPresContext : public nsIObserver,
|
||||
public mozilla::SupportsWeakPtr<nsPresContext> {
|
||||
public:
|
||||
using Encoding = mozilla::Encoding;
|
||||
template <typename T> using NotNull = mozilla::NotNull<T>;
|
||||
typedef mozilla::LangGroupFontPrefs LangGroupFontPrefs;
|
||||
typedef mozilla::ScrollbarStyles ScrollbarStyles;
|
||||
typedef mozilla::StaticPresData StaticPresData;
|
||||
|
@ -1228,12 +1232,12 @@ protected:
|
|||
return StaticPresData::Get()->GetFontPrefsForLangHelper(lang, &mLangGroupFontPrefs, aNeedsToCache);
|
||||
}
|
||||
|
||||
void UpdateCharSet(const nsCString& aCharSet);
|
||||
void UpdateCharSet(NotNull<const Encoding*> aCharSet);
|
||||
|
||||
static bool NotifyDidPaintSubdocumentCallback(nsIDocument* aDocument, void* aData);
|
||||
|
||||
public:
|
||||
void DoChangeCharSet(const nsCString& aCharSet);
|
||||
void DoChangeCharSet(NotNull<const Encoding*> aCharSet);
|
||||
|
||||
/**
|
||||
* Checks for MozAfterPaint listeners on the document
|
||||
|
|
|
@ -3,8 +3,11 @@
|
|||
/* 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 "nsCOMPtr.h"
|
||||
#include "nsContentDLF.h"
|
||||
|
||||
#include "mozilla/Encoding.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsDocShell.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsGkAtoms.h"
|
||||
|
@ -327,7 +330,7 @@ nsContentDLF::CreateBlankDocument(nsILoadGroup *aLoadGroup,
|
|||
// add a nice bow
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
blankDoc->SetDocumentCharacterSetSource(kCharsetFromDocTypeDefault);
|
||||
blankDoc->SetDocumentCharacterSet(NS_LITERAL_CSTRING("UTF-8"));
|
||||
blankDoc->SetDocumentCharacterSet(UTF_8_ENCODING);
|
||||
|
||||
blankDoc.forget(aDocument);
|
||||
}
|
||||
|
|
|
@ -466,10 +466,8 @@ BulletRenderer::CreateWebRenderCommandsForImage(nsDisplayItem* aItem,
|
|||
LayoutDeviceRect destRect = LayoutDeviceRect::FromAppUnits(mDest, appUnitsPerDevPixel);
|
||||
WrRect dest = aSc.ToRelativeWrRectRounded(destRect);
|
||||
|
||||
WrClipRegionToken clipRegion = aBuilder.PushClipRegion(dest);
|
||||
|
||||
aBuilder.PushImage(dest,
|
||||
clipRegion,
|
||||
dest,
|
||||
WrImageRendering::Auto,
|
||||
key.value());
|
||||
}
|
||||
|
|
|
@ -321,7 +321,7 @@ nsDisplayCanvasBackgroundColor::CreateWebRenderCommands(mozilla::wr::DisplayList
|
|||
|
||||
WrRect transformedRect = aSc.ToRelativeWrRect(rect);
|
||||
aBuilder.PushRect(transformedRect,
|
||||
aBuilder.PushClipRegion(transformedRect),
|
||||
transformedRect,
|
||||
wr::ToWrColor(ToDeviceColor(mColor)));
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "gfxContext.h"
|
||||
#include "gfxUtils.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/Encoding.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/gfx/Helpers.h"
|
||||
|
@ -2248,7 +2249,7 @@ nsImageFrame::GetDocumentCharacterSet(nsACString& aCharset) const
|
|||
if (mContent) {
|
||||
NS_ASSERTION(mContent->GetComposedDoc(),
|
||||
"Frame still alive after content removed from document!");
|
||||
aCharset = mContent->GetComposedDoc()->GetDocumentCharacterSet();
|
||||
mContent->GetComposedDoc()->GetDocumentCharacterSet()->Name(aCharset);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3561,13 +3561,12 @@ nsCSSBorderRenderer::CreateWebRenderCommands(wr::DisplayListBuilder& aBuilder,
|
|||
side[i] = wr::ToWrBorderSide(ToDeviceColor(mBorderColors[i]), mBorderStyles[i]);
|
||||
}
|
||||
|
||||
WrClipRegionToken clipRegion = aBuilder.PushClipRegion(transformedRect);
|
||||
WrBorderRadius borderRadius = wr::ToWrBorderRadius(LayerSize(mBorderRadii[0].width, mBorderRadii[0].height),
|
||||
LayerSize(mBorderRadii[1].width, mBorderRadii[1].height),
|
||||
LayerSize(mBorderRadii[3].width, mBorderRadii[3].height),
|
||||
LayerSize(mBorderRadii[2].width, mBorderRadii[2].height));
|
||||
aBuilder.PushBorder(transformedRect,
|
||||
clipRegion,
|
||||
transformedRect,
|
||||
wr::ToWrBorderWidths(mBorderWidths[0], mBorderWidths[1], mBorderWidths[2], mBorderWidths[3]),
|
||||
side[0], side[1], side[2], side[3],
|
||||
borderRadius);
|
||||
|
|
|
@ -1084,7 +1084,7 @@ nsCSSGradientRenderer::BuildWebRenderDisplayItems(wr::DisplayListBuilder& aBuild
|
|||
|
||||
aBuilder.PushLinearGradient(
|
||||
wrGradientBounds,
|
||||
aBuilder.PushClipRegion(wrClipBounds),
|
||||
wrClipBounds,
|
||||
mozilla::wr::ToWrPoint(lineStart),
|
||||
mozilla::wr::ToWrPoint(lineEnd),
|
||||
stops,
|
||||
|
@ -1097,7 +1097,7 @@ nsCSSGradientRenderer::BuildWebRenderDisplayItems(wr::DisplayListBuilder& aBuild
|
|||
|
||||
aBuilder.PushRadialGradient(
|
||||
wrGradientBounds,
|
||||
aBuilder.PushClipRegion(wrClipBounds),
|
||||
wrClipBounds,
|
||||
mozilla::wr::ToWrPoint(lineStart),
|
||||
mozilla::wr::ToWrSize(gradientRadius),
|
||||
stops,
|
||||
|
|
|
@ -4618,12 +4618,12 @@ nsDisplayCaret::CreateWebRenderCommands(wr::DisplayListBuilder& aBuilder,
|
|||
|
||||
// Note, WR will pixel snap anything that is layout aligned.
|
||||
aBuilder.PushRect(caret,
|
||||
aBuilder.PushClipRegion(caret),
|
||||
caret,
|
||||
wr::ToWrColor(color));
|
||||
|
||||
if (!devHookRect.IsEmpty()) {
|
||||
aBuilder.PushRect(hook,
|
||||
aBuilder.PushClipRegion(hook),
|
||||
hook,
|
||||
wr::ToWrColor(color));
|
||||
}
|
||||
}
|
||||
|
@ -4895,7 +4895,7 @@ nsDisplayBorder::CreateBorderImageWebRenderCommands(mozilla::wr::DisplayListBuil
|
|||
}
|
||||
|
||||
aBuilder.PushBorderImage(dest,
|
||||
aBuilder.PushClipRegion(clip),
|
||||
clip,
|
||||
wr::ToWrBorderWidths(widths[0], widths[1], widths[2], widths[3]),
|
||||
key.value(),
|
||||
wr::ToWrNinePatchDescriptor(
|
||||
|
@ -4928,7 +4928,7 @@ nsDisplayBorder::CreateBorderImageWebRenderCommands(mozilla::wr::DisplayListBuil
|
|||
endPoint = endPoint + ViewAs<LayerPixel>(lineEnd, PixelCastJustification::WebRenderHasUnitResolution);
|
||||
|
||||
aBuilder.PushBorderGradient(dest,
|
||||
aBuilder.PushClipRegion(clip),
|
||||
clip,
|
||||
wr::ToWrBorderWidths(widths[0], widths[1], widths[2], widths[3]),
|
||||
wr::ToWrPoint(startPoint),
|
||||
wr::ToWrPoint(endPoint),
|
||||
|
@ -4937,7 +4937,7 @@ nsDisplayBorder::CreateBorderImageWebRenderCommands(mozilla::wr::DisplayListBuil
|
|||
wr::ToWrSideOffsets2Df32(outset[0], outset[1], outset[2], outset[3]));
|
||||
} else {
|
||||
aBuilder.PushBorderRadialGradient(dest,
|
||||
aBuilder.PushClipRegion(clip),
|
||||
clip,
|
||||
wr::ToWrBorderWidths(widths[0], widths[1], widths[2], widths[3]),
|
||||
wr::ToWrPoint(lineStart),
|
||||
wr::ToWrSize(gradientRadius),
|
||||
|
@ -5264,7 +5264,7 @@ nsDisplayBoxShadowOuter::CreateWebRenderCommands(wr::DisplayListBuilder& aBuilde
|
|||
float spreadRadius = float(shadow->mSpread) / float(appUnitsPerDevPixel);
|
||||
|
||||
aBuilder.PushBoxShadow(deviceBoxRect,
|
||||
aBuilder.PushClipRegion(deviceClipRect),
|
||||
deviceClipRect,
|
||||
deviceBoxRect,
|
||||
wr::ToWrPoint(shadowOffset),
|
||||
wr::ToWrColor(shadowColor),
|
||||
|
@ -5421,7 +5421,7 @@ nsDisplayBoxShadowInner::CreateInsetBoxShadowWebRenderCommands(mozilla::wr::Disp
|
|||
float spreadRadius = float(shadowItem->mSpread) / float(appUnitsPerDevPixel);
|
||||
|
||||
aBuilder.PushBoxShadow(wr::ToWrRect(deviceBoxRect),
|
||||
aBuilder.PushClipRegion(deviceClipRect),
|
||||
deviceClipRect,
|
||||
wr::ToWrRect(deviceBoxRect),
|
||||
wr::ToWrPoint(shadowOffset),
|
||||
wr::ToWrColor(shadowColor),
|
||||
|
|
|
@ -652,7 +652,7 @@ nsImageRenderer::BuildWebRenderDisplayItems(nsPresContext* aPresContext,
|
|||
|
||||
LayoutDeviceSize gapSize = LayoutDeviceSize::FromAppUnits(
|
||||
aRepeatSize - aDest.Size(), appUnitsPerDevPixel);
|
||||
aBuilder.PushImage(fill, aBuilder.PushClipRegion(clip),
|
||||
aBuilder.PushImage(fill, clip,
|
||||
wr::ToWrSize(destRect.Size()), wr::ToWrSize(gapSize),
|
||||
wr::ImageRendering::Auto, key.value());
|
||||
break;
|
||||
|
|
|
@ -761,8 +761,8 @@ SheetLoadData::OnDetermineCharset(nsIUnicharStreamLoader* aLoader,
|
|||
|
||||
if (mLoader->mDocument) {
|
||||
// no useful data on charset. Try the document charset.
|
||||
aCharset = mLoader->mDocument->GetDocumentCharacterSet();
|
||||
MOZ_ASSERT(!aCharset.IsEmpty());
|
||||
auto encoding = mLoader->mDocument->GetDocumentCharacterSet();
|
||||
encoding->Name(aCharset);
|
||||
mCharset.Assign(aCharset);
|
||||
LOG((" Setting from document to: %s", PromiseFlatCString(aCharset).get()));
|
||||
return NS_OK;
|
||||
|
|
|
@ -7435,10 +7435,9 @@ BCBlockDirSeg::CreateWebRenderCommands(BCPaintBorderIterator& aIter,
|
|||
transformedRect.width,
|
||||
transformedRect.width,
|
||||
transformedRect.width);
|
||||
WrClipRegionToken clipRegion = aBuilder.PushClipRegion(transformedRect);
|
||||
transformedRect.width *= 2.0f;
|
||||
aBuilder.PushBorder(transformedRect,
|
||||
clipRegion,
|
||||
transformedRect,
|
||||
borderWidths,
|
||||
wrSide[0], wrSide[1], wrSide[2], wrSide[3],
|
||||
borderRadii);
|
||||
|
@ -7694,10 +7693,9 @@ BCInlineDirSeg::CreateWebRenderCommands(BCPaintBorderIterator& aIter,
|
|||
transformedRect.height,
|
||||
transformedRect.height,
|
||||
transformedRect.height);
|
||||
WrClipRegionToken clipRegion = aBuilder.PushClipRegion(transformedRect);
|
||||
transformedRect.height *= 2.0f;
|
||||
aBuilder.PushBorder(transformedRect,
|
||||
clipRegion,
|
||||
transformedRect,
|
||||
borderWidths,
|
||||
wrSide[0], wrSide[1], wrSide[2], wrSide[3],
|
||||
borderRadii);
|
||||
|
|
|
@ -771,7 +771,7 @@ nsXULPopupManager::ShowMenu(nsIContent *aMenu,
|
|||
}
|
||||
else {
|
||||
nsCOMPtr<nsIContent> popupContent = popupFrame->GetContent();
|
||||
FirePopupShowingEvent(popupContent, parentIsContextMenu, aSelectFirstItem);
|
||||
FirePopupShowingEvent(popupContent, parentIsContextMenu, aSelectFirstItem, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -795,7 +795,7 @@ nsXULPopupManager::ShowPopup(nsIContent* aPopup,
|
|||
popupFrame->InitializePopup(aAnchorContent, triggerContent, aPosition,
|
||||
aXPos, aYPos, MenuPopupAnchorType_Node, aAttributesOverride);
|
||||
|
||||
FirePopupShowingEvent(aPopup, aIsContextMenu, aSelectFirstItem);
|
||||
FirePopupShowingEvent(aPopup, aIsContextMenu, aSelectFirstItem, aTriggerEvent);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -812,7 +812,7 @@ nsXULPopupManager::ShowPopupAtScreen(nsIContent* aPopup,
|
|||
InitTriggerEvent(aTriggerEvent, aPopup, getter_AddRefs(triggerContent));
|
||||
|
||||
popupFrame->InitializePopupAtScreen(triggerContent, aXPos, aYPos, aIsContextMenu);
|
||||
FirePopupShowingEvent(aPopup, aIsContextMenu, false);
|
||||
FirePopupShowingEvent(aPopup, aIsContextMenu, false, aTriggerEvent);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -833,7 +833,7 @@ nsXULPopupManager::ShowPopupAtScreenRect(nsIContent* aPopup,
|
|||
popupFrame->InitializePopupAtRect(triggerContent, aPosition,
|
||||
aRect, aAttributesOverride);
|
||||
|
||||
FirePopupShowingEvent(aPopup, aIsContextMenu, false);
|
||||
FirePopupShowingEvent(aPopup, aIsContextMenu, false, aTriggerEvent);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -862,7 +862,7 @@ nsXULPopupManager::ShowTooltipAtScreen(nsIContent* aPopup,
|
|||
|
||||
popupFrame->InitializePopupAtScreen(aTriggerContent, aXPos, aYPos, false);
|
||||
|
||||
FirePopupShowingEvent(aPopup, false, false);
|
||||
FirePopupShowingEvent(aPopup, false, false, nullptr);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -881,7 +881,7 @@ nsXULPopupManager::ShowPopupWithAnchorAlign(nsIContent* aPopup,
|
|||
|
||||
popupFrame->InitializePopupWithAnchorAlign(aAnchorContent, aAnchor,
|
||||
aAlign, aXPos, aYPos);
|
||||
FirePopupShowingEvent(aPopup, aIsContextMenu, false);
|
||||
FirePopupShowingEvent(aPopup, aIsContextMenu, false, nullptr);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1429,7 +1429,8 @@ nsXULPopupManager::ExecuteMenu(nsIContent* aMenu, nsXULMenuCommandEvent* aEvent)
|
|||
void
|
||||
nsXULPopupManager::FirePopupShowingEvent(nsIContent* aPopup,
|
||||
bool aIsContextMenu,
|
||||
bool aSelectFirstItem)
|
||||
bool aSelectFirstItem,
|
||||
nsIDOMEvent* aTriggerEvent)
|
||||
{
|
||||
nsCOMPtr<nsIContent> popup = aPopup; // keep a strong reference to the popup
|
||||
|
||||
|
@ -1475,6 +1476,14 @@ nsXULPopupManager::FirePopupShowingEvent(nsIContent* aPopup,
|
|||
event.mWidget = nullptr;
|
||||
}
|
||||
|
||||
if (aTriggerEvent) {
|
||||
WidgetMouseEventBase* mouseEvent =
|
||||
aTriggerEvent->WidgetEventPtr()->AsMouseEventBase();
|
||||
if (mouseEvent) {
|
||||
event.inputSource = mouseEvent->inputSource;
|
||||
}
|
||||
}
|
||||
|
||||
event.mRefPoint = mCachedMousePoint;
|
||||
event.mModifiers = mCachedModifiers;
|
||||
EventDispatcher::Dispatch(popup, presContext, &event, nullptr, &status);
|
||||
|
@ -2740,7 +2749,7 @@ nsXULPopupShowingEvent::Run()
|
|||
{
|
||||
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
|
||||
if (pm) {
|
||||
pm->FirePopupShowingEvent(mPopup, mIsContextMenu, mSelectFirstItem);
|
||||
pm->FirePopupShowingEvent(mPopup, mIsContextMenu, mSelectFirstItem, nullptr);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -731,10 +731,14 @@ protected:
|
|||
* aPopup - the popup to open
|
||||
* aIsContextMenu - true for context menus
|
||||
* aSelectFirstItem - true to select the first item in the menu
|
||||
* aTriggerEvent - the event that triggered the showing event.
|
||||
* This is currently used to propagate the
|
||||
* inputSource attribute. May be null.
|
||||
*/
|
||||
void FirePopupShowingEvent(nsIContent* aPopup,
|
||||
bool aIsContextMenu,
|
||||
bool aSelectFirstItem);
|
||||
bool aSelectFirstItem,
|
||||
nsIDOMEvent* aTriggerEvent);
|
||||
|
||||
/**
|
||||
* Fire a popuphiding event and then hide the popup. This will be called
|
||||
|
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 44 KiB |
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 68 KiB |
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче