diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-07-26 08:31:49 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-26 08:31:49 -0500 |
commit | a3e8199c97fc0cb61f199d2bda218fe695f04b8c (patch) | |
tree | 454fc7796dc3bd0a6ec88ede6663ef5b4450956b /components | |
parent | b41bf4f1f30b8f4eec92909c8971bc02d5422b50 (diff) | |
parent | 0a86543e6decf02860a5a98c46e01940e79af6fa (diff) | |
download | servo-a3e8199c97fc0cb61f199d2bda218fe695f04b8c.tar.gz servo-a3e8199c97fc0cb61f199d2bda218fe695f04b8c.zip |
Auto merge of #12388 - kilobtye:textarea2, r=pcwalton
Let textarea wrap lines
<!-- Please describe your changes on the following line: -->
1. Change textarea's style from white-space: pre to white-space: pre-wrap.
2. Display insertion point when a line is wrapped.
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #10053 (github issue number if applicable).
<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12388)
<!-- Reviewable:end -->
Diffstat (limited to 'components')
-rw-r--r-- | components/layout/display_list_builder.rs | 4 | ||||
-rw-r--r-- | components/layout/fragment.rs | 17 | ||||
-rw-r--r-- | components/style/properties/properties.mako.rs | 4 |
3 files changed, 14 insertions, 11 deletions
diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index 5eb20156295..8d036dfc90e 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -29,7 +29,6 @@ use gfx::display_list::{LayeredItem, LayerInfo, LineDisplayItem, OpaqueNode}; use gfx::display_list::{SolidColorDisplayItem, StackingContext, StackingContextType}; use gfx::display_list::{TextDisplayItem, TextOrientation, WebRenderImageInfo}; use gfx::paint_thread::THREAD_TINT_COLORS; -use gfx::text::glyph::ByteIndex; use gfx_traits::{color, ScrollPolicy, StackingContextId}; use inline::{FIRST_FRAGMENT_OF_ELEMENT, InlineFlow, LAST_FRAGMENT_OF_ELEMENT}; use ipc_channel::ipc; @@ -970,7 +969,8 @@ impl FragmentDisplayListBuilding for Fragment { Some(insertion_point_index) => insertion_point_index, 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 insertion_point_bounds; diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index f235bd64331..48499d7e36e 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -882,16 +882,23 @@ impl Fragment { let size = LogicalSize::new(self.style.writing_mode, split.inline_size, self.border_box.size.block); - let flags = match self.specific { - SpecificFragmentInfo::ScannedText(ref info) => info.flags, - _ => ScannedTextFlags::empty() + // Preserve the insertion point if it is in this fragment's range or it is at line end. + let (flags, insertion_point) = match self.specific { + 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( text_run, split.range, size, - None, + insertion_point, flags); self.transform(size, SpecificFragmentInfo::ScannedText(info)) } diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index cb9ef5152df..83ad6b73d82 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -2146,10 +2146,6 @@ pub fn modify_style_for_input_text(style: &mut Arc<ComputedValues>) { margin_style.margin_right = computed::LengthOrPercentageOrAuto::Length(Au(0)); margin_style.margin_bottom = 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 |