Bug 1283529 - Make the cite attribute of HTMLQuote/ModElements reachable via the context menu
MozReview-Commit-ID: 9KRbO0SfvCs
--- a/browser/base/content/browser-context.inc
+++ b/browser/base/content/browser-context.inc
@@ -76,16 +76,22 @@
label="&openLinkCmd.label;"
accesskey="&openLinkCmd.accesskey;"
oncommand="gContextMenu.openLink();"/>
<menuitem id="context-openlinkprivate"
label="&openLinkInPrivateWindowCmd.label;"
accesskey="&openLinkInPrivateWindowCmd.accesskey;"
oncommand="gContextMenu.openLinkInPrivateWindow();"/>
<menuseparator id="context-sep-open"/>
+ <menuitem id="context-view-cite-url"
+ label="&viewCiteURLCmd.label;"
+ accesskey="&viewCiteURLCmd.accesskey;"
+ oncommand="gContextMenu.viewCiteURL(event);"
+ onclick="checkForMiddleClick(this, event);"/>
+ <menuseparator id="context-sep-cite"/>
<menuitem id="context-bookmarklink"
label="&bookmarkThisLinkCmd.label;"
accesskey="&bookmarkThisLinkCmd.accesskey;"
oncommand="gContextMenu.bookmarkLink();"/>
<menuitem id="context-sharelink"
label="&shareLink.label;"
accesskey="&shareLink.accesskey;"
oncommand="gContextMenu.shareLink();"/>
--- a/browser/base/content/nsContextMenu.js
+++ b/browser/base/content/nsContextMenu.js
@@ -169,17 +169,17 @@ nsContextMenu.prototype = {
this.showItem("context-openlinkinusercontext-menu", shouldShow && !isWindowPrivate && showContainers);
this.showItem("context-openlinkincurrent", this.onPlainTextLink);
this.showItem("context-sep-open", shouldShow);
},
initNavigationItems: function CM_initNavigationItems() {
var shouldShow = !(this.isContentSelected || this.onLink || this.onImage ||
this.onCanvas || this.onVideo || this.onAudio ||
- this.onTextInput || this.onSocial);
+ this.onTextInput || this.onSocial || this.citeURL != "");
this.showItem("context-navigation", shouldShow);
this.showItem("context-sep-navigation", shouldShow);
let stopped = XULBrowserWindow.stopCommand.getAttribute("disabled") == "true";
let stopReloadItem = "";
if (shouldShow || this.onSocial) {
stopReloadItem = (stopped || this.onSocial) ? "reload" : "stop";
@@ -293,16 +293,19 @@ nsContextMenu.prototype = {
this.showItem("context-sep-viewbgimage", shouldShow &&
!this._hasMultipleBGImages &&
!this.inSyntheticDoc);
document.getElementById("context-viewbgimage")
.disabled = !this.hasBGImage;
this.showItem("context-viewimageinfo", this.onImage);
this.showItem("context-viewimagedesc", this.onImage && this.imageDescURL !== "");
+
+ this.showItem("context-view-cite-url", this.citeURL != "");
+ this.showItem("context-sep-cite", this.citeURL != "");
},
initMiscItems: function CM_initMiscItems() {
// Use "Bookmark This Link" if on a link.
let bookmarkPage = document.getElementById("context-bookmarkpage");
this.showItem(bookmarkPage,
!(this.isContentSelected || this.onTextInput || this.onLink ||
this.onImage || this.onVideo || this.onAudio || this.onSocial ||
@@ -630,16 +633,17 @@ nsContextMenu.prototype = {
return;
}
// Initialize contextual info.
this.onImage = false;
this.onLoadedImage = false;
this.onCompletedImage = false;
this.imageDescURL = "";
+ this.citeURL = "";
this.onCanvas = false;
this.onVideo = false;
this.onAudio = false;
this.onDRMMedia = false;
this.onTextInput = false;
this.onNumeric = false;
this.onKeywordField = false;
this.mediaURL = "";
@@ -856,16 +860,25 @@ nsContextMenu.prototype = {
this._hasMultipleBGImages = true;
}
if (bgImgUrl) {
this.hasBGImage = true;
this.bgImageURL = makeURLAbsolute(elem.baseURI,
bgImgUrl);
}
}
+
+ // Quote/Mod elements with cite attributes?
+ if (this.citeURL == "" &&
+ (elem instanceof HTMLModElement ||
+ elem instanceof HTMLQuoteElement) &&
+ elem.hasAttribute('cite')) {
+ this.citeURL = makeURLAbsolute(elem.baseURI,
+ elem.getAttribute('cite'));
+ }
}
elem = elem.parentNode;
}
// See if the user clicked on MathML
const NS_MathML = "http://www.w3.org/1998/Math/MathML";
if ((this.target.nodeType == Node.TEXT_NODE &&
@@ -1123,16 +1136,25 @@ nsContextMenu.prototype = {
viewImageDesc: function(e) {
urlSecurityCheck(this.imageDescURL,
this.browser.contentPrincipal,
Ci.nsIScriptSecurityManager.DISALLOW_SCRIPT);
openUILink(this.imageDescURL, e, { disallowInheritPrincipal: true,
referrerURI: gContextMenuContentData.documentURIObject });
},
+ // Open the URL in the cite attribute of blockquote, q, ins, and del elements
+ viewCiteURL: function(e) {
+ urlSecurityCheck(this.citeURL, this.browser.contentPrincipal,
+ Ci.nsIScriptSecurityManager.DISALLOW_SCRIPT);
+ openUILink(this.citeURL, e, { disallowInheritPrincipal: true,
+ referrerURI: gContextMenuContentData.documentURIObject });
+ },
+
+
viewFrameInfo: function() {
BrowserPageInfo(gContextMenuContentData.docLocation, null, null,
this.frameOuterWindowID);
},
reloadImage: function() {
urlSecurityCheck(this.mediaURL,
this.browser.contentPrincipal,
--- a/browser/locales/en-US/chrome/browser/browser.dtd
+++ b/browser/locales/en-US/chrome/browser/browser.dtd
@@ -471,16 +471,18 @@ These should match what Safari and other
<!ENTITY viewPageSourceCmd.label "View Page Source">
<!ENTITY viewPageSourceCmd.accesskey "V">
<!ENTITY viewFrameSourceCmd.label "View Frame Source">
<!ENTITY viewFrameSourceCmd.accesskey "V">
<!ENTITY viewPageInfoCmd.label "View Page Info">
<!ENTITY viewPageInfoCmd.accesskey "I">
<!ENTITY viewFrameInfoCmd.label "View Frame Info">
<!ENTITY viewFrameInfoCmd.accesskey "I">
+<!ENTITY viewCiteURLCmd.label "View Citation">
+<!ENTITY viewCiteURLCmd.accesskey "C">
<!ENTITY reloadImageCmd.label "Reload Image">
<!ENTITY reloadImageCmd.accesskey "R">
<!ENTITY viewImageCmd.label "View Image">
<!ENTITY viewImageCmd.accesskey "I">
<!ENTITY viewImageInfoCmd.label "View Image Info">
<!ENTITY viewImageInfoCmd.accesskey "f">
<!ENTITY viewImageDescCmd.label "View Description">
<!ENTITY viewImageDescCmd.accesskey "D">