зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1539356 - Mark EditorBase::InsertNodeTransaction() as MOZ_CAN_RUN_SCRIPT r=m_kato
This patch marks `EditorBase::InsertNodeTransaction()` **and** its callers as `MOZ_CAN_RUN_SCRIPT`. Unfortunately, this patch tells us that some `GetSomething()` methods may destroy the editor since `HTMLEditRules::GetNodesForOperation()`, `HTMLEditRules::GetNodesFromPoint()` and `HTMLEditRules::GetNodesFromSelection()` may change the DOM tree. Additionally, initialization methods may destroy the editor since it may insert a bogus `<br>` node. Note that this patch also removes some unused methods. I.e., they are not result of some cleaning up the code. This patch just avoids marking unused methods as `MOZ_CAN_RUN_SCRIPT`. Differential Revision: https://phabricator.services.mozilla.com/D25027 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
624de11cb1
Коммит
81b30d7143
|
@ -58,23 +58,6 @@ bool nsDocShellEditorData::GetEditable() {
|
|||
return mMakeEditable || (mHTMLEditor != nullptr);
|
||||
}
|
||||
|
||||
nsresult nsDocShellEditorData::CreateEditor() {
|
||||
nsCOMPtr<nsIEditingSession> editingSession;
|
||||
nsresult rv = GetEditingSession(getter_AddRefs(editingSession));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowOuter> domWindow =
|
||||
mDocShell ? mDocShell->GetWindow() : nullptr;
|
||||
rv = editingSession->SetupEditorOnWindow(domWindow);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsDocShellEditorData::GetEditingSession(nsIEditingSession** aResult) {
|
||||
EnsureEditingSession();
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ class nsDocShellEditorData {
|
|||
|
||||
nsresult MakeEditable(bool aWaitForUriLoad);
|
||||
bool GetEditable();
|
||||
nsresult CreateEditor();
|
||||
nsresult GetEditingSession(nsIEditingSession** aResult);
|
||||
mozilla::HTMLEditor* GetHTMLEditor() const { return mHTMLEditor; }
|
||||
nsresult SetHTMLEditor(mozilla::HTMLEditor* aHTMLEditor);
|
||||
|
|
|
@ -1345,8 +1345,10 @@ nsresult nsTextEditorState::PrepareEditor(const nsAString* aValue) {
|
|||
// already does the relevant security checks.
|
||||
AutoNoJSAPI nojsapi;
|
||||
|
||||
rv = newTextEditor->Init(*doc, GetRootNode(), mSelCon, editorFlags,
|
||||
defaultValue);
|
||||
RefPtr<Element> rootElement = GetRootNode();
|
||||
RefPtr<nsTextInputSelectionImpl> selectionController = mSelCon;
|
||||
rv = newTextEditor->Init(*doc, rootElement, selectionController,
|
||||
editorFlags, defaultValue);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
|
|
|
@ -72,6 +72,7 @@ class nsEditingSession final : public nsIEditingSession,
|
|||
// progress load stuff
|
||||
nsresult StartDocumentLoad(nsIWebProgress* aWebProgress,
|
||||
bool isToBeMadeEditable);
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||
nsresult EndDocumentLoad(nsIWebProgress* aWebProgress, nsIChannel* aChannel,
|
||||
nsresult aStatus, bool isToBeMadeEditable);
|
||||
nsresult StartPageLoad(nsIChannel* aChannel);
|
||||
|
|
|
@ -47,6 +47,7 @@ interface nsIEditingSession : nsISupports
|
|||
* (or part of it) editable.
|
||||
* @param aInteractive if PR_FALSE turn off scripting and plugins
|
||||
*/
|
||||
[can_run_script]
|
||||
void makeWindowEditable(in mozIDOMWindowProxy window,
|
||||
in string aEditorType,
|
||||
in boolean doAfterUriLoad,
|
||||
|
@ -70,6 +71,7 @@ interface nsIEditingSession : nsISupports
|
|||
/**
|
||||
* Setup editor and related support objects
|
||||
*/
|
||||
[can_run_script]
|
||||
void setupEditorOnWindow(in mozIDOMWindowProxy window);
|
||||
|
||||
/**
|
||||
|
|
|
@ -495,11 +495,10 @@ already_AddRefed<nsComputedDOMStyle> CSSEditUtils::GetComputedStyle(
|
|||
// whole node if it is a span and if its only attribute is _moz_dirty
|
||||
nsresult CSSEditUtils::RemoveCSSInlineStyle(nsINode& aNode, nsAtom* aProperty,
|
||||
const nsAString& aPropertyValue) {
|
||||
RefPtr<Element> element = aNode.AsElement();
|
||||
NS_ENSURE_STATE(element);
|
||||
OwningNonNull<Element> element(*aNode.AsElement());
|
||||
|
||||
// remove the property from the style attribute
|
||||
nsresult rv = RemoveCSSProperty(*element, *aProperty, aPropertyValue);
|
||||
nsresult rv = RemoveCSSProperty(element, *aProperty, aPropertyValue);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!element->IsHTMLElement(nsGkAtoms::span) ||
|
||||
|
@ -507,7 +506,8 @@ nsresult CSSEditUtils::RemoveCSSInlineStyle(nsINode& aNode, nsAtom* aProperty,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
return mHTMLEditor->RemoveContainerWithTransaction(*element);
|
||||
OwningNonNull<HTMLEditor> htmlEditor(*mHTMLEditor);
|
||||
return htmlEditor->RemoveContainerWithTransaction(element);
|
||||
}
|
||||
|
||||
// Answers true if the property can be removed by setting a "none" CSS value
|
||||
|
@ -847,8 +847,9 @@ nsresult CSSEditUtils::RemoveCSSEquivalentToHTMLStyle(
|
|||
// remove the individual CSS inline styles
|
||||
int32_t count = cssPropertyArray.Length();
|
||||
for (int32_t index = 0; index < count; index++) {
|
||||
nsresult rv = RemoveCSSProperty(*aElement, *cssPropertyArray[index],
|
||||
cssValueArray[index], aSuppressTransaction);
|
||||
nsresult rv =
|
||||
RemoveCSSProperty(*aElement, MOZ_KnownLive(*cssPropertyArray[index]),
|
||||
cssValueArray[index], aSuppressTransaction);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
return NS_OK;
|
||||
|
|
|
@ -100,6 +100,7 @@ class CSSEditUtils final {
|
|||
const nsAString& aValue, bool aSuppressTxn = false);
|
||||
nsresult SetCSSPropertyPixels(dom::Element& aElement, nsAtom& aProperty,
|
||||
int32_t aIntValue);
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult RemoveCSSProperty(dom::Element& aElement, nsAtom& aProperty,
|
||||
const nsAString& aPropertyValue,
|
||||
bool aSuppressTxn = false);
|
||||
|
@ -127,6 +128,7 @@ class CSSEditUtils final {
|
|||
* @param aPropertyValue [IN] The value of the property we have to remove
|
||||
* if the property accepts more than one value.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult RemoveCSSInlineStyle(nsINode& aNode, nsAtom* aProperty,
|
||||
const nsAString& aPropertyValue);
|
||||
|
||||
|
@ -258,6 +260,7 @@ class CSSEditUtils final {
|
|||
* @param aSuppressTransaction [IN] A boolean indicating, when true,
|
||||
* that no transaction should be recorded.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult RemoveCSSEquivalentToHTMLStyle(dom::Element* aElement,
|
||||
nsAtom* aHTMLProperty,
|
||||
nsAtom* aAttribute,
|
||||
|
|
|
@ -2372,13 +2372,15 @@ void EditorBase::CloneAttributesWithTransaction(Element& aDestElement,
|
|||
nsAutoString value;
|
||||
attr->GetValue(value);
|
||||
if (isDestElementInBody) {
|
||||
SetAttributeOrEquivalent(destElement, attr->NodeInfo()->NameAtom(), value,
|
||||
false);
|
||||
SetAttributeOrEquivalent(destElement,
|
||||
MOZ_KnownLive(attr->NodeInfo()->NameAtom()),
|
||||
value, false);
|
||||
} else {
|
||||
// The element is not inserted in the document yet, we don't want to put
|
||||
// a transaction on the UndoStack
|
||||
SetAttributeOrEquivalent(destElement, attr->NodeInfo()->NameAtom(), value,
|
||||
true);
|
||||
SetAttributeOrEquivalent(destElement,
|
||||
MOZ_KnownLive(attr->NodeInfo()->NameAtom()),
|
||||
value, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -171,6 +171,7 @@ class EditorBase : public nsIEditor,
|
|||
* @param aFlags A bitmask of flags for specifying the behavior
|
||||
* of the editor.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual nsresult Init(Document& doc, Element* aRoot,
|
||||
nsISelectionController* aSelCon, uint32_t aFlags,
|
||||
const nsAString& aInitialValue);
|
||||
|
@ -885,6 +886,7 @@ class EditorBase : public nsIEditor,
|
|||
* does nothing during composition, returns NS_OK.
|
||||
* Otherwise, an error code.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual nsresult InsertTextWithTransaction(
|
||||
Document& aDocument, const nsAString& aStringToInsert,
|
||||
const EditorRawDOMPoint& aPointToInsert,
|
||||
|
@ -926,9 +928,9 @@ class EditorBase : public nsIEditor,
|
|||
* before child node referred by this.
|
||||
*/
|
||||
template <typename PT, typename CT>
|
||||
nsresult InsertNodeWithTransaction(
|
||||
nsIContent& aContentToInsert,
|
||||
const EditorDOMPointBase<PT, CT>& aPointToInsert);
|
||||
MOZ_CAN_RUN_SCRIPT nsresult
|
||||
InsertNodeWithTransaction(nsIContent& aContentToInsert,
|
||||
const EditorDOMPointBase<PT, CT>& aPointToInsert);
|
||||
|
||||
/**
|
||||
* ReplaceContainerWithTransaction() creates new element whose name is
|
||||
|
@ -939,6 +941,7 @@ class EditorBase : public nsIEditor,
|
|||
* with new element.
|
||||
* @param aTagName The name of new element node.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
already_AddRefed<Element> ReplaceContainerWithTransaction(
|
||||
Element& aOldContainer, nsAtom& aTagName) {
|
||||
return ReplaceContainerWithTransactionInternal(
|
||||
|
@ -955,6 +958,7 @@ class EditorBase : public nsIEditor,
|
|||
* with new element.
|
||||
* @param aTagName The name of new element node.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
already_AddRefed<Element> ReplaceContainerAndCloneAttributesWithTransaction(
|
||||
Element& aOldContainer, nsAtom& aTagName) {
|
||||
return ReplaceContainerWithTransactionInternal(
|
||||
|
@ -973,6 +977,7 @@ class EditorBase : public nsIEditor,
|
|||
* @param aAttribute Attribute name to be set to the new element.
|
||||
* @param aAttributeValue Attribute value to be set to aAttribute.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
already_AddRefed<Element> ReplaceContainerWithTransaction(
|
||||
Element& aOldContainer, nsAtom& aTagName, nsAtom& aAttribute,
|
||||
const nsAString& aAttributeValue) {
|
||||
|
@ -985,6 +990,7 @@ class EditorBase : public nsIEditor,
|
|||
* aSourceElement to aDestElement after removing all attributes in
|
||||
* aDestElement.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
void CloneAttributesWithTransaction(Element& aDestElement,
|
||||
Element& aSourceElement);
|
||||
|
||||
|
@ -994,6 +1000,7 @@ class EditorBase : public nsIEditor,
|
|||
*
|
||||
* @param aElement The element to be removed.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult RemoveContainerWithTransaction(Element& aElement);
|
||||
|
||||
/**
|
||||
|
@ -1010,6 +1017,7 @@ class EditorBase : public nsIEditor,
|
|||
* was.
|
||||
* @return The new element.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
already_AddRefed<Element> InsertContainerWithTransaction(nsIContent& aContent,
|
||||
nsAtom& aTagName) {
|
||||
return InsertContainerWithTransactionInternal(
|
||||
|
@ -1033,6 +1041,7 @@ class EditorBase : public nsIEditor,
|
|||
* @param aAttributeValue Value to be set to aAttribute.
|
||||
* @return The new element.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
already_AddRefed<Element> InsertContainerWithTransaction(
|
||||
nsIContent& aContent, nsAtom& aTagName, nsAtom& aAttribute,
|
||||
const nsAString& aAttributeValue) {
|
||||
|
@ -1075,7 +1084,7 @@ class EditorBase : public nsIEditor,
|
|||
* @param aContent The node to be moved.
|
||||
*/
|
||||
template <typename PT, typename CT>
|
||||
nsresult MoveNodeWithTransaction(
|
||||
MOZ_CAN_RUN_SCRIPT nsresult MoveNodeWithTransaction(
|
||||
nsIContent& aContent, const EditorDOMPointBase<PT, CT>& aPointToInsert);
|
||||
|
||||
/**
|
||||
|
@ -1085,6 +1094,7 @@ class EditorBase : public nsIEditor,
|
|||
* @param aNewContainer The new container which will contain aContent as
|
||||
* its last child.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult MoveNodeToEndWithTransaction(nsIContent& aContent,
|
||||
nsINode& aNewContainer) {
|
||||
EditorRawDOMPoint pointToInsert;
|
||||
|
@ -1171,6 +1181,7 @@ class EditorBase : public nsIEditor,
|
|||
nsresult RemoveAttributeWithTransaction(Element& aElement,
|
||||
nsAtom& aAttribute);
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual nsresult RemoveAttributeOrEquivalent(Element* aElement,
|
||||
nsAtom* aAttribute,
|
||||
bool aSuppressTransaction) = 0;
|
||||
|
@ -1185,6 +1196,7 @@ class EditorBase : public nsIEditor,
|
|||
nsresult SetAttributeWithTransaction(Element& aElement, nsAtom& aAttribute,
|
||||
const nsAString& aValue);
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual nsresult SetAttributeOrEquivalent(Element* aElement,
|
||||
nsAtom* aAttribute,
|
||||
const nsAString& aValue,
|
||||
|
@ -1281,6 +1293,7 @@ class EditorBase : public nsIEditor,
|
|||
* @param aCloneAllAttributes If true, all attributes of aOldContainer will
|
||||
* be copied to the new element.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
already_AddRefed<Element> ReplaceContainerWithTransactionInternal(
|
||||
Element& aElement, nsAtom& aTagName, nsAtom& aAttribute,
|
||||
const nsAString& aAttributeValue, bool aCloneAllAttributes);
|
||||
|
@ -1303,6 +1316,7 @@ class EditorBase : public nsIEditor,
|
|||
* @param aAttributeValue Value to be set to aAttribute.
|
||||
* @return The new element.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
already_AddRefed<Element> InsertContainerWithTransactionInternal(
|
||||
nsIContent& aContent, nsAtom& aTagName, nsAtom& aAttribute,
|
||||
const nsAString& aAttributeValue);
|
||||
|
@ -1739,6 +1753,7 @@ class EditorBase : public nsIEditor,
|
|||
* OnEndHandlingTopLevelEditSubAction() is called after
|
||||
* SetTopLevelEditSubAction() is handled.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual void OnEndHandlingTopLevelEditSubAction();
|
||||
|
||||
/**
|
||||
|
@ -2116,9 +2131,10 @@ class EditorBase : public nsIEditor,
|
|||
}
|
||||
}
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||
~AutoTopLevelEditSubActionNotifier() {
|
||||
if (!mDoNothing) {
|
||||
mEditorBase.OnEndHandlingTopLevelEditSubAction();
|
||||
MOZ_KnownLive(mEditorBase).OnEndHandlingTopLevelEditSubAction();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -74,6 +74,7 @@ class EditorEventListener : public nsIDOMEventListener {
|
|||
void HandleEndComposition(WidgetCompositionEvent* aCompositionEvent);
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual nsresult MouseDown(dom::MouseEvent* aMouseEvent);
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual nsresult MouseUp(dom::MouseEvent* aMouseEvent) { return NS_OK; }
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual nsresult MouseClick(WidgetMouseEvent* aMouseClickEvent);
|
||||
|
|
|
@ -1343,8 +1343,9 @@ nsresult HTMLEditRules::WillInsertText(EditSubAction aEditSubAction,
|
|||
}
|
||||
|
||||
if (inString->IsEmpty()) {
|
||||
rv = HTMLEditorRef().InsertTextWithTransaction(
|
||||
*doc, *inString, EditorRawDOMPoint(pointToInsert));
|
||||
rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.InsertTextWithTransaction(*doc, *inString,
|
||||
EditorRawDOMPoint(pointToInsert));
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -1444,9 +1445,10 @@ nsresult HTMLEditRules::WillInsertText(EditSubAction aEditSubAction,
|
|||
"by mutation observer");
|
||||
} else {
|
||||
EditorRawDOMPoint pointAfterInsertedString;
|
||||
rv = HTMLEditorRef().InsertTextWithTransaction(
|
||||
*doc, subStr, EditorRawDOMPoint(currentPoint),
|
||||
&pointAfterInsertedString);
|
||||
rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.InsertTextWithTransaction(*doc, subStr,
|
||||
EditorRawDOMPoint(currentPoint),
|
||||
&pointAfterInsertedString);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -1731,8 +1733,8 @@ EditActionResult HTMLEditRules::WillInsertParagraphSeparator() {
|
|||
// MakeBasicBlock() creates AutoSelectionRestorer.
|
||||
// Therefore, even if it returns NS_OK, editor might have been destroyed
|
||||
// at restoring Selection.
|
||||
OwningNonNull<nsAtom> separatorTag = ParagraphSeparatorElement(separator);
|
||||
nsresult rv = MakeBasicBlock(separatorTag);
|
||||
nsresult rv =
|
||||
MakeBasicBlock(MOZ_KnownLive(ParagraphSeparatorElement(separator)));
|
||||
if (NS_WARN_IF(rv == NS_ERROR_EDITOR_DESTROYED) ||
|
||||
NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return EditActionIgnored(NS_ERROR_EDITOR_DESTROYED);
|
||||
|
@ -1796,9 +1798,9 @@ EditActionResult HTMLEditRules::WillInsertParagraphSeparator() {
|
|||
|
||||
nsCOMPtr<Element> listItem = IsInListItem(blockParent);
|
||||
if (listItem && listItem != host) {
|
||||
nsresult rv =
|
||||
ReturnInListItem(*listItem, *atStartOfSelection.GetContainer(),
|
||||
atStartOfSelection.Offset());
|
||||
nsresult rv = ReturnInListItem(
|
||||
*listItem, MOZ_KnownLive(*atStartOfSelection.GetContainer()),
|
||||
atStartOfSelection.Offset());
|
||||
if (NS_WARN_IF(rv == NS_ERROR_EDITOR_DESTROYED)) {
|
||||
return EditActionIgnored(NS_ERROR_EDITOR_DESTROYED);
|
||||
}
|
||||
|
@ -1965,8 +1967,10 @@ nsresult HTMLEditRules::InsertBRElement(const EditorDOMPoint& aPointToBreak) {
|
|||
// the style from the line above.
|
||||
EditorDOMPoint atSecondBRElement(maybeSecondBRNode);
|
||||
if (brElement->GetNextSibling() != maybeSecondBRNode) {
|
||||
nsresult rv = HTMLEditorRef().MoveNodeWithTransaction(
|
||||
*maybeSecondBRNode->AsContent(), afterBRElement);
|
||||
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeWithTransaction(
|
||||
MOZ_KnownLive(*maybeSecondBRNode->AsContent()),
|
||||
afterBRElement);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -2588,7 +2592,7 @@ nsresult HTMLEditRules::WillDeleteSelection(
|
|||
startPoint.GetContainerAsText() && sibling->GetAsText()) {
|
||||
EditorDOMPoint pt;
|
||||
nsresult rv = JoinNearestEditableNodesWithTransaction(
|
||||
*sibling, *startPoint.GetContainerAsContent(), &pt);
|
||||
*sibling, MOZ_KnownLive(*startPoint.GetContainerAsContent()), &pt);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -2700,7 +2704,8 @@ nsresult HTMLEditRules::WillDeleteSelection(
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
EditActionResult ret = TryToJoinBlocksWithTransaction(
|
||||
*leftNode->AsContent(), *rightNode->AsContent());
|
||||
MOZ_KnownLive(*leftNode->AsContent()),
|
||||
MOZ_KnownLive(*rightNode->AsContent()));
|
||||
*aHandled |= ret.Handled();
|
||||
*aCancel |= ret.Canceled();
|
||||
if (NS_WARN_IF(ret.Failed())) {
|
||||
|
@ -2780,7 +2785,8 @@ nsresult HTMLEditRules::WillDeleteSelection(
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
EditActionResult ret = TryToJoinBlocksWithTransaction(
|
||||
*leftNode->AsContent(), *rightNode->AsContent());
|
||||
MOZ_KnownLive(*leftNode->AsContent()),
|
||||
MOZ_KnownLive(*rightNode->AsContent()));
|
||||
// This should claim that trying to join the block means that
|
||||
// this handles the action because the caller shouldn't do anything
|
||||
// anymore in this case.
|
||||
|
@ -3458,8 +3464,8 @@ EditActionResult HTMLEditRules::TryToJoinBlocksWithTransaction(
|
|||
return EditActionIgnored(NS_ERROR_NULL_POINTER);
|
||||
}
|
||||
|
||||
ret |= MoveBlock(*previousContent.GetContainerAsElement(), *rightBlock,
|
||||
previousContent.Offset(), 0);
|
||||
ret |= MoveBlock(MOZ_KnownLive(*previousContent.GetContainerAsElement()),
|
||||
*rightBlock, previousContent.Offset(), 0);
|
||||
if (NS_WARN_IF(ret.Failed())) {
|
||||
return ret;
|
||||
}
|
||||
|
@ -3509,8 +3515,8 @@ EditActionResult HTMLEditRules::TryToJoinBlocksWithTransaction(
|
|||
return EditActionIgnored(NS_ERROR_EDITOR_DESTROYED);
|
||||
}
|
||||
if (pt.IsSet() && mergeLists) {
|
||||
CreateElementResult convertListTypeResult =
|
||||
ConvertListType(*rightBlock, *existingList, *nsGkAtoms::li);
|
||||
CreateElementResult convertListTypeResult = ConvertListType(
|
||||
*rightBlock, MOZ_KnownLive(*existingList), *nsGkAtoms::li);
|
||||
if (NS_WARN_IF(convertListTypeResult.Rv() == NS_ERROR_EDITOR_DESTROYED)) {
|
||||
return EditActionIgnored(NS_ERROR_EDITOR_DESTROYED);
|
||||
}
|
||||
|
@ -3559,8 +3565,8 @@ EditActionResult HTMLEditRules::MoveBlock(Element& aLeftBlock,
|
|||
// get the node to act on
|
||||
if (IsBlockNode(arrayOfNodes[i])) {
|
||||
// For block nodes, move their contents only, then delete block.
|
||||
ret |=
|
||||
MoveContents(*arrayOfNodes[i]->AsElement(), aLeftBlock, &aLeftOffset);
|
||||
ret |= MoveContents(MOZ_KnownLive(*arrayOfNodes[i]->AsElement()),
|
||||
aLeftBlock, &aLeftOffset);
|
||||
if (NS_WARN_IF(ret.Failed())) {
|
||||
return ret;
|
||||
}
|
||||
|
@ -3572,8 +3578,8 @@ EditActionResult HTMLEditRules::MoveBlock(Element& aLeftBlock,
|
|||
ret.MarkAsHandled();
|
||||
} else {
|
||||
// Otherwise move the content as is, checking against the DTD.
|
||||
ret |= MoveNodeSmart(*arrayOfNodes[i]->AsContent(), aLeftBlock,
|
||||
&aLeftOffset);
|
||||
ret |= MoveNodeSmart(MOZ_KnownLive(*arrayOfNodes[i]->AsContent()),
|
||||
aLeftBlock, &aLeftOffset);
|
||||
if (NS_WARN_IF(ret.Rv() == NS_ERROR_EDITOR_DESTROYED)) {
|
||||
return ret;
|
||||
}
|
||||
|
@ -3600,8 +3606,8 @@ EditActionResult HTMLEditRules::MoveNodeSmart(nsIContent& aNode,
|
|||
if (HTMLEditorRef().CanContain(aDestElement, aNode)) {
|
||||
// If it can, move it there.
|
||||
if (*aInOutDestOffset == -1) {
|
||||
nsresult rv =
|
||||
HTMLEditorRef().MoveNodeToEndWithTransaction(aNode, aDestElement);
|
||||
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeToEndWithTransaction(aNode, aDestElement);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return EditActionIgnored(NS_ERROR_EDITOR_DESTROYED);
|
||||
}
|
||||
|
@ -3610,8 +3616,8 @@ EditActionResult HTMLEditRules::MoveNodeSmart(nsIContent& aNode,
|
|||
}
|
||||
} else {
|
||||
EditorRawDOMPoint pointToInsert(&aDestElement, *aInOutDestOffset);
|
||||
nsresult rv =
|
||||
HTMLEditorRef().MoveNodeWithTransaction(aNode, pointToInsert);
|
||||
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeWithTransaction(aNode, pointToInsert);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return EditActionIgnored(NS_ERROR_EDITOR_DESTROYED);
|
||||
}
|
||||
|
@ -3629,7 +3635,8 @@ EditActionResult HTMLEditRules::MoveNodeSmart(nsIContent& aNode,
|
|||
// If it can't, move its children (if any), and then delete it.
|
||||
EditActionResult ret(NS_OK);
|
||||
if (aNode.IsElement()) {
|
||||
ret = MoveContents(*aNode.AsElement(), aDestElement, aInOutDestOffset);
|
||||
ret = MoveContents(MOZ_KnownLive(*aNode.AsElement()), aDestElement,
|
||||
aInOutDestOffset);
|
||||
if (NS_WARN_IF(ret.Failed())) {
|
||||
return ret;
|
||||
}
|
||||
|
@ -3656,7 +3663,7 @@ EditActionResult HTMLEditRules::MoveContents(Element& aElement,
|
|||
|
||||
EditActionResult ret(NS_OK);
|
||||
while (aElement.GetFirstChild()) {
|
||||
ret |= MoveNodeSmart(*aElement.GetFirstChild(), aDestElement,
|
||||
ret |= MoveNodeSmart(MOZ_KnownLive(*aElement.GetFirstChild()), aDestElement,
|
||||
aInOutDestOffset);
|
||||
if (NS_WARN_IF(ret.Failed())) {
|
||||
return ret;
|
||||
|
@ -3964,20 +3971,22 @@ nsresult HTMLEditRules::MakeList(nsAtom& aListType, bool aEntireList,
|
|||
// whole list and then RemoveContainerWithTransaction() on the list.
|
||||
// ConvertListType first: that routine handles converting the list
|
||||
// item types, if needed.
|
||||
rv = HTMLEditorRef().MoveNodeToEndWithTransaction(*curNode, *curList);
|
||||
rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeToEndWithTransaction(*curNode, *curList);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
CreateElementResult convertListTypeResult =
|
||||
ConvertListType(*curNode->AsElement(), aListType, aItemType);
|
||||
CreateElementResult convertListTypeResult = ConvertListType(
|
||||
MOZ_KnownLive(*curNode->AsElement()), aListType, aItemType);
|
||||
if (NS_WARN_IF(convertListTypeResult.Failed())) {
|
||||
return convertListTypeResult.Rv();
|
||||
}
|
||||
rv = HTMLEditorRef().RemoveBlockContainerWithTransaction(
|
||||
*convertListTypeResult.GetNewNode());
|
||||
rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.RemoveBlockContainerWithTransaction(
|
||||
MOZ_KnownLive(*convertListTypeResult.GetNewNode()));
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -3987,8 +3996,8 @@ nsresult HTMLEditRules::MakeList(nsAtom& aListType, bool aEntireList,
|
|||
newBlock = convertListTypeResult.forget();
|
||||
} else {
|
||||
// replace list with new list type
|
||||
CreateElementResult convertListTypeResult =
|
||||
ConvertListType(*curNode->AsElement(), aListType, aItemType);
|
||||
CreateElementResult convertListTypeResult = ConvertListType(
|
||||
MOZ_KnownLive(*curNode->AsElement()), aListType, aItemType);
|
||||
if (NS_WARN_IF(convertListTypeResult.Failed())) {
|
||||
return convertListTypeResult.Rv();
|
||||
}
|
||||
|
@ -4033,7 +4042,8 @@ nsresult HTMLEditRules::MakeList(nsAtom& aListType, bool aEntireList,
|
|||
}
|
||||
}
|
||||
// move list item to new list
|
||||
rv = HTMLEditorRef().MoveNodeToEndWithTransaction(*curNode, *curList);
|
||||
rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeToEndWithTransaction(*curNode, *curList);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -4042,8 +4052,9 @@ nsresult HTMLEditRules::MakeList(nsAtom& aListType, bool aEntireList,
|
|||
}
|
||||
// convert list item type if needed
|
||||
if (!curNode->IsHTMLElement(&aItemType)) {
|
||||
newBlock = HTMLEditorRef().ReplaceContainerWithTransaction(
|
||||
*curNode->AsElement(), aItemType);
|
||||
newBlock = MOZ_KnownLive(HTMLEditorRef())
|
||||
.ReplaceContainerWithTransaction(
|
||||
MOZ_KnownLive(*curNode->AsElement()), aItemType);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -4058,7 +4069,8 @@ nsresult HTMLEditRules::MakeList(nsAtom& aListType, bool aEntireList,
|
|||
curList = atCurNode.GetContainerAsElement();
|
||||
} else if (atCurNode.GetContainer() != curList) {
|
||||
// move list item to new list
|
||||
rv = HTMLEditorRef().MoveNodeToEndWithTransaction(*curNode, *curList);
|
||||
rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeToEndWithTransaction(*curNode, *curList);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -4067,8 +4079,9 @@ nsresult HTMLEditRules::MakeList(nsAtom& aListType, bool aEntireList,
|
|||
}
|
||||
}
|
||||
if (!curNode->IsHTMLElement(&aItemType)) {
|
||||
newBlock = HTMLEditorRef().ReplaceContainerWithTransaction(
|
||||
*curNode->AsElement(), aItemType);
|
||||
newBlock = MOZ_KnownLive(HTMLEditorRef())
|
||||
.ReplaceContainerWithTransaction(
|
||||
MOZ_KnownLive(*curNode->AsElement()), aItemType);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -4109,8 +4122,9 @@ nsresult HTMLEditRules::MakeList(nsAtom& aListType, bool aEntireList,
|
|||
prevListItem = nullptr;
|
||||
int32_t j = i + 1;
|
||||
GetInnerContent(*curNode, arrayOfNodes, &j);
|
||||
rv =
|
||||
HTMLEditorRef().RemoveContainerWithTransaction(*curNode->AsElement());
|
||||
rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.RemoveContainerWithTransaction(
|
||||
MOZ_KnownLive(*curNode->AsElement()));
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -4152,8 +4166,8 @@ nsresult HTMLEditRules::MakeList(nsAtom& aListType, bool aEntireList,
|
|||
if (IsInlineNode(curNode) && prevListItem) {
|
||||
// this is a continuation of some inline nodes that belong together in
|
||||
// the same list item. use prevListItem
|
||||
rv = HTMLEditorRef().MoveNodeToEndWithTransaction(*curNode,
|
||||
*prevListItem);
|
||||
rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeToEndWithTransaction(*curNode, *prevListItem);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -4163,8 +4177,9 @@ nsresult HTMLEditRules::MakeList(nsAtom& aListType, bool aEntireList,
|
|||
} else {
|
||||
// don't wrap li around a paragraph. instead replace paragraph with li
|
||||
if (curNode->IsHTMLElement(nsGkAtoms::p)) {
|
||||
listItem = HTMLEditorRef().ReplaceContainerWithTransaction(
|
||||
*curNode->AsElement(), aItemType);
|
||||
listItem = MOZ_KnownLive(HTMLEditorRef())
|
||||
.ReplaceContainerWithTransaction(
|
||||
MOZ_KnownLive(*curNode->AsElement()), aItemType);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -4172,8 +4187,8 @@ nsresult HTMLEditRules::MakeList(nsAtom& aListType, bool aEntireList,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
} else {
|
||||
listItem = HTMLEditorRef().InsertContainerWithTransaction(*curNode,
|
||||
aItemType);
|
||||
listItem = MOZ_KnownLive(HTMLEditorRef())
|
||||
.InsertContainerWithTransaction(*curNode, aItemType);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -4194,7 +4209,8 @@ nsresult HTMLEditRules::MakeList(nsAtom& aListType, bool aEntireList,
|
|||
if (listItem) {
|
||||
// if we made a new list item, deal with it: tuck the listItem into the
|
||||
// end of the active list
|
||||
rv = HTMLEditorRef().MoveNodeToEndWithTransaction(*listItem, *curList);
|
||||
rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeToEndWithTransaction(*listItem, *curList);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -4249,7 +4265,7 @@ nsresult HTMLEditRules::WillRemoveList(bool* aCancel, bool* aHandled) {
|
|||
// unlist this listitem
|
||||
bool bOutOfList;
|
||||
do {
|
||||
rv = PopListItem(*curNode->AsContent(), &bOutOfList);
|
||||
rv = PopListItem(MOZ_KnownLive(*curNode->AsContent()), &bOutOfList);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -4257,7 +4273,7 @@ nsresult HTMLEditRules::WillRemoveList(bool* aCancel, bool* aHandled) {
|
|||
!bOutOfList); // keep popping it out until it's not in a list anymore
|
||||
} else if (HTMLEditUtils::IsList(curNode)) {
|
||||
// node is a list, move list items out
|
||||
rv = RemoveListStructure(*curNode->AsElement());
|
||||
rv = RemoveListStructure(MOZ_KnownLive(*curNode->AsElement()));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -4683,8 +4699,10 @@ nsresult HTMLEditRules::IndentAroundSelectionWithCSS() {
|
|||
sibling->NodeInfo()->NameAtom() &&
|
||||
atCurNode.GetContainer()->NodeInfo()->NamespaceID() ==
|
||||
sibling->NodeInfo()->NamespaceID()) {
|
||||
nsresult rv = HTMLEditorRef().MoveNodeWithTransaction(
|
||||
*curNode->AsContent(), EditorRawDOMPoint(sibling, 0));
|
||||
nsresult rv =
|
||||
MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeWithTransaction(MOZ_KnownLive(*curNode->AsContent()),
|
||||
EditorRawDOMPoint(sibling, 0));
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -4703,8 +4721,9 @@ nsresult HTMLEditRules::IndentAroundSelectionWithCSS() {
|
|||
sibling->NodeInfo()->NameAtom() &&
|
||||
atCurNode.GetContainer()->NodeInfo()->NamespaceID() ==
|
||||
sibling->NodeInfo()->NamespaceID()) {
|
||||
nsresult rv = HTMLEditorRef().MoveNodeToEndWithTransaction(
|
||||
*curNode->AsContent(), *sibling);
|
||||
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeToEndWithTransaction(
|
||||
MOZ_KnownLive(*curNode->AsContent()), *sibling);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -4744,8 +4763,9 @@ nsresult HTMLEditRules::IndentAroundSelectionWithCSS() {
|
|||
mNewBlock = curList;
|
||||
}
|
||||
// tuck the node into the end of the active list
|
||||
nsresult rv = HTMLEditorRef().MoveNodeToEndWithTransaction(
|
||||
*curNode->AsContent(), *curList);
|
||||
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeToEndWithTransaction(
|
||||
MOZ_KnownLive(*curNode->AsContent()), *curList);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -4758,7 +4778,8 @@ nsresult HTMLEditRules::IndentAroundSelectionWithCSS() {
|
|||
// Not a list item.
|
||||
|
||||
if (IsBlockNode(*curNode)) {
|
||||
nsresult rv = IncreaseMarginToIndent(*curNode->AsElement());
|
||||
nsresult rv =
|
||||
IncreaseMarginToIndent(MOZ_KnownLive(*curNode->AsElement()));
|
||||
if (NS_WARN_IF(rv == NS_ERROR_EDITOR_DESTROYED)) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -4799,8 +4820,9 @@ nsresult HTMLEditRules::IndentAroundSelectionWithCSS() {
|
|||
}
|
||||
|
||||
// tuck the node into the end of the active blockquote
|
||||
nsresult rv = HTMLEditorRef().MoveNodeToEndWithTransaction(
|
||||
*curNode->AsContent(), *curQuote);
|
||||
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeToEndWithTransaction(
|
||||
MOZ_KnownLive(*curNode->AsContent()), *curQuote);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -4950,8 +4972,9 @@ nsresult HTMLEditRules::IndentAroundSelectionWithHTML() {
|
|||
sibling->NodeInfo()->NameAtom() &&
|
||||
atCurNode.GetContainer()->NodeInfo()->NamespaceID() ==
|
||||
sibling->NodeInfo()->NamespaceID()) {
|
||||
rv = HTMLEditorRef().MoveNodeWithTransaction(
|
||||
*curNode->AsContent(), EditorRawDOMPoint(sibling, 0));
|
||||
rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeWithTransaction(MOZ_KnownLive(*curNode->AsContent()),
|
||||
EditorRawDOMPoint(sibling, 0));
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -4970,8 +4993,9 @@ nsresult HTMLEditRules::IndentAroundSelectionWithHTML() {
|
|||
sibling->NodeInfo()->NameAtom() &&
|
||||
atCurNode.GetContainer()->NodeInfo()->NamespaceID() ==
|
||||
sibling->NodeInfo()->NamespaceID()) {
|
||||
rv = HTMLEditorRef().MoveNodeToEndWithTransaction(*curNode->AsContent(),
|
||||
*sibling);
|
||||
rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeToEndWithTransaction(
|
||||
MOZ_KnownLive(*curNode->AsContent()), *sibling);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -5011,8 +5035,9 @@ nsresult HTMLEditRules::IndentAroundSelectionWithHTML() {
|
|||
mNewBlock = curList;
|
||||
}
|
||||
// tuck the node into the end of the active list
|
||||
rv = HTMLEditorRef().MoveNodeToEndWithTransaction(*curNode->AsContent(),
|
||||
*curList);
|
||||
rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeToEndWithTransaction(
|
||||
MOZ_KnownLive(*curNode->AsContent()), *curList);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -5069,7 +5094,8 @@ nsresult HTMLEditRules::IndentAroundSelectionWithHTML() {
|
|||
}
|
||||
}
|
||||
|
||||
rv = HTMLEditorRef().MoveNodeToEndWithTransaction(*listItem, *curList);
|
||||
rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeToEndWithTransaction(*listItem, *curList);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -5118,8 +5144,9 @@ nsresult HTMLEditRules::IndentAroundSelectionWithHTML() {
|
|||
}
|
||||
|
||||
// tuck the node into the end of the active blockquote
|
||||
rv = HTMLEditorRef().MoveNodeToEndWithTransaction(*curNode->AsContent(),
|
||||
*curQuote);
|
||||
rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeToEndWithTransaction(MOZ_KnownLive(*curNode->AsContent()),
|
||||
*curQuote);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -5275,8 +5302,9 @@ SplitRangeOffFromNodeResult HTMLEditRules::OutdentAroundSelection() {
|
|||
lastBQChild = nullptr;
|
||||
curBlockQuoteIsIndentedWithCSS = false;
|
||||
}
|
||||
rv = HTMLEditorRef().RemoveBlockContainerWithTransaction(
|
||||
*curNode->AsElement());
|
||||
rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.RemoveBlockContainerWithTransaction(
|
||||
MOZ_KnownLive(*curNode->AsElement()));
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return SplitRangeOffFromNodeResult(NS_ERROR_EDITOR_DESTROYED);
|
||||
}
|
||||
|
@ -5298,7 +5326,8 @@ SplitRangeOffFromNodeResult HTMLEditRules::OutdentAroundSelection() {
|
|||
RefPtr<nsAtom> unit;
|
||||
CSSEditUtils::ParseLength(value, &f, getter_AddRefs(unit));
|
||||
if (f > 0) {
|
||||
nsresult rv = DecreaseMarginToOutdent(*curNode->AsElement());
|
||||
nsresult rv =
|
||||
DecreaseMarginToOutdent(MOZ_KnownLive(*curNode->AsElement()));
|
||||
if (NS_WARN_IF(rv == NS_ERROR_EDITOR_DESTROYED)) {
|
||||
return SplitRangeOffFromNodeResult(NS_ERROR_EDITOR_DESTROYED);
|
||||
}
|
||||
|
@ -5328,7 +5357,7 @@ SplitRangeOffFromNodeResult HTMLEditRules::OutdentAroundSelection() {
|
|||
lastBQChild = nullptr;
|
||||
curBlockQuoteIsIndentedWithCSS = false;
|
||||
}
|
||||
rv = PopListItem(*curNode->AsContent());
|
||||
rv = PopListItem(MOZ_KnownLive(*curNode->AsContent()));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return SplitRangeOffFromNodeResult(rv);
|
||||
}
|
||||
|
@ -5415,8 +5444,9 @@ SplitRangeOffFromNodeResult HTMLEditRules::OutdentAroundSelection() {
|
|||
// Move node out of list
|
||||
if (HTMLEditUtils::IsList(curNode)) {
|
||||
// Just unwrap this sublist
|
||||
rv = HTMLEditorRef().RemoveBlockContainerWithTransaction(
|
||||
*curNode->AsElement());
|
||||
rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.RemoveBlockContainerWithTransaction(
|
||||
MOZ_KnownLive(*curNode->AsElement()));
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return SplitRangeOffFromNodeResult(NS_ERROR_EDITOR_DESTROYED);
|
||||
}
|
||||
|
@ -5441,8 +5471,8 @@ SplitRangeOffFromNodeResult HTMLEditRules::OutdentAroundSelection() {
|
|||
// list. Be sure to put it after the parent list because this
|
||||
// loop iterates backwards through the parent's list of children.
|
||||
EditorRawDOMPoint afterCurrentList(curParent, offset + 1);
|
||||
rv =
|
||||
HTMLEditorRef().MoveNodeWithTransaction(*child, afterCurrentList);
|
||||
rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeWithTransaction(*child, afterCurrentList);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return SplitRangeOffFromNodeResult(NS_ERROR_EDITOR_DESTROYED);
|
||||
}
|
||||
|
@ -5462,8 +5492,9 @@ SplitRangeOffFromNodeResult HTMLEditRules::OutdentAroundSelection() {
|
|||
child = curNode->GetLastChild();
|
||||
}
|
||||
// Delete the now-empty list
|
||||
rv = HTMLEditorRef().RemoveBlockContainerWithTransaction(
|
||||
*curNode->AsElement());
|
||||
rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.RemoveBlockContainerWithTransaction(
|
||||
MOZ_KnownLive(*curNode->AsElement()));
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return SplitRangeOffFromNodeResult(NS_ERROR_EDITOR_DESTROYED);
|
||||
}
|
||||
|
@ -5522,8 +5553,8 @@ HTMLEditRules::SplitRangeOffFromBlockAndRemoveMiddleContainer(
|
|||
}
|
||||
NS_WARNING_ASSERTION(splitResult.Succeeded(),
|
||||
"Failed to split the range off from the block element");
|
||||
nsresult rv =
|
||||
HTMLEditorRef().RemoveBlockContainerWithTransaction(aBlockElement);
|
||||
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.RemoveBlockContainerWithTransaction(aBlockElement);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return SplitRangeOffFromNodeResult(NS_ERROR_EDITOR_DESTROYED);
|
||||
}
|
||||
|
@ -5587,8 +5618,9 @@ SplitRangeOffFromNodeResult HTMLEditRules::OutdentPartOfBlock(
|
|||
}
|
||||
|
||||
if (!aIsBlockIndentedWithCSS) {
|
||||
nsresult rv = HTMLEditorRef().RemoveBlockContainerWithTransaction(
|
||||
*splitResult.GetMiddleContentAsElement());
|
||||
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.RemoveBlockContainerWithTransaction(MOZ_KnownLive(
|
||||
*splitResult.GetMiddleContentAsElement()));
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return SplitRangeOffFromNodeResult(NS_ERROR_EDITOR_DESTROYED);
|
||||
}
|
||||
|
@ -5600,8 +5632,8 @@ SplitRangeOffFromNodeResult HTMLEditRules::OutdentPartOfBlock(
|
|||
}
|
||||
|
||||
if (splitResult.GetMiddleContentAsElement()) {
|
||||
nsresult rv =
|
||||
DecreaseMarginToOutdent(*splitResult.GetMiddleContentAsElement());
|
||||
nsresult rv = DecreaseMarginToOutdent(
|
||||
MOZ_KnownLive(*splitResult.GetMiddleContentAsElement()));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return SplitRangeOffFromNodeResult(rv);
|
||||
}
|
||||
|
@ -5622,8 +5654,9 @@ CreateElementResult HTMLEditRules::ConvertListType(Element& aListElement,
|
|||
Element* element = child->AsElement();
|
||||
if (HTMLEditUtils::IsListItem(element) &&
|
||||
!element->IsHTMLElement(&aNewListItemTag)) {
|
||||
child = HTMLEditorRef().ReplaceContainerWithTransaction(
|
||||
*element, aNewListItemTag);
|
||||
child = MOZ_KnownLive(HTMLEditorRef())
|
||||
.ReplaceContainerWithTransaction(MOZ_KnownLive(*element),
|
||||
aNewListItemTag);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return CreateElementResult(NS_ERROR_EDITOR_DESTROYED);
|
||||
}
|
||||
|
@ -5634,8 +5667,8 @@ CreateElementResult HTMLEditRules::ConvertListType(Element& aListElement,
|
|||
!element->IsHTMLElement(&aNewListTag)) {
|
||||
// XXX List elements shouldn't have other list elements as their
|
||||
// child. Why do we handle such invalid tree?
|
||||
CreateElementResult convertListTypeResult =
|
||||
ConvertListType(*child->AsElement(), aNewListTag, aNewListItemTag);
|
||||
CreateElementResult convertListTypeResult = ConvertListType(
|
||||
MOZ_KnownLive(*child->AsElement()), aNewListTag, aNewListItemTag);
|
||||
if (NS_WARN_IF(convertListTypeResult.Failed())) {
|
||||
return convertListTypeResult;
|
||||
}
|
||||
|
@ -5649,8 +5682,9 @@ CreateElementResult HTMLEditRules::ConvertListType(Element& aListElement,
|
|||
return CreateElementResult(&aListElement);
|
||||
}
|
||||
|
||||
RefPtr<Element> listElement = HTMLEditorRef().ReplaceContainerWithTransaction(
|
||||
aListElement, aNewListTag);
|
||||
RefPtr<Element> listElement =
|
||||
MOZ_KnownLive(HTMLEditorRef())
|
||||
.ReplaceContainerWithTransaction(aListElement, aNewListTag);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return CreateElementResult(NS_ERROR_EDITOR_DESTROYED);
|
||||
}
|
||||
|
@ -5685,8 +5719,10 @@ nsresult HTMLEditRules::CreateStyleForInsertText(Document& aDocument) {
|
|||
while (item && node != rootElement) {
|
||||
// XXX If we redesign ClearStyle(), we can use EditorDOMPoint in this
|
||||
// method.
|
||||
nsresult rv = HTMLEditorRef().ClearStyle(address_of(node), &offset,
|
||||
item->tag, item->attr);
|
||||
nsresult rv =
|
||||
MOZ_KnownLive(HTMLEditorRef())
|
||||
.ClearStyle(address_of(node), &offset, MOZ_KnownLive(item->tag),
|
||||
MOZ_KnownLive(item->attr));
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -5726,8 +5762,9 @@ nsresult HTMLEditRules::CreateStyleForInsertText(Document& aDocument) {
|
|||
}
|
||||
OwningNonNull<Text> newNode =
|
||||
EditorBase::CreateTextNode(aDocument, EmptyString());
|
||||
nsresult rv = HTMLEditorRef().InsertNodeWithTransaction(
|
||||
*newNode, EditorRawDOMPoint(node, offset));
|
||||
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.InsertNodeWithTransaction(
|
||||
*newNode, EditorRawDOMPoint(node, offset));
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -5743,7 +5780,8 @@ nsresult HTMLEditRules::CreateStyleForInsertText(Document& aDocument) {
|
|||
HTMLEditor::FontSize dir = relFontSize > 0 ? HTMLEditor::FontSize::incr
|
||||
: HTMLEditor::FontSize::decr;
|
||||
for (int32_t j = 0; j < DeprecatedAbs(relFontSize); j++) {
|
||||
rv = HTMLEditorRef().RelativeFontChangeOnTextNode(dir, newNode, 0, -1);
|
||||
rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.RelativeFontChangeOnTextNode(dir, newNode, 0, -1);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -5754,8 +5792,10 @@ nsresult HTMLEditRules::CreateStyleForInsertText(Document& aDocument) {
|
|||
}
|
||||
|
||||
while (item) {
|
||||
rv = HTMLEditorRef().SetInlinePropertyOnNode(
|
||||
*node->AsContent(), *item->tag, item->attr, item->value);
|
||||
rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.SetInlinePropertyOnNode(MOZ_KnownLive(*node->AsContent()),
|
||||
MOZ_KnownLive(*item->tag),
|
||||
MOZ_KnownLive(item->attr), item->value);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -5854,7 +5894,7 @@ nsresult HTMLEditRules::AlignContentsAtSelection(const nsAString& aAlignType) {
|
|||
// header; in HTML 4, it can directly carry the ALIGN attribute and we
|
||||
// don't need to make a div! If we are in CSS mode, all the work is done
|
||||
// in AlignBlock
|
||||
rv = AlignBlock(*node->AsElement(), aAlignType,
|
||||
rv = AlignBlock(MOZ_KnownLive(*node->AsElement()), aAlignType,
|
||||
ResetAlignOf::OnlyDescendants);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
|
@ -5993,7 +6033,7 @@ nsresult HTMLEditRules::AlignContentsAtSelection(const nsAString& aAlignType) {
|
|||
// don't need to nest it, just set the alignment. In CSS, assign the
|
||||
// corresponding CSS styles in AlignBlock
|
||||
if (HTMLEditUtils::SupportsAlignAttr(*curNode)) {
|
||||
rv = AlignBlock(*curNode->AsElement(), aAlignType,
|
||||
rv = AlignBlock(MOZ_KnownLive(*curNode->AsElement()), aAlignType,
|
||||
ResetAlignOf::ElementAndDescendants);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
|
@ -6090,8 +6130,9 @@ nsresult HTMLEditRules::AlignContentsAtSelection(const nsAString& aAlignType) {
|
|||
}
|
||||
|
||||
// Tuck the node into the end of the active div
|
||||
rv = HTMLEditorRef().MoveNodeToEndWithTransaction(*curNode->AsContent(),
|
||||
*curDiv);
|
||||
rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeToEndWithTransaction(MOZ_KnownLive(*curNode->AsContent()),
|
||||
*curDiv);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -6139,8 +6180,10 @@ nsresult HTMLEditRules::AlignBlockContents(nsINode& aNode,
|
|||
if (firstChild == lastChild && firstChild->IsHTMLElement(nsGkAtoms::div)) {
|
||||
// the cell already has a div containing all of its content: just
|
||||
// act on this div.
|
||||
nsresult rv = HTMLEditorRef().SetAttributeOrEquivalent(
|
||||
firstChild->AsElement(), nsGkAtoms::align, aAlignType, false);
|
||||
nsresult rv =
|
||||
MOZ_KnownLive(HTMLEditorRef())
|
||||
.SetAttributeOrEquivalent(MOZ_KnownLive(firstChild->AsElement()),
|
||||
nsGkAtoms::align, aAlignType, false);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -6162,8 +6205,9 @@ nsresult HTMLEditRules::AlignBlockContents(nsINode& aNode,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
// set up the alignment on the div
|
||||
nsresult rv = HTMLEditorRef().SetAttributeOrEquivalent(
|
||||
divElem, nsGkAtoms::align, aAlignType, false);
|
||||
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.SetAttributeOrEquivalent(divElem, nsGkAtoms::align,
|
||||
aAlignType, false);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -6172,8 +6216,9 @@ nsresult HTMLEditRules::AlignBlockContents(nsINode& aNode,
|
|||
}
|
||||
// tuck the children into the end of the active div
|
||||
while (lastChild && (lastChild != divElem)) {
|
||||
nsresult rv = HTMLEditorRef().MoveNodeWithTransaction(
|
||||
*lastChild, EditorRawDOMPoint(divElem, 0));
|
||||
nsresult rv =
|
||||
MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeWithTransaction(*lastChild, EditorRawDOMPoint(divElem, 0));
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -7172,7 +7217,8 @@ nsresult HTMLEditRules::GetNodesForOperation(
|
|||
if (aTouchContent == TouchContent::yes && IsInlineNode(node) &&
|
||||
HTMLEditorRef().IsContainer(node) && !EditorBase::IsTextNode(node)) {
|
||||
nsTArray<OwningNonNull<nsINode>> arrayOfInlines;
|
||||
nsresult rv = BustUpInlinesAtBRs(*node->AsContent(), arrayOfInlines);
|
||||
nsresult rv = BustUpInlinesAtBRs(MOZ_KnownLive(*node->AsContent()),
|
||||
arrayOfInlines);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -7460,8 +7506,9 @@ nsresult HTMLEditRules::BustUpInlinesAtBRs(
|
|||
|
||||
// Move break outside of container and also put in node list
|
||||
EditorRawDOMPoint atNextNode(splitNodeResult.GetNextNode());
|
||||
nsresult rv = HTMLEditorRef().MoveNodeWithTransaction(*brNode->AsContent(),
|
||||
atNextNode);
|
||||
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeWithTransaction(
|
||||
MOZ_KnownLive(*brNode->AsContent()), atNextNode);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -8069,8 +8116,9 @@ nsresult HTMLEditRules::ReturnInListItem(Element& aListItem, nsINode& aNode,
|
|||
"Failed to advance offset after the right list node");
|
||||
if (HTMLEditUtils::IsList(atNextSiblingOfLeftList.GetContainer())) {
|
||||
// If so, move item out of this list and into the grandparent list
|
||||
nsresult rv = HTMLEditorRef().MoveNodeWithTransaction(
|
||||
aListItem, atNextSiblingOfLeftList);
|
||||
nsresult rv =
|
||||
MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeWithTransaction(aListItem, atNextSiblingOfLeftList);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -8222,9 +8270,10 @@ nsresult HTMLEditRules::ReturnInListItem(Element& aListItem, nsINode& aNode,
|
|||
}
|
||||
|
||||
RefPtr<Element> brElement;
|
||||
nsresult rv =
|
||||
HTMLEditorRef().CopyLastEditableChildStylesWithTransaction(
|
||||
*prevItem->AsElement(), aListItem, address_of(brElement));
|
||||
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.CopyLastEditableChildStylesWithTransaction(
|
||||
MOZ_KnownLive(*prevItem->AsElement()), aListItem,
|
||||
address_of(brElement));
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -8361,8 +8410,9 @@ nsresult HTMLEditRules::MakeBlockquote(
|
|||
// note: doesn't matter if we set mNewBlock multiple times.
|
||||
}
|
||||
|
||||
nsresult rv = HTMLEditorRef().MoveNodeToEndWithTransaction(
|
||||
*curNode->AsContent(), *curBlock);
|
||||
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeToEndWithTransaction(
|
||||
MOZ_KnownLive(*curNode->AsContent()), *curBlock);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -8399,8 +8449,9 @@ nsresult HTMLEditRules::RemoveBlockStyle(
|
|||
continue;
|
||||
}
|
||||
// Remove current block
|
||||
nsresult rv = HTMLEditorRef().RemoveBlockContainerWithTransaction(
|
||||
*curNode->AsElement());
|
||||
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.RemoveBlockContainerWithTransaction(
|
||||
MOZ_KnownLive(*curNode->AsElement()));
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -8524,9 +8575,9 @@ nsresult HTMLEditRules::ApplyBlockStyle(
|
|||
HTMLEditUtils::IsFormatNode(curNode)) {
|
||||
// Forget any previous block used for previous inline nodes
|
||||
curBlock = nullptr;
|
||||
newBlock =
|
||||
HTMLEditorRef().ReplaceContainerAndCloneAttributesWithTransaction(
|
||||
*curNode->AsElement(), aBlockTag);
|
||||
newBlock = MOZ_KnownLive(HTMLEditorRef())
|
||||
.ReplaceContainerAndCloneAttributesWithTransaction(
|
||||
MOZ_KnownLive(*curNode->AsElement()), aBlockTag);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -8606,8 +8657,9 @@ nsresult HTMLEditRules::ApplyBlockStyle(
|
|||
// Remember our new block for postprocessing
|
||||
mNewBlock = curBlock;
|
||||
// Note: doesn't matter if we set mNewBlock multiple times.
|
||||
nsresult rv = HTMLEditorRef().MoveNodeToEndWithTransaction(
|
||||
*curNode->AsContent(), *curBlock);
|
||||
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeToEndWithTransaction(
|
||||
MOZ_KnownLive(*curNode->AsContent()), *curBlock);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -8662,8 +8714,9 @@ nsresult HTMLEditRules::ApplyBlockStyle(
|
|||
|
||||
// This is a continuation of some inline nodes that belong together in
|
||||
// the same block item. Use curBlock.
|
||||
nsresult rv = HTMLEditorRef().MoveNodeToEndWithTransaction(
|
||||
*curNode->AsContent(), *curBlock);
|
||||
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeToEndWithTransaction(
|
||||
MOZ_KnownLive(*curNode->AsContent()), *curBlock);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -8751,8 +8804,9 @@ nsresult HTMLEditRules::JoinNearestEditableNodesWithTransaction(
|
|||
// left one
|
||||
if (parent != rightParent) {
|
||||
int32_t parOffset = parent->ComputeIndexOf(&aNodeLeft);
|
||||
nsresult rv = HTMLEditorRef().MoveNodeWithTransaction(
|
||||
aNodeRight, EditorRawDOMPoint(parent, parOffset));
|
||||
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeWithTransaction(
|
||||
aNodeRight, EditorRawDOMPoint(parent, parOffset));
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -9684,8 +9738,8 @@ nsresult HTMLEditRules::PopListItem(nsIContent& aListItem, bool* aOutOfList) {
|
|||
"Failed to advance offset to right list node");
|
||||
}
|
||||
|
||||
nsresult rv =
|
||||
HTMLEditorRef().MoveNodeWithTransaction(*listItem, pointToInsertListItem);
|
||||
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeWithTransaction(*listItem, pointToInsertListItem);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -9703,8 +9757,9 @@ nsresult HTMLEditRules::PopListItem(nsIContent& aListItem, bool* aOutOfList) {
|
|||
// current parent is <dl>, there is same issue.
|
||||
if (!HTMLEditUtils::IsList(pointToInsertListItem.GetContainer()) &&
|
||||
HTMLEditUtils::IsListItem(listItem)) {
|
||||
rv = HTMLEditorRef().RemoveBlockContainerWithTransaction(
|
||||
*listItem->AsElement());
|
||||
rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.RemoveBlockContainerWithTransaction(
|
||||
MOZ_KnownLive(*listItem->AsElement()));
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -9747,7 +9802,7 @@ nsresult HTMLEditRules::RemoveListStructure(Element& aListElement) {
|
|||
}
|
||||
|
||||
if (HTMLEditUtils::IsList(child)) {
|
||||
nsresult rv = RemoveListStructure(*child->AsElement());
|
||||
nsresult rv = RemoveListStructure(MOZ_KnownLive(*child->AsElement()));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -9768,8 +9823,8 @@ nsresult HTMLEditRules::RemoveListStructure(Element& aListElement) {
|
|||
}
|
||||
|
||||
// Delete the now-empty list
|
||||
nsresult rv =
|
||||
HTMLEditorRef().RemoveBlockContainerWithTransaction(aListElement);
|
||||
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.RemoveBlockContainerWithTransaction(aListElement);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -10155,7 +10210,9 @@ nsresult HTMLEditRules::RemoveAlignment(nsINode& aNode,
|
|||
}
|
||||
|
||||
// now remove the CENTER container
|
||||
rv = HTMLEditorRef().RemoveContainerWithTransaction(*child->AsElement());
|
||||
rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.RemoveContainerWithTransaction(
|
||||
MOZ_KnownLive(*child->AsElement()));
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -10177,8 +10234,10 @@ nsresult HTMLEditRules::RemoveAlignment(nsINode& aNode,
|
|||
}
|
||||
if (useCSS) {
|
||||
if (child->IsAnyOfHTMLElements(nsGkAtoms::table, nsGkAtoms::hr)) {
|
||||
nsresult rv = HTMLEditorRef().SetAttributeOrEquivalent(
|
||||
child->AsElement(), nsGkAtoms::align, aAlignType, false);
|
||||
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.SetAttributeOrEquivalent(
|
||||
MOZ_KnownLive(child->AsElement()),
|
||||
nsGkAtoms::align, aAlignType, false);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -10291,8 +10350,9 @@ nsresult HTMLEditRules::AlignBlock(Element& aElement,
|
|||
if (HTMLEditorRef().IsCSSEnabled()) {
|
||||
// Let's use CSS alignment; we use margin-left and margin-right for tables
|
||||
// and text-align for other block-level elements
|
||||
nsresult rv = HTMLEditorRef().SetAttributeOrEquivalent(
|
||||
&aElement, nsGkAtoms::align, aAlignType, false);
|
||||
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.SetAttributeOrEquivalent(&aElement, nsGkAtoms::align,
|
||||
aAlignType, false);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -10309,8 +10369,9 @@ nsresult HTMLEditRules::AlignBlock(Element& aElement,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
rv = HTMLEditorRef().SetAttributeOrEquivalent(&aElement, nsGkAtoms::align,
|
||||
aAlignType, false);
|
||||
rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.SetAttributeOrEquivalent(&aElement, nsGkAtoms::align, aAlignType,
|
||||
false);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -10370,8 +10431,8 @@ nsresult HTMLEditRules::ChangeMarginStart(Element& aElement, bool aIncrease) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
HTMLEditorRef().mCSSEditUtils->RemoveCSSProperty(aElement, marginProperty,
|
||||
value);
|
||||
HTMLEditorRef().mCSSEditUtils->RemoveCSSProperty(
|
||||
aElement, MOZ_KnownLive(marginProperty), value);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -10384,7 +10445,8 @@ nsresult HTMLEditRules::ChangeMarginStart(Element& aElement, bool aIncrease) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult rv = HTMLEditorRef().RemoveContainerWithTransaction(aElement);
|
||||
nsresult rv =
|
||||
MOZ_KnownLive(HTMLEditorRef()).RemoveContainerWithTransaction(aElement);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -10575,8 +10637,9 @@ nsresult HTMLEditRules::PrepareToMakeElementAbsolutePosition(
|
|||
// new block for postprocessing.
|
||||
}
|
||||
// Tuck the node into the end of the active list
|
||||
rv = HTMLEditorRef().MoveNodeToEndWithTransaction(*curNode->AsContent(),
|
||||
*curList);
|
||||
rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeToEndWithTransaction(
|
||||
MOZ_KnownLive(*curNode->AsContent()), *curList);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -10641,7 +10704,8 @@ nsresult HTMLEditRules::PrepareToMakeElementAbsolutePosition(
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
rv = HTMLEditorRef().MoveNodeToEndWithTransaction(*listItem, *curList);
|
||||
rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeToEndWithTransaction(*listItem, *curList);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -10681,8 +10745,9 @@ nsresult HTMLEditRules::PrepareToMakeElementAbsolutePosition(
|
|||
}
|
||||
|
||||
// Tuck the node into the end of the active blockquote
|
||||
rv = HTMLEditorRef().MoveNodeToEndWithTransaction(*curNode->AsContent(),
|
||||
*curPositionedDiv);
|
||||
rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.MoveNodeToEndWithTransaction(MOZ_KnownLive(*curNode->AsContent()),
|
||||
*curPositionedDiv);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -10701,7 +10766,9 @@ nsresult HTMLEditRules::DidAbsolutePosition() {
|
|||
if (!mNewBlock) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult rv = HTMLEditorRef().SetPositionToAbsoluteOrStatic(*mNewBlock, true);
|
||||
OwningNonNull<Element> newBlock(*mNewBlock);
|
||||
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.SetPositionToAbsoluteOrStatic(*newBlock, true);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -10738,8 +10805,8 @@ nsresult HTMLEditRules::WillRemoveAbsolutePosition(bool* aCancel,
|
|||
{
|
||||
AutoSelectionRestorer restoreSelectionLater(HTMLEditorRef());
|
||||
|
||||
nsresult rv =
|
||||
HTMLEditorRef().SetPositionToAbsoluteOrStatic(*element, false);
|
||||
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.SetPositionToAbsoluteOrStatic(*element, false);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
|
|
@ -78,15 +78,23 @@ class HTMLEditRules : public TextEditRules {
|
|||
HTMLEditRules();
|
||||
|
||||
// TextEditRules methods
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual nsresult Init(TextEditor* aTextEditor) override;
|
||||
virtual nsresult DetachEditor() override;
|
||||
virtual nsresult BeforeEdit(EditSubAction aEditSubAction,
|
||||
nsIEditor::EDirection aDirection) override;
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual nsresult AfterEdit(EditSubAction aEditSubAction,
|
||||
nsIEditor::EDirection aDirection) override;
|
||||
// NOTE: Don't mark WillDoAction() nor DidDoAction() as MOZ_CAN_RUN_SCRIPT
|
||||
// because they are too generic and doing it makes a lot of public
|
||||
// editor methods marked as MOZ_CAN_RUN_SCRIPT too, but some of them
|
||||
// may not causes running script. So, ideal fix must be that we make
|
||||
// each method callsed by this method public.
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||
virtual nsresult WillDoAction(EditSubActionInfo& aInfo, bool* aCancel,
|
||||
bool* aHandled) override;
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||
virtual nsresult DidDoAction(EditSubActionInfo& aInfo,
|
||||
nsresult aResult) override;
|
||||
virtual bool DocumentIsEmpty() override;
|
||||
|
@ -96,9 +104,13 @@ class HTMLEditRules : public TextEditRules {
|
|||
*/
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult DocumentModified();
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult GetListState(bool* aMixed, bool* aOL, bool* aUL, bool* aDL);
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult GetListItemState(bool* aMixed, bool* aLI, bool* aDT, bool* aDD);
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult GetAlignment(bool* aMixed, nsIHTMLEditor::EAlignment* aAlign);
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult GetParagraphState(bool* aMixed, nsAString& outFormat);
|
||||
|
||||
/**
|
||||
|
@ -174,6 +186,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* @param aMaxLength The maximum string length which the editor
|
||||
* allows to set.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult WillInsertText(EditSubAction aEditSubAction,
|
||||
bool* aCancel, bool* aHandled,
|
||||
const nsAString* inString,
|
||||
|
@ -210,6 +223,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* @param aInsertToBreak The point where new <br> element will be
|
||||
* inserted before.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult InsertBRElement(const EditorDOMPoint& aInsertToBreak);
|
||||
|
||||
/**
|
||||
|
@ -315,6 +329,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* be joined or it's impossible to join them but it's not
|
||||
* unexpected case, this returns true with this.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE EditActionResult
|
||||
TryToJoinBlocksWithTransaction(nsIContent& aLeftNode, nsIContent& aRightNode);
|
||||
|
||||
|
@ -327,6 +342,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* @return Sets handled to true if this actually joins the nodes.
|
||||
* canceled is always false.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE EditActionResult MoveBlock(Element& aLeftBlock,
|
||||
Element& aRightBlock,
|
||||
int32_t aLeftOffset,
|
||||
|
@ -341,6 +357,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* the nodes.
|
||||
* canceled is always false.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE EditActionResult MoveNodeSmart(nsIContent& aNode,
|
||||
Element& aDestElement,
|
||||
int32_t* aInOutDestOffset);
|
||||
|
@ -354,6 +371,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* the nodes.
|
||||
* canceled is always false.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE EditActionResult MoveContents(Element& aElement,
|
||||
Element& aDestElement,
|
||||
int32_t* aInOutDestOffset);
|
||||
|
@ -455,6 +473,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* @param aCancel Returns true if the operation is canceled.
|
||||
* @param aHandled Returns true if the edit action is handled.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult WillRemoveAbsolutePosition(bool* aCancel,
|
||||
bool* aHandled);
|
||||
|
||||
|
@ -544,6 +563,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* @param aTargetElement Returns target element which should be
|
||||
* changed to absolute positioned.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult PrepareToMakeElementAbsolutePosition(
|
||||
bool* aHandled, RefPtr<Element>* aTargetElement);
|
||||
|
||||
|
@ -554,6 +574,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* WillAbsolutePosition() to absolute positioned.
|
||||
* Therefore, this might cause destroying the HTML editor.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult DidAbsolutePosition();
|
||||
|
||||
/**
|
||||
|
@ -564,6 +585,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* to aAlignType.
|
||||
* @param aAlignType New value of align attribute of <div>.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult AlignInnerBlocks(nsINode& aNode,
|
||||
const nsAString& aAlignType);
|
||||
|
||||
|
@ -578,6 +600,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* @param aAlignType New value of align attribute of <div> which
|
||||
* is only child of aNode.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult AlignBlockContents(nsINode& aNode,
|
||||
const nsAString& aAlignType);
|
||||
|
||||
|
@ -592,6 +615,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* @param aAlignType New align attribute value where the contents
|
||||
* should be aligned to.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult AlignContentsAtSelection(const nsAString& aAlignType);
|
||||
|
||||
nsresult AppendInnerFormatNodes(nsTArray<OwningNonNull<nsINode>>& aArray,
|
||||
|
@ -677,6 +701,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* @param aOffset Typically, Selection start offset in the
|
||||
* start container, where to insert a break.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult ReturnInListItem(Element& aListItem, nsINode& aNode,
|
||||
int32_t aOffset);
|
||||
|
||||
|
@ -684,6 +709,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* Called after handling edit action. This may adjust Selection, remove
|
||||
* unnecessary empty nodes, create <br> elements if needed, etc.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult AfterEditInner(EditSubAction aEditSubAction,
|
||||
nsIEditor::EDirection aDirection);
|
||||
|
||||
|
@ -693,6 +719,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* need to check if the editor is still available even if this returns
|
||||
* NS_OK.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult IndentAroundSelectionWithCSS();
|
||||
|
||||
/**
|
||||
|
@ -701,6 +728,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* need to check if the editor is still available even if this returns
|
||||
* NS_OK.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult IndentAroundSelectionWithHTML();
|
||||
|
||||
/**
|
||||
|
@ -716,6 +744,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* The middle content is middle content of last
|
||||
* outdented element.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE SplitRangeOffFromNodeResult OutdentAroundSelection();
|
||||
|
||||
/**
|
||||
|
@ -735,6 +764,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* The middle content is nullptr since
|
||||
* removing it is the job of this method.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE SplitRangeOffFromNodeResult
|
||||
SplitRangeOffFromBlockAndRemoveMiddleContainer(Element& aBlockElement,
|
||||
nsIContent& aStartOfRange,
|
||||
|
@ -776,6 +806,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* if aIsBlockIndentedWithCSS is true.
|
||||
* Otherwise, nullptr.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE SplitRangeOffFromNodeResult
|
||||
OutdentPartOfBlock(Element& aBlockElement, nsIContent& aStartOfOutdent,
|
||||
nsIContent& aEndOutdent, bool aIsBlockIndentedWithCSS);
|
||||
|
@ -786,6 +817,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* need to check if the editor is still available even if this returns
|
||||
* NS_OK.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult MakeList(nsAtom& aListType, bool aEntireList,
|
||||
const nsAString* aBulletType, bool* aCancel,
|
||||
nsAtom& aItemType);
|
||||
|
@ -804,6 +836,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* New list element may be aListElement if its
|
||||
* tag name is same as aNewListTag.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE CreateElementResult ConvertListType(Element& aListElement,
|
||||
nsAtom& aListType,
|
||||
nsAtom& aItemType);
|
||||
|
@ -814,6 +847,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
*
|
||||
* @param aDocument The document of the editor.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult CreateStyleForInsertText(dom::Document& aDocument);
|
||||
|
||||
/**
|
||||
|
@ -901,6 +935,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* transaction. We should rename this to making clearer what this does.
|
||||
*/
|
||||
enum class TouchContent { no, yes };
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult GetNodesForOperation(
|
||||
nsTArray<RefPtr<nsRange>>& aArrayOfRanges,
|
||||
nsTArray<OwningNonNull<nsINode>>& aOutArrayOfNodes,
|
||||
|
@ -913,6 +948,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* GetNodesFromPoint() constructs a list of nodes from a point that will be
|
||||
* operated on.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult
|
||||
GetNodesFromPoint(const EditorDOMPoint& aPoint, EditSubAction aEditSubAction,
|
||||
nsTArray<OwningNonNull<nsINode>>& outArrayOfNodes,
|
||||
|
@ -922,16 +958,19 @@ class HTMLEditRules : public TextEditRules {
|
|||
* GetNodesFromSelection() constructs a list of nodes from the selection that
|
||||
* will be operated on.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult
|
||||
GetNodesFromSelection(EditSubAction aEditSubAction,
|
||||
nsTArray<OwningNonNull<nsINode>>& outArrayOfNodes,
|
||||
TouchContent aTouchContent);
|
||||
|
||||
enum class EntireList { no, yes };
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult
|
||||
GetListActionNodes(nsTArray<OwningNonNull<nsINode>>& aOutArrayOfNodes,
|
||||
EntireList aEntireList, TouchContent aTouchContent);
|
||||
void GetDefinitionListItemTypes(Element* aElement, bool* aDT, bool* aDD);
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult GetParagraphFormatNodes(
|
||||
nsTArray<OwningNonNull<nsINode>>& outArrayOfNodes);
|
||||
void LookInsideDivBQandList(nsTArray<OwningNonNull<nsINode>>& aNodeArray);
|
||||
|
@ -959,6 +998,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* be set if <br> is at start edge of aNode) and
|
||||
* aNode itself.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult BustUpInlinesAtBRs(
|
||||
nsIContent& aNode, nsTArray<OwningNonNull<nsINode>>& aOutArrayOfNodes);
|
||||
|
||||
|
@ -985,6 +1025,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* If aNodeArray has a table related element, <li>, <blockquote> or <div>,
|
||||
* it will removed and its contents will be moved to where it was.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult RemoveBlockStyle(nsTArray<OwningNonNull<nsINode>>& aNodeArray);
|
||||
|
||||
/**
|
||||
|
@ -1003,6 +1044,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* @param aNodeArray Must be descendants of a node.
|
||||
* @param aBlockTag The element name of new block elements.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult ApplyBlockStyle(
|
||||
nsTArray<OwningNonNull<nsINode>>& aNodeArray, nsAtom& aBlockTag);
|
||||
|
||||
|
@ -1015,6 +1057,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* @param aNodeArray Nodes which will be moved into created
|
||||
* <blockquote> elements.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult
|
||||
MakeBlockquote(nsTArray<OwningNonNull<nsINode>>& aNodeArray);
|
||||
|
||||
|
@ -1060,6 +1103,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* @param aNewFirstChildOfRightNode
|
||||
* The point at the first child of aRightNode.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult JoinNearestEditableNodesWithTransaction(
|
||||
nsIContent& aLeftNode, nsIContent& aRightNode,
|
||||
EditorDOMPoint* aNewFirstChildOfRightNode);
|
||||
|
@ -1081,6 +1125,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* removed (i.e., unwrapped contents of
|
||||
* aListItem). Otherwise, false.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult PopListItem(nsIContent& aListItem,
|
||||
bool* aOutOfList = nullptr);
|
||||
|
||||
|
@ -1096,6 +1141,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
*
|
||||
* @param aListElement A <ul>, <ol> or <dl> element.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult RemoveListStructure(Element& aListElement);
|
||||
|
||||
/**
|
||||
|
@ -1216,6 +1262,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* @param aDescendantsOnly true if align information of aNode itself
|
||||
* shouldn't be removed. Otherwise, false.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult RemoveAlignment(nsINode& aNode,
|
||||
const nsAString& aAlignType,
|
||||
bool aDescendantsOnly);
|
||||
|
@ -1245,6 +1292,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* descendants or only descendants.
|
||||
*/
|
||||
enum class ResetAlignOf { ElementAndDescendants, OnlyDescendants };
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult AlignBlock(Element& aElement,
|
||||
const nsAString& aAlignType,
|
||||
ResetAlignOf aResetAlignOf);
|
||||
|
@ -1256,6 +1304,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
*
|
||||
* @param aElement The element to be indented.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult IncreaseMarginToIndent(Element& aElement) {
|
||||
return ChangeMarginStart(aElement, true);
|
||||
}
|
||||
|
@ -1267,6 +1316,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
*
|
||||
* @param aElement The element to be outdented.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult DecreaseMarginToOutdent(Element& aElement) {
|
||||
return ChangeMarginStart(aElement, false);
|
||||
}
|
||||
|
@ -1281,6 +1331,7 @@ class HTMLEditRules : public TextEditRules {
|
|||
* @param aElement The element to be indented or outdented.
|
||||
* @param aIncrease true for indent, false for outdent.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult ChangeMarginStart(Element& aElement, bool aIncrease);
|
||||
|
||||
/**
|
||||
|
|
|
@ -500,7 +500,8 @@ nsresult HTMLEditor::InitRules() {
|
|||
// instantiate the rules for the html editor
|
||||
mRules = new HTMLEditRules();
|
||||
}
|
||||
return mRules->Init(this);
|
||||
RefPtr<TextEditRules> rules(mRules);
|
||||
return rules->Init(this);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -1484,7 +1485,8 @@ HTMLEditor::RebuildDocumentFromSource(const nsAString& aSourceString) {
|
|||
NS_ENSURE_TRUE(child && child->IsElement(), NS_ERROR_NULL_POINTER);
|
||||
|
||||
// Copy all attributes from the div child to current body element
|
||||
CloneAttributesWithTransaction(*rootElement, *child->AsElement());
|
||||
CloneAttributesWithTransaction(*rootElement,
|
||||
MOZ_KnownLive(*child->AsElement()));
|
||||
|
||||
// place selection at first editable content
|
||||
return MaybeCollapseSelectionAtFirstEditableNode(false);
|
||||
|
@ -2945,7 +2947,7 @@ HTMLEditor::InsertLinkAroundSelection(Element* aAnchorElement) {
|
|||
|
||||
attribute->GetValue(value);
|
||||
|
||||
rv = SetInlinePropertyInternal(*nsGkAtoms::a, name, value);
|
||||
rv = SetInlinePropertyInternal(*nsGkAtoms::a, MOZ_KnownLive(name), value);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -4572,8 +4574,8 @@ nsresult HTMLEditor::CopyLastEditableChildStylesWithTransaction(
|
|||
}
|
||||
// Otherwise, inserts new parent inline container to the previous inserted
|
||||
// inline container.
|
||||
lastClonedElement =
|
||||
InsertContainerWithTransaction(*lastClonedElement, *tagName);
|
||||
lastClonedElement = InsertContainerWithTransaction(*lastClonedElement,
|
||||
MOZ_KnownLive(*tagName));
|
||||
if (NS_WARN_IF(!lastClonedElement)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
|
@ -126,6 +126,7 @@ class HTMLEditor final : public TextEditor,
|
|||
bool GetReturnInParagraphCreatesNewParagraph();
|
||||
|
||||
// TextEditor overrides
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual nsresult Init(Document& aDoc, Element* aRoot,
|
||||
nsISelectionController* aSelCon, uint32_t aFlags,
|
||||
const nsAString& aValue) override;
|
||||
|
@ -200,6 +201,7 @@ class HTMLEditor final : public TextEditor,
|
|||
* this creates an <a> element.
|
||||
* @return Newly created element.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
already_AddRefed<Element> CreateElementWithDefaults(const nsAtom& aTagName);
|
||||
|
||||
/**
|
||||
|
@ -224,6 +226,7 @@ class HTMLEditor final : public TextEditor,
|
|||
* @param aY [IN] vertical position of the pointer
|
||||
* @param aTarget [IN] the element triggering the event
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult OnMouseUp(int32_t aX, int32_t aY, Element* aTarget);
|
||||
|
||||
/**
|
||||
|
@ -345,6 +348,7 @@ class HTMLEditor final : public TextEditor,
|
|||
* This automatically removes exclusive style, however, treats all changes
|
||||
* as a transaction.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult SetInlinePropertyAsAction(nsAtom& aProperty, nsAtom* aAttribute,
|
||||
const nsAString& aValue);
|
||||
|
||||
|
@ -371,6 +375,7 @@ class HTMLEditor final : public TextEditor,
|
|||
* nsGkAtoms::bgcolor. Otherwise, set nullptr.
|
||||
* Must not use nsGkAtoms::_empty here.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult RemoveInlinePropertyAsAction(nsAtom& aProperty, nsAtom* aAttribute);
|
||||
|
||||
/**
|
||||
|
@ -455,16 +460,6 @@ class HTMLEditor final : public TextEditor,
|
|||
*/
|
||||
Element* GetActiveEditingHost() const;
|
||||
|
||||
/** Insert a string as quoted text
|
||||
* (whose representation is dependant on the editor type),
|
||||
* replacing the selected text (if any).
|
||||
*
|
||||
* @param aQuotedText The actual text to be quoted
|
||||
* @parem aNodeInserted Return the node which was inserted.
|
||||
*/
|
||||
nsresult InsertAsQuotation(const nsAString& aQuotedText,
|
||||
nsINode** aNodeInserted);
|
||||
|
||||
/**
|
||||
* Inserts a plaintext string at the current location,
|
||||
* with special processing for lines beginning with ">",
|
||||
|
@ -522,6 +517,7 @@ class HTMLEditor final : public TextEditor,
|
|||
/**
|
||||
* InsertTextWithTransaction() inserts aStringToInsert at aPointToInsert.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual nsresult InsertTextWithTransaction(
|
||||
Document& aDocument, const nsAString& aStringToInsert,
|
||||
const EditorRawDOMPoint& aPointToInsert,
|
||||
|
@ -539,6 +535,7 @@ class HTMLEditor final : public TextEditor,
|
|||
* placeholder, this is set to the new <br>
|
||||
* element.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult CopyLastEditableChildStylesWithTransaction(
|
||||
Element& aPreviousBlock, Element& aNewBlock,
|
||||
RefPtr<Element>* aNewBrElement);
|
||||
|
@ -551,13 +548,16 @@ class HTMLEditor final : public TextEditor,
|
|||
*
|
||||
* @param aElement Block element to be removed.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult RemoveBlockContainerWithTransaction(Element& aElement);
|
||||
|
||||
virtual Element* GetEditorRoot() const override;
|
||||
using EditorBase::IsEditable;
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual nsresult RemoveAttributeOrEquivalent(
|
||||
Element* aElement, nsAtom* aAttribute,
|
||||
bool aSuppressTransaction) override;
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual nsresult SetAttributeOrEquivalent(Element* aElement,
|
||||
nsAtom* aAttribute,
|
||||
const nsAString& aValue,
|
||||
|
@ -667,6 +667,7 @@ class HTMLEditor final : public TextEditor,
|
|||
* @param aEnabled [IN] true to absolutely position the element,
|
||||
* false to put it back in the normal flow
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult SetPositionToAbsoluteOrStatic(Element& aElement, bool aEnabled);
|
||||
|
||||
/**
|
||||
|
@ -764,10 +765,12 @@ class HTMLEditor final : public TextEditor,
|
|||
* Helper routines for font size changing.
|
||||
*/
|
||||
enum class FontSize { incr, decr };
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult RelativeFontChangeOnTextNode(FontSize aDir, Text& aTextNode,
|
||||
int32_t aStartOffset,
|
||||
int32_t aEndOffset);
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult SetInlinePropertyOnNode(nsIContent& aNode, nsAtom& aProperty,
|
||||
nsAtom* aAttribute, const nsAString& aValue);
|
||||
|
||||
|
@ -930,10 +933,12 @@ class HTMLEditor final : public TextEditor,
|
|||
const nsAString* aValue, bool* aFirst,
|
||||
bool* aAny, bool* aAll, nsAString* outValue);
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult ClearStyle(nsCOMPtr<nsINode>* aNode, int32_t* aOffset,
|
||||
nsAtom* aProperty, nsAtom* aAttribute);
|
||||
|
||||
nsresult SetPositionToAbsolute(Element& aElement);
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult SetPositionToStatic(Element& aElement);
|
||||
|
||||
/**
|
||||
|
@ -947,6 +952,7 @@ class HTMLEditor final : public TextEditor,
|
|||
protected: // Called by helper classes.
|
||||
virtual void OnStartToHandleTopLevelEditSubAction(
|
||||
EditSubAction aEditSubAction, nsIEditor::EDirection aDirection) override;
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual void OnEndHandlingTopLevelEditSubAction() override;
|
||||
|
||||
protected: // Shouldn't be used by friend classes
|
||||
|
@ -1435,6 +1441,7 @@ class HTMLEditor final : public TextEditor,
|
|||
* text.
|
||||
* @param aNodeInserted [OUT] The new <blockquote> element.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult InsertAsCitedQuotationInternal(const nsAString& aQuotedText,
|
||||
const nsAString& aCitation,
|
||||
bool aInsertHTML,
|
||||
|
@ -1458,7 +1465,7 @@ class HTMLEditor final : public TextEditor,
|
|||
* Otherwise, the result is not set.
|
||||
*/
|
||||
template <typename PT, typename CT>
|
||||
EditorDOMPoint InsertNodeIntoProperAncestorWithTransaction(
|
||||
MOZ_CAN_RUN_SCRIPT EditorDOMPoint InsertNodeIntoProperAncestorWithTransaction(
|
||||
nsIContent& aNode, const EditorDOMPointBase<PT, CT>& aPointToInsert,
|
||||
SplitAtEdges aSplitAtEdges);
|
||||
|
||||
|
@ -1489,10 +1496,13 @@ class HTMLEditor final : public TextEditor,
|
|||
*/
|
||||
nsresult IndentOrOutdentAsSubAction(EditSubAction aEditSubAction);
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult LoadHTML(const nsAString& aInputString);
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult SetInlinePropertyInternal(nsAtom& aProperty, nsAtom* aAttribute,
|
||||
const nsAString& aValue);
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult RemoveInlinePropertyInternal(nsAtom* aProperty, nsAtom* aAttribute);
|
||||
|
||||
/**
|
||||
|
@ -1502,6 +1512,7 @@ class HTMLEditor final : public TextEditor,
|
|||
* @param aSourceToInsert HTML source fragment to replace the children
|
||||
* of <head> element.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult ReplaceHeadContentsWithSourceWithTransaction(
|
||||
const nsAString& aSourceToInsert);
|
||||
|
||||
|
@ -1630,6 +1641,7 @@ class HTMLEditor final : public TextEditor,
|
|||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(BlobReader)
|
||||
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(BlobReader)
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult OnResult(const nsACString& aResult);
|
||||
nsresult OnError(const nsAString& aErrorName);
|
||||
|
||||
|
@ -1645,6 +1657,7 @@ class HTMLEditor final : public TextEditor,
|
|||
bool mDoDeleteSelection;
|
||||
};
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual nsresult InitRules() override;
|
||||
|
||||
virtual void CreateEventListeners() override;
|
||||
|
@ -1743,6 +1756,7 @@ class HTMLEditor final : public TextEditor,
|
|||
* of course)
|
||||
* This doesn't change or use the current selection.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult InsertCell(Element* aCell, int32_t aRowSpan, int32_t aColSpan,
|
||||
bool aAfter, bool aIsHeader, Element** aNewCell);
|
||||
|
||||
|
@ -1845,6 +1859,7 @@ class HTMLEditor final : public TextEditor,
|
|||
/**
|
||||
* Move all contents from aCellToMerge into aTargetCell (append at end).
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult MergeCells(RefPtr<Element> aTargetCell, RefPtr<Element> aCellToMerge,
|
||||
bool aDeleteCellToMerge);
|
||||
|
||||
|
@ -1902,10 +1917,12 @@ class HTMLEditor final : public TextEditor,
|
|||
nsresult GetCellSpansAt(Element* aTable, int32_t aRowIndex, int32_t aColIndex,
|
||||
int32_t& aActualRowSpan, int32_t& aActualColSpan);
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult SplitCellIntoColumns(Element* aTable, int32_t aRowIndex,
|
||||
int32_t aColIndex, int32_t aColSpanLeft,
|
||||
int32_t aColSpanRight, Element** aNewCell);
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult SplitCellIntoRows(Element* aTable, int32_t aRowIndex,
|
||||
int32_t aColIndex, int32_t aRowSpanAbove,
|
||||
int32_t aRowSpanBelow, Element** aNewCell);
|
||||
|
@ -1930,6 +1947,7 @@ class HTMLEditor final : public TextEditor,
|
|||
* or <table> element itself. Otherwise,
|
||||
* this returns NS_OK but does nothing.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult NormalizeTableInternal(Element& aTableOrElementInTable);
|
||||
|
||||
/**
|
||||
|
@ -2053,14 +2071,18 @@ class HTMLEditor final : public TextEditor,
|
|||
/**
|
||||
* Increase/decrease the font size of selection.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult RelativeFontChange(FontSize aDir);
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult RelativeFontChangeOnNode(int32_t aSizeChange, nsIContent* aNode);
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult RelativeFontChangeHelper(int32_t aSizeChange, nsINode* aNode);
|
||||
|
||||
/**
|
||||
* Helper routines for inline style.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult SetInlinePropertyOnTextNode(Text& aData, int32_t aStartOffset,
|
||||
int32_t aEndOffset, nsAtom& aProperty,
|
||||
nsAtom* aAttribute,
|
||||
|
@ -2070,6 +2092,7 @@ class HTMLEditor final : public TextEditor,
|
|||
nsresult PromoteRangeIfStartsOrEndsInNamedAnchor(nsRange& aRange);
|
||||
nsresult SplitStyleAboveRange(nsRange* aRange, nsAtom* aProperty,
|
||||
nsAtom* aAttribute);
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult RemoveStyleInside(nsIContent& aNode, nsAtom* aProperty,
|
||||
nsAtom* aAttribute,
|
||||
const bool aChildrenOnly = false);
|
||||
|
@ -2080,6 +2103,7 @@ class HTMLEditor final : public TextEditor,
|
|||
bool IsOnlyAttribute(const Element* aElement, nsAtom* aAttribute);
|
||||
|
||||
bool HasStyleOrIdOrClass(Element* aElement);
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult RemoveElementIfNoStyleOrIdOrClass(Element& aElement);
|
||||
|
||||
/**
|
||||
|
@ -2099,7 +2123,7 @@ class HTMLEditor final : public TextEditor,
|
|||
* aClearStyle should be set to false if you want the paste to be affected by
|
||||
* local style (e.g., for the insertHTML command).
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult DoInsertHTMLWithContext(
|
||||
const nsAString& aInputString, const nsAString& aContextStr,
|
||||
const nsAString& aInfoStr, const nsAString& aFlavor, Document* aSourceDoc,
|
||||
|
@ -2226,6 +2250,7 @@ class HTMLEditor final : public TextEditor,
|
|||
int32_t GetNewResizingWidth(int32_t aX, int32_t aY);
|
||||
int32_t GetNewResizingHeight(int32_t aX, int32_t aY);
|
||||
void HideShadowAndInfo();
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
void SetFinalSize(int32_t aX, int32_t aY);
|
||||
void SetResizeIncrements(int32_t aX, int32_t aY, int32_t aW, int32_t aH,
|
||||
bool aPreserveRatio);
|
||||
|
@ -2318,6 +2343,7 @@ class HTMLEditor final : public TextEditor,
|
|||
|
||||
bool IsSimpleModifiableNode(nsIContent* aContent, nsAtom* aProperty,
|
||||
nsAtom* aAttribute, const nsAString* aValue);
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult SetInlinePropertyOnNodeImpl(nsIContent& aNode, nsAtom& aProperty,
|
||||
nsAtom* aAttribute,
|
||||
const nsAString& aValue);
|
||||
|
|
|
@ -34,8 +34,9 @@ namespace mozilla {
|
|||
using dom::Element;
|
||||
|
||||
// prototype
|
||||
static nsresult GetListState(HTMLEditor* aHTMLEditor, bool* aMixed,
|
||||
nsAString& aLocalName);
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY // XXX Needs to change nsIControllerCommand.idl
|
||||
static nsresult
|
||||
GetListState(HTMLEditor* aHTMLEditor, bool* aMixed, nsAString& aLocalName);
|
||||
|
||||
// defines
|
||||
#define STATE_ENABLED "state_enabled"
|
||||
|
@ -84,7 +85,7 @@ StateUpdatingCommandBase::DoCommand(const char* aCommandName,
|
|||
if (NS_WARN_IF(!htmlEditor)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return ToggleState(htmlEditor);
|
||||
return ToggleState(MOZ_KnownLive(htmlEditor));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -245,15 +246,16 @@ nsresult StyleUpdatingCommand::ToggleState(HTMLEditor* aHTMLEditor) {
|
|||
}
|
||||
}
|
||||
|
||||
nsresult rv = aHTMLEditor->RemoveInlinePropertyAsAction(*mTagName, nullptr);
|
||||
nsresult rv = aHTMLEditor->RemoveInlinePropertyAsAction(
|
||||
MOZ_KnownLive(*mTagName), nullptr);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult rv =
|
||||
aHTMLEditor->SetInlinePropertyAsAction(*mTagName, nullptr, EmptyString());
|
||||
nsresult rv = aHTMLEditor->SetInlinePropertyAsAction(MOZ_KnownLive(*mTagName),
|
||||
nullptr, EmptyString());
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -400,7 +402,7 @@ RemoveListCommand::IsCommandEnabled(const char* aCommandName,
|
|||
|
||||
bool bMixed;
|
||||
nsAutoString localName;
|
||||
nsresult rv = GetListState(htmlEditor, &bMixed, localName);
|
||||
nsresult rv = GetListState(MOZ_KnownLive(htmlEditor), &bMixed, localName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*outCmdEnabled = bMixed || !localName.IsEmpty();
|
||||
|
@ -589,7 +591,7 @@ MultiStateCommandBase::DoCommandParams(const char* aCommandName,
|
|||
params->GetString(STATE_ATTRIBUTE, attribute);
|
||||
}
|
||||
}
|
||||
return SetState(htmlEditor, attribute);
|
||||
return SetState(MOZ_KnownLive(htmlEditor), attribute);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -604,7 +606,7 @@ MultiStateCommandBase::GetCommandStateParams(const char* aCommandName,
|
|||
if (NS_WARN_IF(!htmlEditor)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return GetCurrentState(htmlEditor, aParams);
|
||||
return GetCurrentState(MOZ_KnownLive(htmlEditor), aParams);
|
||||
}
|
||||
|
||||
ParagraphStateCommand::ParagraphStateCommand() : MultiStateCommandBase() {}
|
||||
|
@ -1155,7 +1157,7 @@ RemoveStylesCommand::DoCommand(const char* aCommandName, nsISupports* refCon) {
|
|||
if (!htmlEditor) {
|
||||
return NS_OK;
|
||||
}
|
||||
return htmlEditor->RemoveAllInlineProperties();
|
||||
return MOZ_KnownLive(htmlEditor)->RemoveAllInlineProperties();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -1201,7 +1203,7 @@ IncreaseFontSizeCommand::DoCommand(const char* aCommandName,
|
|||
if (!htmlEditor) {
|
||||
return NS_OK;
|
||||
}
|
||||
return htmlEditor->IncreaseFontSize();
|
||||
return MOZ_KnownLive(htmlEditor)->IncreaseFontSize();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -1247,7 +1249,7 @@ DecreaseFontSizeCommand::DoCommand(const char* aCommandName,
|
|||
if (!htmlEditor) {
|
||||
return NS_OK;
|
||||
}
|
||||
return htmlEditor->DecreaseFontSize();
|
||||
return MOZ_KnownLive(htmlEditor)->DecreaseFontSize();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -1297,7 +1299,7 @@ InsertHTMLCommand::DoCommand(const char* aCommandName, nsISupports* refCon) {
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsAutoString html;
|
||||
return htmlEditor->InsertHTML(html);
|
||||
return MOZ_KnownLive(htmlEditor)->InsertHTML(html);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -1322,7 +1324,7 @@ InsertHTMLCommand::DoCommandParams(const char* aCommandName,
|
|||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
return htmlEditor->InsertHTML(html);
|
||||
return MOZ_KnownLive(htmlEditor)->InsertHTML(html);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -1373,11 +1375,14 @@ InsertTagCommand::DoCommand(const char* aCmdName, nsISupports* refCon) {
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
RefPtr<Element> newElement = htmlEditor->CreateElementWithDefaults(*mTagName);
|
||||
RefPtr<Element> newElement =
|
||||
MOZ_KnownLive(htmlEditor)
|
||||
->CreateElementWithDefaults(MOZ_KnownLive(*mTagName));
|
||||
if (NS_WARN_IF(!newElement)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsresult rv = htmlEditor->InsertElementAtSelection(newElement, true);
|
||||
nsresult rv =
|
||||
MOZ_KnownLive(htmlEditor)->InsertElementAtSelection(newElement, true);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -1428,7 +1433,9 @@ InsertTagCommand::DoCommandParams(const char* aCommandName,
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
RefPtr<Element> newElement = htmlEditor->CreateElementWithDefaults(*mTagName);
|
||||
RefPtr<Element> newElement =
|
||||
MOZ_KnownLive(htmlEditor)
|
||||
->CreateElementWithDefaults(MOZ_KnownLive(*mTagName));
|
||||
if (NS_WARN_IF(!newElement)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -1441,14 +1448,14 @@ InsertTagCommand::DoCommandParams(const char* aCommandName,
|
|||
|
||||
// do actual insertion
|
||||
if (mTagName == nsGkAtoms::a) {
|
||||
rv = htmlEditor->InsertLinkAroundSelection(newElement);
|
||||
rv = MOZ_KnownLive(htmlEditor)->InsertLinkAroundSelection(newElement);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
rv = htmlEditor->InsertElementAtSelection(newElement, true);
|
||||
rv = MOZ_KnownLive(htmlEditor)->InsertElementAtSelection(newElement, true);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -1472,7 +1479,8 @@ InsertTagCommand::GetCommandStateParams(const char* aCommandName,
|
|||
/****************************/
|
||||
|
||||
static nsresult GetListState(HTMLEditor* aHTMLEditor, bool* aMixed,
|
||||
nsAString& aLocalName) {
|
||||
nsAString& aLocalName)
|
||||
MOZ_CAN_RUN_SCRIPT_FOR_DEFINITION {
|
||||
MOZ_ASSERT(aHTMLEditor);
|
||||
MOZ_ASSERT(aMixed);
|
||||
|
||||
|
|
|
@ -58,10 +58,12 @@ class StateUpdatingCommandBase : public HTMLEditorCommandBase {
|
|||
virtual ~StateUpdatingCommandBase();
|
||||
|
||||
// get the current state (on or off) for this style or block format
|
||||
virtual nsresult GetCurrentState(HTMLEditor* aHTMLEditor,
|
||||
nsICommandParams* aParams) = 0;
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY // XXX Needs to change nsIControllerCommand.idl
|
||||
virtual nsresult
|
||||
GetCurrentState(HTMLEditor* aHTMLEditor, nsICommandParams* aParams) = 0;
|
||||
|
||||
// add/remove the style
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual nsresult ToggleState(HTMLEditor* aHTMLEditor) = 0;
|
||||
|
||||
protected:
|
||||
|
@ -76,10 +78,12 @@ class StyleUpdatingCommand final : public StateUpdatingCommandBase {
|
|||
|
||||
protected:
|
||||
// get the current state (on or off) for this style or block format
|
||||
nsresult GetCurrentState(HTMLEditor* aHTMLEditor,
|
||||
nsICommandParams* aParams) final;
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY // XXX Needs to change nsIControllerCommand.idl
|
||||
nsresult
|
||||
GetCurrentState(HTMLEditor* aHTMLEditor, nsICommandParams* aParams) final;
|
||||
|
||||
// add/remove the style
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult ToggleState(HTMLEditor* aHTMLEditor) final;
|
||||
};
|
||||
|
||||
|
@ -103,10 +107,12 @@ class ListCommand final : public StateUpdatingCommandBase {
|
|||
|
||||
protected:
|
||||
// get the current state (on or off) for this style or block format
|
||||
nsresult GetCurrentState(HTMLEditor* aHTMLEditor,
|
||||
nsICommandParams* aParams) final;
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY // XXX Needs to change nsIControllerCommand.idl
|
||||
nsresult
|
||||
GetCurrentState(HTMLEditor* aHTMLEditor, nsICommandParams* aParams) final;
|
||||
|
||||
// add/remove the style
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult ToggleState(HTMLEditor* aHTMLEditor) final;
|
||||
};
|
||||
|
||||
|
@ -116,10 +122,12 @@ class ListItemCommand final : public StateUpdatingCommandBase {
|
|||
|
||||
protected:
|
||||
// get the current state (on or off) for this style or block format
|
||||
nsresult GetCurrentState(HTMLEditor* aHTMLEditor,
|
||||
nsICommandParams* aParams) final;
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY // XXX Needs to change nsIControllerCommand.idl
|
||||
nsresult
|
||||
GetCurrentState(HTMLEditor* aHTMLEditor, nsICommandParams* aParams) final;
|
||||
|
||||
// add/remove the style
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult ToggleState(HTMLEditor* aHTMLEditor) final;
|
||||
};
|
||||
|
||||
|
@ -135,8 +143,10 @@ class MultiStateCommandBase : public HTMLEditorCommandBase {
|
|||
protected:
|
||||
virtual ~MultiStateCommandBase();
|
||||
|
||||
virtual nsresult GetCurrentState(HTMLEditor* aHTMLEditor,
|
||||
nsICommandParams* aParams) = 0;
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY // XXX Needs to change nsIControllerCommand.idl
|
||||
virtual nsresult
|
||||
GetCurrentState(HTMLEditor* aHTMLEditor, nsICommandParams* aParams) = 0;
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual nsresult SetState(HTMLEditor* aHTMLEditor,
|
||||
const nsString& newState) = 0;
|
||||
};
|
||||
|
@ -146,8 +156,10 @@ class ParagraphStateCommand final : public MultiStateCommandBase {
|
|||
ParagraphStateCommand();
|
||||
|
||||
protected:
|
||||
nsresult GetCurrentState(HTMLEditor* aHTMLEditor,
|
||||
nsICommandParams* aParams) final;
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY // XXX Needs to change nsIControllerCommand.idl
|
||||
nsresult
|
||||
GetCurrentState(HTMLEditor* aHTMLEditor, nsICommandParams* aParams) final;
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult SetState(HTMLEditor* aHTMLEditor, const nsString& newState) final;
|
||||
};
|
||||
|
||||
|
@ -156,8 +168,10 @@ class FontFaceStateCommand final : public MultiStateCommandBase {
|
|||
FontFaceStateCommand();
|
||||
|
||||
protected:
|
||||
nsresult GetCurrentState(HTMLEditor* aHTMLEditor,
|
||||
nsICommandParams* aParams) final;
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY // XXX Needs to change nsIControllerCommand.idl
|
||||
nsresult
|
||||
GetCurrentState(HTMLEditor* aHTMLEditor, nsICommandParams* aParams) final;
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult SetState(HTMLEditor* aHTMLEditor, const nsString& newState) final;
|
||||
};
|
||||
|
||||
|
@ -166,8 +180,10 @@ class FontSizeStateCommand final : public MultiStateCommandBase {
|
|||
FontSizeStateCommand();
|
||||
|
||||
protected:
|
||||
nsresult GetCurrentState(HTMLEditor* aHTMLEditor,
|
||||
nsICommandParams* aParams) final;
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY // XXX Needs to change nsIControllerCommand.idl
|
||||
nsresult
|
||||
GetCurrentState(HTMLEditor* aHTMLEditor, nsICommandParams* aParams) final;
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult SetState(HTMLEditor* aHTMLEditor, const nsString& newState) final;
|
||||
};
|
||||
|
||||
|
@ -178,8 +194,10 @@ class HighlightColorStateCommand final : public MultiStateCommandBase {
|
|||
protected:
|
||||
NS_IMETHOD IsCommandEnabled(const char* aCommandName,
|
||||
nsISupports* aCommandRefCon, bool* _retval) final;
|
||||
nsresult GetCurrentState(HTMLEditor* aHTMLEditor,
|
||||
nsICommandParams* aParams) final;
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY // XXX Needs to change nsIControllerCommand.idl
|
||||
nsresult
|
||||
GetCurrentState(HTMLEditor* aHTMLEditor, nsICommandParams* aParams) final;
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult SetState(HTMLEditor* aHTMLEditor, const nsString& newState) final;
|
||||
};
|
||||
|
||||
|
@ -188,8 +206,10 @@ class FontColorStateCommand final : public MultiStateCommandBase {
|
|||
FontColorStateCommand();
|
||||
|
||||
protected:
|
||||
nsresult GetCurrentState(HTMLEditor* aHTMLEditor,
|
||||
nsICommandParams* aParams) final;
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY // XXX Needs to change nsIControllerCommand.idl
|
||||
nsresult
|
||||
GetCurrentState(HTMLEditor* aHTMLEditor, nsICommandParams* aParams) final;
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult SetState(HTMLEditor* aHTMLEditor, const nsString& newState) final;
|
||||
};
|
||||
|
||||
|
@ -198,8 +218,10 @@ class AlignCommand final : public MultiStateCommandBase {
|
|||
AlignCommand();
|
||||
|
||||
protected:
|
||||
nsresult GetCurrentState(HTMLEditor* aHTMLEditor,
|
||||
nsICommandParams* aParams) final;
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY // XXX Needs to change nsIControllerCommand.idl
|
||||
nsresult
|
||||
GetCurrentState(HTMLEditor* aHTMLEditor, nsICommandParams* aParams) final;
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult SetState(HTMLEditor* aHTMLEditor, const nsString& newState) final;
|
||||
};
|
||||
|
||||
|
@ -208,8 +230,10 @@ class BackgroundColorStateCommand final : public MultiStateCommandBase {
|
|||
BackgroundColorStateCommand();
|
||||
|
||||
protected:
|
||||
nsresult GetCurrentState(HTMLEditor* aHTMLEditor,
|
||||
nsICommandParams* aParams) final;
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY // XXX Needs to change nsIControllerCommand.idl
|
||||
nsresult
|
||||
GetCurrentState(HTMLEditor* aHTMLEditor, nsICommandParams* aParams) final;
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult SetState(HTMLEditor* aHTMLEditor, const nsString& newState) final;
|
||||
};
|
||||
|
||||
|
@ -220,8 +244,10 @@ class AbsolutePositioningCommand final : public StateUpdatingCommandBase {
|
|||
protected:
|
||||
NS_IMETHOD IsCommandEnabled(const char* aCommandName,
|
||||
nsISupports* aCommandRefCon, bool* _retval) final;
|
||||
nsresult GetCurrentState(HTMLEditor* aHTMLEditor,
|
||||
nsICommandParams* aParams) final;
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY // XXX Needs to change nsIControllerCommand.idl
|
||||
nsresult
|
||||
GetCurrentState(HTMLEditor* aHTMLEditor, nsICommandParams* aParams) final;
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult ToggleState(HTMLEditor* aHTMLEditor) final;
|
||||
};
|
||||
|
||||
|
|
|
@ -523,7 +523,7 @@ nsresult HTMLEditor::DoInsertHTMLWithContext(
|
|||
// Try to insert.
|
||||
EditorDOMPoint insertedPoint =
|
||||
InsertNodeIntoProperAncestorWithTransaction(
|
||||
*curNode->AsContent(), pointToInsert,
|
||||
MOZ_KnownLive(*curNode->AsContent()), pointToInsert,
|
||||
SplitAtEdges::eDoNotCreateEmptyContainer);
|
||||
if (insertedPoint.IsSet()) {
|
||||
lastInsertNode = curNode->AsContent();
|
||||
|
@ -542,7 +542,7 @@ nsresult HTMLEditor::DoInsertHTMLWithContext(
|
|||
}
|
||||
nsCOMPtr<nsINode> oldParent = content->GetParentNode();
|
||||
insertedPoint = InsertNodeIntoProperAncestorWithTransaction(
|
||||
*content->GetParent(), pointToInsert,
|
||||
MOZ_KnownLive(*content->GetParent()), pointToInsert,
|
||||
SplitAtEdges::eDoNotCreateEmptyContainer);
|
||||
if (insertedPoint.IsSet()) {
|
||||
insertedContextParent = oldParent;
|
||||
|
@ -982,9 +982,13 @@ nsresult HTMLEditor::BlobReader::OnResult(const nsACString& aResult) {
|
|||
}
|
||||
|
||||
AutoPlaceholderBatch treatAsOneTransaction(*mHTMLEditor);
|
||||
rv = mHTMLEditor->DoInsertHTMLWithContext(
|
||||
stuffToPaste, EmptyString(), EmptyString(), NS_LITERAL_STRING(kFileMime),
|
||||
mSourceDoc, mPointToInsert, mDoDeleteSelection, mIsSafe, false);
|
||||
RefPtr<Document> sourceDocument(mSourceDoc);
|
||||
EditorDOMPoint pointToInsert(mPointToInsert);
|
||||
rv = MOZ_KnownLive(mHTMLEditor)
|
||||
->DoInsertHTMLWithContext(stuffToPaste, EmptyString(), EmptyString(),
|
||||
NS_LITERAL_STRING(kFileMime),
|
||||
sourceDocument, pointToInsert,
|
||||
mDoDeleteSelection, mIsSafe, false);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return EditorBase::ToGenericNSResult(rv);
|
||||
}
|
||||
|
@ -1009,6 +1013,7 @@ class SlurpBlobEventListener final : public nsIDOMEventListener {
|
|||
explicit SlurpBlobEventListener(HTMLEditor::BlobReader* aListener)
|
||||
: mListener(aListener) {}
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
NS_IMETHOD HandleEvent(Event* aEvent) override;
|
||||
|
||||
private:
|
||||
|
@ -1041,16 +1046,17 @@ SlurpBlobEventListener::HandleEvent(Event* aEvent) {
|
|||
|
||||
EventMessage message = aEvent->WidgetEventPtr()->mMessage;
|
||||
|
||||
RefPtr<HTMLEditor::BlobReader> listener(mListener);
|
||||
if (message == eLoad) {
|
||||
MOZ_ASSERT(reader->DataFormat() == FileReader::FILE_AS_BINARY);
|
||||
|
||||
// The original data has been converted from Latin1 to UTF-16, this just
|
||||
// undoes that conversion.
|
||||
mListener->OnResult(NS_LossyConvertUTF16toASCII(reader->Result()));
|
||||
listener->OnResult(NS_LossyConvertUTF16toASCII(reader->Result()));
|
||||
} else if (message == eLoadError) {
|
||||
nsAutoString errorMessage;
|
||||
reader->GetError()->GetErrorMessage(errorMessage);
|
||||
mListener->OnError(errorMessage);
|
||||
listener->OnError(errorMessage);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1916,39 +1922,6 @@ nsresult HTMLEditor::InsertTextWithQuotationsInternal(
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsresult HTMLEditor::InsertAsQuotation(const nsAString& aQuotedText,
|
||||
nsINode** aNodeInserted) {
|
||||
if (IsPlaintextEditor()) {
|
||||
AutoEditActionDataSetter editActionData(*this, EditAction::eInsertText);
|
||||
if (NS_WARN_IF(!editActionData.CanHandle())) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
MOZ_ASSERT(!aQuotedText.IsVoid());
|
||||
editActionData.SetData(aQuotedText);
|
||||
AutoPlaceholderBatch treatAsOneTransaction(*this);
|
||||
nsresult rv = InsertAsPlaintextQuotation(aQuotedText, true, aNodeInserted);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return EditorBase::ToGenericNSResult(rv);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
AutoEditActionDataSetter editActionData(*this,
|
||||
EditAction::eInsertBlockquoteElement);
|
||||
if (NS_WARN_IF(!editActionData.CanHandle())) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
AutoPlaceholderBatch treatAsOneTransaction(*this);
|
||||
nsAutoString citation;
|
||||
nsresult rv = InsertAsCitedQuotationInternal(aQuotedText, citation, false,
|
||||
aNodeInserted);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return EditorBase::ToGenericNSResult(rv);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Insert plaintext as a quotation, with cite marks (e.g. "> ").
|
||||
// This differs from its corresponding method in TextEditor
|
||||
// in that here, quoted material is enclosed in a <pre> tag
|
||||
|
|
|
@ -228,7 +228,7 @@ nsresult HTMLEditorEventListener::MouseUp(MouseEvent* aMouseEvent) {
|
|||
|
||||
// FYI: We need to notify HTML editor of mouseup even if it's consumed
|
||||
// because HTML editor always needs to release grabbing resizer.
|
||||
HTMLEditor* htmlEditor = mEditorBase->AsHTMLEditor();
|
||||
RefPtr<HTMLEditor> htmlEditor = mEditorBase->AsHTMLEditor();
|
||||
MOZ_ASSERT(htmlEditor);
|
||||
|
||||
RefPtr<EventTarget> target = aMouseEvent->GetTarget();
|
||||
|
|
|
@ -74,6 +74,7 @@ class HTMLEditorEventListener final : public EditorEventListener {
|
|||
protected:
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual nsresult MouseDown(dom::MouseEvent* aMouseEvent) override;
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual nsresult MouseUp(dom::MouseEvent* aMouseEvent) override;
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual nsresult MouseClick(WidgetMouseEvent* aMouseClickEvent) override;
|
||||
|
|
|
@ -970,24 +970,25 @@ void HTMLEditor::SetFinalSize(int32_t aX, int32_t aY) {
|
|||
|
||||
// we want one transaction only from a user's point of view
|
||||
AutoPlaceholderBatch treatAsOneTransaction(*this);
|
||||
RefPtr<Element> resizedObject(mResizedObject);
|
||||
|
||||
if (mResizedObjectIsAbsolutelyPositioned) {
|
||||
if (setHeight) {
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*mResizedObject, *nsGkAtoms::top, y);
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*resizedObject, *nsGkAtoms::top, y);
|
||||
}
|
||||
if (setWidth) {
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*mResizedObject, *nsGkAtoms::left, x);
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*resizedObject, *nsGkAtoms::left, x);
|
||||
}
|
||||
}
|
||||
if (IsCSSEnabled() || mResizedObjectIsAbsolutelyPositioned) {
|
||||
if (setWidth &&
|
||||
mResizedObject->HasAttr(kNameSpaceID_None, nsGkAtoms::width)) {
|
||||
RemoveAttributeWithTransaction(*mResizedObject, *nsGkAtoms::width);
|
||||
resizedObject->HasAttr(kNameSpaceID_None, nsGkAtoms::width)) {
|
||||
RemoveAttributeWithTransaction(*resizedObject, *nsGkAtoms::width);
|
||||
}
|
||||
|
||||
if (setHeight &&
|
||||
mResizedObject->HasAttr(kNameSpaceID_None, nsGkAtoms::height)) {
|
||||
RemoveAttributeWithTransaction(*mResizedObject, *nsGkAtoms::height);
|
||||
resizedObject->HasAttr(kNameSpaceID_None, nsGkAtoms::height)) {
|
||||
RemoveAttributeWithTransaction(*resizedObject, *nsGkAtoms::height);
|
||||
}
|
||||
|
||||
if (setWidth) {
|
||||
|
@ -1005,30 +1006,30 @@ void HTMLEditor::SetFinalSize(int32_t aX, int32_t aY) {
|
|||
// triggering an immediate reflow; otherwise, we have problems
|
||||
// with asynchronous reflow
|
||||
if (setWidth) {
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*mResizedObject, *nsGkAtoms::width,
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*resizedObject, *nsGkAtoms::width,
|
||||
width);
|
||||
}
|
||||
if (setHeight) {
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*mResizedObject, *nsGkAtoms::height,
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*resizedObject, *nsGkAtoms::height,
|
||||
height);
|
||||
}
|
||||
if (setWidth) {
|
||||
nsAutoString w;
|
||||
w.AppendInt(width);
|
||||
SetAttributeWithTransaction(*mResizedObject, *nsGkAtoms::width, w);
|
||||
SetAttributeWithTransaction(*resizedObject, *nsGkAtoms::width, w);
|
||||
}
|
||||
if (setHeight) {
|
||||
nsAutoString h;
|
||||
h.AppendInt(height);
|
||||
SetAttributeWithTransaction(*mResizedObject, *nsGkAtoms::height, h);
|
||||
SetAttributeWithTransaction(*resizedObject, *nsGkAtoms::height, h);
|
||||
}
|
||||
|
||||
if (setWidth) {
|
||||
mCSSEditUtils->RemoveCSSProperty(*mResizedObject, *nsGkAtoms::width,
|
||||
mCSSEditUtils->RemoveCSSProperty(*resizedObject, *nsGkAtoms::width,
|
||||
EmptyString());
|
||||
}
|
||||
if (setHeight) {
|
||||
mCSSEditUtils->RemoveCSSProperty(*mResizedObject, *nsGkAtoms::height,
|
||||
mCSSEditUtils->RemoveCSSProperty(*resizedObject, *nsGkAtoms::height,
|
||||
EmptyString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -186,8 +186,8 @@ nsresult HTMLEditor::SetInlinePropertyInternal(nsAtom& aProperty,
|
|||
nsCOMPtr<nsINode> endNode = range->GetEndContainer();
|
||||
if (startNode && startNode == endNode && startNode->GetAsText()) {
|
||||
rv = SetInlinePropertyOnTextNode(
|
||||
*startNode->GetAsText(), range->StartOffset(), range->EndOffset(),
|
||||
aProperty, aAttribute, aValue);
|
||||
MOZ_KnownLive(*startNode->GetAsText()), range->StartOffset(),
|
||||
range->EndOffset(), aProperty, aAttribute, aValue);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -227,8 +227,8 @@ nsresult HTMLEditor::SetInlinePropertyInternal(nsAtom& aProperty,
|
|||
// subtree iterator works - it will not have reported it).
|
||||
if (startNode && startNode->GetAsText() && IsEditable(startNode)) {
|
||||
rv = SetInlinePropertyOnTextNode(
|
||||
*startNode->GetAsText(), range->StartOffset(), startNode->Length(),
|
||||
aProperty, aAttribute, aValue);
|
||||
MOZ_KnownLive(*startNode->GetAsText()), range->StartOffset(),
|
||||
startNode->Length(), aProperty, aAttribute, aValue);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -246,8 +246,8 @@ nsresult HTMLEditor::SetInlinePropertyInternal(nsAtom& aProperty,
|
|||
// separately handled (it does if it's a text node, due to how the
|
||||
// subtree iterator works - it will not have reported it).
|
||||
if (endNode && endNode->GetAsText() && IsEditable(endNode)) {
|
||||
rv = SetInlinePropertyOnTextNode(*endNode->GetAsText(), 0,
|
||||
range->EndOffset(), aProperty,
|
||||
rv = SetInlinePropertyOnTextNode(MOZ_KnownLive(*endNode->GetAsText()),
|
||||
0, range->EndOffset(), aProperty,
|
||||
aAttribute, aValue);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
|
@ -388,7 +388,7 @@ nsresult HTMLEditor::SetInlinePropertyOnTextNode(
|
|||
|
||||
if (aAttribute) {
|
||||
// Look for siblings that are correct type of node
|
||||
nsIContent* sibling = GetPriorHTMLSibling(textNodeForTheRange);
|
||||
nsCOMPtr<nsIContent> sibling = GetPriorHTMLSibling(textNodeForTheRange);
|
||||
if (IsSimpleModifiableNode(sibling, &aProperty, aAttribute, &aValue)) {
|
||||
// Previous sib is already right kind of inline node; slide this over
|
||||
return MoveNodeToEndWithTransaction(*textNodeForTheRange, *sibling);
|
||||
|
@ -817,7 +817,8 @@ nsresult HTMLEditor::RemoveStyleInside(nsIContent& aNode, nsAtom* aProperty,
|
|||
return rv;
|
||||
}
|
||||
}
|
||||
nsresult rv = RemoveContainerWithTransaction(*aNode.AsElement());
|
||||
nsresult rv =
|
||||
RemoveContainerWithTransaction(MOZ_KnownLive(*aNode.AsElement()));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else if (aNode.IsElement()) {
|
||||
// otherwise we just want to eliminate the attribute
|
||||
|
@ -825,7 +826,8 @@ nsresult HTMLEditor::RemoveStyleInside(nsIContent& aNode, nsAtom* aProperty,
|
|||
// if this matching attribute is the ONLY one on the node,
|
||||
// then remove the whole node. Otherwise just nix the attribute.
|
||||
if (IsOnlyAttribute(aNode.AsElement(), aAttribute)) {
|
||||
nsresult rv = RemoveContainerWithTransaction(*aNode.AsElement());
|
||||
nsresult rv =
|
||||
RemoveContainerWithTransaction(MOZ_KnownLive(*aNode.AsElement()));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -853,10 +855,11 @@ nsresult HTMLEditor::RemoveStyleInside(nsIContent& aNode, nsAtom* aProperty,
|
|||
// attribute
|
||||
// let's remove them
|
||||
mCSSEditUtils->RemoveCSSEquivalentToHTMLStyle(
|
||||
aNode.AsElement(), aProperty, aAttribute, nullptr, false);
|
||||
MOZ_KnownLive(aNode.AsElement()), aProperty, aAttribute, nullptr,
|
||||
false);
|
||||
// remove the node if it is a span or font, if its style attribute is
|
||||
// empty or absent, and if it does not have a class nor an id
|
||||
RemoveElementIfNoStyleOrIdOrClass(*aNode.AsElement());
|
||||
RemoveElementIfNoStyleOrIdOrClass(MOZ_KnownLive(*aNode.AsElement()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -870,7 +873,7 @@ nsresult HTMLEditor::RemoveStyleInside(nsIContent& aNode, nsAtom* aProperty,
|
|||
aNode.IsHTMLElement(nsGkAtoms::small)) &&
|
||||
aAttribute == nsGkAtoms::size) {
|
||||
// if we are setting font size, remove any nested bigs and smalls
|
||||
return RemoveContainerWithTransaction(*aNode.AsElement());
|
||||
return RemoveContainerWithTransaction(MOZ_KnownLive(*aNode.AsElement()));
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1403,7 +1406,7 @@ nsresult HTMLEditor::RemoveInlinePropertyInternal(nsAtom* aProperty,
|
|||
if (CSSEditUtils::IsCSSInvertible(*aProperty, aAttribute)) {
|
||||
NS_NAMED_LITERAL_STRING(value, "-moz-editor-invert-value");
|
||||
SetInlinePropertyOnTextNode(
|
||||
*startNode->GetAsText(), range->StartOffset(),
|
||||
MOZ_KnownLive(*startNode->GetAsText()), range->StartOffset(),
|
||||
range->EndOffset(), *aProperty, aAttribute, value);
|
||||
}
|
||||
}
|
||||
|
@ -1550,9 +1553,9 @@ nsresult HTMLEditor::RelativeFontChange(FontSize aDir) {
|
|||
nsCOMPtr<nsINode> startNode = range->GetStartContainer();
|
||||
nsCOMPtr<nsINode> endNode = range->GetEndContainer();
|
||||
if (startNode == endNode && IsTextNode(startNode)) {
|
||||
rv = RelativeFontChangeOnTextNode(aDir, *startNode->GetAsText(),
|
||||
range->StartOffset(),
|
||||
range->EndOffset());
|
||||
rv = RelativeFontChangeOnTextNode(
|
||||
aDir, MOZ_KnownLive(*startNode->GetAsText()), range->StartOffset(),
|
||||
range->EndOffset());
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -1597,16 +1600,16 @@ nsresult HTMLEditor::RelativeFontChange(FontSize aDir) {
|
|||
// to be separately handled (they do if they are text nodes, due to how
|
||||
// the subtree iterator works - it will not have reported them).
|
||||
if (IsTextNode(startNode) && IsEditable(startNode)) {
|
||||
rv = RelativeFontChangeOnTextNode(aDir, *startNode->GetAsText(),
|
||||
range->StartOffset(),
|
||||
startNode->Length());
|
||||
rv = RelativeFontChangeOnTextNode(
|
||||
aDir, MOZ_KnownLive(*startNode->GetAsText()), range->StartOffset(),
|
||||
startNode->Length());
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
if (IsTextNode(endNode) && IsEditable(endNode)) {
|
||||
rv = RelativeFontChangeOnTextNode(aDir, *endNode->GetAsText(), 0,
|
||||
range->EndOffset());
|
||||
rv = RelativeFontChangeOnTextNode(
|
||||
aDir, MOZ_KnownLive(*endNode->GetAsText()), 0, range->EndOffset());
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -1685,8 +1688,8 @@ nsresult HTMLEditor::RelativeFontChangeOnTextNode(FontSize aDir,
|
|||
}
|
||||
|
||||
// Else reparent the node inside font node with appropriate relative size
|
||||
RefPtr<Element> newElement =
|
||||
InsertContainerWithTransaction(*textNodeForTheRange, *nodeType);
|
||||
RefPtr<Element> newElement = InsertContainerWithTransaction(
|
||||
*textNodeForTheRange, MOZ_KnownLive(*nodeType));
|
||||
if (NS_WARN_IF(!newElement)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -1765,7 +1768,7 @@ nsresult HTMLEditor::RelativeFontChangeOnNode(int32_t aSizeChange,
|
|||
nsresult rv = RelativeFontChangeHelper(aSizeChange, aNode);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
// in that case, just remove this node and pull up the children
|
||||
return RemoveContainerWithTransaction(*aNode->AsElement());
|
||||
return RemoveContainerWithTransaction(MOZ_KnownLive(*aNode->AsElement()));
|
||||
}
|
||||
|
||||
// can it be put inside a "big" or "small"?
|
||||
|
@ -1777,7 +1780,7 @@ nsresult HTMLEditor::RelativeFontChangeOnNode(int32_t aSizeChange,
|
|||
// ok, chuck it in.
|
||||
// first look at siblings of aNode for matching bigs or smalls.
|
||||
// if we find one, move aNode into it.
|
||||
nsIContent* sibling = GetPriorHTMLSibling(aNode);
|
||||
nsCOMPtr<nsIContent> sibling = GetPriorHTMLSibling(aNode);
|
||||
if (sibling && sibling->IsHTMLElement(atom)) {
|
||||
// previous sib is already right kind of inline node; slide this over into
|
||||
// it
|
||||
|
@ -1792,7 +1795,8 @@ nsresult HTMLEditor::RelativeFontChangeOnNode(int32_t aSizeChange,
|
|||
}
|
||||
|
||||
// else insert it above aNode
|
||||
RefPtr<Element> newElement = InsertContainerWithTransaction(*aNode, *atom);
|
||||
RefPtr<Element> newElement =
|
||||
InsertContainerWithTransaction(*aNode, MOZ_KnownLive(*atom));
|
||||
if (NS_WARN_IF(!newElement)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
|
@ -2203,8 +2203,8 @@ nsresult HTMLEditor::SplitCellIntoColumns(Element* aTable, int32_t aRowIndex,
|
|||
// Insert new cell after using the remaining span
|
||||
// and always get the new cell so we can copy the background color;
|
||||
RefPtr<Element> newCellElement;
|
||||
rv = InsertCell(cellData.mElement, cellData.mEffectiveRowSpan, aColSpanRight,
|
||||
true, false, getter_AddRefs(newCellElement));
|
||||
rv = InsertCell(MOZ_KnownLive(cellData.mElement), cellData.mEffectiveRowSpan,
|
||||
aColSpanRight, true, false, getter_AddRefs(newCellElement));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -2374,7 +2374,7 @@ HTMLEditor::SwitchTableCellHeaderType(Element* aSourceCell,
|
|||
// This creates new node, moves children, copies attributes (true)
|
||||
// and manages the selection!
|
||||
RefPtr<Element> newCell = ReplaceContainerAndCloneAttributesWithTransaction(
|
||||
*aSourceCell, *newCellName);
|
||||
*aSourceCell, MOZ_KnownLive(*newCellName));
|
||||
if (NS_WARN_IF(!newCell)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
|
@ -469,9 +469,10 @@ EditActionResult TextEditRules::WillInsertLineBreak(int32_t aMaxLength) {
|
|||
|
||||
// Insert a linefeed character.
|
||||
EditorRawDOMPoint pointAfterInsertedLineBreak;
|
||||
rv = TextEditorRef().InsertTextWithTransaction(*doc, NS_LITERAL_STRING("\n"),
|
||||
pointToInsert,
|
||||
&pointAfterInsertedLineBreak);
|
||||
rv = MOZ_KnownLive(TextEditorRef())
|
||||
.InsertTextWithTransaction(*doc, NS_LITERAL_STRING("\n"),
|
||||
pointToInsert,
|
||||
&pointAfterInsertedLineBreak);
|
||||
if (NS_WARN_IF(!pointAfterInsertedLineBreak.IsSet())) {
|
||||
return EditActionIgnored(NS_ERROR_FAILURE);
|
||||
}
|
||||
|
@ -839,8 +840,8 @@ nsresult TextEditRules::WillInsertText(EditSubAction aEditSubAction,
|
|||
betterInsertionPoint.Set(betterInsertionPoint.GetContainer(),
|
||||
IMESelectionOffset);
|
||||
}
|
||||
rv = TextEditorRef().InsertTextWithTransaction(*doc, *outString,
|
||||
betterInsertionPoint);
|
||||
rv = MOZ_KnownLive(TextEditorRef())
|
||||
.InsertTextWithTransaction(*doc, *outString, betterInsertionPoint);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -854,8 +855,9 @@ nsresult TextEditRules::WillInsertText(EditSubAction aEditSubAction,
|
|||
AutoTransactionsConserveSelection dontChangeMySelection(TextEditorRef());
|
||||
|
||||
EditorRawDOMPoint pointAfterStringInserted;
|
||||
rv = TextEditorRef().InsertTextWithTransaction(
|
||||
*doc, *outString, atStartOfSelection, &pointAfterStringInserted);
|
||||
rv = MOZ_KnownLive(TextEditorRef())
|
||||
.InsertTextWithTransaction(*doc, *outString, atStartOfSelection,
|
||||
&pointAfterStringInserted);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -954,8 +956,9 @@ nsresult TextEditRules::WillSetText(bool* aCancel, bool* aHandled,
|
|||
if (NS_WARN_IF(!newNode)) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult rv = TextEditorRef().InsertNodeWithTransaction(
|
||||
*newNode, EditorRawDOMPoint(rootElement, 0));
|
||||
nsresult rv = MOZ_KnownLive(TextEditorRef())
|
||||
.InsertNodeWithTransaction(
|
||||
*newNode, EditorRawDOMPoint(rootElement, 0));
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
@ -1515,10 +1518,14 @@ nsresult TextEditRules::CreateBogusNodeIfNeeded() {
|
|||
// Give it a special attribute.
|
||||
newBrElement->SetAttr(kNameSpaceID_None, kMOZEditorBogusNodeAttrAtom,
|
||||
kMOZEditorBogusNodeValue, false);
|
||||
if (NS_WARN_IF(mBogusNode != newBrElement)) {
|
||||
return NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE;
|
||||
}
|
||||
|
||||
// Put the node in the document.
|
||||
nsresult rv = TextEditorRef().InsertNodeWithTransaction(
|
||||
*mBogusNode, EditorRawDOMPoint(rootElement, 0));
|
||||
nsresult rv = MOZ_KnownLive(TextEditorRef())
|
||||
.InsertNodeWithTransaction(
|
||||
*newBrElement, EditorRawDOMPoint(rootElement, 0));
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
|
|
@ -80,16 +80,24 @@ class TextEditRules : public nsITimerCallback, public nsINamed {
|
|||
HTMLEditRules* AsHTMLEditRules();
|
||||
const HTMLEditRules* AsHTMLEditRules() const;
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual nsresult Init(TextEditor* aTextEditor);
|
||||
virtual nsresult SetInitialValue(const nsAString& aValue);
|
||||
virtual nsresult DetachEditor();
|
||||
virtual nsresult BeforeEdit(EditSubAction aEditSubAction,
|
||||
nsIEditor::EDirection aDirection);
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual nsresult AfterEdit(EditSubAction aEditSubAction,
|
||||
nsIEditor::EDirection aDirection);
|
||||
// NOTE: Don't mark WillDoAction() nor DidDoAction() as MOZ_CAN_RUN_SCRIPT
|
||||
// because they are too generic and doing it makes a lot of public
|
||||
// editor methods marked as MOZ_CAN_RUN_SCRIPT too, but some of them
|
||||
// may not causes running script. So, ideal fix must be that we make
|
||||
// each method callsed by this method public.
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||
virtual nsresult WillDoAction(EditSubActionInfo& aInfo, bool* aCancel,
|
||||
bool* aHandled);
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||
virtual nsresult DidDoAction(EditSubActionInfo& aInfo, nsresult aResult);
|
||||
|
||||
/**
|
||||
|
@ -196,6 +204,7 @@ class TextEditRules : public nsITimerCallback, public nsINamed {
|
|||
* @param aMaxLength The maximum string length which the text editor
|
||||
* allows to set.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult WillSetText(bool* aCancel, bool* aHandled,
|
||||
const nsAString* inString,
|
||||
int32_t aMaxLength);
|
||||
|
@ -280,6 +289,7 @@ class TextEditRules : public nsITimerCallback, public nsINamed {
|
|||
/**
|
||||
* Creates a bogus <br> node if the root element has no editable content.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE nsresult CreateBogusNodeIfNeeded();
|
||||
|
||||
/**
|
||||
|
|
|
@ -76,7 +76,7 @@ AutoEditInitRulesTrigger::AutoEditInitRulesTrigger(TextEditor* aTextEditor,
|
|||
|
||||
AutoEditInitRulesTrigger::~AutoEditInitRulesTrigger() {
|
||||
if (mTextEditor) {
|
||||
mResult = mTextEditor->EndEditorInit();
|
||||
mResult = MOZ_KnownLive(mTextEditor)->EndEditorInit();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,12 @@ class TextEditUtils final {
|
|||
*/
|
||||
class AutoEditInitRulesTrigger final {
|
||||
private:
|
||||
TextEditor* mTextEditor;
|
||||
RefPtr<TextEditor> mTextEditor;
|
||||
nsresult& mResult;
|
||||
|
||||
public:
|
||||
AutoEditInitRulesTrigger(TextEditor* aTextEditor, nsresult& aResult);
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
~AutoEditInitRulesTrigger();
|
||||
};
|
||||
|
||||
|
|
|
@ -321,7 +321,8 @@ nsresult TextEditor::InitRules() {
|
|||
// instantiate the rules for this text editor
|
||||
mRules = new TextEditRules();
|
||||
}
|
||||
return mRules->Init(this);
|
||||
RefPtr<TextEditRules> textEditRules(mRules);
|
||||
return textEditRules->Init(this);
|
||||
}
|
||||
|
||||
nsresult TextEditor::HandleKeyPressEvent(WidgetKeyboardEvent* aKeyboardEvent) {
|
||||
|
|
|
@ -87,6 +87,7 @@ class TextEditor : public EditorBase, public nsIPlaintextEditor {
|
|||
virtual bool CanPasteTransferable(nsITransferable* aTransferable);
|
||||
|
||||
// Overrides of EditorBase
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual nsresult Init(Document& aDoc, Element* aRoot,
|
||||
nsISelectionController* aSelCon, uint32_t aFlags,
|
||||
const nsAString& aValue) override;
|
||||
|
@ -266,9 +267,11 @@ class TextEditor : public EditorBase, public nsIPlaintextEditor {
|
|||
****************************************************************************/
|
||||
|
||||
// Overrides of EditorBase
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual nsresult RemoveAttributeOrEquivalent(
|
||||
Element* aElement, nsAtom* aAttribute,
|
||||
bool aSuppressTransaction) override;
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual nsresult SetAttributeOrEquivalent(Element* aElement,
|
||||
nsAtom* aAttribute,
|
||||
const nsAString& aValue,
|
||||
|
@ -363,9 +366,11 @@ class TextEditor : public EditorBase, public nsIPlaintextEditor {
|
|||
protected: // Called by helper classes.
|
||||
virtual void OnStartToHandleTopLevelEditSubAction(
|
||||
EditSubAction aEditSubAction, nsIEditor::EDirection aDirection) override;
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual void OnEndHandlingTopLevelEditSubAction() override;
|
||||
|
||||
void BeginEditorInit();
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult EndEditorInit();
|
||||
|
||||
protected: // Shouldn't be used by friend classes
|
||||
|
@ -437,6 +442,7 @@ class TextEditor : public EditorBase, public nsIPlaintextEditor {
|
|||
*/
|
||||
bool IsSafeToInsertData(Document* aSourceDoc);
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual nsresult InitRules();
|
||||
|
||||
/**
|
||||
|
|
|
@ -252,7 +252,8 @@ template <typename PT, typename CT>
|
|||
nsresult WSRunObject::InsertText(
|
||||
Document& aDocument, const nsAString& aStringToInsert,
|
||||
const EditorDOMPointBase<PT, CT>& aPointToInsert,
|
||||
EditorRawDOMPoint* aPointAfterInsertedString) {
|
||||
EditorRawDOMPoint* aPointAfterInsertedString)
|
||||
MOZ_CAN_RUN_SCRIPT_FOR_DEFINITION {
|
||||
// MOOSE: for now, we always assume non-PRE formatting. Fix this later.
|
||||
// meanwhile, the pre case is handled in WillInsertText in
|
||||
// HTMLEditRules.cpp
|
||||
|
@ -381,8 +382,10 @@ nsresult WSRunObject::InsertText(
|
|||
}
|
||||
|
||||
// Ready, aim, fire!
|
||||
nsresult rv = mHTMLEditor->InsertTextWithTransaction(
|
||||
aDocument, theString, pointToInsert, aPointAfterInsertedString);
|
||||
nsresult rv =
|
||||
MOZ_KnownLive(mHTMLEditor)
|
||||
->InsertTextWithTransaction(aDocument, theString, pointToInsert,
|
||||
aPointAfterInsertedString);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -236,10 +236,10 @@ class MOZ_STACK_CLASS WSRunObject final {
|
|||
* Otherwise, an error code.
|
||||
*/
|
||||
template <typename PT, typename CT>
|
||||
nsresult InsertText(dom::Document& aDocument,
|
||||
const nsAString& aStringToInsert,
|
||||
const EditorDOMPointBase<PT, CT>& aPointToInsert,
|
||||
EditorRawDOMPoint* aPointAfterInsertedString = nullptr);
|
||||
MOZ_CAN_RUN_SCRIPT nsresult
|
||||
InsertText(dom::Document& aDocument, const nsAString& aStringToInsert,
|
||||
const EditorDOMPointBase<PT, CT>& aPointToInsert,
|
||||
EditorRawDOMPoint* aPointAfterInsertedString = nullptr);
|
||||
|
||||
// DeleteWSBackward deletes a single visible piece of ws before the ws
|
||||
// point (the point to create the wsRunObject, passed to its constructor).
|
||||
|
|
|
@ -52,10 +52,12 @@ interface nsIEditor : nsISupports
|
|||
|
||||
readonly attribute Selection selection;
|
||||
|
||||
[can_run_script]
|
||||
void setAttributeOrEquivalent(in Element element,
|
||||
in AString sourceAttrName,
|
||||
in AString sourceAttrValue,
|
||||
in boolean aSuppressTransaction);
|
||||
[can_run_script]
|
||||
void removeAttributeOrEquivalent(in Element element,
|
||||
in AString sourceAttrName,
|
||||
in boolean aSuppressTransaction);
|
||||
|
@ -386,6 +388,7 @@ interface nsIEditor : nsISupports
|
|||
* @param aDestNode the destination element to operate on
|
||||
* @param aSourceNode the source element to copy attributes from
|
||||
*/
|
||||
[can_run_script]
|
||||
void cloneAttributes(in Element aDestElement, in Element aSourceElement);
|
||||
|
||||
/**
|
||||
|
@ -398,6 +401,7 @@ interface nsIEditor : nsISupports
|
|||
* 0=first child, 1=second child, etc.
|
||||
* any number > number of current children = last child
|
||||
*/
|
||||
[can_run_script]
|
||||
void insertNode(in Node node,
|
||||
in Node parent,
|
||||
in long aPosition);
|
||||
|
|
|
@ -22,6 +22,7 @@ interface nsIEditorMailSupport : nsISupports
|
|||
* @param aInsertHTML Insert as html? (vs plaintext)
|
||||
* @return The node which was inserted
|
||||
*/
|
||||
[can_run_script]
|
||||
Node insertAsCitedQuotation(in AString aQuotedText,
|
||||
in AString aCitation,
|
||||
in boolean aInsertHTML);
|
||||
|
|
|
@ -42,6 +42,7 @@ interface nsIHTMLEditor : nsISupports
|
|||
* Example: aProperty="font", aAttribute="color",
|
||||
* aValue="0x00FFFF"
|
||||
*/
|
||||
[can_run_script]
|
||||
void setInlineProperty(in AString aProperty,
|
||||
in AString aAttribute,
|
||||
in AString aValue);
|
||||
|
@ -84,6 +85,7 @@ interface nsIHTMLEditor : nsISupports
|
|||
* removeAllInlineProperties() deletes all the inline properties from all
|
||||
* text in the current selection.
|
||||
*/
|
||||
[can_run_script]
|
||||
void removeAllInlineProperties();
|
||||
|
||||
|
||||
|
@ -100,6 +102,7 @@ interface nsIHTMLEditor : nsISupports
|
|||
* @param aAttribute If aProperty is "font", aAttribute should be "face",
|
||||
* "size", "color" or "bgcolor".
|
||||
*/
|
||||
[can_run_script]
|
||||
void removeInlineProperty(in AString aProperty, in AString aAttribute);
|
||||
|
||||
/**
|
||||
|
@ -107,6 +110,7 @@ interface nsIHTMLEditor : nsISupports
|
|||
* All existing text is scanned for existing <FONT SIZE> attributes
|
||||
* so they will be incremented instead of inserting new <FONT> tag
|
||||
*/
|
||||
[can_run_script]
|
||||
void increaseFontSize();
|
||||
|
||||
/**
|
||||
|
@ -114,6 +118,7 @@ interface nsIHTMLEditor : nsISupports
|
|||
* All existing text is scanned for existing <FONT SIZE> attributes
|
||||
* so they will be decreased instead of inserting new <FONT> tag
|
||||
*/
|
||||
[can_run_script]
|
||||
void decreaseFontSize();
|
||||
|
||||
/* ------------ HTML content methods -------------- */
|
||||
|
@ -131,6 +136,7 @@ interface nsIHTMLEditor : nsISupports
|
|||
*
|
||||
* @param aInputString the string to be inserted
|
||||
*/
|
||||
[can_run_script]
|
||||
void insertHTML(in AString aInputString);
|
||||
|
||||
|
||||
|
@ -162,6 +168,7 @@ interface nsIHTMLEditor : nsISupports
|
|||
* after the end of the selection for all element except
|
||||
* Named Anchors, which insert before the selection
|
||||
*/
|
||||
[can_run_script]
|
||||
void insertElementAtSelection(in Element aElement,
|
||||
in boolean aDeleteSelection);
|
||||
|
||||
|
@ -212,6 +219,7 @@ interface nsIHTMLEditor : nsISupports
|
|||
* @param aMixed True if there is more than one format
|
||||
* @return Name of block tag. "" is returned for none.
|
||||
*/
|
||||
[can_run_script]
|
||||
AString getParagraphState(out boolean aMixed);
|
||||
|
||||
/**
|
||||
|
@ -245,6 +253,7 @@ interface nsIHTMLEditor : nsISupports
|
|||
* @param aUL true if an "ul" list is selected.
|
||||
* @param aDL true if a "dl" list is selected.
|
||||
*/
|
||||
[can_run_script]
|
||||
void getListState(out boolean aMixed, out boolean aOL, out boolean aUL,
|
||||
out boolean aDL);
|
||||
|
||||
|
@ -256,6 +265,7 @@ interface nsIHTMLEditor : nsISupports
|
|||
* @param aDT true if "dt" list items are selected.
|
||||
* @param aDD true if "dd" list items are selected.
|
||||
*/
|
||||
[can_run_script]
|
||||
void getListItemState(out boolean aMixed, out boolean aLI,
|
||||
out boolean aDT, out boolean aDD);
|
||||
|
||||
|
@ -266,6 +276,7 @@ interface nsIHTMLEditor : nsISupports
|
|||
* @param aAlign enum value for first encountered alignment
|
||||
* (left/center/right)
|
||||
*/
|
||||
[can_run_script]
|
||||
void getAlignment(out boolean aMixed, out short aAlign);
|
||||
|
||||
/**
|
||||
|
@ -356,6 +367,7 @@ interface nsIHTMLEditor : nsISupports
|
|||
* (an "A" tag with the "name" attribute set)
|
||||
* @return The new element created.
|
||||
*/
|
||||
[can_run_script]
|
||||
Element createElementWithDefaults(in AString aTagName);
|
||||
|
||||
/**
|
||||
|
@ -363,6 +375,7 @@ interface nsIHTMLEditor : nsISupports
|
|||
*
|
||||
* @param aElement An "A" element with a non-empty "href" attribute
|
||||
*/
|
||||
[can_run_script]
|
||||
void insertLinkAroundSelection(in Element aAnchorElement);
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче