Commit graph

61 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
ed2e9ce482
Rustfmt and fix tidy on recent changes. 2019-06-25 13:11:31 +02:00
Emilio Cobos Álvarez
7139a4185a
style: Add code to make part rules affect the style of the elements.
I still haven't implemented each_part(), so this will do nothing yet.

The cascade order stuff is fishy, I know, and I'll fix in a followup if it's
fine with you. I moved the sorting of the rules to rule_collector, since it
seemed to me it was better that way that duplicating the code, and those
SelectorMap functions only have a single caller anyway.

Differential Revision: https://phabricator.services.mozilla.com/D32647
2019-06-25 13:11:29 +02:00
Jan Andre Ikenmeyer
1d6fe65401
Update MPL license to https (part 4) 2018-11-19 14:47:27 +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
chansuke
8dab4d659a
Format style component. 2018-09-09 16:24:45 +02:00
Emilio Cobos Álvarez
2e3aacdf80
style: Add a root bucket to the selector map.
:root can't change without getting unbound from the tree so no fancy stuff other
than that needed.

This removes a lot of revalidation and attribute invalidation matching from the
Chrome, and looks like it should be a good idea in general.

Differential Revision: https://phabricator.services.mozilla.com/D2462
2018-08-08 01:35:54 +02:00
Emilio Cobos Álvarez
fa7d9bf74a
style: Add namespace bucket for the selector map.
After bug 1470163 we have some nasty selectors from mathml.css in every page.

We only want to match them against MathML elements.

This patch brings the global revalidation selectors from 14 to 2 in about:blank.
Also halves the ones from XUL documents.

Bug: 1374017
Reviewed-by: heycam
MozReview-Commit-ID: nOVyknNcVm
2018-07-01 00:05:12 +02:00
Emilio Cobos Álvarez
e5878b96a9
style: Remove Valgrind workaround to make ::slotted use the rule hash.
Bug: 1426516
Reviewed-by: emilio
MozReview-Commit-ID: 2q14kHjajIr
2018-04-28 10:26:07 +02:00
Emilio Cobos Álvarez
84d6c13871
style: Fix cascade order of !important in Shadow DOM.
No cleaner ideas right now that carrying that counter around... Maybe a custom
type may be cleaner?

This makes ApplicableDeclarationBlock a bit bigger. I could probably try to make
the counter a 4 / 5-bit number or something and pack the counter there in the
SourceOrderAndCascadeLevel somehow...

But doesn't seem really worth the churn, and can be done as a followup in any
case. Let me know if you want to block on that.

Bug: 1454162
Reviewed-by: heycam
MozReview-Commit-ID: 1LdW9S4xA6f
2018-04-28 10:26:01 +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
Emilio Cobos Álvarez
eaefaa890e
style: Implement the functional :host(..) selector.
We could invalidate in a slightly more fine-grained way, but I don't think it's
worth the churn vs. keeping the special-cases minimal.

Bug: 1452640
Reviewed-by: xidorn
MozReview-Commit-ID: 5DkQrgwg9GW
2018-04-10 08:04:09 +02:00
Emilio Cobos Álvarez
f2efd04a5d
style: Make Element::id not clone the attribute. 2018-02-24 22:45:43 +01:00
Emilio Cobos Álvarez
98c9292ecb
style: Remove get_ prefix from get_state and get_id. 2018-02-24 22:45:42 +01:00
Emilio Cobos Álvarez
7ab4b21bc3
selectors: Remove the get_ prefix from get_local_name and get_namespace. 2018-02-24 22:45:38 +01:00
Emilio Cobos Álvarez
25868beabd
style: Back out ordermap.
It was worth a shot!
2018-02-12 12:20:46 +01:00
Emilio Cobos Álvarez
4d9ce6b880
style: Temporarily use OrderMap on Gecko.
This will allow us to discard std hash map as a source of crashes.
2018-01-31 16:29:35 +01:00
Emilio Cobos Álvarez
be4c0fecd8
style: Indent some function calls properly. 2018-01-20 02:36:34 +01:00
Emilio Cobos Álvarez
d8455a772f
style: Remove redundant QuirksMode argument to SelectorMap 2018-01-20 02:32:11 +01:00
Emilio Cobos Álvarez
8f6455b9df
style: Remove some unneeded indirection.
All TElement's implement Copy, and are just pointers, so the double indirection
is stupid.

I'm going to try to see if removing this double-indirection fixes some
selector-matching performance, and this is a trivial pre-requisite while I wait
for Talos results.
2018-01-10 03:56:34 +01:00
Emilio Cobos Álvarez
5115cbd1c0
style: Store ::slotted rules separately on the cascade data, since they may cross the shadow boundary.
MozReview-Commit-ID: EY9nK3169vv
2018-01-09 14:26:02 +01:00
Emilio Cobos Álvarez
79e0f19221
style: Workaround a likely valgrind false-positive. 2017-12-20 23:03:07 +01:00
Emilio Cobos Álvarez
b556ddbf55
style: Don't support a list of selectors in ::slotted yet.
Bug: 1425757
Reviewed-by: xidorn
MozReview-Commit-ID: G0I0gM2sWTh
2017-12-20 15:55:09 +01:00
Matt Brubeck
0009ccd330 Remove unused generic from push_applicable_declarations
This function is only ever used with one type.  This gets rid of the
only use of the `smallvec::VecLike` trait, which we may want to
deprecate.  (If we do need to make this function generic in the future,
we can do it using standard traits instead.)
2017-11-29 09:20:13 -08:00
Emilio Cobos Álvarez
7861ec1d5b
style: Make the SelectorMap API slightly nicer. 2017-10-30 12:33:44 +01:00
Manish Goregaokar
b118ba72d0 Revert "Diagnostic map semantics."
This reverts commit f5c5be00a7.
2017-10-23 13:51:08 -07:00
Emilio Cobos Álvarez
1b32709d95
style: avoid selector refcount churn during invalidation.
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-10-23 08:22:49 +02:00
Emilio Cobos Álvarez
b0e54968ec
style: Make MatchingContext generic over SelectorImpl.
This will help Xidorn implement tree pseudos, and in general makes sense,
allowing to put specific matching data in a selectors implementation.
2017-10-19 11:33:13 +02: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
Bobby Holley
f5c5be00a7 Diagnostic map semantics.
MozReview-Commit-ID: C0a5g6xMPY0
2017-10-07 12:54:15 -07:00
Bobby Holley
15b866d8de Revert #18668 - Add mprotect diagnostics for HashMap crash 2017-10-03 12:44:26 -07:00
Bobby Holley
98f370130d Semantics for ProtectedHashMap.
MozReview-Commit-ID: K0m65uZi7iw
2017-09-28 14:13:01 -07: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
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
Emilio Cobos Álvarez
0a1a134050
style: remove selector_map::find_push.
It has a single caller and is overly generic, which is going to make harder to
add fallible allocations to it.
2017-09-09 09:56:09 +02:00
Nicholas Nethercote
ae1216a717 Measure SmallVecs in SelectorMap and InvalidationMap. 2017-09-06 15:39:20 +10:00
Nicholas Nethercote
d880efcab3
Measure the stylist during memory reporting. 2017-09-05 19:43:50 +02:00
Manish Goregaokar
3ddb1fda74 Tidy fixes 2017-09-01 09:53:18 -07:00
Manish Goregaokar
5cd296a264
stylo: Replace all hashtable collections with ones from style::hash 2017-08-31 16:28:30 -07:00
Emilio Cobos Álvarez
4c80cccbd2
stylo: Cleanup a bit of the Stylist clear setup.
This moves us to clear on rebuild, which allows us to remove yet another place
where we track stylist dirtiness.

Bug: 1390255
Reviewed-by: heycam
MozReview-Commit-ID: nihQbUAbh8
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-08-16 08:49:41 +02:00
Emilio Cobos Álvarez
b040d79333
style: Avoid multiple selector walk-ups during SelectorMap insertion.
MozReview-Commit-ID: 5b2X0GL2753
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-08-16 08:49:39 +02:00
Emilio Cobos Álvarez
64a96ce21c
style: Rework how precomputed pseudo stuff works, to avoid malloc/free churn.
This showed up in a few profiles, and was an easy improvement.

MozReview-Commit-ID: HVqATaSB2Ak
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-08-08 10:28:02 +02:00
Emilio Cobos Álvarez
b67c8935eb
style: Remove outdated comments. 2017-08-07 18:31:17 +02:00
Emilio Cobos Álvarez
3d54c0710f
style: Make PrecomputedHasher fail loudly and with error messages when used incorrectly. 2017-08-07 14:12:40 +02: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
Bobby Holley
2f39213072 Use a 1-entry smallvec in the selector maps.
MozReview-Commit-ID: 1JPkVxs3cdP
2017-08-06 23:15:13 -07:00
Emilio Cobos Álvarez
445b8fb3e8
style: Remove SelectorAndHashes. 2017-07-13 05:44:55 +02:00
Emilio Cobos Álvarez
dee4aea264
style: Remove hashes from style rules and dependencies.
Dependencies are very numerous, and now we shouldn't be getting so many of them.

Style rules just don't need them, so it's a waste of memory.
2017-07-13 05:44:53 +02:00
Emilio Cobos Álvarez
9394ea9644
style: Remove unneeded bounds in SelectorMap and related code.
MozReview-Commit-ID: CWwdVCwWijn
2017-07-13 03:34:33 +02:00