зеркало из https://github.com/mozilla/pjs.git
Bug 175074: URN:ISBN link converted to URN://ISBN, patch by Christian Schmidt <bugzilla.mozilla.org@chsc.dk>, r=mconnor
This commit is contained in:
Родитель
860fc1d068
Коммит
13adb8a7d7
|
@ -207,7 +207,7 @@ function checkForImage(elem, htmllocalname)
|
|||
}
|
||||
|
||||
if (imgType == "img") {
|
||||
setInfo("image-desc", getAbsoluteURL(img.longDesc, img));
|
||||
setInfo("image-desc", img.longDesc);
|
||||
} else {
|
||||
setInfo("image-desc", "");
|
||||
}
|
||||
|
@ -267,8 +267,15 @@ function checkForLink(elem, htmllocalname)
|
|||
onLink = true;
|
||||
}
|
||||
|
||||
else if (elem.getAttributeNS(XLinkNS,"href") != "") {
|
||||
setInfo("link-url", getAbsoluteURL(elem.getAttributeNS(XLinkNS,"href"),elem));
|
||||
else if (elem.getAttributeNS(XLinkNS, "href") != "") {
|
||||
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
var url = elem.getAttributeNS(XLinkNS, "href");
|
||||
try {
|
||||
var baseURI = ioService.newURI(elem.baseURI, elem.ownerDocument.characterSet, null);
|
||||
url = ioService.newURI(url, elem.ownerDocument.characterSet, baseURI).spec;
|
||||
} catch (e) {}
|
||||
setInfo("link-url", url);
|
||||
setInfo("link-lang", "");
|
||||
setInfo("link-type", "");
|
||||
setInfo("link-rel", "");
|
||||
|
@ -302,7 +309,7 @@ function checkForInsDel(elem, htmllocalname)
|
|||
{
|
||||
if ((htmllocalname === "ins" || htmllocalname === "del") &&
|
||||
(elem.cite || elem.dateTime)) {
|
||||
setInfo("insdel-cite", getAbsoluteURL(elem.cite, elem));
|
||||
setInfo("insdel-cite", elem.cite);
|
||||
setInfo("insdel-date", elem.dateTime);
|
||||
onInsDel = true;
|
||||
}
|
||||
|
@ -312,7 +319,7 @@ function checkForInsDel(elem, htmllocalname)
|
|||
function checkForQuote(elem, htmllocalname)
|
||||
{
|
||||
if ((htmllocalname === "q" || htmllocalname === "blockquote") && elem.cite) {
|
||||
setInfo("quote-cite", getAbsoluteURL(elem.cite, elem));
|
||||
setInfo("quote-cite", elem.cite);
|
||||
onQuote = true;
|
||||
}
|
||||
}
|
||||
|
@ -427,51 +434,6 @@ function getImageForMap(map)
|
|||
return img;
|
||||
}
|
||||
|
||||
/*
|
||||
* Takes care of XMLBase and <base>
|
||||
* url is the possibly relative url.
|
||||
* node is the node where the url was given (needed for XMLBase)
|
||||
*
|
||||
* This function is called in many places as a workaround for bug 72524
|
||||
* Once bug 72522 is fixed this code should use the Node.baseURI attribute
|
||||
*
|
||||
* for node==null or url=="", empty string is returned
|
||||
*/
|
||||
function getAbsoluteURL(url, node)
|
||||
{
|
||||
if (!url || !node)
|
||||
return "";
|
||||
|
||||
var urlArr = new Array(url);
|
||||
var doc = node.ownerDocument;
|
||||
|
||||
if (node.nodeType == Node.ATTRIBUTE_NODE)
|
||||
node = node.ownerElement;
|
||||
|
||||
while (node && node.nodeType == Node.ELEMENT_NODE) {
|
||||
if (node.getAttributeNS(XMLNS, "base") != "")
|
||||
urlArr.unshift(node.getAttributeNS(XMLNS, "base"));
|
||||
|
||||
node = node.parentNode;
|
||||
}
|
||||
|
||||
// Look for a <base>.
|
||||
var baseTags = getHTMLElements(doc,"base");
|
||||
if (baseTags && baseTags.length) {
|
||||
urlArr.unshift(baseTags[baseTags.length - 1].getAttribute("href"));
|
||||
}
|
||||
|
||||
// resolve everything from bottom up, starting with document location
|
||||
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
var URL = ioService.newURI(doc.location.href, null, null);
|
||||
for (var i=0; i<urlArr.length; i++) {
|
||||
URL.spec = URL.resolve(urlArr[i]);
|
||||
}
|
||||
|
||||
return URL.spec;
|
||||
}
|
||||
|
||||
function getHTMLElements(node, name)
|
||||
{
|
||||
if (htmlMode)
|
||||
|
|
Загрузка…
Ссылка в новой задаче