Skip to content

style: Move -moz-context-properties outside of mako. - #19749

Merged
bors-servo merged 2 commits into
servo:masterfrom
gootorov:move_-moz-context-properties_from_mako
Jan 15, 2018
Merged

bors-servo merged 2 commits into
servo:masterfrom
gootorov:move_-moz-context-properties_from_mako

Conversation

@gootorov

@gootorov gootorov commented Jan 11, 2018 •

Copy link
Copy Markdown
Contributor

Sub-PR of #19015


  • There are tests for these changes OR
  • These changes do not require tests

This change is Reviewable

@highfive

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @bholley: components/style/values/computed/svg.rs, components/style/values/specified/mod.rs, components/style/values/specified/svg.rs, components/style/values/computed/mod.rs, components/style/properties/longhand/inherited_svg.mako.rs
  • @canaltinova: components/style/values/computed/svg.rs, components/style/values/specified/mod.rs, components/style/values/specified/svg.rs, components/style/values/computed/mod.rs, components/style/properties/longhand/inherited_svg.mako.rs
  • @emilio: components/style/values/computed/svg.rs, components/style/values/specified/mod.rs, components/style/values/specified/svg.rs, components/style/values/computed/mod.rs, components/style/properties/longhand/inherited_svg.mako.rs

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jan 11, 2018
@highfive

Copy link
Copy Markdown

warning Warning warning

  • These commits modify style code, but no tests are modified. Please consider adding a test!

@gootorov

gootorov commented Jan 11, 2018 •

Copy link
Copy Markdown
Contributor Author

@emilio, ./mach build-geckolib doesn't report any errors, but ./mach build fails:

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?

@jdm

jdm commented Jan 11, 2018

Copy link
Copy Markdown
Member

@gootorov Can't you add #[cfg(feature = "gecko")] above it?

@gootorov
gootorov force-pushed the move_-moz-context-properties_from_mako branch from f22155c to 4afc00d Compare January 11, 2018 21:46
@gootorov

gootorov commented Jan 11, 2018 •

Copy link
Copy Markdown
Contributor Author

@jdm That worked, thanks. Should we add any tests for this change?

@gootorov gootorov changed the title [WIP] style: Move -moz-context-properties outside of mako. style: Move -moz-context-properties outside of mako. Jan 11, 2018
@gootorov gootorov changed the title style: Move -moz-context-properties outside of mako. [WIP] style: Move -moz-context-properties outside of mako. Jan 11, 2018
@jdm

jdm commented Jan 11, 2018

Copy link
Copy Markdown
Member

We should not need to add any tests for this change.

@gootorov gootorov changed the title [WIP] style: Move -moz-context-properties outside of mako. style: Move -moz-context-properties outside of mako. Jan 11, 2018
animation_value_type="none",
products="gecko",
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-context-properties)",
allow_empty="True")}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(In particular, not all CustomIdents should be parsed like -moz-context-properties.

@gootorov gootorov Jan 12, 2018 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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().

@gootorov gootorov Jan 13, 2018 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it does.

@emilio

emilio commented Jan 12, 2018

Copy link
Copy Markdown
Member

Other than those two little things it looks fine, thank you for doing this!

@gootorov
gootorov force-pushed the move_-moz-context-properties_from_mako branch from 4afc00d to fa7bbb5 Compare January 12, 2018 23:20
Comment thread components/style/values/mod.rs Outdated
Ok(MozContextProperties(CustomIdent(Atom::from(ident.as_ref()))))
}
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@gootorov gootorov Jan 13, 2018 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll guess it should be fine if they're needed but you can wait for @emilio 's review.

Comment thread components/style/values/mod.rs Outdated

/// 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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this could be in svg.rs, and you'd only need to export it from values/mod.rs.

Comment thread components/style/values/mod.rs Outdated
/// 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,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need to duplicate this.


/// Specified MozContextProperties value.
/// Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-context-properties)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: stray newline.

) -> Result<MozContextProperties, ParseError<'i>> {
let location = input.current_source_location();
let i = input.expect_ident()?;
MozContextProperties::from_ident(location, i, &["all", "none", "auto"])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do instead:

Ok(MozContextProperties(CustomIdent::from_ident(..)?))

That way you don't need to duplicate CustomIdent::from_ident.

@gootorov gootorov Jan 13, 2018 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@gootorov
gootorov force-pushed the move_-moz-context-properties_from_mako branch from 4e43201 to 90978c1 Compare January 13, 2018 20:33

pub use values::specified::SVGPaintOrder;

pub use values::specified::MozContextProperties;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this one can be exported in line 14.

pub use values::specified::{MozContextProperties , SVGPaintOrder};

@emilio emilio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the uses can be collapsed, but it's not worth it to block landing this on that nit I think.

LGTM, thanks!

@emilio

emilio commented Jan 15, 2018

Copy link
Copy Markdown
Member

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 90978c1 has been approved by emilio

@highfive highfive assigned emilio and unassigned nox Jan 15, 2018
@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Jan 15, 2018
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 90978c1 with merge 2ff3e11...

bors-servo pushed a commit that referenced this pull request Jan 15, 2018
…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 -->
@bors-servo

Copy link
Copy Markdown
Contributor

☀️ 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
Approved by: emilio
Pushing 2ff3e11 to master...

@bors-servo
bors-servo merged commit 90978c1 into servo:master Jan 15, 2018
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jan 15, 2018
@gootorov
gootorov deleted the move_-moz-context-properties_from_mako branch January 15, 2018 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

style: Move -moz-context-properties outside of mako

7 participants