зеркало из https://github.com/mozilla/pjs.git
Fixed broken smileys in Mail Composer. b=70031, r=suresh, sr=kin
This commit is contained in:
Родитель
f7d4cd3d5d
Коммит
53953ee690
|
@ -3100,18 +3100,13 @@ var nsSetSmiley =
|
||||||
{
|
{
|
||||||
isCommandEnabled: function(aCommand, dummy)
|
isCommandEnabled: function(aCommand, dummy)
|
||||||
{
|
{
|
||||||
return ( window.editorShell && window.editorShell.documentEditable && IsEditingRenderedHTML());
|
return (IsDocumentEditable() && IsEditingRenderedHTML());
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getCommandStateParams: function(aCommand, aParams, aRefCon) {},
|
getCommandStateParams: function(aCommand, aParams, aRefCon) {},
|
||||||
doCommandParams: function(aCommand, aParams, aRefCon) {},
|
doCommandParams: function(aCommand, aParams, aRefCon)
|
||||||
|
|
||||||
doCommand: function(aCommand)
|
|
||||||
{
|
{
|
||||||
|
var smileyCode = aParams.getCStringValue("state_attribute");
|
||||||
var commandNode = document.getElementById(aCommand);
|
|
||||||
var smileyCode = commandNode.getAttribute("state");
|
|
||||||
|
|
||||||
var strSml;
|
var strSml;
|
||||||
switch(smileyCode)
|
switch(smileyCode)
|
||||||
|
@ -3136,19 +3131,12 @@ var nsSetSmiley =
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var selection = window.editorShell.editorSelection;
|
var editor = GetCurrentEditor();
|
||||||
|
var selection = editor.selection;
|
||||||
if (!selection)
|
var extElement = editor.createElementWithDefaults("span");
|
||||||
return;
|
|
||||||
|
|
||||||
var extElement = editorShell.CreateElementWithDefaults("span");
|
|
||||||
if (!extElement)
|
|
||||||
return;
|
|
||||||
|
|
||||||
extElement.setAttribute("class", "moz-smiley-" + strSml);
|
extElement.setAttribute("class", "moz-smiley-" + strSml);
|
||||||
|
|
||||||
|
var intElement = editor.createElementWithDefaults("span");
|
||||||
var intElement = editorShell.CreateElementWithDefaults("span");
|
|
||||||
if (!intElement)
|
if (!intElement)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -3157,7 +3145,7 @@ var nsSetSmiley =
|
||||||
if (smileButMenu.getAttribute("padwithspace"))
|
if (smileButMenu.getAttribute("padwithspace"))
|
||||||
smileyCode = " " + smileyCode + " ";
|
smileyCode = " " + smileyCode + " ";
|
||||||
|
|
||||||
var txtElement = document.createTextNode(smileyCode);
|
var txtElement = editor.document.createTextNode(smileyCode);
|
||||||
if (!txtElement)
|
if (!txtElement)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -3165,7 +3153,7 @@ var nsSetSmiley =
|
||||||
extElement.appendChild (intElement);
|
extElement.appendChild (intElement);
|
||||||
|
|
||||||
|
|
||||||
editorShell.InsertElementAtSelection(extElement,true);
|
editor.insertElementAtSelection(extElement,true);
|
||||||
window._content.focus();
|
window._content.focus();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3173,9 +3161,9 @@ var nsSetSmiley =
|
||||||
{
|
{
|
||||||
dump("Exception occured in smiley InsertElementAtSelection\n");
|
dump("Exception occured in smiley InsertElementAtSelection\n");
|
||||||
}
|
}
|
||||||
|
},
|
||||||
}
|
// This is now deprecated in favor of "doCommandParams"
|
||||||
|
doCommand: function(aCommand) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,20 +43,20 @@
|
||||||
|
|
||||||
function EditorGetText()
|
function EditorGetText()
|
||||||
{
|
{
|
||||||
if (editorShell) {
|
try {
|
||||||
dump("Getting text\n");
|
dump("Getting text\n");
|
||||||
var outputText = GetCurrentEditor().outputToString("text/plain", 2);
|
var outputText = GetCurrentEditor().outputToString("text/plain", 2);
|
||||||
dump("<<" + outputText + ">>\n");
|
dump("<<" + outputText + ">>\n");
|
||||||
}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
function EditorGetHTML()
|
function EditorGetHTML()
|
||||||
{
|
{
|
||||||
if (editorShell) {
|
try {
|
||||||
dump("Getting HTML\n");
|
dump("Getting HTML\n");
|
||||||
var outputHTML = GetCurrentEditor().outputToString("text/html", 256);
|
var outputHTML = GetCurrentEditor().outputToString("text/html", 256);
|
||||||
dump(outputHTML + "\n");
|
dump(outputHTML + "\n");
|
||||||
}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
function EditorDumpContent()
|
function EditorDumpContent()
|
||||||
|
|
|
@ -63,7 +63,6 @@ const kHTMLMimeType = "text/html";
|
||||||
|
|
||||||
var gPreviousNonSourceDisplayMode = 1;
|
var gPreviousNonSourceDisplayMode = 1;
|
||||||
var gEditorDisplayMode = -1;
|
var gEditorDisplayMode = -1;
|
||||||
var WebCompose = false; // Set true for Web Composer, leave false for Messenger Composer
|
|
||||||
var docWasModified = false; // Check if clean document, if clean then unload when user "Opens"
|
var docWasModified = false; // Check if clean document, if clean then unload when user "Opens"
|
||||||
var gContentWindow = 0;
|
var gContentWindow = 0;
|
||||||
var gSourceContentWindow = 0;
|
var gSourceContentWindow = 0;
|
||||||
|
@ -164,7 +163,6 @@ function EditorOnLoad()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WebCompose = true;
|
|
||||||
window.tryToClose = EditorCanClose;
|
window.tryToClose = EditorCanClose;
|
||||||
|
|
||||||
// Continue with normal startup.
|
// Continue with normal startup.
|
||||||
|
@ -207,6 +205,26 @@ function IsEditingRenderedHTML()
|
||||||
return isHTMLEditor() && !IsInHTMLSourceMode();
|
return isHTMLEditor() && !IsInHTMLSourceMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function IsWebComposer()
|
||||||
|
{
|
||||||
|
return document.getElementById("WebComposerWindow") != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function IsDocumentEditable()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return GetCurrentEditor().isDocumentEditable;
|
||||||
|
} catch (e) {}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function IsDocumentModified()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return GetCurrentEditor().documentModified;
|
||||||
|
} catch(e) {}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var DocumentReloadListener =
|
var DocumentReloadListener =
|
||||||
{
|
{
|
||||||
|
@ -234,56 +252,6 @@ function addEditorClickEventListener()
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
function DoWindowCommandControllerSetting(aEditor)
|
|
||||||
{
|
|
||||||
// Get the window command controller created in SetupComposerWindowCommands()
|
|
||||||
if (gComposerWindowControllerID != -1)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
var controller = window.controllers.getControllerById(gComposerWindowControllerID);
|
|
||||||
controller.SetCommandRefCon(aEditor.QueryInterface(Components.interfaces.nsISupports));
|
|
||||||
} catch (e) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var MessageComposeDocumentStateListener =
|
|
||||||
{
|
|
||||||
NotifyDocumentCreated: function()
|
|
||||||
{
|
|
||||||
gEditor = editorShell.editor;
|
|
||||||
|
|
||||||
// do all of our QI'ing here so we don't need to do it elsewhere
|
|
||||||
DoAllQueryInterfaceOnEditor();
|
|
||||||
try {
|
|
||||||
gEditor.QueryInterface(Components.interfaces.nsIEditorMailSupport);
|
|
||||||
} catch(e) {}
|
|
||||||
|
|
||||||
// XXX Temporary: This should be set during startup
|
|
||||||
// once we finish transition from nsIEditorShell is to nsIEditorSession
|
|
||||||
try {
|
|
||||||
gEditor.contentsMIMEType = gIsHTMLEditor ? kHTMLMimeType : kTextMimeType;
|
|
||||||
} catch(e) {}
|
|
||||||
|
|
||||||
addEditorClickEventListener();
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Add the base sheet for editor cursor etc.
|
|
||||||
gEditor.addOverrideStyleSheet(kBaseEditorStyleSheet);
|
|
||||||
} catch (e) {}
|
|
||||||
},
|
|
||||||
|
|
||||||
NotifyDocumentWillBeDestroyed: function()
|
|
||||||
{
|
|
||||||
// note that the editor seems to be gone at this point
|
|
||||||
// so we don't have a way to remove the click listener.
|
|
||||||
// hopefully it is being cleaned up with all listeners
|
|
||||||
},
|
|
||||||
|
|
||||||
NotifyDocumentStateChanged:function()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function DoAllQueryInterfaceOnEditor()
|
function DoAllQueryInterfaceOnEditor()
|
||||||
{
|
{
|
||||||
// do QI here so the interfaces will be accessible on gEditor
|
// do QI here so the interfaces will be accessible on gEditor
|
||||||
|
@ -303,23 +271,66 @@ function DoAllQueryInterfaceOnEditor()
|
||||||
|
|
||||||
// This is called when the real editor document is created,
|
// This is called when the real editor document is created,
|
||||||
// before it's loaded.
|
// before it's loaded.
|
||||||
|
// IMPORTANT: This is used by ALL Composers, so be careful!
|
||||||
var DocumentStateListener =
|
var DocumentStateListener =
|
||||||
{
|
{
|
||||||
NotifyDocumentCreated: function()
|
NotifyDocumentCreated: function()
|
||||||
{
|
{
|
||||||
gEditor = editorShell.editor;
|
gEditor = editorShell.editor;
|
||||||
|
|
||||||
DoWindowCommandControllerSetting(gEditor);
|
// Just for convenience
|
||||||
|
gContentWindow = window._content;
|
||||||
|
|
||||||
// do all of our QI'ing here so we don't need to do it elsewhere
|
// do all of our QI'ing here so we don't need to do it elsewhere
|
||||||
DoAllQueryInterfaceOnEditor();
|
DoAllQueryInterfaceOnEditor();
|
||||||
|
|
||||||
|
if (editorShell.editorType == "htmlmail"
|
||||||
|
|| editorShell.editorType == "textmail")
|
||||||
|
{
|
||||||
|
gEditor.QueryInterface(Components.interfaces.nsIEditorMailSupport);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Mail Composers start focus in address area
|
||||||
|
gContentWindow.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!("InsertCharWindow" in window))
|
||||||
|
window.InsertCharWindow = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Add the base sheets for editor cursor etc.
|
||||||
|
gEditor.addOverrideStyleSheet(kBaseEditorStyleSheet);
|
||||||
|
|
||||||
|
// and extra styles for showing anchors, table borders, smileys, etc
|
||||||
|
gEditor.addOverrideStyleSheet(kNormalStyleSheet);
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
// XXX Temporary: This should be set during startup
|
// XXX Temporary: This should be set during startup
|
||||||
// once we finish transition from nsIEditorShell is to nsIEditorSession
|
// once we finish transition from nsIEditorShell is to nsIEditorSession
|
||||||
try {
|
try {
|
||||||
gEditor.contentsMIMEType = gIsHTMLEditor ? kHTMLMimeType : kTextMimeType;
|
gEditor.contentsMIMEType = gIsHTMLEditor ? kHTMLMimeType : kTextMimeType;
|
||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
|
|
||||||
|
// Add mouse click watcher if right type of editor
|
||||||
|
if (isHTMLEditor())
|
||||||
|
addEditorClickEventListener();
|
||||||
|
|
||||||
|
// udpate menu items now that we have an editor to play with
|
||||||
|
window.updateCommands("create");
|
||||||
|
|
||||||
|
// Do the rest only if a Web Composer application
|
||||||
|
if (IsWebComposer())
|
||||||
|
{
|
||||||
|
// Get the window command controller created in SetupComposerWindowCommands()
|
||||||
|
if (gComposerWindowControllerID != -1)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
var controller = window.controllers.getControllerById(gComposerWindowControllerID);
|
||||||
|
controller.SetCommandRefCon(gEditor.QueryInterface(Components.interfaces.nsISupports));
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
|
||||||
// Call EditorSetDefaultPrefsAndDoctype first so it gets the default author before initing toolbars
|
// Call EditorSetDefaultPrefsAndDoctype first so it gets the default author before initing toolbars
|
||||||
EditorSetDefaultPrefsAndDoctype();
|
EditorSetDefaultPrefsAndDoctype();
|
||||||
EditorInitToolbars();
|
EditorInitToolbars();
|
||||||
|
@ -329,32 +340,13 @@ var DocumentStateListener =
|
||||||
UpdateWindowTitle();
|
UpdateWindowTitle();
|
||||||
BuildRecentMenu();
|
BuildRecentMenu();
|
||||||
|
|
||||||
// Just for convenience
|
|
||||||
gContentWindow = window._content;
|
|
||||||
gContentWindow.focus();
|
|
||||||
|
|
||||||
// udpate menu items now that we have an editor to play with
|
|
||||||
// Note: This must be AFTER gContentWindow.focus();
|
|
||||||
window.updateCommands("create");
|
|
||||||
|
|
||||||
if (!("InsertCharWindow" in window))
|
|
||||||
window.InsertCharWindow = null;
|
|
||||||
|
|
||||||
// We must wait until document is created to get proper Url
|
// We must wait until document is created to get proper Url
|
||||||
// (Windows may load with local file paths)
|
// (Windows may load with local file paths)
|
||||||
SetSaveAndPublishUI(GetDocumentUrl());
|
SetSaveAndPublishUI(GetDocumentUrl());
|
||||||
|
|
||||||
// Add mouse click watcher if right type of editor
|
|
||||||
if (isHTMLEditor())
|
|
||||||
addEditorClickEventListener();
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Add the base sheet for editor cursor etc.
|
|
||||||
gEditor.addOverrideStyleSheet(kBaseEditorStyleSheet);
|
|
||||||
} catch (e) {}
|
|
||||||
|
|
||||||
// Start in "Normal" edit mode
|
// Start in "Normal" edit mode
|
||||||
SetDisplayMode(kDisplayModeNormal);
|
SetDisplayMode(kDisplayModeNormal);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// note that the editor seems to be gone at this point
|
// note that the editor seems to be gone at this point
|
||||||
|
@ -466,6 +458,7 @@ function EditorSharedStartup()
|
||||||
// So we can't use gEditor.AddDocumentStateListener here.
|
// So we can't use gEditor.AddDocumentStateListener here.
|
||||||
if (gIsHTMLEditor)
|
if (gIsHTMLEditor)
|
||||||
{
|
{
|
||||||
|
//XXX this is replaced by nsIEditor::contentsMIMEType
|
||||||
editorShell.contentsMIMEType = kHTMLMimeType;
|
editorShell.contentsMIMEType = kHTMLMimeType;
|
||||||
SetupHTMLEditorCommands();
|
SetupHTMLEditorCommands();
|
||||||
}
|
}
|
||||||
|
@ -476,10 +469,6 @@ function EditorSharedStartup()
|
||||||
}
|
}
|
||||||
|
|
||||||
// add a listener to be called when document is really done loading
|
// add a listener to be called when document is really done loading
|
||||||
if (editorShell.editorType == "htmlmail"
|
|
||||||
|| editorShell.editorType == "textmail")
|
|
||||||
editorShell.RegisterDocumentStateListener( MessageComposeDocumentStateListener );
|
|
||||||
else
|
|
||||||
editorShell.RegisterDocumentStateListener( DocumentStateListener );
|
editorShell.RegisterDocumentStateListener( DocumentStateListener );
|
||||||
|
|
||||||
var isMac = (GetOS() == gMac);
|
var isMac = (GetOS() == gMac);
|
||||||
|
@ -1423,10 +1412,11 @@ function EditorClick(event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// In Show All Tags Mode,
|
// For Web Composer: In Show All Tags Mode,
|
||||||
// single click selects entire element,
|
// single click selects entire element,
|
||||||
// except for body and table elements
|
// except for body and table elements
|
||||||
if (event.target && isHTMLEditor() && gEditorDisplayMode == kDisplayModeAllTags)
|
if (event.target && IsWebComposer()
|
||||||
|
&& isHTMLEditor() && gEditorDisplayMode == kDisplayModeAllTags)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1813,7 +1803,7 @@ function UpdateWindowTitle()
|
||||||
windowTitle += " [" + scheme + ":/.../" + filename + "]";
|
windowTitle += " [" + scheme + ":/.../" + filename + "]";
|
||||||
}
|
}
|
||||||
// Set window title with " - Composer" appended
|
// Set window title with " - Composer" appended
|
||||||
var xulWin = document.getElementById("editorWindow");
|
var xulWin = document.getElementById("WebComposerWindow");
|
||||||
window.title = windowTitle + xulWin.getAttribute("titlemenuseparator") + xulWin.getAttribute("titlemodifier");
|
window.title = windowTitle + xulWin.getAttribute("titlemenuseparator") + xulWin.getAttribute("titlemodifier");
|
||||||
|
|
||||||
// Save changed title in the recent pages data in prefs
|
// Save changed title in the recent pages data in prefs
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
%brandDTD;
|
%brandDTD;
|
||||||
]>
|
]>
|
||||||
|
|
||||||
<window id="editorWindow"
|
<window id="WebComposerWindow"
|
||||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||||
onload="EditorOnLoad()"
|
onload="EditorOnLoad()"
|
||||||
onunload="EditorShutdown()"
|
onunload="EditorShutdown()"
|
||||||
|
|
Загрузка…
Ссылка в новой задаче