Commit graph

544 commits

Author SHA1 Message Date
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
Patrick Walton
ee2ccc4f87 script: Use atom comparison in more places, especially for attributes.
75% improvement in style recalc for Guardians of the Galaxy.
2014-10-14 10:32:40 -07:00
bors-servo
834df4e211 auto merge of #3673 : mrobinson/servo/iframe-margin, r=pcwalton
Instead of taking margin size into account twice when positioning
layers, just rely on the absolute position calculated during display
list construction.
2014-10-14 04:51:35 -06: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
Martin Robinson
e53093e127 Do not compound iframe margins when positioning
Instead of taking margin size into account twice when positioning
layers, just rely on the absolute position calculated during display
list construction.
2014-10-13 17:28:32 -07: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
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
Cameron Zwarich
fb810c08dc Remove trailing whitespace
The Mach test runner doesn't actually make these failures yet, which is
tracked by #3482.
2014-10-06 14:40:42 -07:00
Patrick Walton
885fc1c28b layout: Implement box-sizing: border-box.
Improves GitHub.
2014-10-01 20:24:34 -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
5794da904e Remove unneeded input type information from layout. 2014-10-01 15:40:36 -04:00
Josh Matthews
8112859d55 Disallow toggling radio buttons. Use generated content for checkboxes and radio buttons. Switching to the glyph 0 for the average advance width. 2014-10-01 15:37:40 -04: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
55ef7ca5ad Refactor background image, fix fixed attachment. Improve acid2. 2014-10-01 08:54:24 +10:00
Keegan McAllister
d50114c41d Use string-cache's Namespace type 2014-09-29 21:40:54 -07:00
Patrick Walton
690bf079f7 layout: Refactor a few things, mostly just to obey the line limit. 2014-09-27 06:07:58 -07:00
Patrick Walton
fb5952fed0 layout: Don't double-count padding, etc, and don't draw
backgrounds/borders/etc. twice for inline-blocks.

Improves Reddit, GitHub, and many other sites.
2014-09-27 06:07:58 -07:00
Glenn Watson
15e1e5e43f Fix some mutable variable warnings. 2014-09-27 15:04:40 +10:00
Glenn Watson
26cf00ef4e Don't render backgrounds for text fragments. 2014-09-26 18:28:40 +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
Glenn Watson
32c02fc048 Fix inline context padding on inline-block.
Fixes categories bar on wikipedia - ref #2554.
2014-09-23 15:40:08 +10:00
Glenn Watson
87d18b90a6 Add support for min-width and max-width to images.
This fixes the images on the homepage of github.
2014-09-22 14:03:10 +10:00
Keegan McAllister
dc86e83654 Eliminate warnings 2014-09-20 13:00:55 -07:00
Patrick Walton
08e004d106 Merge pull request #3424 from SimonSapin/font-size-absolute
Add font-size absolute size keywords. Fix #3417
2014-09-19 15:17:55 -07:00
Patrick Walton
b4db9aeaeb Handle generated content with display: block correctly during flow
construction.

The iteration was incorrect here. Although it accidentally worked
before, it will cause problems when we have incremental style
recalculation.

The `after_block_iteration` reftest will become interesting once we have
incremental style recalc.
2014-09-19 12:25:37 -07:00
Simon Sapin
010d87b93e Remove min/max functions from util::geometry. Use std::cmp instead. 2014-09-19 13:56:35 +01:00
Patrick Walton
22bca83509 Merge pull request #3404 from glennw/inline-block-fix
Include margin in inline block intrinsic width. Fixes [edit] links on wikipedia. Also improves google homepage.
2014-09-18 07:51:11 -07:00
Josh Matthews
9607b468bc Revert "script: Use atom comparison in more places, especially for attributes." for persistent test failures.
This reverts commit 874db26104.
2014-09-18 09:20:19 -04:00
Glenn Watson
6bc65f3b07 Include margin in inline block intrinsic width. Fixes [edit] links on wikipedia. 2014-09-18 16:07:28 +10:00
Patrick Walton
874db26104 script: Use atom comparison in more places, especially for attributes.
75% improvement in style recalc for Guardians of the Galaxy.
2014-09-17 13:17:12 -07:00
Matt Brubeck
6c9524b687 Implement background-position keyword values
Also fixes calculation of background-position percentages:

Rather than multiplying the container size by a percent and aligning the top
left of the image at the resulting width, we also need to subtract a
corresponding percent of the image size, per
http://dev.w3.org/csswg/css2/colors.html#propdef-background-position

"A value pair of '100% 100%' places the lower right corner of the image in the
lower right corner of the padding box. With a value pair of '14% 84%', the
point 14% across and 84% down the image is to be placed at the point 14%
across and 84% down the padding box."
2014-09-16 10:24:31 -07:00
Jack Moffitt
e10206e91e Reinstate errors for unused variables and imports. 2014-09-13 23:38:00 -06:00
Glenn Watson
98624c9576 Implement basic support for display: inline-block.
This still needs a lot of work, but it covers the basic
cases and improves wikipedia while passing all existing tests.

Tweak reftest to deal with linux/travis black background.
2014-09-13 07:13:42 +10:00
Glenn Watson
29c3819246 Partial fix for background images on wikipedia pages.
This fixes the visual artifacts seen at the top of wikipedia pages by:
 - Setting clipping rect to avoid images going outside their bounds.
 - Handling case of background-position being >= 100% such that wrapping is required.

However, the gradient is not currently visible on wikipedia. This relies on bug #1997 being fixed.
2014-09-11 16:25:04 +10:00
Jack Moffitt
c6ab60dbfc Cargoify servo 2014-09-08 20:21:42 -06:00
Renamed from src/components/layout/fragment.rs (Browse further)