Bug 1218127 - Add tooltips to all twitter @mentions. r=clokep,florian a=aleth chat/ patch on CLOSED TREE
authoraleth <aleth@instantbird.org>
Fri, 30 Oct 2015 00:18:29 +0100
changeset 18534 ced21c95ce612c7f093de3418afe2a97a301c8ec
parent 18533 29fdfd7d6ee1363a40760fa3f6edfa18fa345401
child 18535 290ae28c7e983753e2c0e9cceb124ae0b3207996
push id11347
push useraleth@instantbird.org
push dateThu, 29 Oct 2015 23:19:07 +0000
treeherdercomm-central@ced21c95ce61 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersclokep, florian, aleth
bugs1218127
Bug 1218127 - Add tooltips to all twitter @mentions. r=clokep,florian a=aleth chat/ patch on CLOSED TREE
chat/content/imtooltip.xml
chat/modules/imContentSink.jsm
chat/protocols/twitter/twitter.js
--- a/chat/content/imtooltip.xml
+++ b/chat/content/imtooltip.xml
@@ -462,17 +462,18 @@
            let conv = document.getBindingParent(elt).conv;
            return updateTooltipFromParticipant(elt.chatBuddy.name, conv,
                                                elt.chatBuddy);
          }
 #endif
 
          let classList = elt.classList;
          if (classList.contains("ib-nick") ||
-             classList.contains("ib-sender")) {
+             classList.contains("ib-sender") ||
+             classList.contains("ib-person")) {
            let conv = getBrowser()._conv;
            if (conv.isChat)
              return updateTooltipFromParticipant(elt.textContent, conv);
            else if (elt.textContent == conv.name)
              return updateTooltipFromConversation(conv);
          }
 
          // Are we over a message?
--- a/chat/modules/imContentSink.jsm
+++ b/chat/modules/imContentSink.jsm
@@ -40,17 +40,18 @@ this.EXPORTED_SYMBOLS = [
  *    FIXME: make this accept functions to filter the CSS values too.
  *
  *  See the 3 examples of rulesets below.
  */
 
 var kAllowedURLs = aValue => /^(https?|ftp|mailto):/.test(aValue);
 var kAllowedMozClasses =
   aClassName => aClassName == "moz-txt-underscore" ||
-                aClassName == "moz-txt-tag";
+                aClassName == "moz-txt-tag" ||
+                aClassName == "ib-person";
 
 /* Tags whose content should be fully removed, and reported in the Error Console. */
 var kForbiddenTags = {
   script: true,
   style: true
 };
 
 // in strict mode, remove all formatings. Keep only links and line breaks.
--- a/chat/protocols/twitter/twitter.js
+++ b/chat/protocols/twitter/twitter.js
@@ -308,16 +308,17 @@ Conversation.prototype = {
           href: u.expanded_url || u.url})));
       }
       if ("user_mentions" in entities &&
           Array.isArray(entities.user_mentions)) {
         entArray = entArray.concat(entities.user_mentions.map(um => ({
           start: um.indices[0],
           end: um.indices[1],
           str: "@" + um.screen_name,
+          text: '@<span class="ib-person">' + um.screen_name + "</span>",
           title: um.name,
           href: "https://twitter.com/" + um.screen_name})));
       }
       entArray.sort((a, b) => a.start - b.start);
       let offset = 0;
       for each (let entity in entArray) {
         let str = text.substring(offset + entity.start, offset + entity.end);
         if (str[0] == "\uFF20") // @ - unicode character similar to @