mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Implemented HTMLInputElement placeholder attribute
+ modified HTMLInputElement.webidl to include placeholder + modified placeholder test expectations
This commit is contained in:
parent
db104b738e
commit
29387f6c4c
5 changed files with 25 additions and 142 deletions
|
@ -65,6 +65,7 @@ pub struct HTMLInputElement {
|
|||
input_type: Cell<InputType>,
|
||||
checked: Cell<bool>,
|
||||
checked_changed: Cell<bool>,
|
||||
placeholder: DOMRefCell<DOMString>,
|
||||
indeterminate: Cell<bool>,
|
||||
value_changed: Cell<bool>,
|
||||
size: Cell<u32>,
|
||||
|
@ -112,6 +113,7 @@ impl HTMLInputElement {
|
|||
htmlelement: HTMLElement::new_inherited(HTMLElementTypeId::HTMLInputElement, localName, prefix, document),
|
||||
input_type: Cell::new(InputType::InputText),
|
||||
checked: Cell::new(false),
|
||||
placeholder: DOMRefCell::new("".to_owned()),
|
||||
indeterminate: Cell::new(false),
|
||||
checked_changed: Cell::new(false),
|
||||
value_changed: Cell::new(false),
|
||||
|
@ -150,7 +152,12 @@ impl LayoutHTMLInputElementHelpers for LayoutJS<HTMLInputElement> {
|
|||
unsafe fn get_value_for_layout(self) -> String {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_raw_textinput_value(input: LayoutJS<HTMLInputElement>) -> String {
|
||||
(*input.unsafe_get()).textinput.borrow_for_layout().get_content()
|
||||
let textinput = (*input.unsafe_get()).textinput.borrow_for_layout().get_content();
|
||||
if !textinput.is_empty() {
|
||||
textinput
|
||||
} else {
|
||||
(*input.unsafe_get()).placeholder.borrow_for_layout().to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
|
@ -274,6 +281,12 @@ impl<'a> HTMLInputElementMethods for JSRef<'a, HTMLInputElement> {
|
|||
// https://html.spec.whatwg.org/multipage/forms.html#attr-fe-name
|
||||
make_setter!(SetName, "name");
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/forms.html#attr-input-placeholder
|
||||
make_getter!(Placeholder);
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/forms.html#attr-input-placeholder
|
||||
make_setter!(SetPlaceholder, "placeholder");
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/forms.html#dom-input-formaction
|
||||
make_url_or_base_getter!(FormAction);
|
||||
|
||||
|
@ -490,6 +503,13 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
|
|||
self.radio_group_updated(Some(value.as_slice()));
|
||||
}
|
||||
}
|
||||
_ if attr.local_name() == &Atom::from_slice("placeholder") => {
|
||||
let value = attr.value();
|
||||
let stripped = value.as_slice().chars()
|
||||
.filter(|&c| c != '\n' && c != '\r')
|
||||
.collect::<String>();
|
||||
*self.placeholder.borrow_mut() = stripped;
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
|
@ -534,6 +554,9 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
|
|||
self.radio_group_updated(None);
|
||||
}
|
||||
}
|
||||
_ if attr.local_name() == &Atom::from_slice("placeholder") => {
|
||||
self.placeholder.borrow_mut().clear();
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ interface HTMLInputElement : HTMLElement {
|
|||
// attribute boolean multiple;
|
||||
attribute DOMString name;
|
||||
// attribute DOMString pattern;
|
||||
// attribute DOMString placeholder;
|
||||
attribute DOMString placeholder;
|
||||
attribute boolean readOnly;
|
||||
// attribute boolean required;
|
||||
attribute unsigned long size;
|
||||
|
|
|
@ -5607,9 +5607,6 @@
|
|||
[HTMLInputElement interface: attribute pattern]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLInputElement interface: attribute placeholder]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLInputElement interface: attribute required]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -5739,9 +5736,6 @@
|
|||
[HTMLInputElement interface: document.createElement("input") must inherit property "pattern" with the proper type (25)]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLInputElement interface: document.createElement("input") must inherit property "placeholder" with the proper type (26)]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLInputElement interface: document.createElement("input") must inherit property "required" with the proper type (28)]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -5658,135 +5658,6 @@
|
|||
[input.pattern: IDL set to object "test-valueOf" followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: typeof IDL attribute]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: IDL get with DOM attribute unset]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: setAttribute() to "" followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: setAttribute() to " \\0\\x01\\x02\\x03\\x04\\x05\\x06\\x07 \\b\\t\\n\\v\\f\\r\\x0e\\x0f \\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17 \\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f foo " followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: setAttribute() to undefined followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: setAttribute() to 7 followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: setAttribute() to 1.5 followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: setAttribute() to true followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: setAttribute() to false followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: setAttribute() to object "[object Object\]" followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: setAttribute() to NaN followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: setAttribute() to Infinity followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: setAttribute() to -Infinity followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: setAttribute() to "\\0" followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: setAttribute() to null followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: setAttribute() to object "test-toString" followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: setAttribute() to object "test-valueOf" followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: IDL set to "" followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: IDL set to " \\0\\x01\\x02\\x03\\x04\\x05\\x06\\x07 \\b\\t\\n\\v\\f\\r\\x0e\\x0f \\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17 \\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f foo " followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: IDL set to undefined followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: IDL set to undefined followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: IDL set to 7 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: IDL set to 7 followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: IDL set to 1.5 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: IDL set to 1.5 followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: IDL set to true followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: IDL set to true followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: IDL set to false followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: IDL set to false followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: IDL set to object "[object Object\]" followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: IDL set to object "[object Object\]" followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: IDL set to NaN followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: IDL set to NaN followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: IDL set to Infinity followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: IDL set to Infinity followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: IDL set to -Infinity followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: IDL set to -Infinity followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: IDL set to "\\0" followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: IDL set to null followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: IDL set to null followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: IDL set to object "test-toString" followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: IDL set to object "test-toString" followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[input.placeholder: IDL set to object "test-valueOf" followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[input.required: typeof IDL attribute]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
[search_input.html]
|
||||
type: testharness
|
||||
[placeholder attribute support on input element]
|
||||
expected: FAIL
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue