Commit graph

591 commits

Author SHA1 Message Date
Anthony Ramine
42ea822edf Make LonghandId just be the discriminants of PropertyDeclaration 🐉🐲
This relies on the fact that `#[repr(u16)]` on enums ensure the discriminant will
be the very first field of the enum value. This has always been the case, but it
has been formally defined only since https://github.com/rust-lang/rfcs/pull/2195.

https://bugzilla.mozilla.org/show_bug.cgi?id=1428285
2018-02-06 14:11:14 +01:00
Anthony Ramine
1ec5164900 Generate PropertyDeclaration just after processing all the Mako files 2018-02-06 13:46:33 +01:00
Anthony Ramine
7f98d8e017 Implement Clone for PropertyDeclaration by hand 🐉🐲
This makes the enum `#[repr(u16)]` and generate code that shares the same
Clone::clone call for all variants sharing the same field type.
2018-02-06 13:45:52 +01:00
Anthony Ramine
5195eb38f2 Make all PropertyDeclaration variants have only one field 2018-02-06 13:45:18 +01:00
Anthony Ramine
3918c983e1 Use LonghandId::is_animatable in PropertyDeclaration::is_animatable 2018-02-04 23:23:21 +01:00
Anthony Ramine
90b37cfa21 Use less type aliases from longhands in PropertyDeclaration
This will help us reuse code between different variants in a later patch,
to implement Clone by hand to optimise it.
2018-02-04 22:57:53 +01:00
Emilio Cobos Álvarez
349d6e7167
style: Cleanup StyleBuilder.
This is in preparation of a cascade optimization for custom properties.

This fixes various fishiness around our StyleBuilder stuff. In particular,
StyleBuilder::for_derived_style (renamed to for_animation) is only used to
compute specified values, and thus doesn't need to know about rules, visited
style, or other things like that.

The flag propagation that was done in StyleAdjuster is now done in StyleBuilder,
since we know beforehand which ones are always inherited, and it simplified the
callers and the StyleAdjuster code. It also fixed some fishiness wrt which flags
were propagated to anon boxes and text.

The text-decoration-lines bit is interesting, because the way it was implemented
in #17722 meant that display: contents elements did get HAS_DECORATION_LINES
flags only if its parent also had it, so in practice the Contents check
preserves behavior, but it's only an optimization looking at Gecko's call-sites,
so we can remove it too.

MozReview-Commit-ID: 6BHCyEO2U8c
2018-02-03 18:07:25 +01:00
Emilio Cobos Álvarez
7fb470c373
style: Remove some uses of StyleBuilder::for_derived_style.
for_derived_style(default_values) is effectively for_inheritance(default_values).

MozReview-Commit-ID: DfTeD49uTlp
2018-02-03 17:40:35 +01:00
bors-servo
6b2e5283c9 Auto merge of #19838 - servo:rm-sequence-writer-as-it-was, r=emilio
Make ToCss' SequenceWriter not monomorphise like a maniac anymore

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19838)
<!-- Reviewable:end -->
2018-01-23 12:03:41 -06:00
Emilio Cobos Álvarez
cd04664fb9
style: Use CascadeFlags for what they're for.
Now that we have an Element around on cascade, we can stop using the cascade
flags mechanism to pass various element-related state, like "is this element the
root", or "should it use the item-based display fixup".

That fixes handwaviness in the handling of those flags from style reparenting,
and code duplication to handle tricky stuff like :visited.

There are a number of other changes that are worth noticing:

 * skip_root_and_item_based_display_fixup is renamed to skip_item_display_fixup:

   TElement::is_root() already implies being the document element, which by
   definition is not native anonymous and not a pseudo-element.

   Thus, you never get fixed-up if your NAC or a pseudo, which is what the code
   tried to avoid, so the only fixup with a point is the item one, which is
   necessary.

 * The pseudo-element probing code was refactored to return early a
   Option::<CascadeInputs>::None, which is nicer than what it was doing.

 * The visited_links_enabled check has moved to selector-matching time. The rest
   of the checks aren't based on whether the element is a link, or are properly
   guarded by parent_style.visited_style().is_some() or visited_rules.is_some().

   Thus you can transitively infer that no element will end up with a :visited
   style, not even from style reparenting.

Anyway, the underlying reason why I want the element in StyleAdjuster is because
we're going to implement an adjustment in there depending on the tag of the
element (converting display: contents to display: none depending on the tag), so
computing that information eagerly, including a hash lookup, wouldn't be nice.
2018-01-23 13:18:54 +01:00
Anthony Ramine
cd8f96cc9e Change ToCss to take a CssWriter<W>
This more concrete wrapper type can write a prefix the very first time something
is written to it. This allows removing plenty of useless monomorphisations caused
by the former W/SequenceWriter<W> pair of types.
2018-01-23 10:41:42 +01:00
Emilio Cobos Álvarez
5ac12b5df4
style: Make the TElement type arrive to the cascade function.
Not super-proud of this one, but it's the easiest way I could think of.

The changeset looks bigger than what it is, because while at it I've rewrapped a
fair amount of functions around to use proper block indentation.

Alternatives are parameterizing Stylist by <E>, which is not fun, or moving the
concrete element from layout_thread to layout, but that implies layout depending
on script, which isn't fun either.

Other alternative is implementing an empty enum and making anon boxes work on
it. It has the advantage of removing the annoying type parameter, but the
disadvantage of instantiating `cascade` twice, which isn't great, and having to
maintain all the boilerplate of a `TElement` implementation that just does
nothing.
2018-01-23 00:57:54 +01:00
Bobby Holley
5526947500 Avoid the generic writer parameter for PropertyDeclaration serialization.
MozReview-Commit-ID: JR3IcL1NRHO
2018-01-22 14:58:05 -08:00
Emilio Cobos Álvarez
c4ae2148f0
style: Remove -moz-border-*-colors.
Bug: 1429723
Reviewed-by: xidorn
MozReview-Commit-ID: 3P6f7rFcDa6
2018-01-22 16:12:35 +01:00
Emilio Cobos Álvarez
e858dc060e
style: Special-case pseudo style attributes to avoid ignoring doc colors.
That way color pickers work even when this setting is on. We always know that
pseudo-element style attributes are trusted.

Bug: 1429248
Reviewed-by: heycam
MozReview-Commit-ID: 6IdmRaMzj6I
2018-01-17 14:35:42 +01:00
Emilio Cobos Álvarez
9dc25ed214
style: Remove "derived" properties and the concept of "custom cascade". 2018-01-14 17:10:44 +01:00
Emilio Cobos Álvarez
8732a1d7de
style: Remove -servo-text-decorations-in-effect.
It is bogus, because it depends on the display property as it's cascaded, but
the display property can change afterwards, for example, if we get blockified
because we're the root element or a flex item.

Replace it with a normal field instead.

Also, it carries some weight, because it's the last property that uses this
concept of "derived" property, and "custom cascade". So we can remove some code
after this.

Compute it after the cascade process in StyleAdjuster.
2018-01-14 17:10:44 +01:00
CYBAI
0291a75b3c style: Remove -servo-display-for-hypothetical-box from longhand 2018-01-13 20:54:50 +08:00
bors-servo
83a8891bd4 Auto merge of #18893 - emilio:bye-can-be-fragmented, r=SimonSapin
style: Remove TNode::set_can_be_fragmented and TNode::can_be_fragmented.

Replace them instead by a computed value flag, the same way as the
IS_IN_DISPLAY_NONE_SUBTREE flag works.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18893)
<!-- Reviewable:end -->
2018-01-05 05:11:00 -06:00
bors-servo
6131371cc2 Auto merge of #19696 - upsuper:rule-cache-opt, r=emilio
Skip rule node which contains only inherited properties for rule cache

This is one possible fix for [bug 1427681](https://bugzilla.mozilla.org/show_bug.cgi?id=1427681) which tries to skip some rule nodes when using rule cache.

Try push for correctness: https://treeherder.mozilla.org/#/jobs?repo=try&revision=74e3941e2cfc5fba4bce839f2518af8a5a8b7411

It doesn't really show much memory saving on awsy. It only shows several KB save on fresh start memory. But since conceptually it's simple, I guess it's worth taking.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19696)
<!-- Reviewable:end -->
2018-01-05 03:35:04 -06:00
Xidorn Quan
3593392788 Skip rule node which contains only inherited properties for rule cache. 2018-01-05 11:29:01 +11:00
Hiroyuki Ikezoe
a4e687aedd Drop animation-name and transition-property from early properties
We don't need to calculate computed animation-name or transition-property prior
to other properties any more because we no longer fill out those other
properties values in response to animation-name or transition-property length
at the time when we calculate computed property values.
2018-01-05 07:02:05 +09:00
Emilio Cobos Álvarez
f3ea248188
style: Remove TNode::set_can_be_fragmented and TNode::can_be_fragmented.
Replace them instead by a computed value flag, the same way as the
IS_IN_DISPLAY_NONE_SUBTREE flag works.
2018-01-04 14:45:54 +01:00
Emilio Cobos Álvarez
10a1e1e15f
style: Simplify some ComputedValueFlags setters. 2018-01-04 14:45:38 +01:00
Emilio Cobos Álvarez
bab6077c1c
Revert #19666 since we do create NAC elements and expect them to be inline.
This reverts commit 1970e82b0d, reversing
changes made to e882660ea6.

The reparenting logic is still bogus, but I'll figure out how to deal with that
in a bit.
2017-12-31 17:00:26 +01:00
Emilio Cobos Álvarez
e464f5b020
style: Simplify the skip item based display fixup adjustment.
In practice the only NAC that possibly inherits from a grid or flex container
are pseudos.

In Gecko, if the root element is an item container, custom anon content would
also sometimes incorrectly inherit from that (see bug 1405635), but that's fixed
in Stylo.

We remove the IS_ROOT_ELEMENT blockification from the "skip display fixup"
check, since the root element is never NAC or anything like that, so there's no
need for the check.

This also fixes some reparenting fishiness related to pseudo-elements. We were
only skipping the fixup when reparenting anon boxes, not when reparenting normal
element styles, nor when reparenting other pseudo styles which are not anon
boxes.
2017-12-31 13:57:49 +01:00
Emilio Cobos Álvarez
bc2ef519ca
style: Renumber CascadeFlags bits. 2017-12-31 09:17:00 +01:00
Emilio Cobos Álvarez
a747de1814
style: Simplify "prohibit display: contents" adjustment.
On top of #19661.

The NAC condition is pointless because NAC don't match author rules unless they
are a pseudo-element too.
2017-12-31 09:17:00 +01:00
Emilio Cobos Álvarez
563da3a19c
style: Simplify ::-moz-fieldset-content special-casing.
The style adjuster knows about the pseudo, so there's no reason to thread that
info down.

There are more simplifications that can be done in followups, cleaning a bit the
cascade flags too, those will come later.
2017-12-30 22:08:04 +01:00
Emilio Cobos Álvarez
dbf0183b0f
style: Use ? in Option more often. 2017-12-09 20:26:09 +01:00
Matt Brubeck
99c2db0549 Update to uluru 0.2 and arrayvec 0.4 2017-12-07 10:05:38 -08:00
Emilio Cobos Álvarez
af879523ea
style: Make all keywords CamelCase for consistency.
This prevents confusion and paves the ground for derive(Parse) of them.
2017-12-06 02:35:10 +01:00
Emilio Cobos Álvarez
2bbeda97d3
style: Inline some things that should never ever appear in a profile. 2017-12-01 20:04:33 +01:00
bors-servo
df50a9a81c Auto merge of #19391 - emilio:early-props-docs, r=upsuper
style: Add a comment about why early properties are early.

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19391)
<!-- Reviewable:end -->
2017-11-27 17:42:50 -06:00
Emilio Cobos Álvarez
5887e1e55c
style: Move get_writing_mode outside of mako, and add a pointer to it. 2017-11-27 21:14:53 +01:00
Emilio Cobos Álvarez
cf45a45e18
style: Add a comment about why early properties are early. 2017-11-27 20:12:59 +01:00
Emilio Cobos Álvarez
7a5a35f5e0
style: Fix indentation of multiple CssParserContext construction. 2017-11-27 15:35:16 +01:00
Emilio Cobos Álvarez
4c02ad00ef
style: Don't insert into the seen set before ignoring document colors.
Otherwise we may stop honoring other colors in other cascade levels.

Fixes: #19370
2017-11-25 02:08:48 +01:00
Emilio Cobos Álvarez
90ba75ab44
style: Perform variable substitution less often.
We're wasting a bunch of work unneedlessly.
2017-11-24 22:53:44 +01:00
Emilio Cobos Álvarez
8de554f334
style: Move property allowance tests to PropertyId::parse_into.
It's not only more consistent (since we have a proper ParserContext there), but
also fixes a bunch of bugs where Gecko accidentally exposes and allows setting
internal state because of conversions from nsCSSPropertyID to PropertyId.

This adds the extra complexity of caring about aliases for longer, but that's
probably not a big deal in practice, since we also have PropertyDeclarationId.

MozReview-Commit-ID: C2Js8PfloxQ
2017-11-21 14:26:16 +01:00
Emilio Cobos Álvarez
c7a3c929f6
style: Enable chrome-only CSS features in user stylesheets.
MozReview-Commit-ID: FJ4vTiOrotH
Reviewed-by: heycam
Bug: 1418963
2017-11-21 10:59:47 +01:00
Emilio Cobos Álvarez
01e41d0439
style: Replace "internal" properties with "enabled_in"
This allows enabling properties in ua sheets and chrome differently.

The setup is:

  * enabled_in needs to be one of the four values:
    ["", "ua", "chrome", "content"]

  * "chrome" implies "ua", and implies that they're explicitly enabled.

  * "" implies the property will never be parsed.

  * "content" implies the property is accessible unconditionally, modulo a pref.

Experimental still keeps trumping over those when the pref is enabled.

This PR replaces uses of internal="" by enabled_in="ua" or enabled_in="".

This may seem that it changes behavior, but since the properties where I added
enabled_in="" already unconditionally error from parse it's not.

Next step is annotating chrome-only properties.
2017-11-18 05:15:19 +01:00
Emilio Cobos Álvarez
bbfb7a47eb
style: Add machinery to handle properties enabled in chrome. 2017-11-16 21:00:44 +01:00
Emilio Cobos Álvarez
2bd91d21d7
style: Replace Gecko's hacky EXPERIMENTAL set with the same mechanism as servo.
We can remove the PREF_foo bits in a bit.
2017-11-16 14:31:36 +01:00
Emilio Cobos Álvarez
187d28c732
style: Add gecko_pref annotation to the properties. 2017-11-16 02:44:35 +01:00
Emilio Cobos Álvarez
f4683d1718
style: Change experimental to servo_pref. 2017-11-16 02:44:13 +01:00
Keith Yeung
6f59a45cdc Move text-decoration-line out of mako 2017-11-14 13:13:23 -08:00
Manish Goregaokar
6631594e28
Replace old transform code with new generic code 2017-11-02 14:30:04 -07:00
Bastien Orivel
29b4eec141 Bump bitflags to 1.0 in every servo crate 2017-10-30 23:36:06 +01:00
Emilio Cobos Álvarez
b8021335d7
style: Ensure logical longhands appear before their physical counter-part.
Bug: 1410028
Reviewed-by: xidorn
MozReview-Commit-ID: KPIbt1e2Eq
2017-10-23 08:37:49 +02:00