aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/text.rs
diff options
context:
space:
mode:
authorMatt Brubeck <mbrubeck@limpet.net>2016-04-01 20:18:28 -0700
committerMatt Brubeck <mbrubeck@limpet.net>2016-04-07 16:09:35 -0700
commit32aad0838e63728f7dbe485d5b8858d4991a1dde (patch)
treed586b1a929eade8faa8addc4fc4aca1cd806e1ec /components/layout/text.rs
parent831243af7c09fa0e878b3b29d84dae9224cfd924 (diff)
downloadservo-32aad0838e63728f7dbe485d5b8858d4991a1dde.tar.gz
servo-32aad0838e63728f7dbe485d5b8858d4991a1dde.zip
Draw insertion point even for empty input fields
This allows text layout to generate an empty text fragment if the fragment contains the insertion point for a text input box.
Diffstat (limited to 'components/layout/text.rs')
-rw-r--r--components/layout/text.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/components/layout/text.rs b/components/layout/text.rs
index 731891e68b3..99fd9ca8a4f 100644
--- a/components/layout/text.rs
+++ b/components/layout/text.rs
@@ -239,6 +239,7 @@ impl TextRunScanner {
mapping.flush(&mut mappings,
&mut run_info,
&**text,
+ insertion_point,
compression,
text_transform,
&mut last_whitespace,
@@ -268,6 +269,7 @@ impl TextRunScanner {
mapping.flush(&mut mappings,
&mut run_info,
&**text,
+ insertion_point,
compression,
text_transform,
&mut last_whitespace,
@@ -336,6 +338,7 @@ impl TextRunScanner {
let scanned_run = runs[mapping.text_run_index].clone();
let requires_line_break_afterward_if_wrapping_on_newlines =
+ !mapping.byte_range.is_empty() &&
scanned_run.run.text.char_at_reverse(mapping.byte_range.end()) == '\n';
if requires_line_break_afterward_if_wrapping_on_newlines {
mapping.char_range.extend_by(CharIndex(-1));
@@ -575,12 +578,13 @@ impl RunMapping {
mappings: &mut Vec<RunMapping>,
run_info: &mut RunInfo,
text: &str,
+ insertion_point: Option<CharIndex>,
compression: CompressionMode,
text_transform: text_transform::T,
last_whitespace: &mut bool,
start_position: &mut usize,
end_position: usize) {
- if *start_position == end_position {
+ if *start_position == end_position && insertion_point.is_none() {
return;
}
let old_byte_length = run_info.text.len();
@@ -601,9 +605,9 @@ impl RunMapping {
run_info.character_length = run_info.character_length + character_count;
*start_position = end_position;
- // Don't flush empty mappings.
- if character_count == 0 {
- return
+ // Don't flush mappings that contain no characters and no insertion_point.
+ if character_count == 0 && !self.contains_insertion_point(insertion_point) {
+ return;
}
let new_byte_length = run_info.text.len();