mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Add FormData constructor
This commit is contained in:
parent
94df5d1cba
commit
73e67568c1
3 changed files with 17 additions and 7 deletions
|
@ -945,8 +945,10 @@ for (uint32_t i = 0; i < length; ++i) {
|
||||||
|
|
||||||
# Set up some sensible defaults for these things insofar as we can.
|
# Set up some sensible defaults for these things insofar as we can.
|
||||||
holderType = None
|
holderType = None
|
||||||
if argIsPointer:
|
initialValue = None
|
||||||
|
if argIsPointer or isOptional:
|
||||||
declType = "Option<" + typePtr + ">"
|
declType = "Option<" + typePtr + ">"
|
||||||
|
initialValue = "None"
|
||||||
else:
|
else:
|
||||||
declType = typePtr
|
declType = typePtr
|
||||||
|
|
||||||
|
@ -995,7 +997,7 @@ for (uint32_t i = 0; i < length; ++i) {
|
||||||
declType = CGGeneric(declType)
|
declType = CGGeneric(declType)
|
||||||
if holderType is not None:
|
if holderType is not None:
|
||||||
holderType = CGGeneric(holderType)
|
holderType = CGGeneric(holderType)
|
||||||
return (templateBody, declType, holderType, isOptional, None)
|
return (templateBody, declType, holderType, isOptional, initialValue)
|
||||||
|
|
||||||
if type.isSpiderMonkeyInterface():
|
if type.isSpiderMonkeyInterface():
|
||||||
assert not isEnforceRange and not isClamp
|
assert not isEnforceRange and not isClamp
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* http://xhr.spec.whatwg.org
|
* http://xhr.spec.whatwg.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*[Constructor(optional HTMLFormElement form)]*/
|
[Constructor(optional HTMLFormElement form)]
|
||||||
interface FormData {
|
interface FormData {
|
||||||
void append(DOMString name, Blob value, optional DOMString filename);
|
void append(DOMString name, Blob value, optional DOMString filename);
|
||||||
void append(DOMString name, DOMString value);
|
void append(DOMString name, DOMString value);
|
||||||
|
|
|
@ -2,10 +2,11 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
use dom::bindings::utils::{Fallible, Reflectable, Reflector, reflect_dom_object};
|
||||||
use dom::bindings::utils::DOMString;
|
use dom::bindings::utils::DOMString;
|
||||||
use dom::bindings::codegen::FormDataBinding;
|
use dom::bindings::codegen::FormDataBinding;
|
||||||
use dom::blob::Blob;
|
use dom::blob::Blob;
|
||||||
|
use dom::node::{AbstractNode, ScriptView};
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
|
|
||||||
use std::hashmap::HashMap;
|
use std::hashmap::HashMap;
|
||||||
|
@ -19,19 +20,26 @@ pub struct FormData {
|
||||||
data: HashMap<~str, FormDatum>,
|
data: HashMap<~str, FormDatum>,
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
window: @mut Window,
|
window: @mut Window,
|
||||||
|
form: Option<AbstractNode<ScriptView>>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FormData {
|
impl FormData {
|
||||||
pub fn new_inherited(window: @mut Window) -> FormData {
|
pub fn new_inherited(form: Option<AbstractNode<ScriptView>>, window: @mut Window) -> FormData {
|
||||||
FormData {
|
FormData {
|
||||||
data: HashMap::new(),
|
data: HashMap::new(),
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
window: window,
|
window: window,
|
||||||
|
form: form
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(window: @mut Window) -> @mut FormData {
|
pub fn new(form: Option<AbstractNode<ScriptView>>, window: @mut Window) -> @mut FormData {
|
||||||
reflect_dom_object(@mut FormData::new_inherited(window), window, FormDataBinding::Wrap)
|
reflect_dom_object(@mut FormData::new_inherited(form, window), window, FormDataBinding::Wrap)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn Constructor(window: @mut Window,
|
||||||
|
form: Option<AbstractNode<ScriptView>>) -> Fallible<@mut FormData> {
|
||||||
|
Ok(FormData::new(form, window))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Append(&mut self, name: DOMString, value: @mut Blob, filename: Option<DOMString>) {
|
pub fn Append(&mut self, name: DOMString, value: @mut Blob, filename: Option<DOMString>) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue