aboutsummaryrefslogtreecommitdiffstats
path: root/components/servo_arc/lib.rs
Commit message (Collapse)AuthorAgeFilesLines
* Strict import formatting (grouping and granularity) (#30325)Samson2023-09-111-11/+8
| | | | | * strict imports formatting * Reformat all imports
* style: Refactor the author sheet cache to keep alive the relevant ↵Emilio Cobos Álvarez2023-05-241-0/+8
| | | | | | | | | | | | | | | StylesheetContents This prevents incorrectly reusing cached results when the contents go away and new contents are allocated with the same address. Note that these keep alive transitively everything else under them, so all other medialist keys don't need this. By making this a proper hashmap it should also improve cache lookup times if the cache grows too big. Differential Revision: https://phabricator.services.mozilla.com/D115202
* Upgrade remaining components to edition 2018sagudev2023-02-181-5/+0
|
* Fix some Clippy lints.Teymour Aldridge2022-08-041-8/+3
|
* style: Simplify code for keeping alive shared memory until all sheets go away.Emilio Cobos Álvarez2019-11-301-4/+9
| | | | | | | | | | | | | | | | | | The existing code wasn't sound, as CSSOM objects also needed to go away before the shared memory goes away (as they keep references to them). This is sound assuming no presence of reference cycles introduced by CSSOM. We may want to live with this and rely on chrome code not writing cycles like this with UA stylesheet DOM objects. We could explicitly drop all potentially-static objects... That seems pretty error prone though. Or we could also just leak the shared memory buffer, is there any reason why we may not want to do that? Differential Revision: https://phabricator.services.mozilla.com/D51870
* style: Properly refcount-log UniqueArcs created with new_uninitialized().Emilio Cobos Álvarez2019-07-241-0/+6
|
* Don't insta-free in UniqueArc::assume_init.Emilio Cobos Álvarez2019-07-241-1/+1
|
* Stylo: replace uses of mem::uninitialized with MaybeUninitSimon Sapin2019-07-161-20/+9
| | | | MozReview-Commit-ID: KGhYL6DJRaR
* Add UniqueArc::new_uninit, UniqueArc::assume_initSimon Sapin2019-07-161-1/+29
| | | | MozReview-Commit-ID: DoNcSsKpRn
* style: Rustfmt recent changes.Emilio Cobos Álvarez2019-07-081-5/+1
|
* style: Generate top-level function and constant declarations for the style ↵Emilio Cobos Álvarez2019-07-081-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* style: Rustfmt recent changes.Emilio Cobos Álvarez2019-06-041-3/+15
|
* style: Use a RwLock'd HashMap instead of a lock-free linked list for rule ↵Emilio Cobos Álvarez2019-06-041-0/+7
| | | | | | | | | | | | | | 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
* style: Rejigger a bit rust features so that rusttests still link.Emilio Cobos Álvarez2019-06-041-4/+4
| | | | | | | | | | | 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
* style: Add refcount logging to servo_arc.Emilio Cobos Álvarez2019-06-041-7/+61
| | | | Differential Revision: https://phabricator.services.mozilla.com/D32173
* style: Use cbindgen for URIs.Emilio Cobos Álvarez2019-06-041-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This doesn't clean up as much as a whole, but it's a step in the right direction. In particular, it allows us to start using simple bindings for: * Filters * Shapes and images, almost. Need to: * Get rid of the complex -moz- gradient parsing (let layout.css.simple-moz-gradient.enabled get to release). * Counters, almost. Need to: * Share the Attr representation with Gecko, by not using Option<>. * Just another variant should be enough (ContentItem::{Attr,Prefixedattr}, maybe). Which in turn allows us to remove a whole lot of bindings in followups to this. The setup changes a bit. This also removes the double pointer I complained about while reviewing the shared UA sheet patches. The old setup is: ``` SpecifiedUrl * CssUrl * Arc<CssUrlData> * String * UrlExtraData * UrlValueSource * Arc<CssUrlData> * load id * resolved uri * CORS mode. * ... ``` The new one removes the double reference to the url data via URLValue, and looks like: ``` SpecifiedUrl * CssUrl * Arc<CssUrlData> * String * UrlExtraData * CorsMode * LoadData * load id * resolved URI ``` The LoadData is the only mutable bit that C++ can change, and is not used from Rust. Ideally, in the future, we could just use rust-url to resolve the URL after parsing or something, and make it all immutable. Maybe. I've verified that this approach still works with the UA sheet patches (via the LoadDataSource::Lazy). The reordering of mWillChange is to avoid nsStyleDisplay from going over the size limit. We want to split it up anyway in bug 1552587, but mBinding gains a tag member, which means that we were having a bit of extra padding. One thing I want to explore is to see if we can abuse rustc's non-zero optimizations to predict the layout from C++, but that's something to explore at some other point in time and with a lot of care and help from Michael (who sits next to me and works on rustc ;)). Differential Revision: https://phabricator.services.mozilla.com/D31742
* style: Implement ArcSlice::default().Emilio Cobos Álvarez2019-05-291-12/+11
| | | | | | Share a singleton to avoid allocating for empty lists. Differential Revision: https://phabricator.services.mozilla.com/D30543
* style: Rustfmt + build fix.Emilio Cobos Álvarez2019-05-101-4/+11
|
* style: Add bindings for ArcSlice and ThinArc, and use them to reduce copies ↵Emilio Cobos Álvarez2019-05-101-0/+8
| | | | | | | | | | | of SVG path data. As I said over bug 1549593, the eventual goal is to use ArcSlice in all inherited properties. But this seemed like a good first candidate that doesn't require me to move around a lot more code, since we were already using cbindgen for the path commands. Differential Revision: https://phabricator.services.mozilla.com/D30134
* style: Introduce ArcSlice, a small wrapper over ThinArc but without an ↵Emilio Cobos Álvarez2019-05-101-3/+14
| | | | | | | | | | explicit header. We could make the header PhantomData or something, but then we wouldn't be able to bind to C++, since C++ doesn't have ZSTs. So add a canary instead to add a runtime check of stuff being sane. Differential Revision: https://phabricator.services.mozilla.com/D30133
* style: Fix an assertion that doesn't account for alignment padding.Emilio Cobos Álvarez2019-05-101-3/+21
| | | | | | | I'm hitting this when trying to add bindings for box shadows, which are 32-bit aligned. Differential Revision: https://phabricator.services.mozilla.com/D30353
* style: Don't panic when creating empty ThinArcs.Emilio Cobos Álvarez2019-05-101-17/+31
| | | | | | | | | The change from [T; 1] to [T; 0] shouldn't change behavior since they have the right alignment and we never poke at that particular array, but feels more correct to avoid creating types that point to uninitialized data or outside of their allocation, now that we allow empty slices. Differential Revision: https://phabricator.services.mozilla.com/D30352
* style: Use PhantomData<T> in servo_arc.Emilio Cobos Álvarez2019-05-101-1/+14
| | | | | | See https://github.com/rust-lang/rust/pull/60594#issuecomment-489966933 Differential Revision: https://phabricator.services.mozilla.com/D30169
* style: ThinArc should use NonNull.Emilio Cobos Álvarez2019-05-101-7/+9
| | | | | | If only for parallelism with Arc<>. Differential Revision: https://phabricator.services.mozilla.com/D30131
* style: Add support for static references to servo_arc::Arc. r=emilioCameron McCormack2019-04-121-38/+156
| | | | Differential Revision: https://phabricator.services.mozilla.com/D17186
* `cargo fix --edition`Simon Sapin2018-11-101-1/+1
|
* Reorder importsPyfisch2018-11-061-2/+2
|
* Fix tidy issues.Emilio Cobos Álvarez2018-09-181-13/+10
|
* servo_arc cleanups for publishing.Manish Goregaokar2018-09-181-140/+202
| | | | Differential Revision: https://phabricator.services.mozilla.com/D6034
* style: Use an acquire load for is_unique in servo_arc.Bobby Holley2018-07-241-8/+3
| | | | | | | | Fixes #21186 Bug: 1476445 Reviewed-by: Manishearth Differential Revision: https://phabricator.services.mozilla.com/D2205
* style: Fix tidy issues and Servo build.Emilio Cobos Álvarez2018-04-291-1/+1
|
* servo_arc: ArcUnion.Bobby Holley2018-04-291-2/+134
| | | | | | Bug: 1455784 Reviewed-by: Manishearth MozReview-Commit-ID: Jxp2A7cj6CV
* Run rustfmt on selectors, servo_arc, and style.Bobby Holley2018-04-101-38/+65
| | | | | | | | | | 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)
* Change debug assertions to specific onesjanczer2018-02-071-1/+1
|
* Use specific negative assertion for ServoArcCYBAI2018-01-261-1/+1
|
* Use specific assertion for ServoArcCYBAI2018-01-261-2/+2
|
* Add some FIXME comments about using ptr::NonNullSimon Sapin2018-01-221-0/+1
|
* Prepare servo_arc for publication on crates.ioSimon Sapin2018-01-121-1/+1
|
* servo_arc: Add some #[inline] and repr(C) annotations.Emilio Cobos Álvarez2017-12-011-3/+30
| | | | | inline is probably unnecessary, but anyway... We rely on those being repr(C), so they rather have some.
* Replace all uses of the `heapsize` crate with `malloc_size_of`.Nicholas Nethercote2017-10-181-11/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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`.
* Fix commonmark Markdown warnings in docs, part 1Matt Brubeck2017-10-171-2/+3
| | | | | | | | Fixes warnings from rust-lang/rust#44229 when `--enable-commonmark` is passed to rustdoc. This is mostly a global find-and-replace for bare URIs on lines by themselves in doc comments.
* servo_arc: Make Arc do a pointer equality check in eq and ne first.Cameron McCormack2017-10-111-2/+2
|
* style: Share user agent cascade data across documents.Emilio Cobos Álvarez2017-09-151-1/+1
| | | | | MozReview-Commit-ID: KcyuTHD0bt9 Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
* style: Add a TLS-based style struct caching mechanism.Emilio Cobos Álvarez2017-09-141-0/+6
|
* Measure selectors.Nicholas Nethercote2017-09-071-0/+6
| | | | | | | | | This patch adds measurement of Selectors within StyleRule. This requires exposing the pointer within ThinArc. The patch also adds measurement of the several CssRule variants, in order to measure nested CssRules (and PropertyDeclarationBlocks) within them: DocumentRule, MediaRule, PageRule, SupportsRule.
* order derivable traits listsClément DAVID2017-08-231-1/+1
| | | | | | Ignoring : - **generated**.rs - python/tidy/servo_tidy_tests/rust_tidy.rs
* stylo: Measure Elements and ComputedValues.Nicholas Nethercote2017-08-031-0/+8
| | | | | | | | | | | | The patch provides FFI access to Gecko's SeenPtrs type from Rust, in order to record what has already been measured when measuring Arcs. (The SeenPtrs must be initialized on the Gecko side because the same table is reused for measuring all Elements within a window, because Elements can share ComputedValues.) I have confirmed with DMD that this is working correctly. The patch also introduces MallocSizeOfRepeats, which is like MallocSizeOf but takes a SizeOfState, which holds a SeenPtrs table.
* stylo: Remove usage of ServoComputedValues from binding functionsManish Goregaokar2017-07-211-0/+6
|
* stylo: Make Servo Arc types use ptr to T instead of ptr to ArcInner<T>Manish Goregaokar2017-07-171-1/+103
|
* stylo: Replace real ComputedValues with bindgenned ComputedValues2Manish Goregaokar2017-07-171-0/+20
|