Commit graph

51 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
bd70c405b4
style: Rename StyleContext to ComputedStyle.
Bug: 1447483
Reviewed-by: jwatt
MozReview-Commit-ID: KATZ6DkmpVY
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2018-03-22 18:04:29 +01:00
Emilio Cobos Álvarez
2e08ab1492
style: Handle correctly nested links.
Followup to #19935, since I'm dumb and missed that orange.
2018-02-03 20:45:56 +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
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
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
bors-servo
7b92eb932b Auto merge of #19760 - emilio:ruby-display-adjust, r=upsuper
style: Ruby style adjustments shouldn't reset mOriginalDisplay.

This matches what Gecko does:

  https://searchfox.org/mozilla-central/rev/7476b71e0010ab3277b77cc0ae4d998c4b1d2b64/layout/style/GeckoStyleContext.cpp#992

And it's conceptually more right, since we ideally shouldn't mutate
mOriginalDisplay from StyleAdjuster.

<!-- 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/19760)
<!-- Reviewable:end -->
2018-01-13 13:16:06 -06:00
Emilio Cobos Álvarez
72e62fe308
style: Ruby style adjustments shouldn't reset mOriginalDisplay.
This matches what Gecko does:

  https://searchfox.org/mozilla-central/rev/7476b71e0010ab3277b77cc0ae4d998c4b1d2b64/layout/style/GeckoStyleContext.cpp#992

And it's conceptually more right, since we ideally shouldn't mutate
mOriginalDisplay from StyleAdjuster.
2018-01-13 13:21:58 +01:00
Emilio Cobos Álvarez
76f22adccc
style: Adjust the writing-mode fixup to call set_adjusted_display on Servo.
This is functionally equivalent right now (set_adjusted_display will just do
set_display), but won't be after #19709.
2018-01-13 12:57:02 +01: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
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
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
f6d0a14246
style: Don't adjust :visited styles.
As the comment says those are not interesting, and it matches what we do for
text and placeholders in Servo_ComputedValues_Inherit.

This fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1425893
2017-12-18 22:48:02 +01: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
Bastien Orivel
29b4eec141 Bump bitflags to 1.0 in every servo crate 2017-10-30 23:36:06 +01:00
Gecko Backout
11c64178d8 Backed out changeset e64e659c077d: servo PR #18809 and revendor for reftest failures, e.g. in layout/reftests/bugs/392435-1.html. r=backout on a CLOSED TREE
Backs out https://github.com/servo/servo/pull/18809
2017-10-19 21:26:51 +00:00
Bastien Orivel
e8e2d0a4b2 Update bitflags to 1.0 in every servo crate
It still needs dependencies update to remove all the other bitflags
versions.
2017-10-19 15:01:17 +02:00
Matt Brubeck
efc3683cc7 Fix commonmark Markdown warnings in docs, part 1
Fixes warnings from rust-lang/rust#44229 when `--enable-commonmark` is
passed to rustdoc.

This is mostly a global find-and-replace for bare URIs on lines by
themselves in doc comments.
2017-10-17 11:24:57 -07:00
Emilio Cobos Álvarez
7d2e2e25d6
style: Handle correctly display changes from ruby to non-ruby in some edge cases.
And add comments to the reset-property-dependent adjustments.

MozReview-Commit-ID: Li6Epx8k5x8
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-09-06 12:56:34 +02:00
Emilio Cobos Álvarez
deefacc9de
style: Reindent some code.
MozReview-Commit-ID: H2qucldbBkc
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-09-06 12:56:33 +02:00
Simon Sapin
35282042bc geckolib: Fix some warnings (treated as error) new in Rust Nigthly 2017-08-17 15:59:33 +02:00
Simon Sapin
b5a4b8d6a0 Upgrade to rustc 1.21.0-nightly (13d94d5fa 2017-08-10) 2017-08-15 14:10:44 +02:00
Emilio Cobos Álvarez
3e2d87d8db
style: Simplify the ruby text adjustment.
StyleBuilder keeps a reference to the parent style, so no need to get it as an
argument.
2017-08-15 07:49:54 +02:00
Xidorn Quan
89ba3553dc Apply line break suppression to text when in any ruby 2017-08-15 09:32:39 +10:00
Boris Chiou
191c2a282b Bug 1374233 - Part 2: Add NonNegativeAu.
Add values::computed::NonNegativeAu, so BorderSideWith could be computed
to this non-negative Au, for the following properties:
1. outline-width
2. border-{*}-width
3. column-rule-width
4. -webkit-text-stroke-width

MozReview-Commit-ID: ASHaB2F7VtM
2017-08-04 14:21:57 +08:00
Emilio Cobos Álvarez
6c5cf5e2ec
style: Move nsStyleContext::mParent to GeckoStyleContext.
Unfortunately this means that we lose the NS_STYLE_INHERIT_BIT optimization to
avoid posting changes if we had not requested the struct. In practice, I'm not
sure this optimization matters much, though, and we already compare all the
structs anyway.

We _could_ keep a weak parent pointer from the text style if needed, given we're
going to keep alive the text style at least until the parent style context goes
away, so should be safe, but I don't think the extra churn is worth it, to be
honest. Happy to do so as part of bug 1368290 if you think it's worth it.

Bug: 1385896
Reviewed-by: heycam
MozReview-Commit-ID: ka6tNwf4Ke
2017-08-03 12:46:51 +02:00
Emilio Cobos Álvarez
2d9255bff1
style: Get rid of GetParentAllowServo in implementation of CSS 'justify-items' property.
Bug: 1384542
Reviewed-by: heycam
MozReview-Commit-ID: 4qydjqSoVXs
2017-07-31 11:55:04 +02:00
Boris Zbarsky
648c0a3d0b Remove the inherited_style getter from StyleBuilder.
The concept of inherited style is about to get a bit more complicated, and this
will prevent consumers from doing it wrong.

Part 1 of Gecko bug1382806.  r=emilio
2017-07-26 13:40:02 -04:00
Emilio Cobos Álvarez
04e855c38d
style: Fix relevant-link-visited logic in presence of nested links.
MozReview-Commit-ID: LIjpTAgrPBY
2017-07-23 22:12:47 +02:00
Emilio Cobos Álvarez
4e0492c5d1
style: Move the RELEVANT_LINK_VISITED flag to servo.
And kill one GetParentAllowServo call while at it, and some other dumbness...

Bug: 1383307
Reviewed-by: Manishearth
2017-07-23 05:22:18 +02:00
Emilio Cobos Álvarez
b576229567
stylo: Set the NS_STYLE_IS_TEXT_COMBINED flag.
This should fix at least
layout/reftests/writing-mode/1135361-ruby-justify-1.html
2017-07-22 02:29:36 +02:00
Emilio Cobos Álvarez
3f323dde10
style: Move a conditional import to where it's used.
To avoid yet another cfg().
2017-07-21 17:41:56 +02:00
Emilio Cobos Álvarez
e374a54050
style: Cleanup the cascade a good bit. 2017-07-20 11:20:37 +02:00
Emilio Cobos Álvarez
fe8638a618
style: More ComputedValuesInner cleanup.
MozReview-Commit-ID: 8rkAP3pMEpD
2017-07-18 17:35:59 +02:00
Xidorn Quan
bae59d4520 Adjust display value for ::-moz-fieldset-content when parent is flex/grid. 2017-07-18 14:13:12 +10:00
Manish Goregaokar
808b1f509b stylo: Use ComputedValuesInner instead of ComputedValues when we don't need it 2017-07-17 18:02:25 -07:00
Xidorn Quan
6a12de1c1a Add style adjustments for ruby. 2017-07-14 10:53:58 +10:00
Xidorn Quan
fcf37b19fd Move HAS_TEXT_DECORATION_LINES setting into StyleAdjuster. 2017-07-14 10:53:50 +10:00
Xidorn Quan
8b842f5417 Use integer for specified and computed font-weight 2017-07-06 15:31:24 +10:00
Emilio Cobos Álvarez
1b2fd3fe85
style: Be more strict when setting the root font size.
Before this commit, we assumed that if the element had no parent element, it was
the root of the document, which is plain false, since we can arrive there from,
let's say, getComputedStyle on a detached node.

Bug: 1374062
Reviewed-By: heycam
MozReview-Commit-ID: 65DxdzXgd0J
2017-06-21 13:28:57 +02:00
Cameron McCormack
4315cecdf4 style: Tweak an import. 2017-06-16 11:31:45 +08:00
Cameron McCormack
36e4d0a511 style: Adjust display:contents to display:inline for NAC (including ::before/::after). 2017-06-16 09:37:57 +08:00
Boris Zbarsky
8125cf89b4 mathvariant attributes should affect computed font style and weight in stylo. 2017-05-24 16:29:50 -04:00
Emilio Cobos Álvarez
3ec2b4f486
style: Adjust text-align properly for -moz- values in tables.
Fixes bug 1363576.

Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-05-10 12:59:14 +02:00
Emilio Cobos Álvarez
3b857f1c4e
style: Add a StyleBuilder struct to avoid refcount and atomic CAS during the cascade.
This should fix most of the complaints that caused
https://bugzilla.mozilla.org/show_bug.cgi?id=1360889 to be open, and also fix a
bunch of other FIXMEs across the style system.
2017-04-30 23:45:40 +02:00
Emilio Cobos Álvarez
5cbc6a9b16
Bug 1360508: Adjust text-combine properly. r=jryans
Text style is always resolved via ServoStyleSet::ResolveStyleForText, either
from the frame constructor initially, or from
ServoRestyleManager::ProcessPostTraversalForText.

So text-only adjustments should go there instead. Since that doesn't call into
cascade(), all the code that passes `pseudo` there is dead code we can remove.

MozReview-Commit-ID: jpbBYpLlUL
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-04-28 17:21:10 +02:00
J. Ryan Stinnett
a5907e03c9 Tweak style adjust ordering to better match Gecko
To ease comparison between Gecko's `nsStyleContext::ApplyStyleFixups` and the
Servo equivalent, move them into a similar ordering.

MozReview-Commit-ID: GV89pbzA8IH
2017-04-27 11:40:00 -05:00
J. Ryan Stinnett
676d177f17 Extra spec comments for style adjustments
MozReview-Commit-ID: J6qxBpQ43Ax
2017-04-27 11:39:59 -05:00
J. Ryan Stinnett
978239927d Port text-combine-upright writing mode fixup to Servo
Ports the Gecko fixup for text-combine-upright writing mode to Servo.  In
addition, this passes the current pseudo element (if any) down to the cascade
for use during the fixup process.

MozReview-Commit-ID: BkHd4AvSsOt
2017-04-27 11:39:59 -05:00