Commit graph

145 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
ad602a0fa8
style: Export a size to fix a test that was trying to use a now-private type. 2020-04-23 05:07:02 +02:00
Emilio Cobos Álvarez
b80d79863c style: Fix some rebase messups from the rule tree refactoring.
This code was all long gone already from Gecko :)
2020-04-18 03:48:21 +02:00
Anthony Ramine
a30da7ad8e Introduce a new type UnsafeBox<T> in the rule tree
This lets us rely less on raw pointers, thus better tracking the lifetime
of the rule node values while dropping strong references etc.
2020-04-17 12:41:10 +02:00
Anthony Ramine
fb28ce6bbe Make StrongRuleNode::ensure_child take a StrongRuleNode for the root 2020-04-17 12:41:09 +02:00
Anthony Ramine
e5cb3d2a4c Move the meat of the rule tree to a submodule "core" 2020-04-17 12:41:08 +02:00
Anthony Ramine
1ea6a0cdd4 Move CascadeLevel to its own rule_tree submodule 2020-04-17 11:43:39 +02:00
Anthony Ramine
13db0c1584 Refactor rule tree children
We move the data structure to its own module for better
encapsulation of unsafe code.
2020-04-17 11:43:38 +02:00
Emilio Cobos Álvarez
414edb5a4a style: Simplify the implementation of HasAuthorSpecifiedRules.
This patch computes the author-specified properties during the CSS cascade, and
removes the complex rule-tree-based implementation that tries to do the cascade
again.

This changes behavior in two ways, one of them which is not observable to
content, I believe:

 * revert now re-enables the native styling. This was brought up in
   https://github.com/w3c/csswg-drafts/issues/4777 and I think it is a bug-fix.

   This is observable to content, and I'm adding a test for it.

 * We don't look at inherited styles from our ancestors when `inherit` is
   specified in a non-author stylesheet. This was introduced for bug 452969 but
   we don't seem to inherit background anymore for file controls or such. It
   seems back then file controls used to have a text-field.

   I audited forms.css and ua.css and we don't explicitly inherit
   padding / border / background-color into any nested form control.

We keep the distinction between border/background and padding, because the later
has some callers. I think we should try to align with Chromium in the long run
and remove the padding bit.

We need to give an appearance to the range-thumb and such so that we can assert
that we don't call HasAuthorSpecifiedRules on non-themed stuff. I used a new
internal value for that.

Differential Revision: https://phabricator.services.mozilla.com/D67722
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
c52bae1923 style: Remove an invalid assert.
This assert was wrong. The assert may fire if we resurrect the node from a
different thread and insert a kid fast enough.

We allow resurrecting nodes (bumping the nodes from zero to one) to avoid
allocation churn.

In particular, while the thread dropping the node gets to read the children (so
after the fetch_sub from the refcount, but before the read() of the children),
another thread could plausibly bumped the refcount back, and added a children.

This is a very big edge case of course, but I'm kinda sad I hadn't realized
before.

Differential Revision: https://phabricator.services.mozilla.com/D63286
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
071ce6f345
style: Rustfmt recent changes. 2020-02-12 02:43:23 +01:00
Emilio Cobos Álvarez
e227715aee
style: Miscellaneous Servo build fixes. 2020-02-12 02:43:23 +01:00
Emilio Cobos Álvarez
8c6fe09dce
style: Fix Servo build. 2020-02-12 02:43:22 +01:00
Emilio Cobos Álvarez
6876fed6e0
style: Fix two issues with themed widgets in high contrast mode.
There were two issues with the existing code that we use to determine whether a
widget is styled or not.

First, it was using `color == Color::transparent()` instead of
`color.is_transparent()` to check for transparent backgrounds. That is not sound
as `Color::transparent()` is the literal value `rgba(0, 0, 0, 0)`, not the
`transparent` keyword, so the equality check would fail.

The other issue is that this function was early-returning false if that check
was returning false. It is a bug for this function to early-return false, as it
makes the result of the function dependent of the order of the declarations.

Differential Revision: https://phabricator.services.mozilla.com/D62060
2020-02-12 02:43:21 +01:00
Emilio Cobos Álvarez
b038924d44
style: Try to collect some more crash information so that we can diagnose this better.
Differential Revision: https://phabricator.services.mozilla.com/D59704
2020-02-12 02:43:19 +01:00
Emilio Cobos Álvarez
d459e3453a
style: Make an assertion a release assert in nightly.
If this can happen legitimately, this will help fuzzers to catch it.

Differential Revision: https://phabricator.services.mozilla.com/D59066
2020-02-12 02:43:09 +01:00
Emilio Cobos Álvarez
ef16c5844f Rustfmt recent changes. 2019-12-16 14:23:56 +01:00
Emilio Cobos Álvarez
ad61cae6b0 style: Update smallvec to 1.0.
Differential Revision: https://phabricator.services.mozilla.com/D56044
2019-12-16 14:23:56 +01:00
Emilio Cobos Álvarez
006417e40a
style: Rustfmt recent changes. 2019-11-30 20:45:07 +01:00
Emilio Cobos Álvarez
1f2c1f555c
style: Optimize storage of ApplicableDeclaration again.
So that we don't regress perf.

Differential Revision: https://phabricator.services.mozilla.com/D52576
2019-11-30 20:44:59 +01:00
Emilio Cobos Álvarez
349492b5e2
style: Fix cascade order of shadow parts.
This moves the shadow cascade order into the cascade level, and refactors the
code a bit for that.

Differential Revision: https://phabricator.services.mozilla.com/D49988
2019-11-30 20:44:58 +01:00
Simon Sapin
c38c964f1b Upgrade to rustc 1.38.0-nightly (dddb7fca0 2019-07-30) 2019-07-31 13:34:01 +02:00
Emilio Cobos Álvarez
248b2ac829
style: Generate top-level function and constant declarations for the style crate.
This needs https://github.com/eqrion/cbindgen/pull/362, but I expect it to be
uncontroversial. I'll add a patch to this bug when it's merged to update it.

cbindgen historically didn't include these, but it turns out to be pretty useful
to generate constants for the style crate (since the binding crate is
`servo/ports/geckolib`).

An alternative is to get a completely different cbindgen-generated header for
these, but that seems a bit wasteful. This generates the constants with the
Style prefix (so we'll get `StyleMAX_GRID_LINE` for example), which is very
ugly. But we probably want to eventually stop using the Style prefix and use a
namespace instead, plus it's trivial to do `auto kMaxLine = StyleMAX_GRID_LINE`,
for example, so it's probably not a huge deal.

Another alternative would be to use associated consts, which _are_ generated by
cbindgen. Something like:

```
struct GridConstants([u8; 0]);
impl GridConstants {
    const MAX_GRID_LINE: i32 = 10000;
}
```

Which would yield something like:

```
static const int32 StyleGridConstants_MAX_GRID_LINE = 10000;
```

I'm not sure if you find it preferrable, but I'm also happy to change it in a
follow-up to use this.

We need to fix a few manual C++ function signature definitions to match the C++
declaration.

Differential Revision: https://phabricator.services.mozilla.com/D35197
2019-07-08 12:43:19 +02:00
Emilio Cobos Álvarez
ef99ab1f08
style: Report heap size of rule tree heap allocations as well.
Differential Revision: https://phabricator.services.mozilla.com/D33353
2019-06-25 13:11:25 +02:00
Emilio Cobos Álvarez
9721bd7d0d
style: Inline one child in the rule tree.
It is indeed the most common case according to a bit of measurement.

A non-atypical example from GitHub for example:

> Rule tree stats:
>  0 - 340
>  1 - 1403
>  2 - 28
>  3 - 8
>  4 - 2
>  6 - 1
>  7 - 3
>  8 - 2
>  12 - 2
>  14 - 1
>  41 - 1
>  45 - 1
>  67 - 1
>  68 - 1

Differential Revision: https://phabricator.services.mozilla.com/D33351
2019-06-25 13:11:25 +02:00
Emilio Cobos Álvarez
a40fd0bd5d
style: Add some very basic rule tree stats that can be enabled with trace-level logging.
This is useful to analyze the shape of the rule tree at a glance.

Differential Revision: https://phabricator.services.mozilla.com/D33350
2019-06-25 13:11:25 +02:00
bors-servo
0d5c6a0c37
Auto merge of #23532 - est31:unused_code_removal_4, r=emilio
Remove unused code (4/4)

<!-- Please describe your changes on the following line: -->

Fourth and final PR in a series of PRs to remove unused/dead code from servo, powered by an (upcoming) tool of mine. Please take a look and tell me if you want to keep something.

* First PR: #23477
* Second PR: #23498
* Third PR: #23499

Shortstat of the combined PR series:
```
47 files changed, 7 insertions(+), 805 deletions(-)
```

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors

<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because they only remove dead code

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/23532)
<!-- Reviewable:end -->
2019-06-07 20:27:53 -04:00
est31
642b7c3ea1 Remove unused code from selector and style crates 2019-06-07 15:14:21 +02:00
Emilio Cobos Álvarez
c155639bc5 style: Fix RuleNode::has_children_for_testing(). 2019-06-04 01:04:05 -04:00
Emilio Cobos Álvarez
390d03da70 style: Appease tidy. 2019-06-04 01:04:00 -04:00
Emilio Cobos Álvarez
665db79274 style: Rustfmt recent changes. 2019-06-04 01:03:59 -04:00
Emilio Cobos Álvarez
f623a6c045 style: Use a RwLock'd HashMap instead of a lock-free linked list for rule node children.
I need to profile this a bit more, but talos was pretty happy about this, and it
solves the known performance issues here such as the test-case from bug 1483963
for example. This also gets rid of a bunch of unsafe code which is nice.

This still keeps the same GC scheme, removing the key from the hashmap when
needed. I kept those as release assertions, but should probably be turned into
debug-only assertions.

Differential Revision: https://phabricator.services.mozilla.com/D6801
2019-06-04 01:03:55 -04:00
Emilio Cobos Álvarez
3652a0f1e1 style: Rejigger a bit rust features so that rusttests still link.
We cannot compile with just feature(gecko + debug_assertions), since that's how
debug rusttests get compiled and they don't have the refcount logging stuff.

We were getting away with it for the pre-existing usage of the style crate,
because it wasn't used during any test and presumably the linker didn't
complain. But servo_arc is definitely used in tests.

Differential Revision: https://phabricator.services.mozilla.com/D32691
2019-06-04 01:03:54 -04:00
Emilio Cobos Álvarez
9a9a4e12d5 style: Add refcount logging to servo_arc.
Differential Revision: https://phabricator.services.mozilla.com/D32173
2019-06-04 01:03:53 -04:00
Emilio Cobos Álvarez
ae32e4df40 style: Use an explicit stack to measure rule tree memory usage.
A patch of mine that makes us measure the rule tree more often triggers this.

Differential Revision: https://phabricator.services.mozilla.com/D26595
2019-04-12 12:20:04 +02:00
Emilio Cobos Álvarez
b268ef6aed style: Remove some redundant use statements. 2019-04-12 12:19:57 +02:00
Emilio Cobos Álvarez
5aeab7adb1 style: Reformat recent changes. 2019-03-13 15:08:38 +01:00
Emilio Cobos Álvarez
6fd17ccb35 style: Implement CSS revert keyword.
The only fishy bit is the animation stuff. In particular, there are two places
where we just mint the revert behavior:

 * When serializing web-animations keyframes (the custom properties stuff in
   declaration_block.rs). That codepath is already not sound and I wanted to
   get rid of it in bug 1501530, but what do I know.

 * When getting an animation value from a property declaration. At that point
   we no longer have the CSS rules that apply to the element to compute the
   right revert value handy. It'd also use the wrong style anyway, I think,
   given the way StyleBuilder::for_animation works.

   We _could_ probably get them out of somewhere, but it seems like a whole lot
   of code reinventing the wheel which is probably not useful, and that Blink
   and WebKit just cannot implement either since they don't have a rule tree,
   so it just doesn't seem worth the churn.

The custom properties code looks a bit different in order to minimize hash
lookups in the common case. FWIW, `revert` for custom properties doesn't seem
very useful either, but oh well.

Differential Revision: https://phabricator.services.mozilla.com/D21877
2019-03-13 15:08:35 +01:00
Hiroyuki Ikezoe
2639916d7d style: Set the important rule change flag when a newly important rule is inserted.
Without this change an assertion checking IsInStyleRefresh() in
EffectCompositor::PostRestyleForAnimation will be hit when we call
FindAnimationsForCompositor from RestyleManager::DoProcessPendingRestyles
that will be introduced in a subsequent commit in this series.

I wrote a crash test which causes an assertion in KeyframeEffect::CanThrottle()
without the subsequent commit, but we need more work in display item stuff to
make the assertion won't happen (bug 1508466).

Differential Revision: https://phabricator.services.mozilla.com/D12368
2018-12-02 14:17:20 -05:00
Jan Andre Ikenmeyer
1d6fe65401
Update MPL license to https (part 4) 2018-11-19 14:47:27 +01:00
Simon Sapin
b1822a39fa cargo fix --edition --features gecko 2018-11-10 17:47:28 +01:00
Simon Sapin
a15d33a10e cargo fix --edition 2018-11-10 17:47:28 +01:00
Pyfisch
9e92eb205a Reorder imports 2018-11-06 22:35:07 +01:00
Pyfisch
cb07debcb6 Format remaining files 2018-11-06 22:30:31 +01:00
Emilio Cobos Álvarez
d035d02517
style: Don't keep a separate list of ignored-when-colors-disabled longhands.
Most of the change is moving sets around to be static functions on
LonghandIdSet. I think I like that pattern, but I can also make the new set a
global static and add mako code to be `pub` or something.

Though I think the LonghandIdSet::foo().contains(..) pattern is nice to read :)

Differential Revision: https://phabricator.services.mozilla.com/D10653
2018-11-05 12:32:15 +01:00
Sean Voisen
62aaf865aa
style: Ignore border-image-source when overriding document colors.
Differential Revision: https://phabricator.services.mozilla.com/D10017
2018-11-05 12:29:20 +01:00
Emilio Cobos Álvarez
5ab81c4254
style: Make Servo build.
StrongRuleNode is really Sync.
2018-09-18 11:46:23 +02:00
Manish Goregaokar
84ca681a78
servo_arc cleanups for publishing.
Differential Revision: https://phabricator.services.mozilla.com/D6034
2018-09-18 11:39:54 +02:00
Cameron McCormack
1f45fc0339
style: Update comments to no longer point to nsRuleNode.
There are a few mentions of nsRuleNode left but they are mostly
historical references so it makes sense to keep them.

Differential Revision: https://phabricator.services.mozilla.com/D5505
2018-09-15 17:57:12 +02:00
chansuke
8dab4d659a
Format style component. 2018-09-09 16:24:45 +02:00
Nicholas Nethercote
fc9df0bcf3
style: Convert FnvHash{Set,Map} instances to FxHash{Set,Map}.
Bug: 1477628
Reviewed-by: heycam
2018-08-08 01:34:35 +02:00