Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign up10933/shorthands #12572
10933/shorthands #12572
Conversation
highfive
commented
Jul 23, 2016
|
Heads up! This PR modifies the following files:
|
highfive
commented
Jul 23, 2016
|
Awesome work! I think it still needs some refactoring to keep things clean, but overall the approach looks good to me. What do you think about the comments suggested below? Thanks again for doing this! :) -S-awaiting-review +S-needs-code-changes Reviewed 1 of 1 files at r11. components/style/properties/properties.mako.rs, line 462 [r11] (raw file):
This should probably be refactored to use a Mako loop. components/style/properties/properties.mako.rs, line 481 [r11] (raw file):
What about hoisting this to the shorthand module? That would keep things more self-contained, and we could do something like: % for shorthand in data.shorthands:
Shorthand::${shorthand.camel_case} => shorthands::{$shorthand.ident}::write(dest, declarations),
% endforNote that the components/style/properties/properties.mako.rs, line 534 [r11] (raw file):
nit: I usually prefer matching the dereferenced value, looks cleaner: match *decl {
PropertyDeclaration::MarginTop(ref value) => // ...
// ...
}components/style/properties/properties.mako.rs, line 592 [r11] (raw file):
nit: keep the else if the same line of the rest of the closing brace: Comments from Reviewable |
|
Review status: 0 of 1 files reviewed at latest revision, 4 unresolved discussions, some commit checks failed. components/style/properties/properties.mako.rs, line 462 [r11] (raw file):
|
|
I'd strongly prefer to move these functions to its own files into their own submodules, though if for some reason you don't have enough time or something, just let me know and we could fill a followup :) Reviewed 1 of 1 files at r12. components/style/properties/properties.mako.rs, line 481 [r11] (raw file):
|
|
I was just joking about the pride thing, it's not a big deal to me. I misunderstood what you meant about moving to a module, I thought you meant move it to the shorthands mod, not another file, so I will make that change as well, in addition to looking into those new shorthands that were added. |
87c9ffd
to
cd5ce86
|
Review status: all files reviewed at latest revision, 2 unresolved discussions, some commit checks failed. components/style/properties/properties.mako.rs, line 481 [r11] (raw file):
|
|
The Travis build is failing due to the the below "missing" shorthand, yet I just rebased the latest from master, and I was able to build without any issue, I am not sure why this shorthand only appears on the Travis build. Should I add a _ => catchall generic serialization in the
|
|
I'd love to see the comment below addressed, that being said, it's not a huge deal. The problem with it as written is that it separates the code needed to add a longhand into two different places. Also, you need to take into account geckolib (the build for it is failing now because of a gecko-only shorthand). You can conditionally add that serialization with the To check the geckolib build, you can use Thanks for everything, this looks great! :) -S-awaiting-review +S-needs-code-changes Reviewed 2 of 2 files at r24. components/style/properties/properties.mako.rs, line 481 [r11] (raw file):
|
|
@craftytrickster, sorry, just replied while you commented. No, the build that is failing isn't servo's main build, it's the gecko port for servo's style system. Above is the command to build it. Let me know if you have any issues and I'll try to help :) Review status: all files reviewed at latest revision, 1 unresolved discussion, some commit checks failed. Comments from Reviewable |
|
I am not sure if it is a lot of work for you, but, would it be possible for you to provide me with one concrete example of changing one of the serializations to using hoisting and the helpers.mako file? Once I see exactly what you mean, I can port the rest of the changes to follow that convention. If it is not easy for you to do quickly, I will try to take more time to analyze what is going on in the helpers.mako file and see if I can figure it out. Thank you once again for the help. |
|
Oh, sure! So, given we have the change I said in the previous review comment, we should port code like: <%helpers:shorthand name="overflow" sub_properties="overflow-x overflow-y">
use properties::longhands::{overflow_x, overflow_y};
let overflow = try!(overflow_x::parse(context, input));
Ok(Longhands {
overflow_x: Some(overflow),
overflow_y: Some(overflow_y::SpecifiedValue(overflow)),
})
</%helpers:shorthand>to something like: <%helpers:shorthand name="overflow" sub_properties="overflow-x overflow-y">
use properties::longhands::{overflow_x, overflow_y};
// Probably a few includes missing here.
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
let overflow = try!(overflow_x::parse(context, input));
Ok(Longhands {
overflow_x: Some(overflow),
overflow_y: Some(overflow_y::SpecifiedValue(overflow)),
})
}
pub fn serialize<'a, W, I>(dest: &mut W,
appendable_value: AppendableValue<'a, I>,
is_first_serialization: &mut bool)
-> fmt::Result
where W: fmt::Write, I: Iterator<Item=&'a PropertyDeclaration>
{
let declarations = match appendable_value {
AppendableValue::DeclarationsForShorthand(_, declarations) => declarations,
_ => return Err(fmt::Error)
};
// snip snip...
write!(dest, ";")
}
</%helpers:shorthand>Does that make sense? :) Also, don't thank me, thank you for all the work you're doing, it's awesome! :) |
|
@emilio thanks for the pointers above. When I have some free time over the next several days I will make the changes. |
cd5ce86
to
ff03405
|
Looks like it failed because I did not rebase master, the Url::parse method looks to have been changed. Should be an easy fix. |
|
The approach looks so much cleaner now! Thanks! I still need to do a bit more thorough review going through the spec for each property, but this looks good to me. Can you rebase so we can make a try run and see which tests need to change? -S-awaiting-review +S-needs-rebase Review status: 0 of 18 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed. Comments from Reviewable |
10933/shorthands <!-- Please describe your changes on the following line: --> This implements the serialization of nearly all of the css shorthand properties with the following exceptions: 1. font - this may be implemented correctly, but I am not 100% sure 2. border-radius - I do not know how to implement this, since I am not familiar with how the property works 3. background - this is implemented, but I think that the implementation might be a tiny bit off. --- <!-- 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 #10933 (github issue number if applicable). Also fixes issue #11448 <!-- Either: --> - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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/12572) <!-- Reviewable:end -->
|
|
highfive
commented
Aug 17, 2016
|
|
These seem intermittents, I filled #12901. @bors-servo: retry |
10933/shorthands <!-- Please describe your changes on the following line: --> This implements the serialization of nearly all of the css shorthand properties with the following exceptions: 1. font - this may be implemented correctly, but I am not 100% sure 2. border-radius - I do not know how to implement this, since I am not familiar with how the property works 3. background - this is implemented, but I think that the implementation might be a tiny bit off. --- <!-- 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 #10933 (github issue number if applicable). Also fixes issue #11448 <!-- Either: --> - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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/12572) <!-- Reviewable:end -->
|
|
highfive
commented
Aug 17, 2016
|
|
For some reason my local only passes when I remove the 3 .ini files corresponding to those failures. However, since Travis CI seems to disagree, I have added them back. Can someone please test the merge commit, hopefully it should go through now. |
|
Oh, yeah, @shinglyu had the same problem, let's see. @bors-servo: r+ |
|
|
10933/shorthands <!-- Please describe your changes on the following line: --> This implements the serialization of nearly all of the css shorthand properties with the following exceptions: 1. font - this may be implemented correctly, but I am not 100% sure 2. border-radius - I do not know how to implement this, since I am not familiar with how the property works 3. background - this is implemented, but I think that the implementation might be a tiny bit off. --- <!-- 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 #10933 (github issue number if applicable). Also fixes issue #11448 <!-- Either: --> - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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/12572) <!-- Reviewable:end -->
|
|
|
Finally! |
craftytrickster commentedJul 23, 2016
•
edited
This implements the serialization of nearly all of the css shorthand properties with the following exceptions:
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is