Commit graph

315 commits

Author SHA1 Message Date
Nika Layzell
ec5cf5ceaf Move nsstring from gecko into servo/support/gecko/nsstring
This is the servo side of bug 1403213.

MozReview-Commit-ID: HFdQiuMnGhJ
2017-10-20 10:52:57 -04:00
Nicholas Nethercote
4506f0d30c Replace all uses of the heapsize crate with malloc_size_of.
Servo currently uses `heapsize`, but Stylo/Gecko use `malloc_size_of`.
`malloc_size_of` is better -- it handles various cases that `heapsize` does not
-- so this patch changes Servo to use `malloc_size_of`.

This patch makes the following changes to the `malloc_size_of` crate.

- Adds `MallocSizeOf` trait implementations for numerous types, some built-in
  (e.g. `VecDeque`), some external and Servo-only (e.g. `string_cache`).

- Makes `enclosing_size_of_op` optional, because vanilla jemalloc doesn't
  support that operation.

- For `HashSet`/`HashMap`, falls back to a computed estimate when
  `enclosing_size_of_op` isn't available.

- Adds an extern "C" `malloc_size_of` function that does the actual heap
  measurement; this is based on the same functions from the `heapsize` crate.

This patch makes the following changes elsewhere.

- Converts all the uses of `heapsize` to instead use `malloc_size_of`.

- Disables the "heapsize"/"heap_size" feature for the external crates that
  provide it.

- Removes the `HeapSizeOf` implementation from `hashglobe`.

- Adds `ignore` annotations to a few `Rc`/`Arc`, because `malloc_size_of`
  doesn't derive those types, unlike `heapsize`.
2017-10-18 22:20:37 +11:00
Savid Sharan
dd02d7a8f8 Removed pdqsort dependency and changed style create to use stdlib sort method. 2017-10-16 18:40:17 -04:00
Emilio Cobos Álvarez
9e6c49d479
style: Share code for Element::Matches. 2017-10-13 17:21:26 +02:00
Nicholas Nethercote
365ae0b637 Remove nsTFixedString<T>.
nsTFixedString<T> is only used as a base class for nsTAutoStringN<T, N>, so
this patch merges the former into the latter, cutting some code and simplifying
the string class hierarchy.

Because the "Fixed" name is now gone, the patch also renames
StringDataFlags::FIXED as INLINE and ClassDataFlags::FIXED as INLINE.

The patch also removes nsFixed[C]String and ns_auto_[c]string! from Rust code
because nsAutoString can't be implemented directly in Rust due to its move
semantics. There were only two uses of ns_auto_string! outside of tests so this
seems like a minor loss.
2017-10-04 13:31:09 +11:00
Bobby Holley
8b6c5988b5 Hoist the LRU cache into its own crate to share it with selectors. 2017-09-20 23:22:20 -07:00
Emilio Cobos Álvarez
c34c92e904 style: Add a TLS-based style struct caching mechanism. 2017-09-14 17:13:39 +08:00
Nicholas Nethercote
32548e5312 Overhaul MallocSizeOf and related things.
This patch makes the MallocSizeOf stuff in Stylo work more like the HeapSizeOf
stuff already in Servo, except better. In particular, it adds deriving support
for MallocSizeOf, which will make it easier to improve coverage.

The patch does the following.

- Combines servo/components/style/stylesheets/memory.rs and the heapsize crate
  into a new crate, malloc_size_of.

- Forks the heapsize_derive crate, calling it malloc_size_of, so that
  MallocSizeOf can be derived.

- Both the new crates have MIT/Apache licenses, like heapsize, in case they are
  incorporated into heapsize in the future.

- Renames the methods within MallocSizeOf and the related traits so they are
  more concise.

- Removes MallocSizeOfWithGuard.

- Adds `derive(MallocSizeOf)` to a lot of types, in some cases replacing an
  equivalent or almost-equivalent hand-written implementation.

- Adds stuff so that Rc/Arc can be handled properly.
2017-09-12 12:37:51 +10:00
bors-servo
e7f45028dc Auto merge of #18431 - mbrubeck:pdb-size, r=SimonSapin
Use SmallBitVec to optimize size of PropertyDeclarationBlock

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

<!-- 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/18431)
<!-- Reviewable:end -->
2017-09-11 08:57:07 -05:00
Matt Brubeck
21006fb752 Use SmallBitVec to replace BitVec 2017-09-11 06:33:43 -07:00
Julian Seward
c85633f48e
stylo: Add uses of fallible Vec, SmallVec and HashMap facilities.
Bug: 1395064
Reviewed-by: emilio
2017-09-10 16:42:06 +02:00
Manish Goregaokar
fae5e10643
stylo: Add hash module for reexporting HashMap 2017-08-31 16:28:27 -07:00
Emilio Cobos Álvarez
2291ce4767
style: Remove CascadeInfo. 2017-08-28 14:40:47 +02:00
Bobby Holley
707ab455bb Eliminate the sequential/traversal parallel distinction in favor of a unified adaptive driver.
MozReview-Commit-ID: ADVTNJntzmp
2017-08-25 10:00:27 -07:00
Xidorn Quan
7e92c15e00 Replace write! with to_css and write_str in some ToCss impls 2017-08-20 17:21:08 +10:00
Hiroyuki Ikezoe
17eba0d4d6 Drop AnimatedProperty for stylo.
set_list_style_type() for gecko needs an additional argument 'Device' [1], and
making list-style-type animtable makes AnimatedProperty::update() call the
set_list_style_type(). To avoid introducing the Device argument to the setter in
servo, this patch makes simply PropertyAnimation conditional build.
(Whereas in stylo, we don't use the setter for animation, we use clone_xx()
instead.)

[1] https://hg.mozilla.org/mozilla-central/file/1d042bcb2632/servo/components/style/properties/properties.mako.rs#l2667
2017-08-09 17:34:55 +09:00
Emilio Cobos Álvarez
720b17a54b
style: Avoid hashing the precomputed hash atoms already have.
This shaves a fair amount of time of stylist rebuild.

Most of the extra remaining overhead are memory allocations...

I'll try to get those sorted out next, though fixing that may overlap quite a
bit with the work Cameron is doing in bug 1382925.

MozReview-Commit-ID: 3j2SBY4QnKf
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-08-07 14:12:39 +02:00
Nathan Froyd
e962ac365b export boxedness of types from longhand_properties_idents
The only piece of information about longhand SpecifiedValue types that
we don't have outside of the properties module is whether the types are
boxed or not.  Provide that information in the
longhand_properties_idents macro so we can move
test_size_of_specified_values outside of the properties module.
2017-08-04 08:03:56 -04:00
bors-servo
3ab6b1cf8f Auto merge of #17898 - BorisChiou:stylo/animation/filter_distance, r=birtles
stylo: Fix compute_squared_distance for AnimatedFilterList

We implement compute_distance for Angle to avoid returning Err(()) from it, and then rewrite compute_squared_distance of AnimatedFilterLIst to avoid using unwrap() and make it simpler.

---
<!-- 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
- [X] These changes fix [Bug 1384014](https://bugzilla.mozilla.org/show_bug.cgi?id=1384014).
- [X] These changes do not require tests because there is a DevTools test for this already.

<!-- 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/17898)
<!-- Reviewable:end -->
2017-07-28 02:08:31 -05:00
Boris Chiou
902819590f Rewrite compute_squared_distance for AnimatedFilterList. 2017-07-28 11:27:46 +08:00
Bobby Holley
ce295f6daf Pass TraversalFlags from C++ into Rust.
MozReview-Commit-ID: EVUzgnL5coN
2017-07-27 14:25:58 -07:00
Manish Goregaokar
01b1027365 Remove last vestiges of stylearc 2017-07-21 14:39:51 -07:00
bors-servo
6597178b91
Auto merge of #17701 - bholley:reuse_allocations, r=emilio
reuse the bloom filter and style sharing cache across traversals

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

<!-- 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/17701)
<!-- Reviewable:end -->
2017-07-14 11:01:07 +02:00
Emilio Cobos Álvarez
a34f288b98
Revert "Auto merge of #17701 - bholley:reuse_allocations, r=emilio"
This reverts commit ebfc8f5858, reversing
changes made to 5585ff2c44.

Animation code can reenter and create a new TLS context from the traversal
SequentialTask, so this won't work as written.
2017-07-13 09:58:08 +02:00
Bobby Holley
d1c31f7eaf Add owning_ref back as a style dep, and update parking_lot. 2017-07-12 16:37:50 -07:00
Emilio Cobos Álvarez
b4c8ba3029
style: Introduce StyleResolverForElement.
This still doesn't make use of it so far, but I prefer introducing it
atomically, then introduce its usage.

MozReview-Commit-ID: 9dRUsl3srHp
2017-07-12 08:39:50 +02:00
Nathan Froyd
096cee8ebc remove various things now that Rust 1.17 is required
std::ptr::eq and Arc::ptr_eq are now usuable, and we can replace a
panic!() with abort().
2017-06-23 10:39:41 -04:00
Bobby Holley
db8f59407f Hoist sink into selectors.
It probably makes more sense (eventually) to put it in SmallVec.

MozReview-Commit-ID: AIBKCLiMNN2
2017-06-20 11:59:10 -07:00
Simon Sapin
a5bb55790f Untry style 2017-06-18 13:18:13 +02:00
Simon Sapin
605ef8b7ec Remove explicit dependencies on serde_derive 2017-06-16 13:58:21 +02:00
Emilio Cobos Álvarez
cb06375fe2
style: Implement a more fine-grained invalidation method.
This commit also removes the old restyle_hints module and splits it into
multiple modules under components/style/invalidation/element/.

The basic approach is to walk down the tree using compound selectors as needed,
in order to do as little selector-matching as possible.

Bug: 1368240
MozReview-Commit-ID: 2YO8fKFygZI
2017-06-13 13:26:41 +02:00
Simon Sapin
5bccf98aa4 ID and class selectors are ASCII case-insensitive in quirks mode.
https://bugzilla.mozilla.org/show_bug.cgi?id=1363778
2017-06-12 23:33:53 +02:00
Bobby Holley
a98fff1af8 Hoist ApplicableDeclaration{Block,List} into a separate file.
MozReview-Commit-ID: EXnAzfyoZ1e
2017-06-12 12:13:21 -07:00
Bobby Holley
fa9d2cb036 Move stylearc into a separate crate.
MozReview-Commit-ID: C3btN8Jw9sJ
2017-06-05 19:44:04 -07:00
Emilio Cobos Álvarez
58fd80e282
style: Split stylesheets.rs
This file has become quite bloated lately. This commit deletes that file in
favor of a set of submodules.

The only noticeable change apart from code move, is converting deep_clone_foo
methods into a trait.

It also unifies logic related to different style rules in the same place.

There's some missing work, specially related to font-face and counter-style, but
I think this is worth landing in the meantime.
2017-06-04 21:50:09 +02:00
Emilio Cobos Álvarez
658075af32
Bug 1357583: style: Add an initial version of the stylesheet invalidation code. r=heycam
MozReview-Commit-ID: 4jLxPYNF07U
2017-05-29 20:15:35 +02:00
Emilio Cobos Álvarez
a67e880256
style: Move SelectorMap to its own submodule. 2017-05-23 14:48:04 +02:00
Behnam Esfahbod
14c524df4f [gfx] [layout] [style] Upgrade unicode-bidi to 0.3 2017-05-22 20:06:19 -05:00
Emilio Cobos Álvarez
311c403522
style: Move all the style sharing code outside matching.rs
This is just a code health change. I want to move it away to keep matching.rs as
simple as possible.
2017-05-21 02:30:51 +02:00
bors-servo
4f0b24ac0c Auto merge of #16960 - servo:derive-all-the-things, r=emilio
Derive HasViewportPercentage 🍷

<!-- 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/16960)
<!-- Reviewable:end -->
2017-05-20 11:34:36 -05:00
Anthony Ramine
90bae7f802 Derive HasViewportPercentage 🍷 2017-05-20 14:48:04 +02:00
Simon Sapin
d2be5239f5 Avoid returning / passing around a huge ParsedDeclaration type
This enum type used to contain the result of parsing
one CSS source declaration (`name: value;`) and expanding shorthands.
Enum types are as big as the biggest of their variant (plus discriminant),
which was quite big because some shorthands
expand to many longhand properties.
This type was returned through many functions and methods,
wrapped and rewrapped in `Result` with different error types.
This presumably caused significant `memmove` traffic.

Instead, we now allocate an `ArrayVec` on the stack
and pass `&mut` references to it for various functions to push into it.
This type is also very big, but we never move it.

We still use an intermediate data structure because we sometimes decide
after shorthand expansion that a declaration is invalid after all
and that we’re gonna drop it.
Only later do we push to a `PropertyDeclarationBlock`,
with an entire `ArrayVec` or nothing.

In future work we can try to avoid a large stack-allocated array,
and instead writing directly to the heap allocation
of the `Vec` inside `PropertyDeclarationBlock`.
However this is tricky:
we need to preserve this "all or nothing" aspect
of parsing one source declaration,
and at the same time we want to make it as little error-prone as possible
for the various call sites.
`PropertyDeclarationBlock` curently does property deduplication
incrementally: as each `PropertyDeclaration` is pushed,
we check if an existing declaration of the same property exists
and if so overwrite it.
To get rid of the stack allocated array we’d need to somehow
deduplicate separately after pushing multiple `PropertyDeclaration`.
2017-05-19 18:53:25 +02:00
bors-servo
61d64daf4c Auto merge of #16931 - nox:font-feature-descriptor, r=emilio
Support font-feature-settings as a @font-face descriptor

<!-- 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/16931)
<!-- Reviewable:end -->
2017-05-19 07:49:27 -05:00
Simon Sapin
ee2794e966 Move bindings tests out of the style crate.
This cuts in almost half the time to run:

```
touch components/style/lib.rs
./mach test-stylo
```
2017-05-18 18:46:29 +02:00
Anthony Ramine
7d66e65d94 Move some style macros into their own module, used first 2017-05-18 18:16:21 +02:00
Anthony Ramine
9964b328b1 Implement the hashless color quirk (fixes #15341) 2017-05-17 14:12:58 +02:00
Fernando Jiménez Moreno
b22e0e9494 Stylo: Bug 1355408 - add support for @-moz-document 2017-05-09 12:52:44 +02:00
bors-servo
8b41c7c137 Auto merge of #16689 - servo:m5e, r=nox
Upgrade to html5ever 0.16

<!-- 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/16689)
<!-- Reviewable:end -->
2017-05-03 08:42:41 -05:00
Bobby Holley
d78ca4c4f9 Use StyleArc in the style system.
MozReview-Commit-ID: flF0fv9E9M
2017-05-02 17:35:44 -07:00
Bobby Holley
6d8fc600b8 Strip down StyleArc to what we need.
We remove most of the doc comments to minimize the number of lines
of forked code.

MozReview-Commit-ID: LehEisKxkJW
2017-05-02 17:34:40 -07:00