Bug 1553705 - Make GenerateStateKey() infallible. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D32258
This commit is contained in:
Cameron McCormack
2019-06-26 21:44:03 +00:00
parent f4cf8185db
commit a7dd303c43
12 changed files with 43 additions and 60 deletions

View File

@@ -2484,24 +2484,19 @@ nsGenericHTMLFormElementWithState::nsGenericHTMLFormElementWithState(
mStateKey.SetIsVoid(true);
}
nsresult nsGenericHTMLFormElementWithState::GenerateStateKey() {
void nsGenericHTMLFormElementWithState::GenerateStateKey() {
// Keep the key if already computed
if (!mStateKey.IsVoid()) {
return NS_OK;
return;
}
Document* doc = GetUncomposedDoc();
if (!doc) {
return NS_OK;
return;
}
// Generate the state key
nsresult rv = nsContentUtils::GenerateStateKey(this, doc, mStateKey);
if (NS_FAILED(rv)) {
mStateKey.SetIsVoid(true);
return rv;
}
nsContentUtils::GenerateStateKey(this, doc, mStateKey);
// If the state key is blank, this is anonymous content or for whatever
// reason we are not supposed to save/restore state: keep it as such.
@@ -2509,7 +2504,6 @@ nsresult nsGenericHTMLFormElementWithState::GenerateStateKey() {
// Add something unique to content so layout doesn't muck us up.
mStateKey += "-C";
}
return NS_OK;
}
PresState* nsGenericHTMLFormElementWithState::GetPrimaryPresState() {