From 931b9e37ad24db6db76dffd300fab93e043a7c99 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 29 May 2018 22:58:49 -0400 Subject: [PATCH] Bug 1455676 part 10. Remove use of nsIDOMNode from remaining xpidl. r=qdot --- dom/base/FragmentOrElement.cpp | 4 +-- dom/base/nsCopySupport.cpp | 2 +- dom/base/nsDOMSerializer.cpp | 2 +- dom/base/nsDOMWindowUtils.cpp | 29 ++++++++--------- dom/base/nsDOMWindowUtils.h | 4 +-- dom/base/nsDocumentEncoder.cpp | 32 ++++--------------- dom/base/nsIDocumentEncoder.idl | 12 +++---- dom/interfaces/base/domstubs.idl | 3 -- dom/interfaces/base/nsIDOMWindowUtils.idl | 16 +++++----- .../WebBrowserPersistLocalDocument.cpp | 23 ------------- editor/libeditor/TextEditor.cpp | 2 +- 11 files changed, 39 insertions(+), 90 deletions(-) diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp index 5d99ca03de48..1e96dd8e6165 100644 --- a/dom/base/FragmentOrElement.cpp +++ b/dom/base/FragmentOrElement.cpp @@ -2242,9 +2242,9 @@ FragmentOrElement::GetMarkup(bool aIncludeSelf, nsAString& aMarkup) MOZ_ASSERT(NS_SUCCEEDED(rv)); if (aIncludeSelf) { - docEncoder->SetNativeNode(this); + docEncoder->SetNode(this); } else { - docEncoder->SetNativeContainerNode(this); + docEncoder->SetContainerNode(this); } rv = docEncoder->EncodeToString(aMarkup); MOZ_ASSERT(NS_SUCCEEDED(rv)); diff --git a/dom/base/nsCopySupport.cpp b/dom/base/nsCopySupport.cpp index 56f377b62039..ae6199df98d8 100644 --- a/dom/base/nsCopySupport.cpp +++ b/dom/base/nsCopySupport.cpp @@ -501,7 +501,7 @@ static nsresult AppendDOMNode(nsITransferable *aTransferable, nsIDocumentEncoder::OutputEncodeBasicEntities); NS_ENSURE_SUCCESS(rv, rv); - rv = docEncoder->SetNativeNode(aDOMNode); + rv = docEncoder->SetNode(aDOMNode); NS_ENSURE_SUCCESS(rv, rv); // serialize to string diff --git a/dom/base/nsDOMSerializer.cpp b/dom/base/nsDOMSerializer.cpp index e53043795951..b8cd243a5aba 100644 --- a/dom/base/nsDOMSerializer.cpp +++ b/dom/base/nsDOMSerializer.cpp @@ -59,7 +59,7 @@ SetUpEncoder(nsINode& aRoot, const nsAString& aCharset, ErrorResult& aRv) // If we are working on the entire document we do not need to // specify which part to serialize if (!entireDocument) { - rv = encoder->SetNativeNode(&aRoot); + rv = encoder->SetNode(&aRoot); } if (NS_FAILED(rv)) { diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index c6ae79289e7d..c2931a0387b1 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -1363,7 +1363,7 @@ nsDOMWindowUtils::NodesFromRect(float aX, float aY, } NS_IMETHODIMP -nsDOMWindowUtils::GetTranslationNodes(nsIDOMNode* aRoot, +nsDOMWindowUtils::GetTranslationNodes(nsINode* aRoot, nsITranslationNodeList** aRetVal) { NS_ENSURE_ARG_POINTER(aRetVal); @@ -1430,7 +1430,7 @@ nsDOMWindowUtils::GetTranslationNodes(nsIDOMNode* aRoot, isTranslationRoot = !parentInList; } - list->AppendElement(content->AsDOMNode(), isTranslationRoot); + list->AppendElement(content, isTranslationRoot); --limit; break; } @@ -1828,7 +1828,7 @@ nsDOMWindowUtils::GetFullZoom(float* aFullZoom) } NS_IMETHODIMP -nsDOMWindowUtils::DispatchDOMEventViaPresShell(nsIDOMNode* aTarget, +nsDOMWindowUtils::DispatchDOMEventViaPresShell(nsINode* aTarget, Event* aEvent, bool aTrusted, bool* aRetVal) @@ -2510,15 +2510,14 @@ nsDOMWindowUtils::GetAsyncPanZoomEnabled(bool *aResult) } NS_IMETHODIMP -nsDOMWindowUtils::SetAsyncScrollOffset(nsIDOMNode* aNode, +nsDOMWindowUtils::SetAsyncScrollOffset(Element* aElement, float aX, float aY) { - nsCOMPtr element = do_QueryInterface(aNode); - if (!element) { + if (!aElement) { return NS_ERROR_INVALID_ARG; } FrameMetrics::ViewID viewId; - if (!nsLayoutUtils::FindIDFor(element, &viewId)) { + if (!nsLayoutUtils::FindIDFor(aElement, &viewId)) { return NS_ERROR_UNEXPECTED; } nsIWidget* widget = GetWidget(); @@ -2546,14 +2545,13 @@ nsDOMWindowUtils::SetAsyncScrollOffset(nsIDOMNode* aNode, } NS_IMETHODIMP -nsDOMWindowUtils::SetAsyncZoom(nsIDOMNode* aRootElement, float aValue) +nsDOMWindowUtils::SetAsyncZoom(Element* aRootElement, float aValue) { - nsCOMPtr element = do_QueryInterface(aRootElement); - if (!element) { + if (!aRootElement) { return NS_ERROR_INVALID_ARG; } FrameMetrics::ViewID viewId; - if (!nsLayoutUtils::FindIDFor(element, &viewId)) { + if (!nsLayoutUtils::FindIDFor(aRootElement, &viewId)) { return NS_ERROR_UNEXPECTED; } nsIWidget* widget = GetWidget(); @@ -3582,11 +3580,10 @@ nsDOMWindowUtils::GetIsParentWindowMainWidgetVisible(bool* aIsVisible) } NS_IMETHODIMP -nsDOMWindowUtils::IsNodeDisabledForEvents(nsIDOMNode* aNode, bool* aRetVal) +nsDOMWindowUtils::IsNodeDisabledForEvents(nsINode* aNode, bool* aRetVal) { *aRetVal = false; - nsCOMPtr n = do_QueryInterface(aNode); - nsINode* node = n; + nsINode* node = aNode; while (node) { if (node->IsNodeOfType(nsINode::eHTML_FORM_CONTROL)) { nsCOMPtr fc = do_QueryInterface(node); @@ -4066,7 +4063,7 @@ nsDOMWindowUtils::TriggerDeviceReset() } NS_IMETHODIMP -nsDOMWindowUtils::ForceUseCounterFlush(nsIDOMNode *aNode) +nsDOMWindowUtils::ForceUseCounterFlush(nsINode *aNode) { NS_ENSURE_ARG_POINTER(aNode); @@ -4294,7 +4291,7 @@ NS_IMPL_ADDREF(nsTranslationNodeList) NS_IMPL_RELEASE(nsTranslationNodeList) NS_IMETHODIMP -nsTranslationNodeList::Item(uint32_t aIndex, nsIDOMNode** aRetVal) +nsTranslationNodeList::Item(uint32_t aIndex, nsINode** aRetVal) { NS_ENSURE_ARG_POINTER(aRetVal); NS_IF_ADDREF(*aRetVal = mNodes.SafeElementAt(aIndex)); diff --git a/dom/base/nsDOMWindowUtils.h b/dom/base/nsDOMWindowUtils.h index 08ca7f3f9419..7f263eba3110 100644 --- a/dom/base/nsDOMWindowUtils.h +++ b/dom/base/nsDOMWindowUtils.h @@ -44,7 +44,7 @@ public: NS_DECL_ISUPPORTS NS_DECL_NSITRANSLATIONNODELIST - void AppendElement(nsIDOMNode* aElement, bool aIsRoot) + void AppendElement(nsINode* aElement, bool aIsRoot) { mNodes.AppendElement(aElement); mNodeIsRoot.AppendElement(aIsRoot); @@ -54,7 +54,7 @@ public: private: ~nsTranslationNodeList() {} - nsTArray > mNodes; + nsTArray > mNodes; nsTArray mNodeIsRoot; uint32_t mLength; }; diff --git a/dom/base/nsDocumentEncoder.cpp b/dom/base/nsDocumentEncoder.cpp index c14250e9c26c..b29d717df942 100644 --- a/dom/base/nsDocumentEncoder.cpp +++ b/dom/base/nsDocumentEncoder.cpp @@ -294,15 +294,7 @@ nsDocumentEncoder::SetRange(nsRange* aRange) } NS_IMETHODIMP -nsDocumentEncoder::SetNode(nsIDOMNode* aNode) -{ - mNodeIsContainer = false; - mNode = do_QueryInterface(aNode); - return NS_OK; -} - -NS_IMETHODIMP -nsDocumentEncoder::SetNativeNode(nsINode* aNode) +nsDocumentEncoder::SetNode(nsINode* aNode) { mNodeIsContainer = false; mNode = aNode; @@ -310,15 +302,7 @@ nsDocumentEncoder::SetNativeNode(nsINode* aNode) } NS_IMETHODIMP -nsDocumentEncoder::SetContainerNode(nsIDOMNode *aContainer) -{ - mNodeIsContainer = true; - mNode = do_QueryInterface(aContainer); - return NS_OK; -} - -NS_IMETHODIMP -nsDocumentEncoder::SetNativeContainerNode(nsINode* aContainer) +nsDocumentEncoder::SetContainerNode(nsINode* aContainer) { mNodeIsContainer = true; mNode = aContainer; @@ -372,10 +356,8 @@ nsDocumentEncoder::SerializeNodeStart(nsINode* aNode, aOriginalNode = aNode; if (mNodeFixup) { bool dummy; - nsCOMPtr domNodeIn = do_QueryInterface(aNode); - nsCOMPtr domNodeOut; - mNodeFixup->FixupNode(domNodeIn, &dummy, getter_AddRefs(domNodeOut)); - fixedNodeKungfuDeathGrip = do_QueryInterface(domNodeOut); + mNodeFixup->FixupNode(aNode, &dummy, + getter_AddRefs(fixedNodeKungfuDeathGrip)); node = fixedNodeKungfuDeathGrip; } } @@ -471,10 +453,8 @@ nsDocumentEncoder::SerializeToStringRecursive(nsINode* aNode, // Keep the node from FixupNode alive. nsCOMPtr fixedNodeKungfuDeathGrip; if (mNodeFixup) { - nsCOMPtr domNodeIn = do_QueryInterface(aNode); - nsCOMPtr domNodeOut; - mNodeFixup->FixupNode(domNodeIn, &serializeClonedChildren, getter_AddRefs(domNodeOut)); - fixedNodeKungfuDeathGrip = do_QueryInterface(domNodeOut); + mNodeFixup->FixupNode(aNode, &serializeClonedChildren, + getter_AddRefs(fixedNodeKungfuDeathGrip)); maybeFixedNode = fixedNodeKungfuDeathGrip; } diff --git a/dom/base/nsIDocumentEncoder.idl b/dom/base/nsIDocumentEncoder.idl index 5b9d819fbb8f..2c140ee2ca36 100644 --- a/dom/base/nsIDocumentEncoder.idl +++ b/dom/base/nsIDocumentEncoder.idl @@ -5,12 +5,12 @@ #include "nsISupports.idl" -interface nsIDOMNode; interface nsIOutputStream; -webidl Selection; webidl Document; +webidl Node; webidl Range; +webidl Selection; %{ C++ class nsINode; @@ -33,7 +33,7 @@ interface nsIDocumentEncoderNodeFixup : nsISupports * instead of the children of the original node. * @return The resulting fixed up node. */ - nsIDOMNode fixupNode(in nsIDOMNode aNode, out boolean aSerializeCloneKids); + Node fixupNode(in Node aNode, out boolean aSerializeCloneKids); }; [scriptable, uuid(21f112df-d96f-47da-bfcb-5331273003d1)] @@ -265,8 +265,7 @@ interface nsIDocumentEncoder : nsISupports * document or range or selection is encoded. * @param aNode The node to encode. */ - void setNode(in nsIDOMNode aNode); - [noscript] void setNativeNode(in nsINodePtr aNode); + void setNode(in Node aNode); /** * If the container is set to a non-null value, then its @@ -274,8 +273,7 @@ interface nsIDocumentEncoder : nsISupports * document or range or selection or node is encoded. * @param aContainer The node which child nodes will be encoded. */ - void setContainerNode(in nsIDOMNode aContainer); - [noscript] void setNativeContainerNode(in nsINodePtr aContainer); + void setContainerNode(in Node aContainer); /** * Documents typically have an intrinsic character set, diff --git a/dom/interfaces/base/domstubs.idl b/dom/interfaces/base/domstubs.idl index 11db982baa76..97acf9a0056a 100644 --- a/dom/interfaces/base/domstubs.idl +++ b/dom/interfaces/base/domstubs.idl @@ -15,9 +15,6 @@ typedef unsigned long long DOMTimeStamp; typedef double DOMHighResTimeStamp; typedef unsigned long long nsViewID; -// Core -interface nsIDOMNode; - // Needed for raises() in our IDL %{C++ namespace mozilla { diff --git a/dom/interfaces/base/nsIDOMWindowUtils.idl b/dom/interfaces/base/nsIDOMWindowUtils.idl index 4412f6c23678..ed92232569bc 100644 --- a/dom/interfaces/base/nsIDOMWindowUtils.idl +++ b/dom/interfaces/base/nsIDOMWindowUtils.idl @@ -31,7 +31,6 @@ native nscolor(nscolor); interface nsIArray; interface nsICycleCollectorListener; -interface nsIDOMNode; interface nsIPreloadedStyleSheet; interface nsITransferable; interface nsIQueryContentEventResult; @@ -49,6 +48,7 @@ webidl DOMRect; webidl Element; webidl EventTarget; webidl Event; +webidl Node; webidl NodeList; [scriptable, uuid(4d6732ca-9da7-4176-b8a1-8dde15cd0bf9)] @@ -780,7 +780,7 @@ interface nsIDOMWindowUtils : nsISupports { * * This method requires chrome privileges. */ - nsITranslationNodeList getTranslationNodes(in nsIDOMNode aRoot); + nsITranslationNodeList getTranslationNodes(in Node aRoot); /** * Compare the two canvases, returning the number of differing pixels and @@ -936,7 +936,7 @@ interface nsIDOMWindowUtils : nsISupports { * @note Event handlers won't get aEvent as parameter, but a similar event. * Also, aEvent should not be reused. */ - boolean dispatchDOMEventViaPresShell(in nsIDOMNode aTarget, + boolean dispatchDOMEventViaPresShell(in Node aTarget, in Event aEvent, in boolean aTrusted); @@ -1402,7 +1402,7 @@ interface nsIDOMWindowUtils : nsISupports { * with that offset if async scrolling is enabled, and then the offset * will be removed. Only call this while test-controlled refreshes is enabled. */ - void setAsyncScrollOffset(in nsIDOMNode aNode, in float aX, in float aY); + void setAsyncScrollOffset(in Element aElement, in float aX, in float aY); /** * Set async zoom value. aRootElement should be the document element of our @@ -1410,7 +1410,7 @@ interface nsIDOMWindowUtils : nsISupports { * existing zoom if async scrolling is enabled, and then the zoom will be * removed. Only call this while test-controlled refreshes is enabled. */ - void setAsyncZoom(in nsIDOMNode aRootElement, in float aValue); + void setAsyncZoom(in Element aRootElement, in float aValue); /** * Do a round-trip to the compositor to ensure any pending APZ repaint requests @@ -1682,7 +1682,7 @@ interface nsIDOMWindowUtils : nsISupports { * may be disabled. Such cases are for example the existence of disabled * attribute or -moz-user-input: none. */ - boolean isNodeDisabledForEvents(in nsIDOMNode aNode); + boolean isNodeDisabledForEvents(in Node aNode); /** * Setting paintFlashing to true will flash newly painted area. @@ -1830,7 +1830,7 @@ interface nsIDOMWindowUtils : nsISupports { * non-deterministic, we have this method here for more determinism when * running tests. */ - void forceUseCounterFlush(in nsIDOMNode aNode); + void forceUseCounterFlush(in Node aNode); /** * Enable or disable displayport suppression. This is intended to be used by @@ -1954,7 +1954,7 @@ interface nsIDOMWindowUtils : nsISupports { [scriptable, uuid(c694e359-7227-4392-a138-33c0cc1f15a6)] interface nsITranslationNodeList : nsISupports { readonly attribute unsigned long length; - nsIDOMNode item(in unsigned long index); + Node item(in unsigned long index); // A translation root is a block element, or an inline element // which its parent is not a translation node. diff --git a/dom/webbrowserpersist/WebBrowserPersistLocalDocument.cpp b/dom/webbrowserpersist/WebBrowserPersistLocalDocument.cpp index 48495a9d630d..084c592356f0 100644 --- a/dom/webbrowserpersist/WebBrowserPersistLocalDocument.cpp +++ b/dom/webbrowserpersist/WebBrowserPersistLocalDocument.cpp @@ -575,9 +575,6 @@ private: return mParent->GetPersistFlags() & aFlag; } - // Helper for XPCOM FixupNode. - nsresult FixupNode(nsINode *aNodeIn, bool *aSerializeCloneKids, - nsINode **aNodeOut); nsresult GetNodeToFixup(nsINode* aNodeIn, nsINode** aNodeOut); nsresult FixupURI(nsAString& aURI); nsresult FixupAttribute(nsINode* aNode, @@ -831,26 +828,6 @@ PersistNodeFixup::FixupXMLStyleSheetLink(dom::ProcessingInstruction* aPI, } NS_IMETHODIMP -PersistNodeFixup::FixupNode(nsIDOMNode *aNodeIn, - bool *aSerializeCloneKids, - nsIDOMNode **aNodeOut) -{ - nsCOMPtr nodeIn = do_QueryInterface(aNodeIn); - nsCOMPtr nodeOut; - nsresult rv = FixupNode(nodeIn, aSerializeCloneKids, - getter_AddRefs(nodeOut)); - // FixupNode can return NS_OK and a null outparam, so check - // the actual value we got before dereferencing it. - if (nodeOut) { - NS_ADDREF(*aNodeOut = nodeOut->AsDOMNode()); - } else { - *aNodeOut = nullptr; - } - - return rv; -} - -nsresult PersistNodeFixup::FixupNode(nsINode* aNodeIn, bool* aSerializeCloneKids, nsINode** aNodeOut) diff --git a/editor/libeditor/TextEditor.cpp b/editor/libeditor/TextEditor.cpp index c3d9c13b41ca..533b71ecbdbc 100644 --- a/editor/libeditor/TextEditor.cpp +++ b/editor/libeditor/TextEditor.cpp @@ -1717,7 +1717,7 @@ TextEditor::GetAndInitDocEncoder(const nsAString& aFormatType, return nullptr; } if (!rootElement->IsHTMLElement(nsGkAtoms::body)) { - rv = docEncoder->SetNativeContainerNode(rootElement); + rv = docEncoder->SetContainerNode(rootElement); if (NS_WARN_IF(NS_FAILED(rv))) { return nullptr; }