Unminifying CSS lines starting by a comment.
Categories
(DevTools :: Style Editor, defect, P3)
Tracking
(firefox68 fixed)
Tracking | Status | |
---|---|---|
firefox68 | --- | fixed |
People
(Reporter: karlcow, Assigned: daisuke)
References
(Blocks 1 open bug)
Details
Attachments
(3 files, 2 obsolete files)
Comment 1•9 years ago
|
||
Updated•6 years ago
|
Updated•6 years ago
|
Comment 3•6 years ago
|
||
Comment 4•6 years ago
|
||
Comment 5•6 years ago
|
||
Comment 6•6 years ago
|
||
Assignee | ||
Comment 7•6 years ago
|
||
Assignee | ||
Comment 8•6 years ago
|
||
Hi Patrick!
I have made a prototype, couldn't you give your feedback?
If this approach is not bad, can we change the our tests as well? Or should we keep the spec?
Thanks!
Comment 9•6 years ago
|
||
It seems to me that this patch lexes the input CSS twice.
That is going to be somewhat expensive.
Maybe a better heuristic here would be to only count newlines
that aren't immediately before or after a comment. That could
be done without lexing twice.
Assignee | ||
Comment 10•6 years ago
|
||
Thank you very much for the feedback, Tom!
Yes, I agree this is expensive, so I'll do without the rexer.
The reason why I had choosen this approach is that I found similar issues and want to fix at same time.
1 . For example, when we see the below example in StyleEditor, the CSS properties will not be prettified.
#information_adchoices_link{
float:left;padding-right:5px;color:#000;display:none}
However, in case of below, we can see prettified contents.
#information_adchoices_link{float:left;padding-right:5px;color:#000;display:none}
2 . Also, below example as well will not be prettified.
/*
* comment
*/#information_adchoices_link{float:left;padding-right:5px;color:#000;display:none}
I thought the expected result is like below:
/*
* comment
*/
#information_adchoices_link{
float:left;
padding-right:5px;
color:#000;
display:none;
}
Thus, before prettifying, I minimized CSS properties part and added a line after comment.
So, at first, I'll fix this comments issue with your suggestion. Then want to fix another issue like above in other patches if needed.
Comment 11•6 years ago
|
||
I wonder if we need a heuristic at all. Would it be a problem if we just always beautified stylesheets?
It would, of course, if they were already formatted nicely. The formatting would change a little, and the stylesheet would end up looking a tiny bit different from the author wrote, and that might be odd.
The initial patch does that I think, right? It doesn't care about checking if the stylesheet is already formatted or not, it minifies it, and then goes from there to re-beautify it.
Of course, we could do this as Tom suggested in comment 4 and only beautify when the user requests it. So by default we wouldn't do anything, and would just wait for the user to press a button to beautify the code.
Now, this would have other consequences. Mostly benefits actually: for instance when linking CSS warnings from the console to the style-editor, the auto-beautifying messes things up as we can't find the right line/column since those changed.
But it would have an obvious user impact that might be perceived negatively too. Suddenly stylesheets aren't easy to scan anymore and one more action is required.
I know that, at least, this would make it harder for the webcompat team to do their jobs.
I think this is, ultimately, a product call. So in the meantime, it'd be good to investigate if we can, as Tom proposed, just address this bug, without extra processing cost, and without big user impacts.
If not, then let's take it to product to take a decision on whether we want to always auto-beautify, or only do it on a user action.
Assignee | ||
Comment 12•6 years ago
|
||
Okay, in this time, I think I can fix only an issue of comment which has multiple lines without big effects.
Thank you very much for your direction!
Assignee | ||
Comment 13•6 years ago
|
||
Hello Tom, thank you for your advice!
I will ready a first patch according to your proposal tomorrow.
So, if possible, I want to you to take this review. May I request to review to you?
Thanks!
Comment 14•6 years ago
|
||
(In reply to Daisuke Akatsuka (:daisuke) from comment #10)
1 . For example, when we see the below example in StyleEditor, the CSS properties will not be prettified.
#information_adchoices_link{ float:left;padding-right:5px;color:#000;display:none}
Yeah. The heuristic approach will always have some limitation.
I tend to think that this is fine, provided that it does the right
thing for the output of the most common minifiers. E.g., if you
wrote this example by hand, then I would say there's no real need
to handle it; but if this is the actual output of a minifier, then
an extension to the heuristic would make sense.
What do you think of that?
You should probably request review from someone else, I doubt I can
push to try any more and I'm really just doing some drive-by comments.
That said, I'm happy to look at the patches of course.
Assignee | ||
Comment 15•6 years ago
|
||
(In reply to Tom Tromey :tromey from comment #14)
(In reply to Daisuke Akatsuka (:daisuke) from comment #10)
1 . For example, when we see the below example in StyleEditor, the CSS properties will not be prettified.
#information_adchoices_link{ float:left;padding-right:5px;color:#000;display:none}
Yeah. The heuristic approach will always have some limitation.
I tend to think that this is fine, provided that it does the right
thing for the output of the most common minifiers. E.g., if you
wrote this example by hand, then I would say there's no real need
to handle it; but if this is the actual output of a minifier, then
an extension to the heuristic would make sense.
Thank you for replying!
I understood the thinking. For me, I'm a bit concerned about the consistency of whether we apply prettifying or not by depending on the CSS. Thus, as you and Patrick said, I think that it makes sense that at first CSS displays as it is, then prettify when user acts explicitly. I'd like to discuss more in another bug.
You should probably request review from someone else, I doubt I can
push to try any more and I'm really just doing some drive-by comments.
That said, I'm happy to look at the patches of course.
Okay, understood!
Assignee | ||
Comment 16•6 years ago
|
||
Assignee | ||
Comment 17•6 years ago
|
||
Depends on D24118
Updated•6 years ago
|
Updated•6 years ago
|
Comment 18•6 years ago
|
||
Comment 19•6 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/9c404dce8474
https://hg.mozilla.org/mozilla-central/rev/168ced563105
Description
•