Bug 1563066, part 2 - XULContentSinkImpl::ContextStack::Push is infallible. r=bzbarsky
☠☠ backed out by 55e113f30a95 ☠ ☠
authorAndrew McCreight <continuation@gmail.com>
Wed, 03 Jul 2019 22:42:42 +0000
changeset 481192 98e692885ecc7198c74ac871e711d3f1cb3f11a9
parent 481191 e5a0ca3d92cc717bff53a6e6478355f043e76662
child 481193 fd915382080de872b69a6245d8e8477b0dd543ce
push id89149
push useramccreight@mozilla.com
push dateWed, 03 Jul 2019 22:58:50 +0000
treeherderautoland@bfc0d9412df9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs1563066
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1563066, part 2 - XULContentSinkImpl::ContextStack::Push is infallible. r=bzbarsky This lets us remove some error handling code, including some that is incorrect. Differential Revision: https://phabricator.services.mozilla.com/D36789
dom/xul/nsXULContentSink.cpp
dom/xul/nsXULContentSink.h
--- a/dom/xul/nsXULContentSink.cpp
+++ b/dom/xul/nsXULContentSink.cpp
@@ -62,24 +62,23 @@ XULContentSinkImpl::ContextStack::Contex
 XULContentSinkImpl::ContextStack::~ContextStack() {
   while (mTop) {
     Entry* doomed = mTop;
     mTop = mTop->mNext;
     delete doomed;
   }
 }
 
-nsresult XULContentSinkImpl::ContextStack::Push(nsXULPrototypeNode* aNode,
-                                                State aState) {
+void XULContentSinkImpl::ContextStack::Push(nsXULPrototypeNode* aNode,
+                                            State aState) {
   Entry* entry = new Entry(aNode, aState, mTop);
 
   mTop = entry;
 
   ++mDepth;
-  return NS_OK;
 }
 
 nsresult XULContentSinkImpl::ContextStack::Pop(State* aState) {
   if (mDepth == 0) return NS_ERROR_UNEXPECTED;
 
   Entry* entry = mTop;
   mTop = mTop->mNext;
   --mDepth;
@@ -626,24 +625,20 @@ nsresult XULContentSinkImpl::OpenRoot(co
     return NS_ERROR_UNEXPECTED;
   }
 
   // Create the element
   nsXULPrototypeElement* element = new nsXULPrototypeElement(aNodeInfo);
 
   // Push the element onto the context stack, so that child
   // containers will hook up to us as their parent.
-  nsresult rv = mContextStack.Push(element, mState);
-  if (NS_FAILED(rv)) {
-    element->Release();
-    return rv;
-  }
+  mContextStack.Push(element, mState);
 
   // Add the attributes
-  rv = AddAttributes(aAttributes, aAttrLen, element);
+  nsresult rv = AddAttributes(aAttributes, aAttrLen, element);
   if (NS_FAILED(rv)) return rv;
 
   mState = eInDocumentElement;
   return NS_OK;
 }
 
 nsresult XULContentSinkImpl::OpenTag(const char16_t** aAttributes,
                                      const uint32_t aAttrLen,
@@ -678,18 +673,17 @@ nsresult XULContentSinkImpl::OpenTag(con
       // OpenScript has pushed the nsPrototypeScriptElement onto the
       // stack, so we're done.
       return NS_OK;
     }
   }
 
   // Push the element onto the context stack, so that child
   // containers will hook up to us as their parent.
-  rv = mContextStack.Push(element, mState);
-  if (NS_FAILED(rv)) return rv;
+  mContextStack.Push(element, mState);
 
   mState = eInDocumentElement;
   return NS_OK;
 }
 
 nsresult XULContentSinkImpl::OpenScript(const char16_t** aAttributes,
                                         const uint32_t aLineNumber) {
   bool isJavaScript = true;
--- a/dom/xul/nsXULContentSink.h
+++ b/dom/xul/nsXULContentSink.h
@@ -110,17 +110,17 @@ class XULContentSinkImpl final : public 
     int32_t mDepth;
 
    public:
     ContextStack();
     ~ContextStack();
 
     int32_t Depth() { return mDepth; }
 
-    nsresult Push(nsXULPrototypeNode* aNode, State aState);
+    void Push(nsXULPrototypeNode* aNode, State aState);
     nsresult Pop(State* aState);
 
     nsresult GetTopNode(RefPtr<nsXULPrototypeNode>& aNode);
     nsresult GetTopChildren(nsPrototypeArray** aChildren);
 
     void Clear();
 
     void Traverse(nsCycleCollectionTraversalCallback& aCallback);