Bug 1434686 part 4. Use IgnoreErrors() in dom/. r=mystor

MozReview-Commit-ID: GwVDrTLPTOb
This commit is contained in:
Boris Zbarsky
2018-02-01 14:21:14 -05:00
parent 6b0d86d490
commit 3ab7ce89fa
33 changed files with 74 additions and 129 deletions

View File

@@ -72,21 +72,20 @@ class CustomElementCallbackReaction final : public CustomElementReaction
void
CustomElementCallback::Call()
{
IgnoredErrorResult rv;
switch (mType) {
case nsIDocument::eConnected:
static_cast<LifecycleConnectedCallback *>(mCallback.get())->Call(mThisObject, rv);
static_cast<LifecycleConnectedCallback *>(mCallback.get())->Call(mThisObject);
break;
case nsIDocument::eDisconnected:
static_cast<LifecycleDisconnectedCallback *>(mCallback.get())->Call(mThisObject, rv);
static_cast<LifecycleDisconnectedCallback *>(mCallback.get())->Call(mThisObject);
break;
case nsIDocument::eAdopted:
static_cast<LifecycleAdoptedCallback *>(mCallback.get())->Call(mThisObject,
mAdoptedCallbackArgs.mOldDocument, mAdoptedCallbackArgs.mNewDocument, rv);
mAdoptedCallbackArgs.mOldDocument, mAdoptedCallbackArgs.mNewDocument);
break;
case nsIDocument::eAttributeChanged:
static_cast<LifecycleAttributeChangedCallback *>(mCallback.get())->Call(mThisObject,
mArgs.name, mArgs.oldValue, mArgs.newValue, mArgs.namespaceURI, rv);
mArgs.name, mArgs.oldValue, mArgs.newValue, mArgs.namespaceURI);
break;
}
}

View File

@@ -1479,8 +1479,7 @@ Navigator::RequestVRPresentation(VRDisplay& aDisplay)
nsINetworkProperties*
Navigator::GetNetworkProperties()
{
IgnoredErrorResult rv;
return GetConnection(rv);
return GetConnection(IgnoreErrors());
}
network::Connection*

View File

@@ -60,6 +60,7 @@
#include "nsVariant.h"
using namespace mozilla::dom;
using mozilla::IgnoreErrors;
class MOZ_STACK_CLASS DragDataProducer
{
@@ -353,10 +354,9 @@ DragDataProducer::GetNodeString(nsIContent* inNode,
// use a range to get the text-equivalent of the node
nsCOMPtr<nsIDocument> doc = node->OwnerDoc();
mozilla::IgnoredErrorResult rv;
RefPtr<nsRange> range = doc->CreateRange(rv);
RefPtr<nsRange> range = doc->CreateRange(IgnoreErrors());
if (range) {
range->SelectNode(*node, rv);
range->SelectNode(*node, IgnoreErrors());
range->ToString(outNodeString);
}
}

View File

@@ -2450,19 +2450,15 @@ nsFocusManager::MoveCaretToFocus(nsIPresShell* aPresShell, nsIContent* aContent)
// Set the range to the start of the currently focused node
// Make sure it's collapsed
{
IgnoredErrorResult ignored;
newRange->SelectNodeContents(*aContent, ignored);
}
newRange->SelectNodeContents(*aContent, IgnoreErrors());
if (!aContent->GetFirstChild() ||
aContent->IsNodeOfType(nsINode::eHTML_FORM_CONTROL)) {
// If current focus node is a leaf, set range to before the
// node by using the parent as a container.
// This prevents it from appearing as selected.
IgnoredErrorResult err1, err2;
newRange->SetStartBefore(*aContent, err1);
newRange->SetEndBefore(*aContent, err2);
newRange->SetStartBefore(*aContent, IgnoreErrors());
newRange->SetEndBefore(*aContent, IgnoreErrors());
}
domSelection->AddRange(newRange);
domSelection->CollapseToStart();

View File

@@ -909,13 +909,11 @@ nsFrameLoader::Show(int32_t marginWidth, int32_t marginHeight,
// same editor object, instead of creating a new one.
RefPtr<HTMLEditor> htmlEditor = mDocShell->GetHTMLEditor();
Unused << htmlEditor;
{
IgnoredErrorResult rv;
htmlDoc->SetDesignMode(NS_LITERAL_STRING("off"), Nothing(), rv);
}
htmlDoc->SetDesignMode(NS_LITERAL_STRING("off"), Nothing(),
IgnoreErrors());
IgnoredErrorResult rv;
htmlDoc->SetDesignMode(NS_LITERAL_STRING("on"), Nothing(), rv);
htmlDoc->SetDesignMode(NS_LITERAL_STRING("on"), Nothing(),
IgnoreErrors());
} else {
// Re-initialize the presentation for contenteditable documents
bool editable = false,

View File

@@ -697,9 +697,9 @@ public:
mozilla::ErrorResult& aError);
already_AddRefed<nsPIDOMWindowOuter> GetContent()
{
mozilla::IgnoredErrorResult ignored;
nsCOMPtr<nsPIDOMWindowOuter> win =
GetContentInternal(ignored, mozilla::dom::CallerType::System);
GetContentInternal(mozilla::IgnoreErrors(),
mozilla::dom::CallerType::System);
return win.forget();
}

View File

@@ -1776,8 +1776,7 @@ nsINode::Remove()
return;
}
IgnoredErrorResult err;
parent->RemoveChild(*this, err);
parent->RemoveChild(*this, IgnoreErrors());
}
Element*

View File

@@ -174,8 +174,7 @@ nsMimeTypeArray::EnsurePluginMimeTypes()
RefPtr<Navigator> navigator = mWindow->Navigator();
IgnoredErrorResult rv;
nsPluginArray *pluginArray = navigator->GetPlugins(rv);
nsPluginArray *pluginArray = navigator->GetPlugins(IgnoreErrors());
if (!pluginArray) {
return;
}

View File

@@ -403,8 +403,7 @@ ClientSource::SetController(const ServiceWorkerDescriptor& aServiceWorker)
// TODO: Also self.navigator.serviceWorker on workers when its exposed there
if (swc && nsContentUtils::IsSafeToRunScript()) {
IgnoredErrorResult ignored;
swc->ControllerChanged(ignored);
swc->ControllerChanged(IgnoreErrors());
}
}

View File

@@ -2735,8 +2735,7 @@ void
Console::ExecuteDumpFunction(const nsAString& aMessage)
{
if (mDumpFunction) {
IgnoredErrorResult rv;
mDumpFunction->Call(aMessage, rv);
mDumpFunction->Call(aMessage);
return;
}

View File

@@ -360,32 +360,30 @@ DOMEventTargetHelper::WantsUntrusted(bool* aRetVal)
void
DOMEventTargetHelper::EventListenerAdded(nsAtom* aType)
{
IgnoredErrorResult rv;
EventListenerWasAdded(Substring(nsDependentAtomString(aType), 2), rv);
EventListenerWasAdded(Substring(nsDependentAtomString(aType), 2),
IgnoreErrors());
MaybeUpdateKeepAlive();
}
void
DOMEventTargetHelper::EventListenerAdded(const nsAString& aType)
{
IgnoredErrorResult rv;
EventListenerWasAdded(aType, rv);
EventListenerWasAdded(aType, IgnoreErrors());
MaybeUpdateKeepAlive();
}
void
DOMEventTargetHelper::EventListenerRemoved(nsAtom* aType)
{
IgnoredErrorResult rv;
EventListenerWasRemoved(Substring(nsDependentAtomString(aType), 2), rv);
EventListenerWasRemoved(Substring(nsDependentAtomString(aType), 2),
IgnoreErrors());
MaybeUpdateKeepAlive();
}
void
DOMEventTargetHelper::EventListenerRemoved(const nsAString& aType)
{
IgnoredErrorResult rv;
EventListenerWasRemoved(aType, rv);
EventListenerWasRemoved(aType, IgnoreErrors());
MaybeUpdateKeepAlive();
}

View File

@@ -578,9 +578,8 @@ DataTransferItemList::GenerateFiles(FileList* aFiles,
MOZ_ASSERT(found);
if (item->Kind() == DataTransferItem::KIND_FILE) {
IgnoredErrorResult rv;
RefPtr<File> file = item->GetAsFile(*aFilesPrincipal, rv);
if (NS_WARN_IF(rv.Failed() || !file)) {
RefPtr<File> file = item->GetAsFile(*aFilesPrincipal, IgnoreErrors());
if (NS_WARN_IF(!file)) {
continue;
}
aFiles->Append(file);

View File

@@ -349,8 +349,7 @@ public:
NS_IMETHOD
VisitHeader(const nsACString& aHeader, const nsACString& aValue) override
{
IgnoredErrorResult result;
mInternalHeaders->Append(aHeader, aValue, result);
mInternalHeaders->Append(aHeader, aValue, IgnoreErrors());
return NS_OK;
}
};

View File

@@ -463,8 +463,7 @@ bool
HTMLButtonElement::RestoreState(nsPresState* aState)
{
if (aState && aState->IsDisabledSet() && !aState->GetDisabled()) {
IgnoredErrorResult rv;
SetDisabled(false, rv);
SetDisabled(false, IgnoreErrors());
}
return false;

View File

@@ -495,8 +495,7 @@ HTMLImageElement::AfterMaybeChangeAttr(int32_t aNamespaceID, nsAtom* aName,
// Bug 1076583 - We still use the older synchronous algorithm in
// non-responsive mode. Force a new load of the image with the
// new cross origin policy
IgnoredErrorResult error;
ForceReload(aNotify, error);
ForceReload(aNotify, IgnoreErrors());
}
}
}

View File

@@ -748,8 +748,7 @@ nsColorPickerShownCallback::UpdateInternal(const nsAString& aColor,
mInput->GetValue(oldValue, CallerType::System);
}
IgnoredErrorResult rv;
mInput->SetValue(aColor, CallerType::System, rv);
mInput->SetValue(aColor, CallerType::System, IgnoreErrors());
if (!aTrustedUpdate) {
nsAutoString newValue;
@@ -1893,15 +1892,13 @@ HTMLInputElement::SetValue(Decimal aValue, CallerType aCallerType)
MOZ_ASSERT(!aValue.isInfinity(), "aValue must not be Infinity!");
if (aValue.isNaN()) {
IgnoredErrorResult rv;
SetValue(EmptyString(), aCallerType, rv);
SetValue(EmptyString(), aCallerType, IgnoreErrors());
return;
}
nsAutoString value;
mInputType->ConvertNumberToString(aValue, value);
IgnoredErrorResult rv;
SetValue(value, aCallerType, rv);
SetValue(value, aCallerType, IgnoreErrors());
}
Nullable<Date>
@@ -6691,8 +6688,7 @@ HTMLInputElement::RestoreState(nsPresState* aState)
}
if (aState->IsDisabledSet() && !aState->GetDisabled()) {
IgnoredErrorResult ignored;
SetDisabled(false, ignored);
SetDisabled(false, IgnoreErrors());
}
return restoredCheckedState;

View File

@@ -190,8 +190,7 @@ HTMLScriptElement::GetScriptType(nsAString& aType)
void
HTMLScriptElement::GetScriptText(nsAString& text)
{
IgnoredErrorResult rv;
GetText(text, rv);
GetText(text, IgnoreErrors());
}
void

View File

@@ -1467,8 +1467,7 @@ HTMLSelectElement::RestoreState(nsPresState* aState)
}
if (aState->IsDisabledSet() && !aState->GetDisabled()) {
IgnoredErrorResult rv;
SetDisabled(false, rv);
SetDisabled(false, IgnoreErrors());
}
return false;

View File

@@ -642,8 +642,7 @@ HTMLTableElement::CreateTHead()
}
}
IgnoredErrorResult rv;
nsINode::InsertBefore(*head, refNode, rv);
nsINode::InsertBefore(*head, refNode, IgnoreErrors());
}
return head.forget();
}
@@ -705,9 +704,8 @@ HTMLTableElement::CreateCaption()
return nullptr;
}
IgnoredErrorResult rv;
nsCOMPtr<nsINode> firsChild = nsINode::GetFirstChild();
nsINode::InsertBefore(*caption, firsChild, rv);
nsINode::InsertBefore(*caption, firsChild, IgnoreErrors());
}
return caption.forget();
}
@@ -746,8 +744,7 @@ HTMLTableElement::CreateTBody()
}
}
IgnoredErrorResult rv;
nsINode::InsertBefore(*newBody, referenceNode, rv);
nsINode::InsertBefore(*newBody, referenceNode, IgnoreErrors());
return newBody.forget();
}

View File

@@ -789,8 +789,7 @@ nsresult
HTMLTextAreaElement::Reset()
{
nsAutoString resetVal;
IgnoredErrorResult res;
GetDefaultValue(resetVal, res);
GetDefaultValue(resetVal, IgnoreErrors());
SetValueChanged(false);
nsresult rv = SetValueInternal(resetVal,
@@ -891,8 +890,7 @@ HTMLTextAreaElement::RestoreState(nsPresState* aState)
}
if (aState->IsDisabledSet() && !aState->GetDisabled()) {
IgnoredErrorResult rv;
SetDisabled(false, rv);
SetDisabled(false, IgnoreErrors());
}
return false;
@@ -1312,8 +1310,7 @@ HTMLTextAreaElement::GetRows()
NS_IMETHODIMP_(void)
HTMLTextAreaElement::GetDefaultValueFromContent(nsAString& aValue)
{
IgnoredErrorResult rv;
GetDefaultValue(aValue, rv);
GetDefaultValue(aValue, IgnoreErrors());
}
NS_IMETHODIMP_(bool)

View File

@@ -368,16 +368,10 @@ ImageDocument::ShrinkToFit()
// Keep image content alive while changing the attributes.
RefPtr<HTMLImageElement> image = HTMLImageElement::FromContent(mImageContent);
{
IgnoredErrorResult ignored;
image->SetWidth(std::max(1, NSToCoordFloor(GetRatio() * mImageWidth)),
ignored);
}
{
IgnoredErrorResult ignored;
image->SetHeight(std::max(1, NSToCoordFloor(GetRatio() * mImageHeight)),
ignored);
}
image->SetWidth(std::max(1, NSToCoordFloor(GetRatio() * mImageWidth)),
IgnoreErrors());
image->SetHeight(std::max(1, NSToCoordFloor(GetRatio() * mImageHeight)),
IgnoreErrors());
// The view might have been scrolled when zooming in, scroll back to the
// origin now that we're showing a shrunk-to-window version.

View File

@@ -2040,12 +2040,10 @@ nsTextEditorState::UnbindFromFrame(nsTextControlFrame* aFrame)
if (!IsSelectionCached()) {
// Go ahead and cache it now.
uint32_t start = 0, end = 0;
IgnoredErrorResult rangeRv;
GetSelectionRange(&start, &end, rangeRv);
GetSelectionRange(&start, &end, IgnoreErrors());
IgnoredErrorResult dirRv;
nsITextControlFrame::SelectionDirection direction =
GetSelectionDirection(dirRv);
GetSelectionDirection(IgnoreErrors());
SelectionProperties& props = GetSelectionProperties();
props.SetStart(start);

View File

@@ -672,8 +672,7 @@ AudioContext::Shutdown()
// We don't want to touch promises if the global is going away soon.
if (!mIsDisconnecting) {
if (!mIsOffline) {
IgnoredErrorResult dummy;
RefPtr<Promise> ignored = Close(dummy);
RefPtr<Promise> ignored = Close(IgnoreErrors());
}
for (auto p : mPromiseGripArray) {

View File

@@ -277,8 +277,7 @@ PromiseDebugging::FlushUncaughtRejectionsInternal()
RefPtr<UncaughtRejectionObserver> obs =
static_cast<UncaughtRejectionObserver*>(observers[j].get());
IgnoredErrorResult err;
obs->OnLeftUncaught(promise, err);
obs->OnLeftUncaught(promise, IgnoreErrors());
}
JSAutoCompartment ac(cx, promise);
Promise::ReportRejectedPromise(cx, promise);
@@ -294,8 +293,7 @@ PromiseDebugging::FlushUncaughtRejectionsInternal()
RefPtr<UncaughtRejectionObserver> obs =
static_cast<UncaughtRejectionObserver*>(observers[j].get());
IgnoredErrorResult err;
obs->OnConsumed(promise, err);
obs->OnConsumed(promise, IgnoreErrors());
}
}
storage->mConsumedRejections.clear();

View File

@@ -737,7 +737,7 @@ RespondWithHandler::ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValu
ir->GetUnfilteredBody(getter_AddRefs(body));
// Errors and redirects may not have a body.
if (body) {
IgnoredErrorResult error;
ErrorResult error;
response->SetBodyUsed(aCx, error);
if (NS_WARN_IF(error.Failed())) {
autoCancel.SetCancelErrorResult(aCx, error);

View File

@@ -618,9 +618,8 @@ private:
ir->SetPrincipalInfo(Move(principalInfo));
}
IgnoredErrorResult ignored;
RefPtr<InternalHeaders> internalHeaders = aCN->GetInternalHeaders();
ir->Headers()->Fill(*(internalHeaders.get()), ignored);
ir->Headers()->Fill(*(internalHeaders.get()), IgnoreErrors());
RefPtr<Response> response =
new Response(aCache->GetGlobalObject(), ir, nullptr);

View File

@@ -386,8 +386,7 @@ SVGAnimationElement::ActivateByHyperlink()
// else, silently fail. We mustn't be part of an SVG document fragment that
// is attached to the document tree so there's nothing we can do here
} else {
IgnoredErrorResult rv;
BeginElement(rv);
BeginElement(IgnoreErrors());
}
}

View File

@@ -258,9 +258,9 @@ SVGUseElement::CreateAnonymousContent()
nsNodeInfoManager* nodeInfoManager =
targetContent->OwnerDoc() == OwnerDoc() ?
nullptr : OwnerDoc()->NodeInfoManager();
IgnoredErrorResult rv;
nsCOMPtr<nsINode> newnode =
nsNodeUtils::Clone(targetContent, true, nodeInfoManager, nullptr, rv);
nsNodeUtils::Clone(targetContent, true, nodeInfoManager, nullptr,
IgnoreErrors());
nsCOMPtr<nsIContent> newcontent = do_QueryInterface(newnode);
if (!newcontent)

View File

@@ -696,8 +696,7 @@ PersistNodeFixup::FixupAttribute(nsINode* aNode,
attr->GetValue(uri);
rv = FixupURI(uri);
if (NS_SUCCEEDED(rv)) {
IgnoredErrorResult err;
attr->SetValue(uri, err);
attr->SetValue(uri, IgnoreErrors());
}
}
@@ -749,8 +748,7 @@ PersistNodeFixup::FixupAnchor(nsINode *aNode)
nsAutoCString uriSpec;
rv = newURI->GetSpec(uriSpec);
NS_ENSURE_SUCCESS(rv, rv);
IgnoredErrorResult err;
attr->SetValue(NS_ConvertUTF8toUTF16(uriSpec), err);
attr->SetValue(NS_ConvertUTF8toUTF16(uriSpec), IgnoreErrors());
}
}
@@ -1128,19 +1126,16 @@ PersistNodeFixup::FixupNode(nsINode* aNodeIn,
nodeAsInput->GetValue(valueStr, dom::CallerType::System);
// Avoid superfluous value="" serialization
if (valueStr.IsEmpty()) {
IgnoredErrorResult ignored;
outElt->RemoveAttribute(valueAttr, ignored);
outElt->RemoveAttribute(valueAttr, IgnoreErrors());
} else {
IgnoredErrorResult ignored;
outElt->SetAttribute(valueAttr, valueStr, ignored);
outElt->SetAttribute(valueAttr, valueStr, IgnoreErrors());
}
break;
case NS_FORM_INPUT_CHECKBOX:
case NS_FORM_INPUT_RADIO:
{
bool checked = nodeAsInput->Checked();
IgnoredErrorResult ignored;
outElt->SetDefaultChecked(checked, ignored);
outElt->SetDefaultChecked(checked, IgnoreErrors());
}
break;
default:
@@ -1160,8 +1155,7 @@ PersistNodeFixup::FixupNode(nsINode* aNodeIn,
nsAutoString valueStr;
nodeAsTextArea->GetValue(valueStr);
IgnoredErrorResult err;
(*aNodeOut)->SetTextContent(valueStr, err);
(*aNodeOut)->SetTextContent(valueStr, IgnoreErrors());
}
return rv;
}
@@ -1173,8 +1167,7 @@ PersistNodeFixup::FixupNode(nsINode* aNodeIn,
dom::HTMLOptionElement* outElt =
dom::HTMLOptionElement::FromContent((*aNodeOut)->AsContent());
bool selected = nodeAsOption->Selected();
IgnoredErrorResult ignored;
outElt->SetDefaultSelected(selected, ignored);
outElt->SetDefaultSelected(selected, IgnoreErrors());
}
return rv;
}

View File

@@ -1649,8 +1649,7 @@ CacheCreator::DeleteCache()
if (mCacheStorage) {
// It's safe to do this while Cache::Match() and Cache::Put() calls are
// running.
IgnoredErrorResult rv;
RefPtr<Promise> promise = mCacheStorage->Delete(mCacheName, rv);
RefPtr<Promise> promise = mCacheStorage->Delete(mCacheName, IgnoreErrors());
// We don't care to know the result of the promise object.
}
@@ -1781,13 +1780,12 @@ CacheScriptLoader::ResolvedCallback(JSContext* aCx,
InternalHeaders* headers = response->GetInternalHeaders();
IgnoredErrorResult ignored;
headers->Get(NS_LITERAL_CSTRING("content-security-policy"),
mCSPHeaderValue, ignored);
mCSPHeaderValue, IgnoreErrors());
headers->Get(NS_LITERAL_CSTRING("content-security-policy-report-only"),
mCSPReportOnlyHeaderValue, ignored);
mCSPReportOnlyHeaderValue, IgnoreErrors());
headers->Get(NS_LITERAL_CSTRING("referrer-policy"),
mReferrerPolicyHeaderValue, ignored);
mReferrerPolicyHeaderValue, IgnoreErrors());
nsCOMPtr<nsIInputStream> inputStream;
response->GetBody(getter_AddRefs(inputStream));

View File

@@ -321,9 +321,9 @@ nsXBLBinding::GenerateAnonymousContent()
if (hasContent) {
nsIDocument* doc = mBoundElement->OwnerDoc();
IgnoredErrorResult rv;
nsCOMPtr<nsINode> clonedNode =
nsNodeUtils::Clone(content, true, doc->NodeInfoManager(), nullptr, rv);
nsNodeUtils::Clone(content, true, doc->NodeInfoManager(), nullptr,
IgnoreErrors());
// FIXME: Bug 1399558, Why is this code OK assuming that nsNodeUtils::Clone
// never fails?
mContent = clonedNode->AsElement();

View File

@@ -675,8 +675,7 @@ nsXBLPrototypeHandler::GetController(EventTarget* aTarget)
RefPtr<nsXULElement> xulElement =
nsXULElement::FromContentOrNull(targetContent);
if (xulElement) {
IgnoredErrorResult rv;
controllers = xulElement->GetControllers(rv);
controllers = xulElement->GetControllers(IgnoreErrors());
}
if (!controllers) {

View File

@@ -879,8 +879,7 @@ nsXULElement::RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify)
nsCOMPtr<nsIContent> curNode = do_QueryInterface(curItem);
if (curNode && nsContentUtils::ContentIsDescendantOf(curNode, oldKid)) {
// Current item going away
IgnoredErrorResult ignored;
nsCOMPtr<nsIBoxObject> box = xulElement->GetBoxObject(ignored);
nsCOMPtr<nsIBoxObject> box = xulElement->GetBoxObject(IgnoreErrors());
listBox = do_QueryInterface(box);
if (listBox && oldKidElem) {
listBox->GetIndexOfItem(oldKidElem, &newCurrentIndex);
@@ -974,8 +973,7 @@ nsXULElement::RemoveChildNode(nsIContent* aKid, bool aNotify)
nsCOMPtr<nsIContent> curNode = do_QueryInterface(curItem);
if (curNode && nsContentUtils::ContentIsDescendantOf(curNode, aKid)) {
// Current item going away
IgnoredErrorResult ignored;
nsCOMPtr<nsIBoxObject> box = xulElement->GetBoxObject(ignored);
nsCOMPtr<nsIBoxObject> box = xulElement->GetBoxObject(IgnoreErrors());
listBox = do_QueryInterface(box);
if (listBox && oldKidElem) {
listBox->GetIndexOfItem(oldKidElem, &newCurrentIndex);