mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-26 14:46:02 +00:00
Bug 841442 - Move HTMLFormElement to WebIDL, r=bz
This commit is contained in:
parent
3e4e0d931a
commit
91c64da847
@ -109,13 +109,13 @@ nsFormData::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
||||
|
||||
/* static */ already_AddRefed<nsFormData>
|
||||
nsFormData::Constructor(const GlobalObject& aGlobal,
|
||||
const Optional<HTMLFormElement*>& aFormElement,
|
||||
const Optional<NonNull<HTMLFormElement> >& aFormElement,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsRefPtr<nsFormData> formData = new nsFormData(aGlobal.Get());
|
||||
if (aFormElement.WasPassed()) {
|
||||
MOZ_ASSERT(aFormElement.Value());
|
||||
aRv = aFormElement.Value()->WalkFormElements(formData);
|
||||
// TODO: this should ...Value().WalkFromElements(formData); - Bug 883827
|
||||
aRv = aFormElement.Value().get()->WalkFormElements(formData);
|
||||
}
|
||||
return formData.forget();
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
}
|
||||
static already_AddRefed<nsFormData>
|
||||
Constructor(const mozilla::dom::GlobalObject& aGlobal,
|
||||
const mozilla::dom::Optional<mozilla::dom::HTMLFormElement*>& aFormElement,
|
||||
const mozilla::dom::Optional<mozilla::dom::NonNull<mozilla::dom::HTMLFormElement> >& aFormElement,
|
||||
mozilla::ErrorResult& aRv);
|
||||
void Append(const nsAString& aName, const nsAString& aValue);
|
||||
void Append(const nsAString& aName, nsIDOMBlob* aBlob,
|
||||
|
@ -4,6 +4,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/HTMLFormElement.h"
|
||||
#include "mozilla/dom/HTMLFormElementBinding.h"
|
||||
#include "nsIHTMLDocument.h"
|
||||
#include "nsEventStateManager.h"
|
||||
#include "nsEventStates.h"
|
||||
@ -252,6 +253,8 @@ HTMLFormElement::HTMLFormElement(already_AddRefed<nsINodeInfo> aNodeInfo)
|
||||
{
|
||||
mImageNameLookupTable.Init(NS_FORM_CONTROL_LIST_HASHTABLE_SIZE);
|
||||
mPastNameLookupTable.Init(NS_FORM_CONTROL_LIST_HASHTABLE_SIZE);
|
||||
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
HTMLFormElement::~HTMLFormElement()
|
||||
@ -311,8 +314,17 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLFormElement,
|
||||
nsGenericHTMLElement)
|
||||
tmp->Clear();
|
||||
++tmp->mExpandoAndGeneration.generation;
|
||||
tmp->mExpandoAndGeneration.expando = JS::UndefinedValue();
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(HTMLFormElement,
|
||||
nsGenericHTMLElement)
|
||||
if (tmp->PreservingWrapper()) {
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_JSVAL_MEMBER_CALLBACK(mExpandoAndGeneration.expando);
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(HTMLFormElement, Element)
|
||||
NS_IMPL_RELEASE_INHERITED(HTMLFormElement, Element)
|
||||
|
||||
@ -334,10 +346,16 @@ NS_ELEMENT_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_ELEMENT_CLONE_WITH_INIT(HTMLFormElement)
|
||||
|
||||
nsIHTMLCollection*
|
||||
HTMLFormElement::Elements()
|
||||
{
|
||||
return mControls;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLFormElement::GetElements(nsIDOMHTMLCollection** aElements)
|
||||
{
|
||||
*aElements = mControls;
|
||||
*aElements = Elements();
|
||||
NS_ADDREF(*aElements);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -399,11 +417,10 @@ NS_IMPL_BOOL_ATTR(HTMLFormElement, NoValidate, novalidate)
|
||||
NS_IMPL_STRING_ATTR(HTMLFormElement, Name, name)
|
||||
NS_IMPL_STRING_ATTR(HTMLFormElement, Target, target)
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLFormElement::Submit()
|
||||
void
|
||||
HTMLFormElement::Submit(ErrorResult& aRv)
|
||||
{
|
||||
// Send the submit event
|
||||
nsresult rv = NS_OK;
|
||||
nsRefPtr<nsPresContext> presContext = GetPresContext();
|
||||
if (mPendingSubmission) {
|
||||
// aha, we have a pending submission that was not flushed
|
||||
@ -413,8 +430,15 @@ HTMLFormElement::Submit()
|
||||
mPendingSubmission = nullptr;
|
||||
}
|
||||
|
||||
rv = DoSubmitOrReset(nullptr, NS_FORM_SUBMIT);
|
||||
return rv;
|
||||
aRv = DoSubmitOrReset(nullptr, NS_FORM_SUBMIT);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLFormElement::Submit()
|
||||
{
|
||||
ErrorResult rv;
|
||||
Submit(rv);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -429,7 +453,7 @@ HTMLFormElement::Reset()
|
||||
NS_IMETHODIMP
|
||||
HTMLFormElement::CheckValidity(bool* retVal)
|
||||
{
|
||||
*retVal = CheckFormValidity(nullptr);
|
||||
*retVal = CheckValidity();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1082,6 +1106,14 @@ HTMLFormElement::GetElementCount() const
|
||||
return count;
|
||||
}
|
||||
|
||||
Element*
|
||||
HTMLFormElement::IndexedGetter(uint32_t aIndex, bool &aFound)
|
||||
{
|
||||
Element* element = mControls->mElements.SafeElementAt(aIndex, nullptr);
|
||||
aFound = element != nullptr;
|
||||
return element;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsIFormControl*)
|
||||
HTMLFormElement::GetElementAt(int32_t aIndex) const
|
||||
{
|
||||
@ -1434,8 +1466,8 @@ HTMLFormElement::HandleDefaultSubmitRemoval()
|
||||
}
|
||||
}
|
||||
|
||||
static nsresult
|
||||
RemoveElementFromTableInternal(
|
||||
nsresult
|
||||
HTMLFormElement::RemoveElementFromTableInternal(
|
||||
nsInterfaceHashtable<nsStringHashKey,nsISupports>& aTable,
|
||||
nsIContent* aChild, const nsAString& aName)
|
||||
{
|
||||
@ -1448,6 +1480,7 @@ RemoveElementFromTableInternal(
|
||||
// we're trying to remove...
|
||||
if (supports == aChild) {
|
||||
aTable.Remove(aName);
|
||||
++mExpandoAndGeneration.generation;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1471,6 +1504,7 @@ RemoveElementFromTableInternal(
|
||||
// If the list is empty we remove if from our hash, this shouldn't
|
||||
// happen tho
|
||||
aTable.Remove(aName);
|
||||
++mExpandoAndGeneration.generation;
|
||||
} else if (length == 1) {
|
||||
// Only one element left, replace the list in the hash with the
|
||||
// single element.
|
||||
@ -1499,32 +1533,56 @@ HTMLFormElement::RemoveElementFromTable(nsGenericHTMLFormElement* aElement,
|
||||
// If the element is being removed from the form, we have to remove it from
|
||||
// the past names map.
|
||||
if (aRemoveReason == ElementRemoved) {
|
||||
uint32_t oldCount = mPastNameLookupTable.Count();
|
||||
mPastNameLookupTable.Enumerate(RemovePastNames, aElement);
|
||||
if (oldCount != mPastNameLookupTable.Count()) {
|
||||
++mExpandoAndGeneration.generation;
|
||||
}
|
||||
}
|
||||
|
||||
return mControls->RemoveElementFromTable(aElement, aName);
|
||||
}
|
||||
|
||||
already_AddRefed<nsISupports>
|
||||
HTMLFormElement::FindNamedItem(const nsAString& aName,
|
||||
nsWrapperCache** aCache)
|
||||
HTMLFormElement::NamedGetter(const nsAString& aName, bool &aFound)
|
||||
{
|
||||
aFound = true;
|
||||
|
||||
nsCOMPtr<nsISupports> result = DoResolveName(aName, true);
|
||||
if (result) {
|
||||
// FIXME Get the wrapper cache from DoResolveName.
|
||||
*aCache = nullptr;
|
||||
AddToPastNamesMap(aName, result);
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
result = mImageNameLookupTable.GetWeak(aName);
|
||||
if (result) {
|
||||
*aCache = nullptr;
|
||||
AddToPastNamesMap(aName, result);
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
result = mPastNameLookupTable.GetWeak(aName);
|
||||
if (result) {
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
aFound = false;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
HTMLFormElement::GetSupportedNames(nsTArray<nsString >& aRetval)
|
||||
{
|
||||
// TODO https://www.w3.org/Bugs/Public/show_bug.cgi?id=22320
|
||||
}
|
||||
|
||||
already_AddRefed<nsISupports>
|
||||
HTMLFormElement::FindNamedItem(const nsAString& aName,
|
||||
nsWrapperCache** aCache)
|
||||
{
|
||||
// FIXME Get the wrapper cache from DoResolveName.
|
||||
|
||||
bool found;
|
||||
nsCOMPtr<nsISupports> result = NamedGetter(aName, found);
|
||||
if (result) {
|
||||
*aCache = nullptr;
|
||||
return result.forget();
|
||||
@ -1765,13 +1823,17 @@ HTMLFormElement::SetEncoding(const nsAString& aEncoding)
|
||||
return SetEnctype(aEncoding);
|
||||
}
|
||||
|
||||
int32_t
|
||||
HTMLFormElement::Length()
|
||||
{
|
||||
return mControls->Length();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLFormElement::GetLength(int32_t* aLength)
|
||||
{
|
||||
uint32_t length;
|
||||
nsresult rv = mControls->GetLength(&length);
|
||||
*aLength = length;
|
||||
return rv;
|
||||
*aLength = Length();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
@ -2456,10 +2518,10 @@ nsFormControlList::NamedItemInternal(const nsAString& aName,
|
||||
return mNameLookupTable.GetWeak(aName);
|
||||
}
|
||||
|
||||
static nsresult
|
||||
AddElementToTableInternal(
|
||||
nsresult
|
||||
HTMLFormElement::AddElementToTableInternal(
|
||||
nsInterfaceHashtable<nsStringHashKey,nsISupports>& aTable,
|
||||
nsIContent* aChild, const nsAString& aName, HTMLFormElement* aForm)
|
||||
nsIContent* aChild, const nsAString& aName)
|
||||
{
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
aTable.Get(aName, getter_AddRefs(supports));
|
||||
@ -2467,6 +2529,7 @@ AddElementToTableInternal(
|
||||
if (!supports) {
|
||||
// No entry found, add the element
|
||||
aTable.Put(aName, aChild);
|
||||
++mExpandoAndGeneration.generation;
|
||||
} else {
|
||||
// Found something in the hash, check its type
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(supports);
|
||||
@ -2482,7 +2545,7 @@ AddElementToTableInternal(
|
||||
|
||||
// Found an element, create a list, add the element to the list and put
|
||||
// the list in the hash
|
||||
nsSimpleContentList *list = new nsSimpleContentList(aForm);
|
||||
nsSimpleContentList *list = new nsSimpleContentList(this);
|
||||
|
||||
// If an element has a @form, we can assume it *might* be able to not have
|
||||
// a parent and still be in the form.
|
||||
@ -2558,7 +2621,7 @@ nsFormControlList::AddElementToTable(nsGenericHTMLFormElement* aChild,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return AddElementToTableInternal(mNameLookupTable, aChild, aName, mForm);
|
||||
return mForm->AddElementToTableInternal(mNameLookupTable, aChild, aName);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -2582,7 +2645,7 @@ nsFormControlList::RemoveElementFromTable(nsGenericHTMLFormElement* aChild,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return RemoveElementFromTableInternal(mNameLookupTable, aChild, aName);
|
||||
return mForm->RemoveElementFromTableInternal(mNameLookupTable, aChild, aName);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -2718,7 +2781,7 @@ nsresult
|
||||
HTMLFormElement::AddImageElementToTable(HTMLImageElement* aChild,
|
||||
const nsAString& aName)
|
||||
{
|
||||
return AddElementToTableInternal(mImageNameLookupTable, aChild, aName, this);
|
||||
return AddElementToTableInternal(mImageNameLookupTable, aChild, aName);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -2758,5 +2821,11 @@ HTMLFormElement::AddToPastNamesMap(const nsAString& aName,
|
||||
}
|
||||
}
|
||||
|
||||
JSObject*
|
||||
HTMLFormElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
||||
{
|
||||
return HTMLFormElementBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -48,6 +48,8 @@ class HTMLFormElement : public nsGenericHTMLElement,
|
||||
public nsIForm,
|
||||
public nsIRadioGroupContainer
|
||||
{
|
||||
friend class nsFormControlList;
|
||||
|
||||
public:
|
||||
HTMLFormElement(already_AddRefed<nsINodeInfo> aNodeInfo);
|
||||
virtual ~HTMLFormElement();
|
||||
@ -131,8 +133,8 @@ public:
|
||||
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLFormElement,
|
||||
nsGenericHTMLElement)
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(HTMLFormElement,
|
||||
nsGenericHTMLElement)
|
||||
|
||||
/**
|
||||
* Remove an element from this form's list of elements
|
||||
@ -315,7 +317,107 @@ public:
|
||||
already_AddRefed<nsISupports>
|
||||
FindNamedItem(const nsAString& aName, nsWrapperCache** aCache);
|
||||
|
||||
// WebIDL
|
||||
|
||||
void GetAcceptCharset(DOMString& aValue)
|
||||
{
|
||||
GetHTMLAttr(nsGkAtoms::acceptcharset, aValue);
|
||||
}
|
||||
|
||||
void SetAcceptCharset(const nsAString& aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::acceptcharset, aValue, aRv);
|
||||
}
|
||||
|
||||
// XPCOM GetAction() is OK
|
||||
void SetAction(const nsAString& aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::action, aValue, aRv);
|
||||
}
|
||||
|
||||
// XPCOM GetAutocomplete() is OK
|
||||
void SetAutocomplete(const nsAString& aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::autocomplete, aValue, aRv);
|
||||
}
|
||||
|
||||
// XPCOM GetEnctype() is OK
|
||||
void SetEnctype(const nsAString& aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::enctype, aValue, aRv);
|
||||
}
|
||||
|
||||
// XPCOM GetEncoding() is OK
|
||||
void SetEncoding(const nsAString& aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetEnctype(aValue, aRv);
|
||||
}
|
||||
|
||||
// XPCOM GetMethod() is OK
|
||||
void SetMethod(const nsAString& aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::method, aValue, aRv);
|
||||
}
|
||||
|
||||
void GetName(DOMString& aValue)
|
||||
{
|
||||
GetHTMLAttr(nsGkAtoms::name, aValue);
|
||||
}
|
||||
|
||||
void SetName(const nsAString& aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::name, aValue, aRv);
|
||||
}
|
||||
|
||||
bool NoValidate() const
|
||||
{
|
||||
return GetBoolAttr(nsGkAtoms::novalidate);
|
||||
}
|
||||
|
||||
void SetNoValidate(bool aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetHTMLBoolAttr(nsGkAtoms::novalidate, aValue, aRv);
|
||||
}
|
||||
|
||||
void GetTarget(DOMString& aValue)
|
||||
{
|
||||
GetHTMLAttr(nsGkAtoms::target, aValue);
|
||||
}
|
||||
|
||||
void SetTarget(const nsAString& aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::target, aValue, aRv);
|
||||
}
|
||||
|
||||
// it's only out-of-line because the class definition is not available in the
|
||||
// header
|
||||
nsIHTMLCollection* Elements();
|
||||
|
||||
int32_t Length();
|
||||
|
||||
void Submit(ErrorResult& aRv);
|
||||
|
||||
// XPCOM Reset() is OK
|
||||
|
||||
bool CheckValidity()
|
||||
{
|
||||
return CheckFormValidity(nullptr);
|
||||
}
|
||||
|
||||
Element*
|
||||
IndexedGetter(uint32_t aIndex, bool &aFound);
|
||||
|
||||
already_AddRefed<nsISupports>
|
||||
NamedGetter(const nsAString& aName, bool &aFound);
|
||||
|
||||
void GetSupportedNames(nsTArray<nsString >& aRetval);
|
||||
|
||||
js::ExpandoAndGeneration mExpandoAndGeneration;
|
||||
|
||||
protected:
|
||||
virtual JSObject* WrapNode(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
||||
|
||||
void PostPasswordEvent();
|
||||
void EventHandled() { mFormPasswordEvent = nullptr; }
|
||||
|
||||
@ -366,7 +468,7 @@ protected:
|
||||
//
|
||||
//
|
||||
/**
|
||||
* Attempt to submit (submission might be deferred)
|
||||
* Attempt to submit (submission might be deferred)
|
||||
* (called by DoSubmitOrReset)
|
||||
*
|
||||
* @param aPresContext the presentation context
|
||||
@ -380,7 +482,7 @@ protected:
|
||||
* @param aFormSubmission the submission object
|
||||
* @param aEvent the DOM event that was passed to us for the submit
|
||||
*/
|
||||
nsresult BuildSubmission(nsFormSubmission** aFormSubmission,
|
||||
nsresult BuildSubmission(nsFormSubmission** aFormSubmission,
|
||||
nsEvent* aEvent);
|
||||
/**
|
||||
* Perform the submission (called by DoSubmit and FlushPendingSubmission)
|
||||
@ -430,6 +532,16 @@ protected:
|
||||
// Insert a element into the past names map.
|
||||
void AddToPastNamesMap(const nsAString& aName, nsISupports* aChild);
|
||||
|
||||
nsresult
|
||||
AddElementToTableInternal(
|
||||
nsInterfaceHashtable<nsStringHashKey,nsISupports>& aTable,
|
||||
nsIContent* aChild, const nsAString& aName);
|
||||
|
||||
nsresult
|
||||
RemoveElementFromTableInternal(
|
||||
nsInterfaceHashtable<nsStringHashKey,nsISupports>& aTable,
|
||||
nsIContent* aChild, const nsAString& aName);
|
||||
|
||||
public:
|
||||
/**
|
||||
* Flush a possible pending submission. If there was a scripted submission
|
||||
|
@ -58,30 +58,18 @@ function reflectString(aParameters)
|
||||
element.removeAttribute(contentAttr);
|
||||
|
||||
element[idlAttr] = null;
|
||||
// TODO: remove this ugly hack when null stringification will work as expected.
|
||||
var todoAttrs = {
|
||||
form: [ "acceptCharset", "name", "target" ],
|
||||
};
|
||||
if (!(element.localName in todoAttrs) || todoAttrs[element.localName].indexOf(idlAttr) == -1) {
|
||||
if (treatNullAs == "EmptyString") {
|
||||
is(element.getAttribute(contentAttr), "",
|
||||
"null should have been stringified to '' for '" + contentAttr + "'");
|
||||
is(element[idlAttr], "",
|
||||
"null should have been stringified to '' for '" + idlAttr + "'");
|
||||
} else {
|
||||
is(element.getAttribute(contentAttr), "null",
|
||||
"null should have been stringified to 'null' for '" + contentAttr + "'");
|
||||
is(element[idlAttr], "null",
|
||||
"null should have been stringified to 'null' for '" + contentAttr + "'");
|
||||
}
|
||||
element.removeAttribute(contentAttr);
|
||||
if (treatNullAs == "EmptyString") {
|
||||
is(element.getAttribute(contentAttr), "",
|
||||
"null should have been stringified to '' for '" + contentAttr + "'");
|
||||
is(element[idlAttr], "",
|
||||
"null should have been stringified to '' for '" + idlAttr + "'");
|
||||
} else {
|
||||
todo_is(element.getAttribute(contentAttr), "null",
|
||||
is(element.getAttribute(contentAttr), "null",
|
||||
"null should have been stringified to 'null' for '" + contentAttr + "'");
|
||||
todo_is(element[idlAttr], "null",
|
||||
is(element[idlAttr], "null",
|
||||
"null should have been stringified to 'null' for '" + contentAttr + "'");
|
||||
element.removeAttribute(contentAttr);
|
||||
}
|
||||
element.removeAttribute(contentAttr);
|
||||
|
||||
// Tests various strings.
|
||||
var stringsToTest = [
|
||||
|
@ -52,9 +52,9 @@ is(form.foo0, input0, "Form.foo0 is still here");
|
||||
|
||||
input0.setAttribute("form", "");
|
||||
ok(!("foo0" in form.elements), "foo0 is not in form.elements");
|
||||
todo_is(form.foo0, undefined, "Form.foo0 should not still be here");
|
||||
todo_is(form.tmp0, undefined, "Form.tmp0 should not still be here");
|
||||
todo_is(form.tmp1, undefined, "Form.tmp1 should not still be here");
|
||||
is(form.foo0, undefined, "Form.foo0 should not still be here");
|
||||
is(form.tmp0, undefined, "Form.tmp0 should not still be here");
|
||||
is(form.tmp1, undefined, "Form.tmp1 should not still be here");
|
||||
|
||||
var input1 = document.getElementById("input1");
|
||||
ok(input1, "input1 exists");
|
||||
@ -73,17 +73,18 @@ ok(input2, "input2 exists");
|
||||
is(form.foo2, input2, "Form.foo2 should exist");
|
||||
input2.parentNode.removeChild(input2);
|
||||
ok(!("foo2" in form.elements), "foo2 is not in form.elements");
|
||||
todo_is(form.foo2, undefined, "Form.foo2 should not longer be there");
|
||||
is(form.foo2, undefined, "Form.foo2 should not longer be there");
|
||||
|
||||
var img0 = document.getElementById("img0");
|
||||
ok(img0, "img0 exists");
|
||||
is(form.bar0, img0, "Form.bar0 should exist");
|
||||
|
||||
img0.setAttribute("name", "old_bar0");
|
||||
is(form.old_bar0, img0, "Form.bar0 is still here");
|
||||
is(form.bar0, img0, "Form.bar0 is still here");
|
||||
|
||||
img0.parentNode.removeChild(img0);
|
||||
todo_is(form.bar0, undefined, "Form.bar0 should not be here");
|
||||
is(form.bar0, undefined, "Form.bar0 should not be here");
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
@ -428,6 +428,72 @@ private:
|
||||
const nsAString* mStr;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
class NonNull
|
||||
{
|
||||
public:
|
||||
NonNull()
|
||||
#ifdef DEBUG
|
||||
: inited(false)
|
||||
#endif
|
||||
{}
|
||||
|
||||
operator T&() {
|
||||
MOZ_ASSERT(inited);
|
||||
MOZ_ASSERT(ptr, "NonNull<T> was set to null");
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
operator const T&() const {
|
||||
MOZ_ASSERT(inited);
|
||||
MOZ_ASSERT(ptr, "NonNull<T> was set to null");
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
void operator=(T* t) {
|
||||
ptr = t;
|
||||
MOZ_ASSERT(ptr);
|
||||
#ifdef DEBUG
|
||||
inited = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
void operator=(U* t) {
|
||||
ptr = t->ToAStringPtr();
|
||||
MOZ_ASSERT(ptr);
|
||||
#ifdef DEBUG
|
||||
inited = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
T** Slot() {
|
||||
#ifdef DEBUG
|
||||
inited = true;
|
||||
#endif
|
||||
return &ptr;
|
||||
}
|
||||
|
||||
T* Ptr() {
|
||||
MOZ_ASSERT(inited);
|
||||
MOZ_ASSERT(ptr, "NonNull<T> was set to null");
|
||||
return ptr;
|
||||
}
|
||||
|
||||
// Make us work with smart-ptr helpers that expect a get()
|
||||
T* get() const {
|
||||
MOZ_ASSERT(inited);
|
||||
MOZ_ASSERT(ptr);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
protected:
|
||||
T* ptr;
|
||||
#ifdef DEBUG
|
||||
bool inited;
|
||||
#endif
|
||||
};
|
||||
|
||||
// Class for representing sequences in arguments. We use a non-auto array
|
||||
// because that allows us to use sequences of sequences and the like. This
|
||||
// needs to be fallible because web content controls the length of the array,
|
||||
|
@ -1350,65 +1350,6 @@ HasPropertyOnPrototype(JSContext* cx, JS::Handle<JSObject*> proxy,
|
||||
DOMProxyHandler* handler,
|
||||
JS::Handle<jsid> id);
|
||||
|
||||
template<class T>
|
||||
class NonNull
|
||||
{
|
||||
public:
|
||||
NonNull()
|
||||
#ifdef DEBUG
|
||||
: inited(false)
|
||||
#endif
|
||||
{}
|
||||
|
||||
operator T&() {
|
||||
MOZ_ASSERT(inited);
|
||||
MOZ_ASSERT(ptr, "NonNull<T> was set to null");
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
operator const T&() const {
|
||||
MOZ_ASSERT(inited);
|
||||
MOZ_ASSERT(ptr, "NonNull<T> was set to null");
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
void operator=(T* t) {
|
||||
ptr = t;
|
||||
MOZ_ASSERT(ptr);
|
||||
#ifdef DEBUG
|
||||
inited = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
void operator=(U* t) {
|
||||
ptr = t->ToAStringPtr();
|
||||
MOZ_ASSERT(ptr);
|
||||
#ifdef DEBUG
|
||||
inited = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
T* Ptr() {
|
||||
MOZ_ASSERT(inited);
|
||||
MOZ_ASSERT(ptr, "NonNull<T> was set to null");
|
||||
return ptr;
|
||||
}
|
||||
|
||||
// Make us work with smart-ptr helpers that expect a get()
|
||||
T* get() const {
|
||||
MOZ_ASSERT(inited);
|
||||
MOZ_ASSERT(ptr);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
protected:
|
||||
T* ptr;
|
||||
#ifdef DEBUG
|
||||
bool inited;
|
||||
#endif
|
||||
};
|
||||
|
||||
template<class T>
|
||||
class OwningNonNull
|
||||
{
|
||||
|
@ -1620,7 +1620,6 @@ addExternalIface('File')
|
||||
addExternalIface('FileCallback', nativeType='nsIFileCallback',
|
||||
headerFile='nsIDOMHTMLCanvasElement.h')
|
||||
addExternalIface('HitRegionOptions', nativeType='nsISupports')
|
||||
addExternalIface('HTMLFormElement', nativeType='mozilla::dom::HTMLFormElement')
|
||||
addExternalIface('IDBOpenDBRequest', nativeType='nsIIDBOpenDBRequest')
|
||||
addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver')
|
||||
addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True)
|
||||
|
@ -7,10 +7,8 @@
|
||||
* http://xhr.spec.whatwg.org
|
||||
*/
|
||||
|
||||
interface HTMLFormElement;
|
||||
|
||||
[Constructor(optional HTMLFormElement form)]
|
||||
interface FormData {
|
||||
void append(DOMString name, Blob value, optional DOMString filename);
|
||||
void append(DOMString name, DOMString value);
|
||||
};
|
||||
};
|
||||
|
48
dom/webidl/HTMLFormElement.webidl
Normal file
48
dom/webidl/HTMLFormElement.webidl
Normal file
@ -0,0 +1,48 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* http://www.whatwg.org/specs/web-apps/current-work/#htmlformelement
|
||||
*
|
||||
* © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
|
||||
* Opera Software ASA. You are granted a license to use, reproduce
|
||||
* and create derivative works of this document.
|
||||
*/
|
||||
|
||||
[OverrideBuiltins]
|
||||
interface HTMLFormElement : HTMLElement {
|
||||
[Pure, SetterThrows]
|
||||
attribute DOMString acceptCharset;
|
||||
[Pure, SetterThrows]
|
||||
attribute DOMString action;
|
||||
[Pure, SetterThrows]
|
||||
attribute DOMString autocomplete;
|
||||
[Pure, SetterThrows]
|
||||
attribute DOMString enctype;
|
||||
[Pure, SetterThrows]
|
||||
attribute DOMString encoding;
|
||||
[Pure, SetterThrows]
|
||||
attribute DOMString method;
|
||||
[Pure, SetterThrows]
|
||||
attribute DOMString name;
|
||||
[Pure, SetterThrows]
|
||||
attribute boolean noValidate;
|
||||
[Pure, SetterThrows]
|
||||
attribute DOMString target;
|
||||
|
||||
[Constant]
|
||||
readonly attribute HTMLCollection elements;
|
||||
[Pure]
|
||||
readonly attribute long length;
|
||||
|
||||
getter Element (unsigned long index);
|
||||
// TODO this should be: getter (RadioNodeList or HTMLInputElement or HTMLImageElement) (DOMString name);
|
||||
getter nsISupports (DOMString name);
|
||||
|
||||
[Throws]
|
||||
void submit();
|
||||
void reset();
|
||||
boolean checkValidity();
|
||||
};
|
@ -109,6 +109,7 @@ webidl_files = \
|
||||
HTMLEmbedElement.webidl \
|
||||
HTMLFieldSetElement.webidl \
|
||||
HTMLFontElement.webidl \
|
||||
HTMLFormElement.webidl \
|
||||
HTMLFrameElement.webidl \
|
||||
HTMLFrameSetElement.webidl \
|
||||
HTMLHeadElement.webidl \
|
||||
|
@ -60,14 +60,6 @@ members = [
|
||||
|
||||
'nsIDOMTouchList.*',
|
||||
|
||||
# dom/interfaces/html
|
||||
'nsIDOMHTMLFormElement.elements',
|
||||
'nsIDOMHTMLFormElement.name',
|
||||
'nsIDOMHTMLFormElement.submit',
|
||||
'nsIDOMHTMLFormElement.length',
|
||||
'nsIDOMHTMLFormElement.target',
|
||||
'nsIDOMHTMLFormElement.action',
|
||||
|
||||
# dom/interfaces/storage
|
||||
'nsIDOMToString.toString',
|
||||
'nsIDOMStorage.setItem',
|
||||
|
Loading…
x
Reference in New Issue
Block a user