/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include"ChangeAttributeTransaction.h"
#include"EditorDOMAPIWrapper.h"
#include"mozilla/Logging.h" #include"mozilla/ToString.h" #include"mozilla/dom/Element.h"// for Element
#include"nsAString.h" #include"nsError.h"// for NS_ERROR_NOT_INITIALIZED, etc.
// Need to get the current value of the attribute and save it, and set // mAttributeWasSet
mAttributeWasSet = mElement->GetAttr(mAttribute, mUndoValue);
// XXX: hack until attribute-was-set code is implemented if (!mUndoValue.IsEmpty()) {
mAttributeWasSet = true;
} // XXX: end hack
const OwningNonNull<EditorBase> editorBase = *mEditorBase; const OwningNonNull<Element> element = *mElement; // Now set the attribute to the new value if (mRemoveAttribute) {
AutoElementAttrAPIWrapper elementWrapper(editorBase, element);
nsresult rv = elementWrapper.UnsetAttr(MOZ_KnownLive(mAttribute), true); if (NS_FAILED(rv)) {
NS_WARNING("AutoElementAttrAPIWrapper::UnsetAttr() failed"); return rv;
}
NS_WARNING_ASSERTION(
elementWrapper.IsExpectedResult(EmptyString()), "Removing attribute caused other mutations, but ignored"); return NS_OK;
}
AutoElementAttrAPIWrapper elementWrapper(editorBase, element);
nsresult rv = elementWrapper.SetAttr(MOZ_KnownLive(mAttribute), mValue, true); if (NS_FAILED(rv)) {
NS_WARNING("AutoElementAttrAPIWrapper::SetAttr() failed"); return rv;
}
NS_WARNING_ASSERTION(elementWrapper.IsExpectedResult(mValue), "Setting attribute caused other mutations, but ignored"); return rv;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.