зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1482648 - Part 3 - Remove remaining broadcasters from front-end code. r=bgrins
Differential Revision: https://phabricator.services.mozilla.com/D3150 --HG-- extra : rebase_source : ae1bca38891bf3876af59e1cff047199b19abacd
This commit is contained in:
Родитель
c09f3ae130
Коммит
bb3d2cf63d
|
@ -356,8 +356,7 @@
|
|||
<menuitem id="context-viewframesource"
|
||||
label="&viewFrameSourceCmd.label;"
|
||||
accesskey="&viewFrameSourceCmd.accesskey;"
|
||||
oncommand="gContextMenu.viewFrameSource();"
|
||||
observes="isFrameImage"/>
|
||||
oncommand="gContextMenu.viewFrameSource();"/>
|
||||
<menuitem id="context-viewframeinfo"
|
||||
label="&viewFrameInfoCmd.label;"
|
||||
accesskey="&viewFrameInfoCmd.accesskey;"
|
||||
|
@ -367,14 +366,12 @@
|
|||
<menuitem id="context-viewpartialsource-selection"
|
||||
label="&viewPartialSourceForSelectionCmd.label;"
|
||||
accesskey="&viewPartialSourceCmd.accesskey;"
|
||||
oncommand="gContextMenu.viewPartialSource();"
|
||||
observes="isImage"/>
|
||||
oncommand="gContextMenu.viewPartialSource();"/>
|
||||
<menuseparator id="context-sep-viewsource"/>
|
||||
<menuitem id="context-viewsource"
|
||||
label="&viewPageSourceCmd.label;"
|
||||
accesskey="&viewPageSourceCmd.accesskey;"
|
||||
oncommand="BrowserViewSource(gContextMenu.browser);"
|
||||
observes="canViewSource"/>
|
||||
oncommand="BrowserViewSource(gContextMenu.browser);"/>
|
||||
<menuitem id="context-viewinfo"
|
||||
label="&viewPageInfoCmd.label;"
|
||||
accesskey="&viewPageInfoCmd.accesskey;"
|
||||
|
|
|
@ -245,7 +245,7 @@
|
|||
</menupopup>
|
||||
</menu>
|
||||
<menu id="pageStyleMenu" label="&pageStyleMenu.label;"
|
||||
accesskey="&pageStyleMenu.accesskey;" observes="isImage">
|
||||
accesskey="&pageStyleMenu.accesskey;">
|
||||
<menupopup onpopupshowing="gPageStyleMenu.fillPopup(this);">
|
||||
<menuitem id="menu_pageStyleNoStyle"
|
||||
label="&pageStyleNoStyle.label;"
|
||||
|
@ -517,9 +517,7 @@
|
|||
label="&pageSourceCmd.label;"
|
||||
key="key_viewSource"
|
||||
command="View:PageSource"
|
||||
accesskey="&pageSourceCmd.accesskey;">
|
||||
<observes element="canViewSource" attribute="disabled"/>
|
||||
</menuitem>
|
||||
accesskey="&pageSourceCmd.accesskey;"/>
|
||||
<menuitem id="menu_devtools_recordExecution"
|
||||
label="&devtoolsRecordExecution.label;"
|
||||
command="Tools:RecordExecution"
|
||||
|
|
|
@ -42,19 +42,13 @@
|
|||
|
||||
#include ../../../toolkit/content/editMenuCommands.inc.xul
|
||||
|
||||
<command id="View:PageSource" oncommand="BrowserViewSource(window.gBrowser.selectedBrowser);" observes="canViewSource"/>
|
||||
<command id="View:PageSource" oncommand="BrowserViewSource(window.gBrowser.selectedBrowser);"/>
|
||||
<command id="View:PageInfo" oncommand="BrowserPageInfo();"/>
|
||||
<command id="View:FullScreen" oncommand="BrowserFullScreen();"/>
|
||||
<command id="View:ReaderView" oncommand="ReaderParent.toggleReaderMode(event);"/>
|
||||
<command id="cmd_find"
|
||||
oncommand="gLazyFindCommand('onFindCommand')"
|
||||
observes="isImage"/>
|
||||
<command id="cmd_findAgain"
|
||||
oncommand="gLazyFindCommand('onFindAgainCommand', false)"
|
||||
observes="isImage"/>
|
||||
<command id="cmd_findPrevious"
|
||||
oncommand="gLazyFindCommand('onFindAgainCommand', true)"
|
||||
observes="isImage"/>
|
||||
<command id="cmd_find" oncommand="gLazyFindCommand('onFindCommand')"/>
|
||||
<command id="cmd_findAgain" oncommand="gLazyFindCommand('onFindAgainCommand', false)"/>
|
||||
<command id="cmd_findPrevious" oncommand="gLazyFindCommand('onFindAgainCommand', true)"/>
|
||||
#ifdef XP_MACOSX
|
||||
<command id="cmd_findSelection" oncommand="gLazyFindCommand('onFindSelectionCommand')"/>
|
||||
#endif
|
||||
|
@ -122,12 +116,6 @@
|
|||
|
||||
#include ../../components/places/content/placesCommands.inc.xul
|
||||
|
||||
<broadcasterset id="mainBroadcasterSet">
|
||||
<broadcaster id="isImage"/>
|
||||
<broadcaster id="canViewSource"/>
|
||||
<broadcaster id="isFrameImage"/>
|
||||
</broadcasterset>
|
||||
|
||||
<keyset id="mainKeyset">
|
||||
<key id="key_newNavigator"
|
||||
key="&newNavigatorCmd.key;"
|
||||
|
|
|
@ -4524,13 +4524,22 @@ var XULBrowserWindow = {
|
|||
delete this.reloadCommand;
|
||||
return this.reloadCommand = document.getElementById("Browser:Reload");
|
||||
},
|
||||
get isImage() {
|
||||
delete this.isImage;
|
||||
return this.isImage = document.getElementById("isImage");
|
||||
get elementsForTextBasedTypes() {
|
||||
delete this.elementsForTextBasedTypes;
|
||||
return this.elementsForTextBasedTypes = [
|
||||
document.getElementById("pageStyleMenu"),
|
||||
document.getElementById("context-viewpartialsource-selection"),
|
||||
document.getElementById("cmd_find"),
|
||||
document.getElementById("cmd_findAgain"),
|
||||
document.getElementById("cmd_findPrevious"),
|
||||
];
|
||||
},
|
||||
get canViewSource() {
|
||||
delete this.canViewSource;
|
||||
return this.canViewSource = document.getElementById("canViewSource");
|
||||
get elementsForViewSource() {
|
||||
delete this.elementsForViewSource;
|
||||
return this.elementsForViewSource = [
|
||||
document.getElementById("context-viewsource"),
|
||||
document.getElementById("View:PageSource"),
|
||||
];
|
||||
},
|
||||
|
||||
forceInitialBrowserNonRemote(aOpener) {
|
||||
|
@ -4684,17 +4693,22 @@ var XULBrowserWindow = {
|
|||
this.setDefaultStatus(msg);
|
||||
|
||||
// Disable menu entries for images, enable otherwise
|
||||
if (browser.documentContentType && BrowserUtils.mimeTypeIsTextBased(browser.documentContentType)) {
|
||||
this.isImage.removeAttribute("disabled");
|
||||
} else {
|
||||
canViewSource = false;
|
||||
this.isImage.setAttribute("disabled", "true");
|
||||
let isText = browser.documentContentType &&
|
||||
BrowserUtils.mimeTypeIsTextBased(browser.documentContentType);
|
||||
for (let element of this.elementsForTextBasedTypes) {
|
||||
if (isText) {
|
||||
element.removeAttribute("disabled");
|
||||
} else {
|
||||
element.setAttribute("disabled", "true");
|
||||
}
|
||||
}
|
||||
|
||||
if (canViewSource) {
|
||||
this.canViewSource.removeAttribute("disabled");
|
||||
} else {
|
||||
this.canViewSource.setAttribute("disabled", "true");
|
||||
for (let element of this.elementsForViewSource) {
|
||||
if (canViewSource && isText) {
|
||||
element.removeAttribute("disabled");
|
||||
} else {
|
||||
element.setAttribute("disabled", "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4733,10 +4747,15 @@ var XULBrowserWindow = {
|
|||
let browser = gBrowser.selectedBrowser;
|
||||
|
||||
// Disable menu entries for images, enable otherwise
|
||||
if (browser.documentContentType && BrowserUtils.mimeTypeIsTextBased(browser.documentContentType))
|
||||
this.isImage.removeAttribute("disabled");
|
||||
else
|
||||
this.isImage.setAttribute("disabled", "true");
|
||||
let isText = browser.documentContentType &&
|
||||
BrowserUtils.mimeTypeIsTextBased(browser.documentContentType);
|
||||
for (let element of this.elementsForTextBasedTypes) {
|
||||
if (isText) {
|
||||
element.removeAttribute("disabled");
|
||||
} else {
|
||||
element.setAttribute("disabled", "true");
|
||||
}
|
||||
}
|
||||
|
||||
this.hideOverLinkImmediately = true;
|
||||
this.setOverLink("", null);
|
||||
|
|
|
@ -133,7 +133,8 @@ nsContextMenu.prototype = {
|
|||
Services.obs.notifyObservers(subject, "on-build-contextmenu");
|
||||
}
|
||||
|
||||
this.isFrameImage = document.getElementById("isFrameImage");
|
||||
this.viewFrameSourceElement =
|
||||
document.getElementById("context-viewframesource");
|
||||
this.ellipsis = "\u2026";
|
||||
try {
|
||||
this.ellipsis = Services.prefs.getComplexValue("intl.ellipsis",
|
||||
|
@ -534,9 +535,9 @@ nsContextMenu.prototype = {
|
|||
// Hide menu entries for images, show otherwise
|
||||
if (this.inFrame) {
|
||||
if (BrowserUtils.mimeTypeIsTextBased(this.target.ownerDocument.contentType))
|
||||
this.isFrameImage.removeAttribute("hidden");
|
||||
this.viewFrameSourceElement.removeAttribute("hidden");
|
||||
else
|
||||
this.isFrameImage.setAttribute("hidden", "true");
|
||||
this.viewFrameSourceElement.setAttribute("hidden", "true");
|
||||
}
|
||||
|
||||
// BiDi UI
|
||||
|
|
|
@ -13,7 +13,7 @@ function wait_while_tab_is_busy() {
|
|||
}
|
||||
|
||||
// This function waits for the tab to stop being busy instead of waiting for it
|
||||
// to load, since the canViewSource change happens at that time.
|
||||
// to load, since the elementsForViewSource change happens at that time.
|
||||
var with_new_tab_opened = async function(options, taskFn) {
|
||||
let busyPromise = wait_while_tab_is_busy();
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(options.gBrowser, options.url, false);
|
||||
|
@ -24,8 +24,10 @@ var with_new_tab_opened = async function(options, taskFn) {
|
|||
|
||||
add_task(async function test_regular_page() {
|
||||
function test_expect_view_source_enabled(browser) {
|
||||
ok(!XULBrowserWindow.canViewSource.hasAttribute("disabled"),
|
||||
"View Source should be enabled");
|
||||
for (let element of [...XULBrowserWindow.elementsForViewSource]) {
|
||||
ok(!element.hasAttribute("disabled"),
|
||||
"View Source should be enabled");
|
||||
}
|
||||
}
|
||||
|
||||
await with_new_tab_opened({
|
||||
|
@ -36,8 +38,10 @@ add_task(async function test_regular_page() {
|
|||
|
||||
add_task(async function test_view_source_page() {
|
||||
function test_expect_view_source_disabled(browser) {
|
||||
ok(XULBrowserWindow.canViewSource.hasAttribute("disabled"),
|
||||
"View Source should be disabled");
|
||||
for (let element of [...XULBrowserWindow.elementsForViewSource]) {
|
||||
ok(element.hasAttribute("disabled"),
|
||||
"View Source should be disabled");
|
||||
}
|
||||
}
|
||||
|
||||
await with_new_tab_opened({
|
||||
|
|
|
@ -26,10 +26,6 @@
|
|||
<script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
|
||||
<script type="application/javascript" src="chrome://browser/content/utilityOverlay.js"/>
|
||||
|
||||
<broadcasterset id="mainBroadcasterSet">
|
||||
<broadcaster id="isFrameImage"/>
|
||||
</broadcasterset>
|
||||
|
||||
<commandset id="mainCommandset">
|
||||
<command id="Browser:Back"
|
||||
oncommand="getPanelBrowser().webNavigation.goBack();"
|
||||
|
|
Загрузка…
Ссылка в новой задаче