mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Let textarea wrap lines
This commit is contained in:
parent
8ded106186
commit
0a86543e6d
4 changed files with 16 additions and 13 deletions
|
@ -29,7 +29,6 @@ use gfx::display_list::{LayeredItem, LayerInfo, LineDisplayItem, OpaqueNode};
|
||||||
use gfx::display_list::{SolidColorDisplayItem, StackingContext, StackingContextType};
|
use gfx::display_list::{SolidColorDisplayItem, StackingContext, StackingContextType};
|
||||||
use gfx::display_list::{TextDisplayItem, TextOrientation, WebRenderImageInfo};
|
use gfx::display_list::{TextDisplayItem, TextOrientation, WebRenderImageInfo};
|
||||||
use gfx::paint_thread::THREAD_TINT_COLORS;
|
use gfx::paint_thread::THREAD_TINT_COLORS;
|
||||||
use gfx::text::glyph::ByteIndex;
|
|
||||||
use gfx_traits::{color, ScrollPolicy, StackingContextId};
|
use gfx_traits::{color, ScrollPolicy, StackingContextId};
|
||||||
use inline::{FIRST_FRAGMENT_OF_ELEMENT, InlineFlow, LAST_FRAGMENT_OF_ELEMENT};
|
use inline::{FIRST_FRAGMENT_OF_ELEMENT, InlineFlow, LAST_FRAGMENT_OF_ELEMENT};
|
||||||
use ipc_channel::ipc;
|
use ipc_channel::ipc;
|
||||||
|
@ -970,7 +969,8 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
Some(insertion_point_index) => insertion_point_index,
|
Some(insertion_point_index) => insertion_point_index,
|
||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
let range = Range::new(ByteIndex(0), insertion_point_index);
|
let range = Range::new(scanned_text_fragment_info.range.begin(),
|
||||||
|
insertion_point_index - scanned_text_fragment_info.range.begin());
|
||||||
let advance = scanned_text_fragment_info.run.advance_for_range(&range);
|
let advance = scanned_text_fragment_info.run.advance_for_range(&range);
|
||||||
|
|
||||||
let insertion_point_bounds;
|
let insertion_point_bounds;
|
||||||
|
|
|
@ -882,16 +882,23 @@ impl Fragment {
|
||||||
let size = LogicalSize::new(self.style.writing_mode,
|
let size = LogicalSize::new(self.style.writing_mode,
|
||||||
split.inline_size,
|
split.inline_size,
|
||||||
self.border_box.size.block);
|
self.border_box.size.block);
|
||||||
let flags = match self.specific {
|
// Preserve the insertion point if it is in this fragment's range or it is at line end.
|
||||||
SpecificFragmentInfo::ScannedText(ref info) => info.flags,
|
let (flags, insertion_point) = match self.specific {
|
||||||
_ => ScannedTextFlags::empty()
|
SpecificFragmentInfo::ScannedText(ref info) => {
|
||||||
|
match info.insertion_point {
|
||||||
|
Some(index) if split.range.contains(index) => (info.flags, info.insertion_point),
|
||||||
|
Some(index) if index == ByteIndex(text_run.text.chars().count() as isize - 1) &&
|
||||||
|
index == split.range.end() => (info.flags, info.insertion_point),
|
||||||
|
_ => (info.flags, None)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_ => (ScannedTextFlags::empty(), None)
|
||||||
};
|
};
|
||||||
// FIXME(pcwalton): This should modify the insertion point as necessary.
|
|
||||||
let info = box ScannedTextFragmentInfo::new(
|
let info = box ScannedTextFragmentInfo::new(
|
||||||
text_run,
|
text_run,
|
||||||
split.range,
|
split.range,
|
||||||
size,
|
size,
|
||||||
None,
|
insertion_point,
|
||||||
flags);
|
flags);
|
||||||
self.transform(size, SpecificFragmentInfo::ScannedText(info))
|
self.transform(size, SpecificFragmentInfo::ScannedText(info))
|
||||||
}
|
}
|
||||||
|
|
|
@ -2130,10 +2130,6 @@ pub fn modify_style_for_input_text(style: &mut Arc<ServoComputedValues>) {
|
||||||
margin_style.margin_right = computed::LengthOrPercentageOrAuto::Length(Au(0));
|
margin_style.margin_right = computed::LengthOrPercentageOrAuto::Length(Au(0));
|
||||||
margin_style.margin_bottom = computed::LengthOrPercentageOrAuto::Length(Au(0));
|
margin_style.margin_bottom = computed::LengthOrPercentageOrAuto::Length(Au(0));
|
||||||
margin_style.margin_left = computed::LengthOrPercentageOrAuto::Length(Au(0));
|
margin_style.margin_left = computed::LengthOrPercentageOrAuto::Length(Au(0));
|
||||||
|
|
||||||
// whitespace inside text input should not be collapsed
|
|
||||||
let inherited_text = Arc::make_mut(&mut style.inheritedtext);
|
|
||||||
inherited_text.white_space = longhands::white_space::computed_value::T::pre;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adjusts the `clip` property so that an inline absolute hypothetical fragment doesn't clip its
|
/// Adjusts the `clip` property so that an inline absolute hypothetical fragment doesn't clip its
|
||||||
|
|
|
@ -9,7 +9,7 @@ input {
|
||||||
color: black;
|
color: black;
|
||||||
font-family: sans-serif;
|
font-family: sans-serif;
|
||||||
font-size: 0.8333em;
|
font-size: 0.8333em;
|
||||||
white-space: nowrap;
|
white-space: pre;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
line-height: 1.8;
|
line-height: 1.8;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ textarea {
|
||||||
color: black;
|
color: black;
|
||||||
font-family: sans-serif;
|
font-family: sans-serif;
|
||||||
font-size: 0.8333em;
|
font-size: 0.8333em;
|
||||||
white-space: pre;
|
white-space: pre-wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
input::selection,
|
input::selection,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue