Commit graph

258 commits

Author SHA1 Message Date
Ting-Yu Lin
4c9d8d36ad Simply element bounds in stylist
TElement already inherits from Debug and PresentationalHintsSynthesizer.
2017-05-10 11:28:31 -07:00
Ting-Yu Lin
dd5f73750c Fix typo for PresentationalHintsSynthesizer 2017-05-10 11:28:26 -07:00
Boris Zbarsky
fb5b587371 Split up Stylist's update() method into separate clear() and rebuild() methods.
This is part 1 of the fix for https://bugzilla.mozilla.org/show_bug.cgi?id=1361843
2017-05-10 13:11:01 -04:00
Emilio Cobos Álvarez
46bf5d61f0
Bug 1355343: Take all the snapshots into account. r=bholley
I've chosen this approach mainly because there's no other good way to guarantee
the model is correct than holding the snapshots alive until a style refresh.

What I tried before this (storing them in a sort of "immutable element data") is
a pain, since we call into style from the frame constructor and other content
notifications, which makes keeping track of which snapshots should be cleared an
which shouldn't an insane task.

Ideally we'd have a single entry-point for style, but that's not the case right
now, and changing that requires pretty non-trivial changes to the frame
constructor.

MozReview-Commit-ID: FF1KWZv2iBM
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-05-10 12:05:39 +02:00
Matt Brubeck
32d37795a2 Bug 1349651 - stylo: Implement HasAuthorSpecifiedRules. 2017-05-09 10:01:46 -07:00
Fernando Jiménez Moreno
b22e0e9494 Stylo: Bug 1355408 - add support for @-moz-document 2017-05-09 12:52:44 +02:00
Bobby Holley
1fb9108daf Use a rule hash for revalidation selectors.
MozReview-Commit-ID: 1mTZcfMxaw8
2017-05-05 10:48:24 -07:00
Bobby Holley
a6fe7bea5e Generalize SelectorMap.
MozReview-Commit-ID: HX4EcLurrr8
2017-05-05 10:48:18 -07:00
Bobby Holley
d78ca4c4f9 Use StyleArc in the style system.
MozReview-Commit-ID: flF0fv9E9M
2017-05-02 17:35:44 -07:00
bors-servo
e92a79619e Auto merge of #16670 - emilio:sharing-is-sometimes-hard, r=bholley
style: Account for cousin sharing in the revalidation logic.

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1361013

<!-- 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/16670)
<!-- Reviewable:end -->
2017-05-01 14:20:43 -05:00
Emilio Cobos Álvarez
e09ae428eb
style: Account for cousin sharing in the revalidation logic.
Fixes bug 1361013.
2017-05-01 20:22:16 +02:00
Hiroyuki Ikezoe
7a01a5f5c4 There is no need to clone for animation/transition declaration block.
Because it's a newly created Arc<Locked<PropertyDeclarationBlock> in
get_animation_rule.
2017-05-01 19:23:40 +09:00
Bobby Holley
71ecff849b Use a single rule hash for both lower_name and name.
Right now in the common case we're doing twice the work during stylist update,
and also checking is_html_element_in_html_document twice during lookup. This
patch aligns us with what Gecko does.

MozReview-Commit-ID: D4TyG30BP8C
2017-04-29 16:07:41 -07:00
Bobby Holley
080ff126b5 Factor out the various things stylist does per-selector into helpers.
This makes things more readable, and easier to profile (since the Gecko
profiler doesn't have any intra-function granularity, so I tend to make
helpers non-inline when drilling down into what's expensive).

It allows us to iterate the selector list once, which could help cache locality
for rules with many selectors.

MozReview-Commit-ID: GdFtgrbYCIu
2017-04-29 16:07:40 -07: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
bors-servo
d8bcc0db1a Auto merge of #16609 - nox:quirks, r=Manishearth,emilio
Implement unitless length quirk

The Gecko side doesn't propagate its quirks mode yet.

<!-- 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/16609)
<!-- Reviewable:end -->
2017-04-27 22:32:24 -05:00
Emilio Cobos Álvarez
7a556a7f03
Bug 1360399: Don't deduplicate revalidation selectors. r=bholley
It's unfortunate, but it's a correctness issue. I was looking at the
expectations update here:

 * https://hg.mozilla.org/integration/autoland/rev/659cddddd434

And investigating it I realised that it's wrong to coalesce selectors like that,
because we keep the bloom filter flags.

So in the test cases disabled, we have a selector that looks like this:

msub > :not(:first-child),
msup > :not(:first-child),
msubsup > :not(:first-child),
mmultiscripts > :not(:first-child) {
    -moz-script-level: +1;
    -moz-math-display: inline;
}

And an element that looks like this:

<msubsup><mi></mi><mi></mi></msubsup>

We're only inserting the first selector msub > :not(:first-child) into the set,
so when we're going to match the <mi> elements we fast-reject it in both cases
due to the bloom filter, so they share style.

I can't see an easy way to fix this keeping the deduplication. If we keep it, we
need to remove the bloom filter optimization, which means that we'd trash the
cache for every first-child in the document (the :not(:first-child) effectively
becomes a global rule).

MozReview-Commit-ID: 9VPkmdj9zDg
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-04-28 02:57:54 +02:00
Boris Zbarsky
c9fd747e69 Fix Stylist::lazily_compute_pseudo_element_style to return None when it should.
We have a fast path to return None if we have no rules for the pseudo-element at
all, but we should also return None if we have no _matching_ rules for it for
the given originating element.  This is relied on by consumers like
Servo_ResolvePseudoStyle, which needs to be able to detect the "no styles for
this pseudo-element for this originating element case", to support probing for
whether work for a specific pseudo-element should be done at all.
2017-04-27 16:00:40 -04:00
Bobby Holley
f4d81b010b Properly handle -moz-any for revalidation selectors.
Note that, while the comment is correct that there is a fair amount of -moz-any
usage in the UA sheet, it's always used as an ancestor selector, and thus ignored
for our purposes. Nevertheless, it's straightforward enough to support properly,
so we do that here.

MozReview-Commit-ID: Kz1yNfPUIaP
2017-04-27 11:13:11 -07:00
Bobby Holley
25832b962f Check for adjacent duplicates when accumulating revalidation selectors.
MozReview-Commit-ID: 4C8L5u1S1sL
2017-04-27 11:12:57 -07:00
Bobby Holley
7e69cf82be Store SelectorInner and only revalidate up to the rightmost ancestor combinator.
MozReview-Commit-ID: HiTGVhwuvCE
2017-04-27 11:12:51 -07:00
Bobby Holley
2df9dc2b03 Use a different visitor pass for gathering revalidation selectors.
This allows us to ignore everything to the left of the rightmost simple selector.

MozReview-Commit-ID: 6I4VzKos22n
2017-04-27 11:12:39 -07: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
Emilio Cobos Álvarez
be0139ff3c
Bug 1331047: Implement the new traversal semantics for stylo. r=bholley,hiro
MozReview-Commit-ID: 4BXx9JpGZKX
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-04-27 14:26:48 +02:00
Anthony Ramine
f68e2fded9 Propagate quirks mode all the way to ParserContext
The quirks mode is still not properly propagated in geckolib.
2017-04-27 10:41:55 +02:00
Brian Birtles
97ce9ed5b0 Add SMIL override cascade level 2017-04-27 12:35:12 +09:00
Anthony Ramine
f872fdac9a Make Stylist::quirks_mode hold a QuirksMode 2017-04-26 17:30:28 +02:00
Simon Sapin
1146921866 Keep custom-ident and string separate in animation/keyframes name. 2017-04-26 13:04:22 +09:00
Simon Sapin
d9c2d1a9fb Use CustomIdent for animation-name and @keyframes 2017-04-26 13:02:16 +09:00
Simon Sapin
7fe57ecaea Rename StdoutErrorReporter to RustLogReporter. 2017-04-24 08:23:41 +02:00
Bobby Holley
60f846b2ca Remove unused StyleRelations.
MozReview-Commit-ID: ed0NiuY9Ek
2017-04-23 12:41:21 -07:00
Bobby Holley
1d6763c8e9 Avoid pointer-chasing to check whether there are any declarations. 2017-04-21 17:28:10 -07:00
Hiroyuki Ikezoe
973d8287a9 Support vendor prefix keyframes rule.
If there are multiple prefixed/non-prefixed @keyframes with the same name;

* non-prefixed rule overrides earlier rules.
* prefixed rule overrides earlier prefixed rules.
2017-04-21 12:18:12 +09:00
Bobby Holley
cebacc7faa Rename SimpleSelector to Component.
MozReview-Commit-ID: JfaZpHSkG8h
2017-04-20 15:04:48 -07:00
Bobby Holley
6d66ec5e11 Store selectors and combinators inline in a single sequence.
This improves cache locality and reduces allocations during parsing.

Note that this reverses the iteration order within a sequence of simple selectors,
but that shouldn't matter.
2017-04-20 15:00:43 -07:00
bors-servo
5274991545 Auto merge of #16516 - emilio:stylesheet-handling, r=bholley
stylo: Centralize stylesheet handling.

This is needed for both bug 1357461 and bug 1273303, where I plan to add smarter
invalidations than what we have now.

Also, it's cleaner.

Ideally I'll move this onto stylist, though that may require extra work to make
it work fine for Servo, so for now let's just do the obvious thing.

<!-- 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/16516)
<!-- Reviewable:end -->
2017-04-19 03:41:08 -05:00
Emilio Cobos Álvarez
4651b94ff0
style: Simplify author_style_disabled handling. 2017-04-19 09:41:37 +02:00
Bobby Holley
9524c5cb57 Introduce SelectorInner and use it for top-level matching.
MozReview-Commit-ID: DxG6USsPIkh
2017-04-18 20:07:53 -07:00
Hiroyuki Ikezoe
bd066af640 Add an FFI which returns computed values for a given declaration block with/without parent_style. r?heycam
The function uses document's default computed values if the parent style
is not specified.
2017-04-15 13:21:20 +09:00
Brad Werth
91a9fb06c7 Add an author_style_disabled flag to stylist.update, and associated structs.
MozReview-Commit-ID: FiXyEN4xVnU
2017-04-14 09:24:20 +08:00
Bobby Holley
687ea0ef9e Add more useful statistics to DUMP_STYLE_STATISTICS. 2017-04-13 13:43:05 +08:00
Emilio Cobos Álvarez
9e33cd5643
style: Simplify dependency visitor, avoid tracking dependencies of nested complex selectors separately. 2017-04-13 01:01:00 +08:00
Bobby Holley
d50946933d Set selector flags when matching elements against revalidation selectors. 2017-04-12 10:35:44 +08:00
Bobby Holley
1663bf6e5d Cache the results of cache entry revalidation and use the bloom filter. 2017-04-12 10:35:42 +08:00
Bobby Holley
d51d95d0c7 Merge style_affecting_attributes_selectors with selectors_for_cache_revalidation. 2017-04-12 09:32:14 +08:00
Bobby Holley
6515f78f6d Check for empty when determining what selectors to use for revalidation. 2017-04-12 09:32:06 +08:00
bors-servo
d77d752990 Auto merge of #16316 - Manishearth:stylo-threadsafe, r=emilio
stylo: Make font base size computation threadsafe

r=emilio https://bugzilla.mozilla.org/show_bug.cgi?id=1351200

<!-- 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/16316)
<!-- Reviewable:end -->
2017-04-09 06:15:51 -05:00
Manish Goregaokar
e402c72d0e stylo: Store font metrics provider in thread local style context 2017-04-09 19:15:35 +08:00
Emilio Cobos Álvarez
0ea58d1ffa
style: Stop special-casing a few attributes for style sharing, and use a visitor to track dependencies.
Also, simplify all the pre-snapshot attribute hacks in the script and style
code.

MozReview-Commit-ID: 6c9ipeb7Tnr
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-04-09 18:15:50 +08:00
Bobby Holley
1ff008caa3 Improve some ergonomics around pseudo-elements.
I think a lot of the current indirection predates the crate merge.

MozReview-Commit-ID: FM28dgZa5go
2017-04-03 12:35:14 -07:00