Bug 1497601 - Use a xul:description instead of a xul:label for tooltips;r=smaug
authorBrian Grinstead <bgrinstead@mozilla.com>
Tue, 16 Oct 2018 13:54:07 +0000
changeset 489803 f2e35ed6a6928b35e085462dc4268fd86f00fdb9
parent 489802 326840e3b097c6a36ade7851cf03de8c8fa56b67
child 489804 31724aea10cae55f30b825ade226c4d25e11a899
child 489848 21f2d2802b18cf831154d454535d27998a6c5176
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewerssmaug
bugs1497601
milestone64.0a1
Bug 1497601 - Use a xul:description instead of a xul:label for tooltips;r=smaug We'd like to be able to implement label features with a Custom Element, and we don't want to run CE reactions inside of NAC. Differential Revision: https://phabricator.services.mozilla.com/D8241
browser/base/content/browser.xul
browser/components/places/content/bookmarksHistoryTooltip.inc.xul
dom/xul/XULTooltipElement.cpp
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -610,30 +610,30 @@ xmlns="http://www.w3.org/1999/xhtml"
                 oncommand="BrowserPageActions.openAboutAddonsForContextAction();"/>
     </menupopup>
 
 #include ../../components/places/content/bookmarksHistoryTooltip.inc.xul
 
     <tooltip id="tabbrowser-tab-tooltip" onpopupshowing="gBrowser.createTooltip(event);"/>
 
     <tooltip id="back-button-tooltip">
-      <label class="tooltip-label" value="&backButton.tooltip;"/>
+      <description class="tooltip-label" value="&backButton.tooltip;"/>
 #ifdef XP_MACOSX
-      <label class="tooltip-label" value="&backForwardButtonMenuMac.tooltip;"/>
+      <description class="tooltip-label" value="&backForwardButtonMenuMac.tooltip;"/>
 #else
-      <label class="tooltip-label" value="&backForwardButtonMenu.tooltip;"/>
+      <description class="tooltip-label" value="&backForwardButtonMenu.tooltip;"/>
 #endif
     </tooltip>
 
     <tooltip id="forward-button-tooltip">
-      <label class="tooltip-label" value="&forwardButton.tooltip;"/>
+      <description class="tooltip-label" value="&forwardButton.tooltip;"/>
 #ifdef XP_MACOSX
-      <label class="tooltip-label" value="&backForwardButtonMenuMac.tooltip;"/>
+      <description class="tooltip-label" value="&backForwardButtonMenuMac.tooltip;"/>
 #else
-      <label class="tooltip-label" value="&backForwardButtonMenu.tooltip;"/>
+      <description class="tooltip-label" value="&backForwardButtonMenu.tooltip;"/>
 #endif
     </tooltip>
 
 #include popup-notifications.inc
 
 #include ../../components/customizableui/content/panelUI.inc.xul
 #include ../../components/controlcenter/content/panel.inc.xul
 #include ../../components/downloads/content/downloadsPanel.inc.xul
--- a/browser/components/places/content/bookmarksHistoryTooltip.inc.xul
+++ b/browser/components/places/content/bookmarksHistoryTooltip.inc.xul
@@ -1,8 +1,8 @@
 <!-- Bookmarks and history tooltip -->
 <tooltip id="bhTooltip" noautohide="true"
          onpopupshowing="return window.top.BookmarksEventHandler.fillInBHTooltip(document, event)">
   <vbox id="bhTooltipTextBox" flex="1">
-    <label id="bhtTitleText" class="tooltip-label" />
-    <label id="bhtUrlText" crop="center" class="tooltip-label uri-element" />
+    <description id="bhtTitleText" class="tooltip-label" />
+    <description id="bhtUrlText" crop="center" class="tooltip-label uri-element" />
   </vbox>
 </tooltip>
--- a/dom/xul/XULTooltipElement.cpp
+++ b/dom/xul/XULTooltipElement.cpp
@@ -22,55 +22,55 @@ NS_NewXULTooltipElement(already_AddRefed
 }
 
 nsresult
 XULTooltipElement::Init()
 {
   // Create the default child label node that will contain the text of the
   // tooltip.
   RefPtr<mozilla::dom::NodeInfo> nodeInfo;
-  nodeInfo = mNodeInfo->NodeInfoManager()->GetNodeInfo(nsGkAtoms::label,
+  nodeInfo = mNodeInfo->NodeInfoManager()->GetNodeInfo(nsGkAtoms::description,
                                                        nullptr,
                                                        kNameSpaceID_XUL,
                                                        nsINode::ELEMENT_NODE);
-  nsCOMPtr<Element> label;
-  nsresult rv = NS_NewXULElement(getter_AddRefs(label),
+  nsCOMPtr<Element> description;
+  nsresult rv = NS_NewXULElement(getter_AddRefs(description),
                                  nodeInfo.forget(), dom::NOT_FROM_PARSER);
   NS_ENSURE_SUCCESS(rv, rv);
-  label->SetAttr(kNameSpaceID_None, nsGkAtoms::_class,
+  description->SetAttr(kNameSpaceID_None, nsGkAtoms::_class,
                  NS_LITERAL_STRING("tooltip-label"), false);
-  label->SetAttr(kNameSpaceID_None, nsGkAtoms::flex,
+  description->SetAttr(kNameSpaceID_None, nsGkAtoms::flex,
                  NS_LITERAL_STRING("true"), false);
   ErrorResult error;
-  AppendChild(*label, error);
+  AppendChild(*description, error);
 
   return error.StealNSResult();
 }
 
 nsresult
 XULTooltipElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
                                 const nsAttrValue* aValue,
                                 const nsAttrValue* aOldValue,
                                 nsIPrincipal* aSubjectPrincipal,
                                 bool aNotify)
 {
   if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::label) {
     // When the label attribute of this node changes propagate the text down
-    // into child label element.
-    nsCOMPtr<nsIContent> label = GetFirstChild();
-    if (label && label->IsXULElement(nsGkAtoms::label)) {
+    // into child description element.
+    nsCOMPtr<nsIContent> description = GetFirstChild();
+    if (description && description->IsXULElement(nsGkAtoms::description)) {
       nsAutoString value;
       if (aValue) {
         aValue->ToString(value);
       }
       nsContentUtils::AddScriptRunner(NS_NewRunnableFunction(
         "XULTooltipElement::AfterSetAttr",
-        [label, value]() {
-          Element* labelElement = label->AsElement();
-          labelElement->SetTextContent(value, IgnoreErrors());
+        [description, value]() {
+          Element* descriptionElement = description->AsElement();
+          descriptionElement->SetTextContent(value, IgnoreErrors());
         })
       );
     }
   }
   return nsXULElement::AfterSetAttr(aNameSpaceID, aName, aValue, aOldValue,
                                     aSubjectPrincipal, aNotify);
 }