diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2016-06-03 13:20:00 +0200 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2016-06-03 14:45:14 +0200 |
commit | ff899dc7033449aa01ee61b5e6c28a8760860325 (patch) | |
tree | 29ae636e8cc6bb229282a0f6298c04109039ead1 /components/script/textinput.rs | |
parent | 6c5f5d35f56f75e5a235836c042a55b67da553d6 (diff) | |
download | servo-ff899dc7033449aa01ee61b5e6c28a8760860325.tar.gz servo-ff899dc7033449aa01ee61b5e6c28a8760860325.zip |
Implement :placeholder-shown (fixes #10561)
Diffstat (limited to 'components/script/textinput.rs')
-rw-r--r-- | components/script/textinput.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/components/script/textinput.rs b/components/script/textinput.rs index 5666fa617b4..c724c2691c4 100644 --- a/components/script/textinput.rs +++ b/components/script/textinput.rs @@ -549,6 +549,11 @@ impl<T: ClipboardProvider> TextInput<T> { } } + /// Whether the content is empty. + pub fn is_empty(&self) -> bool { + self.lines.len() <= 1 && self.lines.get(0).map_or(true, |line| line.is_empty()) + } + /// The length of the content in bytes. pub fn len(&self) -> usize { self.lines.iter().fold(0, |m, l| { |