зеркало из 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)
|
||||
{
|
||||
return ( window.editorShell && window.editorShell.documentEditable && IsEditingRenderedHTML());
|
||||
|
||||
return (IsDocumentEditable() && IsEditingRenderedHTML());
|
||||
},
|
||||
|
||||
getCommandStateParams: function(aCommand, aParams, aRefCon) {},
|
||||
doCommandParams: function(aCommand, aParams, aRefCon) {},
|
||||
|
||||
doCommand: function(aCommand)
|
||||
doCommandParams: function(aCommand, aParams, aRefCon)
|
||||
{
|
||||
|
||||
var commandNode = document.getElementById(aCommand);
|
||||
var smileyCode = commandNode.getAttribute("state");
|
||||
var smileyCode = aParams.getCStringValue("state_attribute");
|
||||
|
||||
var strSml;
|
||||
switch(smileyCode)
|
||||
|
@ -3136,19 +3131,12 @@ var nsSetSmiley =
|
|||
|
||||
try
|
||||
{
|
||||
var selection = window.editorShell.editorSelection;
|
||||
|
||||
if (!selection)
|
||||
return;
|
||||
|
||||
var extElement = editorShell.CreateElementWithDefaults("span");
|
||||
if (!extElement)
|
||||
return;
|
||||
|
||||
var editor = GetCurrentEditor();
|
||||
var selection = editor.selection;
|
||||
var extElement = editor.createElementWithDefaults("span");
|
||||
extElement.setAttribute("class", "moz-smiley-" + strSml);
|
||||
|
||||
|
||||
var intElement = editorShell.CreateElementWithDefaults("span");
|
||||
var intElement = editor.createElementWithDefaults("span");
|
||||
if (!intElement)
|
||||
return;
|
||||
|
||||
|
@ -3157,7 +3145,7 @@ var nsSetSmiley =
|
|||
if (smileButMenu.getAttribute("padwithspace"))
|
||||
smileyCode = " " + smileyCode + " ";
|
||||
|
||||
var txtElement = document.createTextNode(smileyCode);
|
||||
var txtElement = editor.document.createTextNode(smileyCode);
|
||||
if (!txtElement)
|
||||
return;
|
||||
|
||||
|
@ -3165,7 +3153,7 @@ var nsSetSmiley =
|
|||
extElement.appendChild (intElement);
|
||||
|
||||
|
||||
editorShell.InsertElementAtSelection(extElement,true);
|
||||
editor.insertElementAtSelection(extElement,true);
|
||||
window._content.focus();
|
||||
|
||||
}
|
||||
|
@ -3173,9 +3161,9 @@ var nsSetSmiley =
|
|||
{
|
||||
dump("Exception occured in smiley InsertElementAtSelection\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
// This is now deprecated in favor of "doCommandParams"
|
||||
doCommand: function(aCommand) {}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -43,20 +43,20 @@
|
|||
|
||||
function EditorGetText()
|
||||
{
|
||||
if (editorShell) {
|
||||
try {
|
||||
dump("Getting text\n");
|
||||
var outputText = GetCurrentEditor().outputToString("text/plain", 2);
|
||||
dump("<<" + outputText + ">>\n");
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
function EditorGetHTML()
|
||||
{
|
||||
if (editorShell) {
|
||||
try {
|
||||
dump("Getting HTML\n");
|
||||
var outputHTML = GetCurrentEditor().outputToString("text/html", 256);
|
||||
dump(outputHTML + "\n");
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
function EditorDumpContent()
|
||||
|
|
|
@ -63,7 +63,6 @@ const kHTMLMimeType = "text/html";
|
|||
|
||||
var gPreviousNonSourceDisplayMode = 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 gContentWindow = 0;
|
||||
var gSourceContentWindow = 0;
|
||||
|
@ -164,7 +163,6 @@ function EditorOnLoad()
|
|||
}
|
||||
}
|
||||
|
||||
WebCompose = true;
|
||||
window.tryToClose = EditorCanClose;
|
||||
|
||||
// Continue with normal startup.
|
||||
|
@ -207,6 +205,26 @@ function IsEditingRenderedHTML()
|
|||
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 =
|
||||
{
|
||||
|
@ -234,56 +252,6 @@ function addEditorClickEventListener()
|
|||
} 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()
|
||||
{
|
||||
// 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,
|
||||
// before it's loaded.
|
||||
// IMPORTANT: This is used by ALL Composers, so be careful!
|
||||
var DocumentStateListener =
|
||||
{
|
||||
NotifyDocumentCreated: function()
|
||||
{
|
||||
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
|
||||
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
|
||||
// once we finish transition from nsIEditorShell is to nsIEditorSession
|
||||
try {
|
||||
gEditor.contentsMIMEType = gIsHTMLEditor ? kHTMLMimeType : kTextMimeType;
|
||||
} 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
|
||||
EditorSetDefaultPrefsAndDoctype();
|
||||
EditorInitToolbars();
|
||||
|
@ -329,32 +340,13 @@ var DocumentStateListener =
|
|||
UpdateWindowTitle();
|
||||
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
|
||||
// (Windows may load with local file paths)
|
||||
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
|
||||
SetDisplayMode(kDisplayModeNormal);
|
||||
}
|
||||
},
|
||||
|
||||
// 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.
|
||||
if (gIsHTMLEditor)
|
||||
{
|
||||
//XXX this is replaced by nsIEditor::contentsMIMEType
|
||||
editorShell.contentsMIMEType = kHTMLMimeType;
|
||||
SetupHTMLEditorCommands();
|
||||
}
|
||||
|
@ -476,10 +469,6 @@ function EditorSharedStartup()
|
|||
}
|
||||
|
||||
// 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 );
|
||||
|
||||
var isMac = (GetOS() == gMac);
|
||||
|
@ -1423,10 +1412,11 @@ function EditorClick(event)
|
|||
return;
|
||||
}
|
||||
|
||||
// In Show All Tags Mode,
|
||||
// For Web Composer: In Show All Tags Mode,
|
||||
// single click selects entire element,
|
||||
// except for body and table elements
|
||||
if (event.target && isHTMLEditor() && gEditorDisplayMode == kDisplayModeAllTags)
|
||||
if (event.target && IsWebComposer()
|
||||
&& isHTMLEditor() && gEditorDisplayMode == kDisplayModeAllTags)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -1813,7 +1803,7 @@ function UpdateWindowTitle()
|
|||
windowTitle += " [" + scheme + ":/.../" + filename + "]";
|
||||
}
|
||||
// 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");
|
||||
|
||||
// Save changed title in the recent pages data in prefs
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
%brandDTD;
|
||||
]>
|
||||
|
||||
<window id="editorWindow"
|
||||
<window id="WebComposerWindow"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="EditorOnLoad()"
|
||||
onunload="EditorShutdown()"
|
||||
|
|
Загрузка…
Ссылка в новой задаче