Commit graph

69 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
80dae5bc59 Rustfmt. 2021-02-26 16:44:05 +01:00
Emilio Cobos Álvarez
4f28a8cd31 style: Implement parsing and serialization for most of image-set().
This implements the basic image-set notation without the format()
function (for simplicity).

There's a remaining serialization issue (we should probably skip 1x
resolutions), but that's fine for now, I'll address this in a follow-up
when the feature is testable.

The intention is to do the image selection at computed value time
(keeping a selected index or such), but same, follow-up.

This also fixes an issue where the cors-mode for -moz-image-rect and
cross-fade() was getting ignored when parsing.

Differential Revision: https://phabricator.services.mozilla.com/D100640
2021-02-26 16:44:05 +01:00
Emilio Cobos Álvarez
5277275263 style: Make CssUrl::is_fragment marginally more efficient.
No need to do utf8 shenanigans for what this function does.

Differential Revision: https://phabricator.services.mozilla.com/D97473
2021-02-26 16:44:05 +01:00
Simon Sapin
a0d9f97c8e Fix warnings introduced in newer Rust Nightly
This does not (yet) upgrade ./rust-toolchain

The warnings:

* dead_code "field is never read"
* redundant_semicolons "unnecessary trailing semicolon"
* non_fmt_panic "panic message is not a string literal, this is no longer accepted in Rust 2021"
* unstable_name_collisions "a method with this name may be added to the standard library in the future"
* legacy_derive_helpers "derive helper attribute is used before it is introduced" https://github.com/rust-lang/rust/issues/79202
2021-02-25 15:36:03 +01:00
Cameron McCormack
6bae0b99ca style: Gracefully handle errors creating shared memory UA style sheets.
We still panic in a debug build, so that developers can notice when they
need to add a new static atom after modifying UA sheets.

We also add telemetry to note when this happens, add an app note to a
crash report, in case any crash later on occurs, and re-up the existing,
expired shared memory sheet telemetry probes so we can look at them
again.

Differential Revision: https://phabricator.services.mozilla.com/D73188
2020-06-04 01:50:36 +02:00
Emilio Cobos Álvarez
97382a2c41
style: Remove nsStyleImageRequest.
This removes nsStyleImageRequest by moving the load state to LoadData instead
(where other lazy state like the resolved URL and load id lives).

That way we can use cbindgen for more stuff (there's no blocker for using it for
all images now), and we can undo the image tracking shenanigans that I had to do
in bug 1605803 in nsImageFrame.

This removes the mDocGroup member because well, there's no real upside of that
now that quantum DOM is not a thing.

It also removes the static clones of the image requests, and the need for each
computed value instance to have its own request. These were needed because we
needed the image loader for the particular document to observe the image
changes. But we were also tracking the request -> loader for other purposes.
Instead, Now all the images get loaded with GlobalImageObserver as a listener,
which looks in the image map and forwards the notification to all the interested
loaders instead dynamically.

The style value is only responsible to load the image, and no longer tracks /
locks it. Instead, the loader does so, via the image tracker.

Differential Revision: https://phabricator.services.mozilla.com/D58519
2020-02-12 02:43:20 +01:00
Emilio Cobos Álvarez
aa03bf2e19 style: Fix Servo build. 2019-06-04 01:04:01 -04:00
Emilio Cobos Álvarez
665db79274 style: Rustfmt recent changes. 2019-06-04 01:03:59 -04:00
Emilio Cobos Álvarez
57868f571f style: Use cbindgen for filters.
Had to implement some OwnedSlice bits that the canvas code used.

Differential Revision: https://phabricator.services.mozilla.com/D31799
2019-06-04 01:03:52 -04:00
Emilio Cobos Álvarez
ccff9b294f style: Use cbindgen for URIs.
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
2019-06-04 01:03:50 -04:00
Emilio Cobos Álvarez
431b9d00f5 style: Remove eStyleImageType_URL.
It was introduced in bug 1352096 to reduce complexity with Stylo (apparently).

Right now it doesn't look like it reduces any complexity, and it's a bit
annoying with some of the patches that I'm writing at the moment.

So unless there's any objection I think it should go away.

Differential Revision: https://phabricator.services.mozilla.com/D31708
2019-05-29 16:14:25 +02:00
Emilio Cobos Álvarez
49842f5031 style: Fix servo build, and appease tidy / fmt. 2019-04-12 12:20:15 +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
41f6e67893 style: Add ToShmem impl for URLValueSource.
Differential Revision: https://phabricator.services.mozilla.com/D17194
2019-04-12 12:19:49 +02:00
Cameron McCormack
7e7a9e2ec5 style: Allow C++ URLValue objects to be lazily created from Rust SpecifiedUrls.
This avoids having to support storing refcounted URLValue objects in shared memory,
which would be tricky.

Depends on D17183

Differential Revision: https://phabricator.services.mozilla.com/D17184
2019-04-12 12:19:42 +02: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
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
b66e828842
Fix various tidy issues. 2018-10-19 01:01:27 +02:00
Cameron McCormack
5770247af0
style: Make css::URLValue::IsLocalRef call into CssUrlData::is_fragment.
This fixes the issue that we should no longer be looking for control characters.

Differential Revision: https://phabricator.services.mozilla.com/D8876
2018-10-19 00:39:31 +02:00
Cameron McCormack
623363e3c8
style: Have css::URLValue get URLExtraData from its CssUrlData.
Depends on D8874

Differential Revision: https://phabricator.services.mozilla.com/D8875
2018-10-19 00:39:22 +02:00
Cameron McCormack
c4491ea39d
style: Make css::URLValue hold on to a CssUrlData, not just its serialization.
Differential Revision: https://phabricator.services.mozilla.com/D8874
2018-10-19 00:39:13 +02:00
Cameron McCormack
9865a4194c
style: Merge css::{URLValueData, ImageValue} into css::URLValue.
Differential Revision: https://phabricator.services.mozilla.com/D8061
2018-10-19 00:34:27 +02:00
Emilio Cobos Álvarez
f287691f2e
style: fix tidy issues and update test expectations. 2018-10-09 22:01:38 +02:00
Emilio Cobos Álvarez
7345af613a
style: Serialize a bunch of image properties with Servo.
I had to fix the conversion for BackgroundSize too, hopefully we can
simplify all this using cbindgen in the future instead of CalcValue.

Differential Revision: https://phabricator.services.mozilla.com/D7580
2018-10-09 19:45:35 +02:00
Brad Werth
6d57cbd881
style: Expand the Parser trait to allow anonymous CORS to be applied.
Depends on D5106

Differential Revision: https://phabricator.services.mozilla.com/D5341
2018-09-15 17:57:05 +02:00
Brad Werth
b96d44e329
style: Change Gecko_ImageValue_Create to take a CORS mode argument.
Differential Revision: https://phabricator.services.mozilla.com/D5106
2018-09-15 17:56:57 +02:00
chansuke
8dab4d659a
Format style component. 2018-09-09 16:24:45 +02:00
Emilio Cobos Álvarez
750c223021
style: Fix tidy. 2018-06-23 20:34:10 +02:00
Emilio Cobos Álvarez
f564b32b75
style: Better debugging for stylesheets and URLs.
Bug: 1470145
Reviewed-by: xidorn
MozReview-Commit-ID: FIcz2K1ZYX0
2018-06-23 20:37:03 +02:00
Xidorn Quan
ecb2ec63de
style: Rename from_url_value_data to from_url_value and reuse URLValue passed in for ComputedUrl.
Bug: 1461858
Reviewed-by: emilio
MozReview-Commit-ID: LJGm3lUS9mD
2018-05-20 18:58:31 +02:00
Xidorn Quan
5b0903e604
style: Have from_image_request reuse ImageValue from image request directly.
And also remove ComputedImageUrl::from_url_value_data.

Bug: 1461858
Reviewed-by: emilio
MozReview-Commit-ID: 5zifQlU7tOz
2018-05-20 18:58:13 +02:00
Xidorn Quan
45a37503af
style: Make from_image_request infallible.
All callsites already assert, so moving the assertion into the method
should be fine. It is not expected to handle a null image value anyway.

Bug: 1461858
Reviewed-by: emilio
MozReview-Commit-ID: J8CA8m22eSv
2018-05-20 18:57:55 +02:00
Xidorn Quan
dc2aadd43a
style: Make creating CssUrl infallible.
There were a check in CssUrl::parse_from_string for extra data, which
was removed as part of servo/servo#16241, so it never fails now.

CssUrl::from_url_value_data doesn't seem to need Result from the very
beginning. It is unclear why it was made that way.

Bug: 1461858
Reviewed-by: emilio
MozReview-Commit-ID: LXzKlZ6wPYW
2018-05-20 18:57:35 +02:00
Emilio Cobos Álvarez
164bfbcb40
Make servo-tidy happy. 2018-05-19 10:15:17 +02:00
Emilio Cobos Álvarez
1314f47da5
style: Distinguish between specified and computed URLs.
This is needed to serialize computed URLs correctly from getComputedStyle.

Bug: 1461288
Reviewed-by: xidorn
MozReview-Commit-ID: 9wakhqNrszb
2018-05-19 10:15:17 +02:00
Xidorn Quan
07de715bb5
style: Manually implement collect_completion_keywords for some types.
Bug: 1434130
Reviewed-by: emilio
MozReview-Commit-ID: 6T35uylxgho
2018-04-29 03:28:50 +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
Emilio Cobos Álvarez
1d8e64c8ee
style: Simplify ImageValue.
Bug: 1452987
Reviewed-by: heycam
MozReview-Commit-ID: 5LRaaEPSSdY
2018-04-11 09:47:47 +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
Anthony Ramine
afaa00a344 Remove some uses of trivial_to_computed_value 2018-03-09 11:57:22 +01:00
Xidorn Quan
ecbc55ffcf Construct URLValue eagerly and share it between specified value and style structs. 2018-03-08 23:34:35 +11:00
Xidorn Quan
fa5d76c395 Split CssUrl from SpecifiedUrl for non-value URLs. 2018-03-08 23:34:34 +11:00
Xidorn Quan
0090fbb3c8 Move ComputedUrl into their impl mods. 2018-03-08 23:34:33 +11:00
Xidorn Quan
d001fd9a0a Move Parse impl of SpecifiedUrl into corresponding files. 2018-03-08 23:34:33 +11:00
Xidorn Quan
a99ca543cd Add SpecifiedImageUrl for <url> used as images. 2018-03-08 23:34:32 +11:00
Xidorn Quan
14b708311b Remove some useless clone() call on SpecifiedUrl::image_value. 2018-03-08 21:35:33 +11:00
Anthony Ramine
ca45695db1 Introduce #[css(skip)] 2018-03-05 15:53:15 +01:00
Emilio Cobos Álvarez
da94feb11a
style: Copy less URLs on stylo.
Bug: 1442246
Reviewed-by: jdm
MozReview-Commit-ID: NmHue1mGDq
2018-03-03 18:18:22 +01:00