aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-04-04 08:24:48 -0600
committerbors-servo <metajack+bors@gmail.com>2015-04-04 08:24:48 -0600
commit4ffeb81aa73fa87120eabb569fd14d7193813bdf (patch)
tree1bc52b544701f337d69ccb1c6f9e3c214592eca3
parentdb104b738e1ff6b69c3983be6f50f8d7a048b182 (diff)
parent29387f6c4c10fa653abd92b4b03bf2a4d53e9bf2 (diff)
downloadservo-4ffeb81aa73fa87120eabb569fd14d7193813bdf.tar.gz
servo-4ffeb81aa73fa87120eabb569fd14d7193813bdf.zip
auto merge of #5385 : genkku/servo/placeholder, r=jdm
I'm unsure whether I should wrap 'placeholder' in Cell, or DomRefCell, or leave as it is now. Also, the spec says that the placeholder should be presented with line breaks stripped off, should it be done in this stage?
-rw-r--r--components/script/dom/htmlinputelement.rs25
-rw-r--r--components/script/dom/webidls/HTMLInputElement.webidl2
-rw-r--r--tests/wpt/metadata/html/dom/interfaces.html.ini6
-rw-r--r--tests/wpt/metadata/html/dom/reflection-forms.html.ini129
-rw-r--r--tests/wpt/metadata/html/semantics/forms/the-input-element/search_input.html.ini5
5 files changed, 25 insertions, 142 deletions
diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs
index 46e841e79f8..e4ebabb9e13 100644
--- a/components/script/dom/htmlinputelement.rs
+++ b/components/script/dom/htmlinputelement.rs
@@ -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();
+ }
_ => ()
}
}
diff --git a/components/script/dom/webidls/HTMLInputElement.webidl b/components/script/dom/webidls/HTMLInputElement.webidl
index 47180432736..f08f2334fbb 100644
--- a/components/script/dom/webidls/HTMLInputElement.webidl
+++ b/components/script/dom/webidls/HTMLInputElement.webidl
@@ -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;
diff --git a/tests/wpt/metadata/html/dom/interfaces.html.ini b/tests/wpt/metadata/html/dom/interfaces.html.ini
index 474c32309fd..3954b237f63 100644
--- a/tests/wpt/metadata/html/dom/interfaces.html.ini
+++ b/tests/wpt/metadata/html/dom/interfaces.html.ini
@@ -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
diff --git a/tests/wpt/metadata/html/dom/reflection-forms.html.ini b/tests/wpt/metadata/html/dom/reflection-forms.html.ini
index 6215c2315c6..d336d9b06ec 100644
--- a/tests/wpt/metadata/html/dom/reflection-forms.html.ini
+++ b/tests/wpt/metadata/html/dom/reflection-forms.html.ini
@@ -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
diff --git a/tests/wpt/metadata/html/semantics/forms/the-input-element/search_input.html.ini b/tests/wpt/metadata/html/semantics/forms/the-input-element/search_input.html.ini
deleted file mode 100644
index 49b9be48239..00000000000
--- a/tests/wpt/metadata/html/semantics/forms/the-input-element/search_input.html.ini
+++ /dev/null
@@ -1,5 +0,0 @@
-[search_input.html]
- type: testharness
- [placeholder attribute support on input element]
- expected: FAIL
-