Composer was inserting charset information (meta element) after the title of the document; b=145952, r=brade, sr=peterv, a=asa

This commit is contained in:
glazman%netscape.com 2002-10-14 20:14:40 +00:00
Родитель ff192a3bde
Коммит ef94ee2c0f
4 изменённых файлов: 32 добавлений и 15 удалений

Просмотреть файл

@ -2242,15 +2242,6 @@ function EditorSetDefaultPrefsAndDoctype()
domdoc.insertAfter(headelement, domdoc.firstChild);
}
// add title tag if not present
var titlenodelist = gEditor.document.getElementsByTagName("title");
if (headelement && titlenodelist && titlenodelist.length == 0)
{
titleElement = domdoc.createElement("title");
if (titleElement)
headelement.appendChild(titleElement);
}
/* only set default prefs for new documents */
if (!IsUrlAboutBlank(GetDocumentUrl()))
return;
@ -2281,7 +2272,7 @@ function EditorSetDefaultPrefsAndDoctype()
{
element.setAttribute("http-equiv", "content-type");
element.setAttribute("content", "text/html; charset=" + prefCharsetString);
headelement.appendChild( element );
headelement.insertBefore( element, headelement.firstChild );
}
}
@ -2326,6 +2317,15 @@ function EditorSetDefaultPrefsAndDoctype()
}
}
// add title tag if not present
var titlenodelist = gEditor.document.getElementsByTagName("title");
if (headelement && titlenodelist && titlenodelist.length == 0)
{
titleElement = domdoc.createElement("title");
if (titleElement)
headelement.appendChild(titleElement);
}
// Get editor color prefs
var use_custom_colors = false;
try {

Просмотреть файл

@ -634,7 +634,7 @@ function CreateHTTPEquivElement(name)
// Change "content" attribute on a META element,
// or delete entire element it if content is empty
// This uses undoable editor transactions
function SetMetaElementContent(metaElement, content, insertNew)
function SetMetaElementContent(metaElement, content, insertNew, prepend)
{
if (metaElement)
{
@ -650,7 +650,10 @@ function SetMetaElementContent(metaElement, content, insertNew)
if (insertNew)
{
metaElement.setAttribute("content", content);
AppendHeadElement(metaElement);
if (prepend)
PrependHeadElement(metaElement);
else
AppendHeadElement(metaElement);
}
else
editor.setAttribute(metaElement, "content", content);
@ -670,6 +673,20 @@ function GetHeadElement()
return null;
}
function PrependHeadElement(element)
{
var head = GetHeadElement();
if (head)
{
var editor = GetCurrentEditor();
try {
// Use editor's undoable transaction
// Last param "true" says "don't change the selection"
editor.insertNode(element, head, 0, true);
} catch (e) {}
}
}
function AppendHeadElement(element)
{
var head = GetHeadElement();

Просмотреть файл

@ -172,10 +172,10 @@ function onAccept()
SetDocumentTitle(gNewTitle);
if (gAuthorWasEdited)
SetMetaElementContent(gAuthorElement, gAuthor, gInsertNewAuthor);
SetMetaElementContent(gAuthorElement, gAuthor, gInsertNewAuthor, false);
if (gDescWasEdited)
SetMetaElementContent(gDescriptionElement, gDescription, gInsertNewDescription);
SetMetaElementContent(gDescriptionElement, gDescription, gInsertNewDescription, false);
editor.endTransaction();

Просмотреть файл

@ -106,7 +106,7 @@ function onAccept()
if(gCharsetWasChanged)
{
try {
SetMetaElementContent(gContenttypeElement, "text/html; charset=" + gCharset, gInsertNewContentType);
SetMetaElementContent(gContenttypeElement, "text/html; charset=" + gCharset, gInsertNewContentType, true);
editor.documentCharacterSet = gCharset;
} catch (e) {}
}