Repository navigation
style: Move -moz-context-properties outside of mako. - #19749
Conversation
|
Heads up! This PR modifies the following files:
|
|
@emilio, error[E0432]: unresolved import `values::specified::MozContextProperties`
--> components/style/values/computed/svg.rs:16:9
|
16 | pub use values::specified::MozContextProperties;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `MozContextProperties` in `values::specified`
error: aborting due to previous error
error: Could not compile `style`.Not quite sure how to fix this, could you help? |
|
@gootorov Can't you add |
f22155c to
4afc00d
Compare
|
@jdm That worked, thanks. Should we add any tests for this change? |
|
We should not need to add any tests for this change. |
| animation_value_type="none", | ||
| products="gecko", | ||
| spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-context-properties)", | ||
| allow_empty="True")} |
There was a problem hiding this comment.
Maybe we need to pass Python's True for allow_empty and vector?
Ex.
vector=True| /// Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-context-properties) | ||
| pub type MozContextProperties = CustomIdent; | ||
|
|
||
| impl Parse for MozContextProperties { |
There was a problem hiding this comment.
This is implementing parse for CustomIdent, which is intentionally not implemented.
So we should make MozContextProperties a different type, like:
pub struct MozContextProperties(pub CustomIdent);And implement parse on that.
There was a problem hiding this comment.
(In particular, not all CustomIdents should be parsed like -moz-context-properties.
There was a problem hiding this comment.
I'm getting a lot of errors when trying to make MozContextProperties a different type. I suppose it could be related to the match_ignore_ascii_case!() macro in the from_ident() function.
./mach build-geckolib:
error[E0308]: mismatched types
--> /home/user/dev/rust/servo/target/geckolib/debug/build/style-b27e42e5c2727575/out/gecko/atom_macro.rs:18554:60
|
18554 | {{ #[allow(unsafe_code)] #[allow(unused_unsafe)]unsafe { $crate::string_cache::atom_macro::atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_fill as *mut _) } }};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `values::CustomIdent`, found struct `gecko_string_cache::Atom`
|
::: /home/user/dev/rust/servo/target/geckolib/debug/build/style-b27e42e5c2727575/out/gecko_properties.rs
|
20499 | if servo.0 == atom!("fill") {
| ------------- in this macro invocation
|
= note: expected type `values::CustomIdent`
found type `gecko_string_cache::Atom`
error[E0308]: mismatched types
--> /home/user/dev/rust/servo/target/geckolib/debug/build/style-b27e42e5c2727575/out/gecko/atom_macro.rs:18840:60
|
18840 | {{ #[allow(unsafe_code)] #[allow(unused_unsafe)]unsafe { $crate::string_cache::atom_macro::atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_stroke as *mut _) } }};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `values::CustomIdent`, found struct `gecko_string_cache::Atom`
|
::: /home/user/dev/rust/servo/target/geckolib/debug/build/style-b27e42e5c2727575/out/gecko_properties.rs
|
20501 | } else if servo.0 == atom!("stroke") {
| --------------- in this macro invocation
|
= note: expected type `values::CustomIdent`
found type `gecko_string_cache::Atom`
error[E0308]: mismatched types
--> /home/user/dev/rust/servo/target/geckolib/debug/build/style-b27e42e5c2727575/out/gecko/atom_macro.rs:18556:60
|
18556 | {{ #[allow(unsafe_code)] #[allow(unused_unsafe)]unsafe { $crate::string_cache::atom_macro::atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_fill_opacity as *mut _) } }};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected str
|
::: /home/user/dev/rust/servo/target/geckolib/debug/build/style-b27e42e5c2727575/out/gecko_properties.rs
|
20503 | } else if servo.0 == atom!("fill-opacity") {
| --------------------- in this macro invocation
|
= note: expected type `values::CustomIdent`
found type `gecko_string_cache::Atom`
error[E0308]: mismatched types
--> /home/user/dev/rust/servo/target/geckolib/debug/build/style-b27e42e5c2727575/out/gecko/atom_macro.rs:18852:60
|
18852 | {{ #[allow(unsafe_code)] #[allow(unused_unsafe)]unsafe { $crate::string_cache::atom_macro::atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_stroke_opacity as *mut _) } }};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected s
|
::: /home/user/dev/rust/servo/target/geckolib/debug/build/style-b27e42e5c2727575/out/gecko_properties.rs
|
20505 | } else if servo.0 == atom!("stroke-opacity") {
| ----------------------- in this macro invocation
|
= note: expected type `values::CustomIdent`
found type `gecko_string_cache::Atom`
error[E0599]: no method named `into_addrefed` found for type `values::CustomIdent` in the current scope
--> /home/user/dev/rust/servo/target/geckolib/debug/build/style-b27e42e5c2727575/out/gecko_properties.rs:20508:37
|
20508 | gecko.mRawPtr = servo.0.into_addrefed();
| ^^^^^^^^^^^^^
error: aborting due to 5 previous errors
error: Could not compile `style`.There was a problem hiding this comment.
That's because those servo.0 now are a CustomIdent instead of an Atom. You should be able to use (servo.0).0 or (I think, if I recall correctly), servo.0.as_atom().
There was a problem hiding this comment.
servo.0.as_atom() isn't implemented, but (servo.0).0 works. Please, have a look at the current changes. If they're okay, I'll squash and push the changes.
| pub use self::position::{Position, PositionComponent, GridAutoFlow, GridTemplateAreas}; | ||
| pub use self::svg::{SVGLength, SVGOpacity, SVGPaint, SVGPaintKind}; | ||
| pub use self::svg::{SVGPaintOrder, SVGStrokeDashArray, SVGWidth}; | ||
| #[cfg(feature = "gecko")] |
There was a problem hiding this comment.
I'm still not sure why the cfg checks are needed, values/specified/svg doesn't look Gecko-specific.
Does it build fine if you remove all of them?
|
Other than those two little things it looks fine, thank you for doing this! |
4afc00d to
fa7bbb5
Compare
| Ok(MozContextProperties(CustomIdent(Atom::from(ident.as_ref())))) | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
cc @emilio
Should we put MozContextProperties inside values/mod.rs ?
IMO, if this attribute is SVG related, it might be better to put in values/specified/svg.rs
There was a problem hiding this comment.
I was thinking of that too, but putting it inside values/specified/svg.rs would require importing Atom, SelectorParseErrorKind, StyleParseErrorKind, CustomIdent, SourceLocation, CowRcStr, and ParseError. Should we do it?
There was a problem hiding this comment.
I'll guess it should be fine if they're needed but you can wait for @emilio 's review.
|
|
||
| /// Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-context-properties) | ||
| #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] | ||
| pub struct MozContextProperties(pub CustomIdent); |
There was a problem hiding this comment.
Yeah, this could be in svg.rs, and you'd only need to export it from values/mod.rs.
| /// Parse an already-tokenizer identifier | ||
| pub fn from_ident<'i>(location: SourceLocation, ident: &CowRcStr<'i>, excluding: &[&str]) | ||
| -> Result<Self, ParseError<'i>> { | ||
| let valid = match_ignore_ascii_case! { ident, |
There was a problem hiding this comment.
There's no need to duplicate this.
|
|
||
| /// Specified MozContextProperties value. | ||
| /// Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-context-properties) | ||
|
|
| ) -> Result<MozContextProperties, ParseError<'i>> { | ||
| let location = input.current_source_location(); | ||
| let i = input.expect_ident()?; | ||
| MozContextProperties::from_ident(location, i, &["all", "none", "auto"]) |
There was a problem hiding this comment.
Let's do instead:
Ok(MozContextProperties(CustomIdent::from_ident(..)?))That way you don't need to duplicate CustomIdent::from_ident.
There was a problem hiding this comment.
Aaaah! Didn't think of that way. That's clever :).
I think everything should be ok now. Have a look and I'll squash and push the commits.
4e43201 to
90978c1
Compare
|
|
||
| pub use values::specified::SVGPaintOrder; | ||
|
|
||
| pub use values::specified::MozContextProperties; |
There was a problem hiding this comment.
I think this one can be exported in line 14.
pub use values::specified::{MozContextProperties , SVGPaintOrder};
emilio
left a comment
There was a problem hiding this comment.
Yeah, the uses can be collapsed, but it's not worth it to block landing this on that nit I think.
LGTM, thanks!
|
@bors-servo r+ |
|
📌 Commit 90978c1 has been approved by |
…o, r=emilio style: Move -moz-context-properties outside of mako. <!-- Please describe your changes on the following line: --> Sub-PR of #19015 --- <!-- 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 #19742 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- 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/19749) <!-- Reviewable:end -->
|
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev |
Sub-PR of #19015
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is