Bug 1839115 - Expose nsMsgCompose::_NodeTreeConvertible to JS. r=mkmelin
Differential Revision: https://phabricator.services.mozilla.com/D181355 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
f2654ec93e
Коммит
01922ec13f
|
@ -65,6 +65,33 @@ async function checkMsgFile(aFilePath, aConvertibility) {
|
|||
await BrowserTestUtils.closeWindow(messageController.window);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests nodeTreeConvertible() can be called from JavaScript.
|
||||
*/
|
||||
add_task(async function test_msg_nodeTreeConvertible() {
|
||||
let msgCompose = Cc["@mozilla.org/messengercompose/compose;1"].createInstance(
|
||||
Ci.nsIMsgCompose
|
||||
);
|
||||
|
||||
let textDoc = new DOMParser().parseFromString(
|
||||
"<p>Simple Text</p>",
|
||||
"text/html"
|
||||
);
|
||||
Assert.equal(
|
||||
msgCompose.nodeTreeConvertible(textDoc.documentElement),
|
||||
Ci.nsIMsgCompConvertible.Plain
|
||||
);
|
||||
|
||||
let htmlDoc = new DOMParser().parseFromString(
|
||||
'<p>Complex <span style="font-weight: bold">Text</span></p>',
|
||||
"text/html"
|
||||
);
|
||||
Assert.equal(
|
||||
msgCompose.nodeTreeConvertible(htmlDoc.documentElement),
|
||||
Ci.nsIMsgCompConvertible.No
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* Tests that we only open one compose window for one instance of a draft.
|
||||
*/
|
||||
|
|
|
@ -20,6 +20,8 @@ interface mozIDOMWindowProxy;
|
|||
interface nsIEditor;
|
||||
interface nsIMsgWindow;
|
||||
|
||||
webidl Element;
|
||||
|
||||
typedef long MSG_ComposeSaveType;
|
||||
|
||||
[scriptable, uuid(6953e50a-7531-11d3-85fe-006008948010)]
|
||||
|
@ -169,6 +171,13 @@ interface nsIMsgCompose : nsIMsgSendListener {
|
|||
*/
|
||||
long bodyConvertible();
|
||||
|
||||
/**
|
||||
* The level of "convertibility" of the provided node to plaintext.
|
||||
*
|
||||
* @return a value from nsIMsgCompConvertible.
|
||||
*/
|
||||
long nodeTreeConvertible(in Element aNode);
|
||||
|
||||
/**
|
||||
* The identity currently selected for the message compose object. When set
|
||||
* this may change the signature on a message being composed. Note that
|
||||
|
|
|
@ -4715,7 +4715,9 @@ void nsMsgCompose::TagConvertible(Element* node, int32_t* _retval) {
|
|||
/**
|
||||
* Note: Helper function. Parameters are not checked.
|
||||
*/
|
||||
void nsMsgCompose::_NodeTreeConvertible(Element* node, int32_t* _retval) {
|
||||
NS_IMETHODIMP
|
||||
nsMsgCompose::NodeTreeConvertible(Element* node, int32_t* _retval) {
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
int32_t result;
|
||||
|
||||
// Check this node
|
||||
|
@ -4730,13 +4732,14 @@ void nsMsgCompose::_NodeTreeConvertible(Element* node, int32_t* _retval) {
|
|||
nsCOMPtr<Element> domElement = do_QueryInterface(pItem);
|
||||
if (domElement) {
|
||||
int32_t curresult;
|
||||
_NodeTreeConvertible(domElement, &curresult);
|
||||
NodeTreeConvertible(domElement, &curresult);
|
||||
|
||||
if (curresult > result) result = curresult;
|
||||
}
|
||||
}
|
||||
|
||||
*_retval = result;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -4752,8 +4755,7 @@ nsMsgCompose::BodyConvertible(int32_t* _retval) {
|
|||
// get the top level element, which contains <html>
|
||||
nsCOMPtr<Element> rootElement = rootDocument->GetDocumentElement();
|
||||
if (!rootElement) return NS_ERROR_UNEXPECTED;
|
||||
|
||||
_NodeTreeConvertible(rootElement, _retval);
|
||||
NodeTreeConvertible(rootElement, _retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,6 @@ class nsMsgCompose : public nsIMsgCompose, public nsSupportsWeakReference {
|
|||
nsTArray<nsMsgMailList>& mailListResolved,
|
||||
nsTArray<nsMsgRecipient>& aListMembers);
|
||||
void TagConvertible(mozilla::dom::Element* node, int32_t* _retval);
|
||||
void _NodeTreeConvertible(mozilla::dom::Element* node, int32_t* _retval);
|
||||
MOZ_CAN_RUN_SCRIPT nsresult MoveToAboveQuote(void);
|
||||
MOZ_CAN_RUN_SCRIPT nsresult MoveToBeginningOfDocument(void);
|
||||
MOZ_CAN_RUN_SCRIPT nsresult MoveToEndOfDocument(void);
|
||||
|
|
Загрузка…
Ссылка в новой задаче