Commit graph

256 commits

Author SHA1 Message Date
Simon Sapin
084a63df45 Remove usage of the deprecated std::num::Zero trait. 2014-12-18 11:16:47 +00:00
Ms2ger
466faac2a5 Update rustc to revision 3dcd2157403163789aaf21a9ab3c4d30a7c6494d. 2014-12-17 15:19:45 -05:00
Patrick Walton
42a8d9384b layout: Make line breaking able to restart from any position.
This commit removes the "merge-fragments" pass from inline reflow,
instead merging "on the fly". This ended up being simpler, as well as
more fine grained. Additionally, this patch makes the line breaker no
longer clone every fragment (!)

This functionality will be used in the implementation of
`text-overflow`.
2014-12-14 12:23:11 -08:00
Patrick Walton
6943ddb93e layout: Implement overflow-wrap/word-wrap per CSS-TEXT § 6.2.
This property is used by approximately 55% of page loads.

To implement the line breaking behavior, the "breaking strategy" has
been cleaned up and abstracted. This should allow us to easily support
other similar properties in the future, such as `text-overflow` and
`word-break`.
2014-12-13 13:05:05 -08:00
Patrick Walton
caee309ef4 layout: Implement text-indent per CSS 2.1 § 16.1.
I had to use a somewhat unconventional method of computing text
indentation (propagating from blocks down to inlines) because of the way
containing blocks are handled in Servo.

(As a side note, neither Gecko nor WebKit correctly handles percentages
in `text-align`, at least incrementally -- i.e. when the percentages are
relative to the viewport and the viewport is resized.)
2014-12-12 14:55:41 -08:00
Patrick Walton
071d320728 layout: Refactor inline layout a bit. 2014-12-12 14:55:24 -08:00
Joseph Crail
c254d195ad Fix spelling mistakes in comments. 2014-12-11 23:56:29 -05:00
Matt Brubeck
5d0d11c380 Make all of LineBreaker private 2014-12-09 15:57:05 -08:00
Patrick Walton
1c1c507c03 layout: Implement opacity per CSS-COLOR § 3.2.
This adds the infrastructure necessary to support stacking contexts that
are not containing blocks for absolutely-positioned elements. Our
infrastructure did not support that before. This minor revamp actually
ended up simplifying the logic around display list building and
stacking-relative position computation for absolutely-positioned flows,
which was nice.
2014-12-03 14:17:16 -08:00
Patrick Walton
55da2c97d5 layout: Incrementalize reflow of block formatting contexts impacted by
floats, and make float placement idempotent.

This moves float placement outside sequential block size computation.

Improves the maze solver.
2014-11-18 15:36:04 -08:00
Patrick Walton
be36fcd3b1 layout: Eliminate the virtual is_float() in favor of the flow flags 2014-11-18 15:36:04 -08:00
Claes 'Letharion' Gyllensvärd
2737db3ad7 Remove bitfield! macro in favour of bitflags! 2014-11-18 19:26:10 +01:00
Patrick Walton
a4a9a46a87 gfx: Rewrite display list construction to make stacking-contexts more
first-class.

This implements the scheme described here:

    https://groups.google.com/forum/#!topic/mozilla.dev.servo/sZVPSfPVfkg

This commit changes Servo to generate one display list per stacking
context instead of one display list per layer. This is purely a
refactoring; there are no functional changes. Performance is essentially
the same as before. However, there should be numerous future benefits
that this is intended to allow for:

* It makes the code simpler to understand because the "new layer needed"
  vs. "no new layer needed" code paths are more consolidated.

* It makes it easy to support CSS properties that did not fit into our
  previous flat display list model (without unconditionally layerizing
  them):

  o `opacity` should be easy to support because the stacking context
    provides the higher-level grouping of display items to which opacity
    is to be applied.

  o `transform` can be easily supported because the stacking context
    provides a place to stash the transformation matrix. This has the side
    benefit of nicely separating the transformation matrix from the
    clipping regions.

* The `flatten` logic is now O(1) instead of O(n) and now only needs to
  be invoked for pseudo-stacking contexts (right now: just floats),
  instead of for every stacking context.

* Layers are now a proper tree instead of a flat list as far as layout
  is concerned, bringing us closer to a production-quality
  compositing/layers framework.

* This commit opens the door to incremental display list construction at
  the level of stacking contexts.

Future performance improvements could come from optimizing allocation of
display list items, and, of course, incremental display list
construction.
2014-11-14 17:31:15 -08:00
Jack Moffitt
d1b433a3b3 Rust upgrade to rustc hash b03a2755193cd756583bcf5831cf4545d75ecb8a 2014-11-13 11:17:43 +10:00
Martin Robinson
2d72f00ccf Have ContentBox(es)Queries consult the flow tree
Instead of looking at the display tree, have ContentBox(es)Query consult
the flow tree. This allow optimizing away parts of the display tree
later. To do this we need to be more careful about how we send reflow
requests, only querying the flow tree when possible.

Fixes #3790.
2014-11-03 10:30:28 -08:00
Patrick Walton
08fc7c2795 layout: Make incremental reflow more fine-grained by introducing "reflow
out-of-flow" and "reconstruct flow" damage bits.

This is needed for good performance on the maze solver.
2014-10-31 12:24:40 -07:00
Patrick Walton
587cf98209 layout: Promote absolute positioning, floatedness, and clearance into
flags to avoid virtual calls.

These were showing up really high in the maze solver profile.
2014-10-28 19:38:22 -07:00
Patrick Walton
93bf69a6fe layout: Use the new append_from method to get rid of a bunch of moves
in display list construction.

These were showing up in the profile.
2014-10-28 14:28:34 -07:00
Glenn Watson
b1c226778f Cache last fontgroup. Style recalc on wikipedia/rust 66ms -> 41ms. 2014-10-24 08:25:10 +10:00
Patrick Walton
de5e2fd5e2 layout: Shrink fragments down from 448 bytes down to 128 bytes.
16% performance improvement in layout (!)
2014-10-23 09:13:41 -07:00
bors-servo
01f6a8102d auto merge of #3771 : pcwalton/servo/display-list-building-cleanup, r=mrobinson
`layout::fragment` and `layout::block` were getting too big.

r? @mrobinson
2014-10-22 10:54:35 -06:00
Patrick Walton
821793351e layout: Largely move display list building out to a separate file.
`layout::fragment` and `layout::block` were getting too big.
2014-10-22 08:02:17 -07:00
Clark Gaebel
b31f9e0188 properly incrementally set block size 2014-10-21 14:26:22 -07:00
Patrick Walton
bb6f557276 layout: Rewrite text and inline fragment handling during flow
construction to avoid cloning and moving flows so much.

Besides amounting to a 5%-10% win on a page with a lot of text, this
simplifies and refactors the text layout code.
2014-10-20 22:05:38 -07:00
Clark Gaebel
8496c056e7 Fixed the inline_element_border_a reftest with incremental layout turned on. 2014-10-17 11:11:14 -07:00
Clark Gaebel
2faf5b270f Fix image_dynamic_remove reftest with incremental layout turned out
This also adds some extra debugging infrastructure which I found useful tracking
this bug down. A regression in the br reftests is also uncovered by this patch,
which I'll work on fixing next.

r? @pcwalton
2014-10-17 11:11:14 -07:00
Patrick Walton
a6fcec468f layout: Remove FontStyle in favor of using the font style struct
directly, and optimize `get_layout_font_group()` to use a small vector.

Seems to be a 38% layout win on a site I tested with a lot of text.
2014-10-15 22:17:57 -07:00
Clark Gaebel
481adcd654 Fix whitespace_pre with incremental reflow turned on.
This implements fragment merging, in order to incrementally reflow linebroken
text. This makes the `whitespace_pre.html` reftest pass with incremental reflow
turned on with `-i`.
2014-10-15 16:04:21 -07:00
Clark Gaebel
76ed7484eb Use the Deref traits for FlowRefs.
This patch switches FlowRefs to using the Deref and DerefMut traits, instead of
the custom `get` and `get_mut` functions.
2014-10-15 11:04:05 -07:00
Patrick Walton
c7e619dfe7 layout: Rewrite intrinsic inline-size and automatic table layout to
match L. David Baron's work-in-progress specification.

    http://dbaron.org/css/intrinsic/

Column spans are not yet supported.

This effectively adds support for percentage widths, and it also fixes
many bugs, improving the layout of Google and Wikipedia.
2014-10-14 14:17:57 -07:00
Patrick Walton
5f8d3f72d8 layout: Introduce support for legacy presentational attributes to selector
matching, and use it for `<input size>` and `<td width>`.

This implements a general framework for legacy presentational attributes
to the DOM and style calculation, so that adding more of them later will
be straightforward.
2014-10-14 12:44:09 -07:00
bors-servo
fd70b366ae auto merge of #3654 : pcwalton/servo/clip-reform, r=mrobinson
We push down clipping areas during absolute position calculation. This
makes display items into a flat list, improving cache locality. It
dramatically simplifies the code all around.

Because we need to push down clip rects even for absolutely-positioned
children of non-absolutely-positioned flows, this patch alters the
parallel traversal to compute absolute positions for
absolutely-positioned children at the same time it computes absolute
positions for other children. This doesn't seem to break anything either
in theory (since the overall order remains correct) or in practice. It
simplifies the parallel traversal code quite a bit.

See the relevant Gecko bug:
https://bugzilla.mozilla.org/show_bug.cgi?id=615734

r? @mrobinson
2014-10-14 00:42:35 -06:00
Glenn Watson
38e7df8139 Change accidental println to debug macro. 2014-10-14 15:29:36 +10:00
Patrick Walton
bffaad118e layout: Rewrite clipping to be per-display-item instead of having
a separate `ClipDisplayItem`.

We push down clipping areas during absolute position calculation. This
makes display items into a flat list, improving cache locality. It
dramatically simplifies the code all around.

Because we need to push down clip rects even for absolutely-positioned
children of non-absolutely-positioned flows, this patch alters the
parallel traversal to compute absolute positions for
absolutely-positioned children at the same time it computes absolute
positions for other children. This doesn't seem to break anything either
in theory (since the overall order remains correct) or in practice. It
simplifies the parallel traversal code quite a bit.

See the relevant Gecko bug:
https://bugzilla.mozilla.org/show_bug.cgi?id=615734
2014-10-13 21:40:36 -07:00
bors-servo
799d0de0c0 auto merge of #3650 : pcwalton/servo/give-up-on-not-splitting, r=glennw
I don't think it will be possible to avoid splitting fragments in the
presence of `vertical-align`, because one `ScannedTextFragment` could
potentially be split into arbitrary many fragments, each having its own
vertical position that can influence layout of other fragments.

This code also removes parts of `Range` that were no longer used.

r? @glennw
2014-10-13 18:36:40 -06:00
bors-servo
7902ccf850 auto merge of #3631 : pcwalton/servo/idempotent-inline-size, r=glennw
This makes layout more idempotent, which is important for incremental
layout.

Also converts `is_root` to a set of flags and fixes a `TODO` concerning
percentage inline heights of images.

r? @glennw
2014-10-13 18:03:40 -06:00
Patrick Walton
d560d51454 layout: Refactor inline layout to remove the code that tried to avoid
splitting fragments.

I don't think it will be possible to avoid splitting fragments in the
presence of `vertical-align`, because one `ScannedTextFragment` could
potentially be split into arbitrary many fragments, each having its own
vertical position that can influence layout of other fragments.

This code also removes parts of `Range` that were no longer used.
2014-10-13 16:33:19 -07:00
Patrick Walton
423f5f0ebf layout: Store containing block inline-size separately rather than
writing it to a temporary location and overwriting it.

This makes layout more idempotent, which is important for incremental
layout.

Also converts `is_root` to a set of flags and fixes a `TODO` concerning
percentage inline heights of images.
2014-10-13 14:39:34 -07:00
Patrick Walton
2b0e59725b layout: Make content of display: inline-block; overflow: hidden visible. 2014-10-13 08:03:34 -07:00
Clark Gaebel
a29dc2c979 removed restyledamage 2014-10-09 12:55:25 -04:00
Clark Gaebel
d12c6e7383 Incremental Style Recalc
This patch puts in the initial framework for incremental reflow. Nodes' styles
are no longer recalculated unless the node has changed.

I've been hacking on the general problem of incremental reflow for the past
couple weeks, and I've yet to get a full implementation that actually passes all
the reftests + wikipedia + cnn. Therefore, I'm going to try to land the different
parts of it one by one.

This patch only does incremental style recalc, without incremental flow
construction, inline-size bubbling, reflow, or display lists. Those will be coming
in that order as I finish them.

At least with this strategy, I can land a working version of incremental reflow,
even if not yet complete.

r? @pcwalton
2014-10-09 12:55:21 -04:00
Patrick Walton
01c90d8d6a layout: Implement z-index. 2014-10-08 22:30:44 -07:00
Patrick Walton
d30762bb9f layout: white_space::pre should not yield ignorable whitespace.
Improves the Google home page.
2014-10-07 13:39:41 -07:00
Patrick Walton
287fe3b3ab layout: Implement the correct hypothetical box behavior for
absolutely-positioned elements declared with `display: inline`.

Although the computed `display` property of elements with `position:
absolute` is `block`, `position: absolute; display: inline` can still
behave differently from `position: absolute; display: block`. This is
because the hypothetical box for `position: absolute` can be at the
position it would have been if it had `display: inline`. CSS 2.1 §
10.3.7 describes this case in a parenthetical:

"The static-position containing block is the containing block of a
hypothetical box that would have been the first box of the element if
its specified 'position' value had been 'static' and its specified
'float' had been 'none'. (Note that due to the rules in section 9.7 this
hypothetical calculation might require also assuming a different
computed value for 'display'.)"

To handle this, I had to change both style computation and layout. For
the former, I added an internal property
`-servo-display-for-hypothetical-box`, which stores the `display` value
supplied by the author, before the computed value is calculated. Flow
construction now uses this value.

As for layout, implementing the proper behavior is tricky because the
position of an inline fragment in the inline direction cannot be
determined until height assignment, which is a parallelism hazard
because in parallel layout widths are computed before heights. However,
in this particular case we can avoid the parallelism hazard because the
inline direction of a hypothetical box only affects the layout if an
absolutely-positioned element is unconstrained in the inline direction.
Therefore, we can just lay out such absolutely-positioned elements with
a bogus inline position and fix it up once the true inline position of
the hypothetical box is computed. The name for this fix-up process is
"late computation of inline position" (and the corresponding fix-up for
the block position is called "late computation of block position").

This improves the header on /r/rust.
2014-10-01 18:34:53 -07:00
Josh Matthews
f70bb68503 Implement simple layout for text, button, radio, and checkbox inputs. Implement simple interaction for checkboxes and radio buttons. 2014-10-01 15:35:42 -04:00
Glenn Watson
52c5007b07 Add support for <super> and <sup> tags. Fixes equations on wikipedia. 2014-09-30 07:12:54 +10:00
Simon Sapin
b3245fa407 Upgrade to rustc d2b30f7d3 2014-09-23 2014-09-29 17:41:45 +01:00
Glenn Watson
71758643dc Remove unneeded clones and add some comments. 2014-09-27 13:51:10 +10:00
Glenn Watson
cf79e64a5a Improve acid2. Fix line height calculation. Text fragments get correct enclosing element style.
* Enabled acid2 on mac + linux. Updated the reference image. The only difference from the
real acid2 now is the paint order and a 1 pixel horizontal offset on the nose.
* Change line-height to be calculated correctly.
* Apply enclosing element style to text fragments.
2014-09-26 17:12:22 +10:00
Patrick Walton
9aacd4c10c layout: Implement white-space: nowrap.
Improves the Reddit header.
2014-09-23 15:47:45 -07:00