Commit graph

92 commits

Author SHA1 Message Date
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
106fdb1d32 layout: Implement word-spacing per CSS 2.1 § 16.4.
This assumes that there are no ligatures that span across multiple
words. Since we have a per-word shape cache, this is a safe assumption
as of now. I have left comments to ensure that, if and when this is
revisted, we make sure to handle it properly.
2014-12-12 17:55:11 -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
07bc97e3e2 gfx: Implement letter-spacing per CSS 2.1 § 16.4.
The ligature disabling code has been manually verified, but I was unable
to reftest it. (The only way I could think of would be to create an
Ahem-like font with a ligature table, but that would be an awful lot of
work.)

Near as I can tell, the method used to apply the spacing (manually
inserting extra advance post-shaping) matches Gecko.
2014-12-12 11:43:43 -08:00
Joseph Crail
c254d195ad Fix spelling mistakes in comments. 2014-12-11 23:56:29 -05:00
bors-servo
5ef94c716d auto merge of #4340 : michaelwu/servo/css-rem-support, r=SimonSapin
This works on my simple test page https://people.mozilla.org/~mwu/rem.html , hopefully works on real pages too. Seems a little messy to add root_font_size directly to ComputedValues, but it didn't seem appropriate to add to the style structs.
2014-12-11 19:01:01 -07:00
Patrick Walton
52b9951cad layout: Implement outline per CSS 2.1 § 18.4.
`invert` is not yet supported.

Objects that get layers will not yet display outlines properly. This is
because our overflow calculation doesn't take styles into account and
because layers are always anchored to the top left of the border box.
Since fixing this is work that is not related to outline *per se* I'm
leaving that to a followup and making a note in the code.
2014-12-11 14:25:10 -08:00
Michael Wu
94c019dce5 Add support for the 'rem' css unit 2014-12-11 16:29:03 -05:00
Patrick Walton
877f02f1d1 layout: Implement text-transform.
The Unicode awareness of `text-transform` is implemented as well as
possible given the Rust standard library's Unicode support. In
particular, the notion of an alphabetic character is used instead of a
letter.

Gecko has a subclass of text run to handle text transforms, but I
implemented this in a simpler way.
2014-12-10 14:09:08 -08:00
Matthew Rasmus
1b84bd22b8 Implements the :checked pseudo-class for inputs
Relevant spec:
https://html.spec.whatwg.org/multipage/scripting.html#selector-checked

Also modifies HTMLInputElement::SetChecked to no longer modify its
checked content value, instead making use of its internal checkedness
state now that we can match `:checked` properly.
2014-12-08 08:40:15 -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
Clark Gaebel
ffcf0bf394 [gfx/style] Implement border-radius.
This patch is a first stab at implementing border-radius. It looks fine as long as
the border isn't an ellipse (that might not even parse yet), and the border-widths
around a border-radius are the same.

Here's a cool screenshot!

![](https://www.dropbox.com/s/gdtmgjrlnf82gzz/Screenshot%202014-11-12%2018.03.29.png?dl=0)

r? @pcwalton @SimonSapin
2014-12-01 16:10:35 -08:00
Simon Sapin
c6ff02199d Remove dead code 2014-11-28 17:44:00 +00:00
Simon Sapin
18de4dd75d style::properties::longhand shouldn’t be public. 2014-11-28 17:43:14 +00:00
Paul DiPietro
adcf194bf7 Fix deprecation in selector matching test
The 'find' function was changed to 'get'. Changed to reflect this
warning given when running the tests.
2014-11-25 09:45:00 -05:00
Manish Goregaokar
534919327d Use atom! in place of Atom::from_slice where necessary 2014-11-23 22:03:27 +05:30
Bruno de Oliveira Abinader
6f2af793e8 Arc::make_unique is now stable 2014-11-21 10:45:35 -04:00
Bruno de Oliveira Abinader
b9f974ab33 No longer need for local variable in PropertyDeclaration::parse 2014-11-21 10:40:21 -04:00
Jack Moffitt
d1b433a3b3 Rust upgrade to rustc hash b03a2755193cd756583bcf5831cf4545d75ecb8a 2014-11-13 11:17:43 +10:00
bors-servo
f775f12fe9 auto merge of #3886 : glennw/servo/mq, r=SimonSapin 2014-11-06 17:24:28 -07:00
Glenn Watson
a48c780d22 Fix unit tests for media queries. 2014-11-06 15:53:37 -08:00
Glenn Watson
b278fc2284 Short circuit media queries test if stylist is already dirty. 2014-11-06 14:42:55 -08:00
Patrick Walton
215c2a9d4c layout: Implement CSS linear gradients per the CSS-IMAGES specification.
This implements the CSS `linear-gradient` property per the CSS-IMAGES
specification:

    http://dev.w3.org/csswg/css-images-3/

Improves GitHub.
2014-11-06 08:26:47 -08:00
Glenn Watson
11cf538ff4 Make media queries work with resize and page zoom. 2014-11-04 13:25:21 -08:00
Patrick Walton
4bf0acbe38 layout: Support more types of selectors for style sharing.
This helps avoid problems with style sharing in common cases, often
caused by the user agent stylesheet.
2014-10-28 14:12:50 -07:00
Josh Matthews
a1b2f4b590 Add an optional --debug-mozjs argument to mach build that enables a non-optimized, debug build of mozjs and rust-mozjs. Update the Cargo snapshot to enable new feature support. 2014-10-24 16:18:25 -04:00
bors-servo
3910bc942f auto merge of #3794 : glennw/servo/font-content-opt, r=pcwalton 2014-10-23 21:09:29 -06:00
Glenn Watson
b1c226778f Cache last fontgroup. Style recalc on wikipedia/rust 66ms -> 41ms. 2014-10-24 08:25:10 +10:00
Samuel Harrington
6b88fc4c54 Update style/README.md - libcss is gone now 2014-10-23 16:23:54 -05:00
Clark Gaebel
a5bb2f299f more efficient preorder DOM traversals 2014-10-21 10:01:15 -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
bors-servo
3eb6b17137 auto merge of #3610 : glennw/servo/media-queries, r=SimonSapin 2014-10-14 18:36:29 -06:00
bors-servo
56989b8dec auto merge of #3640 : cgaebel/servo/incremental-flow-construction, r=pcwalton
This also hides the not-yet-working parts of incremental reflow behind a runtime
flag. As I get the failing reftests passing, I'll send pull requests for them one
by one.
2014-10-14 16:51:30 -06:00
Glenn Watson
c7d81fdde6 Implement media queries parser and matching. Improves mobile first sites like bootstrap3. 2014-10-15 07:36:31 +10: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
8077edc062 auto merge of #3623 : pcwalton/servo/use-atoms-2, r=jdm
75% improvement in style recalc for Guardians of the Galaxy.
2014-10-14 12:42:35 -06:00
Clark Gaebel
f552e2f750 try to reset flows which need reflow, since reflow isn't yet idempotent 2014-10-14 10:33:46 -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
Glenn Watson
1827852810 Add support for local font faces. Improves fonts on rust lang and guide. 2014-10-14 15:59:08 +10:00
bors-servo
6e3c776387 auto merge of #3635 : SimonSapin/servo/ua-stylesheet, r=pcwalton
Based on https://html.spec.whatwg.org/multipage/rendering.html rather than http://dev.w3.org/csswg/css2/grammar.html

Fixes #3629.

r? @pcwalton
2014-10-13 12:21:44 -06:00
Patrick Walton
2a790d06dd Use Gecko's simpler Bloom filter instead of one based on hash
stretching.

This preserves the usage of the Bloom filter throughout style recalc,
but the implementation is rewritten. Provides a 15% improvement on
Guardians of the Galaxy.
2014-10-10 17:02:27 -07:00
Simon Sapin
e9ebfb74fc Rewrite the user-agent stysheet(s)
Based on https://html.spec.whatwg.org/multipage/rendering.html
rather than http://dev.w3.org/csswg/css2/grammar.html
2014-10-10 17:27:38 +01:00
Simon Sapin
1117d86b63 Add [foo=bar i] case-insensitive attribute selectors. 2014-10-10 14:29:24 +01: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
Tim Taubert
b9e23563bb Support [*|attr], attribute selectors in any namespace (fixes #1558) 2014-10-08 11:01:31 +02:00
Simon Sapin
cf1785ecb1 Read user-agent.css at run time. Fix #3516 2014-10-07 21:16:54 +01:00
Patrick Walton
a4352b1da2 style: Remove max-height from the input style.
Some pages, like Google, want to set height explicitly.
2014-10-07 11:21:50 -07:00
bors-servo
4475cbe7e8 auto merge of #3548 : glennw/servo/remove-encodable, r=jdm 2014-10-06 23:51:35 -06:00
Glenn Watson
01be57cfae Remove manual encodable implementation. Fixes #3425. 2014-10-07 08:00:23 +10:00