Commit graph

96 commits

Author SHA1 Message Date
Simon Sapin
17ec774a49 Stylo: replace uses of mem::uninitialized with MaybeUninit
MozReview-Commit-ID: KGhYL6DJRaR
2019-07-16 08:03:54 +02:00
Emilio Cobos Álvarez
bbc77e3977 style: Share computed and specified value representation of -moz-context-properties.
Differential Revision: https://phabricator.services.mozilla.com/D30545
2019-05-29 16:14:10 +02:00
Emilio Cobos Álvarez
8c004c0858 style: Reformat recent changes. 2019-04-12 12:20:14 +02:00
Cameron McCormack
40248ae5fd style: Add derived ToShmem implementations.
Differential Revision: https://phabricator.services.mozilla.com/D17197
2019-04-12 12:19:52 +02:00
Cameron McCormack
8c007ad999 style: Add ToShmem impl for Atom.
Differential Revision: https://phabricator.services.mozilla.com/D17192
2019-04-12 12:19:48 +02:00
Emilio Cobos Álvarez
8101539c0a style: Document a few more macros. 2019-01-13 21:59:25 +01:00
Emilio Cobos Álvarez
119b316885 style: Rustfmt recent changes. 2019-01-11 00:57:26 +01:00
Cameron McCormack
03507801cf style: Make GkAtoms opaque to avoid lld-link.exe errors.
Differential Revision: https://phabricator.services.mozilla.com/D15800
2019-01-11 00:50:46 +01:00
Cameron McCormack
63fd707bd3 style: Use atom handles in favour of atom pointers in style system code.
Differential Revision: https://phabricator.services.mozilla.com/D15078
2019-01-11 00:50:26 +01:00
Jan Andre Ikenmeyer
1d6fe65401
Update MPL license to https (part 4) 2018-11-19 14:47:27 +01:00
Emilio Cobos Álvarez
f486ef7e47
style: Add an atom bit to know whether we're ascii lowercase.
And thus massively speed up ascii-case-insensitive atom comparisons when both
atoms are lowercase (which is the common case by far).

This removes almost all the slow selector-matching in this page, and it seems
an easier fix than storing the lowercased version of all class-names in quirks
mode in elements and selectors...

Differential Revision: https://phabricator.services.mozilla.com/D10945
2018-11-17 09:56:01 +01:00
Emilio Cobos Álvarez
d9453bc0ea
style: Remove dynamic HTML5 atoms.
Co-authored-by: Nicholas Nethercote <nnethercote@mozilla.com>

Differential Revision: https://phabricator.services.mozilla.com/D11035
2018-11-10 21:11:19 +01:00
Simon Sapin
b1822a39fa cargo fix --edition --features gecko 2018-11-10 17:47:28 +01:00
Pyfisch
9e92eb205a Reorder imports 2018-11-06 22:35:07 +01:00
Nicholas Nethercote
0d5d5a9c82
style: Make static atom pointers constexpr.
This saves one word per static atom, per process.

The `nsGkAtoms` change is only a small part of this commit.

In regen_atoms.py:

- There is now only one link name per platform: nsGkAtoms::sAtoms[].

- But there is a new constant per atom, giving the index into
  nsGkAtoms::sAtoms[].

- And the `atom!` macro for each atom indexes into nsGkAtoms::sAtoms[] using
  the index constant.

- A couple of `*mut` pointers are now `*const`.

Elsewhere, the `(nsStaticAtom*)` casts within the `AppendElement()` calls are
necessary to avoid link errors, presumably due to some template instantiation
wrinkle.

Bug: 1449787
Reviewed-by: froydnj,emilio
2018-10-09 19:45:10 +02:00
Emilio Cobos Álvarez
e9a99b2a7f
style: Manually inline class and ID getters.
Somewhat ugly but hopefully not too much. Somehow it ends up removing more lines
than adding.

Differential Revision: https://phabricator.services.mozilla.com/D3536
2018-08-18 17:54:54 +02:00
Cameron McCormack
e305b5a1f8
style: Remove unused BorrowedAtom.
Differential Revision: https://phabricator.services.mozilla.com/D3159
2018-08-18 17:48:12 +02:00
Nicholas Nethercote
46e572a497
Store nsDynamicAtom's chars after the end of the object.
This reduces memory usage because we only need one allocation instead of two
for the dynamic atom and its chars, and because we don't need to store a
refcount and a size. It precludes sharing of chars between dynamic atoms, but
we weren't benefiting much from that anyway.

This reduces per-process memory usage by up to several hundred KiB on my
Linux64 box.

One consequence of this change is that we need to allocate + copy in
DOMString::SetKnownLiveAtom(), which could make some things slower.

Bug: 1447951
Reviewed-by: froydnj
2018-06-23 20:36:41 +02:00
Xidorn Quan
7fe7b2ffb1
style: Add a ValueInfo trait for exposing types needed by devtools.
Most of types just derive it using proc_macro directly. Some of value
types need manual impl.

In my current plan, this new trait will be used in bug 1434130 to expose
values as well.

Bug: 1455576
Reviewed-by: emilio
MozReview-Commit-ID: LI7fy45VkRw
2018-04-29 03:28:34 +02:00
Bobby Holley
c99bcdd4b8 Run rustfmt on selectors, servo_arc, and style.
This was generated with:

./mach cargo fmt --package selectors &&
./mach cargo fmt --package servo_arc &&
./mach cargo fmt --package style

Using rustfmt 0.4.1-nightly (a4462d1 2018-03-26)
2018-04-10 17:35:15 -07:00
Nicholas Nethercote
77e3522507 Statically allocate static atoms. 2018-03-26 17:05:05 +11:00
Emilio Cobos Álvarez
55e2cd5dc3
style: Remove unsound Atom From implementations.
Fixes #20158
2018-03-19 11:06:53 +01:00
Emilio Cobos Álvarez
39a3d93b4f
style: remove unused AsciiExt imports.
eq_ignore_ascii_case is not in AsciiExt since rustc 1.23.
2018-03-04 15:31:06 +01:00
Emilio Cobos Álvarez
f4c9c598a3
style: Optimize serialization of identifiers of length <= 16 🐉🐲
Much like we optimize to_ascii_lowercase.

This also fixes a bug in Servo where attr() rules with an unknown namespace
prefix are parsed, which is wrong.
2018-02-07 17:34:22 +01:00
Emilio Cobos Álvarez
69ddb9501b
style: Remove some uses of unused unsafe. 2017-11-15 13:26:24 +01:00
Simon Sapin
954b2cc3d8
Allow unused imports for AsciiExt in style code.
See #19128, this part is cherry-picked so Gecko can build with rust nightly.
2017-11-09 12:43:23 +01:00
Nicholas Nethercote
5866b820e0 Introduce nsStaticAtom.
It's a sub-class of nsAtom, useful for cases where you know you are dealing
exclusively with static atoms. The nice thing about it is that you can use
raw nsStaticAtom pointers instead of RefPtr<>. (In fact, the AddRef/Release
implementations ensure that we'll crash if we use RefPtr<nsStaticAtom>.)
2017-10-27 20:33:40 +11:00
Nicholas Nethercote
a26d25db12 Rename size_of_is_0! as malloc_size_of_is_0!.
The new name makes it clearer that it comes from the `malloc_size_of`
crate.
2017-10-18 14:26:56 +11:00
Nicholas Nethercote
7628c1236a Rename nsIAtom as nsAtom.
Bug 1400459 devirtualized nsIAtom so that it is no longer a subclass of
nsISupports. This means that nsAtom is now a better name for it than
nsIAtom.
2017-10-09 09:27:11 +11:00
Michael Layzell
c1c98659b9 Update ns[C]String::from -> ns[C]Str::from where possible 2017-09-26 11:03:35 -04:00
Nicholas Nethercote
c5aa2cb986 Measure PropertyDeclaration more thoroughly.
This patch replaces the handwritten MallocSizeOf implementation for
PropertyDeclaration with a derived one, which gives much more thorough
measurement.

This requires (a) deriving MallocSizeOf for a *lot* of additional types (most
of which already have `derive(HeapSizeOf)` in Servo builds), and (b)
implementing MallocSizeOf for a few more types in the `malloc_size_of` crate.

These changes would significantly improve the reporting coverage for gmail if
it weren't for the fact that SpecifiedUrl isn't measured due to a lack of
clarity about its fields; that can be fixed as a follow-up once bug 1397971 has
landed.
2017-09-14 13:18:03 +10: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
Xidorn Quan
4f6752ed1a Harden assert for creating atom from raw pointer. 2017-08-30 12:36:45 +10:00
Clément DAVID
c5fe235112 order derivable traits lists
Ignoring :
 - **generated**.rs
 - python/tidy/servo_tidy_tests/rust_tidy.rs
2017-08-23 21:38:44 +02:00
Emilio Cobos Álvarez
4e3ea45325
stylo: Devirtualize nsIAtom refcounting.
Bug: 1362338
Reviewed-by: froydnj
MozReview-Commit-ID: 3q5rz3L8quQ
2017-08-09 13:06:11 +02:00
Emilio Cobos Álvarez
efed0ac742
stylo: We've had bitfield accessors for a while now. 2017-08-08 17:34:12 +02:00
Ehsan Akhgari
aeb2b8b098 stylo: Read mName as a raw nsIAtom* from NodeInfoInner. 2017-07-24 10:40:58 -04:00
Simon Sapin
eb98ae6e04 Update cssparser to 0.18
https://github.com/servo/rust-cssparser/pull/171
2017-07-24 11:39:12 +02:00
Emilio Cobos Álvarez
ce9cd802de
style: Clean up after #17427. 2017-06-20 15:42:23 +02:00
Simon Sapin
a5bb55790f Untry style 2017-06-18 13:18:13 +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
Simon Sapin
524fcac191 Add Atom::to_ascii_lowercase 2017-06-12 23:33:15 +02:00
Emilio Cobos Álvarez
cb04ef933b
stylo: Use bitfield accessors in string-cache. 2017-06-11 18:39:25 +02:00
Bobby Holley
47fd83da57 Add a fast path for eq_ignore_ascii_case. 2017-05-24 15:48:43 +02:00
Emilio Cobos Álvarez
1f7d48f564
Revert "Auto merge of #16976 - upsuper:bug1366247, r=nox"
This reverts commit 3d40b516c8, reversing
changes made to 255387a915.
2017-05-21 21:29:50 +02:00
Xidorn Quan
2b1f7f6081 Add sugar for already_AddRefed and use it for conversion between Atom and nsIAtom pointer. 2017-05-21 18:03:47 +10:00
Xidorn Quan
0667287bf6 Relax the requirement of Atom::with. 2017-05-16 14:42:45 +10:00
Xidorn Quan
10b7001dd1 Make atom files generated at build-time. 2017-05-08 21:33:58 +10:00
Xidorn Quan
5b57c5513c Move atom_macro.rs to generated dir. 2017-05-08 21:33:55 +10:00
Xidorn Quan
1ef7b323ac Fix stylo issue after changing counter style names to nsIAtom. 2017-05-06 12:50:08 +10:00