Commit graph

167 commits

Author SHA1 Message Date
Eli Friedman
69ca066802 Fully implement the "align descendants" rule for div.
This adds -servo-left and -servo-right to complement -servo-center.

This intentionally doesn't try to address issue #7301.
2015-10-02 12:53:20 -07:00
Matt Brubeck
441cc479a3 Use the correct container size in compute_overflow
Fixes #7768 - positioning of RTL stacking contexts.
2015-09-28 11:57:40 -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
Michael Howell
029af81570 Actually store the overflow for inline-block elements.
Fixes #7571
2015-09-09 12:24:28 -07:00
bors-servo
aeb8dce2d9 Auto merge of #7534 - pcwalton:inline-absolute-out-of-flow, r=mbrubeck
layout: Lay absolutely-positioned blocks with inline containing blocks out of flow.

Removes the long space before the site-specific drop-down in the Google SERPs.

r? @glennw

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7534)
<!-- Reviewable:end -->
2015-09-04 19:59:11 -06:00
Manish Goregaokar
54c036cd66 Elide most 'a lifetimes 2015-09-04 08:55:51 +05:30
Patrick Walton
dba3e41a63 layout: Lay absolutely-positioned blocks with inline containing blocks out of
flow.

Removes the long space before the site-specific drop-down in the Google SERPs.
2015-09-03 15:37:40 -07: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
bors-servo
a547ae6826 Auto merge of #7496 - servo:calc_, r=SimonSapin
Implement CSS3 Calc

This is #7185 with one commit added to make it build merged with master, which got support for the `ch` unit in the meantime.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7496)
<!-- Reviewable:end -->
2015-09-02 02:33:18 -06:00
Simon Sapin
40b4348824 Upgrade to rustc 1.4.0-dev (cb9323ec0 2015-09-01) 2015-09-02 09:22:17 +02:00
bors-servo
e46499a5df Auto merge of #7498 - pcwalton:inline-absolute-containing-blocks, r=mbrubeck
layout: Implement partial support for inline absolute containing blocks.

Improves the position of the down arrows on google.com SERPs.

r? @mbrubeck

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7498)
<!-- Reviewable:end -->
2015-09-01 16:36:58 -06: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
bors-servo
dcaf66397a Auto merge of #7313 - pcwalton:position-relative-percentage-overflow, r=mbrubeck
layout: Make overflow calculation take relative percentages into account.

This necessitated changing overflow to be calculated by the parent flow
if relatively positioned children are present. That is because the
overflow regions cannot be calculated without knowing relative offsets,
which themselves cannot be calculated without knowing the parent size
(because of percentages). To accomplish this without sacrificing
parallelism in the non-relative case, this patch splits overflow into
"early" and "late" computation. Late overflow computation cannot be
parallelized across children, while early overflow computation can.

Makes the "Apple Music" text show up over the full-bleed promotional
background on apple.com.

r? @SimonSapin -- would appreciate a look over the iframe test case that was changed.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7313)
<!-- Reviewable:end -->
2015-09-01 12:33:07 -06:00
Simon Sapin
80d471d5cf Merge branch 'master' into calc 2015-09-01 18:39:16 +02:00
erneyja
17663315dd make test-tidy check that = have space after them 2015-09-01 07:18:19 -04:00
Patrick Walton
b66f17a445 layout: Make overflow calculation take relative percentages into
account.

This necessitated changing overflow to be calculated by the parent flow
if relatively positioned children are present. That is because the
overflow regions cannot be calculated without knowing relative offsets,
which themselves cannot be calculated without knowing the parent size
(because of percentages). To accomplish this without sacrificing
parallelism in the non-relative case, this patch splits overflow into
"early" and "late" computation. Late overflow computation cannot be
parallelized across children, while early overflow computation can.

Makes the "Apple Music" text show up over the full-bleed promotional
background on apple.com.
2015-08-31 16:50:56 -07:00
David Zbarsky
67db4fbc2e Remove stray changes 2015-08-26 14:15:01 -07:00
David Zbarsky
9556141e57 Implement Calc for LengthOrPercentage 2015-08-26 14:14:43 -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
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
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
bors-servo
d654841288 Auto merge of #7177 - pcwalton:intervening-inline-block, r=mbrubeck
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.)

r? @mbrubeck

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7177)
<!-- Reviewable:end -->
2015-08-17 13:56:53 -06: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
Josh Matthews
8bb853f643 Fix existing syntactics nits. 2015-08-16 10:30:43 -04: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
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
Patrick Walton
df4acbac04 layout: Implement basic overflow: scroll functionality.
Known issues:

* Display list optimization can sometimes optimize out elements that
  should be shown. This affects the Enyo demo.

* The `overflow: scroll` container doesn't clip the inner layer properly
  when borders, border radius, etc. are present.

* `overflow-x: scroll` and `overflow-y: scroll` don't work individually;
  elements are scrolled all at once.

* Scrolling only works on absolutely-positioned elements.
2015-08-10 21:27:04 -07:00
Patrick Walton
11fdb503df layout: Introduce infrastructure for tracking, backing up, and splitting
at the last known good split point, and use it for `white-space:
nowrap`.

Fixes overflowing tables on Wikipedia.

This infrastructure should form the basis of our fix for inline layout
of fragments that don't themselves constitute valid split points. That
will require some more work, however.
2015-08-08 00:01:31 -07:00
Matt Brubeck
8a09f738d4 Replace Arc<Box<TextRun>> with Arc<TextRun> 2015-08-05 18:28:20 -07:00
Patrick Walton
0a589d413d layout: When repairing styles for incremental reflow, only repair
styles of nodes that represent the dirty node, *including its
pseudo-element*.

Fixes lots more jumpiness.

A manual test, `inline-pseudo-repair-jumpiness.html`, has been added. I
was unable to automate it, so I will file a followup issue on that.
2015-08-04 09:02:41 -07:00
bors-servo
d66c59a152 Auto merge of #6784 - glennw:offset-ext, r=pcwalton
Implement offsetParent/Top/Left/Width/Height.



<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6784)
<!-- Reviewable:end -->
2015-08-03 18:39:43 -06:00
Glenn Watson
9e5687e3e7 Implement offsetParent/Top/Left/Width/Height. 2015-08-03 11:55:38 +10:00
Glenn Watson
b9fea3deb3 Fix percentage height calculation, absolute containing block height calculations.
It's not possible to correctly determine during the css cascade whether the container height
is explicitly specified. Additionally, the spec https://drafts.csswg.org/css2/visudet.html#the-height-property
says this should affect the *used* height, rather than the computed height.

This significantly improves the layout in #6643.
2015-08-03 10:47:56 +10:00
Jack Moffitt
dae1a398a4 Use local slice_chars
StrExt::slice_chars is deprecated and will be removed in Rust. This
lifts the implementation from Rust libstd and puts it in util::str.

This fixes a bunch of deprecation warnings in Servo.
2015-07-31 12:23:13 -06:00
Ms2ger
3984e39011 Replace the StyledNode trait with inherent methods. 2015-07-27 19:57:33 +02:00
Matt Brubeck
dfac8ce4a1 Basic support for bidirectional text 2015-07-23 20:05:55 -07:00
Patrick Walton
c84368b703 layout: Make the output of flow tree dumping easier to read when there
are many fragments.
2015-07-07 15:01:18 -07:00
Simon Sapin
75e3e787f6 Upgrade to rustc 1.3.0-dev (f3b97a74a 2015-07-03) 2015-07-04 11:32:41 +02:00
Matt Brubeck
a3b339c358 Simplify next_fragment and fix obsolete docs 2015-06-22 15:23:00 -07:00
ecoal95
8cbfb3482c Use euclid from crates.io 2015-06-19 00:04:24 +02:00
Manish Goregaokar
94fa868d2b Add unsafe blocks to make_unique
See #6376
2015-06-14 20:52:27 +05:30
Corey Farwell
5c408d2be9 rust-geom API changes
https://github.com/servo/rust-geom/pull/81
2015-06-13 12:28:21 -07:00
bors-servo
a8b6632a5a Auto merge of #6328 - mbrubeck:line-comment, r=pcwalton
r? @pcwalton

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6328)
<!-- Reviewable:end -->
2015-06-10 17:44:55 -06:00
Matt Brubeck
775953b11e Fix indices in Line::range doc comment 2015-06-10 14:04:15 -07:00
Manish Goregaokar
af364a412e Audit and reduce unstable usage in layout
Reasons behind existing unstable features:

alloc:

 - `make_unique()`
 - direct calls into `heap::allocate()`, etc
 - `boxed::into_raw()` (naming)

collections:

 - `slice_chars()` (needs to prove its worth)

core:

 - lots and lots of pointer manip
 - `raw` stuff

std_misc:

 - Handle stuff
 - hasher stuff

str_char:

 - CharRange
2015-06-10 00:54:14 +05:30
Patrick Walton
6a197719b3 compositing: Implement display ports and avoid creating display lists
for items outside it.

This improves Servo's performance on large pages.
2015-05-19 16:53:51 -07:00
Patrick Walton
d5ca1a18dc layout: Support percentage widths in inline-blocks.
Improves Twitter.
2015-05-19 13:35:02 -07:00