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
--- 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!");
}
}