Summary: | Fix Aspect Ratio Property Inheritance And Make the Computed Value Equal the Specified Value | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Fady Samuel <fsamuel> | ||||||||||||||
Component: | Layout and Rendering | Assignee: | Fady Samuel <fsamuel> | ||||||||||||||
Status: | RESOLVED FIXED | ||||||||||||||||
Severity: | Normal | CC: | dglazkov, macpherson, ojan, tabatkins, webkit.review.bot | ||||||||||||||
Priority: | P2 | ||||||||||||||||
Version: | 528+ (Nightly build) | ||||||||||||||||
Hardware: | Unspecified | ||||||||||||||||
OS: | Unspecified | ||||||||||||||||
Bug Depends on: | |||||||||||||||||
Bug Blocks: | 47738 | ||||||||||||||||
Attachments: |
|
Description
Fady Samuel
2011-11-23 11:55:11 PST
Created attachment 116401 [details]
Patch
Comment on attachment 116401 [details] Patch Can you add a test for this? The computed style on an element that inherits the value should be wrong without this patch, right? Also, now that I think about it, it doesn't make sense to me that this value would inherit. http://www.xanthir.com/blog/b4810 doesn't say whether it should, but I think it probably shouldn't. Maybe bring this up on www-style and then we'll probably want to delete this chunk of code. (In reply to comment #2) > (From update of attachment 116401 [details]) > Can you add a test for this? The computed style on an element that inherits the value should be wrong without this patch, right? > > Also, now that I think about it, it doesn't make sense to me that this value would inherit. http://www.xanthir.com/blog/b4810 doesn't say whether it should, but I think it probably shouldn't. Maybe bring this up on www-style and then we'll probably want to delete this chunk of code. I spoke to Tab about this a few days ago: http://www.w3.org/TR/CSS2/cascade.html#value-def-inherit He says inherit should work for every property and "6.2.1 The 'inherit' value" seems to suggest the same thing. This is broken on IE up to version 8 according to some sources, however. The *value* 'inherit' is a global value that every property accepts. 'aspect-ratio' should not inherit by default, though. Created attachment 116415 [details]
Patch
(In reply to comment #2) > (From update of attachment 116401 [details]) > Can you add a test for this? The computed style on an element that inherits the value should be wrong without this patch, right? > I added a test for parsing, but I realized I should've (as you said) add a test that checks the computed style. I will do that now, thanks. (In reply to comment #6) > (In reply to comment #2) > > (From update of attachment 116401 [details] [details]) > > Can you add a test for this? The computed style on an element that inherits the value should be wrong without this patch, right? > > > > I added a test for parsing, but I realized I should've (as you said) add a test that checks the computed style. I will do that now, thanks. Yup. Both tests would be good. For the computed style tests, can you check both that we do inherit when the value is inherit and that we don't inherit when it's not? Comment on attachment 116415 [details] Patch Attachment 116415 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/10645020 New failing tests: fast/css/aspect-ratio-parsing-tests.html Created attachment 116458 [details]
Patch
(In reply to comment #9) > Created an attachment (id=116458) [details] > Patch Fixed the computed value of -webkit-aspect-ratio as well after a discussion with Tab. Comment on attachment 116458 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=116458&action=review C++ code is all fine except for the include. A bunch of nits about the test. > Source/WebCore/css/CSSComputedStyleDeclaration.cpp:56 > +#include "RenderStyle.h" Is this include necessary? > LayoutTests/fast/css/aspect-ratio-inheritance.html:1 > +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> should use the html doctype <!DOCTYPE html> > LayoutTests/fast/css/aspect-ratio-inheritance.html:4 > + <link rel="stylesheet" href="../../fast/js/resources/js-test-style.css"> You don't need the stylesheet. It's automatically inserted. Also, I'd drop the head element as well and just use a div instead of the body element. > LayoutTests/fast/css/aspect-ratio-inheritance.html:9 > + <body style="-webkit-aspect-ratio: 1 / 2;"> > + <div id="aspectRatioTest"></div> There's no official style for webkit tests, but it makes sense to be consistent where we can. In this case, 4-space indent. Also, typically we don't indent the top-level elements since every page has them. So, the html, head, body elements and their immediate children are usually not indented. > LayoutTests/fast/css/aspect-ratio-inheritance.html:21 > + <script> > + function testComputedValue(elementId, value, styleAttribute) > + { > + var div = document.getElementById(elementId); > + div.style[styleAttribute] = value; > + var computedValue = window.getComputedStyle(div)[styleAttribute]; > + return computedValue; > + } > + shouldBeEqualToString('testComputedValue("aspectRatioTest", "1 / 4", "-webkit-aspect-ratio")', '1/4'); > + shouldBeEqualToString('testComputedValue("aspectRatioTest", "inherit", "-webkit-aspect-ratio")', '1/2'); > + shouldBeEqualToString('testComputedValue("aspectRatioTest", "none", "-webkit-aspect-ratio")', 'none'); > + </script> This is indented more than the script element below it. Comment on attachment 116458 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=116458&action=review Will make the changes momentarily. I'm just confused about the include comment thanks. >> Source/WebCore/css/CSSComputedStyleDeclaration.cpp:56 >> +#include "RenderStyle.h" > > Is this include necessary? Are we not supposed to include what we use? Certainly we're using RenderStyle... Comment on attachment 116458 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=116458&action=review >> LayoutTests/fast/css/aspect-ratio-inheritance.html:1 >> +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> > > should use the html doctype > <!DOCTYPE html> Done. >> LayoutTests/fast/css/aspect-ratio-inheritance.html:4 >> + <link rel="stylesheet" href="../../fast/js/resources/js-test-style.css"> > > You don't need the stylesheet. It's automatically inserted. Also, I'd drop the head element as well and just use a div instead of the body element. Removed the stylesheet (sorry, been using other layout tests as templates. If I drop the head element, where do I place the pre script? Also, getting rid of the body seems odd (is this valid HTML?). I moved the -webkit-aspect-ratio property to a parent div instead of body though. >> LayoutTests/fast/css/aspect-ratio-inheritance.html:9 >> + <div id="aspectRatioTest"></div> > > There's no official style for webkit tests, but it makes sense to be consistent where we can. In this case, 4-space indent. > > Also, typically we don't indent the top-level elements since every page has them. So, the html, head, body elements and their immediate children are usually not indented. Done. >> LayoutTests/fast/css/aspect-ratio-inheritance.html:21 >> + </script> > > This is indented more than the script element below it. Done. Created attachment 116473 [details]
Patch
Could someone please explain why this is stored as two values instead of just a single floating point value? (In reply to comment #15) > Could someone please explain why this is stored as two values instead of just a single floating point value? The specified value has to show both the numerator and denominator so we must store them separately soemwhere. (In reply to comment #16) > (In reply to comment #15) > > Could someone please explain why this is stored as two values instead of just a single floating point value? > > The specified value has to show both the numerator and denominator so we must store them separately soemwhere. Does anyone object to landing this patch and then iterating over it as Tab Atkins, Luke Macpherson, and I iterate on the details of the spec? (In reply to comment #13) > (From update of attachment 116458 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=116458&action=review > >> LayoutTests/fast/css/aspect-ratio-inheritance.html:4 > >> + <link rel="stylesheet" href="../../fast/js/resources/js-test-style.css"> > > > > You don't need the stylesheet. It's automatically inserted. Also, I'd drop the head element as well and just use a div instead of the body element. > > Removed the stylesheet (sorry, been using other layout tests as templates. If I drop the head element, where do I place the pre script? Also, getting rid of the body seems odd (is this valid HTML?). I moved the -webkit-aspect-ratio property to a parent div instead of body though. Getting rid of the body is perfectly valid HTML. It gets created automatically. I typically write tests like follows: <!DOCTYPE html> <script src="path/to/js-test-pre.js"></script> <div></div> <---- test content here. <script src="path/to/js-test-post.js"></script> There's no need for html/body/head elements unless your test-case specifically requires them. Created attachment 116803 [details]
Patch
Created attachment 116804 [details]
Patch
Comment on attachment 116804 [details] Patch Clearing flags on attachment: 116804 Committed r101275: <http://trac.webkit.org/changeset/101275> All reviewed patches have been landed. Closing bug. |