Bug 1438026 - Part 3: Replace nsPresState with the new PresState type, r=baku

This commit is contained in:
Nika Layzell
2018-03-02 13:18:35 -05:00
parent 63df0ece5a
commit cccd4523db
21 changed files with 256 additions and 372 deletions

View File

@@ -35,7 +35,7 @@
#include "nsMappedAttributes.h"
#include "nsPIDOMWindow.h"
#include "nsPresContext.h"
#include "nsPresState.h"
#include "mozilla/PresState.h"
#include "nsReadableUtils.h"
#include "nsStyleConsts.h"
#include "nsTextEditorState.h"
@@ -831,7 +831,7 @@ HTMLTextAreaElement::SaveState()
nsresult rv = NS_OK;
// Only save if value != defaultValue (bug 62713)
nsPresState *state = nullptr;
PresState *state = nullptr;
if (mValueChanged) {
state = GetPrimaryPresState();
if (state) {
@@ -848,13 +848,7 @@ HTMLTextAreaElement::SaveState()
return rv;
}
nsCOMPtr<nsISupportsString> pState =
do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID);
if (!pState) {
return NS_ERROR_OUT_OF_MEMORY;
}
pState->SetData(value);
state->SetStateProperty(pState);
state->contentData() = Move(value);
}
}
@@ -866,27 +860,25 @@ HTMLTextAreaElement::SaveState()
if (state) {
// We do not want to save the real disabled state but the disabled
// attribute.
state->SetDisabled(HasAttr(kNameSpaceID_None, nsGkAtoms::disabled));
state->disabled() = HasAttr(kNameSpaceID_None, nsGkAtoms::disabled);
state->disabledSet() = true;
}
}
return rv;
}
bool
HTMLTextAreaElement::RestoreState(nsPresState* aState)
HTMLTextAreaElement::RestoreState(PresState* aState)
{
nsCOMPtr<nsISupportsString> state
(do_QueryInterface(aState->GetStateProperty()));
const PresContentData& state = aState->contentData();
if (state) {
nsAutoString data;
state->GetData(data);
if (state.type() == PresContentData::TnsString) {
ErrorResult rv;
SetValue(data, rv);
SetValue(state.get_nsString(), rv);
ENSURE_SUCCESS(rv, false);
}
if (aState->IsDisabledSet() && !aState->GetDisabled()) {
if (aState->disabledSet() && !aState->disabled()) {
SetDisabled(false, IgnoreErrors());
}