From 8f0845aadf237674716084dd3fe91d8f6ed0b1ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 28 Nov 2019 12:20:30 +0000 Subject: [PATCH] Bug 1599843 - Document::ChangeContentEditableCount is infallible. r=masayuki And should take Element, not nsIContent pointers. Depends on D54993 Differential Revision: https://phabricator.services.mozilla.com/D54994 --HG-- extra : moz-landing-system : lando --- dom/base/Document.cpp | 11 ++++------- dom/base/Document.h | 10 ++++------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp index 1660911f655c..36dc59298dd3 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -5299,7 +5299,7 @@ nsresult Document::EditingStateChanged() { // Helper class, used below in ChangeContentEditableCount(). class DeferredContentEditableCountChangeEvent : public Runnable { public: - DeferredContentEditableCountChangeEvent(Document* aDoc, nsIContent* aElement) + DeferredContentEditableCountChangeEvent(Document* aDoc, Element* aElement) : mozilla::Runnable("DeferredContentEditableCountChangeEvent"), mDoc(aDoc), mElement(aElement) {} @@ -5313,11 +5313,10 @@ class DeferredContentEditableCountChangeEvent : public Runnable { private: RefPtr mDoc; - nsCOMPtr mElement; + RefPtr mElement; }; -nsresult Document::ChangeContentEditableCount(nsIContent* aElement, - int32_t aChange) { +void Document::ChangeContentEditableCount(Element* aElement, int32_t aChange) { NS_ASSERTION(int32_t(mContentEditableCount) + aChange >= 0, "Trying to decrement too much."); @@ -5325,11 +5324,9 @@ nsresult Document::ChangeContentEditableCount(nsIContent* aElement, nsContentUtils::AddScriptRunner( new DeferredContentEditableCountChangeEvent(this, aElement)); - - return NS_OK; } -void Document::DeferredContentEditableCountChange(nsIContent* aElement) { +void Document::DeferredContentEditableCountChange(Element* aElement) { if (mParser || (mUpdateNestLevel > 0 && (mContentEditableCount > 0) != IsEditingOn())) { return; diff --git a/dom/base/Document.h b/dom/base/Document.h index bdd7b747a960..5d1f8d375dd1 100644 --- a/dom/base/Document.h +++ b/dom/base/Document.h @@ -1747,13 +1747,11 @@ class Document : public nsINode, * Should be called when an element's editable changes as a result of * changing its contentEditable attribute/property. * - * @param aElement the element for which the contentEditable - * attribute/property was changed - * @param aChange +1 if the contentEditable attribute/property was changed to - * true, -1 if it was changed to false + * The change should be +1 if the contentEditable attribute/property was + * changed to true, -1 if it was changed to false. */ - nsresult ChangeContentEditableCount(nsIContent* aElement, int32_t aChange); - void DeferredContentEditableCountChange(nsIContent* aElement); + void ChangeContentEditableCount(Element*, int32_t aChange); + void DeferredContentEditableCountChange(Element*); enum class EditingState : int8_t { eTearingDown = -2,