Bug 1356843 - Fix -Wcomma warnings in dom/base/ and dom/xml/. r?bz draft
authorChris Peterson <cpeterson@mozilla.com>
Mon, 27 Mar 2017 19:41:50 -0700
changeset 563966 206a327410b1ed367a9deae233c10578e7d8baf2
parent 563965 339eb057a6c8b16d270d023013244672461d32ff
child 563967 ac8f478a584f71bf18fe4df092c81bf9f3aeee60
push id54487
push usercpeterson@mozilla.com
push dateTue, 18 Apr 2017 06:09:29 +0000
reviewersbz
bugs1356843, 1134280
milestone55.0a1
Bug 1356843 - Fix -Wcomma warnings in dom/base/ and dom/xml/. r?bz clang's -Wcomma warning warns about suspicious use of the comma operator such as between two statements or to call a function for side effects within an expression. This warning indicates that nsXMLFragmentContentSink::CloseElement() has been calling aContent->IsHTMLElement() but not using its return value to determine whether to call PreventExecution(). This was a regression from bug 1134280 back in 2015. dom/base/nsGlobalWindow.cpp:9344:55 [-Wcomma] possible misuse of comma operator here dom/xml/nsXMLFragmentContentSink.cpp:227:50 [-Wcomma] possible misuse of comma operator here MozReview-Commit-ID: DontBxeHqGI
dom/base/nsGlobalWindow.cpp
dom/xml/nsXMLFragmentContentSink.cpp
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -9329,21 +9329,23 @@ nsGlobalWindow::ReallyCloseWindow()
            to destroy the container as it should but is a final measure
            to prevent an errant tab from doing so when it shouldn't.
            This works because we reach this code when we shouldn't only
            in the particular circumstance that we belong to a tab
            that has just been closed (and is therefore already missing
            from the list of browsers) (and has an unload handler
            that closes the window). */
         // XXXbz now that we have mHavePendingClose, is this needed?
-        bool isTab = false;
+        bool isTab;
         if (rootWin == AsOuter() ||
-            !bwin || (bwin->IsTabContentWindow(GetOuterWindowInternal(),
-                                               &isTab), isTab))
+            !bwin ||
+            (NS_SUCCEEDED(bwin->IsTabContentWindow(GetOuterWindowInternal(),
+                                                   &isTab)) && isTab)) {
           treeOwnerAsWin->Destroy();
+        }
       }
     }
 
     CleanUp();
   }
 }
 
 void
--- a/dom/xml/nsXMLFragmentContentSink.cpp
+++ b/dom/xml/nsXMLFragmentContentSink.cpp
@@ -1,13 +1,14 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
 #include "nsCOMPtr.h"
 #include "nsXMLContentSink.h"
 #include "nsIFragmentContentSink.h"
 #include "nsIXMLContentSink.h"
 #include "nsContentSink.h"
 #include "nsIExpatSink.h"
 #include "nsIDTD.h"
 #include "nsIDocument.h"
@@ -219,17 +220,17 @@ nsXMLFragmentContentSink::CreateElement(
   return rv;
 }
 
 nsresult
 nsXMLFragmentContentSink::CloseElement(nsIContent* aContent)
 {
   // don't do fancy stuff in nsXMLContentSink
   if (mPreventScriptExecution &&
-      (aContent->IsHTMLElement(nsGkAtoms::script),
+      (aContent->IsHTMLElement(nsGkAtoms::script) ||
        aContent->IsSVGElement(nsGkAtoms::script))) {
     nsCOMPtr<nsIScriptElement> sele = do_QueryInterface(aContent);
     if (sele) {
       sele->PreventExecution();
     } else {
       NS_ASSERTION(nsNameSpaceManager::GetInstance()->mSVGDisabled, "Script did QI correctly, but wasn't a disabled SVG!");
     }
   }