aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/textinput.rs
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2014-12-16 15:03:49 -0700
committerbors-servo <metajack+bors@gmail.com>2014-12-16 15:03:49 -0700
commit5951056973fc0e08e70224214740a274ca8ef20f (patch)
treea8007d81bb3377bd6803f0b589ed1c69ad3463dd /components/script/textinput.rs
parentb6a593650bcc33e4188153d135e9a2781a488f96 (diff)
parente4963869d3820d47865cf5d67a8c13f547061f5e (diff)
downloadservo-5951056973fc0e08e70224214740a274ca8ef20f.tar.gz
servo-5951056973fc0e08e70224214740a274ca8ef20f.zip
auto merge of #4133 : mttr/servo/form_resetting, r=jdm
We can reset `<input type=text>` fields! I wish I could've done something with checkboxes, but unfortunately, that's it for now. In addition to that, this PR implements `HTMLInputAttribute.defaultValue`, updates wpt-test to expect passing tests as a result of that implementation, and fixes an index error crash with text inputs. edit: also includes an html example where one may lazily watch form resets in action: ` tests/html/form_reset_handsfree.html`
Diffstat (limited to 'components/script/textinput.rs')
-rw-r--r--components/script/textinput.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/components/script/textinput.rs b/components/script/textinput.rs
index d39d22918c0..ed120aae943 100644
--- a/components/script/textinput.rs
+++ b/components/script/textinput.rs
@@ -295,6 +295,12 @@ impl TextInput {
vec!(content)
};
self.edit_point.line = min(self.edit_point.line, self.lines.len() - 1);
- self.edit_point.index = min(self.edit_point.index, self.current_line_length() - 1);
+
+ if self.current_line_length() == 0 {
+ self.edit_point.index = 0;
+ }
+ else {
+ self.edit_point.index = min(self.edit_point.index, self.current_line_length() - 1);
+ }
}
}