Commit graph

176 commits

Author SHA1 Message Date
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
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
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
Michael Howell
9d9c5398a8 Get the fundamentals of the HTMLDetailsElement rendering stuff working.
Still need to implement the style invalidation.

Part of #9395
2016-03-19 16:02:11 -07:00
Bobby Holley
539f839958 Remove lifetimes from LayoutNode and friends. 2016-03-14 14:31:57 -07:00
Bobby Holley
7c4dcaa677 Inline ObjectElement::get_type_and_data into the consumers.
The usage here doesn't quite work without the lifetimes.
2016-03-14 14:31:57 -07:00
Simon Sapin
f766e94259 Remove unused fixed_descendants: AbsoluteDescendants
… in `construct.rs` for multicol and table wrappers.
2016-01-28 09:43:14 +01:00
Simon Sapin
5498b54347 Add Multicolumn support block fragmentation. 2016-01-28 09:43:14 +01:00
Simon Sapin
9abbd1b5d1 Sequentialize assign_block_size for flows that can be fragmented.
Fragmentation will be intertwined with block size calculation.
2016-01-28 09:42:17 +01:00
Simon Sapin
da2b4ab381 Disable incremental reflow for multicol and their descendants.
Fragmentation with dynamic updates is hard.
2016-01-27 17:33:12 +01:00
Johannes Linke
6b215f38ee Fix a bunch of clippy lints 2016-01-02 23:27:15 +01:00
Bobby Holley
47059d2d26 Separate style+layout and layout-specific wrapper functionality.
This patch does a number of things, unfortunately all at once:
* Hoists a large subset of the layout wrapper functionality into the style system.
* Merges TElementAttributes into the newly-created TElement.
* Reorganizes LayoutData by style vs layout, and removes LayoutDataShared.
* Simplifies the API for borrowing style/layout data.

There's still more to do to make the style system usable standalone, but
this is a good start.
2015-12-29 11:50:03 -08:00
Bobby Holley
cf33f00018 Generalize the rest of layout to operate on generic Layout*.
There wasn't a good way to split this up, unfortunately.

With this change, the only remaining usage of the Servo-specific structures is
in layout_task, where the root node is received from the script task. \o/
2015-11-28 18:01:02 -08:00
Guillaume Gomez
adf8b359bb Add XMLDocument object 2015-11-27 14:55:41 +01:00
Alan Jeffrey
3dec6edd10 Update string_cache to 0.2.
Updated string_cache, html5ever, xml5ever and selectors in Cargo.toml files and Cargo.lock.
Removed references to string_cache_plugin.
Import atom! and ns! from string_cache.
Replaced ns!("") by ns!().
Replaced ns!(XML) and co by ns!(xml) and co.
Replaced atom!(foo) by atom!("foo").
Replaced Atom::from_slice by Atom::from.
Replaced atom.as_slice() by &*atom.
2015-11-25 10:13:21 -06:00
Bobby Holley
afa3834f3b Rename ThreadSafeLayoutFoo to ServoThreadSafeLayoutFoo and TThreadSafeLayoutFoo to ThreadSafeLayoutFoo. 2015-11-21 11:26:49 -08:00
Bobby Holley
a85ae24c51 Hoist exported ThreadSafeLayoutFoo functionality into traits. 2015-11-21 11:25:20 -08:00
Martin Robinson
90e2f7bfbf Clean up restyle damage after it no longer applies
BUBBLE_ISIZES and REPAINT can become "stuck" on in the default Servo
configuration once they are activated. This is solved by removing these
damage bits after they no longer apply. There isn't a good way to test
this, other than noting that it doesn't break any existing CSS tests.
This will become more important in the future as the REPAINT bit is used
to implement display list patching.
2015-11-20 11:57:58 -08:00
rohan.prinja
9fd823e449 replace InheritTypes imports with inheritance imports 2015-10-30 20:26:30 +09:00
David Raifaizen
091282ee24 Made block type pattern match less inclusive 2015-10-27 09:41:42 -04:00
Ms2ger
b1f4bf617d Pass all the data layout needs from canvas elements at once. 2015-10-26 11:43:23 +01:00
Ms2ger
28f9302b38 Privatize FlowConstructionUtils.
This makes it match the documentation.
2015-10-26 08:52:52 +01:00
Anthony Ramine
aab2c40389 Generate the TypeId enums in codegen 2015-10-14 18:45:35 +02:00
Matt Brubeck
6426f714bd Incremental layout: Don't try to repair text fragment styles
Fixes #7814.
2015-10-01 15:07:39 -07:00
Patrick Walton
c72d0c2ed0 layout: Make the compositor rather than layout determine the position of
each iframe.

The old code that attempted to do this during layout wasn't able to work
for multiple reasons: it couldn't know where the iframe was going to be
on the page (because of nested iframes), and at the time it was building
the display list for a fragment it couldn't know where that fragment was
going to be in page coordinates.

This patch rewrites that code so that both the sizes and positions of
iframes are determined by the compositor. Layout layerizes all iframes
and marks the iframe layers with the appropriate pipeline and subpage
IDs so that the compositor can place them correctly. This approach is
similar in spirit to Gecko's `RefLayer` infrastructure. The logic that
determines when it is time to take the screenshot for reftests has been
significantly revamped to deal with this change in delegation of
responsibility.

Additionally, this code removes the infrastructure that sends layout
data back to the layout task to be destroyed, since it is now all
thread-safe and can be destroyed on the script task.

The failing tests now fail because of a pre-existing bug related to
intrinsic heights and borders on inline replaced elements. They happened
to pass before because we never rendered the iframes at all, which meant
they never had a chance to draw the red border the tests expect to not
render!

Closes #7377.
2015-09-29 09:47:28 -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
bors-servo
acde10f005 Auto merge of #7656 - mbrubeck:incremental-text-6501, r=pcwalton
Reconstruct flows when text/font styles change

These styles are used during text shaping.  When they change, we need to re-run shaping and construct new flows.

Fixes #6501. r? @pcwalton

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7656)
<!-- Reviewable:end -->
2015-09-18 01:32:40 -06:00
Matt Brubeck
040c09fbc5 Always reset HAS_NEWLY_CONSTRUCTED_FLOW during flow construction
This extra reflows when the HAS_NEWLY_CONSTRUCTED_FLOW flag remained set
during a later reflow.  This masked other incremental layout bugs, including
the one tested by the reftest in the commit following this one.
2015-09-17 10:50:47 -07: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
Manish Goregaokar
8e2c37a542 Fix match_refs and let_returns in layout, address review changes 2015-09-04 18:30:46 +05:30
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
Patrick Walton
676f7014e8 layout: Implement partial support for inline absolute containing blocks.
Improves the position of the down arrows on google.com SERPs.
2015-09-01 12:18:19 -07:00
Patrick Walton
930dfbb7ad layout: Fix merge fallout. 2015-08-21 16:08:13 -07:00
Kyle Zentner
0488a36862 Create FlexFlow's for 'display: flex' nodes.
This commit doesn't implement any flexbox behavior at all.
It just constructs FlexFlow's, which act just like the BlockFlow from
which they "inherit."
2015-08-21 15:59:18 -07:00
Simon Sapin
21d69314d4 Don’t mark flow_ref::deref_mut as unsafe.
See discussion in https://github.com/servo/servo/pull/7237
2015-08-21 21:16:25 +02:00
Simon Sapin
649250130b Replace FlowRef with Arc<Flow>, now that Arc supports DST.
… and WeakFlowRef with Weak<Flow>.
2015-08-20 16:49:48 +02:00
Simon Sapin
2d22aa8e7e Replace the unsound impl DerefMut for FlowRef with an unsafe function.
See #6503.
2015-08-20 16:24:26 +02:00
Johann Tuffe
ec07178b6f sort all uses 2015-08-20 20:47:12 +08:00
Patrick Walton
c328c38804 layout: Make inline absolute hypothetical boxes not clip their contents.
Improves the logo on ebay.com.
2015-08-18 16:58:18 -07:00
Corey Farwell
6aaada64dc flow::Flow should follow *_mut naming conventions
Fixes #7148
2015-08-18 09:12:01 -04:00
João Oliveira
067a22a868 Replace uses of for foo in bar.iter(),
and `for foo in bar.iter_mut(), and for foo in bar.into_iter()
(continuation of #7197)
2015-08-18 01:46:11 +01:00
Patrick Walton
a30379975a layout: Improve our handling of inline absolute containing blocks.
Several issues are addressed in this commit:

* Inline flows now bubble up their absolute descendants instead of
  making the inline flow the containing block for them. (In the future,
  we will need to make the inline flow *sometimes* be the containing
  block for them, but for now it improves sites to unconditionally
  bubble up.)

* Fragments now look at their inline fragment context to determine
  whether they are positioned.

* Inline flows now push the stacking-relative position of the absolute
  containing block down to their inline-block fragments.

* Inline absolute hypothetical fragments can be containing blocks.

* Fixes the logic in
  `containing_block_range_for_flow_surrounding_fragment_at_index`. The
  condition to determine whether fragments are positioned was inverted!

* `Descendants`/`AbsDescendants` has been refactored in order to become
  more friendly to inline absolute containing blocks in the future.

Improves the inline position of the green drop-down arrow in the Google
SERPs. (The block position is still wrong.)
2015-08-17 12:43:12 -07:00
João Oliveira
0038580abf Replace uses of for foo in bar.iter() and for foo in bar.iter_mut()
closes #7197
2015-08-15 02:27:39 +01:00
João Oliveira
9c11781880 replace .len() == 0 with is_empty()
closes #7198
2015-08-14 04:00:33 +01:00
Patrick Walton
8fe2f8930c layout: Make inline margins on <input type=button> and friends apply
only to the button and not to the text inside.

Improves the Google home page.
2015-08-13 09:51:17 -07:00
Patrick Walton
8640cf5588 layout: Take relative position offsets for inlines and inline-blocks
into account only once.

There were two bugs here: (1) relative position applied to
scanned/unscanned text fragments independently of the container element
that applied that relative position, causing double-counting; (2)
relative position applied to inline block fragments independently of the
wrapped block itself, causing double-counting.

This commit also removes the `cascade_anonymous` function and the
related `Fragment` constructor. They were unused, and their
functionality has been replaced by the `modify_style_for_*` series of
functions.

Closes #7067.
2015-08-12 08:28:35 -07: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
4e8d2b0e38 Allow list markers to contain multiple fragments
Fixes #6913.
2015-08-07 07:33:06 -07:00