Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement unitless length quirk #15342

Closed
upsuper opened this issue Feb 2, 2017 · 16 comments
Closed

Implement unitless length quirk #15342

upsuper opened this issue Feb 2, 2017 · 16 comments

Comments

@upsuper
Copy link
Member

@upsuper upsuper commented Feb 2, 2017

Spec: https://quirks.spec.whatwg.org/#the-unitless-length-quirk

In quirks mode, certain length properties should accept unitless number as length.

(Part of #11709)

@absoludity
Copy link
Contributor

@absoludity absoludity commented Feb 27, 2017

I just took a look at this, but currently the parse() function for (all?) properties does not have any reference to SharedStyleContext.QuirksMode. I'm not sure if the ParserContex should be updated to include that? (Or ParserContextExtraData - though that looks like it's only used for feature=gecko, but parsing with quirksmode would be needed with or without that, I assume).

Let me know if there's a direction I can head there, or whether I should look for something else :) Thanks @upsuper

@upsuper
Copy link
Member Author

@upsuper upsuper commented Feb 27, 2017

I think we need to add a field about quirks mode to ParserContext, so that parsing functions have access to that. I think that's the right direction. I don't have clear idea about what is the best way to write the parsing code, though.

I don't think it would be an easy one, but I guess it would probably be fine for you :) Thanks for taking look at this.

@absoludity
Copy link
Contributor

@absoludity absoludity commented Mar 3, 2017

Hi @upsuper . I took a look at this last night and put together a small proof-of-concept for background-position-x:

absoludity@5c3beb6

As per the comment there, what I'm not yet sure about is who or what will trigger the ParserContext::QuirksMode to change, and when that happens. I'll take a closer look over the weekend, but let me know if you've any pointers about that.

Thanks.

@upsuper
Copy link
Member Author

@upsuper upsuper commented Mar 3, 2017

I think all constructors of ParserContext should have a new parameter quirks_mode, and that parameter should be recursively propagated into all the callers, until at some level the function is responsible to provide the quirks mode (which is a per-document thing).

For example:

  • ParserContext::new_with_extra_data is called by
  • style::properties::parse_style_attribute, which is called by
  • <script::dom::element::Element as VirtualMethods>::attribute_mutated

and in the method of Element, you can get quirks mode from doc.quirks_mode(), so this chain ends here.

@absoludity
Copy link
Contributor

@absoludity absoludity commented Mar 4, 2017

@upsuper: How can that particular example propagation path (up to attribute_mutated) be tested? Adding the quirks_mode through there is easy enough, but neither the unit tests or wpt tests (unitless-length.html) seem to have any test which is affected by that. I'll look for another propagation path to something for which I can test (currently checking new_with_extra_data -> CSSRule::parse -> ...), as with limited scope of the codebase, I'm not keen to propose PRs without tests.

@upsuper
Copy link
Member Author

@upsuper upsuper commented Mar 5, 2017

I guess you can start with adding a branch to the parse_longhand macro to make it accept an optional quirks mode parameter, and then add some assertions to parsing tests of corresponding properties.

I think wpt test unitless-length.html depends on path via Stylesheet::update_from_str. But since it uses elem.textContent to update the style text, whether it works may depend on other features, so I wouldn't bet too much on that...

@upsuper
Copy link
Member Author

@upsuper upsuper commented Mar 5, 2017

For testing attribute_mutated, the best way is probably having a quirks mode document which use elem.setAttribute('style', sometestcode);. Not sure where is the best place to put it... Probably new reftests in wpt or wpt/mozilla.

@jdm do you have any suggestion?

@absoludity
Copy link
Contributor

@absoludity absoludity commented Mar 5, 2017

Yeah, unit tests of the properties themselves are straight forward (already in the branch for background-position-x, though that's a good idea for updating parse_longhand to accept quirks mode - I'll update to that), but I'd feel safer if I could test the integration also (where I'm pushing the quirks_mode arg up to attribute_mutated in this case). Thanks either way - I'll keep experimenting.

@jdm
Copy link
Member

@jdm jdm commented Mar 5, 2017

Until we can modify css-tests, integration tests belong in tests/wpt/mozilla/tests.

@bholley
Copy link
Contributor

@bholley bholley commented Mar 13, 2017

@absoludity, any updates here?

@absoludity
Copy link
Contributor

@absoludity absoludity commented Mar 13, 2017

@bholley No sorry - been super busy both with work and outside work lately, so I've not done anything since the two commits on my test-quirks branch https://github.com/absoludity/servo/tree/test-quirks

If you're in a position to give this attention now, great - I'm happy to join in again when I get time (hopefully about 1 week from now my evenings should be a little more free). My main aim with the initial branch was to find a way to ensure the changes result in a (new) failing test then passing. I was looking at adding tests/wpt/mozilla/tests as above, based on the wpt quirks test for unitless-length.html, which would do this.

@bholley
Copy link
Contributor

@bholley bholley commented Mar 13, 2017

I'm just going through all the issues that we need to ship Servo's CSS engine in Firefox, and this is one of the ones we're hoping to knock out in the next couple of weeks. If you can get back to this in a week or so that sounds awesome! Really appreciate your help. :-)

@absoludity
Copy link
Contributor

@absoludity absoludity commented Apr 2, 2017

@bholley, @upsuper Sorry - I've not had spare time to do servo work and due to changes in circumstances I'll need to focus on other things for the next months in any spare time that I have. Hopefully someone else can pick this up.

@bholley
Copy link
Contributor

@bholley bholley commented Apr 2, 2017

Ok - thanks for letting us know! We'll try to find a new owner for this.

@nox nox self-assigned this Apr 22, 2017
@nox nox added the C-assigned label Apr 22, 2017
@stshine
Copy link
Contributor

@stshine stshine commented Apr 28, 2017

@nox should this be closed now?

@nox
Copy link
Member

@nox nox commented May 15, 2017

Yes.

@nox nox closed this May 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.