Commit graph

132 commits

Author SHA1 Message Date
Matt Brubeck
1695d14a9e Don't strip out all empty fragments
Empty fragments may need to be layed out to draw borders, padding/background,
and insertion points.  (Fragments that consist of discardable whitespace and
control characters, on the other hand, can still be discarded.)

This ends up preserving some useless empty fragments.  It's possible we could
avoid this by storing some sort of flag on "important" empty fragments, so we
can discard the rest.
2016-04-16 13:13:07 -07:00
Matt Brubeck
fbef2724bf Fix up inline context flags during text fragment scanning
This fixes two problems that could cause scanned text fragments to end up with
incorrect LAST_FRAGMENT_OF_ELEMENT or FIRST_FRAGMENT_OF_ELEMENT flags:

1. If a single unscanned fragment was split into multiple scanned fragments,
   then all of them would inherit its flags.  We need to clear these flags,
   except for the first and last scanned fragment.

2. When an unscanned fragment generated zero scanned fragments, we correctly
   called `meld_with_next_inline_fragment` to transfer LAST_FRAGMENT flags to
   the preceding fragment, but we didn't do anything to transfer
   FIRST_FRAGMENT flags to the following fragment.  We can fix this by calling
   `meld_with_prev_inline_fragment` on the following fragment.
2016-04-16 10:30:03 -07:00
Per Lundberg
96835c6d6f Renamed style structs.
The idea is to rename all style structs from Foo to ServoFoo, as described out in #10185.
2016-04-08 21:47:36 +03:00
Matt Brubeck
32aad0838e 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.
2016-04-07 16:09:35 -07:00
Matt Brubeck
831243af7c Fix insertion point layout for text runs with multiple fragments
Before this fix, if a TextRun containing an insertion point was split into
multiple ScannedText fragments, text layout would draw an insertion point
inside of each of the fragments.  This patch records the insertion point
position at most once per TextRun, and copies it only into the appropriate
ScannedText fragment.
2016-04-07 16:00:49 -07:00
Matt Brubeck
bcaa62e1bd Slight refactoring of RunMapping flush method 2016-04-07 16:00:14 -07:00
Mauricio Collares
d8222dd63d Move CSS line-height property from InheritedBox to InheritedText 2016-04-05 00:28:18 -03:00
Emilio Cobos Álvarez
92f39ea5cf Implement ::selection pseudo-element 2016-03-30 14:28:11 +02:00
bors-servo
0ec96ac02a Auto merge of #10277 - perlun:rename-tcomputedvalues-to-computedvalues, r=SimonSapin
Renamed TComputedValues to ComputedValues

This is a followup to #10210, and a continuation of #10185.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10277)
<!-- Reviewable:end -->
2016-03-30 11:04:57 +05:30
bors-servo
44b2ba2547 Auto merge of #10255 - mbrubeck:box-unscanned, r=pcwalton
Reduce size of layout::fragment::Fragment struct

This reduces the size of the SpecificFragmentInfo enum from 48 to 24.

r? @pcwalton

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10255)
<!-- Reviewable:end -->
2016-03-30 07:49:25 +05:30
Per Lundberg
4cb4cc93e4 Renamed TComputedValues to ComputedValues
This is a followup to #10210, and a continuation of #10185.
2016-03-29 23:30:13 +03:00
Matt Brubeck
31261f045e Put UnscannedTextFragmentInfo in a Box
This reduces the size of the SpecificFragmentInfo enum from 48 to 24.
2016-03-29 08:40:05 -07:00
Per Lundberg
c2ad084713 ComputedValues is now ServoComputedValues
This is the first part of #10185. More to follow. I have built this locally with both servo and geckolib without errors; let's see if it succeeds on all platforms as well.
2016-03-27 10:55:43 +03:00
bors-servo
bed91b3334 Auto merge of #10176 - mbrubeck:selection-range, r=pcwalton
Highlight selected text in input fields

Fixes #9993.  This does not yet allow stylesheets to set the selection colors; instead it uses a hard-coded orange background and white foreground.

r? @pcwalton

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10176)
<!-- Reviewable:end -->
2016-03-26 08:16:20 +05:30
Matt Brubeck
08caf7412f Convert ScannedTextFragment fields into bitflags 2016-03-24 18:33:27 -07:00
Matt Brubeck
6171000875 Highlight selected text in input fields
Fixes #9993.  This does not yet allow stylesheets to set the selection colors;
instead it uses a hard-coded orange background and white foreground.
2016-03-24 18:33:26 -07:00
Bobby Holley
c2daea2c9c Parameterize the rest of the style system on TNode. 2016-03-24 11:50:57 -07:00
Jonathan Schuster
205336bf2e Move util::range into its own crate 2016-02-25 21:06:10 -05:00
Anthony Ramine
db8d502f41 Move util::logical_geometry to style 2016-02-18 10:17:13 +01:00
Corey Farwell
f62e83c848 Prefer is_empty over len when option is available. 2016-01-29 22:49:47 -05:00
Olaf Buddenhagen
422639fb60 layout/text.rs: Add assertion for empty fontgroup 2016-01-14 08:35:32 +01:00
Johannes Linke
6b215f38ee Fix a bunch of clippy lints 2016-01-02 23:27:15 +01:00
Keith Yeung
7de7cb4786 Extend whitespace::T with additional helper methods 2015-11-20 11:05:36 -08:00
Florian Merz
80e8a674e2 display input caret for textarea. fixes #7758 2015-10-21 22:38:23 +02:00
Eli Friedman
3a451ff845 Add support for pre-wrap and pre-line values for white-space.
This is mostly straightforward.  I had to modify a couple of places
which were accidentally discarding whitespace.

Fixes #1513.
2015-10-20 10:44:51 -07:00
Glenn Watson
339a3f869b Split Au type into separate crate, with minimal dependencies. 2015-10-01 07:16:11 +10:00
Matt Brubeck
6304186f4f Fix text-transform:capitalize across text runs 2015-09-29 14:34:50 -07:00
Matt Brubeck
371e6897e1 Break text runs by unicode script 2015-09-29 14:34:49 -07:00
Ravi Shankar
889eec364b sorted the extern crate, mod & use declarations 2015-09-24 02:12:45 +05:30
Brandon Fairchild
de3547e401 Fix reported test-tidy errors for unmerged import blocks
This merges import blocks that were reported by tidy as unmerged.
2015-09-19 12:50:14 -04:00
Patrick Walton
357419dc8d layout: Query and maintain the position of the insertion point
throughout layout for input elements.
2015-09-17 13:31:12 +02:00
Mathieu Rheaume
7320433cca Remove 'get_*' on getters as per RFC 0344 on various components 2015-09-12 20:14:01 -04:00
Patrick Walton
ee8741b7a8 layout: Fix several bugs relating to inline borders, padding, and
margins.

* The code that attempted to strip out borders that span multiple
  fragments in the same element could go wrong if fragments were
  stripped out due to text clumping or whitespace stripping. This patch
  rewrites that code to maintain flags in the inline fragment context
  specifying whether the node is the beginning or end of the element.
  Not only is this easier to maintain, it's closer in spirit to what roc
  originally suggested two years ago: it's isomorphic to "begin element,
  end element" markers for inline layout.

* Padding and margins for spans containing inline-blocks are now
  properly handled via a division of labor between the `InlineBlock`
  fragment and the `BlockFlow` that represents the inline-block.

* Unscanned text fragments may not be joined together into a text run if
  borders, padding, or margins separate them.

Because Servo now matches the rendering of Gecko and WebKit on the
`input_button_margins_a` reftest, I had to modify it to add some
vertical alignment.

The combined effect of all of these fixes places "Advertising" on the
right place on google.com.
2015-09-03 10:24:59 -07:00
Simon Sapin
40b4348824 Upgrade to rustc 1.4.0-dev (cb9323ec0 2015-09-01) 2015-09-02 09:22:17 +02:00
Anthony Ramine
bb3d3db333 Correctly handle length-changing mappings in text-transform 2015-08-19 12:05:31 +02:00
Patrick Walton
ae378a8c3e layout: Rewrite whitespace stripping.
This patch makes Servo unconditionally strip whitespace before text run
scanning (assuming that the `white-space` property allows it). Whitespace
stripping during reflow is now only used for handling whitespace at the ends of
lines; reflow now never attempts to handle ignorable whitespace.

Many CSS tests pass now. There are some new failures, however.

The following reference tests now fail due to a pre-existing bug whereby
whitespace is used to calculate the position of inline hypothetical boxes for
elements with `display: inline; position: absolute`:

* `absolute-replaced-height-036.htm`
* `vertical-align-sub-001.htm`
* `vertical-align-super-001.htm`

The following reference tests fail due to a pre-existing bug whereby we don't
handle `font-size: 0` properly in inline reflow:

* `font-size-zero-1.htm`
* `font-size-zero-2.htm`

The following reference test fails due to the fact that it relied on our
incorrect insertion of whitespace to make room for the black background:

* `inline-formatting-context-007.htm`
2015-08-11 11:42:20 -07:00
Matt Brubeck
b5f9c06776 Rollup merge of #7015 - mbrubeck:arc-box, r=Ms2ger
Replace Arc<Box<TextRun>> with Arc<TextRun>

Removes an extraneous level of indirection.

r? @pcwalton

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7015)
<!-- Reviewable:end -->
2015-08-06 14:07:32 -07:00
Matt Brubeck
8a09f738d4 Replace Arc<Box<TextRun>> with Arc<TextRun> 2015-08-05 18:28:20 -07:00
Matt Brubeck
c4dde7297e Use Box<str> instead of Box<String> for UnscannedTextFragmentInfo
This removes an extraneous layer of indirection, without increasing the size
of the `SpecificFragmentInfo` enum (because `Box<str>` is a fat pointer, which
is the same size as the `FlowRef` trait object that is already stored in
`InlineAbsoluteHypotheticalFragmentInfo`)
2015-08-05 18:05:05 -07:00
David Zbarsky
e484d6b5e3 Implement getComputedStyle 2015-07-29 20:17:50 -04:00
Matt Brubeck
dfac8ce4a1 Basic support for bidirectional text 2015-07-23 20:05:55 -07:00
Matt Brubeck
83c73a5d91 Slice TextRuns by byte range instead of char range
Fixes #6431
2015-06-23 10:06:50 -07:00
Patrick Walton
fec43b49bb layout: Implement per-glyph font fallback.
This improves numerous pages, for example Wikipedia and Ars Technica.

Closes #177.
2015-05-22 17:16:24 -07:00
Simon Sapin
ef8edd4e87 Upgrade to rustc 551a74dddd84cf01440ee84148ebd18bc68bd7c8. 2015-05-05 10:07:34 -04:00
Patrick Walton
8741d9e8c4 layout: Use a flag to record whether we need to perform a line break if
wrapping on newlines rather than searching for a newline character.

Since the newline character might have been stripped out during
whitespace stripping, this was incorrect.

Fixes the "jumpiness" seen on the Google home page, Wikipedia, and many
other places.
2015-04-24 13:16:34 -07:00
Ms2ger
6a55ae06d7 Remove some as_slice calls. 2015-04-24 17:44:47 +02:00
Patrick Walton
6d61468160 layout: Simplify and improve the correctness of whitespace stripping in
text layout, and unify the inline layout paths for pre- and
normally-formatted text.

This fixes a lot of "jumpiness" and removes the `new_line_pos` stuff.

Closes #2260.
2015-04-08 14:29:23 -07:00
Ms2ger
6d7dead4ef Use isize for CharIndex. 2015-04-02 14:45:49 +02:00
Manish Goregaokar
3479d3fa7f Replace unsafe_blocks by unsafe_code. 2015-03-21 10:27:32 +01:00
Matt Brubeck
1ead92b474 Rename dlist to linked_list. 2015-03-18 14:44:34 -07:00