From 49da461a50dba213faeed88f05abfee9e4757192 Mon Sep 17 00:00:00 2001 From: "gijskruitbosch%gmail.com" Date: Wed, 8 Oct 2008 19:00:10 +0000 Subject: [PATCH] Bug 211272 - Double-quote munger breaks word wrapping r=silver@warwickcompsoc.co.uk (James Ross) ChatZilla Only. NPOTFFB. git-svn-id: svn://10.0.0.236/trunk@254570 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/extensions/irc/js/lib/utils.js | 3 ++ mozilla/extensions/irc/xul/content/mungers.js | 35 +++++++------------ mozilla/extensions/irc/xul/content/static.js | 3 -- mozilla/extensions/irc/xul/lib/munger.js | 6 ++-- 4 files changed, 18 insertions(+), 29 deletions(-) diff --git a/mozilla/extensions/irc/js/lib/utils.js b/mozilla/extensions/irc/js/lib/utils.js index 4349a8b15a7..f9817e28ab0 100644 --- a/mozilla/extensions/irc/js/lib/utils.js +++ b/mozilla/extensions/irc/js/lib/utils.js @@ -37,6 +37,9 @@ * * ***** END LICENSE BLOCK ***** */ +// Namespaces we happen to need: +const XHTML_NS = "http://www.w3.org/1999/xhtml"; + var utils = new Object(); var DEBUG = true; diff --git a/mozilla/extensions/irc/xul/content/mungers.js b/mozilla/extensions/irc/xul/content/mungers.js index d8bf8024bc3..e78e30dc6c2 100644 --- a/mozilla/extensions/irc/xul/content/mungers.js +++ b/mozilla/extensions/irc/xul/content/mungers.js @@ -205,8 +205,7 @@ function insertLink(matchText, containerTag, data, mungerEntry) client.prefs["urls.list"].update(); } - var anchor = document.createElementNS("http://www.w3.org/1999/xhtml", - "html:a"); + var anchor = document.createElementNS(XHTML_NS, "html:a"); var mircRE = /\x1f|\x02|\x0f|\x16|\x03([0-9]{1,2}(,[0-9]{1,2})?)?/g; anchor.setAttribute("href", href.replace(mircRE, "")); @@ -246,8 +245,7 @@ function insertMailToLink(matchText, containerTag, eventData, mungerEntry) else href = matchText; - var anchor = document.createElementNS("http://www.w3.org/1999/xhtml", - "html:a"); + var anchor = document.createElementNS(XHTML_NS, "html:a"); var mircRE = /\x1f|\x02|\x0f|\x16|\x03([0-9]{1,2}(,[0-9]{1,2})?)?/g; anchor.setAttribute("href", href.replace(mircRE, "")); @@ -290,8 +288,7 @@ function insertChannelLink(matchText, containerTag, eventData, mungerEntry) var linkText = removeColorCodes(matchText); var encodedLinkText = fromUnicode(linkText, eventData.sourceObject); - var anchor = document.createElementNS("http://www.w3.org/1999/xhtml", - "html:a"); + var anchor = document.createElementNS(XHTML_NS, "html:a"); anchor.setAttribute("href", eventData.network.getURL(encodedLinkText)); // Carry over formatting. @@ -319,8 +316,7 @@ function insertTalkbackLink(matchText, containerTag, eventData, mungerEntry) return; } - var anchor = document.createElementNS("http://www.w3.org/1999/xhtml", - "html:a"); + var anchor = document.createElementNS(XHTML_NS, "html:a"); anchor.setAttribute("href", "http://talkback-public.mozilla.org/" + "search/start.jsp?search=2&type=iid&id=" + matchText); @@ -382,8 +378,7 @@ function insertBugzillaLink (matchText, containerTag, eventData, mungerEntry) } } - var anchor = document.createElementNS("http://www.w3.org/1999/xhtml", - "html:a"); + var anchor = document.createElementNS(XHTML_NS, "html:a"); anchor.setAttribute("href", bugURL); // Carry over formatting. var otherFormatting = calcClass(eventData); @@ -418,8 +413,7 @@ function insertRheet(matchText, containerTag, eventData, mungerEntry) return; } - var anchor = document.createElementNS("http://www.w3.org/1999/xhtml", - "html:a"); + var anchor = document.createElementNS(XHTML_NS, "html:a"); anchor.setAttribute("href", "http://ftp.mozilla.org/pub/mozilla.org/mozilla/libraries/bonus-tracks/rheet.wav"); anchor.setAttribute("class", "chatzilla-rheet chatzilla-link"); @@ -434,6 +428,7 @@ function insertQuote (matchText, containerTag) containerTag.appendChild(document.createTextNode("\u201c")); else containerTag.appendChild(document.createTextNode("\u201d")); + containerTag.appendChild(document.createElementNS(XHTML_NS, "html:wbr")); } function insertSmiley(emoticon, containerTag) @@ -491,8 +486,7 @@ function insertSmiley(emoticon, containerTag) return; } - var span = document.createElementNS ("http://www.w3.org/1999/xhtml", - "html:span"); + var span = document.createElementNS(XHTML_NS, "html:span"); /* create a span to hold the emoticon text */ span.setAttribute ("class", "chatzilla-emote-txt"); @@ -506,8 +500,7 @@ function insertSmiley(emoticon, containerTag) * to turn off the emoticon text, but keep the image. ie. * chatzilla-emote-txt { display: none; } turns off * chatzilla-emote-txt:after as well.*/ - span = document.createElementNS("http://www.w3.org/1999/xhtml", - "html:span"); + span = document.createElementNS(XHTML_NS, "html:span"); span.setAttribute("class", "chatzilla-emote"); span.setAttribute("type", type); span.setAttribute("title", emoticon); @@ -633,8 +626,7 @@ function mircReverseColor (text, containerTag, data) function showCtrlChar(c, containerTag) { - var span = document.createElementNS ("http://www.w3.org/1999/xhtml", - "html:span"); + var span = document.createElementNS(XHTML_NS, "html:span"); span.setAttribute ("class", "chatzilla-control-char"); if (c == "\t") { @@ -656,13 +648,12 @@ function insertHyphenatedWord(longWord, containerTag, data) if (data && ("hasColorInfo" in data)) newClass = calcClass(data); - var wbr = document.createElementNS("http://www.w3.org/1999/xhtml", - "html:wbr"); + var wbr = document.createElementNS(XHTML_NS, "html:wbr"); for (var i = 0; i < wordParts.length; ++i) { if (newClass) { - var newTag = document.createElementNS(NS_XHTML, "html:span"); + var newTag = document.createElementNS(XHTML_NS, "html:span"); newTag.setAttribute("class", newClass); newTag.appendChild(document.createTextNode(wordParts[i])); containerTag.appendChild(newTag); @@ -690,7 +681,7 @@ function insertInlineButton(text, containerTag, data) var title = ary[2]; var command = ary[3]; - var link = document.createElementNS("http://www.w3.org/1999/xhtml", "a"); + var link = document.createElementNS(XHTML_NS, "html:a"); link.setAttribute("href", "x-cz-command:" + encodeURI(command)); link.setAttribute("title", title); link.setAttribute("class", "chatzilla-link"); diff --git a/mozilla/extensions/irc/xul/content/static.js b/mozilla/extensions/irc/xul/content/static.js index 2ddb68e266d..5388f6019d1 100644 --- a/mozilla/extensions/irc/xul/content/static.js +++ b/mozilla/extensions/irc/xul/content/static.js @@ -105,9 +105,6 @@ client.SAFE_LIST_COUNT = 500; */ client.CONFERENCE_LOW_PASS = 10; -// Namespaces we happen to need: -const XHTML_NS = "http://www.w3.org/1999/xhtml"; - client.viewsArray = new Array(); client.activityList = new Object(); client.hostCompat = new Object(); diff --git a/mozilla/extensions/irc/xul/lib/munger.js b/mozilla/extensions/irc/xul/lib/munger.js index 5f231fc3965..d0f4d248668 100644 --- a/mozilla/extensions/irc/xul/lib/munger.js +++ b/mozilla/extensions/irc/xul/lib/munger.js @@ -80,8 +80,6 @@ * */ -const NS_XHTML = "http://www.w3.org/1999/xhtml"; - function CMungerEntry(name, regex, className, priority, startPriority, enable, tagName) { @@ -159,7 +157,7 @@ function mng_munge(text, containerTag, data) { if (!containerTag) - containerTag = document.createElementNS(NS_XHTML, this.tagName); + containerTag = document.createElementNS(XHTML_NS, this.tagName); // Starting from the top, for each valid priority, check all the rules, // return as soon as something matches. @@ -257,7 +255,7 @@ function mng_mungePriority(priority, text, containerTag, data) } else { - var tag = document.createElementNS(NS_XHTML, munger.tagName); + var tag = document.createElementNS(XHTML_NS, munger.tagName); tag.setAttribute("class", munger.className + calcClass(data)); // Don't let this rule match again when we recurse.