Merge mozilla-central to mozilla-inbound

This commit is contained in:
Carsten "Tomcat" Book 2017-06-27 15:14:47 +02:00
Родитель f2acc9fbc8 4e00eff077
Коммит 9abc7cd713
151 изменённых файлов: 1595 добавлений и 1147 удалений

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

@ -281,7 +281,7 @@ XULLinkAccessible::AnchorURIAt(uint32_t aAnchorIndex)
nsCOMPtr<nsIURI> anchorURI; nsCOMPtr<nsIURI> anchorURI;
NS_NewURI(getter_AddRefs(anchorURI), href, NS_NewURI(getter_AddRefs(anchorURI), href,
document->GetDocumentCharacterSet().get(), document->GetDocumentCharacterSet(),
baseURI); baseURI);
return anchorURI.forget(); return anchorURI.forget();

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

@ -1634,6 +1634,10 @@ var gBrowserInit = {
FullScreen.init(); FullScreen.init();
PointerLock.init(); PointerLock.init();
if (AppConstants.isPlatformAndVersionAtLeast("win", "10")) {
ContextMenuTouchModeObserver.init();
}
// initialize the sync UI // initialize the sync UI
gSync.init(); gSync.init();
@ -1843,6 +1847,9 @@ var gBrowserInit = {
this.gmpInstallManager.uninit(); this.gmpInstallManager.uninit();
} }
if (AppConstants.isPlatformAndVersionAtLeast("win", "10")) {
ContextMenuTouchModeObserver.uninit();
}
BrowserOffline.uninit(); BrowserOffline.uninit();
IndexedDBPromptHelper.uninit(); IndexedDBPromptHelper.uninit();
PanelUI.uninit(); PanelUI.uninit();
@ -8219,6 +8226,77 @@ function restoreLastSession() {
SessionStore.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 = { var TabContextMenu = {
contextTab: null, contextTab: null,
_updateToggleMuteMenuItem(aTab, aConditionFn) { _updateToggleMuteMenuItem(aTab, aConditionFn) {

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

@ -62,14 +62,14 @@ function openContextMenu(aMessage) {
let popup = browser.ownerDocument.getElementById("contentAreaContextMenu"); let popup = browser.ownerDocument.getElementById("contentAreaContextMenu");
let event = gContextMenuContentData.event; let event = gContextMenuContentData.event;
// Set touch mode to get larger menu items. // The event is a CPOW that can't be passed into the native openPopupAtScreen
if (event.mozInputSource == MouseEvent.MOZ_SOURCE_TOUCH) { // function. Therefore we synthesize a new MouseEvent to propagate the
popup.setAttribute("touchmode", "true"); // inputSource to the subsequently triggered popupshowing event.
} else { var newEvent = document.createEvent("MouseEvent");
popup.removeAttribute("touchmode"); 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) { function nsContextMenu(aXulMenu, aIsShift) {

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

@ -4,3 +4,5 @@ support-files =
subtst_contextmenu_webext.html subtst_contextmenu_webext.html
[browser_contextmenu_mozextension.js] [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_getCurrent.js]
[browser_ext_tabs_insertCSS.js] [browser_ext_tabs_insertCSS.js]
[browser_ext_tabs_removeCSS.js] [browser_ext_tabs_removeCSS.js]
[browser_ext_tabs_move.js]
[browser_ext_tabs_move_array.js] [browser_ext_tabs_move_array.js]
[browser_ext_tabs_move_window.js] [browser_ext_tabs_move_window.js]
[browser_ext_tabs_move_window_multiple.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 = [ 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 // 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] // [1, 2, 3, 4] -> [1, 4, 2, 3] -> [1, 4, 3, 2]
{"move": [4, 3], "index": 1, "result": [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] // [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); 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"); browser.test.notifyPass("tabs.move");
}, },
}); });

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

@ -18,6 +18,19 @@ var gSearchResultsPane = {
if (!this.searchInput.hidden) { if (!this.searchInput.hidden) {
this.searchInput.addEventListener("command", this); this.searchInput.addEventListener("command", this);
this.searchInput.addEventListener("focus", 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) { searchWithinNode(nodeObject, searchPhrase) {
let matchesFound = false; 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); let simpleTextNodes = this.textNodeDescendants(nodeObject);
for (let node of simpleTextNodes) { for (let node of simpleTextNodes) {
@ -283,12 +299,16 @@ var gSearchResultsPane = {
matchesFound = matchesFound || result; matchesFound = matchesFound || result;
} }
// Collecting data from boxObject // Collecting data from boxObject / label / description
let nodeSizes = []; let nodeSizes = [];
let allNodeText = ""; let allNodeText = "";
let runningSize = 0; let runningSize = 0;
let accessKeyTextNodes = this.textNodeDescendants(nodeObject.boxObject); let accessKeyTextNodes = this.textNodeDescendants(nodeObject.boxObject);
if (nodeObject.tagName == "label" || nodeObject.tagName == "description") {
accessKeyTextNodes.push(...this.textNodeDescendants(nodeObject));
}
for (let node of accessKeyTextNodes) { for (let node of accessKeyTextNodes) {
runningSize += node.textContent.length; runningSize += node.textContent.length;
allNodeText += node.textContent; allNodeText += node.textContent;
@ -391,6 +411,12 @@ var gSearchResultsPane = {
anchorNode.parentElement.classList.add("search-tooltip-parent"); anchorNode.parentElement.classList.add("search-tooltip-parent");
anchorNode.parentElement.appendChild(searchTooltip); 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 // 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 // putting tooltips on, we have to flush layout intentionally, and that
// this is the result of a XUL limitation (bug 1363730). // this is the result of a XUL limitation (bug 1363730).

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

@ -61,8 +61,9 @@ var gPrivacyPane = {
this.trackingProtectionReadPrefs(); this.trackingProtectionReadPrefs();
document.getElementById("trackingprotectionbox").hidden = false; document.getElementById("trackingProtectionExceptions").hidden = false;
document.getElementById("trackingprotectionpbmbox").hidden = true; document.getElementById("trackingProtectionBox").hidden = false;
document.getElementById("trackingProtectionPBMBox").hidden = true;
}, },
/** /**
@ -189,10 +190,6 @@ var gPrivacyPane = {
gPrivacyPane.clearPrivateDataNow(true); gPrivacyPane.clearPrivateDataNow(true);
return false; return false;
}); });
setEventListener("doNotTrackSettings", "click", function() {
gPrivacyPane.showDoNotTrackSettings();
return false;
});
setEventListener("privateBrowsingAutoStart", "command", setEventListener("privateBrowsingAutoStart", "command",
gPrivacyPane.updateAutostart); gPrivacyPane.updateAutostart);
setEventListener("cookieExceptions", "command", setEventListener("cookieExceptions", "command",
@ -207,8 +204,6 @@ var gPrivacyPane = {
gPrivacyPane.showTrackingProtectionExceptions); gPrivacyPane.showTrackingProtectionExceptions);
setEventListener("changeBlockList", "command", setEventListener("changeBlockList", "command",
gPrivacyPane.showBlockLists); gPrivacyPane.showBlockLists);
setEventListener("changeBlockListPBM", "command",
gPrivacyPane.showBlockLists);
setEventListener("browserContainersCheckbox", "command", setEventListener("browserContainersCheckbox", "command",
gPrivacyPane._checkBrowserContainers); gPrivacyPane._checkBrowserContainers);
setEventListener("browserContainersSettings", "command", setEventListener("browserContainersSettings", "command",

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

@ -76,7 +76,10 @@
<preference id="browser.privatebrowsing.autostart" <preference id="browser.privatebrowsing.autostart"
name="browser.privatebrowsing.autostart" name="browser.privatebrowsing.autostart"
type="bool"/> type="bool"/>
<!-- Do not track -->
<preference id="privacy.donottrackheader.enabled"
name="privacy.donottrackheader.enabled"
type="bool"/>
<!-- DRM content --> <!-- DRM content -->
<preference id="media.eme.enabled" <preference id="media.eme.enabled"
name="media.eme.enabled" name="media.eme.enabled"
@ -401,22 +404,48 @@
<!-- Tracking --> <!-- Tracking -->
<groupbox id="trackingGroup" data-category="panePrivacy" hidden="true"> <groupbox id="trackingGroup" data-category="panePrivacy" hidden="true">
<caption><label>&trackingProtectionHeader2.label;</label></caption> <caption><label>&trackingProtectionHeader2.label;</label></caption>
<vbox id="trackingprotectionbox" hidden="true"> <vbox>
<hbox align="start"> <hbox align="start">
<vbox flex="1"> <vbox flex="1">
<description> <description>
&trackingProtection.description; &trackingProtection.description;
<label id="trackingProtectionLearnMore" class="learnMore text-link">&trackingProtectionLearnMore.label;</label>
</description>
<description id="trackingProtectionDesc"
control="trackingProtectionRadioGroup">
&trackingProtection.radioGroupLabel;
</description> </description>
</vbox> </vbox>
<spacer flex="1"/> <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"> <vbox id="trackingProtectionAdvancedSettings">
<button id="trackingProtectionExceptions" <button id="trackingProtectionExceptions"
class="accessory-button" class="accessory-button"
hidden="true"
label="&trackingProtectionExceptions.label;" label="&trackingProtectionExceptions.label;"
accesskey="&trackingProtectionExceptions.accesskey;" accesskey="&trackingProtectionExceptions.accesskey;"
preference="pref.privacy.disable_button.tracking_protection_exceptions" preference="pref.privacy.disable_button.tracking_protection_exceptions"
@ -432,37 +461,15 @@
searchkeywords="&button.cancel.label; &button.ok.label;"/> searchkeywords="&button.cancel.label; &button.ok.label;"/>
</vbox> </vbox>
</hbox> </hbox>
<radiogroup id="trackingProtectionRadioGroup" aria-labelledby="trackingProtectionDesc"> <vbox id="doNotTrackLearnMoreBox">
<radio value="always" <label>&doNotTrack.description;<label
label="&trackingProtectionAlways.label;" class="learnMore text-link" href="https://www.mozilla.org/dnt"
accesskey="&trackingProtectionAlways.accesskey;"/> >&doNotTrack.learnMore.label;</label></label>
<radio value="private" <radiogroup id="doNotTrackRadioGroup" aria-labelledby="doNotTrackDesc" preference="privacy.donottrackheader.enabled">
label="&trackingProtectionPrivate.label;" <radio value="false" label="&doNotTrack.default.label;"/>
accesskey="&trackingProtectionPrivate.accesskey;"/> <radio value="true" label="&doNotTrack.always.label;"/>
<radio value="never" </radiogroup>
label="&trackingProtectionNever.label;" </vbox>
accesskey="&trackingProtectionNever.accesskey;"/>
</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> </vbox>
</groupbox> </groupbox>

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

@ -126,7 +126,7 @@
<checkbox id="trackingProtectionPBM" <checkbox id="trackingProtectionPBM"
preference="privacy.trackingprotection.pbmode.enabled" preference="privacy.trackingprotection.pbmode.enabled"
accesskey="&trackingProtectionPBM5.accesskey;" accesskey="&trackingProtectionPBM5.accesskey;"
label="&trackingProtectionPBM5.label;" /> label="&trackingProtectionPBM5.label;"/>
<label id="trackingProtectionPBMLearnMore" <label id="trackingProtectionPBMLearnMore"
class="learnMore text-link" class="learnMore text-link"
value="&trackingProtectionPBMLearnMore.label;"/> value="&trackingProtectionPBMLearnMore.label;"/>

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

@ -3,8 +3,8 @@
- file, You can obtain one at http://mozilla.org/MPL/2.0/. --> - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!ENTITY trackingProtectionHeader2.label "Tracking Protection"> <!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.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 "Block known tracking companies from displaying content"> <!ENTITY trackingProtection.radioGroupLabel "Use Tracking Protection to block known trackers">
<!ENTITY trackingProtectionAlways.label "Always"> <!ENTITY trackingProtectionAlways.label "Always">
<!ENTITY trackingProtectionAlways.accesskey "y"> <!ENTITY trackingProtectionAlways.accesskey "y">
<!ENTITY trackingProtectionPrivate.label "Only in private windows"> <!ENTITY trackingProtectionPrivate.label "Only in private windows">
@ -15,18 +15,18 @@
<!ENTITY trackingProtectionExceptions.label "Exceptions…"> <!ENTITY trackingProtectionExceptions.label "Exceptions…">
<!ENTITY trackingProtectionExceptions.accesskey "x"> <!ENTITY trackingProtectionExceptions.accesskey "x">
<!ENTITY tracking.label "Tracking">
<!ENTITY trackingProtectionPBM5.label "Use Tracking Protection in Private Windows"> <!ENTITY trackingProtectionPBM5.label "Use Tracking Protection in Private Windows">
<!ENTITY trackingProtectionPBM5.accesskey "v"> <!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 trackingProtectionPBMLearnMore.label "Learn more">
<!ENTITY changeBlockList.label "Change Block List"> <!ENTITY changeBlockList.label "Change Block List">
<!ENTITY changeBlockList.accesskey "C"> <!ENTITY changeBlockList.accesskey "C">
<!-- LOCALIZATION NOTE (doNotTrack.pre.label): include a trailing space as needed --> <!ENTITY doNotTrack.description "Send websites a “Do Not Track” signal that you dont want to be tracked">
<!-- LOCALIZATION NOTE (doNotTrack.post.label): include a starting space as needed --> <!ENTITY doNotTrack.learnMore.label "Learn more">
<!ENTITY doNotTrack.pre.label "You can also "> <!ENTITY doNotTrack.default.label "Only when using Tracking Protection">
<!ENTITY doNotTrack.settings.label "manage your Do Not Track settings"> <!ENTITY doNotTrack.always.label "Always">
<!ENTITY doNotTrack.post.label ".">
<!ENTITY history.label "History"> <!ENTITY history.label "History">
<!ENTITY permissions.label "Permissions"> <!ENTITY permissions.label "Permissions">

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

@ -236,11 +236,8 @@ treecol {
margin-left: 0; margin-left: 0;
} }
/* This learn-more link is inserted at the end of a #doNotTrackLearnMoreBox {
xul:description element so it should behave like normal text. */ margin-top: 30px
#trackingProtectionLearnMore {
white-space: normal;
margin-inline-start: 0;
} }
#trackingProtectionAdvancedSettings { #trackingProtectionAdvancedSettings {

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

@ -1970,8 +1970,8 @@ notification.pluginVulnerable > .notification-inner > .messageCloseButton {
%include ../shared/contextmenu.inc.css %include ../shared/contextmenu.inc.css
/* Make context menu items larger when opened through touch. */ /* Make context menu items larger when opened through touch. */
#contentAreaContextMenu[touchmode] menu, menupopup[touchmode] menu,
#contentAreaContextMenu[touchmode] menuitem { menupopup[touchmode] menuitem {
padding-top: 12px; padding-top: 12px;
padding-bottom: 12px; padding-bottom: 12px;
} }

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

@ -374,14 +374,15 @@ ForEachPing(nsIContent* aContent, ForEachPingCallback aCallback, void* aClosure)
} }
nsIDocument* doc = aContent->OwnerDoc(); nsIDocument* doc = aContent->OwnerDoc();
nsAutoCString charset;
doc->GetDocumentCharacterSet()->Name(charset);
nsWhitespaceTokenizer tokenizer(value); nsWhitespaceTokenizer tokenizer(value);
while (tokenizer.hasMoreTokens()) { while (tokenizer.hasMoreTokens()) {
nsCOMPtr<nsIURI> uri, baseURI = aContent->GetBaseURI(); nsCOMPtr<nsIURI> uri, baseURI = aContent->GetBaseURI();
ios->NewURI(NS_ConvertUTF16toUTF8(tokenizer.nextToken()), ios->NewURI(NS_ConvertUTF16toUTF8(tokenizer.nextToken()),
doc->GetDocumentCharacterSet().get(), charset.get(), baseURI, getter_AddRefs(uri));
baseURI, getter_AddRefs(uri));
// if we can't generate a valid URI, then there is nothing to do // if we can't generate a valid URI, then there is nothing to do
if (!uri) { if (!uri) {
continue; continue;
@ -835,6 +836,8 @@ nsDocShell::nsDocShell()
, mDefaultLoadFlags(nsIRequest::LOAD_NORMAL) , mDefaultLoadFlags(nsIRequest::LOAD_NORMAL)
, mFrameType(FRAME_TYPE_REGULAR) , mFrameType(FRAME_TYPE_REGULAR)
, mPrivateBrowsingId(0) , mPrivateBrowsingId(0)
, mForcedCharset(nullptr)
, mParentCharset(nullptr)
, mParentCharsetSource(0) , mParentCharsetSource(0)
, mJSRunToCompletionDepth(0) , mJSRunToCompletionDepth(0)
, mTouchEventsOverride(nsIDocShell::TOUCHEVENTS_OVERRIDE_NONE) , mTouchEventsOverride(nsIDocShell::TOUCHEVENTS_OVERRIDE_NONE)
@ -2035,7 +2038,7 @@ nsDocShell::GetCharset(nsACString& aCharset)
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE); NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
nsIDocument* doc = presShell->GetDocument(); nsIDocument* doc = presShell->GetDocument();
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE); NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
aCharset = doc->GetDocumentCharacterSet(); doc->GetDocumentCharacterSet()->Name(aCharset);
return NS_OK; return NS_OK;
} }
@ -2121,7 +2124,7 @@ NS_IMETHODIMP
nsDocShell::SetForcedCharset(const nsACString& aCharset) nsDocShell::SetForcedCharset(const nsACString& aCharset)
{ {
if (aCharset.IsEmpty()) { if (aCharset.IsEmpty()) {
mForcedCharset.Truncate(); mForcedCharset = nullptr;
return NS_OK; return NS_OK;
} }
const Encoding* encoding = Encoding::ForLabel(aCharset); const Encoding* encoding = Encoding::ForLabel(aCharset);
@ -2133,19 +2136,19 @@ nsDocShell::SetForcedCharset(const nsACString& aCharset)
// Reject XSS hazards // Reject XSS hazards
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
encoding->Name(mForcedCharset); mForcedCharset = encoding;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDocShell::GetForcedCharset(nsACString& aResult) nsDocShell::GetForcedCharset(nsACString& aResult)
{ {
aResult = mForcedCharset; mForcedCharset->Name(aResult);
return NS_OK; return NS_OK;
} }
void void
nsDocShell::SetParentCharset(const nsACString& aCharset, nsDocShell::SetParentCharset(const Encoding*& aCharset,
int32_t aCharsetSource, int32_t aCharsetSource,
nsIPrincipal* aPrincipal) nsIPrincipal* aPrincipal)
{ {
@ -2155,7 +2158,7 @@ nsDocShell::SetParentCharset(const nsACString& aCharset,
} }
void void
nsDocShell::GetParentCharset(nsACString& aCharset, nsDocShell::GetParentCharset(const Encoding*& aCharset,
int32_t* aCharsetSource, int32_t* aCharsetSource,
nsIPrincipal** aPrincipal) nsIPrincipal** aPrincipal)
{ {
@ -4197,7 +4200,7 @@ nsDocShell::AddChild(nsIDocShellTreeItem* aChild)
// the actual source charset, which is what we're trying to // the actual source charset, which is what we're trying to
// expose here. // expose here.
const nsACString& parentCS = doc->GetDocumentCharacterSet(); const Encoding* parentCS = doc->GetDocumentCharacterSet();
int32_t charsetSource = doc->GetDocumentCharacterSetSource(); int32_t charsetSource = doc->GetDocumentCharacterSetSource();
// set the child's parentCharset // set the child's parentCharset
childAsDocShell->SetParentCharset(parentCS, childAsDocShell->SetParentCharset(parentCS,
@ -11633,7 +11636,8 @@ nsDocShell::ScrollToAnchor(bool aCurHasRef, bool aNewHasRef,
NS_ENSURE_TRUE(mContentViewer, NS_ERROR_FAILURE); NS_ENSURE_TRUE(mContentViewer, NS_ERROR_FAILURE);
nsIDocument* doc = mContentViewer->GetDocument(); nsIDocument* doc = mContentViewer->GetDocument();
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE); NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
const nsACString& charset = doc->GetDocumentCharacterSet(); nsAutoCString charset;
doc->GetDocumentCharacterSet()->Name(charset);
nsCOMPtr<nsITextToSubURI> textToSubURI = nsCOMPtr<nsITextToSubURI> textToSubURI =
do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv); do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv);

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

@ -62,6 +62,7 @@
#include "nsIDeprecationWarner.h" #include "nsIDeprecationWarner.h"
namespace mozilla { namespace mozilla {
class Encoding;
enum class TaskCategory; enum class TaskCategory;
namespace dom { namespace dom {
class EventTarget; class EventTarget;
@ -155,6 +156,7 @@ class nsDocShell final
{ {
friend class nsDSURIContentListener; friend class nsDSURIContentListener;
friend class FramingChecker; friend class FramingChecker;
using Encoding = mozilla::Encoding;
public: public:
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(nsDocShell) MOZ_DECLARE_WEAKREFERENCE_TYPENAME(nsDocShell)
@ -274,6 +276,8 @@ public:
} }
bool InFrameSwap(); bool InFrameSwap();
const Encoding* GetForcedCharset() { return mForcedCharset; }
private: private:
bool CanSetOriginAttributes(); bool CanSetOriginAttributes();
@ -1040,8 +1044,8 @@ protected:
nsString mInterceptedDocumentId; nsString mInterceptedDocumentId;
private: private:
nsCString mForcedCharset; const Encoding* mForcedCharset;
nsCString mParentCharset; const Encoding* mParentCharset;
int32_t mParentCharsetSource; int32_t mParentCharsetSource;
nsCOMPtr<nsIPrincipal> mParentCharsetPrincipal; nsCOMPtr<nsIPrincipal> mParentCharsetPrincipal;
nsTObserverArray<nsWeakPtr> mPrivacyObservers; nsTObserverArray<nsWeakPtr> mPrivacyObservers;

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

@ -11,8 +11,12 @@
%{ C++ %{ C++
#include "js/TypeDecls.h" #include "js/TypeDecls.h"
#include "mozilla/Maybe.h" #include "mozilla/Maybe.h"
#include "mozilla/NotNull.h"
class nsPresContext; class nsPresContext;
class nsIPresShell; class nsIPresShell;
namespace mozilla {
class Encoding;
}
%} %}
/** /**
@ -22,6 +26,7 @@ class nsIPresShell;
[ptr] native nsPresContext(nsPresContext); [ptr] native nsPresContext(nsPresContext);
[ptr] native nsIPresShell(nsIPresShell); [ptr] native nsIPresShell(nsIPresShell);
[ref] native MaybeURI(mozilla::Maybe<nsCOMPtr<nsIURI>>); [ref] native MaybeURI(mozilla::Maybe<nsCOMPtr<nsIURI>>);
[ref] native Encoding(const mozilla::Encoding*);
interface nsIURI; interface nsIURI;
interface nsIChannel; interface nsIChannel;
@ -713,11 +718,11 @@ interface nsIDocShell : nsIDocShellTreeItem
* In a child docshell, this is the charset of the parent docshell * In a child docshell, this is the charset of the parent docshell
*/ */
[noscript, notxpcom, nostdcall] void setParentCharset( [noscript, notxpcom, nostdcall] void setParentCharset(
in ACString parentCharset, in Encoding parentCharset,
in int32_t parentCharsetSource, in int32_t parentCharsetSource,
in nsIPrincipal parentCharsetPrincipal); in nsIPrincipal parentCharsetPrincipal);
[noscript, notxpcom, nostdcall] void getParentCharset( [noscript, notxpcom, nostdcall] void getParentCharset(
out ACString parentCharset, out Encoding parentCharset,
out int32_t parentCharsetSource, out int32_t parentCharsetSource,
out nsIPrincipal parentCharsetPrincipal); out nsIPrincipal parentCharsetPrincipal);

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

@ -1059,8 +1059,9 @@ addAsyncAnimTest("tree_ordering", { observe: div, subtree: true }, function*() {
var extraStyle = document.createElement('style'); var extraStyle = document.createElement('style');
document.head.appendChild(extraStyle); document.head.appendChild(extraStyle);
var sheet = extraStyle.sheet; var sheet = extraStyle.sheet;
var rules = { ".before::before": "animation: anim 100s;", var rules = { ".before::before": "animation: anim 100s; content: '';",
".after::after" : "animation: anim 100s, anim 100s;" }; ".after::after" : "animation: anim 100s, anim 100s; " +
"content: '';"};
for (var selector in rules) { for (var selector in rules) {
sheet.insertRule(selector + '{' + rules[selector] + '}', sheet.insertRule(selector + '{' + rules[selector] + '}',
sheet.cssRules.length); sheet.cssRules.length);

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

@ -429,7 +429,7 @@ nsIContent::GetBaseURI(bool aTryUseXHRDocBaseURI) const
for (uint32_t i = baseAttrs.Length() - 1; i != uint32_t(-1); --i) { for (uint32_t i = baseAttrs.Length() - 1; i != uint32_t(-1); --i) {
nsCOMPtr<nsIURI> newBase; nsCOMPtr<nsIURI> newBase;
nsresult rv = NS_NewURI(getter_AddRefs(newBase), baseAttrs[i], 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() // Do a security check, almost the same as nsDocument::SetBaseURL()
// Only need to do this on the final uri // Only need to do this on the final uri
if (NS_SUCCEEDED(rv) && i == 0) { if (NS_SUCCEEDED(rv) && i == 0) {

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

@ -39,18 +39,6 @@
namespace mozilla { namespace mozilla {
namespace dom { 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) Location::Location(nsPIDOMWindowInner* aWindow, nsIDocShell *aDocShell)
: mInnerWindow(aWindow) : mInnerWindow(aWindow)
{ {
@ -506,11 +494,12 @@ Location::SetHrefWithBase(const nsAString& aHref, nsIURI* aBase,
nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell)); nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell));
nsAutoCString docCharset; if (nsIDocument* doc = GetEntryDocument()) {
if (NS_SUCCEEDED(GetDocumentCharacterSetForURI(aHref, docCharset))) result = NS_NewURI(getter_AddRefs(newUri), aHref,
result = NS_NewURI(getter_AddRefs(newUri), aHref, docCharset.get(), aBase); doc->GetDocumentCharacterSet(), aBase);
else } else {
result = NS_NewURI(getter_AddRefs(newUri), aHref, nullptr, aBase); result = NS_NewURI(getter_AddRefs(newUri), aHref, nullptr, aBase);
}
if (newUri) { if (newUri) {
/* Check with the scriptContext if it is currently processing a script tag. /* 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)); nsCOMPtr<nsIPrefetchService> prefetchService(do_GetService(NS_PREFETCHSERVICE_CONTRACTID));
if (prefetchService) { if (prefetchService) {
// construct URI using document charset // construct URI using document charset
const nsACString &charset = mDocument->GetDocumentCharacterSet(); auto encoding = mDocument->GetDocumentCharacterSet();
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
NS_NewURI(getter_AddRefs(uri), aHref, NS_NewURI(getter_AddRefs(uri), aHref, encoding,
charset.IsEmpty() ? nullptr : PromiseFlatCString(charset).get(),
mDocument->GetDocBaseURI()); mDocument->GetDocBaseURI());
if (uri) { if (uri) {
nsCOMPtr<nsIDOMNode> domNode = do_QueryInterface(aSource); nsCOMPtr<nsIDOMNode> domNode = do_QueryInterface(aSource);
@ -893,10 +892,9 @@ void
nsContentSink::Preconnect(const nsAString& aHref, const nsAString& aCrossOrigin) nsContentSink::Preconnect(const nsAString& aHref, const nsAString& aCrossOrigin)
{ {
// construct URI using document charset // construct URI using document charset
const nsACString& charset = mDocument->GetDocumentCharacterSet(); auto encoding = mDocument->GetDocumentCharacterSet();
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
NS_NewURI(getter_AddRefs(uri), aHref, NS_NewURI(getter_AddRefs(uri), aHref, encoding,
charset.IsEmpty() ? nullptr : PromiseFlatCString(charset).get(),
mDocument->GetDocBaseURI()); mDocument->GetDocBaseURI());
if (uri && mDocument) { if (uri && mDocument) {

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

@ -3162,9 +3162,12 @@ nsContentUtils::NewURIWithDocumentCharset(nsIURI** aResult,
nsIDocument* aDocument, nsIDocument* aDocument,
nsIURI* aBaseURI) nsIURI* aBaseURI)
{ {
return NS_NewURI(aResult, aSpec, if (aDocument) {
aDocument ? aDocument->GetDocumentCharacterSet().get() : nullptr, return NS_NewURI(aResult, aSpec,
aBaseURI, sIOService); aDocument->GetDocumentCharacterSet(),
aBaseURI, sIOService);
}
return NS_NewURI(aResult, aSpec, nullptr, aBaseURI, sIOService);
} }
// static // static

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

@ -6,6 +6,7 @@
#include "nsDOMSerializer.h" #include "nsDOMSerializer.h"
#include "mozilla/Encoding.h"
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsIDocumentEncoder.h" #include "nsIDocumentEncoder.h"
#include "nsIDOMDocument.h" #include "nsIDOMDocument.h"
@ -71,7 +72,7 @@ SetUpEncoder(nsIDOMNode *aRoot, const nsACString& aCharset,
if (charset.IsEmpty()) { if (charset.IsEmpty()) {
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc); nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
NS_ASSERTION(doc, "Need a document"); NS_ASSERTION(doc, "Need a document");
charset = doc->GetDocumentCharacterSet(); doc->GetDocumentCharacterSet()->Name(charset);
} }
rv = encoder->SetCharset(charset); rv = encoder->SetCharset(charset);
if (NS_FAILED(rv)) if (NS_FAILED(rv))

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

@ -1294,7 +1294,7 @@ nsIDocument::nsIDocument()
mBlockAllMixedContentPreloads(false), mBlockAllMixedContentPreloads(false),
mUpgradeInsecureRequests(false), mUpgradeInsecureRequests(false),
mUpgradeInsecurePreloads(false), mUpgradeInsecurePreloads(false),
mCharacterSet(NS_LITERAL_CSTRING("windows-1252")), mCharacterSet(WINDOWS_1252_ENCODING),
mCharacterSetSource(0), mCharacterSetSource(0),
mParentDocument(nullptr), mParentDocument(nullptr),
mCachedRootElement(nullptr), mCachedRootElement(nullptr),
@ -3678,13 +3678,14 @@ nsDocument::GetBaseTarget(nsAString &aBaseTarget)
} }
void 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, if (mCharacterSet != aEncoding) {
// but before we figure out what to do about non-Encoding Standard mCharacterSet = aEncoding;
// encodings in the charset menu and in mailnews, assertions are futile.
if (!mCharacterSet.Equals(aCharSetID)) { nsAutoCString charsetID;
mCharacterSet = aCharSetID; aEncoding->Name(charsetID);
NS_ConvertASCIItoUTF16 charset16(charsetID);
int32_t n = mCharSetObservers.Length(); int32_t n = mCharSetObservers.Length();
@ -3692,7 +3693,7 @@ nsDocument::SetDocumentCharacterSet(const nsACString& aCharSetID)
nsIObserver* observer = mCharSetObservers.ElementAt(i); nsIObserver* observer = mCharSetObservers.ElementAt(i);
observer->Observe(static_cast<nsIDocument *>(this), "charset", 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 void
nsDocument::TryChannelCharset(nsIChannel *aChannel, nsDocument::TryChannelCharset(nsIChannel *aChannel,
int32_t& aCharsetSource, int32_t& aCharsetSource,
nsACString& aCharset, NotNull<const Encoding*>& aEncoding,
nsHtml5TreeOpExecutor* aExecutor) nsHtml5TreeOpExecutor* aExecutor)
{ {
if (aChannel) { if (aChannel) {
@ -3858,7 +3859,7 @@ nsDocument::TryChannelCharset(nsIChannel *aChannel,
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
const Encoding* preferred = Encoding::ForLabel(charsetVal); const Encoding* preferred = Encoding::ForLabel(charsetVal);
if (preferred) { if (preferred) {
preferred->Name(aCharset); aEncoding = WrapNotNull(preferred);
aCharsetSource = kCharsetFromChannel; aCharsetSource = kCharsetFromChannel;
return; return;
} else if (aExecutor && !charsetVal.IsEmpty()) { } else if (aExecutor && !charsetVal.IsEmpty()) {
@ -6495,7 +6496,9 @@ nsDocument::GetCharacterSet(nsAString& aCharacterSet)
void void
nsIDocument::GetCharacterSet(nsAString& aCharacterSet) const nsIDocument::GetCharacterSet(nsAString& aCharacterSet) const
{ {
CopyASCIItoUTF16(GetDocumentCharacterSet(), aCharacterSet); nsAutoCString charset;
GetDocumentCharacterSet()->Name(charset);
CopyASCIItoUTF16(charset, aCharacterSet);
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -6592,9 +6595,7 @@ nsIDocument::LoadBindingDocument(const nsAString& aURI,
ErrorResult& rv) ErrorResult& rv)
{ {
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
rv = NS_NewURI(getter_AddRefs(uri), aURI, rv = NS_NewURI(getter_AddRefs(uri), aURI, mCharacterSet, GetDocBaseURI());
mCharacterSet.get(),
GetDocBaseURI());
if (rv.Failed()) { if (rv.Failed()) {
return; return;
} }
@ -9920,8 +9921,7 @@ nsDocument::ScrollToRef()
// document's charset. // document's charset.
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
const nsACString &docCharset = GetDocumentCharacterSet(); auto encoding = GetDocumentCharacterSet();
const Encoding* encoding = Encoding::ForName(docCharset);
rv = encoding->DecodeWithoutBOMHandling(unescapedRef, ref); rv = encoding->DecodeWithoutBOMHandling(unescapedRef, ref);

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

@ -424,10 +424,11 @@ public:
virtual void GetBaseTarget(nsAString &aBaseTarget) override; 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. * 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. * Add an observer that gets notified whenever the charset changes.
@ -1048,7 +1049,7 @@ protected:
void TryChannelCharset(nsIChannel *aChannel, void TryChannelCharset(nsIChannel *aChannel,
int32_t& aCharsetSource, int32_t& aCharsetSource,
nsACString& aCharset, NotNull<const Encoding*>& aEncoding,
nsHtml5TreeOpExecutor* aExecutor); nsHtml5TreeOpExecutor* aExecutor);
// Call this before the document does something that will unbind all content. // Call this before the document does something that will unbind all content.

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

@ -272,16 +272,15 @@ nsFrameLoader::LoadFrame()
} }
nsCOMPtr<nsIURI> base_uri = mOwnerContent->GetBaseURI(); nsCOMPtr<nsIURI> base_uri = mOwnerContent->GetBaseURI();
const nsCString& doc_charset = doc->GetDocumentCharacterSet(); auto encoding = doc->GetDocumentCharacterSet();
const char *charset = doc_charset.IsEmpty() ? nullptr : doc_charset.get();
nsCOMPtr<nsIURI> uri; 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 the URI was malformed, try to recover by loading about:blank.
if (rv == NS_ERROR_MALFORMED_URI) { if (rv == NS_ERROR_MALFORMED_URI) {
rv = NS_NewURI(getter_AddRefs(uri), NS_LITERAL_STRING("about:blank"), rv = NS_NewURI(getter_AddRefs(uri), NS_LITERAL_STRING("about:blank"),
charset, base_uri); encoding, base_uri);
} }
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {

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

@ -13491,14 +13491,14 @@ nsGlobalWindow::SecurityCheckURL(const char *aURL)
// used to actually kick off the load in nsWindowWatcher.cpp. // used to actually kick off the load in nsWindowWatcher.cpp.
nsCOMPtr<nsIDocument> doc = sourceWindow->GetDoc(); nsCOMPtr<nsIDocument> doc = sourceWindow->GetDoc();
nsIURI* baseURI = nullptr; 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) { if (doc) {
baseURI = doc->GetDocBaseURI(); baseURI = doc->GetDocBaseURI();
charset = doc->GetDocumentCharacterSet(); encoding = doc->GetDocumentCharacterSet();
} }
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewURI(getter_AddRefs(uri), nsDependentCString(aURL), nsresult rv = NS_NewURI(getter_AddRefs(uri), nsDependentCString(aURL),
charset.get(), baseURI); encoding, baseURI);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }

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

@ -34,6 +34,7 @@
#include "mozilla/CORSMode.h" #include "mozilla/CORSMode.h"
#include "mozilla/dom/DispatcherTrait.h" #include "mozilla/dom/DispatcherTrait.h"
#include "mozilla/LinkedList.h" #include "mozilla/LinkedList.h"
#include "mozilla/NotNull.h"
#include "mozilla/SegmentedVector.h" #include "mozilla/SegmentedVector.h"
#include "mozilla/StyleBackendType.h" #include "mozilla/StyleBackendType.h"
#include "mozilla/StyleSheet.h" #include "mozilla/StyleSheet.h"
@ -104,6 +105,7 @@ struct nsCSSSelectorList;
namespace mozilla { namespace mozilla {
class AbstractThread; class AbstractThread;
class CSSStyleSheet; class CSSStyleSheet;
class Encoding;
class ErrorResult; class ErrorResult;
class EventStates; class EventStates;
class PendingAnimationTracker; class PendingAnimationTracker;
@ -211,6 +213,10 @@ class nsIDocument : public nsINode,
{ {
typedef mozilla::dom::GlobalObject GlobalObject; typedef mozilla::dom::GlobalObject GlobalObject;
protected:
using Encoding = mozilla::Encoding;
template <typename T> using NotNull = mozilla::NotNull<T>;
public: public:
typedef mozilla::net::ReferrerPolicy ReferrerPolicyEnum; typedef mozilla::net::ReferrerPolicy ReferrerPolicyEnum;
typedef mozilla::dom::Element Element; typedef mozilla::dom::Element Element;
@ -504,16 +510,15 @@ public:
/** /**
* Return a standard name for the document's character set. * Return a standard name for the document's character set.
*/ */
const nsCString& GetDocumentCharacterSet() const NotNull<const Encoding*> GetDocumentCharacterSet() const
{ {
return mCharacterSet; return mCharacterSet;
} }
/** /**
* Set the document's character encoding. |aCharSetID| should be canonical. * Set the document's character encoding.
* That is, callers are responsible for the charset alias resolution.
*/ */
virtual void SetDocumentCharacterSet(const nsACString& aCharSetID) = 0; virtual void SetDocumentCharacterSet(NotNull<const Encoding*> aEncoding) = 0;
int32_t GetDocumentCharacterSetSource() const int32_t GetDocumentCharacterSetSource() const
{ {
@ -3061,7 +3066,7 @@ protected:
mozilla::WeakPtr<nsDocShell> mDocumentContainer; mozilla::WeakPtr<nsDocShell> mDocumentContainer;
nsCString mCharacterSet; NotNull<const Encoding*> mCharacterSet;
int32_t mCharacterSetSource; int32_t mCharacterSetSource;
// This is just a weak pointer; the parent document owns its children. // 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(); nsCOMPtr<nsIURI> baseURL = thisContent->GetBaseURI();
// (2) Get the charset // (2) Get the charset
const nsCString& charset = aDocument->GetDocumentCharacterSet(); auto encoding = aDocument->GetDocumentCharacterSet();
// (3) Construct the silly thing // (3) Construct the silly thing
return NS_NewURI(aURI, return NS_NewURI(aURI,
aSpec, aSpec,
charset.IsEmpty() ? nullptr : charset.get(), encoding,
baseURL, baseURL,
nsContentUtils::GetIOService()); nsContentUtils::GetIOService());
} }

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

@ -33,8 +33,10 @@ nsReferencedElement::Reset(nsIContent* aFromContent, nsIURI* aURI,
nsAutoCString charset; nsAutoCString charset;
aURI->GetOriginCharset(charset); aURI->GetOriginCharset(charset);
const Encoding* encoding = charset.IsEmpty() ? auto encoding = Encoding::ForLabelNoReplacement(charset);
UTF_8_ENCODING : Encoding::ForName(charset); if (!encoding) {
encoding = UTF_8_ENCODING;
}
nsAutoString ref; nsAutoString ref;
nsresult rv = encoding->DecodeWithoutBOMHandling(refPart, ref); nsresult rv = encoding->DecodeWithoutBOMHandling(refPart, ref);
if (NS_FAILED(rv) || ref.IsEmpty()) { if (NS_FAILED(rv) || ref.IsEmpty()) {

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

@ -53,6 +53,11 @@ ChooseValidatorCompileOptions(const ShBuiltInResources& resources,
// Work around that Mac drivers handle struct scopes incorrectly. // Work around that Mac drivers handle struct scopes incorrectly.
options |= SH_REGENERATE_STRUCT_NAMES; options |= SH_REGENERATE_STRUCT_NAMES;
options |= SH_INIT_OUTPUT_VARIABLES; 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 #endif
if (!gl->IsANGLE() && gl->Vendor() == gl::GLVendor::Intel) { if (!gl->IsANGLE() && gl->Vendor() == gl::GLVendor::Intel) {

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

@ -36,34 +36,33 @@ FallbackEncoding* FallbackEncoding::sInstance = nullptr;
bool FallbackEncoding::sGuessFallbackFromTopLevelDomain = true; bool FallbackEncoding::sGuessFallbackFromTopLevelDomain = true;
FallbackEncoding::FallbackEncoding() FallbackEncoding::FallbackEncoding()
: mFallback(nullptr)
{ {
MOZ_ASSERT(!FallbackEncoding::sInstance, MOZ_ASSERT(!FallbackEncoding::sInstance,
"Singleton already exists."); "Singleton already exists.");
} }
void NotNull<const Encoding*>
FallbackEncoding::Get(nsACString& aFallback) FallbackEncoding::Get()
{ {
if (!mFallback.IsEmpty()) { if (mFallback) {
aFallback = mFallback; return WrapNotNull(mFallback);
return;
} }
const nsAdoptingCString& override = const nsAdoptingCString& override =
Preferences::GetCString("intl.charset.fallback.override"); Preferences::GetCString("intl.charset.fallback.override");
// Don't let the user break things by setting the override to unreasonable // Don't let the user break things by setting the override to unreasonable
// values via about:config // values via about:config
const Encoding* encoding = Encoding::ForLabel(override); auto encoding = Encoding::ForLabel(override);
if (!encoding || !encoding->IsAsciiCompatible() || if (!encoding || !encoding->IsAsciiCompatible() ||
encoding == UTF_8_ENCODING) { encoding == UTF_8_ENCODING) {
mFallback.Truncate(); mFallback = nullptr;
} else { } else {
encoding->Name(mFallback); mFallback = encoding;
} }
if (!mFallback.IsEmpty()) { if (mFallback) {
aFallback = mFallback; return WrapNotNull(mFallback);
return;
} }
nsAutoCString locale; nsAutoCString locale;
@ -80,9 +79,8 @@ FallbackEncoding::Get(nsACString& aFallback)
locale.EqualsLiteral("zh-hk") || locale.EqualsLiteral("zh-hk") ||
locale.EqualsLiteral("zh-mo") || locale.EqualsLiteral("zh-mo") ||
locale.EqualsLiteral("zh-hant")) { locale.EqualsLiteral("zh-hant")) {
mFallback.AssignLiteral("Big5"); mFallback = BIG5_ENCODING;
aFallback = mFallback; return WrapNotNull(mFallback);
return;
} }
// Throw away regions and other variants to accommodate weird stuff seen // Throw away regions and other variants to accommodate weird stuff seen
@ -92,20 +90,23 @@ FallbackEncoding::Get(nsACString& aFallback)
locale.Truncate(index); locale.Truncate(index);
} }
nsAutoCString fallback;
if (NS_FAILED(nsUConvPropertySearch::SearchPropertyValue( if (NS_FAILED(nsUConvPropertySearch::SearchPropertyValue(
localesFallbacks, ArrayLength(localesFallbacks), locale, mFallback))) { localesFallbacks, ArrayLength(localesFallbacks), locale, fallback))) {
mFallback.AssignLiteral("windows-1252"); mFallback = WINDOWS_1252_ENCODING;
} else {
mFallback = Encoding::ForName(fallback);
} }
aFallback = mFallback; return WrapNotNull(mFallback);
} }
void NotNull<const Encoding*>
FallbackEncoding::FromLocale(nsACString& aFallback) FallbackEncoding::FromLocale()
{ {
MOZ_ASSERT(FallbackEncoding::sInstance, MOZ_ASSERT(FallbackEncoding::sInstance,
"Using uninitialized fallback cache."); "Using uninitialized fallback cache.");
FallbackEncoding::sInstance->Get(aFallback); return FallbackEncoding::sInstance->Get();
} }
// PrefChangedFunc // PrefChangedFunc
@ -169,14 +170,15 @@ FallbackEncoding::IsParticipatingTopLevelDomain(const nsACString& aTLD)
dummy)); dummy));
} }
void NotNull<const Encoding*>
FallbackEncoding::FromTopLevelDomain(const nsACString& aTLD, FallbackEncoding::FromTopLevelDomain(const nsACString& aTLD)
nsACString& aFallback)
{ {
nsAutoCString fallback;
if (NS_FAILED(nsUConvPropertySearch::SearchPropertyValue( if (NS_FAILED(nsUConvPropertySearch::SearchPropertyValue(
domainsFallbacks, ArrayLength(domainsFallbacks), aTLD, aFallback))) { domainsFallbacks, ArrayLength(domainsFallbacks), aTLD, fallback))) {
aFallback.AssignLiteral("windows-1252"); return WINDOWS_1252_ENCODING;
} }
return Encoding::ForName(fallback);
} }
} // namespace dom } // namespace dom

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

@ -7,10 +7,12 @@
#ifndef mozilla_dom_FallbackEncoding_h_ #ifndef mozilla_dom_FallbackEncoding_h_
#define mozilla_dom_FallbackEncoding_h_ #define mozilla_dom_FallbackEncoding_h_
#include "mozilla/NotNull.h"
#include "nsIObserver.h" #include "nsIObserver.h"
#include "nsString.h" #include "nsString.h"
namespace mozilla { namespace mozilla {
class Encoding;
namespace dom { namespace dom {
class FallbackEncoding : public nsIObserver class FallbackEncoding : public nsIObserver
@ -30,7 +32,7 @@ public:
* *
* @param aFallback the outparam for the fallback encoding * @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. * 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 aTLD the top-level domain (in Punycode)
* @param aFallback the outparam for the fallback encoding * @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! // public API ends here!
@ -78,7 +80,7 @@ private:
*/ */
void Invalidate() void Invalidate()
{ {
mFallback.Truncate(); mFallback = nullptr;
} }
static void PrefChanged(const char*, void*); static void PrefChanged(const char*, void*);
@ -87,9 +89,9 @@ private:
* Gets the fallback encoding label. * Gets the fallback encoding label.
* @param aFallback the fallback encoding * @param aFallback the fallback encoding
*/ */
void Get(nsACString& aFallback); NotNull<const Encoding*> Get();
nsCString mFallback; const Encoding* mFallback;
}; };
} // namespace dom } // namespace dom

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

@ -887,7 +887,7 @@ GetSubmitEncoding(nsGenericHTMLElement* aForm)
// Get the charset from document // Get the charset from document
nsIDocument* doc = aForm->GetComposedDoc(); nsIDocument* doc = aForm->GetComposedDoc();
if (doc) { if (doc) {
return Encoding::ForName(doc->GetDocumentCharacterSet()); return doc->GetDocumentCharacterSet();
} }
return UTF_8_ENCODING; return UTF_8_ENCODING;
} }

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

@ -171,17 +171,16 @@ MediaDocument::StartDocumentLoad(const char* aCommand,
// not being able to set the charset is not critical. // not being able to set the charset is not critical.
NS_ENSURE_TRUE(docShell, NS_OK); NS_ENSURE_TRUE(docShell, NS_OK);
nsAutoCString charset; const Encoding* encoding;
int32_t source; int32_t source;
nsCOMPtr<nsIPrincipal> principal; nsCOMPtr<nsIPrincipal> principal;
// opening in a new tab // opening in a new tab
docShell->GetParentCharset(charset, &source, getter_AddRefs(principal)); docShell->GetParentCharset(encoding, &source, getter_AddRefs(principal));
if (!charset.IsEmpty() && if (encoding && encoding != UTF_8_ENCODING &&
!charset.EqualsLiteral("UTF-8") &&
NodePrincipal()->Equals(principal)) { NodePrincipal()->Equals(principal)) {
SetDocumentCharacterSetSource(source); SetDocumentCharacterSetSource(source);
SetDocumentCharacterSet(charset); SetDocumentCharacterSet(WrapNotNull(encoding));
} }
return NS_OK; 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 // window or a new tab, in which case |originCharset| of |nsIURI| is not
// reliable. // reliable.
if (mCharacterSetSource != kCharsetUninitialized) { if (mCharacterSetSource != kCharsetUninitialized) {
docCharset = mCharacterSet; mCharacterSet->Name(docCharset);
} else { } else {
// resort to |originCharset| // resort to |originCharset|
url->GetOriginCharset(docCharset); url->GetOriginCharset(docCharset);
SetDocumentCharacterSet(docCharset); auto encoding = Encoding::ForLabelNoReplacement(docCharset);
if (encoding) {
SetDocumentCharacterSet(WrapNotNull(encoding));
}
} }
nsresult rv; nsresult rv;

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

@ -136,7 +136,7 @@ public:
NS_IMETHOD WillResume(void) override; NS_IMETHOD WillResume(void) override;
NS_IMETHOD SetParser(nsParserBase* aParser) override; NS_IMETHOD SetParser(nsParserBase* aParser) override;
virtual void FlushPendingNotifications(FlushType aType) 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 nsISupports *GetTarget() override;
virtual bool IsScriptExecuting() override; virtual bool IsScriptExecuting() override;
@ -1087,11 +1087,10 @@ HTMLContentSink::FlushTags()
return mCurrentContext ? mCurrentContext->FlushTags() : NS_OK; return mCurrentContext ? mCurrentContext->FlushTags() : NS_OK;
} }
NS_IMETHODIMP void
HTMLContentSink::SetDocumentCharset(nsACString& aCharset) HTMLContentSink::SetDocumentCharset(NotNull<const Encoding*> aEncoding)
{ {
MOZ_ASSERT_UNREACHABLE("<meta charset> case doesn't occur with about:blank"); MOZ_ASSERT_UNREACHABLE("<meta charset> case doesn't occur with about:blank");
return NS_ERROR_NOT_IMPLEMENTED;
} }
nsISupports * nsISupports *

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

@ -164,6 +164,12 @@ IsAsciiCompatible(const nsACString& aPreferredName)
aPreferredName.LowerCaseEqualsLiteral("x-imap4-modified-utf7")); aPreferredName.LowerCaseEqualsLiteral("x-imap4-modified-utf7"));
} }
static bool
IsAsciiCompatible(const Encoding* aEncoding)
{
return aEncoding->IsAsciiCompatible() || aEncoding == ISO_2022_JP_ENCODING;
}
nsresult nsresult
NS_NewHTMLDocument(nsIDocument** aInstancePtrResult, bool aLoadedAsData) NS_NewHTMLDocument(nsIDocument** aInstancePtrResult, bool aLoadedAsData)
{ {
@ -286,7 +292,8 @@ nsHTMLDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup,
void void
nsHTMLDocument::TryHintCharset(nsIContentViewer* aCv, nsHTMLDocument::TryHintCharset(nsIContentViewer* aCv,
int32_t& aCharsetSource, nsACString& aCharset) int32_t& aCharsetSource,
NotNull<const Encoding*>& aEncoding)
{ {
if (aCv) { if (aCv) {
int32_t requestCharsetSource; int32_t requestCharsetSource;
@ -297,13 +304,15 @@ nsHTMLDocument::TryHintCharset(nsIContentViewer* aCv,
rv = aCv->GetHintCharacterSet(requestCharset); rv = aCv->GetHintCharacterSet(requestCharset);
aCv->SetHintCharacterSetSource((int32_t)(kCharsetUninitialized)); aCv->SetHintCharacterSetSource((int32_t)(kCharsetUninitialized));
if(requestCharsetSource <= aCharsetSource) if (requestCharsetSource <= aCharsetSource)
return; return;
if(NS_SUCCEEDED(rv) && IsAsciiCompatible(requestCharset)) { if (NS_SUCCEEDED(rv) && !requestCharset.IsEmpty()) {
aCharsetSource = requestCharsetSource; auto encoding = Encoding::ForName(requestCharset);
aCharset = requestCharset; if (IsAsciiCompatible(encoding)) {
aCharsetSource = requestCharsetSource;
aEncoding = encoding;
}
return; return;
} }
} }
@ -316,15 +325,15 @@ void
nsHTMLDocument::TryUserForcedCharset(nsIContentViewer* aCv, nsHTMLDocument::TryUserForcedCharset(nsIContentViewer* aCv,
nsIDocShell* aDocShell, nsIDocShell* aDocShell,
int32_t& aCharsetSource, int32_t& aCharsetSource,
nsACString& aCharset) NotNull<const Encoding*>& aEncoding)
{ {
nsresult rv = NS_OK; nsresult rv = NS_OK;
if(kCharsetFromUserForced <= aCharsetSource) if(kCharsetFromUserForced <= aCharsetSource)
return; return;
// mCharacterSet not updated yet for channel, so check aCharset, too. // mCharacterSet not updated yet for channel, so check aEncoding, too.
if (WillIgnoreCharsetOverride() || !IsAsciiCompatible(aCharset)) { if (WillIgnoreCharsetOverride() || !IsAsciiCompatible(aEncoding)) {
return; return;
} }
@ -337,21 +346,20 @@ nsHTMLDocument::TryUserForcedCharset(nsIContentViewer* aCv,
if(NS_SUCCEEDED(rv) && if(NS_SUCCEEDED(rv) &&
!forceCharsetFromDocShell.IsEmpty() && !forceCharsetFromDocShell.IsEmpty() &&
IsAsciiCompatible(forceCharsetFromDocShell)) { IsAsciiCompatible(forceCharsetFromDocShell)) {
aCharset = forceCharsetFromDocShell; aEncoding = Encoding::ForName(forceCharsetFromDocShell);
aCharsetSource = kCharsetFromUserForced; aCharsetSource = kCharsetFromUserForced;
return; return;
} }
if (aDocShell) { if (aDocShell) {
// This is the Character Encoding menu code path in Firefox // This is the Character Encoding menu code path in Firefox
nsAutoCString charset; auto encoding = nsDocShell::Cast(aDocShell)->GetForcedCharset();
rv = aDocShell->GetForcedCharset(charset);
if (NS_SUCCEEDED(rv) && !charset.IsEmpty()) { if (encoding) {
if (!IsAsciiCompatible(charset)) { if (!IsAsciiCompatible(encoding)) {
return; return;
} }
aCharset = charset; aEncoding = WrapNotNull(encoding);
aCharsetSource = kCharsetFromUserForced; aCharsetSource = kCharsetFromUserForced;
aDocShell->SetForcedCharset(NS_LITERAL_CSTRING("")); aDocShell->SetForcedCharset(NS_LITERAL_CSTRING(""));
} }
@ -361,7 +369,7 @@ nsHTMLDocument::TryUserForcedCharset(nsIContentViewer* aCv,
void void
nsHTMLDocument::TryCacheCharset(nsICachingChannel* aCachingChannel, nsHTMLDocument::TryCacheCharset(nsICachingChannel* aCachingChannel,
int32_t& aCharsetSource, int32_t& aCharsetSource,
nsACString& aCharset) NotNull<const Encoding*>& aEncoding)
{ {
nsresult rv; nsresult rv;
@ -389,15 +397,14 @@ nsHTMLDocument::TryCacheCharset(nsICachingChannel* aCachingChannel,
if (!encoding->IsAsciiCompatible() && encoding != ISO_2022_JP_ENCODING) { if (!encoding->IsAsciiCompatible() && encoding != ISO_2022_JP_ENCODING) {
return; return;
} }
encoding->Name(cachedCharset); aEncoding = WrapNotNull(encoding);
aCharset = cachedCharset;
aCharsetSource = kCharsetFromCache; aCharsetSource = kCharsetFromCache;
} }
void void
nsHTMLDocument::TryParentCharset(nsIDocShell* aDocShell, nsHTMLDocument::TryParentCharset(nsIDocShell* aDocShell,
int32_t& aCharsetSource, int32_t& aCharsetSource,
nsACString& aCharset) NotNull<const Encoding*>& aEncoding)
{ {
if (!aDocShell) { if (!aDocShell) {
return; return;
@ -407,22 +414,22 @@ nsHTMLDocument::TryParentCharset(nsIDocShell* aDocShell,
} }
int32_t parentSource; int32_t parentSource;
nsAutoCString parentCharset; const Encoding* parentCharset;
nsCOMPtr<nsIPrincipal> parentPrincipal; nsCOMPtr<nsIPrincipal> parentPrincipal;
aDocShell->GetParentCharset(parentCharset, aDocShell->GetParentCharset(parentCharset,
&parentSource, &parentSource,
getter_AddRefs(parentPrincipal)); getter_AddRefs(parentPrincipal));
if (parentCharset.IsEmpty()) { if (!parentCharset) {
return; return;
} }
if (kCharsetFromParentForced == parentSource || if (kCharsetFromParentForced == parentSource ||
kCharsetFromUserForced == parentSource) { kCharsetFromUserForced == parentSource) {
if (WillIgnoreCharsetOverride() || if (WillIgnoreCharsetOverride() ||
!IsAsciiCompatible(aCharset) || // if channel said UTF-16 !IsAsciiCompatible(aEncoding) || // if channel said UTF-16
!IsAsciiCompatible(parentCharset)) { !IsAsciiCompatible(parentCharset)) {
return; return;
} }
aCharset.Assign(parentCharset); aEncoding = WrapNotNull(parentCharset);
aCharsetSource = kCharsetFromParentForced; aCharsetSource = kCharsetFromParentForced;
return; return;
} }
@ -438,13 +445,14 @@ nsHTMLDocument::TryParentCharset(nsIDocShell* aDocShell,
return; return;
} }
aCharset.Assign(parentCharset); aEncoding = WrapNotNull(parentCharset);
aCharsetSource = kCharsetFromParentFrame; aCharsetSource = kCharsetFromParentFrame;
} }
} }
void void
nsHTMLDocument::TryTLD(int32_t& aCharsetSource, nsACString& aCharset) nsHTMLDocument::TryTLD(int32_t& aCharsetSource,
NotNull<const Encoding*>& aEncoding)
{ {
if (aCharsetSource >= kCharsetFromTopLevelDomain) { if (aCharsetSource >= kCharsetFromTopLevelDomain) {
return; return;
@ -500,29 +508,32 @@ nsHTMLDocument::TryTLD(int32_t& aCharsetSource, nsACString& aCharset)
return; return;
} }
aCharsetSource = kCharsetFromTopLevelDomain; aCharsetSource = kCharsetFromTopLevelDomain;
FallbackEncoding::FromTopLevelDomain(tld, aCharset); aEncoding = FallbackEncoding::FromTopLevelDomain(tld);
} }
void void
nsHTMLDocument::TryFallback(int32_t& aCharsetSource, nsACString& aCharset) nsHTMLDocument::TryFallback(int32_t& aCharsetSource,
NotNull<const Encoding*>& aEncoding)
{ {
if (kCharsetFromFallback <= aCharsetSource) if (kCharsetFromFallback <= aCharsetSource)
return; return;
aCharsetSource = kCharsetFromFallback; aCharsetSource = kCharsetFromFallback;
FallbackEncoding::FromLocale(aCharset); aEncoding = FallbackEncoding::FromLocale();
} }
void 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 // Make sure to stash this charset on our channel as needed if it's a wyciwyg
// channel. // channel.
nsCOMPtr<nsIWyciwygChannel> wyciwygChannel = do_QueryInterface(mChannel); nsCOMPtr<nsIWyciwygChannel> wyciwygChannel = do_QueryInterface(mChannel);
if (wyciwygChannel) { if (wyciwygChannel) {
nsAutoCString charset;
aEncoding->Name(charset);
wyciwygChannel->SetCharsetAndSource(GetDocumentCharacterSetSource(), wyciwygChannel->SetCharsetAndSource(GetDocumentCharacterSetSource(),
aCharSetID); charset);
} }
} }
@ -671,12 +682,12 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
// These are the charset source and charset for our document // These are the charset source and charset for our document
int32_t charsetSource; int32_t charsetSource;
nsAutoCString charset; auto encoding = UTF_8_ENCODING;
// These are the charset source and charset for the parser. This can differ // 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. // from that for the document if the channel is a wyciwyg channel.
int32_t parserCharsetSource; int32_t parserCharsetSource;
nsAutoCString parserCharset; auto parserCharset = UTF_8_ENCODING;
nsCOMPtr<nsIWyciwygChannel> wyciwygChannel; nsCOMPtr<nsIWyciwygChannel> wyciwygChannel;
@ -693,16 +704,13 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
if (forceUtf8) { if (forceUtf8) {
charsetSource = kCharsetFromUtf8OnlyMime; charsetSource = kCharsetFromUtf8OnlyMime;
charset.AssignLiteral("UTF-8");
parserCharsetSource = charsetSource; parserCharsetSource = charsetSource;
parserCharset = charset;
} else if (!IsHTMLDocument() || !docShell) { // no docshell for text/html XHR } else if (!IsHTMLDocument() || !docShell) { // no docshell for text/html XHR
charsetSource = IsHTMLDocument() ? kCharsetFromFallback charsetSource = IsHTMLDocument() ? kCharsetFromFallback
: kCharsetFromDocTypeDefault; : kCharsetFromDocTypeDefault;
charset.AssignLiteral("UTF-8"); TryChannelCharset(aChannel, charsetSource, encoding, executor);
TryChannelCharset(aChannel, charsetSource, charset, executor); parserCharset = encoding;
parserCharsetSource = charsetSource; parserCharsetSource = charsetSource;
parserCharset = charset;
} else { } else {
NS_ASSERTION(docShell, "Unexpected null value"); 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 // 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 // interpretation as ASCII and the user can be lured to using the
// charset menu. // 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 TryHintCharset(cv, charsetSource, encoding); // XXX mailnews-only
TryParentCharset(docShell, charsetSource, charset); TryParentCharset(docShell, charsetSource, encoding);
if (cachingChan && !urlSpec.IsEmpty()) { if (cachingChan && !urlSpec.IsEmpty()) {
TryCacheCharset(cachingChan, charsetSource, charset); TryCacheCharset(cachingChan, charsetSource, encoding);
} }
TryTLD(charsetSource, charset); TryTLD(charsetSource, encoding);
TryFallback(charsetSource, charset); TryFallback(charsetSource, encoding);
if (wyciwygChannel) { if (wyciwygChannel) {
// We know for sure that the parser needs to be using UTF16. // We know for sure that the parser needs to be using UTF16.
parserCharset = "UTF-16LE"; parserCharset = UTF_16LE_ENCODING;
parserCharsetSource = charsetSource < kCharsetFromChannel ? parserCharsetSource = charsetSource < kCharsetFromChannel ?
kCharsetFromChannel : charsetSource; kCharsetFromChannel : charsetSource;
@ -752,27 +760,34 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
rv = wyciwygChannel->GetCharsetAndSource(&cachedSource, cachedCharset); rv = wyciwygChannel->GetCharsetAndSource(&cachedSource, cachedCharset);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
if (cachedSource > charsetSource) { if (cachedSource > charsetSource) {
charsetSource = cachedSource; auto cachedEncoding = Encoding::ForLabel(cachedCharset);
charset = cachedCharset; if (!cachedEncoding && cachedCharset.EqualsLiteral("replacement")) {
cachedEncoding = REPLACEMENT_ENCODING;
}
if (cachedEncoding) {
charsetSource = cachedSource;
encoding = WrapNotNull(cachedEncoding);
}
} }
} else { } else {
// Don't propagate this error. // Don't propagate this error.
rv = NS_OK; rv = NS_OK;
} }
} else { } else {
parserCharset = charset; parserCharset = encoding;
parserCharsetSource = charsetSource; parserCharsetSource = charsetSource;
} }
} }
SetDocumentCharacterSetSource(charsetSource); SetDocumentCharacterSetSource(charsetSource);
SetDocumentCharacterSet(charset); SetDocumentCharacterSet(encoding);
if (cachingChan) { if (cachingChan) {
NS_ASSERTION(charset == parserCharset, NS_ASSERTION(encoding == parserCharset,
"How did those end up different here? wyciwyg channels are " "How did those end up different here? wyciwyg channels are "
"not nsICachingChannel"); "not nsICachingChannel");
nsAutoCString charset;
encoding->Name(charset);
rv = cachingChan->SetCacheTokenCachedCharset(charset); rv = cachingChan->SetCacheTokenCachedCharset(charset);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "cannot SetMetaDataElement"); NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "cannot SetMetaDataElement");
rv = NS_OK; // don't propagate error rv = NS_OK; // don't propagate error
@ -785,7 +800,7 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
#ifdef DEBUG_charset #ifdef DEBUG_charset
printf(" charset = %s source %d\n", printf(" charset = %s source %d\n",
charset.get(), charsetSource); charset.get(), charsetSource);
#endif #endif
mParser->SetDocumentCharset(parserCharset, parserCharsetSource); mParser->SetDocumentCharset(parserCharset, parserCharsetSource);
mParser->SetCommand(aCommand); mParser->SetCommand(aCommand);
@ -2416,8 +2431,9 @@ nsHTMLDocument::CreateAndAddWyciwygChannel(void)
// Note: we want to treat this like a "previous document" hint so that, // 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. // e.g. a <meta> tag in the document.write content can override it.
SetDocumentCharacterSetSource(kCharsetFromHintPrevDoc); SetDocumentCharacterSetSource(kCharsetFromHintPrevDoc);
mWyciwygChannel->SetCharsetAndSource(kCharsetFromHintPrevDoc, nsAutoCString charset;
GetDocumentCharacterSet()); GetDocumentCharacterSet()->Name(charset);
mWyciwygChannel->SetCharsetAndSource(kCharsetFromHintPrevDoc, charset);
// Inherit load flags from the original document's channel // Inherit load flags from the original document's channel
channel->SetLoadFlags(mLoadFlags); channel->SetLoadFlags(mLoadFlags);
@ -3745,7 +3761,8 @@ nsHTMLDocument::WillIgnoreCharsetOverride()
if (mCharacterSetSource >= kCharsetFromByteOrderMark) { if (mCharacterSetSource >= kCharsetFromByteOrderMark) {
return true; return true;
} }
if (!IsAsciiCompatible(mCharacterSet)) { if (!mCharacterSet->IsAsciiCompatible() &&
mCharacterSet != ISO_2022_JP_ENCODING) {
return true; return true;
} }
nsCOMPtr<nsIWyciwygChannel> wyciwyg = do_QueryInterface(mChannel); nsCOMPtr<nsIWyciwygChannel> wyciwyg = do_QueryInterface(mChannel);

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

@ -321,21 +321,24 @@ protected:
static void TryHintCharset(nsIContentViewer* aContentViewer, static void TryHintCharset(nsIContentViewer* aContentViewer,
int32_t& aCharsetSource, int32_t& aCharsetSource,
nsACString& aCharset); NotNull<const Encoding*>& aEncoding);
void TryUserForcedCharset(nsIContentViewer* aCv, void TryUserForcedCharset(nsIContentViewer* aCv,
nsIDocShell* aDocShell, nsIDocShell* aDocShell,
int32_t& aCharsetSource, int32_t& aCharsetSource,
nsACString& aCharset); NotNull<const Encoding*>& aEncoding);
static void TryCacheCharset(nsICachingChannel* aCachingChannel, static void TryCacheCharset(nsICachingChannel* aCachingChannel,
int32_t& aCharsetSource, int32_t& aCharsetSource,
nsACString& aCharset); NotNull<const Encoding*>& aEncoding);
void TryParentCharset(nsIDocShell* aDocShell, void TryParentCharset(nsIDocShell* aDocShell,
int32_t& charsetSource, nsACString& aCharset); int32_t& charsetSource,
void TryTLD(int32_t& aCharsetSource, nsACString& aCharset); NotNull<const Encoding*>& aEncoding);
static void TryFallback(int32_t& aCharsetSource, nsACString& aCharset); 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. // 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 // Tracks if we are currently processing any document.write calls (either
// implicit or explicit). Note that if a write call writes out something which // implicit or explicit). Note that if a write call writes out something which

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

@ -6,6 +6,7 @@
#include "mozilla/dom/Notification.h" #include "mozilla/dom/Notification.h"
#include "mozilla/Encoding.h"
#include "mozilla/JSONWriter.h" #include "mozilla/JSONWriter.h"
#include "mozilla/Move.h" #include "mozilla/Move.h"
#include "mozilla/OwningNonNull.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 // 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 // workers, but for backwards compat keeping it document charset on main
// thread. // thread.
const char* charset = "UTF-8"; auto encoding = UTF_8_ENCODING;
if (mWorkerPrivate) { if (mWorkerPrivate) {
baseUri = mWorkerPrivate->GetBaseURI(); baseUri = mWorkerPrivate->GetBaseURI();
@ -1930,7 +1931,7 @@ Notification::ResolveIconAndSoundURL(nsString& iconUrl, nsString& soundUrl)
nsIDocument* doc = GetOwner() ? GetOwner()->GetExtantDoc() : nullptr; nsIDocument* doc = GetOwner() ? GetOwner()->GetExtantDoc() : nullptr;
if (doc) { if (doc) {
baseUri = doc->GetBaseURI(); baseUri = doc->GetBaseURI();
charset = doc->GetDocumentCharacterSet().get(); encoding = doc->GetDocumentCharacterSet();
} else { } else {
NS_WARNING("No document found for main thread notification!"); NS_WARNING("No document found for main thread notification!");
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -1940,7 +1941,7 @@ Notification::ResolveIconAndSoundURL(nsString& iconUrl, nsString& soundUrl)
if (baseUri) { if (baseUri) {
if (mIconUrl.Length() > 0) { if (mIconUrl.Length() > 0) {
nsCOMPtr<nsIURI> srcUri; 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)) { if (NS_SUCCEEDED(rv)) {
nsAutoCString src; nsAutoCString src;
srcUri->GetSpec(src); srcUri->GetSpec(src);
@ -1949,7 +1950,7 @@ Notification::ResolveIconAndSoundURL(nsString& iconUrl, nsString& soundUrl)
} }
if (mBehavior.mSoundFile.Length() > 0) { if (mBehavior.mSoundFile.Length() > 0) {
nsCOMPtr<nsIURI> srcUri; 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)) { if (NS_SUCCEEDED(rv)) {
nsAutoCString src; nsAutoCString src;
srcUri->GetSpec(src); srcUri->GetSpec(src);

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

@ -47,11 +47,13 @@ GetAbsoluteURL(const nsAString& aUrl,
nsAString& aAbsoluteUrl) nsAString& aAbsoluteUrl)
{ {
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewURI(getter_AddRefs(uri), nsresult rv;
aUrl, if (aDocument) {
aDocument ? aDocument->GetDocumentCharacterSet().get() rv = NS_NewURI(getter_AddRefs(uri), aUrl,
: nullptr, aDocument->GetDocumentCharacterSet(), aBaseUri);
aBaseUri); } else {
rv = NS_NewURI(getter_AddRefs(uri), aUrl, nullptr, aBaseUri);
}
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return rv; return rv;

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

@ -228,8 +228,7 @@ ScriptLoadHandler::EnsureDecoder(nsIIncrementalStreamLoader* aLoader,
// Get the charset from the charset of the document. // Get the charset from the charset of the document.
if (mScriptLoader->mDocument) { if (mScriptLoader->mDocument) {
encoding = encoding = mScriptLoader->mDocument->GetDocumentCharacterSet();
Encoding::ForName(mScriptLoader->mDocument->GetDocumentCharacterSet());
mDecoder = encoding->NewDecoderWithoutBOMHandling(); mDecoder = encoding->NewDecoderWithoutBOMHandling();
encoding->Name(oCharset); encoding->Name(oCharset);
return true; return true;

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

@ -2569,7 +2569,7 @@ ScriptLoader::ConvertToUTF16(nsIChannel* aChannel, const uint8_t* aData,
} }
if (!unicodeDecoder && aDocument) { if (!unicodeDecoder && aDocument) {
unicodeDecoder = Encoding::ForName(aDocument->GetDocumentCharacterSet()) unicodeDecoder = aDocument->GetDocumentCharacterSet()
->NewDecoderWithoutBOMHandling(); ->NewDecoderWithoutBOMHandling();
} }

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

@ -137,7 +137,7 @@ WebBrowserPersistLocalDocument::GetContentType(nsACString& aContentType)
NS_IMETHODIMP NS_IMETHODIMP
WebBrowserPersistLocalDocument::GetCharacterSet(nsACString& aCharSet) WebBrowserPersistLocalDocument::GetCharacterSet(nsACString& aCharSet)
{ {
aCharSet = GetCharacterSet(); GetCharacterSet()->Name(aCharSet);
return NS_OK; return NS_OK;
} }
@ -236,7 +236,7 @@ WebBrowserPersistLocalDocument::GetHistory()
return history.forget(); return history.forget();
} }
const nsCString& NotNull<const Encoding*>
WebBrowserPersistLocalDocument::GetCharacterSet() const WebBrowserPersistLocalDocument::GetCharacterSet() const
{ {
return mDocument->GetDocumentCharacterSet(); return mDocument->GetDocumentCharacterSet();
@ -397,7 +397,7 @@ ResourceReader::OnWalkURI(const nsACString& aURISpec)
rv = NS_NewURI(getter_AddRefs(uri), rv = NS_NewURI(getter_AddRefs(uri),
aURISpec, aURISpec,
mParent->GetCharacterSet().get(), mParent->GetCharacterSet(),
mCurrentBaseURI); mCurrentBaseURI);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
return OnWalkURI(uri); return OnWalkURI(uri);
@ -552,7 +552,7 @@ ResourceReader::OnWalkDOMNode(nsIDOMNode* aNode)
if (!codebase.IsEmpty()) { if (!codebase.IsEmpty()) {
nsCOMPtr<nsIURI> baseURI; nsCOMPtr<nsIURI> baseURI;
rv = NS_NewURI(getter_AddRefs(baseURI), codebase, rv = NS_NewURI(getter_AddRefs(baseURI), codebase,
mParent->GetCharacterSet().get(), mCurrentBaseURI); mParent->GetCharacterSet(), mCurrentBaseURI);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
if (baseURI) { if (baseURI) {
mCurrentBaseURI = baseURI; mCurrentBaseURI = baseURI;
@ -717,7 +717,7 @@ PersistNodeFixup::FixupURI(nsAString &aURI)
// get the current location of the file (absolutized) // get the current location of the file (absolutized)
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewURI(getter_AddRefs(uri), aURI, nsresult rv = NS_NewURI(getter_AddRefs(uri), aURI,
mParent->GetCharacterSet().get(), mCurrentBaseURI); mParent->GetCharacterSet(), mCurrentBaseURI);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString spec; nsAutoCString spec;
rv = uri->GetSpec(spec); rv = uri->GetSpec(spec);
@ -804,7 +804,7 @@ PersistNodeFixup::FixupAnchor(nsIDOMNode *aNode)
// Make a new URI to replace the current one // Make a new URI to replace the current one
nsCOMPtr<nsIURI> newURI; nsCOMPtr<nsIURI> newURI;
rv = NS_NewURI(getter_AddRefs(newURI), oldCValue, rv = NS_NewURI(getter_AddRefs(newURI), oldCValue,
mParent->GetCharacterSet().get(), relativeURI); mParent->GetCharacterSet(), relativeURI);
if (NS_SUCCEEDED(rv) && newURI) { if (NS_SUCCEEDED(rv) && newURI) {
newURI->SetUserPass(EmptyCString()); newURI->SetUserPass(EmptyCString());
nsAutoCString uriSpec; nsAutoCString uriSpec;
@ -1130,7 +1130,7 @@ PersistNodeFixup::FixupNode(nsIDOMNode *aNodeIn,
if (!codebase.IsEmpty()) { if (!codebase.IsEmpty()) {
nsCOMPtr<nsIURI> baseURI; nsCOMPtr<nsIURI> baseURI;
NS_NewURI(getter_AddRefs(baseURI), codebase, NS_NewURI(getter_AddRefs(baseURI), codebase,
mParent->GetCharacterSet().get(), mCurrentBaseURI); mParent->GetCharacterSet(), mCurrentBaseURI);
if (baseURI) { if (baseURI) {
mCurrentBaseURI = baseURI; mCurrentBaseURI = baseURI;
} }

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

@ -24,7 +24,7 @@ class WebBrowserPersistLocalDocument final
public: public:
explicit WebBrowserPersistLocalDocument(nsIDocument* aDocument); explicit WebBrowserPersistLocalDocument(nsIDocument* aDocument);
const nsCString& GetCharacterSet() const; NotNull<const Encoding*> GetCharacterSet() const;
uint32_t GetPersistFlags() const; uint32_t GetPersistFlags() const;
already_AddRefed<nsIURI> GetBaseURI() const; already_AddRefed<nsIURI> GetBaseURI() const;

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

@ -1632,7 +1632,7 @@ nsXBLPrototypeBinding::ResolveBaseBinding()
mBinding->UnsetAttr(kNameSpaceID_None, nsGkAtoms::display, false); mBinding->UnsetAttr(kNameSpaceID_None, nsGkAtoms::display, false);
return NS_NewURI(getter_AddRefs(mBaseBindingURI), value, return NS_NewURI(getter_AddRefs(mBaseBindingURI), value,
doc->GetDocumentCharacterSet().get(), doc->GetDocumentCharacterSet(),
doc->GetDocBaseURI()); doc->GetDocBaseURI());
} }

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

@ -113,7 +113,7 @@ nsXBLResourceLoader::LoadResources(nsIContent* aBoundElement)
continue; continue;
if (NS_FAILED(NS_NewURI(getter_AddRefs(url), curr->mSrc, if (NS_FAILED(NS_NewURI(getter_AddRefs(url), curr->mSrc,
doc->GetDocumentCharacterSet().get(), docURL))) doc->GetDocumentCharacterSet(), docURL)))
continue; continue;
if (curr->mType == nsGkAtoms::image) { if (curr->mType == nsGkAtoms::image) {

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

@ -182,6 +182,7 @@ XMLHttpRequestMainThread::sDontWarnAboutSyncXHR = false;
XMLHttpRequestMainThread::XMLHttpRequestMainThread() XMLHttpRequestMainThread::XMLHttpRequestMainThread()
: mResponseBodyDecodedPos(0), : mResponseBodyDecodedPos(0),
mResponseCharset(nullptr),
mResponseType(XMLHttpRequestResponseType::_empty), mResponseType(XMLHttpRequestResponseType::_empty),
mRequestObserver(nullptr), mRequestObserver(nullptr),
mState(State::unsent), mState(State::unsent),
@ -496,7 +497,7 @@ XMLHttpRequestMainThread::GetResponseXML(ErrorResult& aRv)
nsresult nsresult
XMLHttpRequestMainThread::DetectCharset() XMLHttpRequestMainThread::DetectCharset()
{ {
mResponseCharset.Truncate(); mResponseCharset = nullptr;
mDecoder = nullptr; mDecoder = nullptr;
if (mResponseType != XMLHttpRequestResponseType::_empty && if (mResponseType != XMLHttpRequestResponseType::_empty &&
@ -523,7 +524,7 @@ XMLHttpRequestMainThread::DetectCharset()
encoding = UTF_8_ENCODING; encoding = UTF_8_ENCODING;
} }
encoding->Name(mResponseCharset); mResponseCharset = encoding;
mDecoder = encoding->NewDecoderWithBOMRemoval(); mDecoder = encoding->NewDecoderWithBOMRemoval();
return NS_OK; return NS_OK;
@ -2435,7 +2436,7 @@ XMLHttpRequestMainThread::MatchCharsetAndDecoderToResponseDocument()
mResponseCharset = mResponseXML->GetDocumentCharacterSet(); mResponseCharset = mResponseXML->GetDocumentCharacterSet();
TruncateResponseText(); TruncateResponseText();
mResponseBodyDecodedPos = 0; mResponseBodyDecodedPos = 0;
mDecoder = Encoding::ForName(mResponseCharset)->NewDecoderWithBOMRemoval(); mDecoder = mResponseCharset->NewDecoderWithBOMRemoval();
} }
} }

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

@ -708,7 +708,7 @@ protected:
// part of the surrogate. // part of the surrogate.
mozilla::UniquePtr<mozilla::Decoder> mDecoder; mozilla::UniquePtr<mozilla::Decoder> mDecoder;
nsCString mResponseCharset; const Encoding* mResponseCharset;
void MatchCharsetAndDecoderToResponseDocument(); void MatchCharsetAndDecoderToResponseDocument();

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

@ -151,7 +151,7 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
// XMLDocuments and documents "created in memory" get to be UTF-8 by default, // XMLDocuments and documents "created in memory" get to be UTF-8 by default,
// unlike the legacy HTML mess // unlike the legacy HTML mess
doc->SetDocumentCharacterSet(NS_LITERAL_CSTRING("UTF-8")); doc->SetDocumentCharacterSet(UTF_8_ENCODING);
if (aDoctype) { if (aDoctype) {
nsCOMPtr<nsINode> doctypeAsNode = do_QueryInterface(aDoctype); nsCOMPtr<nsINode> doctypeAsNode = do_QueryInterface(aDoctype);
@ -322,7 +322,7 @@ XMLDocument::Load(const nsAString& aUrl, CallerType aCallerType,
if (callingDoc) { if (callingDoc) {
baseURI = callingDoc->GetDocBaseURI(); baseURI = callingDoc->GetDocBaseURI();
charset = callingDoc->GetDocumentCharacterSet(); callingDoc->GetDocumentCharacterSet()->Name(charset);
} }
// Create a new URI // Create a new URI
@ -530,8 +530,8 @@ XMLDocument::StartDocumentLoad(const char* aCommand,
int32_t charsetSource = kCharsetFromDocTypeDefault; int32_t charsetSource = kCharsetFromDocTypeDefault;
nsAutoCString charset(NS_LITERAL_CSTRING("UTF-8")); NotNull<const Encoding*> encoding = UTF_8_ENCODING;
TryChannelCharset(aChannel, charsetSource, charset, nullptr); TryChannelCharset(aChannel, charsetSource, encoding, nullptr);
nsCOMPtr<nsIURI> aUrl; nsCOMPtr<nsIURI> aUrl;
rv = aChannel->GetURI(getter_AddRefs(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?"); NS_ASSERTION(mChannel, "How can we not have a channel here?");
mChannelIsPending = true; mChannelIsPending = true;
SetDocumentCharacterSet(charset); SetDocumentCharacterSet(encoding);
mParser->SetDocumentCharset(charset, charsetSource); mParser->SetDocumentCharset(encoding, charsetSource);
mParser->SetCommand(aCommand); mParser->SetCommand(aCommand);
mParser->SetContentSink(sink); mParser->SetContentSink(sink);
mParser->Parse(aUrl, nullptr, (void *)this); mParser->Parse(aUrl, nullptr, (void *)this);

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

@ -115,15 +115,14 @@ XMLStylesheetProcessingInstruction::GetStyleSheetURL(bool* aIsInline)
} }
nsIURI *baseURL; nsIURI *baseURL;
nsAutoCString charset;
nsIDocument *document = OwnerDoc(); nsIDocument *document = OwnerDoc();
baseURL = mOverriddenBaseURI ? baseURL = mOverriddenBaseURI ?
mOverriddenBaseURI.get() : mOverriddenBaseURI.get() :
document->GetDocBaseURI(); document->GetDocBaseURI();
charset = document->GetDocumentCharacterSet(); auto encoding = document->GetDocumentCharacterSet();
nsCOMPtr<nsIURI> aURI; nsCOMPtr<nsIURI> aURI;
NS_NewURI(getter_AddRefs(aURI), href, charset.get(), baseURL); NS_NewURI(getter_AddRefs(aURI), href, encoding, baseURL);
return aURI.forget(); return aURI.forget();
} }

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

@ -731,14 +731,12 @@ nsXMLContentSink::ProcessStyleLink(nsIContent* aElement,
return rv; return rv;
} }
NS_IMETHODIMP void
nsXMLContentSink::SetDocumentCharset(nsACString& aCharset) nsXMLContentSink::SetDocumentCharset(NotNull<const Encoding*> aEncoding)
{ {
if (mDocument) { if (mDocument) {
mDocument->SetDocumentCharacterSet(aCharset); mDocument->SetDocumentCharacterSet(aEncoding);
} }
return NS_OK;
} }
nsISupports * nsISupports *

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

@ -70,7 +70,7 @@ public:
NS_IMETHOD WillResume(void) override; NS_IMETHOD WillResume(void) override;
NS_IMETHOD SetParser(nsParserBase* aParser) override; NS_IMETHOD SetParser(nsParserBase* aParser) override;
virtual void FlushPendingNotifications(mozilla::FlushType aType) 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 nsISupports *GetTarget() override;
virtual bool IsScriptExecuting() override; virtual bool IsScriptExecuting() override;
virtual void ContinueInterruptedParsingAsync() override; virtual void ContinueInterruptedParsingAsync() override;

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

@ -62,7 +62,7 @@ public:
// nsIContentSink // nsIContentSink
NS_IMETHOD WillBuildModel(nsDTDMode aDTDMode) override; NS_IMETHOD WillBuildModel(nsDTDMode aDTDMode) override;
NS_IMETHOD DidBuildModel(bool aTerminated) 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; virtual nsISupports* GetTarget() override;
NS_IMETHOD DidProcessATokenImpl(); NS_IMETHOD DidProcessATokenImpl();
@ -173,11 +173,11 @@ nsXMLFragmentContentSink::DidBuildModel(bool aTerminated)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP void
nsXMLFragmentContentSink::SetDocumentCharset(nsACString& aCharset) nsXMLFragmentContentSink::SetDocumentCharset(
NotNull<const Encoding*> aEncoding)
{ {
NS_NOTREACHED("fragments shouldn't set charset"); NS_NOTREACHED("fragments shouldn't set charset");
return NS_OK;
} }
nsISupports * nsISupports *

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

@ -84,7 +84,8 @@ public:
NS_IMETHOD WillResume(void) override { return NS_OK; } NS_IMETHOD WillResume(void) override { return NS_OK; }
NS_IMETHOD SetParser(nsParserBase* aParser) override { return NS_OK; } NS_IMETHOD SetParser(nsParserBase* aParser) override { return NS_OK; }
virtual void FlushPendingNotifications(mozilla::FlushType aType) override { } 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; } virtual nsISupports *GetTarget() override { return nullptr; }
private: private:
@ -269,9 +270,7 @@ txStylesheetSink::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext)
encoding = UTF_8_ENCODING; encoding = UTF_8_ENCODING;
} }
nsAutoCString charset; mParser->SetDocumentCharset(WrapNotNull(encoding), charsetSource);
encoding->Name(charset);
mParser->SetDocumentCharset(charset, charsetSource);
nsAutoCString contentType; nsAutoCString contentType;
channel->GetContentType(contentType); channel->GetContentType(contentType);

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

@ -163,9 +163,7 @@ txMozillaTextOutput::createResultDocument(nsIDOMDocument* aSourceDocument,
const Encoding* encoding = Encoding::ForLabel(mOutputFormat.mEncoding); const Encoding* encoding = Encoding::ForLabel(mOutputFormat.mEncoding);
if (encoding) { if (encoding) {
mDocument->SetDocumentCharacterSetSource(kCharsetFromOtherComponent); mDocument->SetDocumentCharacterSetSource(kCharsetFromOtherComponent);
nsAutoCString canonicalCharset; mDocument->SetDocumentCharacterSet(WrapNotNull(encoding));
encoding->Name(canonicalCharset);
mDocument->SetDocumentCharacterSet(canonicalCharset);
} }
} }

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

@ -823,9 +823,7 @@ txMozillaXMLOutput::createResultDocument(const nsAString& aName, int32_t aNsID,
const Encoding* encoding = Encoding::ForLabel(mOutputFormat.mEncoding); const Encoding* encoding = Encoding::ForLabel(mOutputFormat.mEncoding);
if (encoding) { if (encoding) {
mDocument->SetDocumentCharacterSetSource(kCharsetFromOtherComponent); mDocument->SetDocumentCharacterSetSource(kCharsetFromOtherComponent);
nsAutoCString canonicalCharset; mDocument->SetDocumentCharacterSet(WrapNotNull(encoding));
encoding->Name(canonicalCharset);
mDocument->SetDocumentCharacterSet(canonicalCharset);
} }
} }

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

@ -213,7 +213,7 @@ XULDocument::XULDocument(void)
mHandlingDelayedBroadcasters(false) mHandlingDelayedBroadcasters(false)
{ {
// Override the default in nsDocument // Override the default in nsDocument
mCharacterSet.AssignLiteral("UTF-8"); mCharacterSet = UTF_8_ENCODING;
mDefaultElementType = kNameSpaceID_XUL; mDefaultElementType = kNameSpaceID_XUL;
mType = eXUL; mType = eXUL;
@ -2025,7 +2025,7 @@ XULDocument::PrepareToLoadPrototype(nsIURI* aURI, const char* aCommand,
parser->SetCommand(nsCRT::strcmp(aCommand, "view-source") ? eViewNormal : parser->SetCommand(nsCRT::strcmp(aCommand, "view-source") ? eViewNormal :
eViewSource); eViewSource);
parser->SetDocumentCharset(NS_LITERAL_CSTRING("UTF-8"), parser->SetDocumentCharset(UTF_8_ENCODING,
kCharsetFromDocTypeDefault); kCharsetFromDocTypeDefault);
parser->SetContentSink(sink); // grabs a reference to the parser parser->SetContentSink(sink); // grabs a reference to the parser

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

@ -256,15 +256,13 @@ XULContentSinkImpl::SetParser(nsParserBase* aParser)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP void
XULContentSinkImpl::SetDocumentCharset(nsACString& aCharset) XULContentSinkImpl::SetDocumentCharset(NotNull<const Encoding*> aEncoding)
{ {
nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocument); nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocument);
if (doc) { if (doc) {
doc->SetDocumentCharacterSet(aCharset); doc->SetDocumentCharacterSet(aEncoding);
} }
return NS_OK;
} }
nsISupports * nsISupports *

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

@ -41,7 +41,7 @@ public:
NS_IMETHOD WillResume(void) override; NS_IMETHOD WillResume(void) override;
NS_IMETHOD SetParser(nsParserBase* aParser) override; NS_IMETHOD SetParser(nsParserBase* aParser) override;
virtual void FlushPendingNotifications(mozilla::FlushType aType) 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 nsISupports *GetTarget() override;
/** /**

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

@ -6,6 +6,7 @@
#include "mozilla/EditorBase.h" #include "mozilla/EditorBase.h"
#include "mozilla/DebugOnly.h" // for DebugOnly #include "mozilla/DebugOnly.h" // for DebugOnly
#include "mozilla/Encoding.h" // for Encoding
#include <stdio.h> // for nullptr, stdout #include <stdio.h> // for nullptr, stdout
#include <string.h> // for strcmp #include <string.h> // for strcmp
@ -1180,7 +1181,7 @@ EditorBase::GetDocumentCharacterSet(nsACString& characterSet)
if (NS_WARN_IF(!document)) { if (NS_WARN_IF(!document)) {
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
} }
characterSet = document->GetDocumentCharacterSet(); document->GetDocumentCharacterSet()->Name(characterSet);
return NS_OK; return NS_OK;
} }
@ -1191,7 +1192,13 @@ EditorBase::SetDocumentCharacterSet(const nsACString& characterSet)
if (NS_WARN_IF(!document)) { if (NS_WARN_IF(!document)) {
return NS_ERROR_UNEXPECTED; 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; return NS_OK;
} }

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

@ -134,7 +134,7 @@ GPUVideoTextureHost::AddWRImage(wr::WebRenderAPI* aAPI,
void void
GPUVideoTextureHost::PushExternalImage(wr::DisplayListBuilder& aBuilder, GPUVideoTextureHost::PushExternalImage(wr::DisplayListBuilder& aBuilder,
const WrRect& aBounds, const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
wr::ImageRendering aFilter, wr::ImageRendering aFilter,
Range<const wr::ImageKey>& aImageKeys) Range<const wr::ImageKey>& aImageKeys)
{ {

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

@ -57,7 +57,7 @@ public:
virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder, virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
const WrRect& aBounds, const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
wr::ImageRendering aFilter, wr::ImageRendering aFilter,
Range<const wr::ImageKey>& aImageKeys) override; Range<const wr::ImageKey>& aImageKeys) override;

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

@ -625,7 +625,7 @@ BufferTextureHost::AddWRImage(wr::WebRenderAPI* aAPI,
void void
BufferTextureHost::PushExternalImage(wr::DisplayListBuilder& aBuilder, BufferTextureHost::PushExternalImage(wr::DisplayListBuilder& aBuilder,
const WrRect& aBounds, const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
wr::ImageRendering aFilter, wr::ImageRendering aFilter,
Range<const wr::ImageKey>& aImageKeys) Range<const wr::ImageKey>& aImageKeys)
{ {

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

@ -644,7 +644,7 @@ public:
// Put all necessary WR commands into DisplayListBuilder for this textureHost rendering. // Put all necessary WR commands into DisplayListBuilder for this textureHost rendering.
virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder, virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
const WrRect& aBounds, const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
wr::ImageRendering aFilter, wr::ImageRendering aFilter,
Range<const wr::ImageKey>& aKeys) Range<const wr::ImageKey>& aKeys)
{ {
@ -750,7 +750,7 @@ public:
virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder, virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
const WrRect& aBounds, const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
wr::ImageRendering aFilter, wr::ImageRendering aFilter,
Range<const wr::ImageKey>& aImageKeys) override; Range<const wr::ImageKey>& aImageKeys) override;

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

@ -918,7 +918,7 @@ DXGITextureHostD3D11::AddWRImage(wr::WebRenderAPI* aAPI,
void void
DXGITextureHostD3D11::PushExternalImage(wr::DisplayListBuilder& aBuilder, DXGITextureHostD3D11::PushExternalImage(wr::DisplayListBuilder& aBuilder,
const WrRect& aBounds, const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
wr::ImageRendering aFilter, wr::ImageRendering aFilter,
Range<const wr::ImageKey>& aImageKeys) Range<const wr::ImageKey>& aImageKeys)
{ {
@ -1085,7 +1085,7 @@ DXGIYCbCrTextureHostD3D11::AddWRImage(wr::WebRenderAPI* aAPI,
void void
DXGIYCbCrTextureHostD3D11::PushExternalImage(wr::DisplayListBuilder& aBuilder, DXGIYCbCrTextureHostD3D11::PushExternalImage(wr::DisplayListBuilder& aBuilder,
const WrRect& aBounds, const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
wr::ImageRendering aFilter, wr::ImageRendering aFilter,
Range<const wr::ImageKey>& aImageKeys) Range<const wr::ImageKey>& aImageKeys)
{ {

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

@ -335,7 +335,7 @@ public:
virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder, virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
const WrRect& aBounds, const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
wr::ImageRendering aFilter, wr::ImageRendering aFilter,
Range<const wr::ImageKey>& aImageKeys) override; Range<const wr::ImageKey>& aImageKeys) override;
@ -396,7 +396,7 @@ public:
virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder, virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
const WrRect& aBounds, const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
wr::ImageRendering aFilter, wr::ImageRendering aFilter,
Range<const wr::ImageKey>& aImageKeys) override; Range<const wr::ImageKey>& aImageKeys) override;

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

@ -225,7 +225,7 @@ MacIOSurfaceTextureHostOGL::AddWRImage(wr::WebRenderAPI* aAPI,
void void
MacIOSurfaceTextureHostOGL::PushExternalImage(wr::DisplayListBuilder& aBuilder, MacIOSurfaceTextureHostOGL::PushExternalImage(wr::DisplayListBuilder& aBuilder,
const WrRect& aBounds, const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
wr::ImageRendering aFilter, wr::ImageRendering aFilter,
Range<const wr::ImageKey>& aImageKeys) Range<const wr::ImageKey>& aImageKeys)
{ {

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

@ -73,7 +73,7 @@ public:
virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder, virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
const WrRect& aBounds, const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
wr::ImageRendering aFilter, wr::ImageRendering aFilter,
Range<const wr::ImageKey>& aImageKeys) override; Range<const wr::ImageKey>& aImageKeys) override;

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

@ -217,9 +217,8 @@ WebRenderBridgeChild::PushGlyphs(wr::DisplayListBuilder& aBuilder, const nsTArra
LayerPoint::FromUnknownPoint(glyphs[j].mPosition)); LayerPoint::FromUnknownPoint(glyphs[j].mPosition));
} }
WrClipRegionToken clipRegion = aBuilder.PushClipRegion(aSc.ToRelativeWrRect(aClip));
aBuilder.PushText(aSc.ToRelativeWrRect(aBounds), aBuilder.PushText(aSc.ToRelativeWrRect(aBounds),
clipRegion, aSc.ToRelativeWrRect(aClip),
glyph_array.color().value(), glyph_array.color().value(),
key, key,
Range<const WrGlyphInstance>(wr_glyph_instances.Elements(), wr_glyph_instances.Length()), 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); LayerRect rect(0, 0, mBounds.width, mBounds.height);
DumpLayerInfo("CanvasLayer", rect); DumpLayerInfo("CanvasLayer", rect);
WrClipRegionToken clip = aBuilder.PushClipRegion(sc.ToRelativeWrRect(rect));
wr::ImageRendering filter = wr::ToImageRendering(mSamplingFilter); wr::ImageRendering filter = wr::ToImageRendering(mSamplingFilter);
if (gfxPrefs::LayersDump()) { if (gfxPrefs::LayersDump()) {
@ -83,7 +81,8 @@ WebRenderCanvasLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
WrBridge()->AddWebRenderParentCommand(OpAddExternalImage(mExternalImageId.value(), key)); WrBridge()->AddWebRenderParentCommand(OpAddExternalImage(mExternalImageId.value(), key));
WrManager()->AddImageKeyForDiscard(key); WrManager()->AddImageKeyForDiscard(key);
aBuilder.PushImage(sc.ToRelativeWrRect(rect), clip, filter, key); WrRect r = sc.ToRelativeWrRect(rect);
aBuilder.PushImage(r, r, filter, key);
} }
void void

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

@ -28,9 +28,8 @@ WebRenderColorLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
LayerRect rect = Bounds(); LayerRect rect = Bounds();
DumpLayerInfo("ColorLayer", rect); DumpLayerInfo("ColorLayer", rect);
WrClipRegionToken clip = aBuilder.PushClipRegion(sc.ToRelativeWrRect(rect)); WrRect r = sc.ToRelativeWrRect(rect);
aBuilder.PushRect(r, r, wr::ToWrColor(mColor));
aBuilder.PushRect(sc.ToRelativeWrRect(rect), clip, wr::ToWrColor(mColor));
} }
} // namespace layers } // namespace layers

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

@ -279,22 +279,20 @@ WebRenderCompositableHolder::ApplyAsyncImages(wr::WebRenderAPI* aApi)
if (holder->mScaleToSize.isSome()) { if (holder->mScaleToSize.isSome()) {
rect = LayerRect(0, 0, holder->mScaleToSize.value().width, holder->mScaleToSize.value().height); rect = LayerRect(0, 0, holder->mScaleToSize.value().width, holder->mScaleToSize.value().height);
} }
WrClipRegionToken clip = builder.PushClipRegion(
wr::ToWrRect(rect), nullptr);
if (useExternalImage) { if (useExternalImage) {
MOZ_ASSERT(holder->mCurrentTexture->AsWebRenderTextureHost()); MOZ_ASSERT(holder->mCurrentTexture->AsWebRenderTextureHost());
Range<const wr::ImageKey> range_keys(&keys[0], keys.Length()); Range<const wr::ImageKey> range_keys(&keys[0], keys.Length());
holder->mCurrentTexture->PushExternalImage(builder, holder->mCurrentTexture->PushExternalImage(builder,
wr::ToWrRect(rect), wr::ToWrRect(rect),
clip, wr::ToWrRect(rect),
holder->mFilter, holder->mFilter,
range_keys); range_keys);
HoldExternalImage(pipelineId, epoch, holder->mCurrentTexture->AsWebRenderTextureHost()); HoldExternalImage(pipelineId, epoch, holder->mCurrentTexture->AsWebRenderTextureHost());
} else { } else {
MOZ_ASSERT(keys.Length() == 1); MOZ_ASSERT(keys.Length() == 1);
builder.PushImage(wr::ToWrRect(rect), builder.PushImage(wr::ToWrRect(rect),
clip, wr::ToWrRect(rect),
holder->mFilter, holder->mFilter,
keys[0]); keys[0]);
} }

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

@ -150,8 +150,8 @@ WebRenderRefLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
PixelCastJustification::MovingDownToChildren); PixelCastJustification::MovingDownToChildren);
DumpLayerInfo("RefLayer", rect); DumpLayerInfo("RefLayer", rect);
WrClipRegionToken clipRegion = aBuilder.PushClipRegion(aSc.ToRelativeWrRect(rect)); WrRect r = aSc.ToRelativeWrRect(rect);
aBuilder.PushIFrame(aSc.ToRelativeWrRect(rect), clipRegion, wr::AsPipelineId(mId)); aBuilder.PushIFrame(r, r, wr::AsPipelineId(mId));
} }
} // namespace layers } // namespace layers

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

@ -139,13 +139,12 @@ WebRenderDisplayItemLayer::PushItemAsBlobImage(wr::DisplayListBuilder& aBuilder,
wr::ByteBuffer bytes(recorder->mOutputStream.mLength, (uint8_t*)recorder->mOutputStream.mData); wr::ByteBuffer bytes(recorder->mOutputStream.mLength, (uint8_t*)recorder->mOutputStream.mData);
WrRect dest = aSc.ToRelativeWrRect(imageRect + offset); WrRect dest = aSc.ToRelativeWrRect(imageRect + offset);
WrClipRegionToken clipRegion = aBuilder.PushClipRegion(dest);
WrImageKey key = GetImageKey(); WrImageKey key = GetImageKey();
WrBridge()->SendAddBlobImage(key, imageSize.ToUnknownSize(), imageSize.width * 4, dt->GetFormat(), bytes); WrBridge()->SendAddBlobImage(key, imageSize.ToUnknownSize(), imageSize.width * 4, dt->GetFormat(), bytes);
WrManager()->AddImageKeyForDiscard(key); WrManager()->AddImageKeyForDiscard(key);
aBuilder.PushImage(dest, aBuilder.PushImage(dest,
clipRegion, dest,
wr::ImageRendering::Auto, wr::ImageRendering::Auto,
key); key);
return true; return true;

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

@ -159,8 +159,8 @@ WebRenderImageLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
PixelCastJustification::MovingDownToChildren); PixelCastJustification::MovingDownToChildren);
DumpLayerInfo("Image Layer async", rect); DumpLayerInfo("Image Layer async", rect);
WrClipRegionToken clipRegion = aBuilder.PushClipRegion(aSc.ToRelativeWrRect(rect)); WrRect r = aSc.ToRelativeWrRect(rect);
aBuilder.PushIFrame(aSc.ToRelativeWrRect(rect), clipRegion, mPipelineId.ref()); aBuilder.PushIFrame(r, r, mPipelineId.ref());
gfx::Matrix4x4 scTransform = GetTransform(); gfx::Matrix4x4 scTransform = GetTransform();
// Translate is applied as part of PushIFrame() // Translate is applied as part of PushIFrame()
@ -215,8 +215,6 @@ WebRenderImageLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
rect = LayerRect(0, 0, mScaleToSize.width, mScaleToSize.height); rect = LayerRect(0, 0, mScaleToSize.width, mScaleToSize.height);
} }
WrClipRegionToken clip = aBuilder.PushClipRegion(
sc.ToRelativeWrRect(rect));
wr::ImageRendering filter = wr::ToImageRendering(mSamplingFilter); wr::ImageRendering filter = wr::ToImageRendering(mSamplingFilter);
DumpLayerInfo("Image Layer", rect); DumpLayerInfo("Image Layer", rect);
@ -225,7 +223,8 @@ WebRenderImageLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
GetLayer(), GetLayer(),
Stringify(filter).c_str()); 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> Maybe<WrImageMask>

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

@ -100,13 +100,12 @@ WebRenderPaintedLayer::CreateWebRenderDisplayList(wr::DisplayListBuilder& aBuild
LayerRect rect = Bounds(); LayerRect rect = Bounds();
DumpLayerInfo("PaintedLayer", rect); DumpLayerInfo("PaintedLayer", rect);
WrClipRegionToken clip = aBuilder.PushClipRegion(sc.ToRelativeWrRect(rect));
WrImageKey key = GetImageKey(); WrImageKey key = GetImageKey();
WrBridge()->AddWebRenderParentCommand(OpAddExternalImage(mExternalImageId.value(), key)); WrBridge()->AddWebRenderParentCommand(OpAddExternalImage(mExternalImageId.value(), key));
WrManager()->AddImageKeyForDiscard(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 void

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

@ -89,9 +89,8 @@ WebRenderPaintedLayerBlob::RenderLayer(wr::DisplayListBuilder& aBuilder,
LayerRect rect = Bounds(); LayerRect rect = Bounds();
DumpLayerInfo("PaintedLayer", rect); DumpLayerInfo("PaintedLayer", rect);
WrClipRegionToken clip = aBuilder.PushClipRegion(sc.ToRelativeWrRect(rect)); WrRect r = sc.ToRelativeWrRect(rect);
aBuilder.PushImage(r, r, wr::ImageRendering::Auto, mImageKey.value());
aBuilder.PushImage(sc.ToRelativeWrRect(rect), clip, wr::ImageRendering::Auto, mImageKey.value());
} }
} // namespace layers } // namespace layers

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

@ -179,7 +179,7 @@ WebRenderTextureHost::AddWRImage(wr::WebRenderAPI* aAPI,
void void
WebRenderTextureHost::PushExternalImage(wr::DisplayListBuilder& aBuilder, WebRenderTextureHost::PushExternalImage(wr::DisplayListBuilder& aBuilder,
const WrRect& aBounds, const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
wr::ImageRendering aFilter, wr::ImageRendering aFilter,
Range<const wr::ImageKey>& aImageKeys) Range<const wr::ImageKey>& aImageKeys)
{ {

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

@ -74,7 +74,7 @@ public:
virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder, virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
const WrRect& aBounds, const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
wr::ImageRendering aFilter, wr::ImageRendering aFilter,
Range<const wr::ImageKey>& aImageKeys) override; Range<const wr::ImageKey>& aImageKeys) override;

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

@ -652,18 +652,20 @@ DisplayListBuilder::PopClipAndScrollInfo()
void void
DisplayListBuilder::PushRect(const WrRect& aBounds, DisplayListBuilder::PushRect(const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
const WrColor& aColor) 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(aBounds).c_str(),
Stringify(aClip).c_str(),
Stringify(aColor).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 void
DisplayListBuilder::PushLinearGradient(const WrRect& aBounds, DisplayListBuilder::PushLinearGradient(const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
const WrPoint& aStartPoint, const WrPoint& aStartPoint,
const WrPoint& aEndPoint, const WrPoint& aEndPoint,
const nsTArray<WrGradientStop>& aStops, const nsTArray<WrGradientStop>& aStops,
@ -671,8 +673,9 @@ DisplayListBuilder::PushLinearGradient(const WrRect& aBounds,
const WrSize aTileSize, const WrSize aTileSize,
const WrSize aTileSpacing) const WrSize aTileSpacing)
{ {
WrClipRegionToken tok = wr_dp_push_clip_region(mWrState, aClip, nullptr, 0, nullptr);
wr_dp_push_linear_gradient(mWrState, wr_dp_push_linear_gradient(mWrState,
aBounds, aClip, aBounds, tok,
aStartPoint, aEndPoint, aStartPoint, aEndPoint,
aStops.Elements(), aStops.Length(), aStops.Elements(), aStops.Length(),
aExtendMode, aExtendMode,
@ -681,7 +684,7 @@ DisplayListBuilder::PushLinearGradient(const WrRect& aBounds,
void void
DisplayListBuilder::PushRadialGradient(const WrRect& aBounds, DisplayListBuilder::PushRadialGradient(const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
const WrPoint& aCenter, const WrPoint& aCenter,
const WrSize& aRadius, const WrSize& aRadius,
const nsTArray<WrGradientStop>& aStops, const nsTArray<WrGradientStop>& aStops,
@ -689,8 +692,9 @@ DisplayListBuilder::PushRadialGradient(const WrRect& aBounds,
const WrSize aTileSize, const WrSize aTileSize,
const WrSize aTileSpacing) const WrSize aTileSpacing)
{ {
WrClipRegionToken tok = wr_dp_push_clip_region(mWrState, aClip, nullptr, 0, nullptr);
wr_dp_push_radial_gradient(mWrState, wr_dp_push_radial_gradient(mWrState,
aBounds, aClip, aBounds, tok,
aCenter, aRadius, aCenter, aRadius,
aStops.Elements(), aStops.Length(), aStops.Elements(), aStops.Length(),
aExtendMode, aExtendMode,
@ -699,7 +703,7 @@ DisplayListBuilder::PushRadialGradient(const WrRect& aBounds,
void void
DisplayListBuilder::PushImage(const WrRect& aBounds, DisplayListBuilder::PushImage(const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
wr::ImageRendering aFilter, wr::ImageRendering aFilter,
wr::ImageKey aImage) wr::ImageKey aImage)
{ {
@ -711,29 +715,32 @@ DisplayListBuilder::PushImage(const WrRect& aBounds,
void void
DisplayListBuilder::PushImage(const WrRect& aBounds, DisplayListBuilder::PushImage(const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
const WrSize& aStretchSize, const WrSize& aStretchSize,
const WrSize& aTileSpacing, const WrSize& aTileSpacing,
wr::ImageRendering aFilter, wr::ImageRendering aFilter,
wr::ImageKey aImage) wr::ImageKey aImage)
{ {
WRDL_LOG("PushImage b=%s s=%s t=%s\n", Stringify(aBounds).c_str(), WrClipRegionToken tok = wr_dp_push_clip_region(mWrState, aClip, nullptr, 0, nullptr);
Stringify(aStretchSize).c_str(), Stringify(aTileSpacing).c_str()); WRDL_LOG("PushImage b=%s cl=%s s=%s t=%s\n", Stringify(aBounds).c_str(),
wr_dp_push_image(mWrState, aBounds, aClip, aStretchSize, aTileSpacing, aFilter, aImage); Stringify(aClip).c_str(), Stringify(aStretchSize).c_str(),
Stringify(aTileSpacing).c_str());
wr_dp_push_image(mWrState, aBounds, tok, aStretchSize, aTileSpacing, aFilter, aImage);
} }
void void
DisplayListBuilder::PushYCbCrPlanarImage(const WrRect& aBounds, DisplayListBuilder::PushYCbCrPlanarImage(const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
wr::ImageKey aImageChannel0, wr::ImageKey aImageChannel0,
wr::ImageKey aImageChannel1, wr::ImageKey aImageChannel1,
wr::ImageKey aImageChannel2, wr::ImageKey aImageChannel2,
WrYuvColorSpace aColorSpace, WrYuvColorSpace aColorSpace,
wr::ImageRendering aRendering) wr::ImageRendering aRendering)
{ {
WrClipRegionToken tok = wr_dp_push_clip_region(mWrState, aClip, nullptr, 0, nullptr);
wr_dp_push_yuv_planar_image(mWrState, wr_dp_push_yuv_planar_image(mWrState,
aBounds, aBounds,
aClip, tok,
aImageChannel0, aImageChannel0,
aImageChannel1, aImageChannel1,
aImageChannel2, aImageChannel2,
@ -743,15 +750,16 @@ DisplayListBuilder::PushYCbCrPlanarImage(const WrRect& aBounds,
void void
DisplayListBuilder::PushNV12Image(const WrRect& aBounds, DisplayListBuilder::PushNV12Image(const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
wr::ImageKey aImageChannel0, wr::ImageKey aImageChannel0,
wr::ImageKey aImageChannel1, wr::ImageKey aImageChannel1,
WrYuvColorSpace aColorSpace, WrYuvColorSpace aColorSpace,
wr::ImageRendering aRendering) wr::ImageRendering aRendering)
{ {
WrClipRegionToken tok = wr_dp_push_clip_region(mWrState, aClip, nullptr, 0, nullptr);
wr_dp_push_yuv_NV12_image(mWrState, wr_dp_push_yuv_NV12_image(mWrState,
aBounds, aBounds,
aClip, tok,
aImageChannel0, aImageChannel0,
aImageChannel1, aImageChannel1,
aColorSpace, aColorSpace,
@ -760,14 +768,15 @@ DisplayListBuilder::PushNV12Image(const WrRect& aBounds,
void void
DisplayListBuilder::PushYCbCrInterleavedImage(const WrRect& aBounds, DisplayListBuilder::PushYCbCrInterleavedImage(const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
wr::ImageKey aImageChannel0, wr::ImageKey aImageChannel0,
WrYuvColorSpace aColorSpace, WrYuvColorSpace aColorSpace,
wr::ImageRendering aRendering) wr::ImageRendering aRendering)
{ {
WrClipRegionToken tok = wr_dp_push_clip_region(mWrState, aClip, nullptr, 0, nullptr);
wr_dp_push_yuv_interleaved_image(mWrState, wr_dp_push_yuv_interleaved_image(mWrState,
aBounds, aBounds,
aClip, tok,
aImageChannel0, aImageChannel0,
aColorSpace, aColorSpace,
aRendering); aRendering);
@ -775,15 +784,16 @@ DisplayListBuilder::PushYCbCrInterleavedImage(const WrRect& aBounds,
void void
DisplayListBuilder::PushIFrame(const WrRect& aBounds, DisplayListBuilder::PushIFrame(const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
PipelineId aPipeline) 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 void
DisplayListBuilder::PushBorder(const WrRect& aBounds, DisplayListBuilder::PushBorder(const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
const WrBorderWidths& aWidths, const WrBorderWidths& aWidths,
const WrBorderSide& aTop, const WrBorderSide& aTop,
const WrBorderSide& aRight, const WrBorderSide& aRight,
@ -791,13 +801,14 @@ DisplayListBuilder::PushBorder(const WrRect& aBounds,
const WrBorderSide& aLeft, const WrBorderSide& aLeft,
const WrBorderRadius& aRadius) 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); aWidths, aTop, aRight, aBottom, aLeft, aRadius);
} }
void void
DisplayListBuilder::PushBorderImage(const WrRect& aBounds, DisplayListBuilder::PushBorderImage(const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
const WrBorderWidths& aWidths, const WrBorderWidths& aWidths,
wr::ImageKey aImage, wr::ImageKey aImage,
const WrNinePatchDescriptor& aPatch, const WrNinePatchDescriptor& aPatch,
@ -805,14 +816,15 @@ DisplayListBuilder::PushBorderImage(const WrRect& aBounds,
const WrRepeatMode& aRepeatHorizontal, const WrRepeatMode& aRepeatHorizontal,
const WrRepeatMode& aRepeatVertical) 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, aWidths, aImage, aPatch, aOutset,
aRepeatHorizontal, aRepeatVertical); aRepeatHorizontal, aRepeatVertical);
} }
void void
DisplayListBuilder::PushBorderGradient(const WrRect& aBounds, DisplayListBuilder::PushBorderGradient(const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
const WrBorderWidths& aWidths, const WrBorderWidths& aWidths,
const WrPoint& aStartPoint, const WrPoint& aStartPoint,
const WrPoint& aEndPoint, const WrPoint& aEndPoint,
@ -820,7 +832,8 @@ DisplayListBuilder::PushBorderGradient(const WrRect& aBounds,
wr::GradientExtendMode aExtendMode, wr::GradientExtendMode aExtendMode,
const WrSideOffsets2Df32& aOutset) 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, aWidths, aStartPoint, aEndPoint,
aStops.Elements(), aStops.Length(), aStops.Elements(), aStops.Length(),
aExtendMode, aOutset); aExtendMode, aOutset);
@ -828,7 +841,7 @@ DisplayListBuilder::PushBorderGradient(const WrRect& aBounds,
void void
DisplayListBuilder::PushBorderRadialGradient(const WrRect& aBounds, DisplayListBuilder::PushBorderRadialGradient(const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
const WrBorderWidths& aWidths, const WrBorderWidths& aWidths,
const WrPoint& aCenter, const WrPoint& aCenter,
const WrSize& aRadius, const WrSize& aRadius,
@ -836,21 +849,23 @@ DisplayListBuilder::PushBorderRadialGradient(const WrRect& aBounds,
wr::GradientExtendMode aExtendMode, wr::GradientExtendMode aExtendMode,
const WrSideOffsets2Df32& aOutset) const WrSideOffsets2Df32& aOutset)
{ {
WrClipRegionToken tok = wr_dp_push_clip_region(mWrState, aClip, nullptr, 0, nullptr);
wr_dp_push_border_radial_gradient( wr_dp_push_border_radial_gradient(
mWrState, aBounds, aClip, aWidths, aCenter, mWrState, aBounds, tok, aWidths, aCenter,
aRadius, aStops.Elements(), aStops.Length(), aRadius, aStops.Elements(), aStops.Length(),
aExtendMode, aOutset); aExtendMode, aOutset);
} }
void void
DisplayListBuilder::PushText(const WrRect& aBounds, DisplayListBuilder::PushText(const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
const gfx::Color& aColor, const gfx::Color& aColor,
wr::FontKey aFontKey, wr::FontKey aFontKey,
Range<const WrGlyphInstance> aGlyphBuffer, Range<const WrGlyphInstance> aGlyphBuffer,
float aGlyphSize) 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), ToWrColor(aColor),
aFontKey, aFontKey,
&aGlyphBuffer[0], aGlyphBuffer.length(), &aGlyphBuffer[0], aGlyphBuffer.length(),
@ -859,7 +874,7 @@ DisplayListBuilder::PushText(const WrRect& aBounds,
void void
DisplayListBuilder::PushBoxShadow(const WrRect& aRect, DisplayListBuilder::PushBoxShadow(const WrRect& aRect,
const WrClipRegionToken aClip, const WrRect& aClip,
const WrRect& aBoxBounds, const WrRect& aBoxBounds,
const WrPoint& aOffset, const WrPoint& aOffset,
const WrColor& aColor, const WrColor& aColor,
@ -868,38 +883,13 @@ DisplayListBuilder::PushBoxShadow(const WrRect& aRect,
const float& aBorderRadius, const float& aBorderRadius,
const WrBoxShadowClipMode& aClipMode) 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, aBoxBounds, aOffset, aColor,
aBlurRadius, aSpreadRadius, aBorderRadius, aBlurRadius, aSpreadRadius, aBorderRadius,
aClipMode); 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> Maybe<WrClipId>
DisplayListBuilder::TopmostClipId() DisplayListBuilder::TopmostClipId()
{ {

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

@ -174,11 +174,11 @@ public:
void PopClipAndScrollInfo(); void PopClipAndScrollInfo();
void PushRect(const WrRect& aBounds, void PushRect(const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
const WrColor& aColor); const WrColor& aColor);
void PushLinearGradient(const WrRect& aBounds, void PushLinearGradient(const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
const WrPoint& aStartPoint, const WrPoint& aStartPoint,
const WrPoint& aEndPoint, const WrPoint& aEndPoint,
const nsTArray<WrGradientStop>& aStops, const nsTArray<WrGradientStop>& aStops,
@ -187,7 +187,7 @@ public:
const WrSize aTileSpacing); const WrSize aTileSpacing);
void PushRadialGradient(const WrRect& aBounds, void PushRadialGradient(const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
const WrPoint& aCenter, const WrPoint& aCenter,
const WrSize& aRadius, const WrSize& aRadius,
const nsTArray<WrGradientStop>& aStops, const nsTArray<WrGradientStop>& aStops,
@ -196,19 +196,19 @@ public:
const WrSize aTileSpacing); const WrSize aTileSpacing);
void PushImage(const WrRect& aBounds, void PushImage(const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
wr::ImageRendering aFilter, wr::ImageRendering aFilter,
wr::ImageKey aImage); wr::ImageKey aImage);
void PushImage(const WrRect& aBounds, void PushImage(const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
const WrSize& aStretchSize, const WrSize& aStretchSize,
const WrSize& aTileSpacing, const WrSize& aTileSpacing,
wr::ImageRendering aFilter, wr::ImageRendering aFilter,
wr::ImageKey aImage); wr::ImageKey aImage);
void PushYCbCrPlanarImage(const WrRect& aBounds, void PushYCbCrPlanarImage(const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
wr::ImageKey aImageChannel0, wr::ImageKey aImageChannel0,
wr::ImageKey aImageChannel1, wr::ImageKey aImageChannel1,
wr::ImageKey aImageChannel2, wr::ImageKey aImageChannel2,
@ -216,24 +216,24 @@ public:
wr::ImageRendering aFilter); wr::ImageRendering aFilter);
void PushNV12Image(const WrRect& aBounds, void PushNV12Image(const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
wr::ImageKey aImageChannel0, wr::ImageKey aImageChannel0,
wr::ImageKey aImageChannel1, wr::ImageKey aImageChannel1,
WrYuvColorSpace aColorSpace, WrYuvColorSpace aColorSpace,
wr::ImageRendering aFilter); wr::ImageRendering aFilter);
void PushYCbCrInterleavedImage(const WrRect& aBounds, void PushYCbCrInterleavedImage(const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
wr::ImageKey aImageChannel0, wr::ImageKey aImageChannel0,
WrYuvColorSpace aColorSpace, WrYuvColorSpace aColorSpace,
wr::ImageRendering aFilter); wr::ImageRendering aFilter);
void PushIFrame(const WrRect& aBounds, void PushIFrame(const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
wr::PipelineId aPipeline); wr::PipelineId aPipeline);
void PushBorder(const WrRect& aBounds, void PushBorder(const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
const WrBorderWidths& aWidths, const WrBorderWidths& aWidths,
const WrBorderSide& aTop, const WrBorderSide& aTop,
const WrBorderSide& aRight, const WrBorderSide& aRight,
@ -242,7 +242,7 @@ public:
const WrBorderRadius& aRadius); const WrBorderRadius& aRadius);
void PushBorderImage(const WrRect& aBounds, void PushBorderImage(const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
const WrBorderWidths& aWidths, const WrBorderWidths& aWidths,
wr::ImageKey aImage, wr::ImageKey aImage,
const WrNinePatchDescriptor& aPatch, const WrNinePatchDescriptor& aPatch,
@ -251,7 +251,7 @@ public:
const WrRepeatMode& aRepeatVertical); const WrRepeatMode& aRepeatVertical);
void PushBorderGradient(const WrRect& aBounds, void PushBorderGradient(const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
const WrBorderWidths& aWidths, const WrBorderWidths& aWidths,
const WrPoint& aStartPoint, const WrPoint& aStartPoint,
const WrPoint& aEndPoint, const WrPoint& aEndPoint,
@ -260,7 +260,7 @@ public:
const WrSideOffsets2Df32& aOutset); const WrSideOffsets2Df32& aOutset);
void PushBorderRadialGradient(const WrRect& aBounds, void PushBorderRadialGradient(const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
const WrBorderWidths& aWidths, const WrBorderWidths& aWidths,
const WrPoint& aCenter, const WrPoint& aCenter,
const WrSize& aRadius, const WrSize& aRadius,
@ -269,14 +269,14 @@ public:
const WrSideOffsets2Df32& aOutset); const WrSideOffsets2Df32& aOutset);
void PushText(const WrRect& aBounds, void PushText(const WrRect& aBounds,
const WrClipRegionToken aClip, const WrRect& aClip,
const gfx::Color& aColor, const gfx::Color& aColor,
wr::FontKey aFontKey, wr::FontKey aFontKey,
Range<const WrGlyphInstance> aGlyphBuffer, Range<const WrGlyphInstance> aGlyphBuffer,
float aGlyphSize); float aGlyphSize);
void PushBoxShadow(const WrRect& aRect, void PushBoxShadow(const WrRect& aRect,
const WrClipRegionToken aClip, const WrRect& aClip,
const WrRect& aBoxBounds, const WrRect& aBoxBounds,
const WrPoint& aOffset, const WrPoint& aOffset,
const WrColor& aColor, const WrColor& aColor,
@ -285,12 +285,6 @@ public:
const float& aBorderRadius, const float& aBorderRadius,
const WrBoxShadowClipMode& aClipMode); 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 // 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 // has not yet been popped with PopClip. Return Nothing() if the clip stack
// is empty. // is empty.

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

@ -9,6 +9,7 @@
#include "nsIAtom.h" #include "nsIAtom.h"
#include "mozilla/ArrayUtils.h" #include "mozilla/ArrayUtils.h"
#include "mozilla/ClearOnShutdown.h" #include "mozilla/ClearOnShutdown.h"
#include "mozilla/Encoding.h"
#include "mozilla/intl/OSPreferences.h" #include "mozilla/intl/OSPreferences.h"
#include "mozilla/ServoBindings.h" #include "mozilla/ServoBindings.h"
@ -46,11 +47,13 @@ nsLanguageAtomService::LookupLanguage(const nsACString &aLanguage)
} }
already_AddRefed<nsIAtom> already_AddRefed<nsIAtom>
nsLanguageAtomService::LookupCharSet(const nsACString& aCharSet) nsLanguageAtomService::LookupCharSet(NotNull<const Encoding*> aEncoding)
{ {
nsAutoCString charset;
aEncoding->Name(charset);
nsAutoCString group; nsAutoCString group;
if (NS_FAILED(nsUConvPropertySearch::SearchPropertyValue( if (NS_FAILED(nsUConvPropertySearch::SearchPropertyValue(
encodingsGroups, ArrayLength(encodingsGroups), aCharSet, group))) { encodingsGroups, ArrayLength(encodingsGroups), charset, group))) {
return RefPtr<nsIAtom>(nsGkAtoms::Unicode).forget(); return RefPtr<nsIAtom>(nsGkAtoms::Unicode).forget();
} }
return NS_Atomize(group); return NS_Atomize(group);

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

@ -11,17 +11,24 @@
#ifndef nsLanguageAtomService_h_ #ifndef nsLanguageAtomService_h_
#define nsLanguageAtomService_h_ #define nsLanguageAtomService_h_
#include "mozilla/NotNull.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsIAtom.h" #include "nsIAtom.h"
#include "nsInterfaceHashtable.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: public:
static nsLanguageAtomService* GetService(); static nsLanguageAtomService* GetService();
nsIAtom* LookupLanguage(const nsACString &aLanguage); nsIAtom* LookupLanguage(const nsACString &aLanguage);
already_AddRefed<nsIAtom> LookupCharSet(const nsACString& aCharSet); already_AddRefed<nsIAtom> LookupCharSet(NotNull<const Encoding*> aCharSet);
nsIAtom* GetLocaleLanguage(); nsIAtom* GetLocaleLanguage();
// Returns the language group that the specified language is a part of. // Returns the language group that the specified language is a part of.

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

@ -7,6 +7,7 @@
#include "mozilla/ArrayUtils.h" #include "mozilla/ArrayUtils.h"
#include "mozilla/DebugOnly.h" #include "mozilla/DebugOnly.h"
#include "mozilla/Encoding.h"
#include "mozilla/EventDispatcher.h" #include "mozilla/EventDispatcher.h"
#include "mozilla/EventStateManager.h" #include "mozilla/EventStateManager.h"
@ -120,7 +121,7 @@ class CharSetChangingRunnable : public Runnable
{ {
public: public:
CharSetChangingRunnable(nsPresContext* aPresContext, CharSetChangingRunnable(nsPresContext* aPresContext,
const nsCString& aCharSet) NotNull<const Encoding*> aCharSet)
: Runnable("CharSetChangingRunnable"), : Runnable("CharSetChangingRunnable"),
mPresContext(aPresContext), mPresContext(aPresContext),
mCharSet(aCharSet) mCharSet(aCharSet)
@ -135,7 +136,7 @@ public:
private: private:
RefPtr<nsPresContext> mPresContext; RefPtr<nsPresContext> mPresContext;
nsCString mCharSet; NotNull<const Encoding*> mCharSet;
}; };
} // namespace } // namespace
@ -196,15 +197,9 @@ nsPresContext::PrefChangedUpdateTimerCallback(nsITimer *aTimer, void *aClosure)
} }
static bool static bool
IsVisualCharset(const nsCString& aCharset) IsVisualCharset(NotNull<const Encoding*> aCharset)
{ {
if (aCharset.LowerCaseEqualsLiteral("ibm862") // Hebrew return aCharset == ISO_8859_8_ENCODING;
|| aCharset.LowerCaseEqualsLiteral("iso-8859-8") ) { // Hebrew
return true; // visual text type
}
else {
return false; // logical text type
}
} }
nsPresContext::nsPresContext(nsIDocument* aDocument, nsPresContextType aType) nsPresContext::nsPresContext(nsIDocument* aDocument, nsPresContextType aType)
@ -1070,7 +1065,7 @@ nsPresContext::DetachShell()
} }
void void
nsPresContext::DoChangeCharSet(const nsCString& aCharSet) nsPresContext::DoChangeCharSet(NotNull<const Encoding*> aCharSet)
{ {
UpdateCharSet(aCharSet); UpdateCharSet(aCharSet);
mDeviceContext->FlushFontCache(); mDeviceContext->FlushFontCache();
@ -1078,7 +1073,7 @@ nsPresContext::DoChangeCharSet(const nsCString& aCharSet)
} }
void void
nsPresContext::UpdateCharSet(const nsCString& aCharSet) nsPresContext::UpdateCharSet(NotNull<const Encoding*> aCharSet)
{ {
mLanguage = mLangService->LookupCharSet(aCharSet); mLanguage = mLangService->LookupCharSet(aCharSet);
// this will be a language group (or script) code rather than a true language code // 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) const char16_t* aData)
{ {
if (!nsCRT::strcmp(aTopic, "charset")) { if (!nsCRT::strcmp(aTopic, "charset")) {
auto encoding = Encoding::ForName(NS_LossyConvertUTF16toASCII(aData));
RefPtr<CharSetChangingRunnable> runnable = RefPtr<CharSetChangingRunnable> runnable =
new CharSetChangingRunnable(this, NS_LossyConvertUTF16toASCII(aData)); new CharSetChangingRunnable(this, encoding);
return Document()->Dispatch("CharSetChangingRunnable", return Document()->Dispatch("CharSetChangingRunnable",
TaskCategory::Other, TaskCategory::Other,
runnable.forget()); runnable.forget());

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

@ -9,6 +9,7 @@
#define nsPresContext_h___ #define nsPresContext_h___
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/NotNull.h"
#include "mozilla/UniquePtr.h" #include "mozilla/UniquePtr.h"
#include "mozilla/WeakPtr.h" #include "mozilla/WeakPtr.h"
#include "nsColor.h" #include "nsColor.h"
@ -71,6 +72,7 @@ class gfxMissingFontRecorder;
namespace mozilla { namespace mozilla {
class EffectCompositor; class EffectCompositor;
class Encoding;
class EventStateManager; class EventStateManager;
class CounterStyleManager; class CounterStyleManager;
class RestyleManager; class RestyleManager;
@ -125,6 +127,8 @@ class nsRootPresContext;
class nsPresContext : public nsIObserver, class nsPresContext : public nsIObserver,
public mozilla::SupportsWeakPtr<nsPresContext> { public mozilla::SupportsWeakPtr<nsPresContext> {
public: public:
using Encoding = mozilla::Encoding;
template <typename T> using NotNull = mozilla::NotNull<T>;
typedef mozilla::LangGroupFontPrefs LangGroupFontPrefs; typedef mozilla::LangGroupFontPrefs LangGroupFontPrefs;
typedef mozilla::ScrollbarStyles ScrollbarStyles; typedef mozilla::ScrollbarStyles ScrollbarStyles;
typedef mozilla::StaticPresData StaticPresData; typedef mozilla::StaticPresData StaticPresData;
@ -1228,12 +1232,12 @@ protected:
return StaticPresData::Get()->GetFontPrefsForLangHelper(lang, &mLangGroupFontPrefs, aNeedsToCache); 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); static bool NotifyDidPaintSubdocumentCallback(nsIDocument* aDocument, void* aData);
public: public:
void DoChangeCharSet(const nsCString& aCharSet); void DoChangeCharSet(NotNull<const Encoding*> aCharSet);
/** /**
* Checks for MozAfterPaint listeners on the document * Checks for MozAfterPaint listeners on the document

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

@ -3,8 +3,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public /* 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 * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsCOMPtr.h"
#include "nsContentDLF.h" #include "nsContentDLF.h"
#include "mozilla/Encoding.h"
#include "nsCOMPtr.h"
#include "nsDocShell.h" #include "nsDocShell.h"
#include "nsGenericHTMLElement.h" #include "nsGenericHTMLElement.h"
#include "nsGkAtoms.h" #include "nsGkAtoms.h"
@ -327,7 +330,7 @@ nsContentDLF::CreateBlankDocument(nsILoadGroup *aLoadGroup,
// add a nice bow // add a nice bow
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
blankDoc->SetDocumentCharacterSetSource(kCharsetFromDocTypeDefault); blankDoc->SetDocumentCharacterSetSource(kCharsetFromDocTypeDefault);
blankDoc->SetDocumentCharacterSet(NS_LITERAL_CSTRING("UTF-8")); blankDoc->SetDocumentCharacterSet(UTF_8_ENCODING);
blankDoc.forget(aDocument); blankDoc.forget(aDocument);
} }

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

@ -466,10 +466,8 @@ BulletRenderer::CreateWebRenderCommandsForImage(nsDisplayItem* aItem,
LayoutDeviceRect destRect = LayoutDeviceRect::FromAppUnits(mDest, appUnitsPerDevPixel); LayoutDeviceRect destRect = LayoutDeviceRect::FromAppUnits(mDest, appUnitsPerDevPixel);
WrRect dest = aSc.ToRelativeWrRectRounded(destRect); WrRect dest = aSc.ToRelativeWrRectRounded(destRect);
WrClipRegionToken clipRegion = aBuilder.PushClipRegion(dest);
aBuilder.PushImage(dest, aBuilder.PushImage(dest,
clipRegion, dest,
WrImageRendering::Auto, WrImageRendering::Auto,
key.value()); key.value());
} }

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

@ -321,7 +321,7 @@ nsDisplayCanvasBackgroundColor::CreateWebRenderCommands(mozilla::wr::DisplayList
WrRect transformedRect = aSc.ToRelativeWrRect(rect); WrRect transformedRect = aSc.ToRelativeWrRect(rect);
aBuilder.PushRect(transformedRect, aBuilder.PushRect(transformedRect,
aBuilder.PushClipRegion(transformedRect), transformedRect,
wr::ToWrColor(ToDeviceColor(mColor))); wr::ToWrColor(ToDeviceColor(mColor)));
} }

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

@ -11,6 +11,7 @@
#include "gfxContext.h" #include "gfxContext.h"
#include "gfxUtils.h" #include "gfxUtils.h"
#include "mozilla/DebugOnly.h" #include "mozilla/DebugOnly.h"
#include "mozilla/Encoding.h"
#include "mozilla/EventStates.h" #include "mozilla/EventStates.h"
#include "mozilla/gfx/2D.h" #include "mozilla/gfx/2D.h"
#include "mozilla/gfx/Helpers.h" #include "mozilla/gfx/Helpers.h"
@ -2248,7 +2249,7 @@ nsImageFrame::GetDocumentCharacterSet(nsACString& aCharset) const
if (mContent) { if (mContent) {
NS_ASSERTION(mContent->GetComposedDoc(), NS_ASSERTION(mContent->GetComposedDoc(),
"Frame still alive after content removed from document!"); "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]); 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), WrBorderRadius borderRadius = wr::ToWrBorderRadius(LayerSize(mBorderRadii[0].width, mBorderRadii[0].height),
LayerSize(mBorderRadii[1].width, mBorderRadii[1].height), LayerSize(mBorderRadii[1].width, mBorderRadii[1].height),
LayerSize(mBorderRadii[3].width, mBorderRadii[3].height), LayerSize(mBorderRadii[3].width, mBorderRadii[3].height),
LayerSize(mBorderRadii[2].width, mBorderRadii[2].height)); LayerSize(mBorderRadii[2].width, mBorderRadii[2].height));
aBuilder.PushBorder(transformedRect, aBuilder.PushBorder(transformedRect,
clipRegion, transformedRect,
wr::ToWrBorderWidths(mBorderWidths[0], mBorderWidths[1], mBorderWidths[2], mBorderWidths[3]), wr::ToWrBorderWidths(mBorderWidths[0], mBorderWidths[1], mBorderWidths[2], mBorderWidths[3]),
side[0], side[1], side[2], side[3], side[0], side[1], side[2], side[3],
borderRadius); borderRadius);

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

@ -1084,7 +1084,7 @@ nsCSSGradientRenderer::BuildWebRenderDisplayItems(wr::DisplayListBuilder& aBuild
aBuilder.PushLinearGradient( aBuilder.PushLinearGradient(
wrGradientBounds, wrGradientBounds,
aBuilder.PushClipRegion(wrClipBounds), wrClipBounds,
mozilla::wr::ToWrPoint(lineStart), mozilla::wr::ToWrPoint(lineStart),
mozilla::wr::ToWrPoint(lineEnd), mozilla::wr::ToWrPoint(lineEnd),
stops, stops,
@ -1097,7 +1097,7 @@ nsCSSGradientRenderer::BuildWebRenderDisplayItems(wr::DisplayListBuilder& aBuild
aBuilder.PushRadialGradient( aBuilder.PushRadialGradient(
wrGradientBounds, wrGradientBounds,
aBuilder.PushClipRegion(wrClipBounds), wrClipBounds,
mozilla::wr::ToWrPoint(lineStart), mozilla::wr::ToWrPoint(lineStart),
mozilla::wr::ToWrSize(gradientRadius), mozilla::wr::ToWrSize(gradientRadius),
stops, stops,

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

@ -4618,12 +4618,12 @@ nsDisplayCaret::CreateWebRenderCommands(wr::DisplayListBuilder& aBuilder,
// Note, WR will pixel snap anything that is layout aligned. // Note, WR will pixel snap anything that is layout aligned.
aBuilder.PushRect(caret, aBuilder.PushRect(caret,
aBuilder.PushClipRegion(caret), caret,
wr::ToWrColor(color)); wr::ToWrColor(color));
if (!devHookRect.IsEmpty()) { if (!devHookRect.IsEmpty()) {
aBuilder.PushRect(hook, aBuilder.PushRect(hook,
aBuilder.PushClipRegion(hook), hook,
wr::ToWrColor(color)); wr::ToWrColor(color));
} }
} }
@ -4895,7 +4895,7 @@ nsDisplayBorder::CreateBorderImageWebRenderCommands(mozilla::wr::DisplayListBuil
} }
aBuilder.PushBorderImage(dest, aBuilder.PushBorderImage(dest,
aBuilder.PushClipRegion(clip), clip,
wr::ToWrBorderWidths(widths[0], widths[1], widths[2], widths[3]), wr::ToWrBorderWidths(widths[0], widths[1], widths[2], widths[3]),
key.value(), key.value(),
wr::ToWrNinePatchDescriptor( wr::ToWrNinePatchDescriptor(
@ -4928,7 +4928,7 @@ nsDisplayBorder::CreateBorderImageWebRenderCommands(mozilla::wr::DisplayListBuil
endPoint = endPoint + ViewAs<LayerPixel>(lineEnd, PixelCastJustification::WebRenderHasUnitResolution); endPoint = endPoint + ViewAs<LayerPixel>(lineEnd, PixelCastJustification::WebRenderHasUnitResolution);
aBuilder.PushBorderGradient(dest, aBuilder.PushBorderGradient(dest,
aBuilder.PushClipRegion(clip), clip,
wr::ToWrBorderWidths(widths[0], widths[1], widths[2], widths[3]), wr::ToWrBorderWidths(widths[0], widths[1], widths[2], widths[3]),
wr::ToWrPoint(startPoint), wr::ToWrPoint(startPoint),
wr::ToWrPoint(endPoint), wr::ToWrPoint(endPoint),
@ -4937,7 +4937,7 @@ nsDisplayBorder::CreateBorderImageWebRenderCommands(mozilla::wr::DisplayListBuil
wr::ToWrSideOffsets2Df32(outset[0], outset[1], outset[2], outset[3])); wr::ToWrSideOffsets2Df32(outset[0], outset[1], outset[2], outset[3]));
} else { } else {
aBuilder.PushBorderRadialGradient(dest, aBuilder.PushBorderRadialGradient(dest,
aBuilder.PushClipRegion(clip), clip,
wr::ToWrBorderWidths(widths[0], widths[1], widths[2], widths[3]), wr::ToWrBorderWidths(widths[0], widths[1], widths[2], widths[3]),
wr::ToWrPoint(lineStart), wr::ToWrPoint(lineStart),
wr::ToWrSize(gradientRadius), wr::ToWrSize(gradientRadius),
@ -5264,7 +5264,7 @@ nsDisplayBoxShadowOuter::CreateWebRenderCommands(wr::DisplayListBuilder& aBuilde
float spreadRadius = float(shadow->mSpread) / float(appUnitsPerDevPixel); float spreadRadius = float(shadow->mSpread) / float(appUnitsPerDevPixel);
aBuilder.PushBoxShadow(deviceBoxRect, aBuilder.PushBoxShadow(deviceBoxRect,
aBuilder.PushClipRegion(deviceClipRect), deviceClipRect,
deviceBoxRect, deviceBoxRect,
wr::ToWrPoint(shadowOffset), wr::ToWrPoint(shadowOffset),
wr::ToWrColor(shadowColor), wr::ToWrColor(shadowColor),
@ -5421,7 +5421,7 @@ nsDisplayBoxShadowInner::CreateInsetBoxShadowWebRenderCommands(mozilla::wr::Disp
float spreadRadius = float(shadowItem->mSpread) / float(appUnitsPerDevPixel); float spreadRadius = float(shadowItem->mSpread) / float(appUnitsPerDevPixel);
aBuilder.PushBoxShadow(wr::ToWrRect(deviceBoxRect), aBuilder.PushBoxShadow(wr::ToWrRect(deviceBoxRect),
aBuilder.PushClipRegion(deviceClipRect), deviceClipRect,
wr::ToWrRect(deviceBoxRect), wr::ToWrRect(deviceBoxRect),
wr::ToWrPoint(shadowOffset), wr::ToWrPoint(shadowOffset),
wr::ToWrColor(shadowColor), wr::ToWrColor(shadowColor),

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

@ -652,7 +652,7 @@ nsImageRenderer::BuildWebRenderDisplayItems(nsPresContext* aPresContext,
LayoutDeviceSize gapSize = LayoutDeviceSize::FromAppUnits( LayoutDeviceSize gapSize = LayoutDeviceSize::FromAppUnits(
aRepeatSize - aDest.Size(), appUnitsPerDevPixel); aRepeatSize - aDest.Size(), appUnitsPerDevPixel);
aBuilder.PushImage(fill, aBuilder.PushClipRegion(clip), aBuilder.PushImage(fill, clip,
wr::ToWrSize(destRect.Size()), wr::ToWrSize(gapSize), wr::ToWrSize(destRect.Size()), wr::ToWrSize(gapSize),
wr::ImageRendering::Auto, key.value()); wr::ImageRendering::Auto, key.value());
break; break;

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

@ -761,8 +761,8 @@ SheetLoadData::OnDetermineCharset(nsIUnicharStreamLoader* aLoader,
if (mLoader->mDocument) { if (mLoader->mDocument) {
// no useful data on charset. Try the document charset. // no useful data on charset. Try the document charset.
aCharset = mLoader->mDocument->GetDocumentCharacterSet(); auto encoding = mLoader->mDocument->GetDocumentCharacterSet();
MOZ_ASSERT(!aCharset.IsEmpty()); encoding->Name(aCharset);
mCharset.Assign(aCharset); mCharset.Assign(aCharset);
LOG((" Setting from document to: %s", PromiseFlatCString(aCharset).get())); LOG((" Setting from document to: %s", PromiseFlatCString(aCharset).get()));
return NS_OK; return NS_OK;

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

@ -7435,10 +7435,9 @@ BCBlockDirSeg::CreateWebRenderCommands(BCPaintBorderIterator& aIter,
transformedRect.width, transformedRect.width,
transformedRect.width, transformedRect.width,
transformedRect.width); transformedRect.width);
WrClipRegionToken clipRegion = aBuilder.PushClipRegion(transformedRect);
transformedRect.width *= 2.0f; transformedRect.width *= 2.0f;
aBuilder.PushBorder(transformedRect, aBuilder.PushBorder(transformedRect,
clipRegion, transformedRect,
borderWidths, borderWidths,
wrSide[0], wrSide[1], wrSide[2], wrSide[3], wrSide[0], wrSide[1], wrSide[2], wrSide[3],
borderRadii); borderRadii);
@ -7694,10 +7693,9 @@ BCInlineDirSeg::CreateWebRenderCommands(BCPaintBorderIterator& aIter,
transformedRect.height, transformedRect.height,
transformedRect.height, transformedRect.height,
transformedRect.height); transformedRect.height);
WrClipRegionToken clipRegion = aBuilder.PushClipRegion(transformedRect);
transformedRect.height *= 2.0f; transformedRect.height *= 2.0f;
aBuilder.PushBorder(transformedRect, aBuilder.PushBorder(transformedRect,
clipRegion, transformedRect,
borderWidths, borderWidths,
wrSide[0], wrSide[1], wrSide[2], wrSide[3], wrSide[0], wrSide[1], wrSide[2], wrSide[3],
borderRadii); borderRadii);

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

@ -771,7 +771,7 @@ nsXULPopupManager::ShowMenu(nsIContent *aMenu,
} }
else { else {
nsCOMPtr<nsIContent> popupContent = popupFrame->GetContent(); 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, popupFrame->InitializePopup(aAnchorContent, triggerContent, aPosition,
aXPos, aYPos, MenuPopupAnchorType_Node, aAttributesOverride); aXPos, aYPos, MenuPopupAnchorType_Node, aAttributesOverride);
FirePopupShowingEvent(aPopup, aIsContextMenu, aSelectFirstItem); FirePopupShowingEvent(aPopup, aIsContextMenu, aSelectFirstItem, aTriggerEvent);
} }
void void
@ -812,7 +812,7 @@ nsXULPopupManager::ShowPopupAtScreen(nsIContent* aPopup,
InitTriggerEvent(aTriggerEvent, aPopup, getter_AddRefs(triggerContent)); InitTriggerEvent(aTriggerEvent, aPopup, getter_AddRefs(triggerContent));
popupFrame->InitializePopupAtScreen(triggerContent, aXPos, aYPos, aIsContextMenu); popupFrame->InitializePopupAtScreen(triggerContent, aXPos, aYPos, aIsContextMenu);
FirePopupShowingEvent(aPopup, aIsContextMenu, false); FirePopupShowingEvent(aPopup, aIsContextMenu, false, aTriggerEvent);
} }
void void
@ -833,7 +833,7 @@ nsXULPopupManager::ShowPopupAtScreenRect(nsIContent* aPopup,
popupFrame->InitializePopupAtRect(triggerContent, aPosition, popupFrame->InitializePopupAtRect(triggerContent, aPosition,
aRect, aAttributesOverride); aRect, aAttributesOverride);
FirePopupShowingEvent(aPopup, aIsContextMenu, false); FirePopupShowingEvent(aPopup, aIsContextMenu, false, aTriggerEvent);
} }
void void
@ -862,7 +862,7 @@ nsXULPopupManager::ShowTooltipAtScreen(nsIContent* aPopup,
popupFrame->InitializePopupAtScreen(aTriggerContent, aXPos, aYPos, false); popupFrame->InitializePopupAtScreen(aTriggerContent, aXPos, aYPos, false);
FirePopupShowingEvent(aPopup, false, false); FirePopupShowingEvent(aPopup, false, false, nullptr);
} }
void void
@ -881,7 +881,7 @@ nsXULPopupManager::ShowPopupWithAnchorAlign(nsIContent* aPopup,
popupFrame->InitializePopupWithAnchorAlign(aAnchorContent, aAnchor, popupFrame->InitializePopupWithAnchorAlign(aAnchorContent, aAnchor,
aAlign, aXPos, aYPos); aAlign, aXPos, aYPos);
FirePopupShowingEvent(aPopup, aIsContextMenu, false); FirePopupShowingEvent(aPopup, aIsContextMenu, false, nullptr);
} }
static void static void
@ -1429,7 +1429,8 @@ nsXULPopupManager::ExecuteMenu(nsIContent* aMenu, nsXULMenuCommandEvent* aEvent)
void void
nsXULPopupManager::FirePopupShowingEvent(nsIContent* aPopup, nsXULPopupManager::FirePopupShowingEvent(nsIContent* aPopup,
bool aIsContextMenu, bool aIsContextMenu,
bool aSelectFirstItem) bool aSelectFirstItem,
nsIDOMEvent* aTriggerEvent)
{ {
nsCOMPtr<nsIContent> popup = aPopup; // keep a strong reference to the popup nsCOMPtr<nsIContent> popup = aPopup; // keep a strong reference to the popup
@ -1475,6 +1476,14 @@ nsXULPopupManager::FirePopupShowingEvent(nsIContent* aPopup,
event.mWidget = nullptr; event.mWidget = nullptr;
} }
if (aTriggerEvent) {
WidgetMouseEventBase* mouseEvent =
aTriggerEvent->WidgetEventPtr()->AsMouseEventBase();
if (mouseEvent) {
event.inputSource = mouseEvent->inputSource;
}
}
event.mRefPoint = mCachedMousePoint; event.mRefPoint = mCachedMousePoint;
event.mModifiers = mCachedModifiers; event.mModifiers = mCachedModifiers;
EventDispatcher::Dispatch(popup, presContext, &event, nullptr, &status); EventDispatcher::Dispatch(popup, presContext, &event, nullptr, &status);
@ -2740,7 +2749,7 @@ nsXULPopupShowingEvent::Run()
{ {
nsXULPopupManager* pm = nsXULPopupManager::GetInstance(); nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
if (pm) { if (pm) {
pm->FirePopupShowingEvent(mPopup, mIsContextMenu, mSelectFirstItem); pm->FirePopupShowingEvent(mPopup, mIsContextMenu, mSelectFirstItem, nullptr);
} }
return NS_OK; return NS_OK;

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

@ -731,10 +731,14 @@ protected:
* aPopup - the popup to open * aPopup - the popup to open
* aIsContextMenu - true for context menus * aIsContextMenu - true for context menus
* aSelectFirstItem - true to select the first item in the menu * 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, void FirePopupShowingEvent(nsIContent* aPopup,
bool aIsContextMenu, bool aIsContextMenu,
bool aSelectFirstItem); bool aSelectFirstItem,
nsIDOMEvent* aTriggerEvent);
/** /**
* Fire a popuphiding event and then hide the popup. This will be called * Fire a popuphiding event and then hide the popup. This will be called

Двоичные данные
mobile/android/app/src/main/res/drawable-hdpi/firefox_logo.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 44 KiB

Двоичные данные
mobile/android/app/src/main/res/drawable-xhdpi/firefox_logo.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 68 KiB

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